From b1bbc998960fff2169dc5a992c47d08723472f9b Mon Sep 17 00:00:00 2001 From: chai Date: Sun, 14 Oct 2018 22:52:40 +0800 Subject: =?UTF-8?q?*=E7=9B=B4=E6=8E=A5=E6=B8=B2=E6=9F=93=E5=AD=97=E7=AC=A6?= =?UTF-8?q?=E4=B8=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lua/common/Proxy.h | 12 ++++++++++++ src/lua/common/Reference.hpp | 12 +++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) (limited to 'src/lua/common') diff --git a/src/lua/common/Proxy.h b/src/lua/common/Proxy.h index 101fe9c..643dd48 100644 --- a/src/lua/common/Proxy.h +++ b/src/lua/common/Proxy.h @@ -27,6 +27,18 @@ namespace lua } } + void retain() + { + if (reference != nullptr) + reference->retain(); + } + + void setUserdata(void* data) + { + if (reference != nullptr) + reference->setUserdata(data); + } + template Ref& getRef() { diff --git a/src/lua/common/Reference.hpp b/src/lua/common/Reference.hpp index feb96bb..bd9dc24 100644 --- a/src/lua/common/Reference.hpp +++ b/src/lua/common/Reference.hpp @@ -23,6 +23,16 @@ namespace lua // object type string const char* const type; + void setUserdata(void* data) + { + userdata = data; + } + + void* getUserdata() + { + return userdata; + } + protected: RefBase(void* obj, const char* t) : count(1) @@ -39,7 +49,7 @@ namespace lua void* object; int count; - + void* userdata; }; template -- cgit v1.1-26-g67d0