aboutsummaryrefslogtreecommitdiff
path: root/src/libjin-lua/common/l_reference.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/libjin-lua/common/l_reference.h')
-rw-r--r--src/libjin-lua/common/l_reference.h54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/libjin-lua/common/l_reference.h b/src/libjin-lua/common/l_reference.h
new file mode 100644
index 0000000..1a62dba
--- /dev/null
+++ b/src/libjin-lua/common/l_reference.h
@@ -0,0 +1,54 @@
+#ifndef __JIN_COMMON_REFERENCE_H
+#define __JIN_COMMON_REFERENCE_H
+
+#include "common/je_lua.h"
+
+namespace JinEngine
+{
+ namespace Lua
+ {
+
+ ///
+ /// This class wraps the reference functionality built into Lua, which allows C++ code to refer to Lua
+ /// variables.
+ ///
+ class LuaRef
+ {
+ public:
+ ///
+ ///
+ ///
+ LuaRef(lua_State* L, int i);
+
+ ///
+ ///
+ ///
+ ~LuaRef();
+
+ ///
+ ///
+ ///
+ void unref();
+
+ ///
+ /// Push value onto the stack.
+ ///
+ void push();
+
+ private:
+ ///
+ ///
+ ///
+ lua_State* const mL;
+
+ ///
+ ///
+ ///
+ int mIndex;
+
+ };
+
+ } // namespace Lua
+} // namespace JinEngine
+
+#endif // __JIN_COMMON_REFERENCE_H \ No newline at end of file