7220-lua-add-a-general-purpose-lexical-parser
uramer 2 years ago
parent 749c89e26e
commit 259f104311

@ -119,7 +119,7 @@ namespace
auto table = makeTable();
LuaUi::Content::View content = makeContent(table);
EXPECT_ANY_THROW(content.at(0));
EXPECT_EQ(content.size(), 0);
EXPECT_EQ(content.size(), 0);
content.assign(content.size(), makeTable());
EXPECT_EQ(content.size(), 1);
content.assign(content.size(), makeTable());

@ -79,7 +79,8 @@ namespace LuaUi::Content
{
if (index < size())
// for some reason mTable[key] = value doesn't call __newindex
mTable[sol::metatable_key][sol::meta_function::new_index].get<sol::protected_function>()(mTable, toLua(index), sol::nil);
mTable[sol::metatable_key][sol::meta_function::new_index].get<sol::protected_function>()(
mTable, toLua(index), sol::nil);
else
throw std::domain_error("Invalid Content index");
}

@ -34,10 +34,6 @@ local function getIndexFromKey(self, key)
validateIndex(self, index)
return index
end
local function nameAt(self, index)
local v = rawget(self, index)
return v and type(v.name) == 'string' and v.name
end
local methods = {
insert = function(self, index, value)
validateIndex(self, index)
@ -78,6 +74,10 @@ M.__index = function(self, key)
local index = getIndexFromKey(self, key)
return rawget(self, index)
end
local function nameAt(self, index)
local v = rawget(self, index)
return v and type(v.name) == 'string' and v.name
end
local function remove(self, index)
local oldName = nameAt(self, index)
if oldName then

Loading…
Cancel
Save