From: Carsten Haitzler Date: Thu, 1 Apr 2004 09:30:45 +0000 (+0000) Subject: string replacement with ID's in edje_cc for verbatim code snippets... see X-Git-Tag: submit/efl/20131015.063327~21942 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=39bb58157340686a162ff5f75af7f6f7ba124656;p=platform%2Fupstream%2Fefl.git string replacement with ID's in edje_cc for verbatim code snippets... see example SVN revision: 9548 --- diff --git a/legacy/edje/data/e_logo.sh b/legacy/edje/data/e_logo.sh index d8f2f121c7..782d4d8fc3 100755 --- a/legacy/edje/data/e_logo.sh +++ b/legacy/edje/data/e_logo.sh @@ -1,2 +1,2 @@ #!/bin/sh -exec edje_cc -v -fd ./test/fonts -id ./images src/e_logo.edc e_logo.eet +exec edje_cc -fd ./test/fonts -id ./images src/e_logo.edc e_logo.eet diff --git a/legacy/edje/data/src/e_logo.edc b/legacy/edje/data/src/e_logo.edc index 538d940089..7a49822533 100644 --- a/legacy/edje/data/src/e_logo.edc +++ b/legacy/edje/data/src/e_logo.edc @@ -472,8 +472,18 @@ collections { source: "logo_anim"; // action: SIGNAL_EMIT "do_it" "the_source"; script { + set_int(global_int, PART:"logo"); + set_int(global_int, PART:"dragable"); + set_int(global_int, IMAGE:"e001.png"); + set_int(global_int, IMAGE:"e002.png"); + set_int(global_int, IMAGE:"e003.png"); + set_int(global_int, IMAGE:"e007.png"); + set_int(global_int, PROGRAM:"logo_animate_signal"); + set_int(global_int, PROGRAM:"logo_animate_signal"); + set_int(global_int, PROGRAM:"logo_animate_signal"); + emit("PROGRAAAAAAAM", "TEEEEEEEEEEEEEST"); - set_int(global_int, 10); +// set_int(global_int, 10); set_float(global_float, 10.0); set_str(global_str, "smelly fish"); new buf[256]; diff --git a/legacy/edje/src/bin/edje_cc.c b/legacy/edje/src/bin/edje_cc.c index 54d16bf266..09780c5836 100644 --- a/legacy/edje/src/bin/edje_cc.c +++ b/legacy/edje/src/bin/edje_cc.c @@ -92,7 +92,9 @@ main(int argc, char **argv) data_setup(); compile(); + data_process_scripts(); data_process_lookups(); + data_process_script_lookups(); data_write(); edje_shutdown(); diff --git a/legacy/edje/src/bin/edje_cc.h b/legacy/edje/src/bin/edje_cc.h index 90659477d7..57d6379065 100644 --- a/legacy/edje/src/bin/edje_cc.h +++ b/legacy/edje/src/bin/edje_cc.h @@ -18,6 +18,7 @@ #include #include #include +#include /* types */ typedef struct _New_Object_Handler New_Object_Handler; diff --git a/legacy/edje/src/bin/edje_cc_out.c b/legacy/edje/src/bin/edje_cc_out.c index 25f625a378..14448c6fe6 100644 --- a/legacy/edje/src/bin/edje_cc_out.c +++ b/legacy/edje/src/bin/edje_cc_out.c @@ -3,6 +3,7 @@ typedef struct _Part_Lookup Part_Lookup; typedef struct _Program_Lookup Program_Lookup; typedef struct _Image_Lookup Image_Lookup; +typedef struct _Code_Lookup Code_Lookup; struct _Part_Lookup { @@ -24,10 +25,18 @@ struct _Image_Lookup int *dest; }; +struct _Code_Lookup +{ + char *ptr; + int len; + int val; +}; + Edje_File *edje_file = NULL; Evas_List *edje_collections = NULL; Evas_List *fonts = NULL; Evas_List *codes = NULL; +Evas_List *code_lookups = NULL; static Eet_Data_Descriptor *edd_edje_file = NULL; static Eet_Data_Descriptor *edd_edje_image_directory = NULL; @@ -157,7 +166,6 @@ data_write(void) pos = ftell(f); rewind(f); fdata = malloc(pos); - printf("%i\n", (int)pos); if (fdata) { if (fread(fdata, pos, 1, f) != 1) @@ -647,3 +655,176 @@ data_process_lookups(void) free(il); } } + +static void +data_process_string(Edje_Part_Collection *pc, char *prefix, char *s, void (*func)(Edje_Part_Collection *pc, char *name, int *val)) +{ + char *p; + char *key; + int keyl; + int quote, escape; + + key = alloca(strlen(prefix) + 2 + 1); + if (!key) return; + strcpy(key, prefix); + strcat(key, ":\""); + keyl = strlen(key); + quote = 0; + escape = 0; + for (p = s; (p) && (*p); p++) + { + if (!quote) + { + if (*p == '\"') + { + quote = 1; + p++; + } + } + if (!quote) + { + if (!strncmp(p, key, keyl)) + { + Code_Lookup *cl; + + cl = calloc(1, sizeof(Code_Lookup)); + if (cl) + { + int inesc = 0; + char *name; + + cl->ptr = p; + p += keyl; + while ((*p)) + { + if (!inesc) + { + if (*p == '\\') inesc = 1; + else if (*p == '\"') break; + } + else + inesc = 0; + p++; + } + cl->len = p - cl->ptr + 1; + name = alloca(cl->len); + if (name) + { + char *pp; + int i; + + name[0] = 0; + pp = cl->ptr + keyl; + inesc = 0; + i = 0; + while (*pp) + { + if (!inesc) + { + if (*pp == '\\') inesc = 1; + else if (*pp == '\"') + { + name[i] = 0; + break; + } + else + { + name[i] = *pp; + name[i + 1] = 0; + i++; + } + } + else + inesc = 0; + pp++; + } + func(pc, name, &(cl->val)); + } + code_lookups = evas_list_append(code_lookups, cl); + } + else break; + } + } + else + { + if (!escape) + { + if (*p == '\"') quote = 0; + else if (*p == '\\') escape = 1; + } + else if (escape) + { + escape = 0; + } + } + } +} + +void +data_queue_image_pc_lookup(Edje_Part_Collection *pc, char *name, int *dest) +{ + data_queue_image_lookup(name, dest); +} + +void +data_process_scripts(void) +{ + Evas_List *l, *l2; + + for (l = codes, l2 = edje_collections; (l) && (l2); l = l->next, l2 = l2->next) + { + Code *cd; + Edje_Part_Collection *pc; + + cd = l->data; + pc = l2->data; + if ((cd->shared) || (cd->programs)) + { + Evas_List *ll; + + if (cd->shared) + { + data_process_string(pc, "PART", cd->shared, data_queue_part_lookup); + data_process_string(pc, "PROGRAM", cd->shared, data_queue_program_lookup); + data_process_string(pc, "IMAGE", cd->shared, data_queue_image_pc_lookup); + } + for (ll = cd->programs; ll; ll = ll->next) + { + Code_Program *cp; + + cp = ll->data; + if (cp->script) + { + data_process_string(pc, "PART", cp->script, data_queue_part_lookup); + data_process_string(pc, "PROGRAM", cp->script, data_queue_program_lookup); + data_process_string(pc, "IMAGE", cp->script, data_queue_image_pc_lookup); + } + } + } + } +} + +void +data_process_script_lookups(void) +{ + Evas_List *l; + + for (l = code_lookups; l; l = l->next) + { + Code_Lookup *cl; + char buf[256]; + int i, n; + + cl = l->data; + snprintf(buf, sizeof(buf), "%i", cl->val); + n = strlen(buf); + if (n > cl->len) + { + fprintf(stderr, "%s: Error. The unexpected happened. A numeric replacement string was larger than the original!\n", + progname); + exit(-1); + } + for (i = 0; i < cl->len; i++) cl->ptr[i] = ' '; + strncpy(cl->ptr, buf, n); + } +} diff --git a/legacy/edje/src/lib/edje_embryo.c b/legacy/edje/src/lib/edje_embryo.c index 91db90fd9d..02c2526c88 100644 --- a/legacy/edje/src/lib/edje_embryo.c +++ b/legacy/edje/src/lib/edje_embryo.c @@ -48,17 +48,6 @@ static void _edje_embryo_globals_init(Edje *ed); -/* BASIC NUTS & BOLTS - * - * get_int(key[]) - * set_int(key[], val) - * get_float(key[]) - * set_float(key[], Float:val) - * get_strlen(key[]) - * get_str(key[], dst[], maxlen) - * set_str(key[], str[]) - */ - /* get_int(id) */ static Embryo_Cell _edje_embryo_fn_get_int(Embryo_Program *ep, Embryo_Cell *params) @@ -194,24 +183,24 @@ _edje_embryo_fn_set_str(Embryo_Program *ep, Embryo_Cell *params) /* EDJE... * - * set_state(part[], state[], Float:state_val) - * set_tween_state(part[], state1[], Float:state1_val, state2[], Float:state2_val) + * set_state(part_id, state[], Float:state_val) + * set_tween_state(part_id, state1[], Float:state1_val, state2[], Float:state2_val) * emit(sig[], src[]) - * run_program(name[]) - * stop_program(name[]) - * stop_programs_on(name[]) - * Direction:get_drag_dir(name[]) - * get_drag(name[], &Float:dx, &Float:&dy) - * set_drag(name[], Float:dx, Float:dy) - * get_drag_step(name[], &Float:dx, &Float:&dy) - * set_drag_step(name[], Float:dx, Float:dy) - * get_drag_page(name[], &Float:dx, &Float:&dy) - * set_drag_page(name[], Float:dx, Float:dy) - * get_drag_count(name[], &Float:dx, &Float:&dy) - * set_drag_count(name[], Float:dx, Float:dy) - * set_drag_confine(name[], confine_name[]) - * text_set(name[], str[]) - * text_get(name[], dst[], maxlen) + * run_program(program_id) + * stop_program(program_id) + * stop_programs_on(part_id) + * Direction:get_drag_dir(part_id) + * get_drag(part_id, &Float:dx, &Float:&dy) + * set_drag(part_id, Float:dx, Float:dy) + * get_drag_step(part_id, &Float:dx, &Float:&dy) + * set_drag_step(part_id, Float:dx, Float:dy) + * get_drag_page(part_id, &Float:dx, &Float:&dy) + * set_drag_page(part_id, Float:dx, Float:dy) + * get_drag_count(part_id, &Float:dx, &Float:&dy) + * set_drag_count(part_id, Float:dx, Float:dy) + * set_drag_confine(part_id, confine_part_id) + * text_set(part_id, str[]) + * text_get(part_id, dst[], maxlen) * get_min_size(w, h) * set_min_size(&w, &h) * get_max_size(w, h) @@ -224,20 +213,20 @@ _edje_embryo_fn_set_str(Embryo_Program *ep, Embryo_Cell *params) * get_color_class(class[], &r, &g, &b, &a) * set_text_class(class[], font[], Float:size) * get_text_class(class[], font[], &Float:size) - * //set_type(name[], Type:type) - * //set_effect(name[], Effect:fx) - * set_mouse_events(name[], ev) - * get_mouse_events(name[]) - * set_repeat_events(name[], rep) - * get_repeat_events(name[]) - * set_clip(name[], clip_name[]) - * get_clip(name[], clip_name_dst[], clip_name_dst_max) + * //set_type(part_id, Type:type) + * //set_effect(part_id, Effect:fx) + * set_mouse_events(part_id, ev) + * get_mouse_events(part_id) + * set_repeat_events(part_id, rep) + * get_repeat_events(part_id) + * set_clip(part_id, clip_part_id) + * get_clip(part_id) */ /* MODIFY STATE VALUES * - * set_state_val(name[], state[], Float:state_val, Param:param, ...) - * get_state_val(name[], state[], Float:state_val, Param:param, ...) + * set_state_val(part_id, state[], Float:state_val, Param:param, ...) + * get_state_val(part_id, state[], Float:state_val, Param:param, ...) * * FOR THESE PROPERTIES: * @@ -247,9 +236,9 @@ _edje_embryo_fn_set_str(Embryo_Program *ep, Embryo_Cell *params) * max[w,h] * step[x,y] * aspect[min,max] - * rel1[rx,ry,namex[],namey[]] + * rel1[rx,ry,part_id,part_id] * rel1[x,y] - * rel2[rx,ry,namex[],namey[]] + * rel2[rx,ry,part_id,part_id] * rel2[x,y] * image[id] * image[tween_list...] (get???)