From 5ff4a5b2721f4f77c667ec92395b1eb4495af546 Mon Sep 17 00:00:00 2001 From: Carsten Haitzler Date: Fri, 2 Jul 2004 10:17:25 +0000 Subject: [PATCH] fully supported message queues now. that was a chunk of work! SVN revision: 10663 --- legacy/edje/data/include/edje.inc | 2 + legacy/edje/data/src/e_logo.edc | 58 ++++- legacy/edje/data/src/test.edc | 15 +- legacy/edje/src/bin/edje_main.c | 20 +- legacy/edje/src/lib/Edje.h | 36 +-- legacy/edje/src/lib/Edje_Edit.h | 6 +- legacy/edje/src/lib/edje_embryo.c | 267 +++++++++++++++++++++-- legacy/edje/src/lib/edje_message_queue.c | 223 +++++++++++-------- legacy/edje/src/lib/edje_misc.c | 127 ----------- legacy/edje/src/lib/edje_private.h | 34 ++- legacy/edje/src/lib/edje_program.c | 2 +- 11 files changed, 499 insertions(+), 291 deletions(-) diff --git a/legacy/edje/data/include/edje.inc b/legacy/edje/data/include/edje.inc index b22d824efd..a24ce4919b 100644 --- a/legacy/edje/data/include/edje.inc +++ b/legacy/edje/data/include/edje.inc @@ -96,3 +96,5 @@ enum Msg_Type MSG_STRING_INT_SET = 10, MSG_INT_FLOAT_SET = 11 }; + +native send_message(Msg_Type:type, id, ...); diff --git a/legacy/edje/data/src/e_logo.edc b/legacy/edje/data/src/e_logo.edc index 457ddaeef0..a63ed72db8 100644 --- a/legacy/edje/data/src/e_logo.edc +++ b/legacy/edje/data/src/e_logo.edc @@ -147,17 +147,59 @@ collections { public global_float; public global_str; + public global_click_count; + public timer_cb(val) { emit("PROGRAAAAAAAM", "TIMER@!@!@!@!@!@!@!"); } - public anim_cb(val, Float: pos) + public anim_cb(val, Float: pos) { new buf[100]; snprintf(buf, 100, "val = %i, pos = %f", val, pos); emit("PR AAAAAAAAANIM", buf); } + + public message(Msg_Type:type, id, ...) + { + emit("MSG", "PROCESS"); + if (type == MSG_NONE) + { + new buf[100]; + + snprintf(buf, sizeof(buf), "ID: %i", id); + emit("MESSAGE_NONE", buf); + } + else if (type == MSG_STRING) + { + new str[100]; + new buf[100]; + + snprintf(buf, sizeof(buf), "MESSAGE STRING ID: %i", id); + for (new j = 0; j < (sizeof(str) - 1); j++) + { + str[j] = getarg(2, j); + if (str[j] == 0) break; + } + emit(buf, str); + } + else if (type == MSG_INT_SET) + { + new buf[100]; + + snprintf(buf, sizeof(buf), "MESSAGE INT SET ID: %i", id); + for (new i = 2; i < numargs(); i++) + { + new val; + new str[100]; + + val = getarg(i); + snprintf(str, sizeof(str), "V %i", val); + emit(buf, str); + } + } + } } parts { part { @@ -632,6 +674,20 @@ collections { } program { name: "logo_click_d2"; + signal: "mouse,down,2"; + source: "logo"; + script { + new i = get_int(global_click_count); + set_int(global_click_count, i + 1); + + if (i < 5) + send_message(MSG_NONE, 777); + else if (i < 10) + send_message(MSG_STRING, 123, "blah blah panties"); + } + } + program { + name: "logo_click_d3"; signal: "mouse,down,3"; source: "logo"; action: DRAG_VAL_STEP -1.0 -1.0; diff --git a/legacy/edje/data/src/test.edc b/legacy/edje/data/src/test.edc index 484bb7003e..ab6123694a 100644 --- a/legacy/edje/data/src/test.edc +++ b/legacy/edje/data/src/test.edc @@ -66,27 +66,40 @@ collections // handle messages from apps public message(Msg_Type:type, id, ...) { + emit("MSG", "PROCESS"); if (type == MSG_NONE) { + new buf[100]; + + snprintf(buf, sizeof(buf), "ID: %i", id); + emit("MESSAGE_NONE", buf); } else if (type == MSG_STRING) { new str[100]; + new buf[100]; + snprintf(buf, sizeof(buf), "MESSAGE STRING ID: %i", id); for (new j = 0; j < (sizeof(str) - 1); j++) { str[j] = getarg(2, j); if (str[j] == 0) break; } + emit(buf, str); } else if (type == MSG_INT_SET) { + new buf[100]; + + snprintf(buf, sizeof(buf), "MESSAGE INT SET ID: %i", id); for (new i = 2; i < numargs(); i++) { new val; + new str[100]; val = getarg(i); - if (val > 9999) break; + snprintf(str, sizeof(str), "V %i", val); + emit(buf, str); } } } diff --git a/legacy/edje/src/bin/edje_main.c b/legacy/edje/src/bin/edje_main.c index f9b31f1b85..92d24dd0db 100644 --- a/legacy/edje/src/bin/edje_main.c +++ b/legacy/edje/src/bin/edje_main.c @@ -643,6 +643,21 @@ test_resize(Demo_Edje *de) evas_object_resize(de->edje, w - 20, h - 30); } +static void +message_cb(void *data, Evas_Object *obj, Edje_Message_Type type, int id, void *msg) +{ + printf("MESSAGE for %p from script type %i id %i\n", obj, type, id); + if (type == EDJE_MESSAGE_STRING) + { + Edje_Message_String *emsg; + + emsg = (Edje_Message_String *)msg; + printf("STWING: \"%s\"\n", emsg->str); + } + printf("Send msg to script...\n"); + edje_object_message_send(obj, EDJE_MESSAGE_NONE, 12345, NULL); +} + void test_setup(char *file, char *name) { @@ -733,14 +748,15 @@ test_setup(char *file, char *name) de->title = o; o = edje_object_add(evas); + edje_object_message_handler_set(o, message_cb, NULL); // edje_object_signal_callback_add(o, "do_it", "the_source", cb, NULL); // edje_object_signal_callback_add(o, "mouse,*", "logo", cb, NULL); edje_object_signal_callback_add(o, "*", "*", cb, NULL); edje_object_file_set(o, file, name); edje_object_part_drag_size_set(o, "dragable", 0.01, 0.5); // edje_object_part_drag_value_set(o, "dragable", 0.5, 0.5); -edje_object_part_drag_step_set(o, "dragable", 0.1, 0.1); -edje_object_part_drag_page_set(o, "dragable", 0.2, 0.2); + edje_object_part_drag_step_set(o, "dragable", 0.1, 0.1); + edje_object_part_drag_page_set(o, "dragable", 0.2, 0.2); evas_object_move(o, xx + 10, yy + 20); evas_object_show(o); edje_object_size_min_get(o, &(de->minw), &(de->minh)); diff --git a/legacy/edje/src/lib/Edje.h b/legacy/edje/src/lib/Edje.h index 02db8bf2d0..37727ee58e 100644 --- a/legacy/edje/src/lib/Edje.h +++ b/legacy/edje/src/lib/Edje.h @@ -4,18 +4,11 @@ #include /* FIXDOC: Define these? */ - -typedef enum _Edje_Queue -{ - EDJE_QUEUE_APP, - EDJE_QUEUE_SCRIPT -} Edje_Queue; - typedef enum _Edje_Message_Type { EDJE_MESSAGE_NONE = 0, - EDJE_MESSAGE_SIGNAL = 1, + EDJE_MESSAGE_SIGNAL = 1, /* DONT USE THIS */ EDJE_MESSAGE_STRING = 2, EDJE_MESSAGE_INT = 3, @@ -32,7 +25,6 @@ typedef enum _Edje_Message_Type EDJE_MESSAGE_STRING_FLOAT_SET = 11 } Edje_Message_Type; -typedef struct _Edje_Message_Signal Edje_Message_Signal; typedef struct _Edje_Message_String Edje_Message_String; typedef struct _Edje_Message_Int Edje_Message_Int; typedef struct _Edje_Message_Float Edje_Message_Float; @@ -44,12 +36,6 @@ typedef struct _Edje_Message_String_Float Edje_Message_String_Float; typedef struct _Edje_Message_String_Int_Set Edje_Message_String_Int_Set; typedef struct _Edje_Message_String_Float_Set Edje_Message_String_Float_Set; -struct _Edje_Message_Signal -{ - char *sig; - char *src; -}; - struct _Edje_Message_String { char *str; @@ -133,9 +119,6 @@ enum extern "C" { #endif - /* Documentation is within .c files */ - /* Doc issues marked with FIXDOC: */ - /* edje_main.c */ int edje_init (void); int edje_shutdown (void); @@ -189,8 +172,8 @@ extern "C" { void edje_object_size_min_calc (Evas_Object *obj, Evas_Coord *minw, Evas_Coord *minh); int edje_object_part_exists (Evas_Object *obj, const char *part); void edje_object_part_geometry_get (Evas_Object *obj, const char *part, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h); - void edje_object_text_change_cb_set(Evas_Object *obj, void (*func) (void *data, Evas_Object *obj, const char *part), void *data); - void edje_object_part_text_set (Evas_Object *obj, const char *part, const char *text); + void edje_object_text_change_cb_set (Evas_Object *obj, void (*func) (void *data, Evas_Object *obj, const char *part), void *data); + void edje_object_part_text_set (Evas_Object *obj, const char *part, const char *text); const char *edje_object_part_text_get (Evas_Object *obj, const char *part); void edje_object_part_swallow (Evas_Object *obj, const char *part, Evas_Object *obj_swallow); void edje_object_part_unswallow (Evas_Object *obj, Evas_Object *obj_swallow); @@ -208,15 +191,10 @@ extern "C" { void edje_object_part_drag_step (Evas_Object *obj, const char *part, double dx, double dy); void edje_object_part_drag_page (Evas_Object *obj, const char *part, double dx, double dy); - /* edje_misc.c */ - int edje_object_variable_id_get (Evas_Object *obj, char *name); - int edje_object_variable_int_get (Evas_Object *obj, int id); - void edje_object_variable_int_set (Evas_Object *obj, int id, int val); - double edje_object_variable_float_get (Evas_Object *obj, int id); - void edje_object_variable_float_set (Evas_Object *obj, int id, double val); - char *edje_object_variable_str_get (Evas_Object *obj, int id); - void edje_object_variable_str_set (Evas_Object *obj, int id, char *str); - + /* edje_message_queue.c */ + void edje_object_message_send (Evas_Object *obj, Edje_Message_Type type, int id, void *msg); + void edje_object_message_handler_set (Evas_Object *obj, void (*func) (void *data, Evas_Object *obj, Edje_Message_Type type, int id, void *msg), void *data); + #ifdef __cplusplus } #endif diff --git a/legacy/edje/src/lib/Edje_Edit.h b/legacy/edje/src/lib/Edje_Edit.h index f2f45cef27..069750cee9 100644 --- a/legacy/edje/src/lib/Edje_Edit.h +++ b/legacy/edje/src/lib/Edje_Edit.h @@ -445,7 +445,11 @@ struct _Edje void *data; } text_change; - int message_num; + struct { + int num; + void (*func) (void *data, Evas_Object *obj, Edje_Message_Type type, int id, void *msg); + void *data; + } message; }; struct _Edje_Real_Part diff --git a/legacy/edje/src/lib/edje_embryo.c b/legacy/edje/src/lib/edje_embryo.c index bbf0923a5f..67cc0601ff 100644 --- a/legacy/edje/src/lib/edje_embryo.c +++ b/legacy/edje/src/lib/edje_embryo.c @@ -78,28 +78,6 @@ static void _edje_embryo_globals_init(Edje *ed); * get_strlen(id) * get_str(id, dst[], maxlen) * set_str(id, str[]) - * ######## lists/arrays for stored variables (to be implemented) - * # count(id) - * # remove(id, n) - * # - * # append_int(id, v) - * # prepend_int(id, v) - * # insert_int(id, v, n) - * # replace_int(id, v, n) - * # fetch_int(id, n) - * # - * # append_float(id, Float:v) - * # prepend_float(id, Float:v) - * # insert_float(id, Float:v, n) - * # replace_float(id, Float:v, n) - * # Float:fetch_float(id, n) - * # - * # append_str(id, str[]) - * # prepend_str(id, str[]) - * # insert_str(id, str[], n) - * # replace_str(id, str[], n) - * # fetch_str(id, n, dst[], maxlen) - * # * timer(Float:in, fname[], val) * cancel_timer(id) * anim(Float:len, fname[], val) @@ -132,10 +110,32 @@ static void _edje_embryo_globals_init(Edje *ed); * still need to implement this: * * ##### post messages to the app via _edje_message_send(); - * # message(id, type, ...); + * # send_message(id, type, ...); * # * ##### what about posting messages to OTHER edje objects (swallowed?) * # ???? + * ######## lists/arrays for stored variables (to be implemented) + * # count(id) + * # remove(id, n) + * # + * # append_int(id, v) + * # prepend_int(id, v) + * # insert_int(id, v, n) + * # replace_int(id, v, n) + * # fetch_int(id, n) + * # + * # append_float(id, Float:v) + * # prepend_float(id, Float:v) + * # insert_float(id, Float:v, n) + * # replace_float(id, Float:v, n) + * # Float:fetch_float(id, n) + * # + * # append_str(id, str[]) + * # prepend_str(id, str[]) + * # insert_str(id, str[], n) + * # replace_str(id, str[], n) + * # fetch_str(id, n, dst[], maxlen) + * # * * ** part_id and program_id need to be able to be "found" from strings * @@ -687,7 +687,7 @@ _edje_embryo_fn_get_text(Embryo_Program *ep, Embryo_Cell *params) part_id = params[1]; if (part_id < 0) return 0; rp = ed->table_parts[part_id % ed->table_parts_size]; - s = edje_object_part_text_get(ed->obj, rp->part->name); + s = (char *)edje_object_part_text_get(ed->obj, rp->part->name); if (s) { if (strlen(s) < params[3]) @@ -900,6 +900,223 @@ _edje_embryo_fn_set_drag_page(Embryo_Program *ep, Embryo_Cell *params) return(0); } +/* send_message(id, Msg_Type:type, ...); */ +static Embryo_Cell +_edje_embryo_fn_send_message(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed; + Edje_Message_Type type; + int id, i, n; + + if (params[0] < (sizeof(Embryo_Cell) * (2))) return 0; + ed = embryo_program_data_get(ep); + type = params[1]; + id = params[2]; + switch (type) + { + case EDJE_MESSAGE_NONE: + _edje_message_send(ed, EDJE_QUEUE_APP, type, id, NULL); + break; + case EDJE_MESSAGE_SIGNAL: + break; + case EDJE_MESSAGE_STRING: + { + Embryo_Cell *cptr; + + cptr = embryo_data_address_get(ep, params[3]); + if (cptr) + { + Edje_Message_String *emsg; + int l; + char *s; + + l = embryo_data_string_length_get(ep, cptr); + s = alloca(l + 1); + embryo_data_string_get(ep, cptr, s); + emsg = alloca(sizeof(Edje_Message_String)); + emsg->str = s; + _edje_message_send(ed, EDJE_QUEUE_APP, type, id, emsg); + } + } + break; + case EDJE_MESSAGE_INT: + { + Edje_Message_Int *emsg; + + emsg = alloca(sizeof(Edje_Message_Int)); + emsg->val = (int)params[3]; + _edje_message_send(ed, EDJE_QUEUE_APP, type, id, emsg); + } + break; + case EDJE_MESSAGE_FLOAT: + { + Edje_Message_Int *emsg; + float f; + + emsg = alloca(sizeof(Edje_Message_Int)); + f = EMBRYO_CELL_TO_FLOAT(params[3]); + emsg->val = (double)f; + _edje_message_send(ed, EDJE_QUEUE_APP, type, id, emsg); + } + break; + case EDJE_MESSAGE_STRING_SET: + { + Edje_Message_String_Set *emsg; + + n = (params[0] / sizeof(Embryo_Cell)); + emsg = alloca(sizeof(Edje_Message_String_Set) + ((n - 3 - 1) * sizeof(char *))); + emsg->count = n - 3; + for (i = 3; i < n; i++) + { + Embryo_Cell *cptr; + + cptr = embryo_data_address_get(ep, params[i]); + if (cptr) + { + int l; + char *s; + + l = embryo_data_string_length_get(ep, cptr); + s = alloca(l + 1); + embryo_data_string_get(ep, cptr, s); + emsg->str[i - 3] = s; + } + } + _edje_message_send(ed, EDJE_QUEUE_APP, type, id, emsg); + } + break; + case EDJE_MESSAGE_INT_SET: + { + Edje_Message_Int_Set *emsg; + + n = (params[0] / sizeof(Embryo_Cell)); + emsg = alloca(sizeof(Edje_Message_Int_Set) + ((n - 3 - 1) * sizeof(int))); + emsg->count = n - 3; + for (i = 3; i < n; i++) + emsg->val[i - 3] = (int)params[i]; + _edje_message_send(ed, EDJE_QUEUE_APP, type, id, emsg); + } + break; + case EDJE_MESSAGE_FLOAT_SET: + { + Edje_Message_Float_Set *emsg; + + n = (params[0] / sizeof(Embryo_Cell)); + emsg = alloca(sizeof(Edje_Message_Float_Set) + ((n - 3 - 1) * sizeof(double))); + emsg->count = n - 3; + for (i = 3; i < n; i++) + { + float f; + + f = EMBRYO_CELL_TO_FLOAT(params[i]); + emsg->val[i - 3] = (double)f; + } + _edje_message_send(ed, EDJE_QUEUE_APP, type, id, emsg); + } + break; + case EDJE_MESSAGE_STRING_INT: + { + Edje_Message_String_Int *emsg; + Embryo_Cell *cptr; + + cptr = embryo_data_address_get(ep, params[3]); + if (cptr) + { + int l; + char *s; + + l = embryo_data_string_length_get(ep, cptr); + s = alloca(l + 1); + embryo_data_string_get(ep, cptr, s); + emsg = alloca(sizeof(Edje_Message_String_Int)); + emsg->str = s; + emsg->val = (int)params[4]; + _edje_message_send(ed, EDJE_QUEUE_APP, type, id, emsg); + } + } + break; + case EDJE_MESSAGE_STRING_FLOAT: + { + Edje_Message_String_Float *emsg; + Embryo_Cell *cptr; + + cptr = embryo_data_address_get(ep, params[3]); + if (cptr) + { + int l; + char *s; + float f; + + l = embryo_data_string_length_get(ep, cptr); + s = alloca(l + 1); + embryo_data_string_get(ep, cptr, s); + emsg = alloca(sizeof(Edje_Message_String_Float)); + emsg->str = s; + f = EMBRYO_CELL_TO_FLOAT(params[4]); + emsg->val = (double)f; + _edje_message_send(ed, EDJE_QUEUE_APP, type, id, emsg); + } + } + break; + case EDJE_MESSAGE_STRING_INT_SET: + { + Edje_Message_String_Int_Set *emsg; + Embryo_Cell *cptr; + + cptr = embryo_data_address_get(ep, params[3]); + if (cptr) + { + int l; + char *s; + + l = embryo_data_string_length_get(ep, cptr); + s = alloca(l + 1); + embryo_data_string_get(ep, cptr, s); + n = (params[0] / sizeof(Embryo_Cell)); + emsg = alloca(sizeof(Edje_Message_String_Int_Set) + ((n - 4 - 1) * sizeof(int))); + emsg->str = s; + emsg->count = n - 4; + for (i = 4; i < n; i++) + emsg->val[i - 4] = (int)params[i]; + _edje_message_send(ed, EDJE_QUEUE_APP, type, id, emsg); + } + } + break; + case EDJE_MESSAGE_STRING_FLOAT_SET: + { + Edje_Message_String_Float_Set *emsg; + Embryo_Cell *cptr; + + cptr = embryo_data_address_get(ep, params[3]); + if (cptr) + { + int l; + char *s; + + l = embryo_data_string_length_get(ep, cptr); + s = alloca(l + 1); + embryo_data_string_get(ep, cptr, s); + n = (params[0] / sizeof(Embryo_Cell)); + emsg = alloca(sizeof(Edje_Message_String_Float_Set) + ((n - 4 - 1) * sizeof(double))); + emsg->str = s; + emsg->count = n - 4; + for (i = 4; i < n; i++) + { + float f; + + f = EMBRYO_CELL_TO_FLOAT(params[i]); + emsg->val[i - 4] = (double)f; + } + _edje_message_send(ed, EDJE_QUEUE_APP, type, id, emsg); + } + } + break; + default: + break; + } + return(0); +} + void _edje_embryo_script_init(Edje *ed) { @@ -950,6 +1167,8 @@ _edje_embryo_script_init(Edje *ed) embryo_program_native_call_add(ep, "set_min_size", _edje_embryo_fn_set_min_size); embryo_program_native_call_add(ep, "set_max_size", _edje_embryo_fn_set_max_size); + embryo_program_native_call_add(ep, "send_message", _edje_embryo_fn_send_message); + embryo_program_vm_push(ep); /* neew a new vm to run in */ _edje_embryo_globals_init(ed); } diff --git a/legacy/edje/src/lib/edje_message_queue.c b/legacy/edje/src/lib/edje_message_queue.c index 71544473db..c6eb7ae1b4 100644 --- a/legacy/edje/src/lib/edje_message_queue.c +++ b/legacy/edje/src/lib/edje_message_queue.c @@ -1,18 +1,25 @@ #include "Edje.h" #include "edje_private.h" -/* NB: global message que to be processed on idle enterer */ +void +edje_object_message_send(Evas_Object *obj, Edje_Message_Type type, int id, void *msg) +{ + Edje *ed; + + ed = _edje_fetch(obj); + if (!ed) return; + _edje_message_send(ed, EDJE_QUEUE_SCRIPT, type, id, msg); +} -/* NB: on deletion of an edje, remvoe all pending msg que items for it */ - -/* NB: each edje needs a messagequeue cointer to knwo how many messages on the - * queue for that edje */ - -/* NB: need to temporarly remove queue so messages added while processing the - * the queue so messages added as a result of processing dont loop. if the - * queue is not empty after processing scheduly 0.0 timeout to induce a - * new processing of the queue - */ +void +edje_object_message_handler_set(Evas_Object *obj, void (*func) (void *data, Evas_Object *obj, Edje_Message_Type type, int id, void *msg), void *data) +{ + Edje *ed; + + ed = _edje_fetch(obj); + if (!ed) return; + _edje_message_cb_set(ed, func, data); +} static Evas_List *msgq = NULL; static Evas_List *tmp_msgq = NULL; @@ -21,7 +28,6 @@ static Ecore_Idle_Enterer *idler = NULL; static int _edje_dummy_timer(void *data) { - printf("DUMMY\n"); return 0; } @@ -46,6 +52,13 @@ _edje_message_shutdown(void) idler = NULL; } +void +_edje_message_cb_set(Edje *ed, void (*func) (void *data, Evas_Object *obj, Edje_Message_Type type, int id, void *msg), void *data) +{ + ed->message.func = func; + ed->message.data = data; +} + Edje_Message * _edje_message_new(Edje *ed, Edje_Queue queue, Edje_Message_Type type, int id) { @@ -57,7 +70,7 @@ _edje_message_new(Edje *ed, Edje_Queue queue, Edje_Message_Type type, int id) em->queue = queue; em->type = type; em->id = id; - em->edje->message_num++; + em->edje->message.num++; return em; } @@ -79,6 +92,7 @@ _edje_message_free(Edje_Message *em) free(emsg->str); free(emsg); } + break; case EDJE_MESSAGE_INT: { Edje_Message_Int *emsg; @@ -86,6 +100,7 @@ _edje_message_free(Edje_Message *em) emsg = (Edje_Message_Int *)em->msg; free(emsg); } + break; case EDJE_MESSAGE_FLOAT: { Edje_Message_Float *emsg; @@ -93,6 +108,7 @@ _edje_message_free(Edje_Message *em) emsg = (Edje_Message_Float *)em->msg; free(emsg); } + break; case EDJE_MESSAGE_INT_SET: { Edje_Message_Int_Set *emsg; @@ -117,6 +133,7 @@ _edje_message_free(Edje_Message *em) free(emsg->str); free(emsg); } + break; case EDJE_MESSAGE_STRING_INT: { Edje_Message_String_Int *emsg; @@ -125,6 +142,7 @@ _edje_message_free(Edje_Message *em) free(emsg->str); free(emsg); } + break; case EDJE_MESSAGE_STRING_FLOAT_SET: { Edje_Message_String_Float_Set *emsg; @@ -133,6 +151,7 @@ _edje_message_free(Edje_Message *em) free(emsg->str); free(emsg); } + break; case EDJE_MESSAGE_STRING_INT_SET: { Edje_Message_String_Int_Set *emsg; @@ -141,6 +160,7 @@ _edje_message_free(Edje_Message *em) free(emsg->str); free(emsg); } + break; case EDJE_MESSAGE_SIGNAL: { Edje_Message_Signal *emsg; @@ -166,7 +186,7 @@ _edje_message_free(Edje_Message *em) break; } } - em->edje->message_num--; + em->edje->message.num--; free(em); } @@ -320,111 +340,124 @@ _edje_message_send(Edje *ed, Edje_Queue queue, Edje_Message_Type type, int id, v void _edje_message_process(Edje_Message *em) { + Embryo_Function fn; + void *pdata; + int i; + + /* signals are only handled one way */ + if (em->type == EDJE_MESSAGE_SIGNAL) + { + _edje_emit_handle(em->edje, + ((Edje_Message_Signal *)em->msg)->sig, + ((Edje_Message_Signal *)em->msg)->src); + return; + } + /* if this has been queued up for the app then just call the callback */ + if (em->queue == EDJE_QUEUE_APP) + { + if (em->edje->message.func) + em->edje->message.func(em->edje->message.data, em->edje->obj, + em->type, em->id, em->msg); + return; + } + /* now this message is destined for the script message handler fn */ + if (!((em->edje->collection) && (em->edje->collection->script))) return; + fn = embryo_program_function_find(em->edje->collection->script, "message"); + if (fn == EMBRYO_FUNCTION_NONE) return; + /* reset the engine */ + _edje_embryo_script_reset(em->edje); + /* these params ALWAYS go on */ + /* first param is the message type - always */ + embryo_parameter_cell_push(em->edje->collection->script, + (Embryo_Cell)em->type); + /* 2nd param is the integer of the event id - always there */ + embryo_parameter_cell_push(em->edje->collection->script, + (Embryo_Cell)em->id); + /* the rest is varags of whatever is in the msg */ switch (em->type) { case EDJE_MESSAGE_NONE: - switch (em->queue) - { - case EDJE_QUEUE_APP: - /* simply call app callback */ - break; - case EDJE_QUEUE_SCRIPT: - if ((em->edje->collection) && (em->edje->collection->script)) - { - Embryo_Function fn; - - _edje_embryo_script_reset(em->edje); - fn = embryo_program_function_find(em->edje->collection->script, "message"); - if (fn != EMBRYO_FUNCTION_NONE) - { - void *pdata; - Embryo_Cell cell; - - /* first param is the message type - always */ - cell = em->type; - embryo_parameter_cell_push(em->edje->collection->script, cell); - /* 2nd param is the integer of the event id - always there */ - cell = em->id; - embryo_parameter_cell_push(em->edje->collection->script, cell); - pdata = embryo_program_data_get(em->edje->collection->script); - embryo_program_data_set(em->edje->collection->script, em->edje); - embryo_program_run(em->edje->collection->script, fn); - embryo_program_data_set(em->edje->collection->script, pdata); - } - } - break; - default: - break; - } - break; - case EDJE_MESSAGE_SIGNAL: - { - char *str1; - char *str2; - - memcpy(&str1, em->msg, sizeof(char *)); - memcpy(&str2, em->msg + sizeof(char *), sizeof(char *)); - _edje_emit_handle(em->edje, str1, str2); - } break; case EDJE_MESSAGE_STRING: - switch (em->queue) - { - case EDJE_QUEUE_APP: - /* simply call app callback */ - break; - case EDJE_QUEUE_SCRIPT: - if ((em->edje->collection) && (em->edje->collection->script)) - { - Embryo_Function fn; - - _edje_embryo_script_reset(em->edje); - fn = embryo_program_function_find(em->edje->collection->script, "message"); - if (fn != EMBRYO_FUNCTION_NONE) - { - void *pdata; - Embryo_Cell cell; - - /* first param is the message type - always */ - cell = em->type; - embryo_parameter_cell_push(em->edje->collection->script, cell); - /* 2nd param is the integer of the event id - always there */ - cell = em->id; - embryo_parameter_cell_push(em->edje->collection->script, cell); - /* 3rd param is the string */ - embryo_parameter_string_push(em->edje->collection->script, em->msg); - pdata = embryo_program_data_get(em->edje->collection->script); - embryo_program_data_set(em->edje->collection->script, em->edje); - embryo_program_run(em->edje->collection->script, fn); - embryo_program_data_set(em->edje->collection->script, pdata); - } - } - break; - default: - break; - } + embryo_parameter_string_push(em->edje->collection->script, + ((Edje_Message_String *)em->msg)->str); break; case EDJE_MESSAGE_INT: + embryo_parameter_cell_push(em->edje->collection->script, + (Embryo_Cell)((Edje_Message_Int *)em->msg)->val); break; case EDJE_MESSAGE_FLOAT: + { + float v; + + v = (Embryo_Cell)((Edje_Message_Float *)em->msg)->val; + embryo_parameter_cell_push(em->edje->collection->script, + (Embryo_Cell)EMBRYO_FLOAT_TO_CELL(v)); + } break; case EDJE_MESSAGE_STRING_SET: + for (i = 0; i < ((Edje_Message_String_Set *)em->msg)->count; i++) + embryo_parameter_string_push(em->edje->collection->script, + ((Edje_Message_String_Set *)em->msg)->str[i]); break; case EDJE_MESSAGE_INT_SET: + for (i = 0; i < ((Edje_Message_Int_Set *)em->msg)->count; i++) + embryo_parameter_cell_push(em->edje->collection->script, + (Embryo_Cell)((Edje_Message_Int_Set *)em->msg)->val[i]); break; case EDJE_MESSAGE_FLOAT_SET: + for (i = 0; i < ((Edje_Message_Float_Set *)em->msg)->count; i++) + { + float v; + + v = ((Edje_Message_Float_Set *)em->msg)->val[i]; + embryo_parameter_cell_push(em->edje->collection->script, + (Embryo_Cell)EMBRYO_FLOAT_TO_CELL(v)); + } break; case EDJE_MESSAGE_STRING_INT: + embryo_parameter_string_push(em->edje->collection->script, + ((Edje_Message_String_Int *)em->msg)->str); + embryo_parameter_cell_push(em->edje->collection->script, + (Embryo_Cell)((Edje_Message_String_Int *)em->msg)->val); break; case EDJE_MESSAGE_STRING_FLOAT: + embryo_parameter_string_push(em->edje->collection->script, + ((Edje_Message_String_Float *)em->msg)->str); + { + float v; + + v = (Embryo_Cell)((Edje_Message_String_Float *)em->msg)->val; + embryo_parameter_cell_push(em->edje->collection->script, + (Embryo_Cell)EMBRYO_FLOAT_TO_CELL(v)); + } break; case EDJE_MESSAGE_STRING_INT_SET: + embryo_parameter_string_push(em->edje->collection->script, + ((Edje_Message_String_Int_Set *)em->msg)->str); + for (i = 0; i < ((Edje_Message_String_Int_Set *)em->msg)->count; i++) + embryo_parameter_cell_push(em->edje->collection->script, + (Embryo_Cell)((Edje_Message_String_Int_Set *)em->msg)->val[i]); break; case EDJE_MESSAGE_STRING_FLOAT_SET: + embryo_parameter_string_push(em->edje->collection->script, + ((Edje_Message_String_Float_Set *)em->msg)->str); + for (i = 0; i < ((Edje_Message_String_Float_Set *)em->msg)->count; i++) + { + float v; + + v = ((Edje_Message_String_Float_Set *)em->msg)->val[i]; + embryo_parameter_cell_push(em->edje->collection->script, + (Embryo_Cell)EMBRYO_FLOAT_TO_CELL(v)); + } break; default: break; } + pdata = embryo_program_data_get(em->edje->collection->script); + embryo_program_data_set(em->edje->collection->script, em->edje); + embryo_program_run(em->edje->collection->script, fn); + embryo_program_data_set(em->edje->collection->script, pdata); } void @@ -477,7 +510,7 @@ _edje_message_del(Edje *ed) { Evas_List *l; - if (ed->message_num <= 0) return; + if (ed->message.num <= 0) return; /* delete any messages on the main queue for this edje object */ for (l = msgq; ; ) { @@ -492,7 +525,7 @@ _edje_message_del(Edje *ed) msgq = evas_list_remove_list(msgq, lp); _edje_message_free(em); } - if (ed->message_num <= 0) return; + if (ed->message.num <= 0) return; } /* delete any on the processing queue */ for (l = tmp_msgq; ; ) @@ -508,6 +541,6 @@ _edje_message_del(Edje *ed) msgq = evas_list_remove_list(msgq, lp); _edje_message_free(em); } - if (ed->message_num <= 0) return; + if (ed->message.num <= 0) return; } } diff --git a/legacy/edje/src/lib/edje_misc.c b/legacy/edje/src/lib/edje_misc.c index dd496ea201..113055ccb7 100644 --- a/legacy/edje/src/lib/edje_misc.c +++ b/legacy/edje/src/lib/edje_misc.c @@ -1,129 +1,2 @@ #include "Edje.h" #include "edje_private.h" - -/************************** API Routines **************************/ - -/* FIXDOC: Verify/Expand */ -/** Returns the variable ID - * @param obj A valid Evas_Object handle - * @param name The variable name - * - * @return Variable ID\n - * 0 on Error. - */ -int -edje_object_variable_id_get(Evas_Object *obj, char *name) -{ - Edje *ed; - int id; - - ed = _edje_fetch(obj); - if ((!ed) || (!name)) return 0; - return _edje_var_string_id_get(ed, name); -} - -/* FIXDOC: Verify/Expand */ -/** Returns the variable int - * @param obj A valid Evas_Object handle - * @param id The variable id - * - * @return Variable int\n - * 0 on Error - */ -int -edje_object_variable_int_get(Evas_Object *obj, int id) -{ - Edje *ed; - - ed = _edje_fetch(obj); - if ((!ed) || (id <= 0)) return 0; - return _edje_var_int_get(ed, id); -} - -/* FIXDOC: Verify/Expand */ -/** Sets the variable int - * @param obj A valid Evas_Object handle - * @param id The variable id - * @param val The int value to set - */ -void -edje_object_variable_int_set(Evas_Object *obj, int id, int val) -{ - Edje *ed; - - ed = _edje_fetch(obj); - if ((!ed) || (id <= 0)) return; - _edje_var_int_set(ed, id, val); -} - -/* FIXDOC: Verify/Expand */ -/** Returns the variable float - * @param obj A valid Evas_Object handle - * @param id The variable id - * - * @return Variable float\n - * 0 on Error - */ -double -edje_object_variable_float_get(Evas_Object *obj, int id) -{ - Edje *ed; - - ed = _edje_fetch(obj); - if ((!ed) || (id <= 0)) return 0; - return _edje_var_float_get(ed, id); -} - -/* FIXDOC: Verify/Expand */ -/** Sets the variable float - * @param obj A valid Evas_Object handle - * @param id The variable id - * @param val The float value to set - */ -void -edje_object_variable_float_set(Evas_Object *obj, int id, double val) -{ - Edje *ed; - - ed = _edje_fetch(obj); - if ((!ed) || (id <= 0)) return; - _edje_var_float_set(ed, id, val); -} - -/* FIXDOC: Verify/Expand */ -/** Returns the variable string - * @param obj A valid Evas_Object handle - * @param id The variable id - * - * @return Variable String\n - * 0 on Error - */ -char * -edje_object_variable_str_get(Evas_Object *obj, int id) -{ - Edje *ed; - char *s; - - ed = _edje_fetch(obj); - if ((!ed) || (id <= 0)) return NULL; - s = _edje_var_str_get(ed, id); - if (!s) return NULL; - return strdup(s); -} - -/* FIXDOC: Verify/Expand */ -/** Sets the variable string - * @param obj A valid Evas_Object handle - * @param id The variable id - * @param str The string value to set - */ -void -edje_object_variable_str_set(Evas_Object *obj, int id, char *str) -{ - Edje *ed; - - ed = _edje_fetch(obj); - if ((!ed) || (id <= 0)) return; - if (!str) str = ""; - _edje_var_str_set(ed, id, str); -} diff --git a/legacy/edje/src/lib/edje_private.h b/legacy/edje/src/lib/edje_private.h index 939a8ef0af..d06c460a2a 100644 --- a/legacy/edje/src/lib/edje_private.h +++ b/legacy/edje/src/lib/edje_private.h @@ -40,7 +40,20 @@ * ? all unsafe calls that may result in callbacks must be marked and dealt with */ -typedef struct _Edje_Message Edje_Message; +typedef enum _Edje_Queue +{ + EDJE_QUEUE_APP, + EDJE_QUEUE_SCRIPT +} Edje_Queue; + +typedef struct _Edje_Message_Signal Edje_Message_Signal; +typedef struct _Edje_Message Edje_Message; + +struct _Edje_Message_Signal +{ + char *sig; + char *src; +}; struct _Edje_Message { @@ -126,14 +139,15 @@ int _edje_var_anim_add (Edje *ed, double len, char *fname, void _edje_var_anim_del (Edje *ed, int id); void _edje_var_anim_frametime_reset(void); -void _edje_message_init(void); -void _edje_message_shutdown(void); -Edje_Message *_edje_message_new(Edje *ed, Edje_Queue queue, Edje_Message_Type type, int id); -void _edje_message_free(Edje_Message *em); -void _edje_message_send(Edje *ed, Edje_Queue queue, Edje_Message_Type type, int id, void *emsg); -void _edje_message_process(Edje_Message *em); -void _edje_message_queue_process(void); -void _edje_message_queue_clear(void); -void _edje_message_del(Edje *ed); +void _edje_message_init (void); +void _edje_message_shutdown (void); +void _edje_message_cb_set (Edje *ed, void (*func) (void *data, Evas_Object *obj, Edje_Message_Type type, int id, void *msg), void *data); +Edje_Message *_edje_message_new (Edje *ed, Edje_Queue queue, Edje_Message_Type type, int id); +void _edje_message_free (Edje_Message *em); +void _edje_message_send (Edje *ed, Edje_Queue queue, Edje_Message_Type type, int id, void *emsg); +void _edje_message_process (Edje_Message *em); +void _edje_message_queue_process (void); +void _edje_message_queue_clear (void); +void _edje_message_del (Edje *ed); #endif diff --git a/legacy/edje/src/lib/edje_program.c b/legacy/edje/src/lib/edje_program.c index a826e60882..034b4bd707 100644 --- a/legacy/edje/src/lib/edje_program.c +++ b/legacy/edje/src/lib/edje_program.c @@ -732,7 +732,7 @@ _edje_emit(Edje *ed, char *sig, char *src) if (ed->delete_me) return; emsg.sig = sig; emsg.src = src; - _edje_message_send(ed, EDJE_QUEUE_APP, EDJE_MESSAGE_SIGNAL, 0, &emsg); + _edje_message_send(ed, EDJE_QUEUE_SCRIPT, EDJE_MESSAGE_SIGNAL, 0, &emsg); } /* FIXME: what if we delete the evas object??? */