From 7c1508ec8c22d6f8ff1390beda044f21a5ce3a5f Mon Sep 17 00:00:00 2001 From: tsauerbeck Date: Fri, 22 Oct 2004 20:25:31 +0000 Subject: [PATCH] implemented string list calls. untested, beware. SVN revision: 11964 --- legacy/edje/data/include/edje.inc | 4 ++ legacy/edje/src/lib/edje_embryo.c | 90 +++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+) diff --git a/legacy/edje/data/include/edje.inc b/legacy/edje/data/include/edje.inc index b74d097cc7..1d3f067fc2 100644 --- a/legacy/edje/data/include/edje.inc +++ b/legacy/edje/data/include/edje.inc @@ -43,6 +43,10 @@ native append_int (id, v); native prepend_int(id, v); native insert_int (id, pos, v); native fetch_int (id, pos); +native append_str (id, str[]); +native prepend_str(id, str[]); +native insert_str (id, pos, str[]); +native fetch_str (id, pos, dst[], maxlen); /********************/ /* Edje timer calls */ diff --git a/legacy/edje/src/lib/edje_embryo.c b/legacy/edje/src/lib/edje_embryo.c index e5d7d3a3b8..7b99a4d33a 100644 --- a/legacy/edje/src/lib/edje_embryo.c +++ b/legacy/edje/src/lib/edje_embryo.c @@ -408,6 +408,92 @@ _edje_embryo_fn_fetch_int(Embryo_Program *ep, Embryo_Cell *params) (int) params[2]); } +/* append_str(id, str[]) */ +static Embryo_Cell +_edje_embryo_fn_append_str(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed = embryo_program_data_get(ep); + char *s; + + CHKPARAM(2); + + GETSTR(s, params[2]); + if (s) + _edje_var_list_str_append(ed, (int) params[1], s); + + return 0; +} + +/* prepend_str(id, str[]) */ +static Embryo_Cell +_edje_embryo_fn_prepend_str(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed = embryo_program_data_get(ep); + char *s; + + CHKPARAM(2); + + GETSTR(s, params[2]); + if (s) + _edje_var_list_str_prepend(ed, (int) params[1], s); + + return 0; +} + +/* insert_str(id, pos, str[]) */ +static Embryo_Cell +_edje_embryo_fn_insert_str(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed = embryo_program_data_get(ep); + char *s; + + CHKPARAM(3); + + GETSTR(s, params[3]); + if (s) + _edje_var_list_str_insert(ed, (int) params[1], (int) params[2], s); + + return 0; +} + +/* fetch_str(id, pos, dst[], maxlen) */ +static Embryo_Cell +_edje_embryo_fn_fetch_str(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed = embryo_program_data_get(ep); + char *s; + + CHKPARAM(4); + + s = (char *) _edje_var_list_nth_str_get(ed, (int) params[1], + (int) params[2]); + if (s) + { + if (strlen(s) < params[4]) + { + SETSTR(s, params[3]); + } + else + { + char *ss; + + ss = strdup(s); + if (ss) + { + ss[params[4] - 1] = 0; + SETSTR(ss, params[3]); + free(ss); + } + } + } + else + { + SETSTR("", params[3]); + } + + return 0; +} + /* timer(Float:in, fname[], val) */ static Embryo_Cell _edje_embryo_fn_timer(Embryo_Program *ep, Embryo_Cell *params) @@ -1255,6 +1341,10 @@ _edje_embryo_script_init(Edje *ed) embryo_program_native_call_add(ep, "prepend_int", _edje_embryo_fn_prepend_int); embryo_program_native_call_add(ep, "insert_int", _edje_embryo_fn_insert_int); embryo_program_native_call_add(ep, "fetch_int", _edje_embryo_fn_fetch_int); + embryo_program_native_call_add(ep, "append_str", _edje_embryo_fn_append_str); + embryo_program_native_call_add(ep, "prepend_str", _edje_embryo_fn_prepend_str); + embryo_program_native_call_add(ep, "insert_str", _edje_embryo_fn_insert_str); + embryo_program_native_call_add(ep, "fetch_str", _edje_embryo_fn_fetch_str); embryo_program_native_call_add(ep, "timer", _edje_embryo_fn_timer); embryo_program_native_call_add(ep, "cancel_timer", _edje_embryo_fn_cancel_timer);