summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2016-09-29 17:19:30 +0200
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2016-10-07 11:54:23 +0200
commit809e2ed4de22e68fe897465b38e7919b10b378c9 (patch)
treead1c0e12fdb99100e424e939daa072d86a868655
parent0306810d526137de063afa41d02a93717632c4ec (diff)
eolian gen2: abort on OOM (not much we can do anyway)
-rw-r--r--src/bin/eolian2/headers.c3
-rw-r--r--src/bin/eolian2/main.c15
-rw-r--r--src/bin/eolian2/main.h4
-rw-r--r--src/bin/eolian2/sources.c19
4 files changed, 18 insertions, 23 deletions
diff --git a/src/bin/eolian2/headers.c b/src/bin/eolian2/headers.c
index bd593c3d1b..048338cca6 100644
--- a/src/bin/eolian2/headers.c
+++ b/src/bin/eolian2/headers.c
@@ -199,8 +199,7 @@ eo_gen_header_gen(const Eolian_Class *cl, Eina_Strbuf *buf, Eina_Bool legacy)
199 return; 199 return;
200 200
201 char *cname = NULL, *cnameu = NULL, *cnamel = NULL; 201 char *cname = NULL, *cnameu = NULL, *cnamel = NULL;
202 if (!eo_gen_class_names_get(cl, &cname, &cnameu, &cnamel)) 202 eo_gen_class_names_get(cl, &cname, &cnameu, &cnamel);
203 return;
204 203
205 /* class definition */ 204 /* class definition */
206 205
diff --git a/src/bin/eolian2/main.c b/src/bin/eolian2/main.c
index b97e64d7fa..a1cda50c1b 100644
--- a/src/bin/eolian2/main.c
+++ b/src/bin/eolian2/main.c
@@ -1,3 +1,4 @@
1#include <stdlib.h>
1#include <unistd.h> 2#include <unistd.h>
2#include <libgen.h> 3#include <libgen.h>
3 4
@@ -227,19 +228,19 @@ char *eo_gen_c_full_name_get(const char *nm)
227 return NULL; 228 return NULL;
228 char *buf = strdup(nm); 229 char *buf = strdup(nm);
229 if (!buf) 230 if (!buf)
230 return NULL; 231 abort();
231 for (char *p = strchr(buf, '.'); p; p = strchr(p, '.')) 232 for (char *p = strchr(buf, '.'); p; p = strchr(p, '.'))
232 *p = '_'; 233 *p = '_';
233 return buf; 234 return buf;
234} 235}
235 236
236Eina_Bool eo_gen_class_names_get(const Eolian_Class *cl, char **cname, 237void eo_gen_class_names_get(const Eolian_Class *cl, char **cname,
237 char **cnameu, char **cnamel) 238 char **cnameu, char **cnamel)
238{ 239{
239 char *cn = NULL, *cnu = NULL, *cnl = NULL; 240 char *cn = NULL, *cnu = NULL, *cnl = NULL;
240 cn = eo_gen_c_full_name_get(eolian_class_full_name_get(cl)); 241 cn = eo_gen_c_full_name_get(eolian_class_full_name_get(cl));
241 if (!cn) 242 if (!cn)
242 return EINA_FALSE; 243 abort();
243 if (cname) 244 if (cname)
244 *cname = cn; 245 *cname = cn;
245 246
@@ -249,7 +250,7 @@ Eina_Bool eo_gen_class_names_get(const Eolian_Class *cl, char **cname,
249 if (!cnu) 250 if (!cnu)
250 { 251 {
251 free(cn); 252 free(cn);
252 return EINA_FALSE; 253 abort();
253 } 254 }
254 eina_str_toupper(&cnu); 255 eina_str_toupper(&cnu);
255 *cnameu = cnu; 256 *cnameu = cnu;
@@ -262,7 +263,7 @@ Eina_Bool eo_gen_class_names_get(const Eolian_Class *cl, char **cname,
262 { 263 {
263 free(cn); 264 free(cn);
264 free(cnu); 265 free(cnu);
265 return EINA_FALSE; 266 abort();
266 } 267 }
267 eina_str_tolower(&cnl); 268 eina_str_tolower(&cnl);
268 *cnamel = cnl; 269 *cnamel = cnl;
@@ -270,8 +271,6 @@ Eina_Bool eo_gen_class_names_get(const Eolian_Class *cl, char **cname,
270 271
271 if (!cname) 272 if (!cname)
272 free(cn); 273 free(cn);
273
274 return EINA_TRUE;
275} 274}
276 275
277static Eina_Bool 276static Eina_Bool
diff --git a/src/bin/eolian2/main.h b/src/bin/eolian2/main.h
index fc12597b4f..0dd0b793ff 100644
--- a/src/bin/eolian2/main.h
+++ b/src/bin/eolian2/main.h
@@ -36,7 +36,7 @@ extern int _eolian_gen_log_dom;
36#define CRIT(...) EINA_LOG_DOM_CRIT(_eolian_gen_log_dom, __VA_ARGS__) 36#define CRIT(...) EINA_LOG_DOM_CRIT(_eolian_gen_log_dom, __VA_ARGS__)
37 37
38char *eo_gen_c_full_name_get(const char *nm); 38char *eo_gen_c_full_name_get(const char *nm);
39Eina_Bool eo_gen_class_names_get(const Eolian_Class *cl, char **cname, 39void eo_gen_class_names_get(const Eolian_Class *cl, char **cname,
40 char **cnameu, char **cnamel); 40 char **cnameu, char **cnamel);
41 41
42#endif 42#endif
diff --git a/src/bin/eolian2/sources.c b/src/bin/eolian2/sources.c
index 5da860e3a5..91f095b50c 100644
--- a/src/bin/eolian2/sources.c
+++ b/src/bin/eolian2/sources.c
@@ -216,10 +216,8 @@ _gen_func(const Eolian_Class *cl, const Eolian_Function *fid,
216 : eina_stringshare_add("void"); 216 : eina_stringshare_add("void");
217 217
218 char *cname = NULL, *cnameu = NULL, *cnamel = NULL, *ocnamel = NULL; 218 char *cname = NULL, *cnameu = NULL, *cnamel = NULL, *ocnamel = NULL;
219 if (!eo_gen_class_names_get(cl, &cname, &cnameu, &cnamel)) 219 eo_gen_class_names_get(cl, &cname, &cnameu, &cnamel);
220 goto end; 220 eo_gen_class_names_get(eolian_implement_class_get(impl), NULL, NULL, &ocnamel);
221 if (!eo_gen_class_names_get(eolian_implement_class_get(impl), NULL, NULL, &ocnamel))
222 goto end;
223 221
224 if (impl_need) 222 if (impl_need)
225 { 223 {
@@ -446,7 +444,6 @@ _gen_func(const Eolian_Class *cl, const Eolian_Function *fid,
446 eina_stringshare_del(eofn); 444 eina_stringshare_del(eofn);
447 } 445 }
448 446
449end:
450 free(cname); 447 free(cname);
451 free(cnameu); 448 free(cnameu);
452 free(cnamel); 449 free(cnamel);
@@ -503,8 +500,7 @@ _gen_initializer(const Eolian_Class *cl, Eina_Strbuf *buf)
503 eina_iterator_free(itr); 500 eina_iterator_free(itr);
504 501
505 char *cnamel = NULL; 502 char *cnamel = NULL;
506 if (!eo_gen_class_names_get(cl, NULL, NULL, &cnamel)) 503 eo_gen_class_names_get(cl, NULL, NULL, &cnamel);
507 return EINA_FALSE;
508 504
509 eina_strbuf_append(buf, "\nstatic Eina_Bool\n_"); 505 eina_strbuf_append(buf, "\nstatic Eina_Bool\n_");
510 eina_strbuf_append(buf, cnamel); 506 eina_strbuf_append(buf, cnamel);
@@ -530,8 +526,8 @@ _gen_initializer(const Eolian_Class *cl, Eina_Strbuf *buf)
530 526
531 Eina_Bool found = !!eina_hash_find(_funcs_params_init, &imp); 527 Eina_Bool found = !!eina_hash_find(_funcs_params_init, &imp);
532 char *ocnamel = NULL; 528 char *ocnamel = NULL;
533 if ((cl != icl) && !eo_gen_class_names_get(cl, NULL, NULL, &ocnamel)) 529 if (cl != icl)
534 return EINA_FALSE; 530 eo_gen_class_names_get(cl, NULL, NULL, &ocnamel);
535 531
536 switch (ftype) 532 switch (ftype)
537 { 533 {
@@ -584,6 +580,8 @@ _gen_initializer(const Eolian_Class *cl, Eina_Strbuf *buf)
584 580
585 eina_strbuf_append(buf, "}\n\n"); 581 eina_strbuf_append(buf, "}\n\n");
586 582
583 free(cnamel);
584
587 return EINA_TRUE; 585 return EINA_TRUE;
588} 586}
589 587
@@ -596,8 +594,7 @@ eo_gen_source_gen(const Eolian_Class *cl, Eina_Strbuf *buf)
596 _funcs_params_init = eina_hash_pointer_new(NULL); 594 _funcs_params_init = eina_hash_pointer_new(NULL);
597 595
598 char *cname = NULL, *cnameu = NULL, *cnamel = NULL; 596 char *cname = NULL, *cnameu = NULL, *cnamel = NULL;
599 if (!eo_gen_class_names_get(cl, &cname, &cnameu, &cnamel)) 597 eo_gen_class_names_get(cl, &cname, &cnameu, &cnamel);
600 return;
601 598
602 /* event section, they come first */ 599 /* event section, they come first */
603 { 600 {