diff options
Diffstat (limited to 'src/lua/modules/filesystem')
-rw-r--r-- | src/lua/modules/filesystem/je_lua_filesystem.cpp (renamed from src/lua/modules/filesystem/filesystem.cpp) | 41 | ||||
-rw-r--r-- | src/lua/modules/filesystem/je_lua_filesystem.h | 0 |
2 files changed, 21 insertions, 20 deletions
diff --git a/src/lua/modules/filesystem/filesystem.cpp b/src/lua/modules/filesystem/je_lua_filesystem.cpp index 7466ce8..6245ba8 100644 --- a/src/lua/modules/filesystem/filesystem.cpp +++ b/src/lua/modules/filesystem/je_lua_filesystem.cpp @@ -1,3 +1,4 @@ +#include "lua/common/je_lua_common.h" #include "lua/modules/luax.h" #include "libjin/jin.h" #include <string> @@ -9,25 +10,25 @@ namespace JinEngine namespace Lua { - static struct + LUA_IMPLEMENT struct { AssetDatabase* fs; } context; - static int l_init(lua_State* L) + LUA_IMPLEMENT int l_init(lua_State* L) { context.fs = AssetDatabase::get(); return 0; } - static int l_mount(lua_State* L) + LUA_IMPLEMENT int l_mount(lua_State* L) { const char* path = luax_checkstring(L, 1); context.fs->mount(path); return 0; } - static int l_exist(lua_State * L) + LUA_IMPLEMENT int l_exist(lua_State * L) { const char* path = luax_checkstring(L, 1); int r = context.fs->exists(path); @@ -35,7 +36,7 @@ namespace JinEngine return 1; } - static int l_isDir(lua_State* L) + LUA_IMPLEMENT int l_isDir(lua_State* L) { const char* path = luax_checkstring(L, 1); int r = context.fs->isDir(path); @@ -43,7 +44,7 @@ namespace JinEngine return 1; } - static int l_isFile(lua_State* L) + LUA_IMPLEMENT int l_isFile(lua_State* L) { const char* path = luax_checkstring(L, 1); int r = context.fs->isFile(path); @@ -51,7 +52,7 @@ namespace JinEngine return 1; } - static int loadbuffer(lua_State* L) + LUA_IMPLEMENT int loadbuffer(lua_State* L) { const char* filename = lua_tostring(L, -1); Buffer bf; @@ -60,7 +61,7 @@ namespace JinEngine return 1; } - static int loader(lua_State* L) + LUA_IMPLEMENT int loader(lua_State* L) { const char * filename = lua_tostring(L, -1); @@ -107,7 +108,7 @@ namespace JinEngine return 1; } - static int l_read(lua_State* L) + LUA_IMPLEMENT int l_read(lua_State* L) { AssetDatabase* fs = context.fs; const char* file = luax_checkstring(L, 1); @@ -119,20 +120,20 @@ namespace JinEngine return 2; } - static const luaL_Reg f[] = { - { "init", l_init }, - { "mount", l_mount }, - { "isDirectory", l_isDir }, - { "isFile", l_isFile }, - { "exist", l_exist }, - { "read", l_read }, - { 0, 0 } - }; - - int luaopen_filesystem(lua_State* L) + LUA_EXPORT int luaopen_filesystem(lua_State* L) { + luaL_Reg f[] = { + { "init", l_init }, + { "mount", l_mount }, + { "isDirectory", l_isDir }, + { "isFile", l_isFile }, + { "exist", l_exist }, + { "read", l_read }, + { 0, 0 } + }; luax_newlib(L, f); luax_registersearcher(L, loader, 1); + return 0; } diff --git a/src/lua/modules/filesystem/je_lua_filesystem.h b/src/lua/modules/filesystem/je_lua_filesystem.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/lua/modules/filesystem/je_lua_filesystem.h |