Enlightenment CVS committal
Author : raster
Project : e17
Module : libs/edje
Dir : e17/libs/edje/src/lib
Modified Files:
Edje_Edit.h Makefile.am edje_embryo.c edje_load.c
edje_private.h edje_util.c
Added Files:
edje_var.c
Log Message:
busy adding some MEAT to edje's embryo script support. just added
"persistent" variables - ie tied to each instance of an edje object and you
can save/load via get_int() set_int() get_float() set_float(), get_str(),
get_strlen() and set_str(). the values are fetched/stored wherever you do
these calls. you need a public variable declaration to indicate you want to
use a global var, and use this variable handle as the variable index - edje
will init it for you.
e_logo.edc has some examples...
:)
this solves being able to keep state like if a check button is enabled or
disabled etc. etc. etc.
then i guess its onto the rest of the calls...
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/edje/src/lib/Edje_Edit.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -3 -r1.5 -r1.6
--- Edje_Edit.h 28 Mar 2004 05:26:17 -0000 1.5
+++ Edje_Edit.h 30 Mar 2004 10:30:35 -0000 1.6
@@ -123,6 +123,13 @@
#define EDJE_TWEEN_MODE_DECELERATE 4
#define EDJE_TWEEN_MODE_LAST 5
+#define EDJE_VAR_NONE 0
+#define EDJE_VAR_INT 1
+#define EDJE_VAR_FLOAT 2
+#define EDJE_VAR_STRING 3
+
+#define EDJE_VAR_MAGIC_BASE 0x12fe84ba
+
/*----------*/
struct _Edje_File
@@ -371,6 +378,11 @@
typedef struct _Edje_Text_Style Edje_Text_Style;
typedef struct _Edje_Color_Class Edje_Color_Class;
typedef struct _Edje_Text_Class Edje_Text_Class;
+typedef struct _Edje_Var Edje_Var;
+typedef struct _Edje_Var_Int Edje_Var_Int;
+typedef struct _Edje_Var_Float Edje_Var_Float;
+typedef struct _Edje_Var_String Edje_Var_String;
+typedef struct _Edje_Var_Pool Edje_Var_Pool;
struct _Edje
{
@@ -412,6 +424,7 @@
Evas_List *emissions;
int load_error;
int freeze;
+ Edje_Var_Pool *var_pool;
};
struct _Edje_Real_Part
@@ -567,6 +580,37 @@
double size;
};
+struct _Edje_Var_Int
+{
+ int v;
+};
+
+struct _Edje_Var_Float
+{
+ double v;
+};
+
+struct _Edje_Var_String
+{
+ char *v;
+};
+
+struct _Edje_Var_Pool
+{
+ int size;
+ Edje_Var *vars;
+};
+
+struct _Edje_Var
+{
+ unsigned char type;
+ union {
+ Edje_Var_Int i;
+ Edje_Var_Float f;
+ Edje_Var_String s;
+ } data;
+};
+
void _edje_part_pos_set(Edje *ed, Edje_Real_Part *ep, int mode, double pos);
void _edje_part_description_apply(Edje *ed, Edje_Real_Part *ep, char *d1, double
v1, char *d2, double v2);
void _edje_recalc(Edje *ed);
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/edje/src/lib/Makefile.am,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -3 -r1.12 -r1.13
--- Makefile.am 26 Mar 2004 09:10:05 -0000 1.12
+++ Makefile.am 30 Mar 2004 10:30:35 -0000 1.13
@@ -34,6 +34,7 @@
edje_smart.c \
edje_text.c \
edje_util.c \
+edje_var.c \
edje_private.h
libedje_la_LIBADD = $(LDFLAGS) -lm @evas_libs@ @ecore_libs@ @eet_libs@
@embryo_libs@
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/edje/src/lib/edje_embryo.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -3 -r1.5 -r1.6
--- edje_embryo.c 30 Mar 2004 02:03:07 -0000 1.5
+++ edje_embryo.c 30 Mar 2004 10:30:35 -0000 1.6
@@ -1,50 +1,8 @@
#include "Edje.h"
#include "edje_private.h"
-#define CHKPARAM(n) if (params[0] != (sizeof(Embryo_Cell) * (n))) return 0;
-
-/**** All the api exported to edje scripts ****/
-/* tst() */
-static Embryo_Cell
-_edje_embryo_fn_tst(Embryo_Program *ep, Embryo_Cell *params)
-{
- Edje *ed;
-
- /* params[0] = number of bytes of params passed */
- ed = embryo_program_data_get(ep);
- printf("EDJE DEBUG: Embryo code detected for \"%s\":\"%s\"\n",
- ed->path, ed->part);
- return 7;
-}
-
-/* emit(sig[], src[]) */
-static Embryo_Cell
-_edje_embryo_fn_emit(Embryo_Program *ep, Embryo_Cell *params)
-{
- Edje *ed;
- Embryo_Cell *cptr;
- char *sig, *src;
- int l;
-
- CHKPARAM(2);
- ed = embryo_program_data_get(ep);
-
- cptr = embryo_data_address_get(ep, params[1]);
- l = embryo_data_string_length_get(ep, cptr);
- sig = alloca(l + 1);
- embryo_data_string_get(ep, cptr, sig);
-
- cptr = embryo_data_address_get(ep, params[2]);
- l = embryo_data_string_length_get(ep, cptr);
- src = alloca(l + 1);
- embryo_data_string_get(ep, cptr, src);
-
- _edje_emit(ed, sig, src);
- return 0;
-}
-
/*
- * ALREADY EXPORTEd By EMBRYO:
+ * ALREADY EXPORTED BY EMBRYO:
*
* Float:atof(string[]);
* Float:fract(Float:value);
@@ -73,29 +31,168 @@
* strchr(str[], ch[]);
* strrchr(str[], ch[]);
* rand();
- *
- * ROUTINES TO EXPORT:
- *
- * BASIC NUTS & BOLTS
+ */
+
+#define CHKPARAM(n) if (params[0] != (sizeof(Embryo_Cell) * (n))) return 0;
+#define GETSTR(str, par) { \
+ Embryo_Cell *___cptr; \
+ int ___l; \
+ if ((___cptr = embryo_data_address_get(ep, (par)))) { \
+ ___l = embryo_data_string_length_get(ep, ___cptr); \
+ if (((str) = alloca(___l + 1))) \
+ embryo_data_string_get(ep, ___cptr, (str));}}
+#define SETSTR(str, par) { \
+ Embryo_Cell *___cptr; \
+ if ((___cptr = embryo_data_address_get(ep, (par)))) { \
+ embryo_data_string_set(ep, str, ___cptr);}}
+
+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[])
- *
- * TIMERS... (tick off in N seconds from now)
+ */
+
+/* get_int(id) */
+static Embryo_Cell
+_edje_embryo_fn_get_int(Embryo_Program *ep, Embryo_Cell *params)
+{
+ Edje *ed;
+
+ CHKPARAM(1);
+ ed = embryo_program_data_get(ep);
+ return (Embryo_Cell)_edje_var_int_get(ed, (int)params[1]);
+}
+
+/* set_int(id, v) */
+static Embryo_Cell
+_edje_embryo_fn_set_int(Embryo_Program *ep, Embryo_Cell *params)
+{
+ Edje *ed;
+
+ CHKPARAM(2);
+ ed = embryo_program_data_get(ep);
+ _edje_var_int_set(ed, (int)params[1], (int)params[2]);
+ return 0;
+}
+
+/* get_float(id) */
+static Embryo_Cell
+_edje_embryo_fn_get_float(Embryo_Program *ep, Embryo_Cell *params)
+{
+ Edje *ed;
+ float v;
+
+ CHKPARAM(1);
+ ed = embryo_program_data_get(ep);
+ v = (float)_edje_var_float_get(ed, params[1]);
+ return EMBRYO_FLOAT_TO_CELL(v);
+}
+
+/* set_float(id, v) */
+static Embryo_Cell
+_edje_embryo_fn_set_float(Embryo_Program *ep, Embryo_Cell *params)
+{
+ Edje *ed;
+ float v;
+
+ CHKPARAM(2);
+ ed = embryo_program_data_get(ep);
+ v = EMBRYO_CELL_TO_FLOAT(params[2]);
+ _edje_var_float_set(ed, (int)params[1], (double)v);
+ return 0;
+}
+
+/* get_str(id, dst[], maxlen) */
+static Embryo_Cell
+_edje_embryo_fn_get_str(Embryo_Program *ep, Embryo_Cell *params)
+{
+ Edje *ed;
+ char *s;
+
+ CHKPARAM(3);
+ if (params[3] < 1) return 0;
+ ed = embryo_program_data_get(ep);
+ s = (char *)_edje_var_str_get(ed, (int)params[1]);
+ if (s)
+ {
+ if (strlen(s) < params[3])
+ {
+ SETSTR(s, params[2]);
+ }
+ else
+ {
+ char *ss;
+
+ ss = strdup(s);
+ if (ss)
+ {
+ ss[params[3] - 1] = 0;
+ SETSTR(ss, params[2]);
+ free(ss);
+ }
+ }
+ }
+ else
+ {
+ SETSTR("", params[2]);
+ }
+ return 0;
+}
+
+/* get_strlen(id) */
+static Embryo_Cell
+_edje_embryo_fn_get_strlen(Embryo_Program *ep, Embryo_Cell *params)
+{
+ Edje *ed;
+ char *s;
+
+ CHKPARAM(1);
+ ed = embryo_program_data_get(ep);
+ s = (char *)_edje_var_str_get(ed, (int)params[1]);
+ if (s)
+ {
+ return strlen(s);
+ }
+ return 0;
+}
+
+/* set_str(id, str[]) */
+static Embryo_Cell
+_edje_embryo_fn_set_str(Embryo_Program *ep, Embryo_Cell *params)
+{
+ Edje *ed;
+ char *s;
+
+ CHKPARAM(2);
+ ed = embryo_program_data_get(ep);
+ GETSTR(s, params[2]);
+ if (s)
+ {
+ _edje_var_str_set(ed, (int)params[1], s);
+ }
+ return 0;
+}
+
+/* TIMERS... (tick off in N seconds from now)
*
* timer(Float:in, fname[], val)
* cancel_timer(id)
- *
- * ANIMATORS... (run for N seconds, passing in position)
+ */
+
+/* ANIMATORS... (run for N seconds, passing in position)
*
* anim(Float:length, fname[], ...) (varargs = series of int's - no strings))
- * candel_anim(id);
- *
- * EDJE...
+ * cancel_anim(id);
+ */
+
+/* EDJE...
*
* set_state(part[], state[], Float:state_val)
* set_tween_state(part[], state1[], Float:state1_val, state2[], Float:state2_val)
@@ -135,13 +232,14 @@
* get_repeat_events(name[])
* set_clip(name[], clip_name[])
* get_clip(name[], clip_name_dst[], clip_name_dst_max)
- *
- * MODIFY STATE VALUES
+ */
+
+/* MODIFY STATE VALUES
*
* set_state_val(name[], state[], Float:state_val, Param:param, ...)
* get_state_val(name[], state[], Float:state_val, Param:param, ...)
*
- * for these:
+ * FOR THESE PROPERTIES:
*
* visible
* align[x,y]
@@ -169,26 +267,65 @@
* text[fit_x,fit_y]
* text[min_x,min_y]
* text[align_x,align_y]
- *
- * FUTURE: KEYS???
+ */
+
+/* FUTURE: KEYS???
*
*/
+/**** All the api exported to edje scripts ****/
+/* tst() */
+static Embryo_Cell
+_edje_embryo_fn_tst(Embryo_Program *ep, Embryo_Cell *params)
+{
+ Edje *ed;
+
+ /* params[0] = number of bytes of params passed */
+ ed = embryo_program_data_get(ep);
+ printf("EDJE DEBUG: Embryo code detected for \"%s\":\"%s\"\n",
+ ed->path, ed->part);
+ return 7;
+}
+
+/* emit(sig[], src[]) */
+static Embryo_Cell
+_edje_embryo_fn_emit(Embryo_Program *ep, Embryo_Cell *params)
+{
+ Edje *ed;
+ char *sig, *src;
+
+ CHKPARAM(2);
+ ed = embryo_program_data_get(ep);
+ GETSTR(sig, params[1]);
+ GETSTR(src, params[2]);
+ if ((!sig) || (!src)) return 0;
+ _edje_emit(ed, sig, src);
+ return 0;
+}
+
void
_edje_embryo_script_init(Edje *ed)
{
Embryo_Program *ep;
-
+
if (!ed) return;
if (!ed->collection) return;
if (!ed->collection->script) return;
ep = ed->collection->script;
embryo_program_data_set(ep, ed);
/* first advertise all the edje "script" calls */
+ embryo_program_native_call_add(ep, "get_int", _edje_embryo_fn_get_int);
+ embryo_program_native_call_add(ep, "set_int", _edje_embryo_fn_set_int);
+ embryo_program_native_call_add(ep, "get_float", _edje_embryo_fn_get_float);
+ embryo_program_native_call_add(ep, "set_float", _edje_embryo_fn_set_float);
+ embryo_program_native_call_add(ep, "get_str", _edje_embryo_fn_get_str);
+ embryo_program_native_call_add(ep, "get_strlen", _edje_embryo_fn_get_strlen);
+ embryo_program_native_call_add(ep, "set_str", _edje_embryo_fn_set_str);
+
embryo_program_native_call_add(ep, "tst", _edje_embryo_fn_tst);
embryo_program_native_call_add(ep, "emit", _edje_embryo_fn_emit);
-
embryo_program_vm_push(ep); /* neew a new vm to run in */
+ _edje_embryo_globals_init(ed);
}
void
@@ -211,6 +348,7 @@
if (!ed->collection->script) return;
if (embryo_program_recursion_get(ed->collection->script) > 0) return;
embryo_program_vm_reset(ed->collection->script);
+ _edje_embryo_globals_init(ed);
}
void
@@ -232,3 +370,24 @@
printf("EDJE DEBUG: Done.\n");
}
}
+
+static void
+_edje_embryo_globals_init(Edje *ed)
+{
+ int n, i;
+ Embryo_Program *ep;
+
+ ep = ed->collection->script;
+ n = embryo_program_variable_count_get(ep);
+ for (i = 0; i < n; i++)
+ {
+ Embryo_Cell cell, *cptr;
+
+ cell = embryo_program_variable_get(ep, i);
+ if (cell != EMBRYO_CELL_NONE)
+ {
+ cptr = embryo_data_address_get(ep, cell);
+ if (cptr) *cptr = EDJE_VAR_MAGIC_BASE + i;
+ }
+ }
+}
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/edje/src/lib/edje_load.c,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -3 -r1.38 -r1.39
--- edje_load.c 26 Mar 2004 09:10:05 -0000 1.38
+++ edje_load.c 30 Mar 2004 10:30:35 -0000 1.39
@@ -187,6 +187,7 @@
_edje_block(ed);
_edje_freeze(ed);
if (ed->collection->script) _edje_embryo_script_init(ed);
+ _edje_var_init(ed);
_edje_emit(ed, "load", "");
for (l = ed->parts; l; l = l->next)
{
@@ -451,6 +452,7 @@
_edje_emit(ed, NULL, NULL); /* clear out signal emissions */
ed->dont_clear_signals = 1;
_edje_block_violate(ed);
+ _edje_var_shutdown(ed);
if (ed->collection)
{
ed->collection->references--;
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/edje/src/lib/edje_private.h,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -3 -r1.61 -r1.62
--- edje_private.h 28 Mar 2004 05:26:17 -0000 1.61
+++ edje_private.h 30 Mar 2004 10:30:35 -0000 1.62
@@ -15,6 +15,7 @@
#include <math.h>
#include <fnmatch.h>
+#include <alloca.h>
#include "Edje_Edit.h"
@@ -56,9 +57,18 @@
extern Edje_Text_Style _edje_text_styles[EDJE_TEXT_EFFECT_LAST];
extern Evas_List *_edje_edjes;
-void _edje_embryo_script_init (Edje *ed);
-void _edje_embryo_script_shutdown (Edje *ed);
-void _edje_embryo_script_reset (Edje *ed);
-void _edje_embryo_test_run (Edje *ed, char *fname, char *sig, char *src);
-
+void _edje_embryo_script_init (Edje *ed);
+void _edje_embryo_script_shutdown (Edje *ed);
+void _edje_embryo_script_reset (Edje *ed);
+void _edje_embryo_test_run (Edje *ed, char *fname, char *sig, char
*src);
+void _edje_var_init (Edje *ed);
+void _edje_var_shutdown (Edje *ed);
+int _edje_var_string_id_get (Edje *ed, char *string);
+int _edje_var_int_get (Edje *ed, int id);
+void _edje_var_int_set (Edje *ed, int id, int v);
+double _edje_var_float_get (Edje *ed, int id);
+void _edje_var_float_set (Edje *ed, int id, double v);
+const char *_edje_var_str_get (Edje *ed, int id);
+void _edje_var_str_set (Edje *ed, int id, char *str);
+
#endif
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/edje/src/lib/edje_util.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -3 -r1.34 -r1.35
--- edje_util.c 16 Jan 2004 01:42:57 -0000 1.34
+++ edje_util.c 30 Mar 2004 10:30:35 -0000 1.35
@@ -995,6 +995,10 @@
_edje_emit(ed, "drag,page", rp->part->name);
}
+
+
+
+
Edje_Real_Part *
_edje_real_part_get(Edje *ed, char *part)
{
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs