summaryrefslogtreecommitdiff
path: root/src/bin/eolian/eo1_generator.c
diff options
context:
space:
mode:
authorDaniel Zaoui <daniel.zaoui@samsung.com>2014-03-23 07:28:04 +0200
committerDaniel Zaoui <daniel.zaoui@samsung.com>2014-03-24 08:14:30 +0200
commit4092dc6277b3c8b79034d4e80ec35631450d5f3d (patch)
tree2be3c5cbc4508a994f7dee6d6b5e69cc5c95fc32 /src/bin/eolian/eo1_generator.c
parent0987b31247b99fcd78eaaddd60072279a9dc9be4 (diff)
Eolian/Generator: more stuff.
Better support of empty events/funcs lists Better support of class constructor Preparation for Eo2: separate Eo1 specific code and common code
Diffstat (limited to '')
-rw-r--r--src/bin/eolian/eo1_generator.c161
1 files changed, 99 insertions, 62 deletions
diff --git a/src/bin/eolian/eo1_generator.c b/src/bin/eolian/eo1_generator.c
index b6f61ef63f..d294504038 100644
--- a/src/bin/eolian/eo1_generator.c
+++ b/src/bin/eolian/eo1_generator.c
@@ -16,9 +16,7 @@ _gen_@#class_class_destructor(Eo_Class *klass)\n\
16"; 16";
17 17
18static const char 18static const char
19tmpl_eo_src_end[] = "\ 19tmpl_eo1_class_ctor[] = "\
20@#list_ctors_body\
21\n\
22static void\n\ 20static void\n\
23_gen_@#class_class_constructor(Eo_Class *klass)\n\ 21_gen_@#class_class_constructor(Eo_Class *klass)\n\
24{\n\ 22{\n\
@@ -26,24 +24,35 @@ _gen_@#class_class_constructor(Eo_Class *klass)\n\
26 EO_OP_FUNC_SENTINEL\n\ 24 EO_OP_FUNC_SENTINEL\n\
27 };\n\ 25 };\n\
28 eo_class_funcs_set(klass, func_desc);\n\ 26 eo_class_funcs_set(klass, func_desc);\n\
29@#ctor_func\ 27@#user_ctor_func\
30}\n\ 28}\n\n";
31\n\ 29
32@#dtor_func\ 30static const char
31tmpl_eo1_ops_desc[] = "\
33static const Eo_Op_Description _@#class_op_desc[] = {@#list_op\n\ 32static const Eo_Op_Description _@#class_op_desc[] = {@#list_op\n\
34 EO_OP_DESCRIPTION_SENTINEL\n\ 33 EO_OP_DESCRIPTION_SENTINEL\n\
35};\n\ 34};\n\n";
36\n\ 35
36static const char
37tmpl_events_desc[] = "\
37static const Eo_Event_Description *_@#class_event_desc[] = {@#list_evdesc\n\ 38static const Eo_Event_Description *_@#class_event_desc[] = {@#list_evdesc\n\
38 NULL\n\ 39 NULL\n\
39};\n\ 40};\n\n";
41
42static const char
43tmpl_eo_src[] = "\
44@#functions_body\
40\n\ 45\n\
46@#ctor_func\
47@#dtor_func\
48@#ops_desc\
49@#events_desc\
41static const Eo_Class_Description _@#class_class_desc = {\n\ 50static const Eo_Class_Description _@#class_class_desc = {\n\
42 EO_VERSION,\n\ 51 EO_VERSION,\n\
43 \"@#Class\",\n\ 52 \"@#Class\",\n\
44 @#type_class,\n\ 53 @#type_class,\n\
45 EO_CLASS_DESCRIPTION_OPS(&@#EOPREFIX_BASE_ID, _@#class_op_desc, @#EOPREFIX_SUB_ID_LAST),\n\ 54 @#eo_class_desc_ops,\n\
46 _@#class_event_desc,\n\ 55 @#Events_Desc,\n\
47 @#SizeOfData,\n\ 56 @#SizeOfData,\n\
48 _gen_@#class_class_constructor,\n\ 57 _gen_@#class_class_constructor,\n\
49 @#dtor_name\n\ 58 @#dtor_name\n\
@@ -120,14 +129,7 @@ _eo_obj_@#class_@#func(Eo *obj, void *_pd, va_list *list@#list_unused)\n\
120}\n\ 129}\n\
121"; 130";
122 131
123Eina_Bool 132static Eina_Bool
124eo1_enum_append(const char *classname, const char *funcname, Eina_Strbuf *str)
125{
126 _template_fill(str, tmpl_eo_subid_apnd, classname, funcname, EINA_FALSE);
127 return EINA_TRUE;
128}
129
130Eina_Bool
131eo1_fundef_generate(const char *classname, Eolian_Function func, Eolian_Function_Type ftype, Eina_Strbuf *functext) 133eo1_fundef_generate(const char *classname, Eolian_Function func, Eolian_Function_Type ftype, Eina_Strbuf *functext)
132{ 134{
133 const char *str_dir[] = {"in", "out", "inout"}; 135 const char *str_dir[] = {"in", "out", "inout"};
@@ -357,7 +359,7 @@ _varg_upgr(const char *stype)
357 return stype; 359 return stype;
358} 360}
359 361
360Eina_Bool 362static Eina_Bool
361eo1_bind_func_generate(const char *classname, Eolian_Function funcid, Eolian_Function_Type ftype, Eina_Strbuf *buf, const char *impl_name) 363eo1_bind_func_generate(const char *classname, Eolian_Function funcid, Eolian_Function_Type ftype, Eina_Strbuf *buf, const char *impl_name)
362{ 364{
363 const char *suffix = ""; 365 const char *suffix = "";
@@ -499,24 +501,34 @@ eo1_bind_func_generate(const char *classname, Eolian_Function funcid, Eolian_Fun
499 return EINA_TRUE; 501 return EINA_TRUE;
500} 502}
501 503
502Eina_Bool 504static Eina_Bool
503eo1_eo_func_desc_generate(const char *classname, const char *funcname, Eina_Strbuf *buf) 505eo1_eo_func_desc_generate(const char *class_name, const char *impl_name, const char *func_name, Eina_Strbuf *buf)
504{ 506{
505 _template_fill(buf, tmpl_eo_func_desc, classname, funcname, EINA_TRUE); 507 if (impl_name)
506 eina_strbuf_replace_all(buf, "@#EOPREFIX", current_eo_prefix_upper); 508 _class_func_names_fill(impl_name, func_name);
509 else
510 _class_func_names_fill(class_name, func_name);
511 eina_strbuf_reset(buf);
512 eina_strbuf_append_printf(buf,
513 "\n EO_OP_FUNC(%s_ID(%s_SUB_ID_%s), _eo_obj_%s%s%s_%s),",
514 current_eo_prefix_upper, current_eo_prefix_upper, capfunc,
515 lowclass, impl_name?"_":"", impl_name?impl_name:"",
516 func_name);
507 return EINA_TRUE; 517 return EINA_TRUE;
508} 518}
509 519
510Eina_Bool 520static Eina_Bool
511eo1_eo_op_desc_generate(const char *classname, const char *funcname, Eina_Strbuf *buf) 521eo1_eo_op_desc_generate(const char *classname, const char *funcname,
522 const char *desc, Eina_Strbuf *buf)
512{ 523{
513 _template_fill(buf, tmpl_eo_op_desc, classname, funcname, EINA_TRUE); 524 _template_fill(buf, tmpl_eo_op_desc, classname, funcname, EINA_TRUE);
514 eina_strbuf_replace_all(buf, "@#EOPREFIX", current_eo_prefix_upper); 525 eina_strbuf_replace_all(buf, "@#EOPREFIX", current_eo_prefix_upper);
526 eina_strbuf_replace_all(buf, "@#desc", desc);
515 527
516 return EINA_TRUE; 528 return EINA_TRUE;
517} 529}
518 530
519Eina_Bool 531static Eina_Bool
520eo1_source_beginning_generate(const char *classname, Eina_Strbuf *buf) 532eo1_source_beginning_generate(const char *classname, Eina_Strbuf *buf)
521{ 533{
522 const Eina_List *itr; 534 const Eina_List *itr;
@@ -559,7 +571,7 @@ eo1_source_beginning_generate(const char *classname, Eina_Strbuf *buf)
559 return EINA_TRUE; 571 return EINA_TRUE;
560} 572}
561 573
562Eina_Bool 574static Eina_Bool
563eo1_source_end_generate(const char *classname, Eina_Strbuf *buf) 575eo1_source_end_generate(const char *classname, Eina_Strbuf *buf)
564{ 576{
565 Eina_Bool ret = EINA_FALSE; 577 Eina_Bool ret = EINA_FALSE;
@@ -599,20 +611,19 @@ eo1_source_end_generate(const char *classname, Eina_Strbuf *buf)
599 Eina_Strbuf *str_ev = eina_strbuf_new(); 611 Eina_Strbuf *str_ev = eina_strbuf_new();
600 Eina_Strbuf *tmpl_impl = eina_strbuf_new(); 612 Eina_Strbuf *tmpl_impl = eina_strbuf_new();
601 613
602 _template_fill(str_end, tmpl_eo_src_end, classname, "", EINA_TRUE); 614 _template_fill(str_end, tmpl_eo_src, classname, NULL, EINA_TRUE);
603 615
604 if (!eolian_class_functions_list_get(classname, CONSTRUCTOR) &&
605 !eolian_class_functions_list_get(classname, DESTRUCTOR) &&
606 !eolian_class_functions_list_get(classname, PROPERTY_FUNC) &&
607 !eolian_class_functions_list_get(classname, METHOD_FUNC))
608 {
609 eina_strbuf_replace_all(str_end, "&@#EOPREFIX_BASE_ID", "NULL");
610 eina_strbuf_replace_all(str_end, "@#EOPREFIX_SUB_ID_LAST", "0");
611 }
612 eina_strbuf_replace_all(str_end, "@#type_class", str_classtype); 616 eina_strbuf_replace_all(str_end, "@#type_class", str_classtype);
613 eina_strbuf_replace_all(str_end, "@#EOPREFIX", current_eo_prefix_upper); 617 eina_strbuf_replace_all(str_end, "@#EOPREFIX", current_eo_prefix_upper);
614 eina_strbuf_replace_all(str_end, "@#eoprefix", current_eo_prefix_lower); 618 eina_strbuf_replace_all(str_end, "@#eoprefix", current_eo_prefix_lower);
615 619
620 _template_fill(tmpbuf, tmpl_eo1_class_ctor, classname, "", EINA_TRUE);
621 eina_strbuf_replace_all(str_end, "@#ctor_func", eina_strbuf_string_get(tmpbuf));
622 eina_strbuf_reset(tmpbuf);
623 if (eolian_class_ctor_enable_get(classname))
624 _template_fill(tmpbuf, " _@#class_class_constructor(klass);\n", classname, "", EINA_TRUE);
625 eina_strbuf_replace_all(str_end, "@#user_ctor_func", eina_strbuf_string_get(tmpbuf));
626
616 if (eolian_class_dtor_enable_get(classname)) 627 if (eolian_class_dtor_enable_get(classname))
617 { 628 {
618 _template_fill(tmpbuf, tmpl_dtor, classname, "", EINA_TRUE); 629 _template_fill(tmpbuf, tmpl_dtor, classname, "", EINA_TRUE);
@@ -627,9 +638,6 @@ eo1_source_end_generate(const char *classname, Eina_Strbuf *buf)
627 } 638 }
628 639
629 eina_strbuf_reset(tmpbuf); 640 eina_strbuf_reset(tmpbuf);
630 if (eolian_class_ctor_enable_get(classname))
631 _template_fill(tmpbuf, " _@#class_class_constructor(klass);\n", classname, "", EINA_TRUE);
632 eina_strbuf_replace_all(str_end, "@#ctor_func", eina_strbuf_string_get(tmpbuf));
633 641
634 // default constructor 642 // default constructor
635 Eolian_Function ctor_fn = eolian_class_default_constructor_get(classname); 643 Eolian_Function ctor_fn = eolian_class_default_constructor_get(classname);
@@ -722,17 +730,13 @@ eo1_source_end_generate(const char *classname, Eina_Strbuf *buf)
722 { 730 {
723 const char *funcname = eolian_function_name_get(fn); 731 const char *funcname = eolian_function_name_get(fn);
724 char *desc = _source_desc_get(eolian_function_description_get(fn, "comment")); 732 char *desc = _source_desc_get(eolian_function_description_get(fn, "comment"));
725 733 eo1_eo_op_desc_generate(classname, funcname, desc, tmpbuf);
726 _template_fill(tmpbuf, tmpl_eo_op_desc, classname, funcname, EINA_TRUE); 734 eina_strbuf_append(str_op, eina_strbuf_string_get(tmpbuf));
727 eina_strbuf_replace_all(tmpbuf, "@#EOPREFIX", current_eo_prefix_upper);
728
729 eina_strbuf_replace_all(tmpbuf, "@#desc", desc);
730 free(desc); 735 free(desc);
731 736
732 eina_strbuf_append(str_op, eina_strbuf_string_get(tmpbuf)); 737 eo1_eo_func_desc_generate(classname, NULL, funcname, tmpbuf);
738 eina_strbuf_append(str_func, eina_strbuf_string_get(tmpbuf));
733 739
734 _template_fill(str_func, tmpl_eo_func_desc, classname, funcname, EINA_FALSE);
735 eina_strbuf_replace_all(str_func, "@#EOPREFIX", current_eo_prefix_upper);
736 eo1_bind_func_generate(classname, fn, UNRESOLVED, str_bodyf, NULL); 740 eo1_bind_func_generate(classname, fn, UNRESOLVED, str_bodyf, NULL);
737 } 741 }
738 742
@@ -751,13 +755,12 @@ eo1_source_end_generate(const char *classname, Eina_Strbuf *buf)
751 char *desc = _source_desc_get(eolian_function_description_get(fn, "comment_set")); 755 char *desc = _source_desc_get(eolian_function_description_get(fn, "comment_set"));
752 756
753 sprintf(tmpstr, "%s_set", funcname); 757 sprintf(tmpstr, "%s_set", funcname);
754 eo1_eo_op_desc_generate(classname, tmpstr, tmpbuf); 758 eo1_eo_op_desc_generate(classname, tmpstr, desc, tmpbuf);
755 eina_strbuf_replace_all(tmpbuf, "@#desc", desc);
756 eina_strbuf_append(str_op, eina_strbuf_string_get(tmpbuf)); 759 eina_strbuf_append(str_op, eina_strbuf_string_get(tmpbuf));
757 free(desc); 760 free(desc);
758 761
759 if (!eolian_function_is_virtual_pure(fn)) 762 if (!eolian_function_is_virtual_pure(fn))
760 eo1_eo_func_desc_generate(classname, tmpstr, tmpbuf); 763 eo1_eo_func_desc_generate(classname, NULL, tmpstr, tmpbuf);
761 else 764 else
762 eina_strbuf_reset(tmpbuf); 765 eina_strbuf_reset(tmpbuf);
763 eina_strbuf_append(str_func, eina_strbuf_string_get(tmpbuf)); 766 eina_strbuf_append(str_func, eina_strbuf_string_get(tmpbuf));
@@ -767,13 +770,12 @@ eo1_source_end_generate(const char *classname, Eina_Strbuf *buf)
767 char *desc = _source_desc_get(eolian_function_description_get(fn, "comment_get")); 770 char *desc = _source_desc_get(eolian_function_description_get(fn, "comment_get"));
768 771
769 sprintf(tmpstr, "%s_get", funcname); 772 sprintf(tmpstr, "%s_get", funcname);
770 eo1_eo_op_desc_generate(classname, tmpstr, tmpbuf); 773 eo1_eo_op_desc_generate(classname, tmpstr, desc, tmpbuf);
771 eina_strbuf_replace_all(tmpbuf, "@#desc", desc);
772 free(desc); 774 free(desc);
773 eina_strbuf_append(str_op, eina_strbuf_string_get(tmpbuf)); 775 eina_strbuf_append(str_op, eina_strbuf_string_get(tmpbuf));
774 776
775 if (!eolian_function_is_virtual_pure(fn)) 777 if (!eolian_function_is_virtual_pure(fn))
776 eo1_eo_func_desc_generate(classname, tmpstr, tmpbuf); 778 eo1_eo_func_desc_generate(classname, NULL, tmpstr, tmpbuf);
777 else 779 else
778 eina_strbuf_reset(tmpbuf); 780 eina_strbuf_reset(tmpbuf);
779 eina_strbuf_append(str_func, eina_strbuf_string_get(tmpbuf)); 781 eina_strbuf_append(str_func, eina_strbuf_string_get(tmpbuf));
@@ -784,15 +786,14 @@ eo1_source_end_generate(const char *classname, Eina_Strbuf *buf)
784 EINA_LIST_FOREACH(eolian_class_functions_list_get(classname, METHOD_FUNC), itr, fn) 786 EINA_LIST_FOREACH(eolian_class_functions_list_get(classname, METHOD_FUNC), itr, fn)
785 { 787 {
786 const char *funcname = eolian_function_name_get(fn); 788 const char *funcname = eolian_function_name_get(fn);
787 char *desc = _source_desc_get(eolian_function_description_get(fn, "comment"));
788 789
789 eo1_eo_op_desc_generate(classname, funcname, tmpbuf); 790 char *desc = _source_desc_get(eolian_function_description_get(fn, "comment"));
790 eina_strbuf_replace_all(tmpbuf, "@#desc", desc); 791 eo1_eo_op_desc_generate(classname, funcname, desc, tmpbuf);
791 free(desc); 792 free(desc);
792 eina_strbuf_append(str_op, eina_strbuf_string_get(tmpbuf)); 793 eina_strbuf_append(str_op, eina_strbuf_string_get(tmpbuf));
793 794
794 if (!eolian_function_is_virtual_pure(fn)) 795 if (!eolian_function_is_virtual_pure(fn))
795 eo1_eo_func_desc_generate(classname, funcname, tmpbuf); 796 eo1_eo_func_desc_generate(classname, NULL, funcname, tmpbuf);
796 else 797 else
797 eina_strbuf_reset(tmpbuf); 798 eina_strbuf_reset(tmpbuf);
798 eina_strbuf_append(str_func, eina_strbuf_string_get(tmpbuf)); 799 eina_strbuf_append(str_func, eina_strbuf_string_get(tmpbuf));
@@ -808,7 +809,23 @@ eo1_source_end_generate(const char *classname, Eina_Strbuf *buf)
808 eina_strbuf_replace_all(tmpbuf, ",", "_"); 809 eina_strbuf_replace_all(tmpbuf, ",", "_");
809 eina_strbuf_append_printf(str_ev, "\n %s,", eina_strbuf_string_get(tmpbuf)); 810 eina_strbuf_append_printf(str_ev, "\n %s,", eina_strbuf_string_get(tmpbuf));
810 } 811 }
811 eina_strbuf_replace_all(str_end, "@#list_evdesc", eina_strbuf_string_get(str_ev)); 812
813 eina_strbuf_reset(tmpbuf);
814 if (eina_strbuf_length_get(str_ev))
815 {
816 Eina_Strbuf *events_desc = eina_strbuf_new();
817 _template_fill(events_desc, tmpl_events_desc, classname, "", EINA_TRUE);
818 eina_strbuf_replace_all(events_desc, "@#list_evdesc", eina_strbuf_string_get(str_ev));
819 eina_strbuf_replace_all(str_end, "@#events_desc", eina_strbuf_string_get(events_desc));
820 eina_strbuf_free(events_desc);
821 eina_strbuf_append_printf(tmpbuf, "_%s_event_desc", lowclass);
822 }
823 else
824 {
825 eina_strbuf_append_printf(tmpbuf, "NULL");
826 eina_strbuf_replace_all(str_end, "@#events_desc", "");
827 }
828 eina_strbuf_replace_all(str_end, "@#Events_Desc", eina_strbuf_string_get(tmpbuf));
812 829
813 const char *inherit_name; 830 const char *inherit_name;
814 eina_strbuf_reset(tmpbuf); 831 eina_strbuf_reset(tmpbuf);
@@ -824,8 +841,28 @@ eo1_source_end_generate(const char *classname, Eina_Strbuf *buf)
824 eina_strbuf_replace_all(str_end, "@#list_inherit", eina_strbuf_string_get(tmpbuf)); 841 eina_strbuf_replace_all(str_end, "@#list_inherit", eina_strbuf_string_get(tmpbuf));
825 842
826 eina_strbuf_replace_all(str_end, "@#list_func", eina_strbuf_string_get(str_func)); 843 eina_strbuf_replace_all(str_end, "@#list_func", eina_strbuf_string_get(str_func));
827 eina_strbuf_replace_all(str_end, "@#list_op", eina_strbuf_string_get(str_op)); 844
828 eina_strbuf_replace_all(str_end, "@#list_ctors_body", eina_strbuf_string_get(str_bodyf)); 845 eina_strbuf_reset(tmpbuf);
846 if (eina_strbuf_length_get(str_op))
847 {
848 Eina_Strbuf *ops_desc = eina_strbuf_new();
849 _template_fill(ops_desc, tmpl_eo1_ops_desc, classname, "", EINA_TRUE);
850 eina_strbuf_replace_all(ops_desc, "@#list_op", eina_strbuf_string_get(str_op));
851 eina_strbuf_replace_all(str_end, "@#ops_desc", eina_strbuf_string_get(ops_desc));
852 eina_strbuf_free(ops_desc);
853 _template_fill(tmpbuf,
854 "EO_CLASS_DESCRIPTION_OPS(&@#EOPREFIX_BASE_ID, _@#class_op_desc, @#EOPREFIX_SUB_ID_LAST)",
855 classname, NULL, EINA_TRUE);
856 eina_strbuf_replace_all(tmpbuf, "@#EOPREFIX", current_eo_prefix_upper);
857 }
858 else
859 {
860 eina_strbuf_replace_all(str_end, "@#ops_desc", "");
861 eina_strbuf_append_printf(tmpbuf, "EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0)");
862 }
863
864 eina_strbuf_replace_all(str_end, "@#functions_body", eina_strbuf_string_get(str_bodyf));
865 eina_strbuf_replace_all(str_end, "@#eo_class_desc_ops", eina_strbuf_string_get(tmpbuf));
829 866
830 const char *data_type = eolian_class_data_type_get(classname); 867 const char *data_type = eolian_class_data_type_get(classname);
831 if (data_type && !strcmp(data_type, "null")) 868 if (data_type && !strcmp(data_type, "null"))