From 32345800737b668011a87328cd3dcce59ec2934c Mon Sep 17 00:00:00 2001 From: chai Date: Tue, 26 Oct 2021 11:27:58 +0800 Subject: *misc --- Runtime/Scripting/Common/Common.bind.cpp | 14 ++++++++++++ Runtime/Scripting/Common/DataBuffer.bind.cpp | 19 +++++++++++++++++ Runtime/Scripting/Path.bind.cpp | 32 ---------------------------- Runtime/Scripting/Path/Path.bind.cpp | 32 ++++++++++++++++++++++++++++ 4 files changed, 65 insertions(+), 32 deletions(-) create mode 100644 Runtime/Scripting/Common/Common.bind.cpp create mode 100644 Runtime/Scripting/Common/DataBuffer.bind.cpp delete mode 100644 Runtime/Scripting/Path.bind.cpp create mode 100644 Runtime/Scripting/Path/Path.bind.cpp (limited to 'Runtime/Scripting') diff --git a/Runtime/Scripting/Common/Common.bind.cpp b/Runtime/Scripting/Common/Common.bind.cpp new file mode 100644 index 0000000..081426d --- /dev/null +++ b/Runtime/Scripting/Common/Common.bind.cpp @@ -0,0 +1,14 @@ +#include "Runtime/Lua/LuaHelper.h" +#include "Runtime/Common/DataBuffer.h" + +int luaopen_GameLab(lua_State* L) +{ + LUA_BIND_STATE(L); + + state.PushGlobalNamespace(); + state.PushNamespace("GameLab"); + + state.RegisterNativeClass(); + + return 1; +} \ No newline at end of file diff --git a/Runtime/Scripting/Common/DataBuffer.bind.cpp b/Runtime/Scripting/Common/DataBuffer.bind.cpp new file mode 100644 index 0000000..5a5c30a --- /dev/null +++ b/Runtime/Scripting/Common/DataBuffer.bind.cpp @@ -0,0 +1,19 @@ +#include "Runtime/Common/DataBuffer.h" + +LUA_BIND_REGISTRY(DataBuffer) +{ + LUA_BIND_REGISTER_METHODS(state, + { "GetLength", _GetLength } + ); +} + +LUA_BIND_POSTPROCESS(DataBuffer) +{ +} + +LUA_BIND_IMPL_METHOD(DataBuffer, _GetLength) +{ + LUA_BIND_PREPARE(L, DataBuffer); + state.Push(self->length); + return 1; +} \ No newline at end of file diff --git a/Runtime/Scripting/Path.bind.cpp b/Runtime/Scripting/Path.bind.cpp deleted file mode 100644 index 920f586..0000000 --- a/Runtime/Scripting/Path.bind.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include "Runtime/Lua/LuaBind/LuaBind.h" - -#ifdef GAMELAB_WIN -#include -#endif - -using namespace LuaBind; - -static int GetRootDirectory(lua_State* L) -{ -#ifdef GAMELAB_WIN - char path[MAX_PATH]; - GetCurrentDirectory(MAX_PATH, path); - lua_pushstring(L, path); - return 1; -#else - return 0; -#endif -} - -int luaopen_GameLab_Path(lua_State* L) -{ - LUA_BIND_STATE(L); - - state.PushGlobalNamespace(); - state.PushNamespace("GameLab"); - state.PushNamespace("Path"); - - state.RegisterMethod("GetRootDirectory", GetRootDirectory); - - return 1; -} diff --git a/Runtime/Scripting/Path/Path.bind.cpp b/Runtime/Scripting/Path/Path.bind.cpp new file mode 100644 index 0000000..920f586 --- /dev/null +++ b/Runtime/Scripting/Path/Path.bind.cpp @@ -0,0 +1,32 @@ +#include "Runtime/Lua/LuaBind/LuaBind.h" + +#ifdef GAMELAB_WIN +#include +#endif + +using namespace LuaBind; + +static int GetRootDirectory(lua_State* L) +{ +#ifdef GAMELAB_WIN + char path[MAX_PATH]; + GetCurrentDirectory(MAX_PATH, path); + lua_pushstring(L, path); + return 1; +#else + return 0; +#endif +} + +int luaopen_GameLab_Path(lua_State* L) +{ + LUA_BIND_STATE(L); + + state.PushGlobalNamespace(); + state.PushNamespace("GameLab"); + state.PushNamespace("Path"); + + state.RegisterMethod("GetRootDirectory", GetRootDirectory); + + return 1; +} -- cgit v1.1-26-g67d0