mirror of
https://github.com/ThePhD/sol2.git
synced 2024-03-22 13:10:44 +08:00
🐛 Fix #1149
This commit is contained in:
parent
bc04471c11
commit
d0ab12e965
|
@ -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
|
||||
|
|
|
@ -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)));
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -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) {
|
||||
|
|
|
@ -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()");
|
||||
|
|
Loading…
Reference in New Issue
Block a user