summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2016-09-29 16:20:51 +0200
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2016-10-07 11:54:23 +0200
commit911a0847bec24ca1d1120970cf5f720536f19504 (patch)
treeb92683fee35138bd4bee4380a109ad2cdadcc88b
parent8a39a96bc5f7b2ba9bb37bbf5244872ce64a357a (diff)
eolian gen2: fully generate source
-rw-r--r--src/bin/eolian2/sources.c90
1 files changed, 89 insertions, 1 deletions
diff --git a/src/bin/eolian2/sources.c b/src/bin/eolian2/sources.c
index 6b836e2998..b5c8b17bb2 100644
--- a/src/bin/eolian2/sources.c
+++ b/src/bin/eolian2/sources.c
@@ -1,6 +1,23 @@
1#include "main.h" 1#include "main.h"
2#include "docs.h" 2#include "docs.h"
3 3
4static const char *
5_cl_type_str_get(const Eolian_Class *cl)
6{
7 switch (eolian_class_type_get(cl))
8 {
9 case EOLIAN_CLASS_REGULAR:
10 case EOLIAN_CLASS_ABSTRACT:
11 return "CLASS";
12 case EOLIAN_CLASS_MIXIN:
13 return "MIXIN";
14 case EOLIAN_CLASS_INTERFACE:
15 return "INTERFACE";
16 default:
17 return NULL;
18 }
19}
20
4/* Used to store the function names that will have to be appended 21/* Used to store the function names that will have to be appended
5 * with __eolian during C generation. Needed when params have to 22 * with __eolian during C generation. Needed when params have to
6 * be initialized and for future features. 23 * be initialized and for future features.
@@ -520,7 +537,7 @@ _gen_initializer(const Eolian_Class *cl, Eina_Strbuf *buf)
520 eina_strbuf_free(ops); 537 eina_strbuf_free(ops);
521 eina_strbuf_free(cops); 538 eina_strbuf_free(cops);
522 539
523 eina_strbuf_append(buf, "}\n"); 540 eina_strbuf_append(buf, "}\n\n");
524 541
525 return EINA_TRUE; 542 return EINA_TRUE;
526} 543}
@@ -533,6 +550,10 @@ eo_gen_source_gen(const Eolian_Class *cl, Eina_Strbuf *buf)
533 550
534 _funcs_params_init = eina_hash_pointer_new(NULL); 551 _funcs_params_init = eina_hash_pointer_new(NULL);
535 552
553 char *cname = NULL, *cnameu = NULL, *cnamel = NULL;
554 if (!eo_gen_class_names_get(cl, &cname, &cnameu, &cnamel))
555 return;
556
536 /* event section, they come first */ 557 /* event section, they come first */
537 { 558 {
538 Eina_Iterator *itr = eolian_class_events_get(cl); 559 Eina_Iterator *itr = eolian_class_events_get(cl);
@@ -578,7 +599,74 @@ eo_gen_source_gen(const Eolian_Class *cl, Eina_Strbuf *buf)
578 eina_iterator_free(itr); 599 eina_iterator_free(itr);
579 } 600 }
580 601
602 /* class initializer - contains method defs */
581 Eina_Bool has_init = _gen_initializer(cl, buf); 603 Eina_Bool has_init = _gen_initializer(cl, buf);
582 604
605 /* class description */
606 eina_strbuf_append(buf, "static const Efl_Class_Description _");
607 eina_strbuf_append(buf, cnamel);
608 eina_strbuf_append(buf, "_class_desc = {\n"
609 " EO_VERSION,\n");
610 eina_strbuf_append_printf(buf, " \"%s\",\n", cname);
611
612 const char *dt = eolian_class_data_type_get(cl);
613 if (dt && !strcmp(dt, "null"))
614 eina_strbuf_append(buf, " 0,\n");
615 else
616 {
617 eina_strbuf_append(buf, " sizeof(");
618 if (dt)
619 eina_strbuf_append(buf, dt);
620 else
621 eina_strbuf_append_printf(buf, "%s_Data", cname);
622 eina_strbuf_append(buf, "),\n");
623 }
624
625 if (has_init)
626 eina_strbuf_append_printf(buf, " _%s_class_initializer,\n", cnamel);
627 else
628 eina_strbuf_append(buf, " NULL,\n");
629
630 if (eolian_class_ctor_enable_get(cl))
631 eina_strbuf_append_printf(buf, " _%s_class_constructor,\n", cnamel);
632 else
633 eina_strbuf_append(buf, " NULL,\n");
634
635 if (eolian_class_dtor_enable_get(cl))
636 eina_strbuf_append_printf(buf, " _%s_class_destructor\n", cnamel);
637 else
638 eina_strbuf_append(buf, " NULL\n");
639
640 eina_strbuf_append(buf, "}\n\n");
641
642 /* class def */
643 eina_strbuf_append(buf, "EFL_DEFINE_CLASS(");
644
645 Eina_Stringshare *cgfunc = eolian_class_c_get_function_name_get(cl);
646 eina_strbuf_append(buf, cgfunc);
647 eina_stringshare_del(cgfunc);
648
649 eina_strbuf_append_printf(buf, ", &_%s_class_desc", cnamel);
650
651 /* inherits in EFL_DEFINE_CLASS */
652 {
653 Eina_Iterator *itr = eolian_class_inherits_get(cl);
654 const char *iname;
655 EINA_ITERATOR_FOREACH(itr, iname)
656 {
657 eina_strbuf_append(buf, ", ");
658 eina_strbuf_append_printf(buf, "%s_%s", cnameu,
659 _cl_type_str_get(eolian_class_get_by_name(iname)));
660 }
661 eina_iterator_free(itr);
662 }
663
664 /* terminate inherits */
665 eina_strbuf_append(buf, ", NULL);\n");
666
667 /* and we're done */
668 free(cname);
669 free(cnameu);
670 free(cnamel);
583 eina_hash_free(_funcs_params_init); 671 eina_hash_free(_funcs_params_init);
584} 672}