diff options
author | chai <chaifix@163.com> | 2019-03-14 23:12:54 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2019-03-14 23:12:54 +0800 |
commit | 8644e03586ac9c39741f62cbcbce87b18805538c (patch) | |
tree | 72021765f5262b7f2f7eebe299fd4e1aaa7c89b7 /Source/Samples/LuaxTest/main.cpp | |
parent | 8d8c4ff1664625e7428d0d31cd798d9321680cb2 (diff) |
*大小写
Diffstat (limited to 'Source/Samples/LuaxTest/main.cpp')
-rw-r--r-- | Source/Samples/LuaxTest/main.cpp | 51 |
1 files changed, 45 insertions, 6 deletions
diff --git a/Source/Samples/LuaxTest/main.cpp b/Source/Samples/LuaxTest/main.cpp index fdcf29a..a629da6 100644 --- a/Source/Samples/LuaxTest/main.cpp +++ b/Source/Samples/LuaxTest/main.cpp @@ -53,7 +53,7 @@ void School::RegisterLuaxClass(LuaxState& state) { NULL, NULL } }; - state.Register(regTable); + state.RegisterMethods(regTable); } @@ -101,11 +101,8 @@ int Boy::l_New(lua_State* L) int Boy::l_GetAge(lua_State* L) { LUAX_SETUP(L, "U"); - Boy* self = state.GetLuaUserdata<Boy>(1); - state.Push(self->mAge); - return 1; } @@ -135,7 +132,19 @@ void Boy::RegisterLuaxClass(LuaxState& state) {NULL, NULL} }; - state.Register(regTable); + state.RegisterMethods(regTable); + + // boyİ + LuaxEnum EHabits[] = { + { "Computer", 1}, + { "Buscketball", 2}, + { "Baseball", 3}, + { "Girls", 4}, + {0, 0} + }; + + state.RegisterEnum("EHabits", EHabits); + } void Boy::RegisterLuaxInterface(LuaxState& state) @@ -146,7 +155,21 @@ void Boy::RegisterLuaxInterface(LuaxState& state) {NULL, NULL} }; - state.Register(regTable); + state.RegisterMethods(regTable); +} + +void Boy::RegisterLuaxPostprocess(LuaxState& state) +{ + // boyİ + LuaxEnum EHabits[] = { + { "Computer", 1}, + { "Buscketball", 2}, + { "Baseball", 3}, + { "Girls", 4}, + {0, 0} + }; + + state.RegisterEnum("EHabits", EHabits); } //---------------------------------------------------------------------------------------------------------------- @@ -203,6 +226,11 @@ function main() end print(Asura.SimBoy.Foo()) + print(Asura.EGender.BOY) + --Asura.EGender.BOY = 2 + print(Asura.EGender.BOY) + print(Asura.SimBoy.EHabits.Girls) + print(Asura.EHabits.Girls) end function err(msg) print(msg) @@ -227,6 +255,17 @@ int main() Luax::LuaxState& state = runtime[L].state; state.OpenLibs(); state.PushNamespace("Asura"); + + //עenum + LuaxEnum EGender[] = { + { "BOY", 7 }, + { "GIRL", 8 }, + { "MID", 9 }, + { 0, 0 }, + }; + + state.RegisterEnum("EGender", EGender); + state.PushNamespace("author"); state.SetField(-1, "name", "chai"); state.SetField(-1, "func", func); |