diff options
Diffstat (limited to 'src/lua/modules/bit')
-rw-r--r-- | src/lua/modules/bit/je_lua_bit.cpp (renamed from src/lua/modules/bit/bit.cpp) | 41 | ||||
-rw-r--r-- | src/lua/modules/bit/je_lua_bit.h | 0 |
2 files changed, 22 insertions, 19 deletions
diff --git a/src/lua/modules/bit/bit.cpp b/src/lua/modules/bit/je_lua_bit.cpp index cedd60a..fdd0ae0 100644 --- a/src/lua/modules/bit/bit.cpp +++ b/src/lua/modules/bit/je_lua_bit.cpp @@ -1,5 +1,7 @@ +#include "lua/common/je_lua_common.h" #include "lua/modules/luax.h" #include "libjin/jin.h" + #include <cstdlib> namespace JinEngine @@ -7,7 +9,7 @@ namespace JinEngine namespace Lua { - static int l_and(lua_State* L) + LUA_IMPLEMENT int l_and(lua_State* L) { int a = luax_checkinteger(L, 1); int b = luax_checkinteger(L, 2); @@ -15,7 +17,7 @@ namespace JinEngine return 1; } - static int l_or(lua_State* L) + LUA_IMPLEMENT int l_or(lua_State* L) { int a = luax_checkinteger(L, 1); int b = luax_checkinteger(L, 2); @@ -23,7 +25,7 @@ namespace JinEngine return 1; } - static int l_xor(lua_State* L) + LUA_IMPLEMENT int l_xor(lua_State* L) { int a = luax_checkinteger(L, 1); int b = luax_checkinteger(L, 2); @@ -31,14 +33,14 @@ namespace JinEngine return 1; } - static int l_not(lua_State* L) + LUA_IMPLEMENT int l_not(lua_State* L) { int n = luax_checkinteger(L, 1); luax_pushinteger(L, ~n); return 1; } - static int l_lshift(lua_State* L) + LUA_IMPLEMENT int l_lshift(lua_State* L) { int a = luax_checkinteger(L, 1); int b = luax_checkinteger(L, 2); @@ -46,7 +48,7 @@ namespace JinEngine return 1; } - static int l_rshift(lua_State* L) + LUA_IMPLEMENT int l_rshift(lua_State* L) { int a = luax_checkinteger(L, 1); int b = luax_checkinteger(L, 2); @@ -54,7 +56,7 @@ namespace JinEngine return 1; } - static int l_include(lua_State* L) + LUA_IMPLEMENT int l_include(lua_State* L) { int a = luax_checkinteger(L, 1); int b = luax_checkinteger(L, 2); @@ -62,19 +64,20 @@ namespace JinEngine return 1; } - static const luaL_Reg f[] = { - { "bAnd", l_and }, - { "bOr" , l_or }, - { "bXor", l_xor }, - { "bNot", l_not }, - { "bLs", l_lshift }, - { "bRs", l_rshift }, - { "bInc", l_include }, - { 0, 0 } - }; - - int luaopen_bit(lua_State* L) + + LUA_EXPORT int luaopen_bit(lua_State* L) { + luaL_Reg f[] = { + { "bAnd", l_and }, + { "bOr" , l_or }, + { "bXor", l_xor }, + { "bNot", l_not }, + { "bLs", l_lshift }, + { "bRs", l_rshift }, + { "bInc", l_include }, + { 0, 0 } + }; + luax_newlib(L, f); return 1; diff --git a/src/lua/modules/bit/je_lua_bit.h b/src/lua/modules/bit/je_lua_bit.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/lua/modules/bit/je_lua_bit.h |