This commit is contained in:
ThePhD 2021-03-07 13:43:56 -05:00
parent bc04471c11
commit d0ab12e965
No known key found for this signature in database
GPG Key ID: 1509DB1C0F702BFA
5 changed files with 39 additions and 9 deletions

View File

@ -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

View File

@ -864,6 +864,11 @@ namespace sol {
return lcw.call(L, std::get<0>(f.arguments));
}
static int call(lua_State* L, function_arguments<Sig, P>& f) {
lua_call_wrapper<T, meta::unqualified_t<P>, 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<Sig, P>&& f) {
lua_call_wrapper<T, meta::unqualified_t<P>, is_index, is_variable, checked, boost, clean_stack> lcw {};
return lcw.call(L, std::get<0>(std::move(f.arguments)));

View File

@ -0,0 +1,23 @@
#include <sol/sol.hpp>
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>("Test");
// compile ok.
T.set_function("create", &Test::create);
// compile error.
T.set_function("staticCreate", &Test::staticCreate);
return 0;
}

View File

@ -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[]
= { &regression_1008, &regression_1000, &regression_1067, &regression_1072, &regression_1087, &regression_1095, &regression_1096 };
= { &regression_1008, &regression_1000, &regression_1067, &regression_1072, &regression_1087, &regression_1095, &regression_1096, &regression_1149 };
static const int regression_tests_sizeof_regressions = sizeof(regression_tests_regressions) / sizeof(regression_tests_regressions[0]);
int trampoline(f_ptr* f) {

View File

@ -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<sol::table>("os").set_function("fun", []() {
INFO("stateless lambda()");