summaryrefslogtreecommitdiff
path: root/src/bin/eolian/eo1_generator.c
diff options
context:
space:
mode:
authorDaniel Zaoui <daniel.zaoui@samsung.com>2014-05-29 14:42:16 +0300
committerDaniel Zaoui <daniel.zaoui@samsung.com>2014-05-29 14:48:05 +0300
commitdc3178404f2d82cddf5be19de03dd81cdeab7541 (patch)
tree757a76a847d5902c6ecd781e1ead42b8c82883cc /src/bin/eolian/eo1_generator.c
parentf4a0c8054f1ad8b1352bc3a261f0213ff71daa82 (diff)
Eolian: modify 'implement' API parameters.
The function eolian_implement_information_get was returning strings for the class and the function. It was written in this way at the beginning because it was not needed to verify the correctness of the class and the function. Now that we have the namespace feature, this function must check it, meaning that the class and the function are now known. So we can return them instead of returning the strings. The generators had to find the class from the classname. It is no more needed. The C++ generator has been adapted to this new API.
Diffstat (limited to '')
-rw-r--r--src/bin/eolian/eo1_generator.c94
1 files changed, 30 insertions, 64 deletions
diff --git a/src/bin/eolian/eo1_generator.c b/src/bin/eolian/eo1_generator.c
index 003be9c1a3..c8f5829b35 100644
--- a/src/bin/eolian/eo1_generator.c
+++ b/src/bin/eolian/eo1_generator.c
@@ -52,9 +52,6 @@ EO_DEFINE_CLASS(@#eoprefix_class_get, &_@#class_class_desc, @#list_inheritNULL);
52"; 52";
53 53
54static const char 54static const char
55tmpl_eo_func_desc[] = "\n EO_OP_FUNC_OVERRIDE(@#eoprefix_@#func, _@#class_@#func),";
56
57static const char
58tmpl_eo_op_desc[] = "\n EO_OP_FUNC(@#eoprefix_@#func, _@#class_@#func, \"@#desc\"),"; 55tmpl_eo_op_desc[] = "\n EO_OP_FUNC(@#eoprefix_@#func, _@#class_@#func, \"@#desc\"),";
59 56
60static const char 57static const char
@@ -590,7 +587,6 @@ eo_source_end_generate(const Eolian_Class class, Eina_Strbuf *buf)
590 Eina_Strbuf *str_func = eina_strbuf_new(); 587 Eina_Strbuf *str_func = eina_strbuf_new();
591 Eina_Strbuf *str_bodyf = eina_strbuf_new(); 588 Eina_Strbuf *str_bodyf = eina_strbuf_new();
592 Eina_Strbuf *str_ev = eina_strbuf_new(); 589 Eina_Strbuf *str_ev = eina_strbuf_new();
593 Eina_Strbuf *tmpl_impl = eina_strbuf_new();
594 590
595 _template_fill(str_end, tmpl_eo_src, class, NULL, NULL, EINA_TRUE); 591 _template_fill(str_end, tmpl_eo_src, class, NULL, NULL, EINA_TRUE);
596 592
@@ -628,80 +624,51 @@ eo_source_end_generate(const Eolian_Class class, Eina_Strbuf *buf)
628 Eolian_Implement impl_desc; 624 Eolian_Implement impl_desc;
629 EINA_LIST_FOREACH(eolian_class_implements_list_get(class), itr, impl_desc) 625 EINA_LIST_FOREACH(eolian_class_implements_list_get(class), itr, impl_desc)
630 { 626 {
631 const char *funcname; 627 Eolian_Class impl_class;
632 const char *impl_classname;
633 Eolian_Function_Type ftype; 628 Eolian_Function_Type ftype;
634
635 eolian_implement_information_get(impl_desc, &impl_classname, &funcname, &ftype);
636 Eolian_Class impl_class = eolian_class_find_by_name(impl_classname);
637 _eolian_class_vars impl_env; 629 _eolian_class_vars impl_env;
638 _class_env_create(impl_class, NULL, &impl_env); 630 Eolian_Function fnid;
631 const char *funcname;
639 632
640 eina_strbuf_reset(tmpl_impl); 633 eolian_implement_information_get(impl_desc, &impl_class, &fnid, &ftype);
641 eina_strbuf_append(tmpl_impl, tmpl_eo_func_desc); 634 _class_env_create(impl_class, NULL, &impl_env);
642 eina_strbuf_replace_all(tmpl_impl, "@#eoprefix", impl_env.lower_eo_prefix); 635 funcname = eolian_function_name_get(fnid);
643 636
644 char implname[0xFF]; 637 char implname[0xFF];
645 char *tp = implname; 638 char *tp = implname;
646 sprintf(implname, "%s_%s", class_env.full_classname, impl_env.full_classname); 639 sprintf(implname, "%s_%s", class_env.full_classname, impl_env.full_classname);
647 eina_str_tolower(&tp); 640 eina_str_tolower(&tp);
648 641
649 eina_strbuf_replace_all(tmpl_impl, "@#class", implname); 642 if (!fnid)
650 const char *tmpl_impl_str = eina_strbuf_string_get(tmpl_impl);
651
652 Eolian_Function in_meth = NULL;
653 Eolian_Function in_prop = NULL;
654 const Eina_List *itr2;
655 Eolian_Function fnid;
656 EINA_LIST_FOREACH(eolian_class_functions_list_get(impl_class, EOLIAN_CTOR), itr2, fnid)
657 if (fnid && !strcmp(eolian_function_name_get(fnid), funcname)) in_meth = fnid;
658 EINA_LIST_FOREACH(eolian_class_functions_list_get(impl_class, EOLIAN_METHOD), itr2, fnid)
659 if (fnid && !strcmp(eolian_function_name_get(fnid), funcname)) in_meth = fnid;
660 EINA_LIST_FOREACH(eolian_class_functions_list_get(impl_class, EOLIAN_PROPERTY), itr2, fnid)
661 if (fnid && !strcmp(eolian_function_name_get(fnid), funcname)) in_prop = fnid;
662
663 if (!in_meth && !in_prop)
664 { 643 {
665 ERR ("Failed to generate implementation of %s:%s - missing form super class", impl_classname, funcname); 644 ERR ("Failed to generate implementation of %s - missing form super class",
645 eolian_implement_full_name_get(impl_desc));
666 goto end; 646 goto end;
667 } 647 }
668 648
669 /* e.g event_freeze can be a property or a method. If a type is explicit (property EOLIAN_PROP_SET/EOLIAN_PROP_GET), 649 switch (ftype)
670 * we assume it can't be a method.
671 */
672 if ((in_meth && in_prop) && (ftype == EOLIAN_PROP_SET || ftype == EOLIAN_PROP_GET)) in_meth = NULL;
673
674 if (in_meth)
675 { 650 {
676 _template_fill(str_op, tmpl_impl_str, impl_class, NULL, funcname, EINA_FALSE); 651 case EOLIAN_PROP_SET: case EOLIAN_PROP_GET: case EOLIAN_PROPERTY:
677 eo_bind_func_generate(class, in_meth, EOLIAN_UNRESOLVED, str_bodyf, &impl_env); 652 if (ftype != EOLIAN_PROP_GET)
678 continue; 653 {
654 eina_strbuf_append_printf(str_op, "\n EO_OP_FUNC_OVERRIDE(%s_%s_set, _%s_%s_set),",
655 impl_env.lower_eo_prefix, funcname, implname, funcname);
656 eo_bind_func_generate(class, fnid, EOLIAN_PROP_SET, str_bodyf, &impl_env);
657 }
658
659 if (ftype != EOLIAN_PROP_SET)
660 {
661 eina_strbuf_append_printf(str_op, "\n EO_OP_FUNC_OVERRIDE(%s_%s_get, _%s_%s_get),",
662 impl_env.lower_eo_prefix, funcname, implname, funcname);
663 eo_bind_func_generate(class, fnid, EOLIAN_PROP_GET, str_bodyf, &impl_env);
664 }
665 break;
666 default:
667 eina_strbuf_append_printf(str_op, "\n EO_OP_FUNC_OVERRIDE(%s_%s, _%s_%s),",
668 impl_env.lower_eo_prefix, funcname, implname, funcname);
669 eo_bind_func_generate(class, fnid, ftype, str_bodyf, &impl_env);
670 break;
679 } 671 }
680
681 if (in_prop)
682 {
683 char tmpstr[0xFF];
684
685 if ((ftype != EOLIAN_PROP_GET) && (ftype != EOLIAN_PROP_SET)) ftype = eolian_function_type_get(in_prop);
686
687 Eina_Bool prop_read = ( ftype == EOLIAN_PROP_SET ) ? EINA_FALSE : EINA_TRUE;
688 Eina_Bool prop_write = ( ftype == EOLIAN_PROP_GET ) ? EINA_FALSE : EINA_TRUE;
689
690 if (prop_write)
691 {
692 sprintf(tmpstr, "%s_set", funcname);
693 _template_fill(str_op, tmpl_impl_str, impl_class, NULL, tmpstr, EINA_FALSE);
694 eo_bind_func_generate(class, in_prop, EOLIAN_PROP_SET, str_bodyf, &impl_env);
695 }
696
697 if (prop_read)
698 {
699 sprintf(tmpstr, "%s_get", funcname);
700 _template_fill(str_op, tmpl_impl_str, impl_class, NULL, tmpstr, EINA_FALSE);
701 eo_bind_func_generate(class, in_prop, EOLIAN_PROP_GET, str_bodyf, &impl_env);
702 }
703 }
704 eina_strbuf_append(str_op, eina_strbuf_string_get(tmpbuf));
705 } 672 }
706 673
707 //Constructors 674 //Constructors
@@ -864,7 +831,6 @@ end:
864 eina_strbuf_free(str_bodyf); 831 eina_strbuf_free(str_bodyf);
865 eina_strbuf_free(str_end); 832 eina_strbuf_free(str_end);
866 eina_strbuf_free(str_ev); 833 eina_strbuf_free(str_ev);
867 eina_strbuf_free(tmpl_impl);
868 834
869 return ret; 835 return ret;
870} 836}