Skip to content

Commit 0383b7d

Browse files
committed
More fixes
1 parent 294b9d8 commit 0383b7d

4 files changed

Lines changed: 34 additions & 36 deletions

File tree

Distribution/LuaBridge/LuaBridge.h

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13369,13 +13369,13 @@ class Namespace : public detail::Registrar
1336913369
entry.paramTypes = detail::reflect_param_type_names<ArgsPack>();
1337013370
overload_set->entries.push_back(std::move(entry));
1337113371
13372-
lua_pushcclosure_x(L, &detail::constructor_placement_proxy<T, ArgsPack>, className, 1);
13372+
lua_pushcclosure_x(L, &detail::constructor_placement_proxy<T, ArgsPack>, "new", 1);
1337313373
1337413374
} (), ...);
1337513375
#else
1337613376
([&]
1337713377
{
13378-
lua_pushcclosure_x(L, &detail::constructor_placement_proxy<T, detail::function_arguments_t<Functions>>, className, 0);
13378+
lua_pushcclosure_x(L, &detail::constructor_placement_proxy<T, detail::function_arguments_t<Functions>>, "new", 0);
1337913379
1338013380
} (), ...);
1338113381
#endif
@@ -13406,12 +13406,12 @@ class Namespace : public detail::Registrar
1340613406
1340713407
([&]
1340813408
{
13409-
lua_pushcclosure_x(L, &detail::constructor_placement_proxy<T, detail::function_arguments_t<Functions>>, className, 0);
13409+
lua_pushcclosure_x(L, &detail::constructor_placement_proxy<T, detail::function_arguments_t<Functions>>, "new", 0);
1341013410
lua_rawseti(L, -2, idx++);
1341113411
1341213412
} (), ...);
1341313413
13414-
lua_pushcclosure_x(L, &detail::try_overload_functions<false>, className, 2);
13414+
lua_pushcclosure_x(L, &detail::try_overload_functions<false>, "new", 2);
1341513415
}
1341613416
1341713417
rawsetfield(L, -2, "new");
@@ -13453,10 +13453,10 @@ class Namespace : public detail::Registrar
1345313453
}
1345413454
1345513455
lua_newuserdata_aligned<F>(L, F(detail::get_underlying(std::move(functions))));
13456-
lua_pushcclosure_x(L, &detail::invoke_proxy_constructor<F, 2>, className, 2);
13456+
lua_pushcclosure_x(L, &detail::invoke_proxy_constructor<F, 2>, "new", 2);
1345713457
#else
1345813458
lua_newuserdata_aligned<F>(L, F(detail::get_underlying(std::move(functions))));
13459-
lua_pushcclosure_x(L, &detail::invoke_proxy_constructor<F>, className, 1);
13459+
lua_pushcclosure_x(L, &detail::invoke_proxy_constructor<F>, "new", 1);
1346013460
#endif
1346113461
} (), ...);
1346213462
}
@@ -13503,12 +13503,12 @@ class Namespace : public detail::Registrar
1350313503
using F = detail::constructor_forwarder<T, InnerF>;
1350413504
1350513505
lua_newuserdata_aligned<F>(L, F(detail::get_underlying(std::move(functions))));
13506-
lua_pushcclosure_x(L, &detail::invoke_proxy_constructor<F>, className, 1);
13506+
lua_pushcclosure_x(L, &detail::invoke_proxy_constructor<F>, "new", 1);
1350713507
lua_rawseti(L, -2, idx++);
1350813508
1350913509
} (), ...);
1351013510
13511-
lua_pushcclosure_x(L, &detail::try_overload_functions<false>, className, 2);
13511+
lua_pushcclosure_x(L, &detail::try_overload_functions<false>, "new", 2);
1351213512
}
1351313513
1351413514
rawsetfield(L, -2, "new");
@@ -13526,7 +13526,7 @@ class Namespace : public detail::Registrar
1352613526
{
1352713527
([&]
1352813528
{
13529-
lua_pushcclosure_x(L, &detail::constructor_container_proxy<C, detail::function_arguments_t<Functions>>, className, 0);
13529+
lua_pushcclosure_x(L, &detail::constructor_container_proxy<C, detail::function_arguments_t<Functions>>, "new", 0);
1353013530
1353113531
} (), ...);
1353213532
}
@@ -13552,12 +13552,12 @@ class Namespace : public detail::Registrar
1355213552
1355313553
([&]
1355413554
{
13555-
lua_pushcclosure_x(L, &detail::constructor_container_proxy<C, detail::function_arguments_t<Functions>>, className, 0);
13555+
lua_pushcclosure_x(L, &detail::constructor_container_proxy<C, detail::function_arguments_t<Functions>>, "new", 0);
1355613556
lua_rawseti(L, -2, idx++);
1355713557
1355813558
} (), ...);
1355913559
13560-
lua_pushcclosure_x(L, &detail::try_overload_functions<false>, className, 2);
13560+
lua_pushcclosure_x(L, &detail::try_overload_functions<false>, "new", 2);
1356113561
}
1356213562
1356313563
rawsetfield(L, -2, "new");
@@ -13580,7 +13580,7 @@ class Namespace : public detail::Registrar
1358013580
using F = detail::container_forwarder<C, Functions>;
1358113581
1358213582
lua_newuserdata_aligned<F>(L, F(std::move(functions)));
13583-
lua_pushcclosure_x(L, &detail::invoke_proxy_constructor<F>, className, 1);
13583+
lua_pushcclosure_x(L, &detail::invoke_proxy_constructor<F>, "new", 1);
1358413584
1358513585
} (), ...);
1358613586
}
@@ -13617,12 +13617,12 @@ class Namespace : public detail::Registrar
1361713617
using F = detail::container_forwarder<C, Functions>;
1361813618
1361913619
lua_newuserdata_aligned<F>(L, F(std::move(functions)));
13620-
lua_pushcclosure_x(L, &detail::invoke_proxy_constructor<F>, className, 1);
13620+
lua_pushcclosure_x(L, &detail::invoke_proxy_constructor<F>, "new", 1);
1362113621
lua_rawseti(L, -2, idx++);
1362213622
1362313623
} (), ...);
1362413624
13625-
lua_pushcclosure_x(L, &detail::try_overload_functions<false>, className, 2);
13625+
lua_pushcclosure_x(L, &detail::try_overload_functions<false>, "new", 2);
1362613626
}
1362713627
1362813628
rawsetfield(L, -2, "new");
@@ -13657,7 +13657,7 @@ class Namespace : public detail::Registrar
1365713657
using F = detail::factory_forwarder<T, Allocator, Deallocator>;
1365813658
1365913659
lua_newuserdata_aligned<F>(L, F(std::move(allocator), std::move(deallocator)));
13660-
lua_pushcclosure_x(L, &detail::invoke_proxy_constructor<F>, className, 1);
13660+
lua_pushcclosure_x(L, &detail::invoke_proxy_constructor<F>, "new", 1);
1366113661
rawsetfield(L, -2, "new");
1366213662
1366313663
return *this;

