summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorDaniel Zaoui <daniel.zaoui@samsung.com>2014-02-20 13:54:12 +0200
committerDaniel Zaoui <daniel.zaoui@samsung.com>2014-03-03 14:09:56 +0200
commit21533a0079f9d0ca169eb6cad465527ba9a961bd (patch)
tree7e834866e341e4ead7115d58252baa0d97f37995 /src/bin
parentbaaf92c93aa3f39642b6ff90213fbef26f937eda (diff)
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.
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/eolian/eo1_generator.c6
-rw-r--r--src/bin/eolian/legacy_generator.c18
-rw-r--r--src/bin/eolian/main.c80
3 files changed, 66 insertions, 38 deletions
diff --git a/src/bin/eolian/eo1_generator.c b/src/bin/eolian/eo1_generator.c
index c632bcac60..a02cfaede5 100644
--- a/src/bin/eolian/eo1_generator.c
+++ b/src/bin/eolian/eo1_generator.c
@@ -226,7 +226,7 @@ eo1_header_generate(const char *classname, Eina_Strbuf *buf)
226 226
227 if (!eolian_class_exists(classname)) 227 if (!eolian_class_exists(classname))
228 { 228 {
229 printf ("Class \"%s\" not found in database\n", classname); 229 ERR ("Class \"%s\" not found in database", classname);
230 return EINA_FALSE; 230 return EINA_FALSE;
231 } 231 }
232 232
@@ -508,7 +508,7 @@ eo1_source_end_generate(const char *classname, Eina_Strbuf *buf)
508 508
509 if (!str_classtype) 509 if (!str_classtype)
510 { 510 {
511 printf ("Unknown class type for class %s !\n", classname); 511 ERR ("Unknown class type for class %s !", classname);
512 return EINA_FALSE; 512 return EINA_FALSE;
513 } 513 }
514 514
@@ -590,7 +590,7 @@ eo1_source_end_generate(const char *classname, Eina_Strbuf *buf)
590 590
591 if (!in_meth && !in_prop) 591 if (!in_meth && !in_prop)
592 { 592 {
593 printf ("Failed to generate implementation of %s:%s - missing form super class\n", impl_class, funcname); 593 ERR ("Failed to generate implementation of %s:%s - missing form super class", impl_class, funcname);
594 return EINA_FALSE; 594 return EINA_FALSE;
595 } 595 }
596 596
diff --git a/src/bin/eolian/legacy_generator.c b/src/bin/eolian/legacy_generator.c
index ad9aa7e55b..fcc858122a 100644
--- a/src/bin/eolian/legacy_generator.c
+++ b/src/bin/eolian/legacy_generator.c
@@ -320,7 +320,7 @@ legacy_header_append(const char *classname, int eo_version, Eina_Strbuf *header)
320 { 320 {
321 printf ("Class %s not found - append all\n", classname); 321 printf ("Class %s not found - append all\n", classname);
322 eina_strbuf_append_char(header, '\n'); 322 eina_strbuf_append_char(header, '\n');
323 eo1_header_generate(classname, header); 323 if (!eo1_header_generate(classname, header)) return EINA_FALSE;
324 return EINA_TRUE; 324 return EINA_TRUE;
325 } 325 }
326 326
@@ -356,7 +356,7 @@ legacy_header_append(const char *classname, int eo_version, Eina_Strbuf *header)
356 { 356 {
357 printf ("Appending eo function %s\n", funcname); 357 printf ("Appending eo function %s\n", funcname);
358 eo1_enum_append(classname, funcname, str_subid); 358 eo1_enum_append(classname, funcname, str_subid);
359 eo1_fundef_generate(classname, (Eolian_Function)data, UNRESOLVED, str_funcdef); 359 if (!eo1_fundef_generate(classname, (Eolian_Function)data, UNRESOLVED, str_funcdef)) return EINA_FALSE;
360 } 360 }
361 } 361 }
362 if (prop_read) 362 if (prop_read)
@@ -366,7 +366,7 @@ legacy_header_append(const char *classname, int eo_version, Eina_Strbuf *header)
366 { 366 {
367 printf ("Appending eo function %s\n", tmpstr); 367 printf ("Appending eo function %s\n", tmpstr);
368 eo1_enum_append(classname, tmpstr, str_subid); 368 eo1_enum_append(classname, tmpstr, str_subid);
369 eo1_fundef_generate(classname, (Eolian_Function)data, GET, str_funcdef); 369 if (!eo1_fundef_generate(classname, (Eolian_Function)data, GET, str_funcdef)) return EINA_FALSE;
370 } 370 }
371 } 371 }
372 if (prop_write) 372 if (prop_write)
@@ -376,7 +376,7 @@ legacy_header_append(const char *classname, int eo_version, Eina_Strbuf *header)
376 { 376 {
377 printf ("Appending eo function %s\n", tmpstr); 377 printf ("Appending eo function %s\n", tmpstr);
378 eo1_enum_append(classname, tmpstr, str_subid); 378 eo1_enum_append(classname, tmpstr, str_subid);
379 eo1_fundef_generate(classname, (Eolian_Function)data, SET, str_funcdef); 379 if (!eo1_fundef_generate(classname, (Eolian_Function)data, SET, str_funcdef)) return EINA_FALSE;
380 } 380 }
381 } 381 }
382 } 382 }
@@ -407,7 +407,7 @@ legacy_source_generate(const char *classname, Eina_Bool legacy, int eo_version,
407 Eina_Strbuf *tmpbuf = eina_strbuf_new(); 407 Eina_Strbuf *tmpbuf = eina_strbuf_new();
408 Eina_Strbuf *str_bodyf = eina_strbuf_new(); 408 Eina_Strbuf *str_bodyf = eina_strbuf_new();
409 409
410 eo1_source_beginning_generate(classname, buf); 410 if (!eo1_source_beginning_generate(classname, buf)) return EINA_FALSE;
411 411
412 //Properties 412 //Properties
413 Eolian_Function fn; 413 Eolian_Function fn;
@@ -420,12 +420,12 @@ legacy_source_generate(const char *classname, Eina_Bool legacy, int eo_version,
420 420
421 if (prop_read) 421 if (prop_read)
422 { 422 {
423 eo1_bind_func_generate(classname, fn, GET, str_bodyf); 423 if (!eo1_bind_func_generate(classname, fn, GET, str_bodyf)) return EINA_FALSE;
424 if (legacy) _eapi_func_generate(classname, fn, GET, str_bodyf); 424 if (legacy) _eapi_func_generate(classname, fn, GET, str_bodyf);
425 } 425 }
426 if (prop_write) 426 if (prop_write)
427 { 427 {
428 eo1_bind_func_generate(classname, fn, SET, str_bodyf); 428 if (!eo1_bind_func_generate(classname, fn, SET, str_bodyf)) return EINA_FALSE;
429 if (legacy) _eapi_func_generate(classname, fn, SET, str_bodyf); 429 if (legacy) _eapi_func_generate(classname, fn, SET, str_bodyf);
430 } 430 }
431 } 431 }
@@ -433,13 +433,13 @@ legacy_source_generate(const char *classname, Eina_Bool legacy, int eo_version,
433 //Methods 433 //Methods
434 EINA_LIST_FOREACH(eolian_class_functions_list_get(classname, METHOD_FUNC), itr, fn) 434 EINA_LIST_FOREACH(eolian_class_functions_list_get(classname, METHOD_FUNC), itr, fn)
435 { 435 {
436 eo1_bind_func_generate(classname, fn, UNRESOLVED, str_bodyf); 436 if (!eo1_bind_func_generate(classname, fn, UNRESOLVED, str_bodyf)) return EINA_FALSE;
437 if (legacy) _eapi_func_generate(classname, fn, UNRESOLVED, str_bodyf); 437 if (legacy) _eapi_func_generate(classname, fn, UNRESOLVED, str_bodyf);
438 } 438 }
439 439
440 eina_strbuf_append(buf, eina_strbuf_string_get(str_bodyf)); 440 eina_strbuf_append(buf, eina_strbuf_string_get(str_bodyf));
441 441
442 eo1_source_end_generate(classname, buf); 442 if (!eo1_source_end_generate(classname, buf)) return EINA_FALSE;
443 443
444 eina_strbuf_free(tmpbuf); 444 eina_strbuf_free(tmpbuf);
445 eina_strbuf_free(str_bodyf); 445 eina_strbuf_free(str_bodyf);
diff --git a/src/bin/eolian/main.c b/src/bin/eolian/main.c
index 736d9924d2..754f6e8bb8 100644
--- a/src/bin/eolian/main.c
+++ b/src/bin/eolian/main.c
@@ -23,25 +23,33 @@ _generate_h_file(char *filename, const char *classname, Eina_Bool append)
23 Eina_File *fn = eina_file_open(filename, EINA_FALSE); 23 Eina_File *fn = eina_file_open(filename, EINA_FALSE);
24 if (!fn) 24 if (!fn)
25 { 25 {
26 printf ("Cant open file \"%s\" for updating.\n", filename); 26 ERR ("Cant open file \"%s\" for updating.", filename);
27 goto end; 27 goto end;
28 } 28 }
29 29
30 eina_strbuf_append(hfile, (char*)eina_file_map_all(fn, EINA_FILE_SEQUENTIAL)); 30 eina_strbuf_append(hfile, (char*)eina_file_map_all(fn, EINA_FILE_SEQUENTIAL));
31 eina_file_close(fn); 31 eina_file_close(fn);
32 32
33 legacy_header_append(classname, eo_version, hfile); 33 if (!legacy_header_append(classname, eo_version, hfile))
34 {
35 ERR("Failed to generate header for %s", classname);
36 goto end;
37 }
34 } 38 }
35 else 39 else
36 { 40 {
37 eo1_header_generate(classname, hfile); 41 if (!eo1_header_generate(classname, hfile))
42 {
43 ERR("Failed to generate header for %s", classname);
44 goto end;
45 }
38 } 46 }
39 const char *htext = eina_strbuf_string_get(hfile); 47 const char *htext = eina_strbuf_string_get(hfile);
40 48
41 FILE* fd = fopen(filename, "w"); 49 FILE* fd = fopen(filename, "w");
42 if (!fd) 50 if (!fd)
43 { 51 {
44 printf ("Couldn't open file %s for writing\n", filename); 52 ERR ("Couldn't open file %s for writing", filename);
45 goto end; 53 goto end;
46 } 54 }
47 if (htext) fputs(htext, fd); 55 if (htext) fputs(htext, fd);
@@ -60,12 +68,16 @@ _generate_c_file(char *filename, const char *classname, Eina_Bool append)
60 Eina_Bool ret = EINA_FALSE; 68 Eina_Bool ret = EINA_FALSE;
61 69
62 Eina_Strbuf *cfile = eina_strbuf_new(); 70 Eina_Strbuf *cfile = eina_strbuf_new();
63 legacy_source_generate(classname, legacy_support, eo_version, cfile); 71 if (!legacy_source_generate(classname, legacy_support, eo_version, cfile))
72 {
73 ERR("Failed to generate source for %s", classname);
74 goto end;
75 }
64 76
65 FILE* fd = fopen(filename, (append) ? "a" : "w"); 77 FILE* fd = fopen(filename, (append) ? "a" : "w");
66 if (!fd) 78 if (!fd)
67 { 79 {
68 printf ("Couldnt open file %s for writing\n", filename); 80 ERR("Couldnt open file %s for writing", filename);
69 goto end; 81 goto end;
70 } 82 }
71 const char *ctext = eina_strbuf_string_get(cfile); 83 const char *ctext = eina_strbuf_string_get(cfile);
@@ -91,23 +103,31 @@ _generate_legacy_header_file(char *filename, const char *classname, Eina_Bool ap
91 Eina_File *fn = eina_file_open(filename, EINA_FALSE); 103 Eina_File *fn = eina_file_open(filename, EINA_FALSE);
92 if (!fn) 104 if (!fn)
93 { 105 {
94 printf ("Cant open file \"%s\" for updating.\n", filename); 106 ERR ("Cant open file \"%s\" for updating.", filename);
95 goto end; 107 goto end;
96 } 108 }
97 eina_strbuf_append(lfile, (char*)eina_file_map_all(fn, EINA_FILE_SEQUENTIAL)); 109 eina_strbuf_append(lfile, (char*)eina_file_map_all(fn, EINA_FILE_SEQUENTIAL));
98 eina_file_close(fn); 110 eina_file_close(fn);
99 111
100 legacy_header_append(classname, eo_version, lfile); 112 if (!legacy_header_append(classname, eo_version, lfile))
113 {
114 ERR("Failed to generate header for %s", classname);
115 goto end;
116 }
101 } 117 }
102 else 118 else
103 { 119 {
104 legacy_header_generate(classname, eo_version, lfile); 120 if (!eo1_header_generate(classname, lfile))
121 {
122 ERR("Failed to generate header for %s", classname);
123 goto end;
124 }
105 } 125 }
106 126
107 FILE* fd = fopen(filename, "w"); 127 FILE* fd = fopen(filename, "w");
108 if (!fd) 128 if (!fd)
109 { 129 {
110 printf ("Couldnt open file %s for writing\n", filename); 130 ERR ("Couldnt open file %s for writing", filename);
111 goto end; 131 goto end;
112 } 132 }
113 const char *ltext = eina_strbuf_string_get(lfile); 133 const char *ltext = eina_strbuf_string_get(lfile);
@@ -127,16 +147,25 @@ _generate_eo_and_legacy_h_file(char *filename, const char *classname)
127 147
128 Eina_Strbuf *hfile = eina_strbuf_new(); 148 Eina_Strbuf *hfile = eina_strbuf_new();
129 149
150 if (!eo1_header_generate(classname, hfile))
151 {
152 ERR("Failed to generate header for %s", classname);
153 goto end;
154 }
155 if (!legacy_header_generate(classname, eo_version, hfile))
156 {
157 ERR("Failed to generate header for %s", classname);
158 goto end;
159 }
160
161 const char *htext = eina_strbuf_string_get(hfile);
130 FILE* fd = fopen(filename, "w"); 162 FILE* fd = fopen(filename, "w");
131 if (!fd) 163 if (!fd)
132 { 164 {
133 printf ("Couldnt open file %s for writing\n", filename); 165 ERR ("Couldnt open file %s for writing", filename);
134 goto end; 166 goto end;
135 } 167 }
136 168
137 eo1_header_generate(classname, hfile);
138 legacy_header_generate(classname, eo_version, hfile);
139 const char *htext = eina_strbuf_string_get(hfile);
140 if (htext) fputs(htext, fd); 169 if (htext) fputs(htext, fd);
141 170
142 fclose(fd); 171 fclose(fd);
@@ -260,7 +289,7 @@ int main(int argc, char **argv)
260 289
261 if (!files4gen) 290 if (!files4gen)
262 { 291 {
263 printf("No input files specified.\nTerminating.\n"); 292 ERR("No input files specified.\nTerminating.\n");
264 goto end; 293 goto end;
265 } 294 }
266 295
@@ -269,7 +298,7 @@ int main(int argc, char **argv)
269 { 298 {
270 if (!eolian_eo_file_parse(filename)) 299 if (!eolian_eo_file_parse(filename))
271 { 300 {
272 printf("Error during parsing file %s\n", filename); 301 ERR("Error during parsing file %s\n", filename);
273 goto end; 302 goto end;
274 } 303 }
275 } 304 }
@@ -278,7 +307,7 @@ int main(int argc, char **argv)
278 { 307 {
279 if (!eolian_eo_file_parse(filename)) 308 if (!eolian_eo_file_parse(filename))
280 { 309 {
281 printf("Error during parsing file %s\n", filename); 310 ERR("Error during parsing file %s\n", filename);
282 goto end; 311 goto end;
283 } 312 }
284 } 313 }
@@ -294,7 +323,7 @@ int main(int argc, char **argv)
294 323
295 if (!eo_version) 324 if (!eo_version)
296 { 325 {
297 printf("No eo version specified (use --eo1 or --eo2). Aborting eo generation.\n"); 326 ERR("No eo version specified (use --eo1 or --eo2). Aborting eo generation.\n");
298 goto end; 327 goto end;
299 } 328 }
300 329
@@ -314,36 +343,35 @@ int main(int argc, char **argv)
314 case H_GEN: case H_EO_APP: 343 case H_GEN: case H_EO_APP:
315 { 344 {
316 INF("%s header file %s\n", (gen_opt == H_EO_APP) ? "Appending" : "Generating", output_filename); 345 INF("%s header file %s\n", (gen_opt == H_EO_APP) ? "Appending" : "Generating", output_filename);
317 _generate_h_file(output_filename, classname, gen_opt == H_EO_APP); 346 ret = (_generate_h_file(output_filename, classname, gen_opt == H_EO_APP)?0:1);
318 break; 347 break;
319 } 348 }
320 case H_LEG_APP: 349 case H_LEG_APP:
321 { 350 {
322 INF("Appending legacy file %s\n", output_filename); 351 INF("Appending legacy file %s\n", output_filename);
323 _generate_legacy_header_file(output_filename, classname, EINA_TRUE); 352 ret = _generate_legacy_header_file(output_filename, classname, EINA_TRUE)?0:1;
324 break; 353 break;
325 } 354 }
326 case H_LEG_EO_GEN: 355 case H_LEG_EO_GEN:
327 { 356 {
328 INF("Generating eo and legacy header file %s\n", output_filename); 357 INF("Generating eo and legacy header file %s\n", output_filename);
329 _generate_eo_and_legacy_h_file(output_filename, classname); 358 ret = _generate_eo_and_legacy_h_file(output_filename, classname)?0:1;
330 break; 359 break;
331 } 360 }
332 case C_GEN: 361 case C_GEN:
333 { 362 {
334 INF("Generating source file %s\n", output_filename); 363 INF("Generating source file %s\n", output_filename);
335 _generate_c_file(output_filename, classname, EINA_FALSE); 364 ret = _generate_c_file(output_filename, classname, EINA_FALSE)?0:1;
336 break; 365 break;
337 } 366 }
338 default: 367 default:
339 free(output_filename); 368 ERR("Bad generation option\n");
340 printf("Bad generation option\n"); 369 break;
341 goto end;
342 } 370 }
343 free(output_filename); 371 free(output_filename);
344 } 372 }
373 else ret = 0;
345 374
346 ret = 0;
347end: 375end:
348 EINA_LIST_FREE(included_files, filename) 376 EINA_LIST_FREE(included_files, filename)
349 free((char *)filename); 377 free((char *)filename);