1. fix a leak. i was naughty. spank spank
2. message queue is in - i am currently not surer if i shoudl go with this varags api internally ot move to a more manual "build a list" thing... but the message queue does work - i've moved signals to use it. SVN revision: 10653
This commit is contained in:
parent
bf242d9d42
commit
5b506efe2c
|
@ -9,11 +9,9 @@
|
|||
#include <Ecore_Fb.h>
|
||||
#endif
|
||||
#include <Ecore_Evas.h>
|
||||
/* ... only for testing */
|
||||
#include <Eet.h>
|
||||
#include "edje_private.h"
|
||||
/* ... end testing */
|
||||
#include "Edje.h"
|
||||
#include "edje_private.h"
|
||||
#include "config.h"
|
||||
|
||||
#define DAT PACKAGE_DATA_DIR"/"
|
||||
|
|
|
@ -5,6 +5,33 @@
|
|||
|
||||
/* FIXDOC: Define these? */
|
||||
|
||||
typedef enum _Edje_Queue
|
||||
{
|
||||
EDJE_QUEUE_APP,
|
||||
EDJE_QUEUE_SCRIPT
|
||||
} Edje_Queue;
|
||||
|
||||
typedef enum _Edje_Message_Type
|
||||
{
|
||||
EDJE_MESSAGE_NONE,
|
||||
|
||||
EDJE_MESSAGE_SIGNAL,
|
||||
|
||||
EDJE_MESSAGE_STRING,
|
||||
EDJE_MESSAGE_INT,
|
||||
EDJE_MESSAGE_FLOAT,
|
||||
|
||||
EDJE_MESSAGE_STRING_SET,
|
||||
EDJE_MESSAGE_INT_SET,
|
||||
EDJE_MESSAGE_FLOAT_SET,
|
||||
|
||||
EDJE_MESSAGE_STRING_INT,
|
||||
EDJE_MESSAGE_STRING_FLOAT,
|
||||
|
||||
EDJE_MESSAGE_STRING_INT_SET,
|
||||
EDJE_MESSAGE_STRING_FLOAT_SET
|
||||
} Edje_Message_Type;
|
||||
|
||||
#define EDJE_DRAG_DIR_NONE 0
|
||||
#define EDJE_DRAG_DIR_X 1
|
||||
#define EDJE_DRAG_DIR_Y 2
|
||||
|
|
|
@ -380,7 +380,6 @@ typedef struct _Edje_Real_Part Edje_Real_Part;
|
|||
typedef struct _Edje_Running_Program Edje_Running_Program;
|
||||
typedef struct _Edje_Signal_Callback Edje_Signal_Callback;
|
||||
typedef struct _Edje_Calc_Params Edje_Calc_Params;
|
||||
typedef struct _Edje_Emission Edje_Emission;
|
||||
typedef struct _Edje_Pending_Program Edje_Pending_Program;
|
||||
typedef struct _Edje_Text_Style Edje_Text_Style;
|
||||
typedef struct _Edje_Color_Class Edje_Color_Class;
|
||||
|
@ -417,7 +416,6 @@ struct _Edje
|
|||
unsigned short walking_actions : 1;
|
||||
unsigned short block_break : 1;
|
||||
unsigned short delete_me : 1;
|
||||
unsigned short dont_clear_signals : 1;
|
||||
double paused_at;
|
||||
Evas *evas; /* the evas this edje belongs to */
|
||||
Evas_Object *obj; /* the smart object */
|
||||
|
@ -432,7 +430,6 @@ struct _Edje
|
|||
Evas_List *text_classes;
|
||||
int references;
|
||||
int block;
|
||||
Evas_List *emissions;
|
||||
int load_error;
|
||||
int freeze;
|
||||
/* variable pool for edje embryo scripts */
|
||||
|
@ -447,6 +444,8 @@ struct _Edje
|
|||
void (*func) (void *data, Evas_Object *obj, const char *part);
|
||||
void *data;
|
||||
} text_change;
|
||||
|
||||
int message_num;
|
||||
};
|
||||
|
||||
struct _Edje_Real_Part
|
||||
|
@ -558,12 +557,6 @@ struct _Edje_Calc_Params
|
|||
} text;
|
||||
};
|
||||
|
||||
struct _Edje_Emission
|
||||
{
|
||||
char *signal;
|
||||
char *source;
|
||||
};
|
||||
|
||||
struct _Edje_Pending_Program
|
||||
{
|
||||
Edje *edje;
|
||||
|
@ -693,6 +686,8 @@ void _edje_collection_free(Edje *ed, Edje_Part_Collection *ec);
|
|||
|
||||
Edje *_edje_add(Evas_Object *obj);
|
||||
void _edje_del(Edje *ed);
|
||||
void _edje_ref(Edje *ed);
|
||||
void _edje_unref(Edje *ed);
|
||||
void _edje_clean_objects(Edje *ed);
|
||||
void _edje_ref(Edje *ed);
|
||||
void _edje_unref(Edje *ed);
|
||||
|
@ -701,6 +696,7 @@ int _edje_program_run_iterate(Edje_Running_Program *runp, double tim);
|
|||
void _edje_program_end(Edje *ed, Edje_Running_Program *runp);
|
||||
void _edje_program_run(Edje *ed, Edje_Program *pr, int force, char *ssig, char *ssrc);
|
||||
void _edje_emit(Edje *ed, char *sig, char *src);
|
||||
void _edje_emit_handle(Edje *ed, char *sig, char *src);
|
||||
|
||||
void _edje_text_init(void);
|
||||
void _edje_text_part_on_add(Edje *ed, Edje_Real_Part *ep);
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#include "Edje.h"
|
||||
#include "edje_private.h"
|
||||
|
||||
int edje_edit_init()
|
||||
|
|
|
@ -78,9 +78,29 @@ 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
|
||||
* ** dynamic allocation (just use cell as index to dynamic block)
|
||||
* timer(Float:in, fname[], val);
|
||||
* ######## 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)
|
||||
* cancel_anim(id)
|
||||
|
@ -111,6 +131,12 @@ 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, ...);
|
||||
* #
|
||||
* ##### what about posting messages to OTHER edje objects (swallowed?)
|
||||
* # ????
|
||||
*
|
||||
* ** part_id and program_id need to be able to be "found" from strings
|
||||
*
|
||||
* get_drag_count(part_id, &Float:dx, &Float:&dy)
|
||||
|
@ -964,17 +990,15 @@ _edje_embryo_test_run(Edje *ed, char *fname, char *sig, char *src)
|
|||
fn = embryo_program_function_find(ed->collection->script, fname);
|
||||
if (fn != EMBRYO_FUNCTION_NONE)
|
||||
{
|
||||
void *pdata;
|
||||
|
||||
printf("EDJE DEBUG: About to run script from program.\n");
|
||||
embryo_parameter_string_push(ed->collection->script, sig);
|
||||
embryo_parameter_string_push(ed->collection->script, src);
|
||||
{
|
||||
void *pdata;
|
||||
|
||||
pdata = embryo_program_data_get(ed->collection->script);
|
||||
embryo_program_data_set(ed->collection->script, ed);
|
||||
embryo_program_run(ed->collection->script, fn);
|
||||
embryo_program_data_set(ed->collection->script, pdata);
|
||||
}
|
||||
pdata = embryo_program_data_get(ed->collection->script);
|
||||
embryo_program_data_set(ed->collection->script, ed);
|
||||
embryo_program_run(ed->collection->script, fn);
|
||||
embryo_program_data_set(ed->collection->script, pdata);
|
||||
printf("EDJE DEBUG: Done.\n");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -526,8 +526,7 @@ _edje_file_add(Edje *ed)
|
|||
void
|
||||
_edje_file_del(Edje *ed)
|
||||
{
|
||||
_edje_emit(ed, NULL, NULL); /* clear out signal emissions */
|
||||
ed->dont_clear_signals = 1;
|
||||
_edje_message_del(ed);
|
||||
_edje_block_violate(ed);
|
||||
_edje_var_shutdown(ed);
|
||||
if (ed->collection)
|
||||
|
@ -663,6 +662,19 @@ _edje_file_free(Edje_File *edf)
|
|||
}
|
||||
free(edf->collection_dir);
|
||||
}
|
||||
if (edf->data)
|
||||
{
|
||||
while (edf->data)
|
||||
{
|
||||
Edje_Data *edt;
|
||||
|
||||
edt = edf->data->data;
|
||||
edf->data = evas_list_remove(edf->data, edt);
|
||||
if (edt->key) free(edt->key);
|
||||
if (edt->value) free(edt->value);
|
||||
free(edt);
|
||||
}
|
||||
}
|
||||
if (edf->collection_hash) evas_hash_free(edf->collection_hash);
|
||||
free(edf);
|
||||
}
|
||||
|
@ -723,6 +735,19 @@ _edje_collection_free(Edje *ed, Edje_Part_Collection *ec)
|
|||
}
|
||||
free(ep);
|
||||
}
|
||||
if (ec->data)
|
||||
{
|
||||
while (ec->data)
|
||||
{
|
||||
Edje_Data *edt;
|
||||
|
||||
edt = ec->data->data;
|
||||
ec->data = evas_list_remove(ec->data, edt);
|
||||
if (edt->key) free(edt->key);
|
||||
if (edt->value) free(edt->value);
|
||||
free(edt);
|
||||
}
|
||||
}
|
||||
#ifdef EDJE_PROGRAM_CACHE
|
||||
if (ec->prog_cache.no_matches) evas_hash_free(ec->prog_cache.no_matches);
|
||||
if (ec->prog_cache.matches)
|
||||
|
|
|
@ -19,6 +19,7 @@ edje_init(void)
|
|||
_edje_text_init();
|
||||
embryo_init();
|
||||
}
|
||||
_edje_message_init();
|
||||
return initted;
|
||||
}
|
||||
|
||||
|
@ -32,6 +33,7 @@ edje_shutdown(void)
|
|||
initted--;
|
||||
if (initted > 0) return initted;
|
||||
|
||||
_edje_message_shutdown();
|
||||
_edje_edd_free();
|
||||
_edje_color_class_members_free();
|
||||
_edje_text_class_members_free();
|
||||
|
@ -140,6 +142,5 @@ void
|
|||
_edje_unref(Edje *ed)
|
||||
{
|
||||
ed->references--;
|
||||
if (ed->references <= 0)
|
||||
_edje_del(ed);
|
||||
if (ed->references <= 0) _edje_del(ed);
|
||||
}
|
||||
|
|
|
@ -1,2 +1,393 @@
|
|||
#include "Edje.h"
|
||||
#include "edje_private.h"
|
||||
|
||||
/* NB: global message que to be processed on idle enterer */
|
||||
|
||||
/* 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
|
||||
*/
|
||||
|
||||
static Evas_List *msgq = NULL;
|
||||
static Evas_List *tmp_msgq = NULL;
|
||||
static Ecore_Idle_Enterer *idler = NULL;
|
||||
|
||||
static int
|
||||
_edje_dummy_timer(void *data)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
_edje_idler(void *data)
|
||||
{
|
||||
_edje_message_queue_process();
|
||||
return 1;
|
||||
}
|
||||
|
||||
void
|
||||
_edje_message_init(void)
|
||||
{
|
||||
idler = ecore_idle_enterer_add(_edje_idler, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
_edje_message_shutdown(void)
|
||||
{
|
||||
_edje_message_queue_clear();
|
||||
ecore_idle_enterer_del(idler);
|
||||
idler = NULL;
|
||||
}
|
||||
|
||||
Edje_Message *
|
||||
_edje_message_new(Edje *ed, Edje_Queue queue, Edje_Message_Type type, int id)
|
||||
{
|
||||
Edje_Message *em;
|
||||
|
||||
em = calloc(1, sizeof(Edje_Message));
|
||||
if (!em) return NULL;
|
||||
em->edje = ed;
|
||||
em->queue = queue;
|
||||
em->type = type;
|
||||
em->id = id;
|
||||
em->edje->message_num++;
|
||||
return em;
|
||||
}
|
||||
|
||||
void
|
||||
_edje_message_free(Edje_Message *em)
|
||||
{
|
||||
if (em->msg)
|
||||
{
|
||||
char *ptr;
|
||||
int i, count;
|
||||
|
||||
switch (em->type)
|
||||
{
|
||||
case EDJE_MESSAGE_STRING:
|
||||
case EDJE_MESSAGE_INT:
|
||||
case EDJE_MESSAGE_FLOAT:
|
||||
case EDJE_MESSAGE_INT_SET:
|
||||
case EDJE_MESSAGE_FLOAT_SET:
|
||||
free(em->msg);
|
||||
break;
|
||||
case EDJE_MESSAGE_STRING_FLOAT:
|
||||
case EDJE_MESSAGE_STRING_INT:
|
||||
case EDJE_MESSAGE_STRING_FLOAT_SET:
|
||||
case EDJE_MESSAGE_STRING_INT_SET:
|
||||
memcpy(&ptr, em->msg, sizeof(char *));
|
||||
free(ptr);
|
||||
free(em->msg);
|
||||
break;
|
||||
case EDJE_MESSAGE_SIGNAL:
|
||||
memcpy(&ptr, em->msg, sizeof(char *));
|
||||
free(ptr);
|
||||
memcpy(&ptr, em->msg + sizeof(char *), sizeof(char *));
|
||||
free(ptr);
|
||||
free(em->msg);
|
||||
break;
|
||||
case EDJE_MESSAGE_STRING_SET:
|
||||
memcpy(&count, em->msg, sizeof(int));
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
memcpy(&ptr, em->msg + sizeof(int) + (i * sizeof(char *)), sizeof(char *));
|
||||
free(ptr);
|
||||
}
|
||||
free(em->msg);
|
||||
break;
|
||||
case EDJE_MESSAGE_NONE:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
em->edje->message_num--;
|
||||
free(em);
|
||||
}
|
||||
|
||||
void
|
||||
_edje_message_send(Edje *ed, Edje_Queue queue, Edje_Message_Type type, int id, ...)
|
||||
{
|
||||
/* FIXME: check all malloc fails and gracefully unroll and exit */
|
||||
Edje_Message *em;
|
||||
va_list args;
|
||||
int count = 0, i;
|
||||
char *str = NULL, *str2 = NULL, *s;
|
||||
int num = 0;
|
||||
double flt = 0.0;
|
||||
unsigned char *msg = NULL;
|
||||
|
||||
em = _edje_message_new(ed, queue, type, id);
|
||||
if (!em) return;
|
||||
va_start(args, id);
|
||||
|
||||
/* this is evil code - but all we do is pack pointers, ints and doubles */
|
||||
/* into the msg generic pointer one after the other */
|
||||
switch (em->type)
|
||||
{
|
||||
case EDJE_MESSAGE_NONE:
|
||||
break;
|
||||
case EDJE_MESSAGE_SIGNAL:
|
||||
str = va_arg(args, char *);
|
||||
str2 = va_arg(args, char *);
|
||||
msg = malloc(sizeof(char *) * 2);
|
||||
s = strdup(str);
|
||||
memcpy(msg + (0 * sizeof(char *)), &s, sizeof(char *));
|
||||
s = strdup(str2);
|
||||
memcpy(msg + (1 * sizeof(char *)), &s, sizeof(char *));
|
||||
break;
|
||||
case EDJE_MESSAGE_STRING:
|
||||
str = va_arg(args, char *);
|
||||
msg = strdup(str);
|
||||
break;
|
||||
case EDJE_MESSAGE_INT:
|
||||
num = va_arg(args, int);
|
||||
msg = malloc(sizeof(int));
|
||||
memcpy(msg, &num, sizeof(int));
|
||||
break;
|
||||
case EDJE_MESSAGE_FLOAT:
|
||||
flt = va_arg(args, double);
|
||||
msg = malloc(sizeof(double));
|
||||
memcpy(msg, &flt, sizeof(double));
|
||||
break;
|
||||
case EDJE_MESSAGE_STRING_SET:
|
||||
count = va_arg(args, int);
|
||||
msg = malloc(sizeof(int) + (count * sizeof(char *)));
|
||||
memcpy(msg, &count, sizeof(int));
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
str = va_arg(args, char *);
|
||||
s = strdup(str);
|
||||
memcpy(msg + sizeof(int) + (i * sizeof(char *)), &s, sizeof(char *));
|
||||
}
|
||||
break;
|
||||
case EDJE_MESSAGE_INT_SET:
|
||||
count = va_arg(args, int);
|
||||
msg = malloc(sizeof(int) + (count * sizeof(int)));
|
||||
memcpy(msg, &count, sizeof(int));
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
num = va_arg(args, int);
|
||||
memcpy(msg + sizeof(int) + (i * sizeof(int)), &num, sizeof(int));
|
||||
}
|
||||
break;
|
||||
case EDJE_MESSAGE_FLOAT_SET:
|
||||
count = va_arg(args, int);
|
||||
msg = malloc(sizeof(int) + (count * sizeof(double)));
|
||||
memcpy(msg, &count, sizeof(int));
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
flt = va_arg(args, double);
|
||||
memcpy(msg + sizeof(int) + (i * sizeof(double)), &flt, sizeof(double));
|
||||
}
|
||||
break;
|
||||
case EDJE_MESSAGE_STRING_INT:
|
||||
str = va_arg(args, char *);
|
||||
num = va_arg(args, int);
|
||||
msg = malloc(sizeof(char *) + sizeof(int));
|
||||
s = strdup(str);
|
||||
memcpy(msg, &s, sizeof(char *));
|
||||
memcpy(msg + sizeof(char *), &num, sizeof(int));
|
||||
break;
|
||||
case EDJE_MESSAGE_STRING_FLOAT:
|
||||
str = va_arg(args, char *);
|
||||
flt = va_arg(args, double);
|
||||
msg = malloc(sizeof(char *) + sizeof(double));
|
||||
s = strdup(str);
|
||||
memcpy(msg, &s, sizeof(char *));
|
||||
memcpy(msg + sizeof(char *), &flt, sizeof(double));
|
||||
break;
|
||||
case EDJE_MESSAGE_STRING_INT_SET:
|
||||
str = va_arg(args, char *);
|
||||
count = va_arg(args, int);
|
||||
msg = malloc(sizeof (char *) + sizeof(int) + (count * sizeof(int)));
|
||||
s = strdup(str);
|
||||
memcpy(msg, &s, sizeof(char *));
|
||||
memcpy(msg + sizeof(char *), &count, sizeof(int));
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
num = va_arg(args, int);
|
||||
memcpy(msg + sizeof(char *) + sizeof(int) + (i * sizeof(int)), &num, sizeof(int));
|
||||
}
|
||||
break;
|
||||
case EDJE_MESSAGE_STRING_FLOAT_SET:
|
||||
str = va_arg(args, char *);
|
||||
count = va_arg(args, int);
|
||||
msg = malloc(sizeof (char *) + sizeof(int) + (count * sizeof(double)));
|
||||
s = strdup(str);
|
||||
memcpy(msg, &s, sizeof(char *));
|
||||
memcpy(msg + sizeof(char *), &count, sizeof(int));
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
flt = va_arg(args, double);
|
||||
memcpy(msg + sizeof(char *) + sizeof(int) + (i * sizeof(double)), &flt, sizeof(double));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
em->msg = msg;
|
||||
msgq = evas_list_append(msgq, em);
|
||||
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void
|
||||
_edje_message_process(Edje_Message *em)
|
||||
{
|
||||
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, "_msg");
|
||||
if (fn != EMBRYO_FUNCTION_NONE)
|
||||
{
|
||||
void *pdata;
|
||||
Embryo_Cell cell;
|
||||
|
||||
// embryo_parameter_string_push(em->edje->collection->script, sig);
|
||||
/* first 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);
|
||||
}
|
||||
}
|
||||
/* call script fn */
|
||||
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 *));
|
||||
// printf("HANDLE SIG!\n");
|
||||
_edje_emit_handle(em->edje, str1, str2);
|
||||
}
|
||||
break;
|
||||
case EDJE_MESSAGE_STRING:
|
||||
break;
|
||||
case EDJE_MESSAGE_INT:
|
||||
break;
|
||||
case EDJE_MESSAGE_FLOAT:
|
||||
break;
|
||||
case EDJE_MESSAGE_STRING_SET:
|
||||
break;
|
||||
case EDJE_MESSAGE_INT_SET:
|
||||
break;
|
||||
case EDJE_MESSAGE_FLOAT_SET:
|
||||
break;
|
||||
case EDJE_MESSAGE_STRING_INT:
|
||||
break;
|
||||
case EDJE_MESSAGE_STRING_FLOAT:
|
||||
break;
|
||||
case EDJE_MESSAGE_STRING_INT_SET:
|
||||
break;
|
||||
case EDJE_MESSAGE_STRING_FLOAT_SET:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
_edje_message_queue_process(void)
|
||||
{
|
||||
if (msgq == NULL) return;
|
||||
|
||||
// printf("PROCESS\n");
|
||||
/* a temporary message queue */
|
||||
tmp_msgq = msgq;
|
||||
msgq = NULL;
|
||||
|
||||
while (tmp_msgq)
|
||||
{
|
||||
Edje_Message *em;
|
||||
|
||||
em = tmp_msgq->data;
|
||||
tmp_msgq = evas_list_remove_list(tmp_msgq, tmp_msgq);
|
||||
_edje_message_process(em);
|
||||
_edje_message_free(em);
|
||||
}
|
||||
|
||||
/* if the message queue filled again set a timer to expire in 0.0 sec */
|
||||
/* to get the dle enterer to be run again */
|
||||
if (msgq)
|
||||
ecore_timer_add(0.0, _edje_dummy_timer, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
_edje_message_queue_clear(void)
|
||||
{
|
||||
while (msgq)
|
||||
{
|
||||
Edje_Message *em;
|
||||
|
||||
em = msgq->data;
|
||||
msgq = evas_list_remove_list(msgq, msgq);
|
||||
_edje_message_free(em);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
_edje_message_del(Edje *ed)
|
||||
{
|
||||
Evas_List *l;
|
||||
|
||||
if (ed->message_num <= 0) return;
|
||||
/* delete any messages on the main queue for this edje object */
|
||||
for (l = msgq; ; )
|
||||
{
|
||||
Edje_Message *em;
|
||||
Evas_List *lp;
|
||||
|
||||
em = l->data;
|
||||
lp = l;
|
||||
l = l->next;
|
||||
if (em->edje == ed)
|
||||
{
|
||||
msgq = evas_list_remove_list(msgq, lp);
|
||||
_edje_message_free(em);
|
||||
}
|
||||
if (ed->message_num <= 0) return;
|
||||
}
|
||||
/* delete any on the processing queue */
|
||||
for (l = tmp_msgq; ; )
|
||||
{
|
||||
Edje_Message *em;
|
||||
Evas_List *lp;
|
||||
|
||||
em = l->data;
|
||||
lp = l;
|
||||
l = l->next;
|
||||
if (em->edje == ed)
|
||||
{
|
||||
msgq = evas_list_remove_list(msgq, lp);
|
||||
_edje_message_free(em);
|
||||
}
|
||||
if (ed->message_num <= 0) return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
#include <math.h>
|
||||
#include <fnmatch.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#ifdef HAVE_ALLOCA_H
|
||||
#include <alloca.h>
|
||||
|
@ -40,6 +41,16 @@
|
|||
* ? all unsafe calls that may result in callbacks must be marked and dealt with
|
||||
*/
|
||||
|
||||
typedef struct _Edje_Message Edje_Message;
|
||||
|
||||
struct _Edje_Message
|
||||
{
|
||||
Edje *edje;
|
||||
Edje_Queue queue;
|
||||
Edje_Message_Type type;
|
||||
int id;
|
||||
unsigned char *msg;
|
||||
};
|
||||
|
||||
extern Eet_Data_Descriptor *_edje_edd_edje_file;
|
||||
extern Eet_Data_Descriptor *_edje_edd_edje_data;
|
||||
|
@ -116,5 +127,14 @@ 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 _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
|
||||
|
|
|
@ -724,209 +724,141 @@ _edje_program_run(Edje *ed, Edje_Program *pr, int force, char *ssig, char *ssrc)
|
|||
_edje_unblock(ed);
|
||||
}
|
||||
|
||||
static void _edje_emission_free(Edje_Emission *ee)
|
||||
{
|
||||
if (!ee)
|
||||
return;
|
||||
|
||||
if (ee->signal)
|
||||
free(ee->signal);
|
||||
|
||||
if (ee->source)
|
||||
free(ee->source);
|
||||
|
||||
free(ee);
|
||||
}
|
||||
|
||||
void
|
||||
_edje_emit(Edje *ed, char *sig, char *src)
|
||||
{
|
||||
Evas_List *l;
|
||||
Edje_Emission *ee = NULL;
|
||||
/* limit self-feeding loops in callbacks to 64 levels */
|
||||
static int recursions = 0;
|
||||
static int recursion_limit = 0;
|
||||
|
||||
if ((!sig) && (!src))
|
||||
{
|
||||
while (ed->emissions)
|
||||
{
|
||||
ee = ed->emissions->data;
|
||||
ed->emissions = evas_list_remove(ed->emissions, ee);
|
||||
|
||||
_edje_emission_free(ee);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (ed->delete_me) return;
|
||||
if ((recursions >= 64) || (recursion_limit))
|
||||
{
|
||||
recursion_limit = 1;
|
||||
return;
|
||||
}
|
||||
recursions++;
|
||||
_edje_message_send(ed, EDJE_QUEUE_APP, EDJE_MESSAGE_SIGNAL, 0, sig, src);
|
||||
}
|
||||
|
||||
/* FIXME: what if we delete the evas object??? */
|
||||
void
|
||||
_edje_emit_handle(Edje *ed, char *sig, char *src)
|
||||
{
|
||||
Evas_List *l;
|
||||
|
||||
if (ed->delete_me) return;
|
||||
// printf("EDJE EMIT: signal: \"%s\" source: \"%s\"\n", sig, src);
|
||||
if ((sig) && (src))
|
||||
{
|
||||
ee = calloc(1, sizeof(Edje_Emission));
|
||||
if (!ee)
|
||||
{
|
||||
recursions--;
|
||||
if (recursions == 0) recursion_limit = 0;
|
||||
return;
|
||||
}
|
||||
ee->signal = strdup(sig);
|
||||
ee->source = strdup(src);
|
||||
if ((ed->emissions) || (_edje_block_break(ed)))
|
||||
{
|
||||
ed->emissions = evas_list_append(ed->emissions, ee);
|
||||
recursions--;
|
||||
if (recursions == 0) recursion_limit = 0;
|
||||
return;
|
||||
}
|
||||
else
|
||||
ed->emissions = evas_list_append(ed->emissions, ee);
|
||||
}
|
||||
if (!ed->emissions) return;
|
||||
_edje_block(ed);
|
||||
_edje_ref(ed);
|
||||
_edje_freeze(ed);
|
||||
while (ed->emissions)
|
||||
if (ed->collection)
|
||||
{
|
||||
ee = ed->emissions->data;
|
||||
ed->emissions = evas_list_remove(ed->emissions, ee);
|
||||
if (ed->collection)
|
||||
Edje_Part_Collection *ec;
|
||||
#ifdef EDJE_PROGRAM_CACHE
|
||||
char *tmps;
|
||||
int l1, l2;
|
||||
#endif
|
||||
int done;
|
||||
|
||||
ec = ed->collection;
|
||||
#ifdef EDJE_PROGRAM_CACHE
|
||||
l1 = strlen(sig);
|
||||
l2 = strlen(src);
|
||||
tmps = malloc(l1 + l2 + 2);
|
||||
|
||||
if (tmps)
|
||||
{
|
||||
Edje_Part_Collection *ec;
|
||||
#ifdef EDJE_PROGRAM_CACHE
|
||||
char *tmps;
|
||||
strcpy(tmps, sig);
|
||||
tmps[l1] = '\377';
|
||||
strcpy(&(tmps[l1 + 1]), src);
|
||||
}
|
||||
#endif
|
||||
int l1, l2;
|
||||
int done;
|
||||
|
||||
ec = ed->collection;
|
||||
done = 0;
|
||||
|
||||
#ifdef EDJE_PROGRAM_CACHE
|
||||
l1 = strlen(ee->signal);
|
||||
l2 = strlen(ee->source);
|
||||
tmps = malloc(l1 + l2 + 2);
|
||||
if (tmps)
|
||||
{
|
||||
Evas_List *matches;
|
||||
|
||||
if (tmps)
|
||||
if (evas_hash_find(ec->prog_cache.no_matches, tmps))
|
||||
{
|
||||
strcpy(tmps, ee->signal);
|
||||
tmps[l1] = '\377';
|
||||
strcpy(&(tmps[l1 + 1]), ee->source);
|
||||
done = 1;
|
||||
}
|
||||
#endif
|
||||
done = 0;
|
||||
|
||||
#ifdef EDJE_PROGRAM_CACHE
|
||||
if (tmps)
|
||||
else if ((matches = evas_hash_find(ec->prog_cache.matches, tmps)))
|
||||
{
|
||||
Evas_List *matches;
|
||||
|
||||
if (evas_hash_find(ec->prog_cache.no_matches, tmps))
|
||||
{
|
||||
done = 1;
|
||||
}
|
||||
else if ((matches = evas_hash_find(ec->prog_cache.matches, tmps)))
|
||||
{
|
||||
for (l = matches; l; l = l->next)
|
||||
{
|
||||
Edje_Program *pr;
|
||||
|
||||
pr = l->data;
|
||||
_edje_program_run(ed, pr, 0, sig, src);
|
||||
if (_edje_block_break(ed))
|
||||
{
|
||||
if (tmps) free(tmps);
|
||||
if (!ed->dont_clear_signals)
|
||||
_edje_emit(ed, NULL, NULL);
|
||||
goto break_prog;
|
||||
}
|
||||
}
|
||||
done = 1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (!done)
|
||||
{
|
||||
#ifdef EDJE_PROGRAM_CACHE
|
||||
int matched = 0;
|
||||
Evas_List *matches = NULL;
|
||||
#endif
|
||||
|
||||
for (l = ed->collection->programs; l; l = l->next)
|
||||
for (l = matches; l; l = l->next)
|
||||
{
|
||||
Edje_Program *pr;
|
||||
|
||||
pr = l->data;
|
||||
if ((pr->signal) &&
|
||||
(pr->source) &&
|
||||
(_edje_glob_match(ee->signal, pr->signal)) &&
|
||||
(_edje_glob_match(ee->source, pr->source)))
|
||||
_edje_program_run(ed, pr, 0, sig, src);
|
||||
if (_edje_block_break(ed))
|
||||
{
|
||||
#ifdef EDJE_PROGRAM_CACHE
|
||||
matched++;
|
||||
#endif
|
||||
_edje_program_run(ed, pr, 0, ee->signal, ee->source);
|
||||
if (_edje_block_break(ed))
|
||||
{
|
||||
#ifdef EDJE_PROGRAM_CACHE
|
||||
if (tmps) free(tmps);
|
||||
evas_list_free(matches);
|
||||
#endif
|
||||
if (!ed->dont_clear_signals)
|
||||
_edje_emit(ed, NULL, NULL);
|
||||
goto break_prog;
|
||||
}
|
||||
#ifdef EDJE_PROGRAM_CACHE
|
||||
matches = evas_list_append(matches, pr);
|
||||
#endif
|
||||
if (tmps) free(tmps);
|
||||
goto break_prog;
|
||||
}
|
||||
}
|
||||
#ifdef EDJE_PROGRAM_CACHE
|
||||
if (tmps)
|
||||
{
|
||||
if (matched == 0)
|
||||
ec->prog_cache.no_matches =
|
||||
evas_hash_add(ec->prog_cache.no_matches, tmps, ed);
|
||||
else
|
||||
ec->prog_cache.matches =
|
||||
evas_hash_add(ec->prog_cache.matches, tmps, matches);
|
||||
}
|
||||
#endif
|
||||
done = 1;
|
||||
}
|
||||
_edje_emit_cb(ed, ee->signal, ee->source);
|
||||
if (_edje_block_break(ed))
|
||||
}
|
||||
#endif
|
||||
if (!done)
|
||||
{
|
||||
#ifdef EDJE_PROGRAM_CACHE
|
||||
int matched = 0;
|
||||
Evas_List *matches = NULL;
|
||||
#endif
|
||||
|
||||
for (l = ed->collection->programs; l; l = l->next)
|
||||
{
|
||||
Edje_Program *pr;
|
||||
|
||||
pr = l->data;
|
||||
if ((pr->signal) &&
|
||||
(pr->source) &&
|
||||
(_edje_glob_match(sig, pr->signal)) &&
|
||||
(_edje_glob_match(src, pr->source)))
|
||||
{
|
||||
#ifdef EDJE_PROGRAM_CACHE
|
||||
if (tmps) free(tmps);
|
||||
#endif
|
||||
if (!ed->dont_clear_signals)
|
||||
_edje_emit(ed, NULL, NULL);
|
||||
goto break_prog;
|
||||
matched++;
|
||||
#endif
|
||||
_edje_program_run(ed, pr, 0, sig, src);
|
||||
if (_edje_block_break(ed))
|
||||
{
|
||||
#ifdef EDJE_PROGRAM_CACHE
|
||||
if (tmps) free(tmps);
|
||||
evas_list_free(matches);
|
||||
#endif
|
||||
goto break_prog;
|
||||
}
|
||||
#ifdef EDJE_PROGRAM_CACHE
|
||||
matches = evas_list_append(matches, pr);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#ifdef EDJE_PROGRAM_CACHE
|
||||
if (tmps)
|
||||
{
|
||||
if (matched == 0)
|
||||
ec->prog_cache.no_matches =
|
||||
evas_hash_add(ec->prog_cache.no_matches, tmps, ed);
|
||||
else
|
||||
ec->prog_cache.matches =
|
||||
evas_hash_add(ec->prog_cache.matches, tmps, matches);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
_edje_emit_cb(ed, sig, src);
|
||||
if (_edje_block_break(ed))
|
||||
{
|
||||
#ifdef EDJE_PROGRAM_CACHE
|
||||
if (tmps) free(tmps);
|
||||
tmps = NULL;
|
||||
#endif
|
||||
#endif
|
||||
goto break_prog;
|
||||
}
|
||||
|
||||
_edje_emission_free(ee);
|
||||
ee = NULL;
|
||||
#ifdef EDJE_PROGRAM_CACHE
|
||||
if (tmps) free(tmps);
|
||||
tmps = NULL;
|
||||
#endif
|
||||
}
|
||||
break_prog:
|
||||
|
||||
if (ee)
|
||||
_edje_emission_free(ee);
|
||||
|
||||
recursions--;
|
||||
if (recursions == 0) recursion_limit = 0;
|
||||
_edje_thaw(ed);
|
||||
_edje_unref(ed);
|
||||
_edje_unblock(ed);
|
||||
}
|
||||
|
||||
/* FIXME: what if we delete the evas object??? */
|
||||
static void
|
||||
_edje_emit_cb(Edje *ed, char *sig, char *src)
|
||||
{
|
||||
|
|
|
@ -1480,8 +1480,6 @@ _edje_unblock(Edje *ed)
|
|||
if (ed->block == 0)
|
||||
{
|
||||
ed->block_break = 0;
|
||||
ed->dont_clear_signals = 0;
|
||||
if (ed->emissions) _edje_emit(ed, "", NULL);
|
||||
}
|
||||
return ed->block;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue