aboutsummaryrefslogtreecommitdiff
path: root/src/lua/common/Proxy.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/lua/common/Proxy.h')
-rw-r--r--src/lua/common/Proxy.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/lua/common/Proxy.h b/src/lua/common/Proxy.h
new file mode 100644
index 0000000..60658ec
--- /dev/null
+++ b/src/lua/common/Proxy.h
@@ -0,0 +1,46 @@
+#ifndef __JIN_COMMON_PROXY_H
+#define __JIN_COMMON_PROXY_H
+
+#include "Reference.hpp"
+
+namespace jin
+{
+namespace lua
+{
+
+ class Proxy
+ {
+ public:
+ void bind(Reference* ref, const char* t)
+ {
+ if (ref == nullptr)
+ return;
+ reference = ref;
+ type = t;
+ }
+
+ void release()
+ {
+ if (reference != nullptr)
+ {
+ reference->release();
+ reference = nullptr;
+ type = nullptr;
+ }
+ }
+
+ template<class T>
+ Ref<T>& getRef()
+ {
+ return *(Ref<T>*) reference;
+ }
+
+ const char* type; // type name and metatable name
+ Reference* reference; // acctual object binded
+
+ };
+
+} // lua
+} // jin
+
+#endif // __JIN_COMMON_PROXY_H \ No newline at end of file