summaryrefslogtreecommitdiff
path: root/Runtime/Lua/LuaBind
diff options
context:
space:
mode:
Diffstat (limited to 'Runtime/Lua/LuaBind')
-rw-r--r--Runtime/Lua/LuaBind/LuaBind.h1
-rw-r--r--Runtime/Lua/LuaBind/LuaBindInvoker.cpp8
-rw-r--r--Runtime/Lua/LuaBind/LuaBindInvoker.h3
-rw-r--r--Runtime/Lua/LuaBind/LuaBindLClass.h16
-rw-r--r--Runtime/Lua/LuaBind/LuaBindState.cpp7
-rw-r--r--Runtime/Lua/LuaBind/LuaBindState.h4
-rw-r--r--Runtime/Lua/LuaBind/LuaBindTable.h2
7 files changed, 36 insertions, 5 deletions
diff --git a/Runtime/Lua/LuaBind/LuaBind.h b/Runtime/Lua/LuaBind/LuaBind.h
index b6c5870..2a73c98 100644
--- a/Runtime/Lua/LuaBind/LuaBind.h
+++ b/Runtime/Lua/LuaBind/LuaBind.h
@@ -12,5 +12,6 @@
#include "LuaBindState.inc"
#include "LuaBindInvoker.h"
#include "LuaBindTable.h"
+#include "LuaBindLClass.h"
#endif \ No newline at end of file
diff --git a/Runtime/Lua/LuaBind/LuaBindInvoker.cpp b/Runtime/Lua/LuaBind/LuaBindInvoker.cpp
index debebf8..a95ef5c 100644
--- a/Runtime/Lua/LuaBind/LuaBindInvoker.cpp
+++ b/Runtime/Lua/LuaBind/LuaBindInvoker.cpp
@@ -76,12 +76,18 @@ namespace LuaBind
++argc;
}
- void MemberInvoker::AddTable(INativeTable& tb)
+ void MemberInvoker::AddTable(const INativeTable& tb)
{
tb.CastToTable(state);
++argc;
}
+ void MemberInvoker::AddLuaObject(const ILuaClass& obj)
+ {
+ obj.CastToLuaObject(state);
+ ++argc;
+ }
+
void MemberInvoker::AddMember(MemberRef member)
{
owner->PushMemberRef(state, member);
diff --git a/Runtime/Lua/LuaBind/LuaBindInvoker.h b/Runtime/Lua/LuaBind/LuaBindInvoker.h
index 8ea57a2..edb0725 100644
--- a/Runtime/Lua/LuaBind/LuaBindInvoker.h
+++ b/Runtime/Lua/LuaBind/LuaBindInvoker.h
@@ -56,7 +56,8 @@ namespace LuaBind
void AddNil();
void AddBool(bool b);
void AddString(const char* str);
- void AddTable(INativeTable& tb);
+ void AddTable(const INativeTable& tb);
+ void AddLuaObject(const ILuaClass& obj);
template<class T>
void AddUserdata(NativeClass<T>& udata) {
udata.PushUserdata(state);
diff --git a/Runtime/Lua/LuaBind/LuaBindLClass.h b/Runtime/Lua/LuaBind/LuaBindLClass.h
new file mode 100644
index 0000000..9f4c959
--- /dev/null
+++ b/Runtime/Lua/LuaBind/LuaBindLClass.h
@@ -0,0 +1,16 @@
+#pragma once
+
+namespace LuaBind
+{
+
+ class State;
+
+ // 需要转成lua class对象的实现这个接口,创建一个lua的对象,放在栈顶
+ class ILuaClass
+ {
+ public:
+ virtual void CastToLuaObject(State&) const = 0 ;
+
+ };
+
+}
diff --git a/Runtime/Lua/LuaBind/LuaBindState.cpp b/Runtime/Lua/LuaBind/LuaBindState.cpp
index 676c19c..92e46cd 100644
--- a/Runtime/Lua/LuaBind/LuaBindState.cpp
+++ b/Runtime/Lua/LuaBind/LuaBindState.cpp
@@ -196,7 +196,12 @@ namespace LuaBind
}
}
- void State::PushTable(INativeTable& tb)
+ void State::PushLuaObject(const ILuaClass& lc)
+ {
+ lc.CastToLuaObject(*this);
+ }
+
+ void State::PushTable(const INativeTable& tb)
{
tb.CastToTable(*this);
}
diff --git a/Runtime/Lua/LuaBind/LuaBindState.h b/Runtime/Lua/LuaBind/LuaBindState.h
index 24bd092..aaad952 100644
--- a/Runtime/Lua/LuaBind/LuaBindState.h
+++ b/Runtime/Lua/LuaBind/LuaBindState.h
@@ -7,6 +7,7 @@
#include "LuaBindRefTable.h"
#include "LuaBindGlobalState.h"
#include "LuaBindTable.h"
+#include "LuaBindLClass.h"
namespace LuaBind
{
@@ -101,7 +102,8 @@ namespace LuaBind
bool HasField(int idx, int name, int type);
bool HasKeys(int idx);
- void PushTable(INativeTable& tb);
+ void PushLuaObject(const ILuaClass& lc);
+ void PushTable(const INativeTable& tb);
void PushNil();
void Push(bool value);
void Push(cc8* value);
diff --git a/Runtime/Lua/LuaBind/LuaBindTable.h b/Runtime/Lua/LuaBind/LuaBindTable.h
index 3a6ec6c..a3822d3 100644
--- a/Runtime/Lua/LuaBind/LuaBindTable.h
+++ b/Runtime/Lua/LuaBind/LuaBindTable.h
@@ -9,7 +9,7 @@ namespace LuaBind
struct INativeTable
{
// 将结构转换为table并留在栈顶
- virtual void CastToTable(State& state) = 0;
+ virtual void CastToTable(State& state) const = 0;
};
} \ No newline at end of file