From cb499ab28e49a3ea633da50214e18d45c29e609d Mon Sep 17 00:00:00 2001 From: Daniel Zaoui Date: Wed, 28 May 2014 15:46:30 +0300 Subject: [PATCH] Eolian: Add an internal environment for class variables. 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 | 28 ++++++++++++++++++++++++++++ src/bin/eolian/common_funcs.h | 17 ++++++++++++++--- 2 files changed, 42 insertions(+), 3 deletions(-) diff --git a/src/bin/eolian/common_funcs.c b/src/bin/eolian/common_funcs.c index da6123ce3c..da770f4d8d 100644 --- a/src/bin/eolian/common_funcs.c +++ b/src/bin/eolian/common_funcs.c @@ -19,6 +19,34 @@ _class_name_concatenate(const Eolian_Class class, char *buffer) sprintf(buffer, "%s", eolian_class_name_get(class)); } +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) { diff --git a/src/bin/eolian/common_funcs.h b/src/bin/eolian/common_funcs.h index 03cce704a6..6b8d5046b4 100644 --- a/src/bin/eolian/common_funcs.h +++ b/src/bin/eolian/common_funcs.h @@ -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