diff options
author | Felipe Magno de Almeida <felipe@expertisesolutions.com.br> | 2015-11-01 21:57:43 -0200 |
---|---|---|
committer | Felipe Magno de Almeida <felipe@expertisesolutions.com.br> | 2015-11-01 21:57:43 -0200 |
commit | fa88a2337f4c1ed74dbe5f8e9b8ab9e80aa94215 (patch) | |
tree | 289d1f0e30abe7aeb9100ab9ed3e3a755d1c18b7 /src/bin/eolian | |
parent | b9a6a8e7384fc79fced2132407208abfedf77fe1 (diff) |
Eo: Partial implementation to remove eo_dodevs/felipealmeida/eo_optimisations
Diffstat (limited to '')
-rw-r--r-- | src/bin/eolian/eo_generator.c | 148 | ||||
-rw-r--r-- | src/bin/eolian/impl_generator.c | 4 | ||||
-rw-r--r-- | src/bin/eolian/legacy_generator.c | 21 |
3 files changed, 143 insertions, 30 deletions
diff --git a/src/bin/eolian/eo_generator.c b/src/bin/eolian/eo_generator.c index 2e4f545391..3232ebb8c7 100644 --- a/src/bin/eolian/eo_generator.c +++ b/src/bin/eolian/eo_generator.c | |||
@@ -98,7 +98,23 @@ eo_fundef_generate(const Eolian_Class *class, const Eolian_Function *func, Eolia | |||
98 | eina_strbuf_append_char(str_func, '\n'); | 98 | eina_strbuf_append_char(str_func, '\n'); |
99 | eina_strbuf_free(dbuf); | 99 | eina_strbuf_free(dbuf); |
100 | } | 100 | } |
101 | eina_strbuf_append_printf(str_func, "EOAPI @#rettype %s(@#full_params);\n", func_env.lower_eo_func); | 101 | Eina_Bool has_params = EINA_FALSE; |
102 | |||
103 | itr = eolian_property_keys_get(func, ftype); | ||
104 | has_params |= (eina_iterator_next(itr, &data)); | ||
105 | eina_iterator_free(itr); | ||
106 | |||
107 | if (!has_params && !var_as_ret) | ||
108 | { | ||
109 | itr = is_prop ? eolian_property_values_get(func, ftype) : eolian_function_parameters_get(func); | ||
110 | has_params |= (eina_iterator_next(itr, &data)); | ||
111 | eina_iterator_free(itr); | ||
112 | } | ||
113 | |||
114 | eina_strbuf_append_printf(str_func, "EOAPI @#rettype %s(Eo const* ___object%s@#full_params);\n", func_env.lower_eo_func | ||
115 | , has_params?", ":""); | ||
116 | eina_strbuf_append_printf(str_func, "EOAPI @#rettype eo_super_%s(Eo const* ___klass, Eo const* ___object%s@#full_params);\n", func_env.lower_eo_func | ||
117 | , has_params?", ":""); | ||
102 | 118 | ||
103 | if (scope == EOLIAN_SCOPE_PROTECTED) | 119 | if (scope == EOLIAN_SCOPE_PROTECTED) |
104 | eina_strbuf_append_printf(str_func, "#endif\n"); | 120 | eina_strbuf_append_printf(str_func, "#endif\n"); |
@@ -518,13 +534,13 @@ eo_bind_func_generate(const Eolian_Class *class, const Eolian_Function *funcid, | |||
518 | } | 534 | } |
519 | Eina_Bool ret_is_void = (!rettype || !strcmp(rettype, "void")); | 535 | Eina_Bool ret_is_void = (!rettype || !strcmp(rettype, "void")); |
520 | _class_func_env_create(class, eolian_function_name_get(funcid), ftype, &func_env); | 536 | _class_func_env_create(class, eolian_function_name_get(funcid), ftype, &func_env); |
521 | eina_strbuf_append_printf(eo_func_decl, | 537 | /* eina_strbuf_append_printf(eo_func_decl, */ |
522 | "EOAPI EO_%sFUNC_BODY%s(%s", | 538 | /* "EOAPI EO_%sFUNC_BODY%s(%s", */ |
523 | ret_is_void?"VOID_":"", has_params?"V":"", | 539 | /* ret_is_void?"VOID_":"", has_params?"V":"", */ |
524 | func_env.lower_eo_func); | 540 | /* func_env.lower_eo_func); */ |
525 | if (!ret_is_void) | 541 | const char *val_str = NULL; |
542 | if (!ret_is_void) | ||
526 | { | 543 | { |
527 | const char *val_str = NULL; | ||
528 | if (default_ret_val) | 544 | if (default_ret_val) |
529 | { | 545 | { |
530 | Eolian_Value val = eolian_expression_eval | 546 | Eolian_Value val = eolian_expression_eval |
@@ -532,25 +548,109 @@ eo_bind_func_generate(const Eolian_Class *class, const Eolian_Function *funcid, | |||
532 | if (val.type) | 548 | if (val.type) |
533 | val_str = eolian_expression_value_to_literal(&val); | 549 | val_str = eolian_expression_value_to_literal(&val); |
534 | } | 550 | } |
535 | eina_strbuf_append_printf(eo_func_decl, ", %s, %s", | 551 | |
536 | rettype, val_str?val_str:"0"); | 552 | /* eina_strbuf_append_printf(eo_func_decl, ", %s, %s", */ |
537 | if (val_str && eolian_expression_type_get(default_ret_val) == EOLIAN_EXPR_NAME) | 553 | /* rettype, val_str?val_str:"0"); */ |
538 | { | 554 | /* if (val_str && eolian_expression_type_get(default_ret_val) == EOLIAN_EXPR_NAME) */ |
539 | Eina_Stringshare *string = eolian_expression_serialize(default_ret_val); | 555 | /* { */ |
540 | eina_strbuf_append_printf(eo_func_decl, " /* %s */", string); | 556 | /* Eina_Stringshare *string = eolian_expression_serialize(default_ret_val); */ |
541 | eina_stringshare_del(string); | 557 | /* eina_strbuf_append_printf(eo_func_decl, " /\* %s *\/", string); */ |
542 | } | 558 | /* eina_stringshare_del(string); */ |
543 | } | 559 | /* } */ |
544 | if (has_params) | ||
545 | { | ||
546 | eina_strbuf_replace_all(full_params, " EINA_UNUSED", ""); | ||
547 | eina_strbuf_append_printf(eo_func_decl, ", EO_FUNC_CALL(%s)%s", | ||
548 | eina_strbuf_string_get(params), | ||
549 | eina_strbuf_string_get(full_params)); | ||
550 | } | 560 | } |
551 | eina_strbuf_append_printf(eo_func_decl, ");"); | 561 | /* if (has_params) */ |
562 | /* { */ | ||
563 | /* eina_strbuf_replace_all(full_params, " EINA_UNUSED", ""); */ | ||
564 | /* eina_strbuf_append_printf(eo_func_decl, ", EO_FUNC_CALL(%s)%s", */ | ||
565 | /* eina_strbuf_string_get(params), */ | ||
566 | /* eina_strbuf_string_get(full_params)); */ | ||
567 | /* } */ | ||
568 | /* eina_strbuf_append_printf(eo_func_decl, ");"); */ | ||
569 | |||
570 | eina_strbuf_append_printf(eo_func_decl, | ||
571 | "EOAPI %s %s(Eo const* _object%s);\n", ret_is_void?"void":rettype, func_env.lower_eo_func, | ||
572 | eina_strbuf_string_get(full_params)); | ||
573 | |||
574 | eina_strbuf_append_printf(eo_func_decl, | ||
575 | "static %s _eo_impl_%s(_Eo_Class const* ___klass, Eo const* ___oid, _Eo_Object const* ___object%s)\n{\n" | ||
576 | , ret_is_void?"void":rettype, func_env.lower_eo_func, | ||
577 | eina_strbuf_string_get(full_params)); | ||
578 | eina_strbuf_append_printf(eo_func_decl, | ||
579 | " typedef %s (*_Eo_func)(Eo*, void *obj_data%s);\n" | ||
580 | " static Eo_Op ___op = EO_NOOP;\n" | ||
581 | " fprintf(stderr, \"%%s %%s:%%d\\n\", __func__, __FILE__, __LINE__); fflush(stderr);\n" | ||
582 | " if (EINA_UNLIKELY(___op == EO_NOOP))\n" | ||
583 | " {\n" | ||
584 | " fprintf(stderr, \"%%s %%s:%%d\\n\", __func__, __FILE__, __LINE__); fflush(stderr);\n" | ||
585 | " ___op = _eo_api_op_id_get(EO_FUNC_COMMON_OP_FUNC(%s));\n" | ||
586 | " fprintf(stderr, \"%%s %%s:%%d\\n\", __func__, __FILE__, __LINE__); fflush(stderr);\n" | ||
587 | " if (___op == EO_NOOP) return %s;\n" | ||
588 | " }\n" | ||
589 | " fprintf(stderr, \"%%s %%s:%%d\\n\", __func__, __FILE__, __LINE__); fflush(stderr);\n" | ||
590 | " const op_type_funcs *___func = _dich_func_get(___klass, ___op);\n" | ||
591 | " fprintf(stderr, \"%%s %%s:%%d\\n\", __func__, __FILE__, __LINE__); fflush(stderr);\n" | ||
592 | " fprintf(stderr, \"___func %%p\\n\", ___func); fflush(stderr);\n" | ||
593 | " //assert(!!___func);\n" | ||
594 | " fprintf(stderr, \"___func->func %%p\\n\", ___func->func);fflush(stderr);\n" | ||
595 | " fprintf(stderr, \"___func->src %%p\\n\", ___func->src);fflush(stderr);\n" | ||
596 | " _Eo_func ___func_ = (_Eo_func) ___func->func;\n" | ||
597 | " void* ___data = _eo_data_scope_get(___object, ___func->src);\n" | ||
598 | " %s%s\n" | ||
599 | " %s ___func_((Eo*)___oid, ___data%s%s);\n" | ||
600 | " %s\n}\n" | ||
601 | , ret_is_void?"void":rettype | ||
602 | /* , func_env.lower_eo_func */ | ||
603 | , eina_strbuf_string_get(full_params) | ||
604 | , func_env.lower_eo_func | ||
605 | , ret_is_void?"":val_str?val_str:"0" | ||
606 | , ret_is_void?"":rettype | ||
607 | , ret_is_void?"":" _ret;" | ||
608 | /* , func_env.lower_eo_func */ | ||
609 | /* , ret_is_void?"":val_str?val_str:"0" */ | ||
610 | , ret_is_void?"":"_ret = " | ||
611 | , has_params?", ":"" | ||
612 | , eina_strbuf_string_get(params) | ||
613 | , ret_is_void?"":"return _ret;" | ||
614 | ); | ||
615 | |||
616 | eina_strbuf_append_printf(eo_func_decl, | ||
617 | "EOAPI %s %s(Eo const* ___object%s)\n{\n", ret_is_void?"void":rettype, func_env.lower_eo_func, | ||
618 | eina_strbuf_string_get(full_params)); | ||
619 | eina_strbuf_append_printf(eo_func_decl, | ||
620 | " fprintf(stderr, \"%%s %%s:%%d\\n\", __func__, __FILE__, __LINE__); fflush(stderr);\n" | ||
621 | " _Eo_Object* ___obj = (_Eo_Object*)_eo_obj_pointer_get((Eo_Id)___object);\n" | ||
622 | " if(___obj) {\n" | ||
623 | " fprintf(stderr, \"%%s %%s:%%d\\n\", __func__, __FILE__, __LINE__); fflush(stderr);\n" | ||
624 | " return _eo_impl_%s(___obj->klass, ___object, ___obj%s%s);\n" | ||
625 | " }\n" | ||
626 | "}\n" | ||
627 | , func_env.lower_eo_func | ||
628 | , has_params?", ":"" | ||
629 | , eina_strbuf_string_get(params) | ||
630 | ); | ||
631 | |||
632 | eina_strbuf_append_printf(eo_func_decl, | ||
633 | "EOAPI %s eo_super_%s(Eo_Class const* ___klass, Eo const* ___object%s)\n{\n" | ||
634 | , ret_is_void?"void":rettype, func_env.lower_eo_func | ||
635 | , eina_strbuf_string_get(full_params)); | ||
636 | eina_strbuf_append_printf(eo_func_decl, | ||
637 | " fprintf(stderr, \"%%s %%s:%%d\\n\", __func__, __FILE__, __LINE__); fflush(stderr);\n" | ||
638 | " _Eo_Object* ___obj = (_Eo_Object*)_eo_obj_pointer_get((Eo_Id)___object);\n" | ||
639 | " if(___obj) {\n" | ||
640 | " fprintf(stderr, \"%%s %%s:%%d\\n\", __func__, __FILE__, __LINE__); fflush(stderr);\n" | ||
641 | " _Eo_Class* ___kls = (_Eo_Class*)_eo_class_pointer_get((Eo_Id)___klass);\n" | ||
642 | " fprintf(stderr, \"%%s %%s:%%d\\n\", __func__, __FILE__, __LINE__); fflush(stderr);\n" | ||
643 | " if(___kls)\n" | ||
644 | " return _eo_impl_%s(___kls->parent, ___object, ___obj%s%s);\n" | ||
645 | " }\n" | ||
646 | "}\n" | ||
647 | , func_env.lower_eo_func | ||
648 | , has_params?", ":"" | ||
649 | , eina_strbuf_string_get(params) | ||
650 | ); | ||
651 | |||
552 | eina_strbuf_append_printf(fbody, "%s\n", eina_strbuf_string_get(eo_func_decl)); | 652 | eina_strbuf_append_printf(fbody, "%s\n", eina_strbuf_string_get(eo_func_decl)); |
553 | eina_strbuf_free(eo_func_decl); | 653 | /* eina_strbuf_free(eo_func_decl); */ |
554 | } | 654 | } |
555 | 655 | ||
556 | if (need_implementation) | 656 | if (need_implementation) |
diff --git a/src/bin/eolian/impl_generator.c b/src/bin/eolian/impl_generator.c index 4103a2110d..c4f74f1ff6 100644 --- a/src/bin/eolian/impl_generator.c +++ b/src/bin/eolian/impl_generator.c | |||
@@ -172,9 +172,9 @@ _prototype_generate(const Eolian_Function *foo, Eolian_Function_Type ftype, Eina | |||
172 | { | 172 | { |
173 | eina_strbuf_append_printf | 173 | eina_strbuf_append_printf |
174 | (super_invok, | 174 | (super_invok, |
175 | " eo_do_super(obj, %s_%s, %s_%s(%s));\n", | 175 | " eo_super_%s_%s(%s_%s, obj, %s);\n", |
176 | class_env.upper_eo_prefix, class_env.upper_classtype, | ||
177 | impl_env.lower_eo_prefix, eolian_function_name_get(foo), | 176 | impl_env.lower_eo_prefix, eolian_function_name_get(foo), |
177 | class_env.upper_eo_prefix, class_env.upper_classtype, | ||
178 | eina_strbuf_string_get(short_params)); | 178 | eina_strbuf_string_get(short_params)); |
179 | } | 179 | } |
180 | } | 180 | } |
diff --git a/src/bin/eolian/legacy_generator.c b/src/bin/eolian/legacy_generator.c index 18b4506ab2..d05122e546 100644 --- a/src/bin/eolian/legacy_generator.c +++ b/src/bin/eolian/legacy_generator.c | |||
@@ -24,7 +24,7 @@ EAPI @#ret_type\n\ | |||
24 | @#eapi_func(@#full_params)\n\ | 24 | @#eapi_func(@#full_params)\n\ |
25 | {\n\ | 25 | {\n\ |
26 | @#ret_type ret;\n\ | 26 | @#ret_type ret;\n\ |
27 | eo_do(@#eo_obj, ret = @#eo_func(@#eo_params));\n\ | 27 | eo_do(@#eo_obj, ret = @#eo_func(@#eo_obj%s@#eo_params));\n\ |
28 | return ret;\n\ | 28 | return ret;\n\ |
29 | }\n\ | 29 | }\n\ |
30 | "; | 30 | "; |
@@ -34,7 +34,7 @@ tmpl_eapi_body_void[] ="\ | |||
34 | EAPI void\n\ | 34 | EAPI void\n\ |
35 | @#eapi_func(@#full_params)\n\ | 35 | @#eapi_func(@#full_params)\n\ |
36 | {\n\ | 36 | {\n\ |
37 | eo_do(@#eo_obj, @#eo_func(@#eo_params));\n\ | 37 | eo_do(@#eo_obj, @#eo_func(@#eo_obj%s@#eo_params));\n\ |
38 | }\n\ | 38 | }\n\ |
39 | "; | 39 | "; |
40 | 40 | ||
@@ -229,10 +229,23 @@ _eapi_func_generate(const Eolian_Class *class, const Eolian_Function *funcid, Eo | |||
229 | 229 | ||
230 | if (!rettype && rettypet) rettype = eolian_type_c_type_get(rettypet); | 230 | if (!rettype && rettypet) rettype = eolian_type_c_type_get(rettypet); |
231 | 231 | ||
232 | Eina_Bool has_params = EINA_FALSE; | ||
233 | |||
234 | itr = eolian_property_keys_get(funcid, ftype); | ||
235 | has_params |= (eina_iterator_next(itr, &data)); | ||
236 | eina_iterator_free(itr); | ||
237 | |||
238 | if (!has_params && !var_as_ret) | ||
239 | { | ||
240 | itr = is_prop ? eolian_property_values_get(funcid, ftype) : eolian_function_parameters_get(funcid); | ||
241 | has_params |= (eina_iterator_next(itr, &data)); | ||
242 | eina_iterator_free(itr); | ||
243 | } | ||
244 | |||
232 | if (rettype && (!ret_is_void)) | 245 | if (rettype && (!ret_is_void)) |
233 | eina_strbuf_append(fbody, tmpl_eapi_body); | 246 | eina_strbuf_append_printf(fbody, tmpl_eapi_body, has_params?", ":""); |
234 | else | 247 | else |
235 | eina_strbuf_append(fbody, tmpl_eapi_body_void); | 248 | eina_strbuf_append_printf(fbody, tmpl_eapi_body_void, has_params?", ":""); |
236 | 249 | ||
237 | if (!eolian_function_is_class(funcid)) | 250 | if (!eolian_function_is_class(funcid)) |
238 | { | 251 | { |