diff --git a/CMakeLists.txt b/CMakeLists.txt index a1ed4a57..b2cc9e48 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,14 +27,17 @@ cmake_minimum_required(VERSION 3.15.0) # # # project declaration project(sol2 VERSION 3.2.5 LANGUAGES CXX C) -include(GNUInstallDirs) - # # # Modules # # Include modules useful to the project, whether locally made in our own cmake DIRECTORY # # our from the standard cmake libraries # Add home-rolled modules path to front of module path list set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules" "${CMAKE_MODULE_PATH}") +if (PROJECT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) + set(SOL2_IS_TOP_LEVEL TRUE) + message(STATUS "sol2 is the top-level directory...") +endif() + # Include standard modules include(CMakePackageConfigHelpers) include(CheckCXXCompilerFlag) @@ -89,11 +92,6 @@ else() set(IS_X64 TRUE) endif() -if (PROJECT_SOURCE_DIR STREQUAL ${CMAKE_SOURCE_DIR}) - set(SOL2_IS_TOP_LEVEL TRUE) - message(STATUS "sol2 is the top-level directory...") -endif() - # # # sol2 Source Groups # # Sources everyone is going to need # Header files diff --git a/include/sol/call.hpp b/include/sol/call.hpp index 67131fd1..2066bd82 100644 --- a/include/sol/call.hpp +++ b/include/sol/call.hpp @@ -864,6 +864,11 @@ namespace sol { return lcw.call(L, std::get<0>(f.arguments)); } + static int call(lua_State* L, function_arguments& f) { + lua_call_wrapper, is_index, is_variable, checked, boost, clean_stack> lcw {}; + return lcw.call(L, std::get<0>(f.arguments)); + } + static int call(lua_State* L, function_arguments&& f) { lua_call_wrapper, is_index, is_variable, checked, boost, clean_stack> lcw {}; return lcw.call(L, std::get<0>(std::move(f.arguments))); diff --git a/tests/regression_tests/simple/source/1149 - static method gets const-morphed in internals.cpp b/tests/regression_tests/simple/source/1149 - static method gets const-morphed in internals.cpp new file mode 100644 index 00000000..b0c079ea --- /dev/null +++ b/tests/regression_tests/simple/source/1149 - static method gets const-morphed in internals.cpp @@ -0,0 +1,23 @@ +#include + +inline namespace sol2_regression_test_1149 { + struct Test { + static Test* staticCreate() { + return new Test(); + } + Test* create() { + return new Test(); + } + }; +} // namespace sol2_regression_test_1149 + +unsigned int regression_1149() { + sol::state lua = {}; + auto T = lua.new_usertype("Test"); + // compile ok. + T.set_function("create", &Test::create); + // compile error. + T.set_function("staticCreate", &Test::staticCreate); + + return 0; +} diff --git a/tests/regression_tests/simple/source/main.cpp b/tests/regression_tests/simple/source/main.cpp index 10e97c41..234b46e3 100644 --- a/tests/regression_tests/simple/source/main.cpp +++ b/tests/regression_tests/simple/source/main.cpp @@ -9,9 +9,10 @@ extern unsigned int regression_1072(); extern unsigned int regression_1087(); extern unsigned int regression_1095(); extern unsigned int regression_1096(); +extern unsigned int regression_1149(); static f_ptr* const regression_tests_regressions[] - = { ®ression_1008, ®ression_1000, ®ression_1067, ®ression_1072, ®ression_1087, ®ression_1095, ®ression_1096 }; + = { ®ression_1008, ®ression_1000, ®ression_1067, ®ression_1072, ®ression_1087, ®ression_1095, ®ression_1096, ®ression_1149 }; static const int regression_tests_sizeof_regressions = sizeof(regression_tests_regressions) / sizeof(regression_tests_regressions[0]); int trampoline(f_ptr* f) { diff --git a/tests/runtime_tests/source/tables.cpp b/tests/runtime_tests/source/tables.cpp index acf7fb55..33fb3e50 100644 --- a/tests/runtime_tests/source/tables.cpp +++ b/tests/runtime_tests/source/tables.cpp @@ -137,7 +137,10 @@ TEST_CASE("tables/create-with-local", "Check if creating a table is kosher") { TEST_CASE("tables/function variables", "Check if tables and function calls work as intended") { sol::state lua; lua.open_libraries(sol::lib::base, sol::lib::os); - auto run_script = [](sol::state& lua) -> void { lua.safe_script("assert(os.fun() == \"test\")"); }; + auto run_script = [](sol::state& lua) -> void { + auto pf = lua.safe_script("assert(os.fun() == \"test\")"); + REQUIRE(pf.valid()); + }; lua.get("os").set_function("fun", []() { INFO("stateless lambda()");