Eolian: Add an internal environment for class variables.
authorDaniel Zaoui <daniel.zaoui@samsung.com>
Wed, 28 May 2014 12:46:30 +0000 (15:46 +0300)
committerDaniel Zaoui <daniel.zaoui@samsung.com>
Thu, 29 May 2014 06:58:27 +0000 (09:58 +0300)
To reduce the invocations to strings conversions, we store the
classname, the Eo prefix in upper and lower cases in global variables.
The problem comes when we have to handle overriding functions. A lot of
conflicts between class base and class inheriting can happen.

The chosen solution is to create independent environments storing the
converted strings.

src/bin/eolian/common_funcs.c
src/bin/eolian/common_funcs.h

index da6123c..da770f4 100644 (file)
@@ -20,6 +20,34 @@ _class_name_concatenate(const Eolian_Class class, char *buffer)
 }
 
 void
+_class_env_create(const Eolian_Class class, const char *over_classname, _eolian_class_vars *env)
+{
+   if (!env || !class) return;
+
+   const char *eo_prefix = NULL;
+   char *p;
+
+   if (!class)
+      strncpy(env->full_classname, over_classname, PATH_MAX - 1);
+   else
+      _class_name_concatenate(class, env->full_classname);
+
+   /* class/CLASS*/
+   p = strncpy(env->upper_classname, env->full_classname, PATH_MAX - 1);
+   eina_str_toupper(&p);
+   p = strncpy(env->lower_classname, env->full_classname, PATH_MAX - 1);
+   eina_str_tolower(&p);
+
+   /* eo_prefix */
+   if (class) eo_prefix = eolian_class_eo_prefix_get(class);
+   if (!eo_prefix) eo_prefix = env->full_classname;
+   p = strncpy(env->upper_eo_prefix, eo_prefix, PATH_MAX - 1);
+   eina_str_toupper(&p);
+   p = strncpy(env->lower_eo_prefix, eo_prefix, PATH_MAX - 1);
+   eina_str_tolower(&p);
+}
+
+void
 _class_func_names_fill(const Eolian_Class class, const char *over_classname, const char *funcname)
 {
    char *p;
index 03cce70..6b8d504 100644 (file)
@@ -33,6 +33,17 @@ extern int _eolian_gen_log_dom;
 #endif
 #define CRIT(...) EINA_LOG_DOM_CRIT(_eolian_gen_log_dom, __VA_ARGS__)
 
+typedef struct
+{
+   char full_classname[PATH_MAX];
+
+   char upper_eo_prefix[PATH_MAX];
+   char lower_eo_prefix[PATH_MAX];
+
+   char upper_classname[PATH_MAX];
+   char lower_classname[PATH_MAX];
+}_eolian_class_vars;
+
 void _template_fill(Eina_Strbuf *buf, const char *templ, const Eolian_Class class, const char *classname, const char *funcname, Eina_Bool reset);
 
 char *_nextline(char *str, unsigned int lines);
@@ -41,6 +52,8 @@ char *_startline(char *str, char *pos);
 
 char *_source_desc_get(const char *str);
 
+void _class_env_create(const Eolian_Class class, const char *over_classname, _eolian_class_vars *env);
+
 void _class_func_names_fill(const Eolian_Class class, const char *classname, const char *funcname);
 
 char current_eo_prefix_lower[256];
@@ -49,10 +62,8 @@ char current_eo_prefix_upper[256];
 
 char current_classname[256];
 
-char capobjclass[0xFF];
-char lowobjclass[0xFF];
 char capclass[0xFF];
 char lowclass[0xFF];
-char normclass[0xFF];
+
 char capfunc[0xFF];
 #endif