forked from enlightenment/efl
Eolian/Generator: errors handling improvement.
Errors occuring during generation are now propagated to the main (i.e exit code). Logs have been ported to EINA_LOG instead of printf.
This commit is contained in:
parent
baaf92c93a
commit
21533a0079
|
@ -226,7 +226,7 @@ eo1_header_generate(const char *classname, Eina_Strbuf *buf)
|
|||
|
||||
if (!eolian_class_exists(classname))
|
||||
{
|
||||
printf ("Class \"%s\" not found in database\n", classname);
|
||||
ERR ("Class \"%s\" not found in database", classname);
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
|
@ -508,7 +508,7 @@ eo1_source_end_generate(const char *classname, Eina_Strbuf *buf)
|
|||
|
||||
if (!str_classtype)
|
||||
{
|
||||
printf ("Unknown class type for class %s !\n", classname);
|
||||
ERR ("Unknown class type for class %s !", classname);
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
|
@ -590,7 +590,7 @@ eo1_source_end_generate(const char *classname, Eina_Strbuf *buf)
|
|||
|
||||
if (!in_meth && !in_prop)
|
||||
{
|
||||
printf ("Failed to generate implementation of %s:%s - missing form super class\n", impl_class, funcname);
|
||||
ERR ("Failed to generate implementation of %s:%s - missing form super class", impl_class, funcname);
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
|
|
|
@ -320,7 +320,7 @@ legacy_header_append(const char *classname, int eo_version, Eina_Strbuf *header)
|
|||
{
|
||||
printf ("Class %s not found - append all\n", classname);
|
||||
eina_strbuf_append_char(header, '\n');
|
||||
eo1_header_generate(classname, header);
|
||||
if (!eo1_header_generate(classname, header)) return EINA_FALSE;
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
|
@ -356,7 +356,7 @@ legacy_header_append(const char *classname, int eo_version, Eina_Strbuf *header)
|
|||
{
|
||||
printf ("Appending eo function %s\n", funcname);
|
||||
eo1_enum_append(classname, funcname, str_subid);
|
||||
eo1_fundef_generate(classname, (Eolian_Function)data, UNRESOLVED, str_funcdef);
|
||||
if (!eo1_fundef_generate(classname, (Eolian_Function)data, UNRESOLVED, str_funcdef)) return EINA_FALSE;
|
||||
}
|
||||
}
|
||||
if (prop_read)
|
||||
|
@ -366,7 +366,7 @@ legacy_header_append(const char *classname, int eo_version, Eina_Strbuf *header)
|
|||
{
|
||||
printf ("Appending eo function %s\n", tmpstr);
|
||||
eo1_enum_append(classname, tmpstr, str_subid);
|
||||
eo1_fundef_generate(classname, (Eolian_Function)data, GET, str_funcdef);
|
||||
if (!eo1_fundef_generate(classname, (Eolian_Function)data, GET, str_funcdef)) return EINA_FALSE;
|
||||
}
|
||||
}
|
||||
if (prop_write)
|
||||
|
@ -376,7 +376,7 @@ legacy_header_append(const char *classname, int eo_version, Eina_Strbuf *header)
|
|||
{
|
||||
printf ("Appending eo function %s\n", tmpstr);
|
||||
eo1_enum_append(classname, tmpstr, str_subid);
|
||||
eo1_fundef_generate(classname, (Eolian_Function)data, SET, str_funcdef);
|
||||
if (!eo1_fundef_generate(classname, (Eolian_Function)data, SET, str_funcdef)) return EINA_FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -407,7 +407,7 @@ legacy_source_generate(const char *classname, Eina_Bool legacy, int eo_version,
|
|||
Eina_Strbuf *tmpbuf = eina_strbuf_new();
|
||||
Eina_Strbuf *str_bodyf = eina_strbuf_new();
|
||||
|
||||
eo1_source_beginning_generate(classname, buf);
|
||||
if (!eo1_source_beginning_generate(classname, buf)) return EINA_FALSE;
|
||||
|
||||
//Properties
|
||||
Eolian_Function fn;
|
||||
|
@ -420,12 +420,12 @@ legacy_source_generate(const char *classname, Eina_Bool legacy, int eo_version,
|
|||
|
||||
if (prop_read)
|
||||
{
|
||||
eo1_bind_func_generate(classname, fn, GET, str_bodyf);
|
||||
if (!eo1_bind_func_generate(classname, fn, GET, str_bodyf)) return EINA_FALSE;
|
||||
if (legacy) _eapi_func_generate(classname, fn, GET, str_bodyf);
|
||||
}
|
||||
if (prop_write)
|
||||
{
|
||||
eo1_bind_func_generate(classname, fn, SET, str_bodyf);
|
||||
if (!eo1_bind_func_generate(classname, fn, SET, str_bodyf)) return EINA_FALSE;
|
||||
if (legacy) _eapi_func_generate(classname, fn, SET, str_bodyf);
|
||||
}
|
||||
}
|
||||
|
@ -433,13 +433,13 @@ legacy_source_generate(const char *classname, Eina_Bool legacy, int eo_version,
|
|||
//Methods
|
||||
EINA_LIST_FOREACH(eolian_class_functions_list_get(classname, METHOD_FUNC), itr, fn)
|
||||
{
|
||||
eo1_bind_func_generate(classname, fn, UNRESOLVED, str_bodyf);
|
||||
if (!eo1_bind_func_generate(classname, fn, UNRESOLVED, str_bodyf)) return EINA_FALSE;
|
||||
if (legacy) _eapi_func_generate(classname, fn, UNRESOLVED, str_bodyf);
|
||||
}
|
||||
|
||||
eina_strbuf_append(buf, eina_strbuf_string_get(str_bodyf));
|
||||
|
||||
eo1_source_end_generate(classname, buf);
|
||||
if (!eo1_source_end_generate(classname, buf)) return EINA_FALSE;
|
||||
|
||||
eina_strbuf_free(tmpbuf);
|
||||
eina_strbuf_free(str_bodyf);
|
||||
|
|
|
@ -23,25 +23,33 @@ _generate_h_file(char *filename, const char *classname, Eina_Bool append)
|
|||
Eina_File *fn = eina_file_open(filename, EINA_FALSE);
|
||||
if (!fn)
|
||||
{
|
||||
printf ("Cant open file \"%s\" for updating.\n", filename);
|
||||
ERR ("Cant open file \"%s\" for updating.", filename);
|
||||
goto end;
|
||||
}
|
||||
|
||||
eina_strbuf_append(hfile, (char*)eina_file_map_all(fn, EINA_FILE_SEQUENTIAL));
|
||||
eina_file_close(fn);
|
||||
|
||||
legacy_header_append(classname, eo_version, hfile);
|
||||
if (!legacy_header_append(classname, eo_version, hfile))
|
||||
{
|
||||
ERR("Failed to generate header for %s", classname);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
eo1_header_generate(classname, hfile);
|
||||
if (!eo1_header_generate(classname, hfile))
|
||||
{
|
||||
ERR("Failed to generate header for %s", classname);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
const char *htext = eina_strbuf_string_get(hfile);
|
||||
|
||||
FILE* fd = fopen(filename, "w");
|
||||
if (!fd)
|
||||
{
|
||||
printf ("Couldn't open file %s for writing\n", filename);
|
||||
ERR ("Couldn't open file %s for writing", filename);
|
||||
goto end;
|
||||
}
|
||||
if (htext) fputs(htext, fd);
|
||||
|
@ -60,12 +68,16 @@ _generate_c_file(char *filename, const char *classname, Eina_Bool append)
|
|||
Eina_Bool ret = EINA_FALSE;
|
||||
|
||||
Eina_Strbuf *cfile = eina_strbuf_new();
|
||||
legacy_source_generate(classname, legacy_support, eo_version, cfile);
|
||||
if (!legacy_source_generate(classname, legacy_support, eo_version, cfile))
|
||||
{
|
||||
ERR("Failed to generate source for %s", classname);
|
||||
goto end;
|
||||
}
|
||||
|
||||
FILE* fd = fopen(filename, (append) ? "a" : "w");
|
||||
if (!fd)
|
||||
{
|
||||
printf ("Couldnt open file %s for writing\n", filename);
|
||||
ERR("Couldnt open file %s for writing", filename);
|
||||
goto end;
|
||||
}
|
||||
const char *ctext = eina_strbuf_string_get(cfile);
|
||||
|
@ -91,23 +103,31 @@ _generate_legacy_header_file(char *filename, const char *classname, Eina_Bool ap
|
|||
Eina_File *fn = eina_file_open(filename, EINA_FALSE);
|
||||
if (!fn)
|
||||
{
|
||||
printf ("Cant open file \"%s\" for updating.\n", filename);
|
||||
ERR ("Cant open file \"%s\" for updating.", filename);
|
||||
goto end;
|
||||
}
|
||||
eina_strbuf_append(lfile, (char*)eina_file_map_all(fn, EINA_FILE_SEQUENTIAL));
|
||||
eina_file_close(fn);
|
||||
|
||||
legacy_header_append(classname, eo_version, lfile);
|
||||
if (!legacy_header_append(classname, eo_version, lfile))
|
||||
{
|
||||
ERR("Failed to generate header for %s", classname);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
legacy_header_generate(classname, eo_version, lfile);
|
||||
if (!eo1_header_generate(classname, lfile))
|
||||
{
|
||||
ERR("Failed to generate header for %s", classname);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
FILE* fd = fopen(filename, "w");
|
||||
if (!fd)
|
||||
{
|
||||
printf ("Couldnt open file %s for writing\n", filename);
|
||||
ERR ("Couldnt open file %s for writing", filename);
|
||||
goto end;
|
||||
}
|
||||
const char *ltext = eina_strbuf_string_get(lfile);
|
||||
|
@ -127,16 +147,25 @@ _generate_eo_and_legacy_h_file(char *filename, const char *classname)
|
|||
|
||||
Eina_Strbuf *hfile = eina_strbuf_new();
|
||||
|
||||
FILE* fd = fopen(filename, "w");
|
||||
if (!fd)
|
||||
if (!eo1_header_generate(classname, hfile))
|
||||
{
|
||||
printf ("Couldnt open file %s for writing\n", filename);
|
||||
ERR("Failed to generate header for %s", classname);
|
||||
goto end;
|
||||
}
|
||||
if (!legacy_header_generate(classname, eo_version, hfile))
|
||||
{
|
||||
ERR("Failed to generate header for %s", classname);
|
||||
goto end;
|
||||
}
|
||||
|
||||
eo1_header_generate(classname, hfile);
|
||||
legacy_header_generate(classname, eo_version, hfile);
|
||||
const char *htext = eina_strbuf_string_get(hfile);
|
||||
FILE* fd = fopen(filename, "w");
|
||||
if (!fd)
|
||||
{
|
||||
ERR ("Couldnt open file %s for writing", filename);
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (htext) fputs(htext, fd);
|
||||
|
||||
fclose(fd);
|
||||
|
@ -260,7 +289,7 @@ int main(int argc, char **argv)
|
|||
|
||||
if (!files4gen)
|
||||
{
|
||||
printf("No input files specified.\nTerminating.\n");
|
||||
ERR("No input files specified.\nTerminating.\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -269,7 +298,7 @@ int main(int argc, char **argv)
|
|||
{
|
||||
if (!eolian_eo_file_parse(filename))
|
||||
{
|
||||
printf("Error during parsing file %s\n", filename);
|
||||
ERR("Error during parsing file %s\n", filename);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
@ -278,7 +307,7 @@ int main(int argc, char **argv)
|
|||
{
|
||||
if (!eolian_eo_file_parse(filename))
|
||||
{
|
||||
printf("Error during parsing file %s\n", filename);
|
||||
ERR("Error during parsing file %s\n", filename);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
@ -294,7 +323,7 @@ int main(int argc, char **argv)
|
|||
|
||||
if (!eo_version)
|
||||
{
|
||||
printf("No eo version specified (use --eo1 or --eo2). Aborting eo generation.\n");
|
||||
ERR("No eo version specified (use --eo1 or --eo2). Aborting eo generation.\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -314,36 +343,35 @@ int main(int argc, char **argv)
|
|||
case H_GEN: case H_EO_APP:
|
||||
{
|
||||
INF("%s header file %s\n", (gen_opt == H_EO_APP) ? "Appending" : "Generating", output_filename);
|
||||
_generate_h_file(output_filename, classname, gen_opt == H_EO_APP);
|
||||
ret = (_generate_h_file(output_filename, classname, gen_opt == H_EO_APP)?0:1);
|
||||
break;
|
||||
}
|
||||
case H_LEG_APP:
|
||||
{
|
||||
INF("Appending legacy file %s\n", output_filename);
|
||||
_generate_legacy_header_file(output_filename, classname, EINA_TRUE);
|
||||
ret = _generate_legacy_header_file(output_filename, classname, EINA_TRUE)?0:1;
|
||||
break;
|
||||
}
|
||||
case H_LEG_EO_GEN:
|
||||
{
|
||||
INF("Generating eo and legacy header file %s\n", output_filename);
|
||||
_generate_eo_and_legacy_h_file(output_filename, classname);
|
||||
ret = _generate_eo_and_legacy_h_file(output_filename, classname)?0:1;
|
||||
break;
|
||||
}
|
||||
case C_GEN:
|
||||
{
|
||||
INF("Generating source file %s\n", output_filename);
|
||||
_generate_c_file(output_filename, classname, EINA_FALSE);
|
||||
ret = _generate_c_file(output_filename, classname, EINA_FALSE)?0:1;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
free(output_filename);
|
||||
printf("Bad generation option\n");
|
||||
goto end;
|
||||
ERR("Bad generation option\n");
|
||||
break;
|
||||
}
|
||||
free(output_filename);
|
||||
}
|
||||
else ret = 0;
|
||||
|
||||
ret = 0;
|
||||
end:
|
||||
EINA_LIST_FREE(included_files, filename)
|
||||
free((char *)filename);
|
||||
|
|
Loading…
Reference in New Issue