Source/LuaBridge/detail/Namespace.h

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,13 +1294,13 @@ class Namespace : public detail::Registrar
12941294
overload_set->entries.push_back(std::move(entry));
12951295

12961296
// OverloadSet is at stack top (upvalue[1]); constructor_placement_proxy ignores it.
1297-
lua_pushcclosure_x(L, &detail::constructor_placement_proxy<T, ArgsPack>, className, 1);
1297+
lua_pushcclosure_x(L, &detail::constructor_placement_proxy<T, ArgsPack>, "new", 1);
12981298

12991299
} (), ...);
13001300
#else
13011301
([&]
13021302
{
1303-
lua_pushcclosure_x(L, &detail::constructor_placement_proxy<T, detail::function_arguments_t<Functions>>, className, 0);
1303+
lua_pushcclosure_x(L, &detail::constructor_placement_proxy<T, detail::function_arguments_t<Functions>>, "new", 0);
13041304

13051305
} (), ...);
13061306
#endif
@@ -1332,12 +1332,12 @@ class Namespace : public detail::Registrar
13321332

13331333
([&]
13341334
{
1335-
lua_pushcclosure_x(L, &detail::constructor_placement_proxy<T, detail::function_arguments_t<Functions>>, className, 0);
1335+
lua_pushcclosure_x(L, &detail::constructor_placement_proxy<T, detail::function_arguments_t<Functions>>, "new", 0);
13361336
lua_rawseti(L, -2, idx++);
13371337

13381338
} (), ...);
13391339

