From f706f0e17ac2e7893feddc96b496db89f35e94a8 Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 10 Nov 2021 19:49:15 +0800 Subject: *misc --- Runtime/Lua/LuaBind/LuaBindInvoker.cpp | 4 ++-- Runtime/Lua/LuaBind/LuaBindInvoker.h | 12 ++++-------- Runtime/Lua/LuaBind/LuaBindLFunction.h | 21 +++++++++++++++++++++ 3 files changed, 27 insertions(+), 10 deletions(-) create mode 100644 Runtime/Lua/LuaBind/LuaBindLFunction.h (limited to 'Runtime/Lua') diff --git a/Runtime/Lua/LuaBind/LuaBindInvoker.cpp b/Runtime/Lua/LuaBind/LuaBindInvoker.cpp index a95ef5c..bd12e5c 100644 --- a/Runtime/Lua/LuaBind/LuaBindInvoker.cpp +++ b/Runtime/Lua/LuaBind/LuaBindInvoker.cpp @@ -43,9 +43,9 @@ namespace LuaBind { method.PushRef(state); state.Call(argc, nReturns, onErrorOccured); + argc = 0; } - - + void MemberInvoker::AddInt(int n) { state.Push(n); diff --git a/Runtime/Lua/LuaBind/LuaBindInvoker.h b/Runtime/Lua/LuaBind/LuaBindInvoker.h index edb0725..45a4e63 100644 --- a/Runtime/Lua/LuaBind/LuaBindInvoker.h +++ b/Runtime/Lua/LuaBind/LuaBindInvoker.h @@ -11,13 +11,9 @@ namespace LuaBind // 调用全局lua方法 struct GlobalInvoker { - GlobalInvoker(lua_State* st) - : state(st) - { - argc = 0; - } - UniversalRef method; + UniversalRef method; + GlobalInvoker(lua_State* st) : state(st), argc(0) {} void AddInt(int n); void AddFloat(float n); void AddNil(); @@ -30,9 +26,9 @@ namespace LuaBind ++argc; } - void Invoke(int nReturns); + virtual void Invoke(int nReturns); - private: + protected: State state; int argc; }; diff --git a/Runtime/Lua/LuaBind/LuaBindLFunction.h b/Runtime/Lua/LuaBind/LuaBindLFunction.h new file mode 100644 index 0000000..1ad6fa0 --- /dev/null +++ b/Runtime/Lua/LuaBind/LuaBindLFunction.h @@ -0,0 +1,21 @@ +#pragma once +#include "LuaBindInvoker.h" + +namespace LuaBind +{ + struct LuaFunction : public GlobalInvoker + { + const char* method; // full name + + LuaFunction(lua_State* L, const char* func) + : GlobalInvoker(L) + , method(func) + {} + + void Invoke(int nReturns) override + { + + } + }; + +} \ No newline at end of file -- cgit v1.1-26-g67d0