diff options
author | chai <chaifix@163.com> | 2018-11-22 08:42:31 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2018-11-22 08:42:31 +0800 |
commit | 1b25709b10cf92007096949f002b4941517eb749 (patch) | |
tree | 1f7a99938e17104d332e2547b99be95f853e2914 /src/lua/common/je_lua_proxy.h | |
parent | 07022c42a925d4d0c23ab31f0e75883766ce773a (diff) |
*注册lua对象
Diffstat (limited to 'src/lua/common/je_lua_proxy.h')
-rw-r--r-- | src/lua/common/je_lua_proxy.h | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/src/lua/common/je_lua_proxy.h b/src/lua/common/je_lua_proxy.h index 2914533..5541a5a 100644 --- a/src/lua/common/je_lua_proxy.h +++ b/src/lua/common/je_lua_proxy.h @@ -29,13 +29,7 @@ namespace JinEngine shared = nullptr; } } -/* - void retain() - { - if (shared != nullptr) - shared->retain(); - } -*/ + template<class T> Shared<T>& getShared() { @@ -62,9 +56,12 @@ namespace JinEngine }; - inline Proxy* luax_newinstance(lua_State* L, const char* type) + inline Proxy* luax_newinstance(lua_State* L, const char* type, SharedBase* shared = nullptr) { - return static_cast<Proxy*>(luax_newinstance(L, type, sizeof(Proxy))); + Proxy* proxy = static_cast<Proxy*>(luax_newinstance(L, type, sizeof(Proxy))); + if(shared) + proxy->bind(shared); + return proxy; } } // namespace Lua |