summaryrefslogtreecommitdiff
path: root/Source/Samples/LuaxTest/main.cpp
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2019-03-12 23:08:31 +0800
committerchai <chaifix@163.com>2019-03-12 23:08:31 +0800
commit6016ece202eef94ed76bd20d4f7879ccc71cc2e6 (patch)
treeda0d0be011ee24489174bde1ec1c436ce7aaa1b2 /Source/Samples/LuaxTest/main.cpp
parent9eba034f5c2ffd49f33d38c283b24230f9e362e0 (diff)
*luax
Diffstat (limited to 'Source/Samples/LuaxTest/main.cpp')
-rw-r--r--Source/Samples/LuaxTest/main.cpp29
1 files changed, 22 insertions, 7 deletions
diff --git a/Source/Samples/LuaxTest/main.cpp b/Source/Samples/LuaxTest/main.cpp
index 828b427..8dc7281 100644
--- a/Source/Samples/LuaxTest/main.cpp
+++ b/Source/Samples/LuaxTest/main.cpp
@@ -36,7 +36,7 @@ public:
int School::l_GetName(lua_State* L)
{
- LuaxState state(L);
+ LUAX_STATE(L);
School* school = Get();
@@ -84,7 +84,7 @@ public:
int Boy::l_New(lua_State* L)
{
- LuaxState state(L);
+ LUAX_STATE(L);
int age = state.GetValue(1, 0);
@@ -97,7 +97,6 @@ int Boy::l_New(lua_State* L)
int Boy::l_GetAge(lua_State* L)
{
LUAX_SETUP(L, "U");
-
return 1;
}
@@ -149,6 +148,19 @@ function main()
print(Asura.SimBoy.GetClassName())
print(Asura.School.GetName())
print(Asura.School.Region)
+--[[
+ local Kid = Asura.SimBoy.Extend()
+ Asura.Kid = Kid
+ Kid.New = function(self, height, age)
+ self.base(age)
+ self.height = height
+ end
+ Kid.GetHeight = function(self)
+ print(self.height)
+ end
+ local kid = Kid.New(110, 12)
+ kid:GetHeight()
+]]
end
function err(msg)
print(msg)
@@ -167,8 +179,11 @@ int func(lua_State* L)
int main()
{
- lua_State* L = lua_open();
- Luax::LuaxState state(L);
+ LuaxRuntime& runtime = LuaxRuntime::Get();
+ lua_State* L = runtime.Open();
+
+ Luax::LuaxState& state = runtime[L].state;
+ LuaxRefTable& strong = runtime[L].strongRefTable;
state.OpenLibs();
state.PushNamespace("Asura");
state.PushNamespace("author");
@@ -183,8 +198,8 @@ int main()
state.PopNamespace(); // Asura
state.DoString(script);
-
- lua_close(L);
+
+ runtime.Close(L);
getchar();
} \ No newline at end of file