diff options
author | chai <chaifix@163.com> | 2021-11-08 09:23:38 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2021-11-08 09:23:38 +0800 |
commit | 138d3f4d3d6e2aaf5ba34f89af15ef85ea074357 (patch) | |
tree | 31ca6e8ea6d2e960e8d35f801bd92555942822e2 /Runtime/Lua/LuaBind/LuaBindInvoker.h | |
parent | efce5b6bd5c9d4f8214a71e0f7a7c35751710a4c (diff) |
*misc
Diffstat (limited to 'Runtime/Lua/LuaBind/LuaBindInvoker.h')
-rw-r--r-- | Runtime/Lua/LuaBind/LuaBindInvoker.h | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/Runtime/Lua/LuaBind/LuaBindInvoker.h b/Runtime/Lua/LuaBind/LuaBindInvoker.h new file mode 100644 index 0000000..8ea57a2 --- /dev/null +++ b/Runtime/Lua/LuaBind/LuaBindInvoker.h @@ -0,0 +1,77 @@ +#ifndef LUA_BIND_INVOKER_H +#define LUA_BIND_INVOKER_H + +#include "LuaBindRef.h" +#include "LuaBindTable.h" +#include "LuaBindClass.hpp" + +namespace LuaBind +{ + + // 调用全局lua方法 + struct GlobalInvoker + { + GlobalInvoker(lua_State* st) + : state(st) + { + argc = 0; + } + UniversalRef method; + + void AddInt(int n); + void AddFloat(float n); + void AddNil(); + void AddBool(bool b); + void AddString(const char* str); + void AddTable(INativeTable& tb); + template<class T> + void AddUserdata(NativeClass<T>& udata) { + udata.PushUserdata(state); + ++argc; + } + + void Invoke(int nReturns); + + private: + State state; + int argc; + }; + + // 调用成员的方法 + struct MemberInvoker + { + MemberRef member; + const char* method; + + MemberInvoker(lua_State* st, LuaBind::Object* owner) + : state(st) + { + argc = 0; + this->owner = owner; + } + + void AddMember(MemberRef member); + void AddInt(int n); + void AddFloat(float n); + void AddNil(); + void AddBool(bool b); + void AddString(const char* str); + void AddTable(INativeTable& tb); + template<class T> + void AddUserdata(NativeClass<T>& udata) { + udata.PushUserdata(state); + ++argc; + } + + void Invoke(int nReturns); + + private: + LuaBind::Object* owner; + State state; + int argc; + + }; + +} + +#endif
\ No newline at end of file |