mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-04-16 08:42:23 +00:00
Clean up
This commit is contained in:
parent
749c89e26e
commit
259f104311
@ -119,7 +119,7 @@ namespace
|
|||||||
auto table = makeTable();
|
auto table = makeTable();
|
||||||
LuaUi::Content::View content = makeContent(table);
|
LuaUi::Content::View content = makeContent(table);
|
||||||
EXPECT_ANY_THROW(content.at(0));
|
EXPECT_ANY_THROW(content.at(0));
|
||||||
EXPECT_EQ(content.size(), 0);
|
EXPECT_EQ(content.size(), 0);
|
||||||
content.assign(content.size(), makeTable());
|
content.assign(content.size(), makeTable());
|
||||||
EXPECT_EQ(content.size(), 1);
|
EXPECT_EQ(content.size(), 1);
|
||||||
content.assign(content.size(), makeTable());
|
content.assign(content.size(), makeTable());
|
||||||
|
@ -79,7 +79,8 @@ namespace LuaUi::Content
|
|||||||
{
|
{
|
||||||
if (index < size())
|
if (index < size())
|
||||||
// for some reason mTable[key] = value doesn't call __newindex
|
// 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
|
else
|
||||||
throw std::domain_error("Invalid Content index");
|
throw std::domain_error("Invalid Content index");
|
||||||
}
|
}
|
||||||
|
@ -34,10 +34,6 @@ local function getIndexFromKey(self, key)
|
|||||||
validateIndex(self, index)
|
validateIndex(self, index)
|
||||||
return index
|
return index
|
||||||
end
|
end
|
||||||
local function nameAt(self, index)
|
|
||||||
local v = rawget(self, index)
|
|
||||||
return v and type(v.name) == 'string' and v.name
|
|
||||||
end
|
|
||||||
local methods = {
|
local methods = {
|
||||||
insert = function(self, index, value)
|
insert = function(self, index, value)
|
||||||
validateIndex(self, index)
|
validateIndex(self, index)
|
||||||
@ -78,6 +74,10 @@ M.__index = function(self, key)
|
|||||||
local index = getIndexFromKey(self, key)
|
local index = getIndexFromKey(self, key)
|
||||||
return rawget(self, index)
|
return rawget(self, index)
|
||||||
end
|
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 function remove(self, index)
|
||||||
local oldName = nameAt(self, index)
|
local oldName = nameAt(self, index)
|
||||||
if oldName then
|
if oldName then
|
||||||
|
Loading…
x
Reference in New Issue
Block a user