From 9bc6d9c266c44487899a6b621d135758f5fed6e1 Mon Sep 17 00:00:00 2001 From: onefang Date: Thu, 17 Nov 2011 18:38:23 +0000 Subject: [PATCH] Make a better messaeg callback example. git-svn-id: http://svn.enlightenment.org/svn/e/trunk/edje@65348 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- src/examples/lua_script.edc | 47 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/src/examples/lua_script.edc b/src/examples/lua_script.edc index 001681e..d347e44 100644 --- a/src/examples/lua_script.edc +++ b/src/examples/lua_script.edc @@ -21,7 +21,29 @@ collections { local count = 0; local fndata = 99; local text_geom; - + + --// Functions to print tables. + local print_table, print_table_start; + + function print_table_start(table, space, name) + print(space .. name .. ": "); + print(space .. "{"); + print_table(table, space .. " "); + print(space .. "}"); + end + + function print_table(table, space) + for k, v in pairs(table) do + if type(v) == "table" then + print_table_start(v, space, k); + elseif type(v) == "string" then + print(space .. k .. ': "' .. v .. '";') + else + print(space .. k .. ": " .. v .. ";") + end + end + end + local function mycb3 (v) print("lua::callback transition " .. D.val .. " v: " .. v); d = {}; @@ -255,6 +277,29 @@ collections { --// vararg appropriately. they are the same as the params passed --// to edje:messagesend() (if any are passed at all). Any array --// arguments are passed as a single table. + + if ("none" == type) then + print("lua::message no args"); + elseif ("strset" == type) then + strs = ... ; + print_table_start(strs, "", "lua::message strings"); + elseif ("intset" == type) then + ints = ... ; + print_table_start(ints, "", "lua::message ints"); + elseif ("floatset" == type) then + floats = ... ; + print_table_start(floats, "", "lua::message floats"); + elseif ("strintset" == type) then + str, ints = ... ; + print("lua::message " .. str); + print_table_start(ints, "", "lua::message ints"); + elseif ("strfloatset" == type) then + str, floats = ... ; + print("lua::message " .. str); + print_table_start(floats, "", "lua::message floats"); + else + print("lua::message " .. ... ); + end end function signal (sig, src) -- 2.7.4