From dee0756ff21c1f7dd4eea067dfb90feb1ba4763d Mon Sep 17 00:00:00 2001 From: Benoit Germain Date: Fri, 14 Mar 2025 11:32:58 +0100 Subject: lanes/core.[so|dll] → lanes_core.[so|dll] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Lanes.makefile | 11 ++++------- src/lane.hpp | 2 +- src/lanes.cpp | 12 ++++++------ src/lanes.lua | 10 +++++----- src/state.cpp | 7 +++---- src/universe.cpp | 2 +- 6 files changed, 20 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/Lanes.makefile b/src/Lanes.makefile index 9798848..7d0a153 100644 --- a/src/Lanes.makefile +++ b/src/Lanes.makefile @@ -7,16 +7,14 @@ include ../Shared.makefile -_MODULE=lanes +_TARGET := lanes_core.$(_SO) _SRC := $(wildcard *.cpp) _OBJ := $(_SRC:.cpp=.o) -_MODULE_DIR = $(_MODULE) - #--- -all: info $(_MODULE)/core.$(_SO) +all: info $(_TARGET) info: $(info CC: $(CC)) @@ -30,12 +28,11 @@ _pch.hpp.gch: _pch.hpp # Note: Don't put $(LUA_LIBS) ahead of $^; MSYS will not like that (I think) # -$(_MODULE_DIR)/core.$(_SO): $(_OBJ) - mkdir -p $(_MODULE_DIR) +$(_TARGET): $(_OBJ) $(CC) $(LIBFLAG) $^ $(LIBS) $(LUA_LIBS) -o $@ clean: - -rm -rf $(_MODULE)/core.$(_SO) *.o *.map *.gch + -rm -rf $(_TARGET) *.o *.map *.gch #--- # NSLU2 "slug" Linux ARM diff --git a/src/lane.hpp b/src/lane.hpp index 4b5188c..9b678d6 100644 --- a/src/lane.hpp +++ b/src/lane.hpp @@ -41,7 +41,7 @@ static constexpr std::string_view kLaneMetatableName{ "Lane" }; // must be a #define instead of a constexpr to benefit from compile-time string concatenation #define kLanesLibName "lanes" -#define kLanesCoreLibName kLanesLibName ".core" +#define kLanesCoreLibName kLanesLibName "_core" // for cancel() argument enum class [[nodiscard]] WakeLane diff --git a/src/lanes.cpp b/src/lanes.cpp index 678540d..15e04a3 100644 --- a/src/lanes.cpp +++ b/src/lanes.cpp @@ -760,7 +760,7 @@ LUAG_FUNC(configure) // register all native functions found in that module in the transferable functions database // we process it before _G because we don't want to find the module when scanning _G (this would generate longer names) - // for example in package.loaded["lanes.core"].* + // for example in package.loaded["lanes_core"].* tools::PopulateFuncLookupTable(L_, kIdxTop, _name); STACK_CHECK(L_, 2); @@ -862,11 +862,11 @@ LANES_API int luaopen_lanes_core(lua_State* const L_) // Create main module interface table // we only have 1 closure, which must be called to configure Lanes lua_newtable(L_); // L_: M - lua_pushvalue(L_, 1); // L_: M "lanes.core" - lua_pushvalue(L_, -2); // L_: M "lanes.core" M + lua_pushvalue(L_, 1); // L_: M "lanes_core" + lua_pushvalue(L_, -2); // L_: M "lanes_core" M lua_pushcclosure(L_, LG_configure, 2); // L_: M LG_configure() kConfigRegKey.pushValue(L_); // L_: M LG_configure() settings - if (!lua_isnil(L_, -1)) { // this is not the first require "lanes.core": call configure() immediately + if (!lua_isnil(L_, -1)) { // this is not the first require "lanes_core": call configure() immediately lua_pushvalue(L_, -1); // L_: M LG_configure() settings settings lua_setfield(L_, -4, "settings"); // L_: M LG_configure() settings lua_call(L_, 1, 0); // L_: M @@ -898,8 +898,8 @@ static int default_luaopen_lanes(lua_State* const L_) LANES_API void luaopen_lanes_embedded(lua_State* const L_, lua_CFunction const luaopen_lanes_) { STACK_CHECK_START_REL(L_, 0); - // pre-require lanes.core so that when lanes.lua calls require "lanes.core" it finds it is already loaded - luaL_requiref(L_, kLanesCoreLibName, luaopen_lanes_core, 0); // L_: ... lanes.core + // pre-require lanes_core so that when lanes.lua calls require "lanes_core" it finds it is already loaded + luaL_requiref(L_, kLanesCoreLibName, luaopen_lanes_core, 0); // L_: ... lanes_core lua_pop(L_, 1); // L_: ... STACK_CHECK(L_, 0); // call user-provided function that runs the chunk "lanes.lua" from wherever they stored it diff --git a/src/lanes.lua b/src/lanes.lua index 4df1f64..98f8c20 100644 --- a/src/lanes.lua +++ b/src/lanes.lua @@ -35,7 +35,7 @@ THE SOFTWARE. =============================================================================== ]]-- -local core = require "lanes.core" +local core = require "lanes_core" -- Lua 5.1: module() creates a global variable -- Lua 5.2: module() is gone -- almost everything module() does is done by require() anyway @@ -228,7 +228,7 @@ local valid_libs = ["table"] = true, ["utf8"] = true, -- - ["lanes.core"] = true + ["lanes_core"] = true } -- same structure, but contains only the libraries that the current Lua flavor actually supports local supported_libs @@ -329,8 +329,8 @@ local process_gen_opt = function(...) error "Libs specification '*' must be used alone" end local found = {} - -- accept lib identifiers followed by an optional question mark - for s, question in string_gmatch(libs, "([%a%d.]+)(%??)") do + -- accept lib identifiers (alphanumeric plus '.-_'), followed by an optional question mark + for s, question in string_gmatch(libs, "([%-%w_.]+)(%??)") do if not valid_libs[s] then error("Bad library name: " .. string_format("%q", tostring(s)), 2) end @@ -643,7 +643,7 @@ local configure_timers = function() end end end -- timer_body() - timer_lane = gen("lanes.core,table", { name = "LanesTimer", package = {}, priority = core.max_prio }, timer_body)() + timer_lane = gen("lanes_core,table", { name = "LanesTimer", package = {}, priority = core.max_prio }, timer_body)() end -- first_time ----- diff --git a/src/state.cpp b/src/state.cpp index 6fabc5f..b558d11 100644 --- a/src/state.cpp +++ b/src/state.cpp @@ -99,9 +99,9 @@ namespace { DEBUGSPEW_CODE(DebugSpew(Universe::Get(L_)) << "opening '" << _name << "' library" << std::endl); STACK_CHECK_START_REL(L_, 0); // open the library as if through require(), and create a global as well if necessary (the library table is left on the stack) - bool const _isLanesCore{ _libfunc == luaopen_lanes_core }; // don't want to create a global for "lanes.core" + bool const _isLanesCore{ _libfunc == luaopen_lanes_core }; // don't want to create a global for "lanes_core" luaL_requiref(L_, _name.data(), _libfunc, !_isLanesCore); // L_: {lib} - // lanes.core doesn't declare a global, so scan it here and now + // lanes_core doesn't declare a global, so scan it here and now if (_isLanesCore) { tools::PopulateFuncLookupTable(L_, kIdxTop, _name); } @@ -224,7 +224,7 @@ namespace state { if (_libs == "*") { DEBUGSPEW_CODE(DebugSpew(U_) << "opening ALL standard libraries" << std::endl); luaL_openlibs(_L); - // don't forget lanes.core for regular lane states + // don't forget lanes_core for regular lane states Open1Lib(_L, kLanesCoreLibName); _libs = ""; // done with libs } else { @@ -248,7 +248,6 @@ namespace state { // scan all libraries, open them one by one auto isLibNameChar = [](char const c_) { - // '.' can be part of name for "lanes.core" return std::isalnum(c_) || c_ == '.' || c_ == '-' || c_ == '_'; }; while (!_libs.empty()) { diff --git a/src/universe.cpp b/src/universe.cpp index bc309a2..3da0801 100644 --- a/src/universe.cpp +++ b/src/universe.cpp @@ -91,7 +91,7 @@ void Universe::callOnStateCreate(lua_State* const L_, lua_State* const from_, Lo // C function: recreate a closure in the new state, bypassing the lookup scheme lua_pushcfunction(L_, std::get(onStateCreateFunc)); // on_state_create() - } else { // Lua function located in the config table, copied when we opened "lanes.core" + } else { // Lua function located in the config table, copied when we opened "lanes_core" LUA_ASSERT(from_, std::holds_alternative(onStateCreateFunc)); if (mode_ != LookupMode::LaneBody) { // if attempting to call in a keeper state, do nothing because the function doesn't exist there -- cgit v1.2.3-55-g6feb