diff options
author | chai <chaifix@163.com> | 2018-08-18 13:26:31 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2018-08-18 13:26:31 +0800 |
commit | a68d5cf198a87bb3e14d03dc7347ed52134355d4 (patch) | |
tree | 90caa0e10762a3795eb9a835e5678cbfd4507fdb /src/lua/common/Proxy.h | |
parent | e257f98dbf5c0064037b966a353e0eb1ffcba0a8 (diff) |
*update
Diffstat (limited to 'src/lua/common/Proxy.h')
-rw-r--r-- | src/lua/common/Proxy.h | 46 |
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 |