diff options
author | chai <chaifix@163.com> | 2018-10-25 08:18:13 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2018-10-25 08:18:13 +0800 |
commit | 7322a090355af1989d7a1de0de431b6c89844fe2 (patch) | |
tree | c164a05b263007e18cc1c83c8183023d6a19ef82 /src/lua/modules/net/je_lua_socket.cpp | |
parent | f889c9c20fc09f26eb8a70674c1d60181835c38a (diff) |
*增加lua导出宏
Diffstat (limited to 'src/lua/modules/net/je_lua_socket.cpp')
-rw-r--r-- | src/lua/modules/net/je_lua_socket.cpp | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/src/lua/modules/net/je_lua_socket.cpp b/src/lua/modules/net/je_lua_socket.cpp index 7ad6057..512bde3 100644 --- a/src/lua/modules/net/je_lua_socket.cpp +++ b/src/lua/modules/net/je_lua_socket.cpp @@ -1,6 +1,6 @@ #include "lua/modules/luax.h" #include "lua/modules/types.h" -#include "lua/common/common.h" +#include "lua/common/je_lua_common.h" #include "libjin/jin.h" #include "je_lua_buffer.h" @@ -16,20 +16,20 @@ namespace JinEngine const int BUFFER_SIZE = 1024; - static inline SocketRef checkSocket(lua_State* L, int pos = 1) + LUA_IMPLEMENT inline SocketRef checkSocket(lua_State* L, int pos = 1) { Proxy* proxy = (Proxy*)luax_checktype(L, pos, JIN_NETWORK_SOCKET); return proxy->getRef<Socket>(); } - static inline Ref<Buffer>& checkNetBuffer(lua_State* L, int pos = 1) + LUA_IMPLEMENT inline Ref<Buffer>& checkNetBuffer(lua_State* L, int pos = 1) { Proxy* proxy = (Proxy*)luax_checktype(L, pos, JIN_NETWORK_BUFFER); return proxy->getRef<Buffer>(); } // return net.Socket - static int l_accept(lua_State* L) + LUA_IMPLEMENT int l_accept(lua_State* L) { SocketRef socket = checkSocket(L); Socket* client = socket->accept(); @@ -39,7 +39,7 @@ namespace JinEngine } // return net.Buffer - static int l_receive(lua_State* L) + LUA_IMPLEMENT int l_receive(lua_State* L) { SocketRef socket = checkSocket(L); char buffer[BUFFER_SIZE] = {0}; @@ -51,7 +51,7 @@ namespace JinEngine } // Socket:receiveFrom(address, port) - static int l_receiveFrom(lua_State* L) + LUA_IMPLEMENT int l_receiveFrom(lua_State* L) { SocketRef socket = checkSocket(L); int address = luax_checkinteger(L, 2); @@ -65,7 +65,7 @@ namespace JinEngine } // Socket:send(net.Buffer) -> data_length - static int l_send(lua_State* L) + LUA_IMPLEMENT int l_send(lua_State* L) { SocketRef socket = checkSocket(L); Ref<Buffer>& ref = checkNetBuffer(L, 2); @@ -75,7 +75,7 @@ namespace JinEngine } // Socket:sendTo(address, port, net.Buffer) - static int l_sendTo(lua_State* L) + LUA_IMPLEMENT int l_sendTo(lua_State* L) { SocketRef socket = checkSocket(L); int address = luax_checkinteger(L, 2); @@ -85,14 +85,14 @@ namespace JinEngine return 0; } - static int l_close(lua_State* L) + LUA_IMPLEMENT int l_close(lua_State* L) { SocketRef socket = checkSocket(L); socket->close(); return 0; } - static int l_configBlocking(lua_State* L) + LUA_IMPLEMENT int l_configBlocking(lua_State* L) { SocketRef socket = checkSocket(L); bool blocking = luax_checkbool(L, 2); @@ -100,14 +100,14 @@ namespace JinEngine return 0; } - static int l_gc(lua_State* L) + LUA_IMPLEMENT int l_gc(lua_State* L) { Proxy* proxy = (Proxy*)luax_checktype(L, 1, JIN_NETWORK_SOCKET); proxy->release(); return 0; } - static const luaL_Reg socket_function[] = { + LUA_IMPLEMENT const luaL_Reg socket_function[] = { { "__gc", l_gc }, { "accept", l_accept }, { "receive", l_receive }, @@ -119,7 +119,7 @@ namespace JinEngine { 0, 0 } }; - int luaopen_Socket(lua_State* L) + LUA_EXPORT int luaopen_Socket(lua_State* L) { luax_newtype(L, JIN_NETWORK_SOCKET, socket_function); return 0; |