diff options
Diffstat (limited to 'Runtime/Lua')
-rw-r--r-- | Runtime/Lua/LuaBind/LuaBindInvoker.h | 6 | ||||
-rw-r--r-- | Runtime/Lua/LuaBind/LuaBindLClass.h | 12 | ||||
-rw-r--r-- | Runtime/Lua/LuaBind/LuaBindState.h | 4 |
3 files changed, 22 insertions, 0 deletions
diff --git a/Runtime/Lua/LuaBind/LuaBindInvoker.h b/Runtime/Lua/LuaBind/LuaBindInvoker.h index 5f24b15..cbfb2f9 100644 --- a/Runtime/Lua/LuaBind/LuaBindInvoker.h +++ b/Runtime/Lua/LuaBind/LuaBindInvoker.h @@ -59,6 +59,12 @@ namespace LuaBind udata.PushUserdata(state); ++argc; } + template<class T> + void AddLuaObject(T& obj) { + //LuaObjectTransfer::CastToLuaObject<T>(state, obj); + obj.CastToLuaObject(state); + ++argc; + } void Invoke(int nReturns = 0); diff --git a/Runtime/Lua/LuaBind/LuaBindLClass.h b/Runtime/Lua/LuaBind/LuaBindLClass.h index 296d6a1..538941e 100644 --- a/Runtime/Lua/LuaBind/LuaBindLClass.h +++ b/Runtime/Lua/LuaBind/LuaBindLClass.h @@ -14,4 +14,16 @@ namespace LuaBind };
+ class LuaObjectTransfer
+ {
+ public:
+ // 或者特化这些方法
+ template <class T>
+ static void CastToLuaObject(State&, T& in);
+
+ template <class T>
+ static void RestoreFromLuaObject(State& state, int index, T& out);
+
+ };
+
}
diff --git a/Runtime/Lua/LuaBind/LuaBindState.h b/Runtime/Lua/LuaBind/LuaBindState.h index e8ac42d..680f6e2 100644 --- a/Runtime/Lua/LuaBind/LuaBindState.h +++ b/Runtime/Lua/LuaBind/LuaBindState.h @@ -104,6 +104,10 @@ namespace LuaBind bool HasField(int idx, int name, int type); bool HasKeys(int idx); + template <class T> + void PushLuaObject(const T& obj) { + obj.CastToLuaObject(*this); + } void PushLuaObject(const ILuaClass& lc); void PushTable(const INativeTable& tb); void PushNil(); |