From 8ec2e41bd6503204e5ce7a3f83c6086d1396871b Mon Sep 17 00:00:00 2001 From: raster Date: Fri, 9 Jul 2010 05:12:35 +0000 Subject: [PATCH] lua2 getting gooooooooooooooood. message method still needs work. git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/edje@50139 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- src/lib/edje_lua2.c | 158 +++++++++++++++++++++++++++++++++++++++++ src/lib/edje_lua_script_only.c | 50 ++++++------- src/lib/edje_private.h | 11 ++- src/lib/edje_program.c | 4 ++ src/lib/edje_smart.c | 2 + 5 files changed, 195 insertions(+), 30 deletions(-) diff --git a/src/lib/edje_lua2.c b/src/lib/edje_lua2.c index 8f3252b..f5fd86c 100644 --- a/src/lib/edje_lua2.c +++ b/src/lib/edje_lua2.c @@ -332,6 +332,164 @@ _elua_obj_del(lua_State *L) //------------------- //--------------- //------------- + +void +_edje_lua2_script_func_shutdown(Edje *ed) +{ + int err; + + lua_getglobal(ed->L, "shutdown"); + if (!lua_isnil(ed->L, -1)) + { + if ((err = lua_pcall(ed->L, 0, 0, 0))) + _edje_lua2_error(ed->L, err); + } + else + lua_pop(ed->L, 1); + _edje_lua2_script_shutdown(ed); +} + +void +_edje_lua2_script_func_show(Edje *ed) +{ + int err; + + lua_getglobal(ed->L, "show"); + if (!lua_isnil(ed->L, -1)) + { + if ((err = lua_pcall(ed->L, 0, 0, 0))) + _edje_lua2_error(ed->L, err); + } + else + lua_pop(ed->L, 1); +} + +void +_edje_lua2_script_func_hide(Edje *ed) +{ + int err; + + lua_getglobal(ed->L, "hide"); + if (!lua_isnil(ed->L, -1)) + { + if ((err = lua_pcall(ed->L, 0, 0, 0))) + _edje_lua2_error(ed->L, err); + } + else + lua_pop(ed->L, 1); +} + +void +_edje_lua2_script_func_move(Edje *ed) +{ + int err; + + lua_getglobal(ed->L, "move"); + if (!lua_isnil(ed->L, -1)) + { + lua_pushinteger(ed->L, ed->x); + lua_pushinteger(ed->L, ed->y); + if ((err = lua_pcall(ed->L, 2, 0, 0))) + _edje_lua2_error(ed->L, err); + } + else + lua_pop(ed->L, 1); +} + +void +_edje_lua2_script_func_resize(Edje *ed) +{ + int err; + + lua_getglobal(ed->L, "resize"); + if (!lua_isnil(ed->L, -1)) + { + lua_pushinteger(ed->L, ed->w); + lua_pushinteger(ed->L, ed->h); + if ((err = lua_pcall(ed->L, 2, 0, 0))) + _edje_lua2_error(ed->L, err); + } + else + lua_pop(ed->L, 1); +} + +void +_edje_lua2_script_func_message(Edje *ed, Edje_Message *em) +{ + int err; + + lua_getglobal(ed->L, "message"); + if (!lua_isnil(ed->L, -1)) + { + lua_pushinteger(ed->L, em->id); + switch (em->type) + { + case EDJE_MESSAGE_NONE: + lua_pushstring(ed->L, "none"); + break; + case EDJE_MESSAGE_SIGNAL: + printf("sig msg\n"); + break; + case EDJE_MESSAGE_STRING: + lua_pushstring(ed->L, "str"); + break; + case EDJE_MESSAGE_INT: + lua_pushstring(ed->L, "int"); + break; + case EDJE_MESSAGE_FLOAT: + lua_pushstring(ed->L, "float"); + break; + case EDJE_MESSAGE_STRING_SET: + lua_pushstring(ed->L, "strset"); + break; + case EDJE_MESSAGE_INT_SET: + lua_pushstring(ed->L, "intset"); + break; + case EDJE_MESSAGE_FLOAT_SET: + lua_pushstring(ed->L, "floatset"); + break; + case EDJE_MESSAGE_STRING_INT: + lua_pushstring(ed->L, "strint"); + break; + case EDJE_MESSAGE_STRING_FLOAT: + lua_pushstring(ed->L, "strfloat"); + break; + case EDJE_MESSAGE_STRING_INT_SET: + lua_pushstring(ed->L, "strintset"); + break; + case EDJE_MESSAGE_STRING_FLOAT_SET: + lua_pushstring(ed->L, "strfloatset"); + break; + default: + break; + } + if ((err = lua_pcall(ed->L, 2, 0, 0))) + _edje_lua2_error(ed->L, err); + } + else + lua_pop(ed->L, 1); +} + +void +_edje_lua2_script_func_signal(Edje *ed, const char *sig, const char *src) +{ + int err; + + lua_getglobal(ed->L, "signal"); + if (!lua_isnil(ed->L, -1)) + { + lua_pushstring(ed->L, sig); + lua_pushstring(ed->L, src); + if ((err = lua_pcall(ed->L, 2, 0, 0))) + _edje_lua2_error(ed->L, err); + } + else + lua_pop(ed->L, 1); +} + +//------------- +//------------- +//------------- static int _elua_echo(lua_State *L) { diff --git a/src/lib/edje_lua_script_only.c b/src/lib/edje_lua_script_only.c index 164374d..90d669a 100644 --- a/src/lib/edje_lua_script_only.c +++ b/src/lib/edje_lua_script_only.c @@ -73,20 +73,7 @@ _edje_lua_script_only_shutdown(Edje *ed) if (ed->collection && ed->L) { #ifdef LUA2 - int err; - - if (ed->L) - { - lua_getglobal(ed->L, "shutdown"); - if (!lua_isnil(ed->L, -1)) - { - if ((err = lua_pcall(ed->L, 0, 0, 0))) - _edje_lua2_error(ed->L, err); - } - else - lua_pop(ed->L, 1); - } - _edje_lua2_script_shutdown(ed); + _edje_lua2_script_func_shutdown(ed); #else lua_State *L = ed->L; lua_getglobal(L, "shutdown"); @@ -110,10 +97,11 @@ _edje_lua_script_only_shutdown(Edje *ed) void _edje_lua_script_only_show(Edje * ed) { -#ifdef LUA2 -#else if (ed->collection && ed->L) { +#ifdef LUA2 + _edje_lua2_script_func_show(ed); +#else lua_State *L = ed->L; lua_getglobal(L, "show"); if (!lua_isnil (L, -1)) @@ -129,17 +117,18 @@ _edje_lua_script_only_show(Edje * ed) } else lua_pop (L, 1); - } #endif + } } void _edje_lua_script_only_hide(Edje * ed) { -#ifdef LUA2 -#else if (ed->collection && ed->L) { +#ifdef LUA2 + _edje_lua2_script_func_hide(ed); +#else lua_State *L = ed->L; lua_getglobal(L, "hide"); if (!lua_isnil (L, -1)) @@ -155,17 +144,18 @@ _edje_lua_script_only_hide(Edje * ed) } else lua_pop (L, 1); - } #endif + } } void _edje_lua_script_only_move(Edje * ed) { -#ifdef LUA2 -#else if (ed->collection && ed->L) { +#ifdef LUA2 + _edje_lua2_script_func_move(ed); +#else lua_State *L = ed->L; lua_getglobal(L, "move"); if (!lua_isnil (L, -1)) @@ -183,17 +173,18 @@ _edje_lua_script_only_move(Edje * ed) } else lua_pop (L, 1); - } #endif + } } void _edje_lua_script_only_resize(Edje * ed) { -#ifdef LUA2 -#else if (ed->collection && ed->L) { +#ifdef LUA2 + _edje_lua2_script_func_resize(ed); +#else lua_State *L = ed->L; lua_getglobal(L, "resize"); if (!lua_isnil (L, -1)) @@ -211,17 +202,18 @@ _edje_lua_script_only_resize(Edje * ed) } else lua_pop (L, 1); - } #endif + } } void _edje_lua_script_only_message(Edje * ed, Edje_Message * em) { -#ifdef LUA2 -#else if (ed->collection && ed->L) { +#ifdef LUA2 + _edje_lua2_script_func_message(ed, em); +#else lua_State *L = ed->L; lua_getglobal(L, "message"); if (!lua_isnil (L, -1)) @@ -325,7 +317,7 @@ _edje_lua_script_only_message(Edje * ed, Edje_Message * em) } else lua_pop (L, 1); - } #endif + } } diff --git a/src/lib/edje_private.h b/src/lib/edje_private.h index df73ed8..5a3171f 100644 --- a/src/lib/edje_private.h +++ b/src/lib/edje_private.h @@ -1655,7 +1655,7 @@ void _edje_module_shutdown(); // new lua stuff - supercedes the old -//#define LUA2 1 +#define LUA2 1 #ifdef LUA2 void _edje_lua2_error_full(const char *file, const char *fnc, int line, lua_State *L, int err_code); @@ -1664,6 +1664,15 @@ void _edje_lua2_script_init(Edje *ed); void _edje_lua2_script_shutdown(Edje *ed); void _edje_lua2_script_load(Edje_Part_Collection *edc, void *data, int size); void _edje_lua2_script_unload(Edje_Part_Collection *edc); + +void _edje_lua2_script_func_shutdown(Edje *ed); +void _edje_lua2_script_func_show(Edje *ed); +void _edje_lua2_script_func_hide(Edje *ed); +void _edje_lua2_script_func_move(Edje *ed); +void _edje_lua2_script_func_resize(Edje *ed); +void _edje_lua2_script_func_message(Edje *ed, Edje_Message *em); +void _edje_lua2_script_func_signal(Edje *ed, const char *sig, const char *src); + #endif #include "edje_convert.h" diff --git a/src/lib/edje_program.c b/src/lib/edje_program.c index df6d8d5..4356e00 100644 --- a/src/lib/edje_program.c +++ b/src/lib/edje_program.c @@ -1199,6 +1199,10 @@ _edje_emit_handle(Edje *ed, const char *sig, const char *src) _edje_block(ed); _edje_ref(ed); _edje_freeze(ed); +#ifdef LUA2 + if (ed->collection && ed->L) + _edje_lua2_script_func_signal(ed, sig, src); +#endif if (ed->collection) { Edje_Part_Collection *ec; diff --git a/src/lib/edje_smart.c b/src/lib/edje_smart.c index ba6f1b8..2c9817e 100644 --- a/src/lib/edje_smart.c +++ b/src/lib/edje_smart.c @@ -234,6 +234,7 @@ _edje_smart_show(Evas_Object * obj) ed = evas_object_smart_data_get(obj); if (!ed) return; + if (evas_object_visible_get(obj)) return; if (evas_object_visible_get(ed->clipper)) return; if ((ed->collection) && (evas_object_clipees_get(ed->clipper))) evas_object_show(ed->clipper); @@ -257,6 +258,7 @@ _edje_smart_hide(Evas_Object * obj) ed = evas_object_smart_data_get(obj); if (!ed) return; + if (!evas_object_visible_get(obj)) return; if (!evas_object_visible_get(ed->clipper)) return; if ((ed->collection) && (evas_object_clipees_get(ed->clipper))) evas_object_hide(ed->clipper); -- 2.7.4