diff options
Diffstat (limited to 'source/tests')
-rw-r--r-- | source/tests/02-luax/main.cpp | 10 | ||||
-rw-r--r-- | source/tests/05-physfs/main.cpp | 37 |
2 files changed, 37 insertions, 10 deletions
diff --git a/source/tests/02-luax/main.cpp b/source/tests/02-luax/main.cpp index d5fe3bf..59a4bcb 100644 --- a/source/tests/02-luax/main.cpp +++ b/source/tests/02-luax/main.cpp @@ -15,7 +15,7 @@ extern "C"{ using namespace std; using namespace Luax; -//---------------------------------------------------------------------------------------------------------------- +//--------------------------------------------------------------------------------// class School : public Singleton<School> @@ -64,7 +64,7 @@ void School::RegisterLuaxPostprocess(Luax::LuaxState&) { } -//---------------------------------------------------------------------------------------------------------------- +//--------------------------------------------------------------------------------// class Boy : public LuaxNativeClass<Boy> { @@ -186,7 +186,7 @@ void Boy::RegisterLuaxPostprocess(LuaxState& state) ); } -//---------------------------------------------------------------------------------------------------------------- +//--------------------------------------------------------------------------------// /// /// Ӧsignalıհ /// @@ -253,11 +253,11 @@ private: }; -//---------------------------------------------------------------------------------------------------------------- +//--------------------------------------------------------------------------------// #include "script.lua" -//---------------------------------------------------------------------------------------------------------------- +//--------------------------------------------------------------------------------// int func(lua_State* L) { diff --git a/source/tests/05-physfs/main.cpp b/source/tests/05-physfs/main.cpp index 28e55e9..14a2745 100644 --- a/source/tests/05-physfs/main.cpp +++ b/source/tests/05-physfs/main.cpp @@ -2,10 +2,12 @@ #include <asura-lib-utils/utils.h> -using namespace Luax; using namespace std; +using namespace AEScripting; string code = R"( +local thread = nil +local dst = nil function main() local suc = Filesystem.Init(arg0) print(suc) @@ -24,6 +26,28 @@ function main() print(file:GetExtension()) print(file:GetName()) + dst = DataBuffer.New(138567) + thread = Thread.New("IO thread") + local content = "" + local cont = "ok" + local task = IOTask.New("root/physfs2.txt", dst, EIOTaskType.READ, function(db) + function _r() + print("test..............") + local c = db:GetData() + print(c) + end + function err(msg) + print(msg) + end + xpcall(_r, err) + end) + thread:AddTask(task) + thread:Start() + + print("-------------end-------------") + + print(thread:GetName()) + io.read() end @@ -38,18 +62,21 @@ int main(int argc, char* args[]) { AsuraEngine::UtilsModule utils; - lua_State* L = LuaxRuntime::Get().Open(); - AEScripting::LuaEnv::Get()->Init(L); - LuaxState& state = LuaxRuntime::Get().GetLuaxState(L); + // ÿһasuraһlua stateһһlua߳ + AEScripting::LuaEnv::Get()->Init(); + + Luax::LuaxState& state = LuaEnv::Get()->GetMainLuaxState(); + state.OpenLibs(); state.PushGlobalNamespace(); if(argc > 0) state.SetField(-1, "arg0", args[0]); utils.Initialize(state); state.PopNamespace(); + state.DoString(code); - LuaxRuntime::Get().Close(L); + LuaEnv::Get()->Exit(); return 0; }
\ No newline at end of file |