implement shared_table constructor (#52)
This commit is contained in:
parent
cfd2e9b39d
commit
720c3aeac4
2
libs/sol
2
libs/sol
@ -1 +1 @@
|
||||
Subproject commit 3342e65b385aac57caca3b8284713682c9ea1211
|
||||
Subproject commit 0fb52a11520e049c0cf809254f7e862bac3a55fa
|
||||
@ -18,7 +18,13 @@ sol::object createThread(const sol::this_state& lua,
|
||||
return sol::make_object(lua, std::make_shared<Thread>(path, cpath, step, function, args));
|
||||
}
|
||||
|
||||
sol::object createTable(sol::this_state lua) {
|
||||
sol::object createTable(sol::this_state lua, const sol::optional<sol::object>& tbl) {
|
||||
if (tbl)
|
||||
{
|
||||
REQUIRE(tbl->get_type() == sol::type::table) << "Unexpected type for effil.table, table expected got: "
|
||||
<< lua_typename(lua, (int)tbl->get_type());
|
||||
return createStoredObject(*tbl)->unpack(lua);
|
||||
}
|
||||
return sol::make_object(lua, GC::instance().create<SharedTable>());
|
||||
}
|
||||
|
||||
|
||||
@ -2,6 +2,16 @@ require "bootstrap-tests"
|
||||
|
||||
test.shared_table.tear_down = default_tear_down
|
||||
|
||||
test.shared_table.constructor = function ()
|
||||
local share = effil.table {
|
||||
key = "value"
|
||||
}
|
||||
test.equal(share.key, "value")
|
||||
test.equal(pcall(effil.table, ""), false)
|
||||
test.equal(pcall(effil.table, 22), false)
|
||||
test.equal(pcall(effil.table, effil.table()), false)
|
||||
end
|
||||
|
||||
test.shared_table.pairs = function ()
|
||||
local share = effil.table()
|
||||
local data = { 0, 0, 0, ["key1"] = 0, ["key2"] = 0, ["key3"] = 0 }
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user