From 9d225b3e246a1d1bfcbf43c2d76eafb98f8e217f Mon Sep 17 00:00:00 2001 From: Bruce Date: Tue, 26 Sep 2023 23:13:28 +0800 Subject: [PATCH] add .core suffix cpp lib name --- lualib-src/lua_http.cpp | 2 +- lualib-src/lua_moon.cpp | 4 ++-- lualib/moon.lua | 2 +- lualib/moon/api/core.lua | 10 +++++----- lualib/moon/http/client.lua | 6 +++--- lualib/moon/http/server.lua | 7 +++---- lualib/moon/socket.lua | 2 +- moon-src/moon.cpp | 13 +++++++------ 8 files changed, 23 insertions(+), 23 deletions(-) diff --git a/lualib-src/lua_http.cpp b/lualib-src/lua_http.cpp index a28d82ad5..85543a736 100644 --- a/lualib-src/lua_http.cpp +++ b/lualib-src/lua_http.cpp @@ -119,7 +119,7 @@ static int lhttp_urldecode(lua_State* L) } extern "C" { - int LUAMOD_API luaopen_http(lua_State *L) + int LUAMOD_API luaopen_http_core(lua_State *L) { luaL_Reg l[] = { { "parse_request", lhttp_parse_request}, diff --git a/lualib-src/lua_moon.cpp b/lualib-src/lua_moon.cpp index 50b9df604..bebfd35f9 100644 --- a/lualib-src/lua_moon.cpp +++ b/lualib-src/lua_moon.cpp @@ -428,7 +428,7 @@ static int lmi_collect(lua_State* L) } extern "C" { - int LUAMOD_API luaopen_moon(lua_State* L) + int LUAMOD_API luaopen_moon_core(lua_State* L) { luaL_Reg l[] = { { "clock", lmoon_clock}, @@ -724,7 +724,7 @@ static int lasio_unpack_udp(lua_State* L) } extern "C" { - int LUAMOD_API luaopen_asio(lua_State* L) + int LUAMOD_API luaopen_asio_core(lua_State* L) { luaL_Reg l[] = { { "try_open", lasio_try_open}, diff --git a/lualib/moon.lua b/lualib/moon.lua index 600ad7c86..b79429e3f 100644 --- a/lualib/moon.lua +++ b/lualib/moon.lua @@ -6,7 +6,7 @@ require("base.math") require("base.util") require("base.class") -local core = require("mooncore") +local core = require("moon.core") local seri = require("seri") local pairs = pairs diff --git a/lualib/moon/api/core.lua b/lualib/moon/api/core.lua index 89aae782f..5a0656844 100644 --- a/lualib/moon/api/core.lua +++ b/lualib/moon/api/core.lua @@ -1,14 +1,14 @@ error("DO NOT REQUIRE THIS FILE") ---- lightuserdata buffer* ----@class buffer_ptr - ---- lightuserdata message* ---@meta +--- lightuserdata, cpp type `buffer*` +---@class buffer_ptr + +--- lightuserdata, cpp type `message*` ---@class message_ptr ---- lightuserdata char* +--- lightuserdata, cpp type `char*` ---@class cstring_ptr ---@class core diff --git a/lualib/moon/http/client.lua b/lualib/moon/http/client.lua index f17b3fab4..464351d35 100644 --- a/lualib/moon/http/client.lua +++ b/lualib/moon/http/client.lua @@ -1,8 +1,8 @@ -local http = require("http") local buffer = require("buffer") local moon = require("moon") local json = require("json") local socket = require("moon.socket") +local c = require("http.core") local string = string @@ -14,10 +14,10 @@ local tonumber = tonumber local tointeger = math.tointeger local pairs = pairs -local parse_response = http.parse_response +local parse_response = c.parse_response ---@type fun(params:table):string -local create_query_string = http.create_query_string +local create_query_string = c.create_query_string ----------------------------------------------------------------- diff --git a/lualib/moon/http/server.lua b/lualib/moon/http/server.lua index a1754e433..7a2994088 100644 --- a/lualib/moon/http/server.lua +++ b/lualib/moon/http/server.lua @@ -1,12 +1,11 @@ local moon = require("moon") -local http = require("http") local buffer = require("buffer") ----@type fs local fs = require("fs") local socket = require("moon.socket") +local c = require("http.core") -local parse_request = http.parse_request -local parse_query_string = http.parse_query_string +local parse_request = c.parse_request +local parse_query_string = c.parse_query_string local tbinsert = table.insert local tbconcat = table.concat diff --git a/lualib/moon/socket.lua b/lualib/moon/socket.lua index 72b8f5aaf..72f867443 100644 --- a/lualib/moon/socket.lua +++ b/lualib/moon/socket.lua @@ -1,5 +1,5 @@ local moon = require("moon") -local core = require("asio") +local core = require("asio.core") local make_session = moon.make_session local id = moon.id diff --git a/moon-src/moon.cpp b/moon-src/moon.cpp index ce6a93110..787ce7fb6 100644 --- a/moon-src/moon.cpp +++ b/moon-src/moon.cpp @@ -255,20 +255,21 @@ int main(int argc, char* argv[]) extern "C" { void open_custom_libs(lua_State* L) { - //core + #ifdef LUA_CACHELIB REGISTER_CUSTOM_LIBRARY("codecache", luaopen_cache); #endif - REGISTER_CUSTOM_LIBRARY("mooncore", luaopen_moon); - REGISTER_CUSTOM_LIBRARY("asio", luaopen_asio); + //core + REGISTER_CUSTOM_LIBRARY("moon.core", luaopen_moon_core); + REGISTER_CUSTOM_LIBRARY("asio.core", luaopen_asio_core); + REGISTER_CUSTOM_LIBRARY("sharetable.core", luaopen_sharetable_core); + REGISTER_CUSTOM_LIBRARY("socket.core", luaopen_socket_core); + REGISTER_CUSTOM_LIBRARY("http.core", luaopen_http_core); REGISTER_CUSTOM_LIBRARY("fs", luaopen_fs); - REGISTER_CUSTOM_LIBRARY("http", luaopen_http); REGISTER_CUSTOM_LIBRARY("seri", luaopen_serialize); REGISTER_CUSTOM_LIBRARY("json", luaopen_json); REGISTER_CUSTOM_LIBRARY("buffer", luaopen_buffer); - REGISTER_CUSTOM_LIBRARY("sharetable.core", luaopen_sharetable_core); - REGISTER_CUSTOM_LIBRARY("socket.core", luaopen_socket_core); //custom REGISTER_CUSTOM_LIBRARY("pb", luaopen_pb);