aboutsummaryrefslogtreecommitdiff
path: root/src/lua/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/lua/common')
-rw-r--r--src/lua/common/Proxy.h12
-rw-r--r--src/lua/common/Reference.hpp21
2 files changed, 20 insertions, 13 deletions
diff --git a/src/lua/common/Proxy.h b/src/lua/common/Proxy.h
index 60658ec..8323ead 100644
--- a/src/lua/common/Proxy.h
+++ b/src/lua/common/Proxy.h
@@ -11,12 +11,11 @@ namespace lua
class Proxy
{
public:
- void bind(Reference* ref, const char* t)
+ void bind(RefBase* ref)
{
if (ref == nullptr)
return;
reference = ref;
- type = t;
}
void release()
@@ -25,7 +24,6 @@ namespace lua
{
reference->release();
reference = nullptr;
- type = nullptr;
}
}
@@ -35,8 +33,12 @@ namespace lua
return *(Ref<T>*) reference;
}
- const char* type; // type name and metatable name
- Reference* reference; // acctual object binded
+ const char* getObjectType()
+ {
+ return reference->type;
+ }
+
+ RefBase* reference;
};
diff --git a/src/lua/common/Reference.hpp b/src/lua/common/Reference.hpp
index 7647a3f..feb96bb 100644
--- a/src/lua/common/Reference.hpp
+++ b/src/lua/common/Reference.hpp
@@ -6,7 +6,7 @@ namespace jin
namespace lua
{
- /*abstract*/class Reference
+ /*abstract*/class RefBase
{
public:
void retain()
@@ -20,29 +20,34 @@ namespace lua
delete this;
}
+ // object type string
+ const char* const type;
+
protected:
- Reference(void* obj)
+ RefBase(void* obj, const char* t)
: count(1)
, object(obj)
+ , type(t)
{
}
- Reference(const Reference&);
- virtual ~Reference()
+ RefBase(const RefBase&);
+
+ virtual ~RefBase()
{
}
void* object;
- int count;
+ int count;
};
template<class T>
- class Ref : public Reference
+ class Ref : public RefBase
{
public:
- Ref(T* obj)
- : Reference(obj)
+ Ref(T* obj, const char* type)
+ : RefBase(obj, type)
{
}