Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Source/LuaBridge/detail/Namespace.h
Original file line number Diff line number Diff line change
Expand Up @@ -347,9 +347,13 @@ class Namespace : public detail::Registrar
}
else
{
LUABRIDGE_ASSERT(lua_istable(L, -1)); // Stack: ns, st
LUABRIDGE_ASSERT(lua_istable(L, -1)); // Stack: ns, vst
++m_stackSize;

lua_getmetatable(L, -1); // Stack: ns, vst, st
lua_insert(L, -2); // Stack: ns, st, vst
lua_pop(L, 1); // Stack: ns, st

// Map T back from its stored tables

lua_rawgetp(L, LUA_REGISTRYINDEX, detail::getConstRegistryKey<T>()); // Stack: ns, st, co
Expand Down
21 changes: 21 additions & 0 deletions Tests/Source/ClassTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1718,6 +1718,27 @@ TEST_F(ClassStaticProperties, FieldPointers_Overridden)
ASSERT_EQ(7, Derived::staticData);
}

TEST_F(ClassStaticProperties, SubsequentRegistration)
{
using Int = Class<int, EmptyBase>;

luabridge::getGlobalNamespace(L)
.beginClass<Int>("Int")
.endClass()
.beginClass<Int>("Int")
.addStaticProperty("staticData", &Int::staticData, true)
.endClass();

Int::staticData = 10;

runLua("result = Int.staticData");
ASSERT_TRUE(result().isNumber());
ASSERT_EQ(10, result<int>());

runLua("Int.staticData = 20");
ASSERT_EQ(20, Int::staticData);
}

struct ClassMetaMethods : ClassTests
{
};
Expand Down