diff options
| author | Benoit Germain <benoit.germain@ubisoft.com> | 2025-03-14 11:32:58 +0100 |
|---|---|---|
| committer | Benoit Germain <benoit.germain@ubisoft.com> | 2025-03-14 11:32:58 +0100 |
| commit | dee0756ff21c1f7dd4eea067dfb90feb1ba4763d (patch) | |
| tree | 981ddd4ddc22bc1fae54ce3e0034da746571fb1a /src | |
| parent | 536a64557c82c350fd73ea64c6d4dd1737896579 (diff) | |
| download | lanes-dee0756ff21c1f7dd4eea067dfb90feb1ba4763d.tar.gz lanes-dee0756ff21c1f7dd4eea067dfb90feb1ba4763d.tar.bz2 lanes-dee0756ff21c1f7dd4eea067dfb90feb1ba4763d.zip | |
lanes/core.[so|dll] → lanes_core.[so|dll]
Diffstat (limited to 'src')
| -rw-r--r-- | src/Lanes.makefile | 11 | ||||
| -rw-r--r-- | src/lane.hpp | 2 | ||||
| -rw-r--r-- | src/lanes.cpp | 12 | ||||
| -rw-r--r-- | src/lanes.lua | 10 | ||||
| -rw-r--r-- | src/state.cpp | 7 | ||||
| -rw-r--r-- | src/universe.cpp | 2 |
6 files changed, 20 insertions, 24 deletions
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 @@ | |||
| 7 | 7 | ||
| 8 | include ../Shared.makefile | 8 | include ../Shared.makefile |
| 9 | 9 | ||
| 10 | _MODULE=lanes | 10 | _TARGET := lanes_core.$(_SO) |
| 11 | 11 | ||
| 12 | _SRC := $(wildcard *.cpp) | 12 | _SRC := $(wildcard *.cpp) |
| 13 | 13 | ||
| 14 | _OBJ := $(_SRC:.cpp=.o) | 14 | _OBJ := $(_SRC:.cpp=.o) |
| 15 | 15 | ||
| 16 | _MODULE_DIR = $(_MODULE) | ||
| 17 | |||
| 18 | #--- | 16 | #--- |
| 19 | all: info $(_MODULE)/core.$(_SO) | 17 | all: info $(_TARGET) |
| 20 | 18 | ||
| 21 | info: | 19 | info: |
| 22 | $(info CC: $(CC)) | 20 | $(info CC: $(CC)) |
| @@ -30,12 +28,11 @@ _pch.hpp.gch: _pch.hpp | |||
| 30 | 28 | ||
| 31 | # Note: Don't put $(LUA_LIBS) ahead of $^; MSYS will not like that (I think) | 29 | # Note: Don't put $(LUA_LIBS) ahead of $^; MSYS will not like that (I think) |
| 32 | # | 30 | # |
| 33 | $(_MODULE_DIR)/core.$(_SO): $(_OBJ) | 31 | $(_TARGET): $(_OBJ) |
| 34 | mkdir -p $(_MODULE_DIR) | ||
| 35 | $(CC) $(LIBFLAG) $^ $(LIBS) $(LUA_LIBS) -o $@ | 32 | $(CC) $(LIBFLAG) $^ $(LIBS) $(LUA_LIBS) -o $@ |
| 36 | 33 | ||
| 37 | clean: | 34 | clean: |
| 38 | -rm -rf $(_MODULE)/core.$(_SO) *.o *.map *.gch | 35 | -rm -rf $(_TARGET) *.o *.map *.gch |
| 39 | 36 | ||
| 40 | #--- | 37 | #--- |
| 41 | # NSLU2 "slug" Linux ARM | 38 | # 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" }; | |||
| 41 | 41 | ||
| 42 | // must be a #define instead of a constexpr to benefit from compile-time string concatenation | 42 | // must be a #define instead of a constexpr to benefit from compile-time string concatenation |
| 43 | #define kLanesLibName "lanes" | 43 | #define kLanesLibName "lanes" |
| 44 | #define kLanesCoreLibName kLanesLibName ".core" | 44 | #define kLanesCoreLibName kLanesLibName "_core" |
| 45 | 45 | ||
| 46 | // for cancel() argument | 46 | // for cancel() argument |
| 47 | enum class [[nodiscard]] WakeLane | 47 | 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) | |||
| 760 | 760 | ||
| 761 | // register all native functions found in that module in the transferable functions database | 761 | // register all native functions found in that module in the transferable functions database |
| 762 | // we process it before _G because we don't want to find the module when scanning _G (this would generate longer names) | 762 | // we process it before _G because we don't want to find the module when scanning _G (this would generate longer names) |
| 763 | // for example in package.loaded["lanes.core"].* | 763 | // for example in package.loaded["lanes_core"].* |
| 764 | tools::PopulateFuncLookupTable(L_, kIdxTop, _name); | 764 | tools::PopulateFuncLookupTable(L_, kIdxTop, _name); |
| 765 | STACK_CHECK(L_, 2); | 765 | STACK_CHECK(L_, 2); |
| 766 | 766 | ||
| @@ -862,11 +862,11 @@ LANES_API int luaopen_lanes_core(lua_State* const L_) | |||
| 862 | // Create main module interface table | 862 | // Create main module interface table |
| 863 | // we only have 1 closure, which must be called to configure Lanes | 863 | // we only have 1 closure, which must be called to configure Lanes |
| 864 | lua_newtable(L_); // L_: M | 864 | lua_newtable(L_); // L_: M |
| 865 | lua_pushvalue(L_, 1); // L_: M "lanes.core" | 865 | lua_pushvalue(L_, 1); // L_: M "lanes_core" |
| 866 | lua_pushvalue(L_, -2); // L_: M "lanes.core" M | 866 | lua_pushvalue(L_, -2); // L_: M "lanes_core" M |
| 867 | lua_pushcclosure(L_, LG_configure, 2); // L_: M LG_configure() | 867 | lua_pushcclosure(L_, LG_configure, 2); // L_: M LG_configure() |
| 868 | kConfigRegKey.pushValue(L_); // L_: M LG_configure() settings | 868 | kConfigRegKey.pushValue(L_); // L_: M LG_configure() settings |
| 869 | if (!lua_isnil(L_, -1)) { // this is not the first require "lanes.core": call configure() immediately | 869 | if (!lua_isnil(L_, -1)) { // this is not the first require "lanes_core": call configure() immediately |
| 870 | lua_pushvalue(L_, -1); // L_: M LG_configure() settings settings | 870 | lua_pushvalue(L_, -1); // L_: M LG_configure() settings settings |
| 871 | lua_setfield(L_, -4, "settings"); // L_: M LG_configure() settings | 871 | lua_setfield(L_, -4, "settings"); // L_: M LG_configure() settings |
| 872 | lua_call(L_, 1, 0); // L_: M | 872 | lua_call(L_, 1, 0); // L_: M |
| @@ -898,8 +898,8 @@ static int default_luaopen_lanes(lua_State* const L_) | |||
| 898 | LANES_API void luaopen_lanes_embedded(lua_State* const L_, lua_CFunction const luaopen_lanes_) | 898 | LANES_API void luaopen_lanes_embedded(lua_State* const L_, lua_CFunction const luaopen_lanes_) |
| 899 | { | 899 | { |
| 900 | STACK_CHECK_START_REL(L_, 0); | 900 | STACK_CHECK_START_REL(L_, 0); |
| 901 | // pre-require lanes.core so that when lanes.lua calls require "lanes.core" it finds it is already loaded | 901 | // pre-require lanes_core so that when lanes.lua calls require "lanes_core" it finds it is already loaded |
| 902 | luaL_requiref(L_, kLanesCoreLibName, luaopen_lanes_core, 0); // L_: ... lanes.core | 902 | luaL_requiref(L_, kLanesCoreLibName, luaopen_lanes_core, 0); // L_: ... lanes_core |
| 903 | lua_pop(L_, 1); // L_: ... | 903 | lua_pop(L_, 1); // L_: ... |
| 904 | STACK_CHECK(L_, 0); | 904 | STACK_CHECK(L_, 0); |
| 905 | // call user-provided function that runs the chunk "lanes.lua" from wherever they stored it | 905 | // 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. | |||
| 35 | =============================================================================== | 35 | =============================================================================== |
| 36 | ]]-- | 36 | ]]-- |
| 37 | 37 | ||
| 38 | local core = require "lanes.core" | 38 | local core = require "lanes_core" |
| 39 | -- Lua 5.1: module() creates a global variable | 39 | -- Lua 5.1: module() creates a global variable |
| 40 | -- Lua 5.2: module() is gone | 40 | -- Lua 5.2: module() is gone |
| 41 | -- almost everything module() does is done by require() anyway | 41 | -- almost everything module() does is done by require() anyway |
| @@ -228,7 +228,7 @@ local valid_libs = | |||
| 228 | ["table"] = true, | 228 | ["table"] = true, |
| 229 | ["utf8"] = true, | 229 | ["utf8"] = true, |
| 230 | -- | 230 | -- |
| 231 | ["lanes.core"] = true | 231 | ["lanes_core"] = true |
| 232 | } | 232 | } |
| 233 | -- same structure, but contains only the libraries that the current Lua flavor actually supports | 233 | -- same structure, but contains only the libraries that the current Lua flavor actually supports |
| 234 | local supported_libs | 234 | local supported_libs |
| @@ -329,8 +329,8 @@ local process_gen_opt = function(...) | |||
| 329 | error "Libs specification '*' must be used alone" | 329 | error "Libs specification '*' must be used alone" |
| 330 | end | 330 | end |
| 331 | local found = {} | 331 | local found = {} |
| 332 | -- accept lib identifiers followed by an optional question mark | 332 | -- accept lib identifiers (alphanumeric plus '.-_'), followed by an optional question mark |
| 333 | for s, question in string_gmatch(libs, "([%a%d.]+)(%??)") do | 333 | for s, question in string_gmatch(libs, "([%-%w_.]+)(%??)") do |
| 334 | if not valid_libs[s] then | 334 | if not valid_libs[s] then |
| 335 | error("Bad library name: " .. string_format("%q", tostring(s)), 2) | 335 | error("Bad library name: " .. string_format("%q", tostring(s)), 2) |
| 336 | end | 336 | end |
| @@ -643,7 +643,7 @@ local configure_timers = function() | |||
| 643 | end | 643 | end |
| 644 | end | 644 | end |
| 645 | end -- timer_body() | 645 | end -- timer_body() |
| 646 | timer_lane = gen("lanes.core,table", { name = "LanesTimer", package = {}, priority = core.max_prio }, timer_body)() | 646 | timer_lane = gen("lanes_core,table", { name = "LanesTimer", package = {}, priority = core.max_prio }, timer_body)() |
| 647 | end -- first_time | 647 | end -- first_time |
| 648 | 648 | ||
| 649 | ----- | 649 | ----- |
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 { | |||
| 99 | DEBUGSPEW_CODE(DebugSpew(Universe::Get(L_)) << "opening '" << _name << "' library" << std::endl); | 99 | DEBUGSPEW_CODE(DebugSpew(Universe::Get(L_)) << "opening '" << _name << "' library" << std::endl); |
| 100 | STACK_CHECK_START_REL(L_, 0); | 100 | STACK_CHECK_START_REL(L_, 0); |
| 101 | // open the library as if through require(), and create a global as well if necessary (the library table is left on the stack) | 101 | // open the library as if through require(), and create a global as well if necessary (the library table is left on the stack) |
| 102 | bool const _isLanesCore{ _libfunc == luaopen_lanes_core }; // don't want to create a global for "lanes.core" | 102 | bool const _isLanesCore{ _libfunc == luaopen_lanes_core }; // don't want to create a global for "lanes_core" |
| 103 | luaL_requiref(L_, _name.data(), _libfunc, !_isLanesCore); // L_: {lib} | 103 | luaL_requiref(L_, _name.data(), _libfunc, !_isLanesCore); // L_: {lib} |
| 104 | // lanes.core doesn't declare a global, so scan it here and now | 104 | // lanes_core doesn't declare a global, so scan it here and now |
| 105 | if (_isLanesCore) { | 105 | if (_isLanesCore) { |
| 106 | tools::PopulateFuncLookupTable(L_, kIdxTop, _name); | 106 | tools::PopulateFuncLookupTable(L_, kIdxTop, _name); |
| 107 | } | 107 | } |
| @@ -224,7 +224,7 @@ namespace state { | |||
| 224 | if (_libs == "*") { | 224 | if (_libs == "*") { |
| 225 | DEBUGSPEW_CODE(DebugSpew(U_) << "opening ALL standard libraries" << std::endl); | 225 | DEBUGSPEW_CODE(DebugSpew(U_) << "opening ALL standard libraries" << std::endl); |
| 226 | luaL_openlibs(_L); | 226 | luaL_openlibs(_L); |
| 227 | // don't forget lanes.core for regular lane states | 227 | // don't forget lanes_core for regular lane states |
| 228 | Open1Lib(_L, kLanesCoreLibName); | 228 | Open1Lib(_L, kLanesCoreLibName); |
| 229 | _libs = ""; // done with libs | 229 | _libs = ""; // done with libs |
| 230 | } else { | 230 | } else { |
| @@ -248,7 +248,6 @@ namespace state { | |||
| 248 | 248 | ||
| 249 | // scan all libraries, open them one by one | 249 | // scan all libraries, open them one by one |
| 250 | auto isLibNameChar = [](char const c_) { | 250 | auto isLibNameChar = [](char const c_) { |
| 251 | // '.' can be part of name for "lanes.core" | ||
| 252 | return std::isalnum(c_) || c_ == '.' || c_ == '-' || c_ == '_'; | 251 | return std::isalnum(c_) || c_ == '.' || c_ == '-' || c_ == '_'; |
| 253 | }; | 252 | }; |
| 254 | while (!_libs.empty()) { | 253 | 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 | |||
| 91 | 91 | ||
| 92 | // C function: recreate a closure in the new state, bypassing the lookup scheme | 92 | // C function: recreate a closure in the new state, bypassing the lookup scheme |
| 93 | lua_pushcfunction(L_, std::get<lua_CFunction>(onStateCreateFunc)); // on_state_create() | 93 | lua_pushcfunction(L_, std::get<lua_CFunction>(onStateCreateFunc)); // on_state_create() |
| 94 | } else { // Lua function located in the config table, copied when we opened "lanes.core" | 94 | } else { // Lua function located in the config table, copied when we opened "lanes_core" |
| 95 | LUA_ASSERT(from_, std::holds_alternative<uintptr_t>(onStateCreateFunc)); | 95 | LUA_ASSERT(from_, std::holds_alternative<uintptr_t>(onStateCreateFunc)); |
| 96 | if (mode_ != LookupMode::LaneBody) { | 96 | if (mode_ != LookupMode::LaneBody) { |
| 97 | // if attempting to call in a keeper state, do nothing because the function doesn't exist there | 97 | // if attempting to call in a keeper state, do nothing because the function doesn't exist there |
