mirror of
https://github.com/gnosygnu/xowa.git
synced 2024-10-27 20:34:16 +00:00
Scribunto: Make table accessible from datawrapper in mw.lua [#586]
This commit is contained in:
parent
bb86b026fe
commit
1bffdadbaf
@ -35,6 +35,14 @@ class Luaj_value_ {
|
|||||||
int rv_idx = 0;
|
int rv_idx = 0;
|
||||||
LuaValue cur = LuaValue.NIL; // needed for luaj iterator; tbl.next(cur);
|
LuaValue cur = LuaValue.NIL; // needed for luaj iterator; tbl.next(cur);
|
||||||
|
|
||||||
|
// override tbl with xo_orig_table from mw.lua.dataWrapper; ISSUE#:586: DATE:2019-10-29
|
||||||
|
LuaValue metatable_obj = tbl.getmetatable();
|
||||||
|
if (metatable_obj != null && !metatable_obj.isnil()) {
|
||||||
|
LuaValue orig_data_obj = ((LuaTable)metatable_obj).get("xo_orig_data");
|
||||||
|
if (orig_data_obj != null && !orig_data_obj.isnil())
|
||||||
|
tbl = (LuaTable)orig_data_obj;
|
||||||
|
}
|
||||||
|
|
||||||
// loop over pairs in tbl; no direct way to get kvs
|
// loop over pairs in tbl; no direct way to get kvs
|
||||||
while (true) {
|
while (true) {
|
||||||
// get next itm
|
// get next itm
|
||||||
|
@ -19,7 +19,11 @@ function mw.dump_table(o)
|
|||||||
if type(o) == 'table' then
|
if type(o) == 'table' then
|
||||||
local s = '{ '
|
local s = '{ '
|
||||||
for k,v in pairs(o) do
|
for k,v in pairs(o) do
|
||||||
if type(k) ~= 'number' then k = '"'..k..'"' end
|
if type(k) == 'table' then
|
||||||
|
k = mw.dump_table(k)
|
||||||
|
elseif type(k) ~= 'number' then
|
||||||
|
k = '"'..k..'"'
|
||||||
|
end
|
||||||
dump_table_count = dump_table_count + 1;
|
dump_table_count = dump_table_count + 1;
|
||||||
s = s .. '['..k..'] = ' .. mw.dump_table(v) .. ','
|
s = s .. '['..k..'] = ' .. mw.dump_table(v) .. ','
|
||||||
dump_table_count = dump_table_count - 1;
|
dump_table_count = dump_table_count - 1;
|
||||||
@ -712,6 +716,7 @@ local function dataWrapper( data, seen )
|
|||||||
end
|
end
|
||||||
|
|
||||||
local mt = {
|
local mt = {
|
||||||
|
xo_orig_data = data, -- tbl.next does not retrieve data from datawrapper; ISSUE#:586: DATE:2019-10-29
|
||||||
mw_loadData = true,
|
mw_loadData = true,
|
||||||
__index = function ( tt, k )
|
__index = function ( tt, k )
|
||||||
assert( t == tt )
|
assert( t == tt )
|
||||||
|
Loading…
Reference in New Issue
Block a user