lua2 getting gooooooooooooooood. message method still needs work.

SVN revision: 50139
This commit is contained in:
Carsten Haitzler 2010-07-09 05:12:35 +00:00
parent 442fe3afae
commit 519ca3be8b
5 changed files with 195 additions and 30 deletions

View File

@ -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)
{

View File

@ -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
}
}

View File

@ -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"

View File

@ -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;

View File

@ -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);