summaryrefslogtreecommitdiff
path: root/src/bin/eolian/eo1_generator.c
diff options
context:
space:
mode:
authorDaniel Zaoui <daniel.zaoui@samsung.com>2014-03-19 07:52:04 +0200
committerDaniel Zaoui <daniel.zaoui@samsung.com>2014-03-19 07:52:04 +0200
commitd5256d442db17ebcd11737a9804857068cc397c9 (patch)
treea07195386e83dcd9668ec6f6b788e37239f15d82 /src/bin/eolian/eo1_generator.c
parentde0c0f0fd862eca6b1e6ac98019ffaadfa6b7403 (diff)
Eolian/Generator: Don't generate sub ids structure if not needed.
If no methods and properties are declared for a class, no base id and sub_ids structure are generated. @fix
Diffstat (limited to '')
-rw-r--r--src/bin/eolian/eo1_generator.c55
1 files changed, 39 insertions, 16 deletions
diff --git a/src/bin/eolian/eo1_generator.c b/src/bin/eolian/eo1_generator.c
index 1610ec75ca..a2388b5ea0 100644
--- a/src/bin/eolian/eo1_generator.c
+++ b/src/bin/eolian/eo1_generator.c
@@ -6,15 +6,6 @@
6#include "common_funcs.h" 6#include "common_funcs.h"
7 7
8static const char 8static const char
9tmpl_eo_src_begin[] = "\
10\n\
11EAPI Eo_Op @#EOPREFIX_BASE_ID = EO_NOOP;\n\
12\n\
13@#list_events\n\
14\n\
15";
16
17static const char
18tmpl_dtor[] = "\ 9tmpl_dtor[] = "\
19static void\n\ 10static void\n\
20_gen_@#class_class_destructor(Eo_Class *klass)\n\ 11_gen_@#class_class_destructor(Eo_Class *klass)\n\
@@ -87,6 +78,14 @@ enum\n\
87"; 78";
88 79
89static const char 80static const char
81tmpl_eo_obj_header_no_ids[] = "\
82#define @#EOPREFIX_CLASS @#eoprefix_class_get()\n\
83\n\
84const Eo_Class *@#eoprefix_class_get(void) EINA_CONST;\n\
85\n\
86";
87
88static const char
90tmpl_eo_subid[] = "\n @#EOPREFIX_SUB_ID_@#FUNC,"; 89tmpl_eo_subid[] = "\n @#EOPREFIX_SUB_ID_@#FUNC,";
91 90
92static const char 91static const char
@@ -249,6 +248,7 @@ eo1_header_generate(const char *classname, Eina_Strbuf *buf)
249 const Eina_List *l; 248 const Eina_List *l;
250 void *data; 249 void *data;
251 char *tmpstr = malloc(0x1FF); 250 char *tmpstr = malloc(0x1FF);
251 Eina_Bool no_ids = EINA_TRUE;
252 252
253 if (!eolian_class_exists(classname)) 253 if (!eolian_class_exists(classname))
254 { 254 {
@@ -256,8 +256,19 @@ eo1_header_generate(const char *classname, Eina_Strbuf *buf)
256 return EINA_FALSE; 256 return EINA_FALSE;
257 } 257 }
258 258
259 if (eolian_class_functions_list_get(classname, CONSTRUCTOR) ||
260 eolian_class_functions_list_get(classname, DESTRUCTOR) ||
261 eolian_class_functions_list_get(classname, PROPERTY_FUNC) ||
262 eolian_class_functions_list_get(classname, METHOD_FUNC))
263 {
264 no_ids = EINA_FALSE;
265 }
266
259 Eina_Strbuf * str_hdr = eina_strbuf_new(); 267 Eina_Strbuf * str_hdr = eina_strbuf_new();
260 _template_fill(str_hdr, tmpl_eo_obj_header, classname, "", EINA_TRUE); 268 if (no_ids)
269 _template_fill(str_hdr, tmpl_eo_obj_header_no_ids, classname, "", EINA_TRUE);
270 else
271 _template_fill(str_hdr, tmpl_eo_obj_header, classname, "", EINA_TRUE);
261 272
262 eina_strbuf_replace_all(str_hdr, "@#EOPREFIX", current_eo_prefix_upper); 273 eina_strbuf_replace_all(str_hdr, "@#EOPREFIX", current_eo_prefix_upper);
263 eina_strbuf_replace_all(str_hdr, "@#eoprefix", current_eo_prefix_lower); 274 eina_strbuf_replace_all(str_hdr, "@#eoprefix", current_eo_prefix_lower);
@@ -510,11 +521,17 @@ eo1_source_beginning_generate(const char *classname, Eina_Strbuf *buf)
510 const Eina_List *itr; 521 const Eina_List *itr;
511 522
512 Eina_Strbuf *tmpbuf = eina_strbuf_new(); 523 Eina_Strbuf *tmpbuf = eina_strbuf_new();
513 Eina_Strbuf *str_begin = eina_strbuf_new();
514 Eina_Strbuf *str_ev = eina_strbuf_new(); 524 Eina_Strbuf *str_ev = eina_strbuf_new();
515 525
516 _template_fill(str_begin, tmpl_eo_src_begin, classname, "", EINA_TRUE); 526 if (eolian_class_functions_list_get(classname, CONSTRUCTOR) ||
517 eina_strbuf_replace_all(str_begin, "@#EOPREFIX", current_eo_prefix_upper); 527 eolian_class_functions_list_get(classname, DESTRUCTOR) ||
528 eolian_class_functions_list_get(classname, PROPERTY_FUNC) ||
529 eolian_class_functions_list_get(classname, METHOD_FUNC))
530 {
531 _template_fill(NULL, NULL, classname, NULL, EINA_TRUE);
532 eina_strbuf_append_printf(buf, "EAPI Eo_Op @#EOPREFIX_BASE_ID = EO_NOOP;\n");
533 eina_strbuf_replace_all(buf, "@#EOPREFIX", current_eo_prefix_upper);
534 }
518 535
519 Eolian_Event event; 536 Eolian_Event event;
520 EINA_LIST_FOREACH(eolian_class_events_list_get(classname), itr, event) 537 EINA_LIST_FOREACH(eolian_class_events_list_get(classname), itr, event)
@@ -534,12 +551,10 @@ eo1_source_beginning_generate(const char *classname, Eina_Strbuf *buf)
534 free(evdesc_line1); 551 free(evdesc_line1);
535 } 552 }
536 553
537 eina_strbuf_replace_all(str_begin, "@#list_events", eina_strbuf_string_get(tmpbuf)); 554 eina_strbuf_append(buf, eina_strbuf_string_get(tmpbuf));
538 eina_strbuf_append(buf, eina_strbuf_string_get(str_begin));
539 555
540 eina_strbuf_free(str_ev); 556 eina_strbuf_free(str_ev);
541 eina_strbuf_free(tmpbuf); 557 eina_strbuf_free(tmpbuf);
542 eina_strbuf_free(str_begin);
543 return EINA_TRUE; 558 return EINA_TRUE;
544} 559}
545 560
@@ -585,6 +600,14 @@ eo1_source_end_generate(const char *classname, Eina_Strbuf *buf)
585 600
586 _template_fill(str_end, tmpl_eo_src_end, classname, "", EINA_TRUE); 601 _template_fill(str_end, tmpl_eo_src_end, classname, "", EINA_TRUE);
587 602
603 if (!eolian_class_functions_list_get(classname, CONSTRUCTOR) &&
604 !eolian_class_functions_list_get(classname, DESTRUCTOR) &&
605 !eolian_class_functions_list_get(classname, PROPERTY_FUNC) &&
606 !eolian_class_functions_list_get(classname, METHOD_FUNC))
607 {
608 eina_strbuf_replace_all(str_end, "&@#EOPREFIX_BASE_ID", "NULL");
609 eina_strbuf_replace_all(str_end, "@#EOPREFIX_SUB_ID_LAST", "0");
610 }
588 eina_strbuf_replace_all(str_end, "@#type_class", str_classtype); 611 eina_strbuf_replace_all(str_end, "@#type_class", str_classtype);
589 eina_strbuf_replace_all(str_end, "@#EOPREFIX", current_eo_prefix_upper); 612 eina_strbuf_replace_all(str_end, "@#EOPREFIX", current_eo_prefix_upper);
590 eina_strbuf_replace_all(str_end, "@#eoprefix", current_eo_prefix_lower); 613 eina_strbuf_replace_all(str_end, "@#eoprefix", current_eo_prefix_lower);