Eolian: Coverity fixes

This commit is contained in:
Daniel Zaoui 2014-03-07 10:43:56 +02:00
parent 445059e706
commit bb8af681f9
7 changed files with 392 additions and 254 deletions

View File

@ -21,13 +21,13 @@ _template_fill(Eina_Strbuf *buf, const char* templ, const char* classname, const
if (strcmp(classname, normclass)) if (strcmp(classname, normclass))
{ {
//Fill cache //Fill cache
strcpy(normclass, classname); strncpy(normclass, classname, sizeof(normclass) - 1);
strcpy(capclass, classname); strncpy(capclass, classname, sizeof(capclass) - 1);
p = capclass; p = capclass;
eina_str_toupper(&p); eina_str_toupper(&p);
strcpy(lowclass, classname); strncpy(lowclass, classname, sizeof(lowclass) - 1);
p = lowclass; p = lowclass;
eina_str_tolower(&p); eina_str_tolower(&p);
@ -44,23 +44,25 @@ _template_fill(Eina_Strbuf *buf, const char* templ, const char* classname, const
eina_strbuf_append(classobj, "Evas_Obj"); eina_strbuf_append(classobj, "Evas_Obj");
} }
strcpy(capobjclass, eina_strbuf_string_get(classobj)); strncpy(capobjclass, eina_strbuf_string_get(classobj),
sizeof(capobjclass) - 1);
p = capobjclass; p = capobjclass;
eina_str_toupper(&p); eina_str_toupper(&p);
strcpy(lowobjclass, eina_strbuf_string_get(classobj)); strncpy(lowobjclass, eina_strbuf_string_get(classobj),
sizeof(lowobjclass) - 1);
p = lowobjclass; p = lowobjclass;
eina_str_tolower(&p); eina_str_tolower(&p);
strcpy(eoprefix, lowobjclass); strncpy(eoprefix, lowobjclass, sizeof(eoprefix) - 1);
if (!strcmp(classname, "Elm_Widget")) if (!strcmp(classname, "Elm_Widget"))
strcpy(eoprefix, "elm_wdg"); strncpy(eoprefix, "elm_wdg", sizeof(eoprefix) - 1);
eina_strbuf_free(classobj); eina_strbuf_free(classobj);
} }
strcpy(capfunc, funcname); strncpy(capfunc, funcname, sizeof(capfunc) - 1);
p = capfunc; eina_str_toupper(&p); p = capfunc; eina_str_toupper(&p);
eina_strbuf_replace_all(buf, "@#func", funcname); eina_strbuf_replace_all(buf, "@#func", funcname);
@ -79,10 +81,11 @@ _nextline(char *str, unsigned int lines)
if (!str) return NULL; if (!str) return NULL;
char *ret = str; char *ret = str;
while ((lines--) && *ret) while (lines--)
{ {
ret= strchr(ret, '\n'); ret= strchr(ret, '\n');
if (ret) ret++; if (ret) ret++;
else return NULL;
} }
return ret; return ret;
} }
@ -111,6 +114,7 @@ _source_desc_get(const char *str)
eina_strbuf_replace_all(part, "\"", "\\\""); eina_strbuf_replace_all(part, "\"", "\\\"");
} }
char *ret = eina_strbuf_string_steal(part); char *ret = eina_strbuf_string_steal(part);
eina_strbuf_free(part);
return ret; return ret;
} }

View File

@ -496,6 +496,7 @@ eo1_source_beginning_generate(const char *classname, Eina_Strbuf *buf)
Eina_Bool Eina_Bool
eo1_source_end_generate(const char *classname, Eina_Strbuf *buf) eo1_source_end_generate(const char *classname, Eina_Strbuf *buf)
{ {
Eina_Bool ret = EINA_FALSE;
const Eina_List *itr; const Eina_List *itr;
Eolian_Function fn; Eolian_Function fn;
@ -530,6 +531,7 @@ eo1_source_end_generate(const char *classname, Eina_Strbuf *buf)
Eina_Strbuf *str_func = eina_strbuf_new(); Eina_Strbuf *str_func = eina_strbuf_new();
Eina_Strbuf *str_bodyf = eina_strbuf_new(); Eina_Strbuf *str_bodyf = eina_strbuf_new();
Eina_Strbuf *str_ev = eina_strbuf_new(); Eina_Strbuf *str_ev = eina_strbuf_new();
Eina_Strbuf *tmpl_impl = eina_strbuf_new();
_template_fill(str_end, tmpl_eo_src_end, classname, "", EINA_TRUE); _template_fill(str_end, tmpl_eo_src_end, classname, "", EINA_TRUE);
@ -578,7 +580,7 @@ eo1_source_end_generate(const char *classname, Eina_Strbuf *buf)
eolian_implement_information_get(impl_desc, &impl_class, &funcname, &ftype); eolian_implement_information_get(impl_desc, &impl_class, &funcname, &ftype);
Eina_Strbuf *tmpl_impl = eina_strbuf_new(); eina_strbuf_reset(tmpl_impl);
eina_strbuf_append(tmpl_impl, tmpl_eo_func_desc); eina_strbuf_append(tmpl_impl, tmpl_eo_func_desc);
char implname[0xFF]; char implname[0xFF];
@ -603,7 +605,7 @@ eo1_source_end_generate(const char *classname, Eina_Strbuf *buf)
if (!in_meth && !in_prop) if (!in_meth && !in_prop)
{ {
ERR ("Failed to generate implementation of %s:%s - missing form super class", impl_class, funcname); ERR ("Failed to generate implementation of %s:%s - missing form super class", impl_class, funcname);
return EINA_FALSE; goto end;
} }
if (in_meth) if (in_meth)
@ -635,7 +637,6 @@ eo1_source_end_generate(const char *classname, Eina_Strbuf *buf)
eo1_bind_func_generate(classname, in_prop, GET, str_bodyf, impl_class); eo1_bind_func_generate(classname, in_prop, GET, str_bodyf, impl_class);
} }
} }
eina_strbuf_free(tmpl_impl);
} }
//Constructors //Constructors
@ -749,13 +750,16 @@ eo1_source_end_generate(const char *classname, Eina_Strbuf *buf)
eina_strbuf_append(buf, eina_strbuf_string_get(str_end)); eina_strbuf_append(buf, eina_strbuf_string_get(str_end));
ret = EINA_TRUE;
end:
eina_strbuf_free(tmpbuf); eina_strbuf_free(tmpbuf);
eina_strbuf_free(str_op); eina_strbuf_free(str_op);
eina_strbuf_free(str_func); eina_strbuf_free(str_func);
eina_strbuf_free(str_bodyf); eina_strbuf_free(str_bodyf);
eina_strbuf_free(str_end); eina_strbuf_free(str_end);
eina_strbuf_free(str_ev); eina_strbuf_free(str_ev);
eina_strbuf_free(tmpl_impl);
return EINA_TRUE; return ret;
} }

