From a68d5cf198a87bb3e14d03dc7347ed52134355d4 Mon Sep 17 00:00:00 2001 From: chai Date: Sat, 18 Aug 2018 13:26:31 +0800 Subject: *update --- src/lua/common/Proxy.h | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/lua/common/Proxy.h (limited to 'src/lua/common/Proxy.h') 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 + Ref& getRef() + { + return *(Ref*) 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 -- cgit v1.1-26-g67d0