1340-
lua_pushcclosure_x(L, &detail::try_overload_functions<false>, className, 2);
1340+
lua_pushcclosure_x(L, &detail::try_overload_functions<false>, "new", 2);
13411341
}
13421342

13431343
rawsetfield(L, -2, "new");
@@ -1389,10 +1389,10 @@ class Namespace : public detail::Registrar
13891389
}
13901390
// OverloadSet is now at stack top (upvalue[1]).
13911391
lua_newuserdata_aligned<F>(L, F(detail::get_underlying(std::move(functions)))); // upvalue[2]
1392-
lua_pushcclosure_x(L, &detail::invoke_proxy_constructor<F, 2>, className, 2);
1392+
lua_pushcclosure_x(L, &detail::invoke_proxy_constructor<F, 2>, "new", 2);
13931393
#else
13941394
lua_newuserdata_aligned<F>(L, F(detail::get_underlying(std::move(functions)))); // Stack: co, cl, st, upvalue
1395-
lua_pushcclosure_x(L, &detail::invoke_proxy_constructor<F>, className, 1); // Stack: co, cl, st, function
1395+
lua_pushcclosure_x(L, &detail::invoke_proxy_constructor<F>, "new", 1); // Stack: co, cl, st, function
13961396
#endif
13971397
} (), ...);
13981398
}
@@ -1440,12 +1440,12 @@ class Namespace : public detail::Registrar
14401440
using F = detail::constructor_forwarder<T, InnerF>;
14411441

14421442
lua_newuserdata_aligned<F>(L, F(detail::get_underlying(std::move(functions))));
1443-
lua_pushcclosure_x(L, &detail::invoke_proxy_constructor<F>, className, 1);
1443+
lua_pushcclosure_x(L, &detail::invoke_proxy_constructor<F>, "new", 1);
14441444
lua_rawseti(L, -2, idx++);
14451445

14461446
} (), ...);
14471447

1448-
lua_pushcclosure_x(L, &detail::try_overload_functions<false>, className, 2);
1448+
lua_pushcclosure_x(L, &detail::try_overload_functions<false>, "new", 2);
14491449
}
14501450

14511451
rawsetfield(L, -2, "new"); // Stack: co, cl, st
@@ -1467,7 +1467,7 @@ class Namespace : public detail::Registrar
14671467
{
14681468
([&]
14691469
{
1470-
lua_pushcclosure_x(L, &detail::constructor_container_proxy<C, detail::function_arguments_t<Functions>>, className, 0);
1470+
lua_pushcclosure_x(L, &detail::constructor_container_proxy<C, detail::function_arguments_t<Functions>>, "new", 0);
14711471

14721472
} (), ...);
14731473
}
@@ -1494,12 +1494,12 @@ class Namespace : public detail::Registrar
14941494

14951495
([&]
14961496
{
1497-
lua_pushcclosure_x(L, &detail::constructor_container_proxy<C, detail::function_arguments_t<Functions>>, className, 0);
1497+
lua_pushcclosure_x(L, &detail::constructor_container_proxy<C, detail::function_arguments_t<Functions>>, "new", 0);
14981498
lua_rawseti(L, -2, idx++);
14991499

15001500
} (), ...);
15011501

1502-
lua_pushcclosure_x(L, &detail::try_overload_functions<false>, className, 2);
1502+
lua_pushcclosure_x(L, &detail::try_overload_functions<false>, "new", 2);
15031503
}
15041504

15051505
rawsetfield(L, -2, "new");
@@ -1528,7 +1528,7 @@ class Namespace : public detail::Registrar
15281528
using F = detail::container_forwarder<C, Functions>;
15291529

15301530
lua_newuserdata_aligned<F>(L, F(std::move(functions))); // Stack: co, cl, st, upvalue
1531-
lua_pushcclosure_x(L, &detail::invoke_proxy_constructor<F>, className, 1); // Stack: co, cl, st, function
1531+
lua_pushcclosure_x(L, &detail::invoke_proxy_constructor<F>, "new", 1); // Stack: co, cl, st, function
15321532

15331533
} (), ...);
15341534
}
@@ -1566,12 +1566,12 @@ class Namespace : public detail::Registrar
15661566
using F = detail::container_forwarder<C, Functions>;
15671567

15681568
lua_newuserdata_aligned<F>(L, F(std::move(functions)));
1569-
lua_pushcclosure_x(L, &detail::invoke_proxy_constructor<F>, className, 1);
1569+
lua_pushcclosure_x(L, &detail::invoke_proxy_constructor<F>, "new", 1);
15701570
lua_rawseti(L, -2, idx++);
15711571

15721572
} (), ...);
15731573

1574-
lua_pushcclosure_x(L, &detail::try_overload_functions<false>, className, 2);
1574+
lua_pushcclosure_x(L, &detail::try_overload_functions<false>, "new", 2);
15751575
}
15761576

15771577
rawsetfield(L, -2, "new"); // Stack: co, cl, st
@@ -1616,7 +1616,7 @@ class Namespace : public detail::Registrar
16161616
using F = detail::factory_forwarder<T, Allocator, Deallocator>;
16171617

16181618
lua_newuserdata_aligned<F>(L, F(std::move(allocator), std::move(deallocator))); // Stack: co, cl, st, upvalue
1619-
lua_pushcclosure_x(L, &detail::invoke_proxy_constructor<F>, className, 1); // Stack: co, cl, st, function
1619+
lua_pushcclosure_x(L, &detail::invoke_proxy_constructor<F>, "new", 1); // Stack: co, cl, st, function
16201620
rawsetfield(L, -2, "new"); // Stack: co, cl, st
16211621

16221622
return *this;

Tests/Source/ClassTests.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3382,7 +3382,6 @@ TEST_F(ClassTests, BugWithLuauNotPrintingClassConstructorNameInErrors)
33823382
.beginNamespace("foo")
33833383
.beginClass<ClassWithMethod>("ClassWithMethod")
33843384
.addConstructor<void (*)(lua_State*)>()
3385-
.addFunction("methodWithError", &ClassWithMethod::methodWithError)
33863385
.endClass()
33873386
.endNamespace();
33883387

@@ -3400,7 +3399,6 @@ TEST_F(ClassTests, BugWithLuauNotPrintingClassMethodNameInErrors)
34003399
luabridge::getGlobalNamespace(L)
34013400
.beginNamespace("foo")
34023401
.beginClass<ClassWithMethod>("ClassWithMethod")
3403-
.addConstructor<void (*)(lua_State*)>()
34043402
.addFunction("methodWithError", &ClassWithMethod::methodWithError)
34053403
.endClass()
34063404
.endNamespace();

Tests/Source/Tests.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -751,13 +751,13 @@ TEST_F(LuaBridgeTest, InvokePassingUnregisteredClassShouldThrowAndRestoreStack)
751751
auto f1 = luabridge::getGlobal(L, "f1");
752752

753753
#if LUABRIDGE_HAS_EXCEPTIONS
754-
EXPECT_THROW(f1.call(unregistered), luabridge::LuaException);
754+
EXPECT_THROW(f1.call(unregistered), luabridge::LuaException);
755755
#else
756756
int stackTop = lua_gettop(L);
757757

758-
auto result = f1.call(unregistered);
759-
EXPECT_FALSE(result);
760-
EXPECT_EQ(luabridge::makeErrorCode(luabridge::ErrorCode::ClassNotRegistered), result.error());
758+
auto result = f1.call(unregistered);
759+
EXPECT_FALSE(result);
760+
EXPECT_EQ(luabridge::makeErrorCode(luabridge::ErrorCode::ClassNotRegistered), result.error());
761761

762762
EXPECT_EQ(stackTop, lua_gettop(L));
763763
#endif

0 commit comments

Comments
 (0)