View File

@ -227,7 +227,7 @@ _eapi_func_generate(const char *classname, Eolian_Function funcid, Eolian_Functi
if (!func_lpref) if (!func_lpref)
{ {
strcpy(tmpstr, classname); strncpy(tmpstr, classname, sizeof(tmpstr) - 1);
char *p = tmpstr; char *p = tmpstr;
eina_str_tolower(&p); eina_str_tolower(&p);
func_lpref = tmpstr; func_lpref = tmpstr;
@ -437,6 +437,7 @@ legacy_header_append(const char *classname, int eo_version EINA_UNUSED, Eina_Str
Eina_Bool Eina_Bool
legacy_source_generate(const char *classname, Eina_Bool legacy, int eo_version EINA_UNUSED, Eina_Strbuf *buf) legacy_source_generate(const char *classname, Eina_Bool legacy, int eo_version EINA_UNUSED, Eina_Strbuf *buf)
{ {
Eina_Bool ret = EINA_FALSE;
const Eina_List *itr; const Eina_List *itr;
if (!eolian_class_exists(classname)) if (!eolian_class_exists(classname))
@ -448,7 +449,7 @@ legacy_source_generate(const char *classname, Eina_Bool legacy, int eo_version E
Eina_Strbuf *tmpbuf = eina_strbuf_new(); Eina_Strbuf *tmpbuf = eina_strbuf_new();
Eina_Strbuf *str_bodyf = eina_strbuf_new(); Eina_Strbuf *str_bodyf = eina_strbuf_new();
if (!eo1_source_beginning_generate(classname, buf)) return EINA_FALSE; if (!eo1_source_beginning_generate(classname, buf)) goto end;
//Properties //Properties
Eolian_Function fn; Eolian_Function fn;
@ -461,12 +462,12 @@ legacy_source_generate(const char *classname, Eina_Bool legacy, int eo_version E
if (prop_write) if (prop_write)
{ {
if (!eo1_bind_func_generate(classname, fn, SET, str_bodyf, NULL)) return EINA_FALSE; if (!eo1_bind_func_generate(classname, fn, SET, str_bodyf, NULL)) goto end;
if (legacy) _eapi_func_generate(classname, fn, SET, str_bodyf); if (legacy) _eapi_func_generate(classname, fn, SET, str_bodyf);
} }
if (prop_read) if (prop_read)
{ {
if (!eo1_bind_func_generate(classname, fn, GET, str_bodyf, NULL)) return EINA_FALSE; if (!eo1_bind_func_generate(classname, fn, GET, str_bodyf, NULL)) goto end;
if (legacy) _eapi_func_generate(classname, fn, GET, str_bodyf); if (legacy) _eapi_func_generate(classname, fn, GET, str_bodyf);
} }
} }
@ -474,16 +475,18 @@ legacy_source_generate(const char *classname, Eina_Bool legacy, int eo_version E
//Methods //Methods
EINA_LIST_FOREACH(eolian_class_functions_list_get(classname, METHOD_FUNC), itr, fn) EINA_LIST_FOREACH(eolian_class_functions_list_get(classname, METHOD_FUNC), itr, fn)
{ {
if (!eo1_bind_func_generate(classname, fn, UNRESOLVED, str_bodyf, NULL)) return EINA_FALSE; if (!eo1_bind_func_generate(classname, fn, UNRESOLVED, str_bodyf, NULL)) goto end;
if (legacy) _eapi_func_generate(classname, fn, UNRESOLVED, str_bodyf); if (legacy) _eapi_func_generate(classname, fn, UNRESOLVED, str_bodyf);
} }
eina_strbuf_append(buf, eina_strbuf_string_get(str_bodyf)); eina_strbuf_append(buf, eina_strbuf_string_get(str_bodyf));
if (!eo1_source_end_generate(classname, buf)) return EINA_FALSE; if (!eo1_source_end_generate(classname, buf)) goto end;
ret = EINA_TRUE;
end:
eina_strbuf_free(tmpbuf); eina_strbuf_free(tmpbuf);
eina_strbuf_free(str_bodyf); eina_strbuf_free(str_bodyf);
return EINA_TRUE; return ret;
} }

View File

@ -15,8 +15,9 @@ static Eina_Bool legacy_support = EINA_FALSE;
static char* static char*
_include_guard_enclose(const char *fname, const char *fbody) _include_guard_enclose(const char *fname, const char *fbody)
{ {
char incname[0xFF]; char incname[255];
strcpy (incname, fname); memset(incname, 0, sizeof(incname));
strncpy (incname, fname, sizeof(incname) - 1);
char *p = incname; char *p = incname;
eina_str_toupper(&p); eina_str_toupper(&p);

File diff suppressed because it is too large Load Diff

View File

@ -366,6 +366,7 @@ _eo_tokenizer_implement_get(Eo_Tokenizer *toknz, char *p)
###### TOKENIZE ACCESSOR ###### TOKENIZE ACCESSOR
action end_accessor_comment { action end_accessor_comment {
if (!toknz->tmp.accessor) ABORT(toknz, "No accessor!!!");
if (toknz->tmp.accessor->comment != NULL) if (toknz->tmp.accessor->comment != NULL)
ABORT(toknz, "accessor has already a comment"); ABORT(toknz, "accessor has already a comment");
toknz->tmp.accessor->comment = _eo_tokenizer_token_get(toknz, fpc-1); toknz->tmp.accessor->comment = _eo_tokenizer_token_get(toknz, fpc-1);
@ -373,6 +374,7 @@ _eo_tokenizer_implement_get(Eo_Tokenizer *toknz, char *p)
} }
action end_accessor_rettype { action end_accessor_rettype {
if (!toknz->tmp.accessor) ABORT(toknz, "No accessor!!!");
if (toknz->tmp.accessor->ret.type != NULL) if (toknz->tmp.accessor->ret.type != NULL)
ABORT(toknz, "accessor has already a return type"); ABORT(toknz, "accessor has already a return type");
toknz->tmp.accessor->ret.type = _eo_tokenizer_token_get(toknz, fpc); toknz->tmp.accessor->ret.type = _eo_tokenizer_token_get(toknz, fpc);
@ -380,6 +382,7 @@ _eo_tokenizer_implement_get(Eo_Tokenizer *toknz, char *p)
} }
action end_accessor_rettype_comment { action end_accessor_rettype_comment {
if (!toknz->tmp.accessor) ABORT(toknz, "No accessor!!!");
if (toknz->tmp.accessor->ret.comment != NULL) if (toknz->tmp.accessor->ret.comment != NULL)
ABORT(toknz, "accessor return type has already a comment"); ABORT(toknz, "accessor return type has already a comment");
toknz->tmp.accessor->ret.comment = _eo_tokenizer_token_get(toknz, fpc-2); toknz->tmp.accessor->ret.comment = _eo_tokenizer_token_get(toknz, fpc-2);
@ -387,16 +390,19 @@ _eo_tokenizer_implement_get(Eo_Tokenizer *toknz, char *p)
} }
action end_accessor_rettype_unused_flag { action end_accessor_rettype_unused_flag {
if (!toknz->tmp.accessor) ABORT(toknz, "No accessor!!!");
toknz->tmp.accessor->ret.warn_unused = EINA_TRUE; toknz->tmp.accessor->ret.warn_unused = EINA_TRUE;
INF(" WARN_UNUSED"); INF(" WARN_UNUSED");
} }
action end_accessor_legacy { action end_accessor_legacy {
if (!toknz->tmp.accessor) ABORT(toknz, "No accessor!!!");
toknz->tmp.accessor->legacy = _eo_tokenizer_token_get(toknz, fpc); toknz->tmp.accessor->legacy = _eo_tokenizer_token_get(toknz, fpc);
} }
action end_accessor { action end_accessor {
INF(" }"); INF(" }");
if (!toknz->tmp.prop) ABORT(toknz, "No prop!!!");
toknz->tmp.prop->accessors = eina_list_append(toknz->tmp.prop->accessors, toknz->tmp.accessor); toknz->tmp.prop->accessors = eina_list_append(toknz->tmp.prop->accessors, toknz->tmp.accessor);
toknz->tmp.accessor = NULL; toknz->tmp.accessor = NULL;
toknz->current_nesting--; toknz->current_nesting--;
@ -408,6 +414,8 @@ _eo_tokenizer_implement_get(Eo_Tokenizer *toknz, char *p)
} }
action end_param_desc { action end_param_desc {
if (!toknz->tmp.accessor_param)
ABORT(toknz, "No accessor param!!!");
toknz->tmp.accessor_param->attrs = _eo_tokenizer_token_get(toknz, fpc); toknz->tmp.accessor_param->attrs = _eo_tokenizer_token_get(toknz, fpc);
toknz->tmp.accessor->params = toknz->tmp.accessor->params =
eina_list_append(toknz->tmp.accessor->params, toknz->tmp.accessor_param); eina_list_append(toknz->tmp.accessor->params, toknz->tmp.accessor_param);
@ -506,6 +514,7 @@ _eo_tokenizer_implement_get(Eo_Tokenizer *toknz, char *p)
} }
action end_property { action end_property {
if (!toknz->tmp.prop) ABORT(toknz, "No property!!!");
if (eina_list_count(toknz->tmp.prop->values) == 0) if (eina_list_count(toknz->tmp.prop->values) == 0)
WRN("property '%s' has no values.", toknz->tmp.prop->name); WRN("property '%s' has no values.", toknz->tmp.prop->name);
if (eina_list_count(toknz->tmp.prop->accessors) == 0) if (eina_list_count(toknz->tmp.prop->accessors) == 0)
@ -536,6 +545,7 @@ _eo_tokenizer_implement_get(Eo_Tokenizer *toknz, char *p)
###### TOKENIZE PROPERTIES ###### TOKENIZE PROPERTIES
action begin_property { action begin_property {
if (!toknz->tmp.prop) ABORT(toknz, "No property!!!");
INF(" %s {", toknz->tmp.prop->name); INF(" %s {", toknz->tmp.prop->name);
toknz->current_nesting++; toknz->current_nesting++;
fgoto tokenize_property; fgoto tokenize_property;
@ -566,6 +576,7 @@ _eo_tokenizer_implement_get(Eo_Tokenizer *toknz, char *p)
###### TOKENIZE METHOD ###### TOKENIZE METHOD
action end_method_comment { action end_method_comment {
if (!toknz->tmp.meth) ABORT(toknz, "No method!!!");
if (toknz->tmp.meth->comment != NULL) if (toknz->tmp.meth->comment != NULL)
ABORT(toknz, "method has already a comment"); ABORT(toknz, "method has already a comment");
toknz->tmp.meth->comment = _eo_tokenizer_token_get(toknz, fpc-1); toknz->tmp.meth->comment = _eo_tokenizer_token_get(toknz, fpc-1);
@ -573,6 +584,7 @@ _eo_tokenizer_implement_get(Eo_Tokenizer *toknz, char *p)
} }
action begin_method_params { action begin_method_params {
if (!toknz->tmp.meth) ABORT(toknz, "No method!!!");
INF(" params {"); INF(" params {");
toknz->current_nesting++; toknz->current_nesting++;
toknz->tmp.params = &(toknz->tmp.meth->params); toknz->tmp.params = &(toknz->tmp.meth->params);
@ -580,6 +592,7 @@ _eo_tokenizer_implement_get(Eo_Tokenizer *toknz, char *p)
} }
action end_method_rettype { action end_method_rettype {
if (!toknz->tmp.meth) ABORT(toknz, "No method!!!");
if (toknz->tmp.meth->ret.type != NULL) if (toknz->tmp.meth->ret.type != NULL)
ABORT(toknz, "method '%s' has already a return type", toknz->tmp.meth->name); ABORT(toknz, "method '%s' has already a return type", toknz->tmp.meth->name);
toknz->tmp.meth->ret.type = _eo_tokenizer_token_get(toknz, fpc); toknz->tmp.meth->ret.type = _eo_tokenizer_token_get(toknz, fpc);
@ -587,6 +600,7 @@ _eo_tokenizer_implement_get(Eo_Tokenizer *toknz, char *p)
} }
action end_method_rettype_comment { action end_method_rettype_comment {
if (!toknz->tmp.meth) ABORT(toknz, "No method!!!");
if (toknz->tmp.meth->ret.comment != NULL) if (toknz->tmp.meth->ret.comment != NULL)
ABORT(toknz, "method '%s' return type has already a comment", toknz->tmp.meth->name); ABORT(toknz, "method '%s' return type has already a comment", toknz->tmp.meth->name);
toknz->tmp.meth->ret.comment = _eo_tokenizer_token_get(toknz, fpc-2); toknz->tmp.meth->ret.comment = _eo_tokenizer_token_get(toknz, fpc-2);
@ -594,21 +608,25 @@ _eo_tokenizer_implement_get(Eo_Tokenizer *toknz, char *p)
} }
action end_method_rettype_unused_flag{ action end_method_rettype_unused_flag{
if (!toknz->tmp.meth) ABORT(toknz, "No method!!!");
toknz->tmp.meth->ret.warn_unused = EINA_TRUE; toknz->tmp.meth->ret.warn_unused = EINA_TRUE;
INF(" WARN_UNUSED"); INF(" WARN_UNUSED");
} }
action end_method_legacy { action end_method_legacy {
if (!toknz->tmp.meth) ABORT(toknz, "No method!!!");
toknz->tmp.meth->legacy = _eo_tokenizer_token_get(toknz, fpc); toknz->tmp.meth->legacy = _eo_tokenizer_token_get(toknz, fpc);
} }
action end_method_obj_const{ action end_method_obj_const{
if (!toknz->tmp.meth) ABORT(toknz, "No method!!!");
toknz->tmp.meth->obj_const = EINA_TRUE; toknz->tmp.meth->obj_const = EINA_TRUE;
INF(" obj const"); INF(" obj const");
} }
action end_method { action end_method {
Eina_List **l; Eina_List **l;
if (!toknz->tmp.meth) ABORT(toknz, "No method!!!");
if (eina_list_count(toknz->tmp.meth->params) == 0) if (eina_list_count(toknz->tmp.meth->params) == 0)
WRN("method '%s' has no parameters.", toknz->tmp.meth->name); WRN("method '%s' has no parameters.", toknz->tmp.meth->name);
INF(" }"); INF(" }");
@ -657,6 +675,7 @@ _eo_tokenizer_implement_get(Eo_Tokenizer *toknz, char *p)
###### TOKENIZE METHODS ###### TOKENIZE METHODS
action begin_method { action begin_method {
if (!toknz->tmp.meth) ABORT(toknz, "No method!!!");
INF(" %s {", toknz->tmp.meth->name); INF(" %s {", toknz->tmp.meth->name);
toknz->current_nesting++; toknz->current_nesting++;
fgoto tokenize_method; fgoto tokenize_method;
@ -688,6 +707,7 @@ _eo_tokenizer_implement_get(Eo_Tokenizer *toknz, char *p)
###### TOKENIZE CLASS ###### TOKENIZE CLASS
action end_class_comment { action end_class_comment {
if (!toknz->tmp.kls) ABORT(toknz, "No class!!!");
if (toknz->tmp.kls->comment != NULL) if (toknz->tmp.kls->comment != NULL)
ABORT(toknz, "class %s has already a comment", toknz->tmp.kls->name); ABORT(toknz, "class %s has already a comment", toknz->tmp.kls->name);
toknz->tmp.kls->comment = _eo_tokenizer_token_get(toknz, fpc-1); toknz->tmp.kls->comment = _eo_tokenizer_token_get(toknz, fpc-1);
@ -699,6 +719,7 @@ _eo_tokenizer_implement_get(Eo_Tokenizer *toknz, char *p)
} }
action end_inherits { action end_inherits {
if (!toknz->tmp.kls) ABORT(toknz, "No class!!!");
toknz->tmp.kls->inherits = toknz->tmp.str_items; toknz->tmp.kls->inherits = toknz->tmp.str_items;
toknz->tmp.str_items = NULL; toknz->tmp.str_items = NULL;
} }
@ -737,6 +758,7 @@ _eo_tokenizer_implement_get(Eo_Tokenizer *toknz, char *p)
} }
action end_class { action end_class {
if (!toknz->tmp.kls) ABORT(toknz, "No class!!!");
INF("end class: %s", toknz->tmp.kls->name); INF("end class: %s", toknz->tmp.kls->name);
toknz->classes = eina_list_append(toknz->classes, toknz->tmp.kls); toknz->classes = eina_list_append(toknz->classes, toknz->tmp.kls);
toknz->tmp.kls = NULL; toknz->tmp.kls = NULL;
@ -745,11 +767,13 @@ _eo_tokenizer_implement_get(Eo_Tokenizer *toknz, char *p)
} }
action end_event_name { action end_event_name {
if (!toknz->tmp.kls) ABORT(toknz, "No class!!!");
toknz->tmp.event = _eo_tokenizer_event_get(toknz, fpc); toknz->tmp.event = _eo_tokenizer_event_get(toknz, fpc);
toknz->tmp.kls->events = eina_list_append(toknz->tmp.kls->events, toknz->tmp.event); toknz->tmp.kls->events = eina_list_append(toknz->tmp.kls->events, toknz->tmp.event);
} }
action end_event_comment { action end_event_comment {
if (!toknz->tmp.event) ABORT(toknz, "No event!!!");
if (toknz->tmp.event->comment != NULL) if (toknz->tmp.event->comment != NULL)
ABORT(toknz, "event %s has already a comment", toknz->tmp.event->name); ABORT(toknz, "event %s has already a comment", toknz->tmp.event->name);
toknz->tmp.event->comment = _eo_tokenizer_token_get(toknz, fpc-2); toknz->tmp.event->comment = _eo_tokenizer_token_get(toknz, fpc-2);
@ -757,6 +781,7 @@ _eo_tokenizer_implement_get(Eo_Tokenizer *toknz, char *p)
} }
action end_legacy_prefix { action end_legacy_prefix {
if (!toknz->tmp.kls) ABORT(toknz, "No class!!!");
if (toknz->tmp.kls->legacy_prefix != NULL) if (toknz->tmp.kls->legacy_prefix != NULL)
ABORT(toknz, "A legacy prefix has already been given"); ABORT(toknz, "A legacy prefix has already been given");
toknz->tmp.kls->legacy_prefix = _eo_tokenizer_token_get(toknz, fpc); toknz->tmp.kls->legacy_prefix = _eo_tokenizer_token_get(toknz, fpc);
@ -769,23 +794,27 @@ _eo_tokenizer_implement_get(Eo_Tokenizer *toknz, char *p)
inherits = begin_list (class_it class_it_next*)? end_list %end_inherits; inherits = begin_list (class_it class_it_next*)? end_list %end_inherits;
action impl_meth_store { action impl_meth_store {
if (!toknz->tmp.kls) ABORT(toknz, "No class!!!");
toknz->tmp.impl = _eo_tokenizer_implement_get(toknz, fpc); toknz->tmp.impl = _eo_tokenizer_implement_get(toknz, fpc);
toknz->tmp.kls->implements = eina_list_append(toknz->tmp.kls->implements, toknz->tmp.impl); toknz->tmp.kls->implements = eina_list_append(toknz->tmp.kls->implements, toknz->tmp.impl);
} }
action impl_legacy_create { action impl_legacy_create {
if (!toknz->tmp.impl) ABORT(toknz, "No implement!!!");
if (toknz->tmp.impl->legacy) if (toknz->tmp.impl->legacy)
ABORT(toknz, "Legacy section already allocated for implement item"); ABORT(toknz, "Legacy section already allocated for implement item");
toknz->tmp.impl->legacy = calloc(1, sizeof(Eo_Implement_Legacy_Def)); toknz->tmp.impl->legacy = calloc(1, sizeof(Eo_Implement_Legacy_Def));
} }
action impl_legacy_function_name_store { action impl_legacy_function_name_store {
if (!toknz->tmp.impl) ABORT(toknz, "No implement!!!");
if (!toknz->tmp.impl->legacy) if (!toknz->tmp.impl->legacy)
ABORT(toknz, "No legacy section"); ABORT(toknz, "No legacy section");
toknz->tmp.impl->legacy->function_name = _eo_tokenizer_token_get(toknz, fpc); toknz->tmp.impl->legacy->function_name = _eo_tokenizer_token_get(toknz, fpc);
} }
action impl_legacy_eo_param_store { action impl_legacy_eo_param_store {
if (!toknz->tmp.impl) ABORT(toknz, "No implement!!!");
toknz->tmp.impl_leg_param = calloc(1, sizeof(Eo_Implement_Legacy_Param_Def)); toknz->tmp.impl_leg_param = calloc(1, sizeof(Eo_Implement_Legacy_Param_Def));
toknz->tmp.impl->legacy->params = eina_list_append( toknz->tmp.impl->legacy->params = eina_list_append(
toknz->tmp.impl->legacy->params, toknz->tmp.impl_leg_param); toknz->tmp.impl->legacy->params, toknz->tmp.impl_leg_param);
@ -794,20 +823,26 @@ _eo_tokenizer_implement_get(Eo_Tokenizer *toknz, char *p)
} }
action impl_legacy_leg_param_store { action impl_legacy_leg_param_store {
if (!toknz->tmp.impl_leg_param)
ABORT(toknz, "No implement legacy param!!!");
toknz->tmp.impl_leg_param->legacy_name = _eo_tokenizer_token_get(toknz, fpc); toknz->tmp.impl_leg_param->legacy_name = _eo_tokenizer_token_get(toknz, fpc);
} }
action impl_legacy_param_comment_store { action impl_legacy_param_comment_store {
if (!toknz->tmp.impl_leg_param)
ABORT(toknz, "No implement legacy param!!!");
toknz->tmp.impl_leg_param->comment = _eo_tokenizer_token_get(toknz, fpc-2); toknz->tmp.impl_leg_param->comment = _eo_tokenizer_token_get(toknz, fpc-2);
} }
action impl_legacy_return_type_store { action impl_legacy_return_type_store {
if (!toknz->tmp.impl) ABORT(toknz, "No implement!!!");
if (!toknz->tmp.impl->legacy) if (!toknz->tmp.impl->legacy)
ABORT(toknz, "No legacy section"); ABORT(toknz, "No legacy section");
toknz->tmp.impl->legacy->ret_type= _eo_tokenizer_token_get(toknz, fpc); toknz->tmp.impl->legacy->ret_type= _eo_tokenizer_token_get(toknz, fpc);
} }
action impl_legacy_return_val_store { action impl_legacy_return_val_store {
if (!toknz->tmp.impl) ABORT(toknz, "No implement!!!");
if (!toknz->tmp.impl->legacy) if (!toknz->tmp.impl->legacy)
ABORT(toknz, "No legacy section"); ABORT(toknz, "No legacy section");
toknz->tmp.impl->legacy->ret_value = _eo_tokenizer_token_get(toknz, fpc); toknz->tmp.impl->legacy->ret_value = _eo_tokenizer_token_get(toknz, fpc);
@ -868,6 +903,7 @@ _eo_tokenizer_implement_get(Eo_Tokenizer *toknz, char *p)
###### TOP LEVEL ###### TOP LEVEL
action begin_class { action begin_class {
if (!toknz->tmp.kls) ABORT(toknz, "No class!!!");
INF("begin class: %s", toknz->tmp.kls->name); INF("begin class: %s", toknz->tmp.kls->name);
toknz->current_nesting++; toknz->current_nesting++;
fgoto tokenize_class; fgoto tokenize_class;
@ -1153,6 +1189,7 @@ eo_tokenizer_dump(Eo_Tokenizer *toknz)
Eina_Bool Eina_Bool
eo_tokenizer_database_fill(const char *filename) eo_tokenizer_database_fill(const char *filename)
{ {
Eina_Bool ret = EINA_FALSE;
const char *s; const char *s;
Eina_List *k, *l, *m; Eina_List *k, *l, *m;
@ -1163,25 +1200,25 @@ eo_tokenizer_database_fill(const char *filename)
Eo_Accessor_Def *accessor; Eo_Accessor_Def *accessor;
Eo_Event_Def *event; Eo_Event_Def *event;
Eo_Implement_Def *impl; Eo_Implement_Def *impl;
/* Eo_Ret_Def *ret; */
Eo_Tokenizer *toknz = eo_tokenizer_get(); Eo_Tokenizer *toknz = eo_tokenizer_get();
if (!toknz) if (!toknz)
{ {
ERR("can't create eo_tokenizer"); ERR("can't create eo_tokenizer");
return EINA_FALSE; goto end;
} }
FILE *stream = fopen(filename, "rb"); FILE *stream = fopen(filename, "rb");
char *buffer = malloc(BUFSIZE);
unsigned int len = fread(buffer, 1, BUFSIZE, stream);
if (!stream) if (!stream)
{ {
ERR("unable to read in %s", filename); ERR("unable to read in %s", filename);
return EINA_FALSE; goto end;
} }
if (!eo_tokenizer_mem_walk(toknz, filename, buffer, len)) return EINA_FALSE; char *buffer = malloc(BUFSIZE);
unsigned int len = fread(buffer, 1, BUFSIZE, stream);
if (!eo_tokenizer_mem_walk(toknz, filename, buffer, len)) goto end;
EINA_LIST_FOREACH(toknz->classes, k, kls) EINA_LIST_FOREACH(toknz->classes, k, kls)
{ {
@ -1263,12 +1300,12 @@ eo_tokenizer_database_fill(const char *filename)
if (!desc) if (!desc)
{ {
printf("Error - %s not known as parameter of property %s\n", acc_param->name, prop->name); printf("Error - %s not known as parameter of property %s\n", acc_param->name, prop->name);
return EINA_FALSE;
}
if (strstr(acc_param->attrs, "const"))
{
database_parameter_get_const_attribute_set(desc, EINA_TRUE);
} }
else
if (strstr(acc_param->attrs, "const"))
{
database_parameter_get_const_attribute_set(desc, EINA_TRUE);
}
} }
} }
} }
@ -1338,8 +1375,8 @@ eo_tokenizer_database_fill(const char *filename)
kls->name, func, ftype); kls->name, func, ftype);
if (!foo_id) if (!foo_id)
{ {
printf("Error - %s not known in class %s\n", class + 9, kls->name); ERR("Error - %s not known in class %s", class + 9, kls->name);
return EINA_FALSE; goto end;
} }
database_function_set_as_virtual_pure(foo_id); database_function_set_as_virtual_pure(foo_id);
continue; continue;
@ -1371,8 +1408,12 @@ eo_tokenizer_database_fill(const char *filename)
} }
eo_tokenizer_free(toknz); ret = EINA_TRUE;
return EINA_TRUE; end:
if (buffer) free(buffer);
if (stream) fclose(stream);
if (toknz) eo_tokenizer_free(toknz);
return ret;
} }
void void

View File

@ -986,50 +986,50 @@ static Eina_Bool _function_print(const _Function_Id *fid, int nb_spaces)
{ {
printf("%*s<%s> %s\n", nb_spaces, "", ret_desc ? ret_desc : "", fid->name); printf("%*s<%s> %s\n", nb_spaces, "", ret_desc ? ret_desc : "", fid->name);
const char *str = eolian_function_description_get(foo_id, EOLIAN_COMMENT_GET); const char *str = eolian_function_description_get(foo_id, EOLIAN_COMMENT_GET);
if (str) printf("%*s<%s>\n", nb_spaces + 5, "", (str ? str : "")); if (str) printf("%*s<%s>\n", nb_spaces + 5, "", str);
str = eolian_function_description_get(foo_id, EOLIAN_COMMENT_SET); str = eolian_function_description_get(foo_id, EOLIAN_COMMENT_SET);
if (str) printf("%*s<%s>\n", nb_spaces + 5, "", (str ? str : "")); if (str) printf("%*s<%s>\n", nb_spaces + 5, "", str);
str = eolian_function_data_get(foo_id, EOLIAN_LEGACY_GET); str = eolian_function_data_get(foo_id, EOLIAN_LEGACY_GET);
if (str) printf("%*slegacy_get: <%s>\n", nb_spaces + 5, "", (str ? str : "")); if (str) printf("%*slegacy_get: <%s>\n", nb_spaces + 5, "", str);
str = eolian_function_data_get(foo_id, EOLIAN_LEGACY_SET); str = eolian_function_data_get(foo_id, EOLIAN_LEGACY_SET);
if (str) printf("%*slegacy_set: <%s>\n", nb_spaces + 5, "", (str ? str : "")); if (str) printf("%*slegacy_set: <%s>\n", nb_spaces + 5, "", str);
str = eolian_function_data_get(foo_id, EOLIAN_PROP_GET_RETURN_TYPE); str = eolian_function_data_get(foo_id, EOLIAN_PROP_GET_RETURN_TYPE);
if (str) printf("%*sreturn type for get: <%s>\n", nb_spaces + 5, "", (str ? str : "")); if (str) printf("%*sreturn type for get: <%s>\n", nb_spaces + 5, "", str);
str = eolian_function_data_get(foo_id, EOLIAN_PROP_SET_RETURN_TYPE); str = eolian_function_data_get(foo_id, EOLIAN_PROP_SET_RETURN_TYPE);
if (str) printf("%*sreturn type for set: <%s>\n", nb_spaces + 5, "", (str ? str : "")); if (str) printf("%*sreturn type for set: <%s>\n", nb_spaces + 5, "", str);
break; break;
} }
case GET: case GET:
{ {
printf("%*sGET:<%s> %s\n", nb_spaces, "", ret_desc ? ret_desc : "", fid->name); printf("%*sGET:<%s> %s\n", nb_spaces, "", ret_desc ? ret_desc : "", fid->name);
const char *str = eolian_function_description_get(foo_id, EOLIAN_COMMENT_GET); const char *str = eolian_function_description_get(foo_id, EOLIAN_COMMENT_GET);
if (str) printf("%*s<%s>\n", nb_spaces + 5, "", (str ? str : "")); if (str) printf("%*s<%s>\n", nb_spaces + 5, "", str);
str = eolian_function_data_get(foo_id, EOLIAN_LEGACY_GET); str = eolian_function_data_get(foo_id, EOLIAN_LEGACY_GET);
if (str) printf("%*slegacy: <%s>\n", nb_spaces + 5, "", (str ? str : "")); if (str) printf("%*slegacy: <%s>\n", nb_spaces + 5, "", str);
str = eolian_function_data_get(foo_id, EOLIAN_PROP_GET_RETURN_TYPE); str = eolian_function_data_get(foo_id, EOLIAN_PROP_GET_RETURN_TYPE);
if (str) printf("%*sreturn type: <%s>\n", nb_spaces + 5, "", (str ? str : "")); if (str) printf("%*sreturn type: <%s>\n", nb_spaces + 5, "", str);
break; break;
} }
case SET: case SET:
{ {
printf("%*sSET:<%s> %s\n", nb_spaces, "", ret_desc ? ret_desc : "", fid->name); printf("%*sSET:<%s> %s\n", nb_spaces, "", ret_desc ? ret_desc : "", fid->name);
const char *str = eolian_function_description_get(foo_id, EOLIAN_COMMENT_SET); const char *str = eolian_function_description_get(foo_id, EOLIAN_COMMENT_SET);
if (str) printf("%*s<%s>\n", nb_spaces + 5, "", (str ? str : "")); if (str) printf("%*s<%s>\n", nb_spaces + 5, "", str);
str = eolian_function_data_get(foo_id, EOLIAN_LEGACY_SET); str = eolian_function_data_get(foo_id, EOLIAN_LEGACY_SET);
if (str) printf("%*slegacy: <%s>\n", nb_spaces + 5, "", (str ? str : "")); if (str) printf("%*slegacy: <%s>\n", nb_spaces + 5, "", str);
str = eolian_function_data_get(foo_id, EOLIAN_PROP_SET_RETURN_TYPE); str = eolian_function_data_get(foo_id, EOLIAN_PROP_SET_RETURN_TYPE);
if (str) printf("%*sreturn type: <%s>\n", nb_spaces + 5, "", (str ? str : "")); if (str) printf("%*sreturn type: <%s>\n", nb_spaces + 5, "", str);
break; break;
} }
case METHOD_FUNC: case METHOD_FUNC:
{ {
printf("%*s<%s> %s\n", nb_spaces, "", ret_desc ? ret_desc : "", fid->name); printf("%*s<%s> %s\n", nb_spaces, "", ret_desc ? ret_desc : "", fid->name);
const char *str = eolian_function_description_get(foo_id, EOLIAN_COMMENT); const char *str = eolian_function_description_get(foo_id, EOLIAN_COMMENT);
if (str) printf("%*s<%s>\n", nb_spaces + 5, "", (str ? str : "")); if (str) printf("%*s<%s>\n", nb_spaces + 5, "", str);
str = eolian_function_data_get(foo_id, EOLIAN_LEGACY); str = eolian_function_data_get(foo_id, EOLIAN_LEGACY);
if (str) printf("%*slegacy: <%s>\n", nb_spaces + 5, "", (str ? str : "")); if (str) printf("%*slegacy: <%s>\n", nb_spaces + 5, "", str);
str = eolian_function_data_get(foo_id, EOLIAN_METHOD_RETURN_TYPE); str = eolian_function_data_get(foo_id, EOLIAN_METHOD_RETURN_TYPE);
if (str) printf("%*sreturn type: <%s>\n", nb_spaces + 5, "", (str ? str : "")); if (str) printf("%*sreturn type: <%s>\n", nb_spaces + 5, "", str);
if (fid->obj_is_const) printf("%*sobj const: <true>\n", nb_spaces + 5, ""); if (fid->obj_is_const) printf("%*sobj const: <true>\n", nb_spaces + 5, "");
break; break;
} }
@ -1038,11 +1038,11 @@ static Eina_Bool _function_print(const _Function_Id *fid, int nb_spaces)
{ {
//char *str = eina_hash_find(fid->data, "comment"); //char *str = eina_hash_find(fid->data, "comment");
const char *str = eolian_function_description_get(foo_id, EOLIAN_COMMENT); const char *str = eolian_function_description_get(foo_id, EOLIAN_COMMENT);
if (str) printf("%*s<%s>\n", nb_spaces + 5, "", (str ? str : "")); if (str) printf("%*s<%s>\n", nb_spaces + 5, "", str);
str = eolian_function_data_get(foo_id, EOLIAN_LEGACY); str = eolian_function_data_get(foo_id, EOLIAN_LEGACY);
if (str) printf("%*slegacy: <%s>\n", nb_spaces + 5, "", (str ? str : "")); if (str) printf("%*slegacy: <%s>\n", nb_spaces + 5, "", str);
str = eolian_function_data_get(foo_id, EOLIAN_METHOD_RETURN_TYPE); str = eolian_function_data_get(foo_id, EOLIAN_METHOD_RETURN_TYPE);
if (str) printf("%*sreturn type: <%s>\n", nb_spaces + 5, "", (str ? str : "")); if (str) printf("%*sreturn type: <%s>\n", nb_spaces + 5, "", str);
break; break;
} }
default: default: