Skip to content
Browse files

Added == operator to lua::object

  • Loading branch information...
1 parent 2ae2569 commit c6bf9d13e713dfee402b859f6f9f3ec502146d57 @JakobOvrum committed Jul 15, 2010
Showing with 38 additions and 0 deletions.
  1. +13 −0 luacpp/nil.hpp
  2. +3 −0 luacpp/object.hpp
  3. +3 −0 luacpp/reference.hpp
  4. +3 −0 src/nil.cpp
  5. +16 −0 test/nil.cpp
View
13 luacpp/nil.hpp
@@ -0,0 +1,13 @@
+#ifndef LCPP_NIL_H
+#define LCPP_NIL_H
+
+namespace lua
+{
+ class nil_t
+ {
+ };
+
+ extern nil_t nil;
+}
+
+#endif
View
3 luacpp/object.hpp
@@ -29,6 +29,9 @@ namespace lua
return t;
}
+
+ bool operator==(const reference& r);
+ bool operator==(const nil_t& t);
};
}
View
3 luacpp/reference.hpp
@@ -8,6 +8,8 @@ struct lua_State;
namespace lua
{
+ class object;
+
class reference
{
public:
@@ -35,6 +37,7 @@ namespace lua
int ref;
friend void pushValue(lua_State* L, reference& ref);
+ friend class object;
};
}
View
3 src/nil.cpp
@@ -0,0 +1,3 @@
+#include <luacpp/nil.hpp>
+
+lua::nil_t lua::nil;
View
16 test/nil.cpp
@@ -0,0 +1,16 @@
+#include <luacpp.hpp>
+
+#include <cassert>
+
+int main()
+{
+ lua::state lua;
+
+ lua["foo"] = 1;
+ assert(static_cast<int>(lua["foo"]) == 1);
+
+ lua["foo"] = lua::nil;
+ lua::object foo = lua["foo"];
+
+ assert(foo == lua::nil);
+}

0 comments on commit c6bf9d1

Please sign in to comment.
Something went wrong with that request. Please try again.