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.
This commit is contained in:
Daniel Zaoui 2014-05-28 15:46:30 +03:00
parent d949e9b41b
commit cb499ab28e
2 changed files with 42 additions and 3 deletions

View File

@ -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)
{

View 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