From 1b25709b10cf92007096949f002b4941517eb749 Mon Sep 17 00:00:00 2001 From: chai Date: Thu, 22 Nov 2018 08:42:31 +0800 Subject: =?UTF-8?q?*=E6=B3=A8=E5=86=8Clua=E5=AF=B9=E8=B1=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lua/common/je_lua_proxy.h | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'src/lua/common/je_lua_proxy.h') 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 Shared& 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(luax_newinstance(L, type, sizeof(Proxy))); + Proxy* proxy = static_cast(luax_newinstance(L, type, sizeof(Proxy))); + if(shared) + proxy->bind(shared); + return proxy; } } // namespace Lua -- cgit v1.1-26-g67d0