mirror of
https://github.com/ThePhD/sol2.git
synced 2024-03-22 13:10:44 +08:00
Tabs to spaces
This commit is contained in:
parent
84ae20a57a
commit
30c1f8c1b8
|
@ -188,11 +188,11 @@ struct base_function {
|
||||||
struct userdata_gc {
|
struct userdata_gc {
|
||||||
static int gc(lua_State* L) {
|
static int gc(lua_State* L) {
|
||||||
for (std::size_t i = 0; i < N; ++i) {
|
for (std::size_t i = 0; i < N; ++i) {
|
||||||
upvalue_t up = stack::get<upvalue_t>(L, i + 1);
|
upvalue_t up = stack::get<upvalue_t>(L, i + 1);
|
||||||
base_function* obj = static_cast<base_function*>(up.value);
|
base_function* obj = static_cast<base_function*>(up.value);
|
||||||
std::allocator<base_function> alloc{};
|
std::allocator<base_function> alloc{};
|
||||||
alloc.destroy(obj);
|
alloc.destroy(obj);
|
||||||
alloc.deallocate(obj, 1);
|
alloc.deallocate(obj, 1);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
10
tests.cpp
10
tests.cpp
|
@ -393,7 +393,7 @@ TEST_CASE("tables/functions_variables", "Check if tables and function calls work
|
||||||
|
|
||||||
TEST_CASE("functions/overloaded", "Check if overloaded function resolution templates compile/work") {
|
TEST_CASE("functions/overloaded", "Check if overloaded function resolution templates compile/work") {
|
||||||
sol::state lua;
|
sol::state lua;
|
||||||
lua.open_libraries(sol::lib::base);
|
lua.open_libraries(sol::lib::base);
|
||||||
|
|
||||||
lua.set_function("non_overloaded", non_overloaded);
|
lua.set_function("non_overloaded", non_overloaded);
|
||||||
REQUIRE_NOTHROW(lua.script("x = non_overloaded(1)\nprint(x)"));
|
REQUIRE_NOTHROW(lua.script("x = non_overloaded(1)\nprint(x)"));
|
||||||
|
@ -720,7 +720,7 @@ TEST_CASE("userdata/issue-number-thirty-five", "using value types created from l
|
||||||
return sqrtf(x*x + y*y + z*z);
|
return sqrtf(x*x + y*y + z*z);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec normalized() {
|
Vec normalized() {
|
||||||
float invS = 1 / length();
|
float invS = 1 / length();
|
||||||
return {x * invS, y * invS, z * invS};
|
return {x * invS, y * invS, z * invS};
|
||||||
}
|
}
|
||||||
|
@ -766,7 +766,7 @@ TEST_CASE("userdata/lua-stored-userdata", "ensure userdata values can be stored
|
||||||
};
|
};
|
||||||
|
|
||||||
sol::state lua;
|
sol::state lua;
|
||||||
lua.open_libraries(sol::lib::base);
|
lua.open_libraries(sol::lib::base);
|
||||||
|
|
||||||
{
|
{
|
||||||
sol::constructors<sol::types<float, float, float>> ctor;
|
sol::constructors<sol::types<float, float, float>> ctor;
|
||||||
|
@ -778,10 +778,10 @@ TEST_CASE("userdata/lua-stored-userdata", "ensure userdata values can be stored
|
||||||
// userdata dies, but still usable in lua!
|
// userdata dies, but still usable in lua!
|
||||||
}
|
}
|
||||||
|
|
||||||
REQUIRE_NOTHROW(lua.script("collectgarbage()\n"
|
REQUIRE_NOTHROW(lua.script("collectgarbage()\n"
|
||||||
"v = Vec.new(1, 2, 3)\n"
|
"v = Vec.new(1, 2, 3)\n"
|
||||||
"print(v:length())"));
|
"print(v:length())"));
|
||||||
|
|
||||||
REQUIRE_NOTHROW(lua.script("v = Vec.new(1, 2, 3)\n"
|
REQUIRE_NOTHROW(lua.script("v = Vec.new(1, 2, 3)\n"
|
||||||
"print(v:normalized():length())" ));
|
"print(v:normalized():length())" ));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user