diff options
author | Shinwoo Kim <cinoo.kim@samsung.com> | 2016-03-09 15:10:26 +0900 |
---|---|---|
committer | Shinwoo Kim <cinoo.kim@samsung.com> | 2016-03-09 15:11:12 +0900 |
commit | a5f2d81dea516cd8072c61e7dc180f03a45e8e0c (patch) | |
tree | 7f7ecf878b4f65c5b59201ba18ece62550631e67 | |
parent | 17e1ad13c6424f0847b5cdc875294fdc6ef90135 (diff) | |
download | screen-reader-a5f2d81dea516cd8072c61e7dc180f03a45e8e0c.tar.gz screen-reader-a5f2d81dea516cd8072c61e7dc180f03a45e8e0c.tar.bz2 screen-reader-a5f2d81dea516cd8072c61e7dc180f03a45e8e0c.zip |
Revert "mobile-lua: add additional LABELLED_BY relation"
This reverts commit 9d9260eadb124a7418855e7d06afccae66cc0667.
Change-Id: Ie9e30cacaae0c2ee793073c4de1b936701c9e4ae
-rw-r--r-- | res/scripts/mobile.lua | 44 | ||||
-rw-r--r-- | src/lua_engine.c | 6 |
2 files changed, 11 insertions, 39 deletions
diff --git a/res/scripts/mobile.lua b/res/scripts/mobile.lua index 39d5396..c53c2e0 100644 --- a/res/scripts/mobile.lua +++ b/res/scripts/mobile.lua @@ -114,44 +114,16 @@ function trait(obj) end end -function stringArrayAppend(strings, string) - if string ~= "" then - table.insert(strings, string) - end -end - -function generateStringArray(objects, createFunc) - local ret = {} - for k, target in ipairs(objects) do - stringArrayAppend(ret, createFunc(target)) - end - return ret -end - function describeObject(obj) - local labels = generateStringArray(obj:inRelation(RELATION_LABELLED_BY), function(x) return x:name() end) - local descriptions = generateStringArray(obj:inRelation(RELATION_DESCRIBED_BY), function(x) return x:description() end) - local traits = generateStringArray(obj:inRelation(RELATION_DESCRIBED_BY), trait) - - -- use original object name if related objects do not provide other - if table.getn(labels) == 0 then - stringArrayAppend(labels, obj:name()) - end - - -- use original object description if related objects do not provide other - if table.getn(descriptions) == 0 then - stringArrayAppend(descriptions, obj:description()) + local related_trait = {} + for k, target in ipairs(obj:inRelation(RELATION_DESCRIBED_BY)) do + table.insert(related_trait, trait(target)) end - - -- use original object trait if related objects do not provide other - if table.getn(traits) == 0 then - stringArrayAppend(traits, trait(obj)) + local ret = {obj:name(), trait(obj), obj:description(), table.concat(related_trait, ", ")} + for i=#ret,1,-1 do + if ret[i] == nil or ret[i] == "" then + table.remove(ret, i) + end end - - local ret = {} - stringArrayAppend(ret, table.concat(labels, ", ")) - stringArrayAppend(ret, table.concat(traits, ", ")) - stringArrayAppend(ret, table.concat(descriptions, ", ")) - return table.concat(ret, ", ") end diff --git a/src/lua_engine.c b/src/lua_engine.c index 76cd94f..b2d8207 100644 --- a/src/lua_engine.c +++ b/src/lua_engine.c @@ -166,7 +166,7 @@ static int _accessible_relations(lua_State *L) { AtspiAccessible *obj = _pop_class_obj(L, 1, 1, ACCESSIBLE_CLASS_NAME); AtspiRelationType type = lua_tonumber(L, -1); GError *err = NULL; - int i, j, idx; + int i, j; lua_newtable(L); if (!obj) return 1; @@ -174,7 +174,7 @@ static int _accessible_relations(lua_State *L) { GERROR_CHECK(err); if (!rels) return 1; - for (i = 0, idx = 1; i < rels->len; i++) + for (i = 0; i < rels->len; i++) { AtspiRelation *rel = g_array_index(rels, AtspiRelation*, i); if (atspi_relation_get_relation_type(rel) == type) @@ -183,7 +183,7 @@ static int _accessible_relations(lua_State *L) { { AtspiAccessible *target = atspi_relation_get_target(rel, j); if (!target) continue; - lua_pushinteger(L, idx++); + lua_pushinteger(L, j); _push_class_obj(L, target, ACCESSIBLE_CLASS_NAME); lua_settable(L, -3); } |