If only I had a test that took a unique_ptr as a second argument. RIP.
This commit is contained in:
ThePhD 2017-06-26 10:10:47 -04:00
parent 13370e7e42
commit af2136ba00
4 changed files with 20 additions and 12 deletions

View File

@ -20,8 +20,8 @@
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// This file was generated with a script.
// Generated 2017-06-24 14:16:16.927775 UTC
// This header was generated with sol v2.17.5 (revision 17271c8)
// Generated 2017-06-26 14:10:10.059447 UTC
// This header was generated with sol v2.17.5 (revision 13370e7)
// https://github.com/ThePhD/sol2
#ifndef SOL_SINGLE_INCLUDE_HPP
@ -5707,7 +5707,7 @@ namespace sol {
}
int metatableindex = lua_gettop(L);
if (stack_detail::check_metatable<detail::unique_usertype<T>>(L, metatableindex)) {
void* memory = lua_touserdata(L, 1);
void* memory = lua_touserdata(L, index);
T** pointerpointer = static_cast<T**>(memory);
detail::unique_destructor& pdx = *static_cast<detail::unique_destructor*>(static_cast<void*>(pointerpointer + 1));
bool success = &detail::usertype_unique_alloc_destroy<T, X> == pdx;

View File

@ -430,7 +430,7 @@ namespace sol {
}
int metatableindex = lua_gettop(L);
if (stack_detail::check_metatable<detail::unique_usertype<T>>(L, metatableindex)) {
void* memory = lua_touserdata(L, 1);
void* memory = lua_touserdata(L, index);
T** pointerpointer = static_cast<T**>(memory);
detail::unique_destructor& pdx = *static_cast<detail::unique_destructor*>(static_cast<void*>(pointerpointer + 1));
bool success = &detail::usertype_unique_alloc_destroy<T, X> == pdx;

View File

@ -1149,6 +1149,9 @@ TEST_CASE("functions/unique-overloading", "make sure overloading can work with p
auto print_up_test = [](std::unique_ptr<test>& x) {
REQUIRE(x->special_value == 21);
};
auto print_up_2_test = [](int, std::unique_ptr<test>& x) {
REQUIRE(x->special_value == 21);
};
auto print_sp_test = [](std::shared_ptr<test>& x) {
REQUIRE(x->special_value == 44);
};
@ -1175,6 +1178,7 @@ TEST_CASE("functions/unique-overloading", "make sure overloading can work with p
std::ref(print_ptr_test)
));
lua.set_function("h", std::ref(fptr));
lua.set_function("i", std::move(print_up_2_test));
lua["v1"] = std::make_unique<test>(21);
lua["v2"] = std::make_shared<test>(44);
@ -1191,6 +1195,7 @@ TEST_CASE("functions/unique-overloading", "make sure overloading can work with p
lua.script("h(v2)");
lua.script("h(v3)");
lua.script("h(v4)");
lua.script("i(v1)");
}());
};
// LuaJIT segfaults hard on some Linux machines

View File

@ -1476,9 +1476,12 @@ TEST_CASE("usertype/abstract-base-class", "Ensure that abstract base classes and
sol::state lua;
lua.new_usertype<abstract_A>("A", "a", &abstract_A::a);
lua.new_usertype<abstract_B>("B", sol::base_classes, sol::bases<abstract_A>());
lua.script(R"(local b = B.new()
REQUIRE_NOTHROW([&]() {
lua.script(R"(
local b = B.new()
b:a()
)");
});
}
TEST_CASE("usertype/as_function", "Ensure that variables can be turned into functions by as_function") {