mirror of
https://github.com/ThePhD/sol2.git
synced 2024-03-22 13:10:44 +08:00
Closes #431
If only I had a test that took a unique_ptr as a second argument. RIP.
This commit is contained in:
parent
13370e7e42
commit
af2136ba00
|
@ -20,8 +20,8 @@
|
||||||
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
// This file was generated with a script.
|
// This file was generated with a script.
|
||||||
// Generated 2017-06-24 14:16:16.927775 UTC
|
// Generated 2017-06-26 14:10:10.059447 UTC
|
||||||
// This header was generated with sol v2.17.5 (revision 17271c8)
|
// This header was generated with sol v2.17.5 (revision 13370e7)
|
||||||
// https://github.com/ThePhD/sol2
|
// https://github.com/ThePhD/sol2
|
||||||
|
|
||||||
#ifndef SOL_SINGLE_INCLUDE_HPP
|
#ifndef SOL_SINGLE_INCLUDE_HPP
|
||||||
|
@ -5707,7 +5707,7 @@ namespace sol {
|
||||||
}
|
}
|
||||||
int metatableindex = lua_gettop(L);
|
int metatableindex = lua_gettop(L);
|
||||||
if (stack_detail::check_metatable<detail::unique_usertype<T>>(L, metatableindex)) {
|
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);
|
T** pointerpointer = static_cast<T**>(memory);
|
||||||
detail::unique_destructor& pdx = *static_cast<detail::unique_destructor*>(static_cast<void*>(pointerpointer + 1));
|
detail::unique_destructor& pdx = *static_cast<detail::unique_destructor*>(static_cast<void*>(pointerpointer + 1));
|
||||||
bool success = &detail::usertype_unique_alloc_destroy<T, X> == pdx;
|
bool success = &detail::usertype_unique_alloc_destroy<T, X> == pdx;
|
||||||
|
|
|
@ -430,7 +430,7 @@ namespace sol {
|
||||||
}
|
}
|
||||||
int metatableindex = lua_gettop(L);
|
int metatableindex = lua_gettop(L);
|
||||||
if (stack_detail::check_metatable<detail::unique_usertype<T>>(L, metatableindex)) {
|
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);
|
T** pointerpointer = static_cast<T**>(memory);
|
||||||
detail::unique_destructor& pdx = *static_cast<detail::unique_destructor*>(static_cast<void*>(pointerpointer + 1));
|
detail::unique_destructor& pdx = *static_cast<detail::unique_destructor*>(static_cast<void*>(pointerpointer + 1));
|
||||||
bool success = &detail::usertype_unique_alloc_destroy<T, X> == pdx;
|
bool success = &detail::usertype_unique_alloc_destroy<T, X> == pdx;
|
||||||
|
|
|
@ -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) {
|
auto print_up_test = [](std::unique_ptr<test>& x) {
|
||||||
REQUIRE(x->special_value == 21);
|
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) {
|
auto print_sp_test = [](std::shared_ptr<test>& x) {
|
||||||
REQUIRE(x->special_value == 44);
|
REQUIRE(x->special_value == 44);
|
||||||
};
|
};
|
||||||
|
@ -1158,7 +1161,7 @@ TEST_CASE("functions/unique-overloading", "make sure overloading can work with p
|
||||||
auto print_ref_test = [](test& x) {
|
auto print_ref_test = [](test& x) {
|
||||||
bool is_any = x.special_value == 17
|
bool is_any = x.special_value == 17
|
||||||
|| x.special_value == 21
|
|| x.special_value == 21
|
||||||
|| x. special_value == 44;
|
|| x.special_value == 44;
|
||||||
REQUIRE(is_any);
|
REQUIRE(is_any);
|
||||||
};
|
};
|
||||||
using f_t = void(test&);
|
using f_t = void(test&);
|
||||||
|
@ -1175,6 +1178,7 @@ TEST_CASE("functions/unique-overloading", "make sure overloading can work with p
|
||||||
std::ref(print_ptr_test)
|
std::ref(print_ptr_test)
|
||||||
));
|
));
|
||||||
lua.set_function("h", std::ref(fptr));
|
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["v1"] = std::make_unique<test>(21);
|
||||||
lua["v2"] = std::make_shared<test>(44);
|
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(v2)");
|
||||||
lua.script("h(v3)");
|
lua.script("h(v3)");
|
||||||
lua.script("h(v4)");
|
lua.script("h(v4)");
|
||||||
|
lua.script("i(v1)");
|
||||||
}());
|
}());
|
||||||
};
|
};
|
||||||
// LuaJIT segfaults hard on some Linux machines
|
// LuaJIT segfaults hard on some Linux machines
|
||||||
|
|
|
@ -1464,11 +1464,11 @@ TEST_CASE("usertype/unique_usertype-check", "make sure unique usertypes don't ge
|
||||||
|
|
||||||
sol::function my_func = lua["my_func"];
|
sol::function my_func = lua["my_func"];
|
||||||
REQUIRE_NOTHROW([&]{
|
REQUIRE_NOTHROW([&]{
|
||||||
auto ent = std::make_shared<Entity>();
|
auto ent = std::make_shared<Entity>();
|
||||||
my_func(ent);
|
my_func(ent);
|
||||||
Entity ent2;
|
Entity ent2;
|
||||||
my_func(ent2);
|
my_func(ent2);
|
||||||
my_func(std::make_shared<Entity>());
|
my_func(std::make_shared<Entity>());
|
||||||
}());
|
}());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1476,9 +1476,12 @@ TEST_CASE("usertype/abstract-base-class", "Ensure that abstract base classes and
|
||||||
sol::state lua;
|
sol::state lua;
|
||||||
lua.new_usertype<abstract_A>("A", "a", &abstract_A::a);
|
lua.new_usertype<abstract_A>("A", "a", &abstract_A::a);
|
||||||
lua.new_usertype<abstract_B>("B", sol::base_classes, sol::bases<abstract_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()
|
b:a()
|
||||||
)");
|
)");
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("usertype/as_function", "Ensure that variables can be turned into functions by as_function") {
|
TEST_CASE("usertype/as_function", "Ensure that variables can be turned into functions by as_function") {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user