summaryrefslogtreecommitdiff
path: root/Runtime/Lua/LuaBind/LuaBindInvoker.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Runtime/Lua/LuaBind/LuaBindInvoker.cpp')
-rw-r--r--Runtime/Lua/LuaBind/LuaBindInvoker.cpp105
1 files changed, 105 insertions, 0 deletions
diff --git a/Runtime/Lua/LuaBind/LuaBindInvoker.cpp b/Runtime/Lua/LuaBind/LuaBindInvoker.cpp
new file mode 100644
index 0000000..debebf8
--- /dev/null
+++ b/Runtime/Lua/LuaBind/LuaBindInvoker.cpp
@@ -0,0 +1,105 @@
+#include "LuaBindInvoker.h"
+
+namespace LuaBind
+{
+
+ void GlobalInvoker::AddInt(int n)
+ {
+ state.Push(n);
+ ++argc;
+ }
+
+ void GlobalInvoker::AddFloat(float n)
+ {
+ state.Push(n);
+ ++argc;
+ }
+
+ void GlobalInvoker::AddNil()
+ {
+ state.PushNil();
+ ++argc;
+ }
+
+ void GlobalInvoker::AddBool(bool b)
+ {
+ state.Push(b);
+ ++argc;
+ }
+
+ void GlobalInvoker::AddString(const char* str)
+ {
+ state.Push(str);
+ ++argc;
+ }
+
+ void GlobalInvoker::AddTable(INativeTable& tb)
+ {
+ tb.CastToTable(state);
+ ++argc;
+ }
+
+ void GlobalInvoker::Invoke(int nReturns)
+ {
+ method.PushRef(state);
+ state.Call(argc, nReturns, onErrorOccured);
+ }
+
+
+ void MemberInvoker::AddInt(int n)
+ {
+ state.Push(n);
+ ++argc;
+ }
+
+ void MemberInvoker::AddFloat(float n)
+ {
+ state.Push(n);
+ ++argc;
+ }
+
+ void MemberInvoker::AddNil()
+ {
+ state.PushNil();
+ ++argc;
+ }
+
+ void MemberInvoker::AddBool(bool b)
+ {
+ state.Push(b);
+ ++argc;
+ }
+
+ void MemberInvoker::AddString(const char* str)
+ {
+ state.Push(str);
+ ++argc;
+ }
+
+ void MemberInvoker::AddTable(INativeTable& tb)
+ {
+ tb.CastToTable(state);
+ ++argc;
+ }
+
+ void MemberInvoker::AddMember(MemberRef member)
+ {
+ owner->PushMemberRef(state, member);
+ ++argc;
+ }
+
+ void MemberInvoker::Invoke(int nReturns)
+ {
+ owner->PushMemberRef(state, member);
+ state.GetField(-1, method);
+ if (!state.IsType(-1, LUA_TFUNCTION))
+ {
+ state.Pop(2);
+ return;
+ }
+ lua_replace(state, -2);
+ lua_insert(state, -1 - argc);
+ state.Call(argc, nReturns, onErrorOccured);
+ }
+
+}