diff options
Diffstat (limited to 'Runtime/Lua/LuaBind/LuaBindLFunction.cpp')
-rw-r--r-- | Runtime/Lua/LuaBind/LuaBindLFunction.cpp | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/Runtime/Lua/LuaBind/LuaBindLFunction.cpp b/Runtime/Lua/LuaBind/LuaBindLFunction.cpp new file mode 100644 index 0000000..b468897 --- /dev/null +++ b/Runtime/Lua/LuaBind/LuaBindLFunction.cpp @@ -0,0 +1,63 @@ +#include "LuaBindLFunction.h" +#include "LuaBindHelper.h" + +namespace LuaBind +{ + + LuaFunction::LuaFunction(const char* func) + { + method = func; + } + + void LuaFunction::operator = (const char* func) + { + method = func; + } + + void LuaFunction::AddInt(State& state, int n) + { + state.Push(n); + ++argc; + } + + void LuaFunction::AddFloat(State& state, float n) + { + state.Push(n); + ++argc; + } + + void LuaFunction::AddNil(State& state) + { + state.PushNil(); + ++argc; + } + + void LuaFunction::AddBool(State& state, bool b) + { + state.Push(b); + ++argc; + } + + void LuaFunction::AddString(State& state, const char* str) + { + state.Push(str); + ++argc; + } + + void LuaFunction::AddTable(State& state, INativeTable& tb) + { + tb.CastToTable(state); + ++argc; + } + + void LuaFunction::Invoke(State& state, int nReturns) + { + if (state.GetGlobalField(method)) + { + int funcIdx = -1 - argc; + lua_replace(state, funcIdx); + state.Call(argc, nReturns); + } + } + +}
\ No newline at end of file |