Enlightenment CVS committal
Author : raster
Project : e17
Module : libs/edje
Dir : e17/libs/edje/src/bin
Modified Files:
edje_cc.c edje_cc.h edje_cc_out.c
Log Message:
string replacement with ID's in edje_cc for verbatim code snippets... see
example
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/edje/src/bin/edje_cc.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -3 -r1.12 -r1.13
--- edje_cc.c 8 Mar 2004 02:43:47 -0000 1.12
+++ edje_cc.c 1 Apr 2004 09:30:45 -0000 1.13
@@ -92,7 +92,9 @@
data_setup();
compile();
+ data_process_scripts();
data_process_lookups();
+ data_process_script_lookups();
data_write();
edje_shutdown();
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/edje/src/bin/edje_cc.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -3 -r1.10 -r1.11
--- edje_cc.h 28 Mar 2004 05:26:17 -0000 1.10
+++ edje_cc.h 1 Apr 2004 09:30:45 -0000 1.11
@@ -18,6 +18,7 @@
#include <stdarg.h>
#include <locale.h>
#include <ctype.h>
+#include <alloca.h>
/* types */
typedef struct _New_Object_Handler New_Object_Handler;
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/edje/src/bin/edje_cc_out.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -3 -r1.13 -r1.14
--- edje_cc_out.c 30 Mar 2004 10:30:35 -0000 1.13
+++ edje_cc_out.c 1 Apr 2004 09:30:45 -0000 1.14
@@ -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 @@
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 @@
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 @@
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);
+ }
+}
-------------------------------------------------------
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