diff options
author | Daniel Kolesa <d.kolesa@samsung.com> | 2019-09-05 15:14:39 +0200 |
---|---|---|
committer | Daniel Kolesa <d.kolesa@samsung.com> | 2019-09-05 15:19:28 +0200 |
commit | 04b0321bea1637539eff15c7759ab43991fe4d09 (patch) | |
tree | 095eecf1f68ea98092946b7a305538f88f7a11d3 | |
parent | ee0023055f76096788afae3dbdaaeb9c05b99334 (diff) |
eolian: update C generator to respect by_ref as well as tests
-rw-r--r-- | src/bin/eolian/headers.c | 9 | ||||
-rw-r--r-- | src/bin/eolian/sources.c | 67 | ||||
-rw-r--r-- | src/bin/eolian/types.c | 6 | ||||
-rw-r--r-- | src/tests/eolian/data/class_simple.eo | 4 | ||||
-rw-r--r-- | src/tests/eolian/data/consts.eo | 2 | ||||
-rw-r--r-- | src/tests/eolian/data/object_impl.eo | 2 | ||||
-rw-r--r-- | src/tests/eolian/data/override.eo | 2 | ||||
-rw-r--r-- | src/tests/eolian/data/struct.eo | 4 | ||||
-rw-r--r-- | src/tests/eolian/eolian_parsing.c | 9 |
9 files changed, 55 insertions, 50 deletions
diff --git a/src/bin/eolian/headers.c b/src/bin/eolian/headers.c index f21ae2e8f6..0973038d88 100644 --- a/src/bin/eolian/headers.c +++ b/src/bin/eolian/headers.c | |||
@@ -18,7 +18,7 @@ _gen_param(Eina_Strbuf *buf, Eolian_Function_Parameter *pr, | |||
18 | const Eolian_Type *prt = eolian_parameter_type_get(pr); | 18 | const Eolian_Type *prt = eolian_parameter_type_get(pr); |
19 | const Eolian_Typedecl *ptd = eolian_type_typedecl_get(prt); | 19 | const Eolian_Typedecl *ptd = eolian_type_typedecl_get(prt); |
20 | const char *prn = eolian_parameter_name_get(pr); | 20 | const char *prn = eolian_parameter_name_get(pr); |
21 | Eina_Stringshare *prtn = eolian_type_c_type_get(prt, EOLIAN_C_TYPE_PARAM); | 21 | Eina_Stringshare *prtn = eolian_parameter_c_type_get(pr, EINA_FALSE); |
22 | 22 | ||
23 | if (ptd && (eolian_typedecl_type_get(ptd) == EOLIAN_TYPEDECL_FUNCTION_POINTER)) | 23 | if (ptd && (eolian_typedecl_type_get(ptd) == EOLIAN_TYPEDECL_FUNCTION_POINTER)) |
24 | { | 24 | { |
@@ -83,6 +83,7 @@ _gen_func(const Eolian_State *state, const Eolian_Function *fid, | |||
83 | Eina_Bool var_as_ret = EINA_FALSE; | 83 | Eina_Bool var_as_ret = EINA_FALSE; |
84 | const Eolian_Type *rtp = eolian_function_return_type_get(fid, ftype); | 84 | const Eolian_Type *rtp = eolian_function_return_type_get(fid, ftype); |
85 | Eina_Bool return_move = eolian_function_return_is_move(fid, ftype); | 85 | Eina_Bool return_move = eolian_function_return_is_move(fid, ftype); |
86 | Eina_Stringshare *rtps = NULL; | ||
86 | if (ftype == EOLIAN_PROP_GET && !rtp) | 87 | if (ftype == EOLIAN_PROP_GET && !rtp) |
87 | { | 88 | { |
88 | void *d1, *d2; | 89 | void *d1, *d2; |
@@ -92,6 +93,7 @@ _gen_func(const Eolian_State *state, const Eolian_Function *fid, | |||
92 | Eolian_Function_Parameter *pr = (Eolian_Function_Parameter *)d1; | 93 | Eolian_Function_Parameter *pr = (Eolian_Function_Parameter *)d1; |
93 | rtp = eolian_parameter_type_get(pr); | 94 | rtp = eolian_parameter_type_get(pr); |
94 | return_move = eolian_parameter_is_move(pr); | 95 | return_move = eolian_parameter_is_move(pr); |
96 | rtps = eolian_parameter_c_type_get(pr, EINA_TRUE); | ||
95 | var_as_ret = EINA_TRUE; | 97 | var_as_ret = EINA_TRUE; |
96 | } | 98 | } |
97 | eina_iterator_free(itr); | 99 | eina_iterator_free(itr); |
@@ -119,17 +121,18 @@ _gen_func(const Eolian_State *state, const Eolian_Function *fid, | |||
119 | eina_strbuf_append(buf, "EOAPI "); | 121 | eina_strbuf_append(buf, "EOAPI "); |
120 | if (rtp) | 122 | if (rtp) |
121 | { | 123 | { |
122 | Eina_Stringshare *rtps = eolian_type_c_type_get(rtp, EOLIAN_C_TYPE_RETURN); | 124 | if (!rtps) |
125 | rtps = eolian_function_return_c_type_get(fid, ftype); | ||
123 | eina_strbuf_append(buf, rtps); | 126 | eina_strbuf_append(buf, rtps); |
124 | if (rtps[strlen(rtps) - 1] != '*') | 127 | if (rtps[strlen(rtps) - 1] != '*') |
125 | eina_strbuf_append_char(buf, ' '); | 128 | eina_strbuf_append_char(buf, ' '); |
126 | eina_stringshare_del(rtps); | ||
127 | } | 129 | } |
128 | else | 130 | else |
129 | eina_strbuf_append(buf, "void "); | 131 | eina_strbuf_append(buf, "void "); |
130 | 132 | ||
131 | eina_strbuf_append(buf, fcn); | 133 | eina_strbuf_append(buf, fcn); |
132 | eina_stringshare_del(fcn); | 134 | eina_stringshare_del(fcn); |
135 | eina_stringshare_del(rtps); | ||
133 | 136 | ||
134 | Eina_Strbuf *flagbuf = NULL; | 137 | Eina_Strbuf *flagbuf = NULL; |
135 | int nidx = !eolian_function_is_static(fid); | 138 | int nidx = !eolian_function_is_static(fid); |
diff --git a/src/bin/eolian/sources.c b/src/bin/eolian/sources.c index 2d2db389f4..dea9d86011 100644 --- a/src/bin/eolian/sources.c +++ b/src/bin/eolian/sources.c | |||
@@ -103,7 +103,7 @@ _gen_func_pointer_param(const char *name, Eina_Stringshare *c_type, | |||
103 | } | 103 | } |
104 | 104 | ||
105 | static void | 105 | static void |
106 | _append_defval(Eina_Strbuf *buf, const Eolian_Expression *exp, const Eolian_Type *tp) | 106 | _append_defval(Eina_Strbuf *buf, const Eolian_Expression *exp, const Eolian_Type *tp, const char *ctp) |
107 | { | 107 | { |
108 | if (exp) | 108 | if (exp) |
109 | { | 109 | { |
@@ -139,13 +139,11 @@ _append_defval(Eina_Strbuf *buf, const Eolian_Expression *exp, const Eolian_Type | |||
139 | free(sn); | 139 | free(sn); |
140 | return; | 140 | return; |
141 | } | 141 | } |
142 | Eina_Stringshare *ctp = eolian_type_c_type_get(btp, EOLIAN_C_TYPE_DEFAULT); | ||
143 | if (strchr(ctp, '*')) | 142 | if (strchr(ctp, '*')) |
144 | { | 143 | { |
145 | eina_strbuf_append(buf, "NULL"); | 144 | eina_strbuf_append(buf, "NULL"); |
146 | return; | 145 | return; |
147 | } | 146 | } |
148 | eina_stringshare_del(ctp); | ||
149 | /* enums and remaining regulars... 0 should do */ | 147 | /* enums and remaining regulars... 0 should do */ |
150 | eina_strbuf_append(buf, "0"); | 148 | eina_strbuf_append(buf, "0"); |
151 | } | 149 | } |
@@ -377,9 +375,11 @@ _get_reflect_initf(const Eolian_Type *abtp) | |||
377 | } | 375 | } |
378 | 376 | ||
379 | static void | 377 | static void |
380 | _gen_reflect_get(Eina_Strbuf *buf, const char *cnamel, const Eolian_Type *valt, | 378 | _gen_reflect_get(Eina_Strbuf *buf, const char *cnamel, |
379 | const Eolian_Function_Parameter *pr, | ||
381 | const Eolian_Function *fid, Eina_Hash *refh) | 380 | const Eolian_Function *fid, Eina_Hash *refh) |
382 | { | 381 | { |
382 | const Eolian_Type *valt = eolian_parameter_type_get(pr); | ||
383 | if (eolian_type_is_ptr(valt)) | 383 | if (eolian_type_is_ptr(valt)) |
384 | return; | 384 | return; |
385 | 385 | ||
@@ -399,7 +399,7 @@ _gen_reflect_get(Eina_Strbuf *buf, const char *cnamel, const Eolian_Type *valt, | |||
399 | cnamel, eolian_function_name_get(fid)); | 399 | cnamel, eolian_function_name_get(fid)); |
400 | eina_strbuf_append(buf, "{\n"); | 400 | eina_strbuf_append(buf, "{\n"); |
401 | 401 | ||
402 | Eina_Stringshare *ct = eolian_type_c_type_get(valt, EOLIAN_C_TYPE_RETURN); | 402 | Eina_Stringshare *ct = eolian_parameter_c_type_get(pr, EINA_TRUE); |
403 | const char *starsp = (ct[strlen(ct) - 1] != '*') ? " " : ""; | 403 | const char *starsp = (ct[strlen(ct) - 1] != '*') ? " " : ""; |
404 | 404 | ||
405 | Eina_Stringshare *fcn = eolian_function_full_c_name_get(fid, EOLIAN_PROP_GET); | 405 | Eina_Stringshare *fcn = eolian_function_full_c_name_get(fid, EOLIAN_PROP_GET); |
@@ -412,9 +412,11 @@ _gen_reflect_get(Eina_Strbuf *buf, const char *cnamel, const Eolian_Type *valt, | |||
412 | } | 412 | } |
413 | 413 | ||
414 | static void | 414 | static void |
415 | _gen_reflect_set(Eina_Strbuf *buf, const char *cnamel, const Eolian_Type *valt, | 415 | _gen_reflect_set(Eina_Strbuf *buf, const char *cnamel, |
416 | const Eolian_Function_Parameter *pr, | ||
416 | const Eolian_Function *fid, Eina_Hash *refh) | 417 | const Eolian_Function *fid, Eina_Hash *refh) |
417 | { | 418 | { |
419 | const Eolian_Type *valt = eolian_parameter_type_get(pr); | ||
418 | if (eolian_type_is_ptr(valt)) | 420 | if (eolian_type_is_ptr(valt)) |
419 | return; | 421 | return; |
420 | 422 | ||
@@ -435,7 +437,7 @@ _gen_reflect_set(Eina_Strbuf *buf, const char *cnamel, const Eolian_Type *valt, | |||
435 | eina_strbuf_append(buf, "{\n"); | 437 | eina_strbuf_append(buf, "{\n"); |
436 | eina_strbuf_append(buf, " Eina_Error r = 0;"); | 438 | eina_strbuf_append(buf, " Eina_Error r = 0;"); |
437 | 439 | ||
438 | Eina_Stringshare *ct = eolian_type_c_type_get(valt, EOLIAN_C_TYPE_PARAM); | 440 | Eina_Stringshare *ct = eolian_parameter_c_type_get(pr, EINA_FALSE); |
439 | const char *starsp = (ct[strlen(ct) - 1] != '*') ? " " : ""; | 441 | const char *starsp = (ct[strlen(ct) - 1] != '*') ? " " : ""; |
440 | eina_strbuf_append_printf(buf, " %s%scval;\n", ct, starsp); | 442 | eina_strbuf_append_printf(buf, " %s%scval;\n", ct, starsp); |
441 | eina_stringshare_del(ct); | 443 | eina_stringshare_del(ct); |
@@ -458,14 +460,11 @@ _gen_reflect_set(Eina_Strbuf *buf, const char *cnamel, const Eolian_Type *valt, | |||
458 | } | 460 | } |
459 | 461 | ||
460 | static void | 462 | static void |
461 | _emit_class_function(Eina_Strbuf *buf, const Eolian_Function *fid, const Eolian_Type *rtp, Eina_Strbuf *params_full, | 463 | _emit_class_function(Eina_Strbuf *buf, const Eolian_Function *fid, const char *rtpn, Eina_Strbuf *params_full, |
462 | const char *ocnamel, const char *func_suffix, Eina_Strbuf *params, const char *function_name) | 464 | const char *ocnamel, const char *func_suffix, Eina_Strbuf *params, const char *function_name) |
463 | { | 465 | { |
464 | eina_strbuf_append(buf, "EOAPI "); | 466 | eina_strbuf_append(buf, "EOAPI "); |
465 | if (rtp) | 467 | eina_strbuf_append(buf, rtpn); |
466 | eina_strbuf_append(buf, eolian_type_c_type_get(rtp, EOLIAN_C_TYPE_RETURN)); | ||
467 | else | ||
468 | eina_strbuf_append(buf, "void"); | ||
469 | eina_strbuf_append(buf, " "); | 468 | eina_strbuf_append(buf, " "); |
470 | eina_strbuf_append(buf, function_name); | 469 | eina_strbuf_append(buf, function_name); |
471 | eina_strbuf_append(buf, "("); | 470 | eina_strbuf_append(buf, "("); |
@@ -476,7 +475,7 @@ _emit_class_function(Eina_Strbuf *buf, const Eolian_Function *fid, const Eolian_ | |||
476 | eina_strbuf_append(buf, ")\n"); | 475 | eina_strbuf_append(buf, ")\n"); |
477 | eina_strbuf_append(buf, "{\n"); | 476 | eina_strbuf_append(buf, "{\n"); |
478 | eina_strbuf_append_printf(buf, " %s();\n", eolian_class_c_get_function_name_get(eolian_function_class_get(fid))); | 477 | eina_strbuf_append_printf(buf, " %s();\n", eolian_class_c_get_function_name_get(eolian_function_class_get(fid))); |
479 | if (rtp) | 478 | if (strcmp(rtpn, "void")) |
480 | eina_strbuf_append(buf, " return "); | 479 | eina_strbuf_append(buf, " return "); |
481 | else | 480 | else |
482 | eina_strbuf_append(buf, " "); | 481 | eina_strbuf_append(buf, " "); |
@@ -504,14 +503,16 @@ _gen_func(const Eolian_Class *cl, const Eolian_Function *fid, | |||
504 | Eina_Bool is_prop = (ftype == EOLIAN_PROP_GET || ftype == EOLIAN_PROP_SET); | 503 | Eina_Bool is_prop = (ftype == EOLIAN_PROP_GET || ftype == EOLIAN_PROP_SET); |
505 | Eina_Bool var_as_ret = EINA_FALSE; | 504 | Eina_Bool var_as_ret = EINA_FALSE; |
506 | /* assume we're not generating reflection api by default */ | 505 | /* assume we're not generating reflection api by default */ |
507 | const Eolian_Type *reflect_type = NULL; | 506 | const Eolian_Function_Parameter *reflect_param = NULL; |
508 | 507 | ||
509 | const Eolian_Expression *def_ret = NULL; | 508 | const Eolian_Expression *def_ret = NULL; |
510 | const Eolian_Type *rtp = eolian_function_return_type_get(fid, ftype); | 509 | const Eolian_Type *rtp = eolian_function_return_type_get(fid, ftype); |
510 | Eina_Stringshare *rtpn = NULL; | ||
511 | if (rtp) | 511 | if (rtp) |
512 | { | 512 | { |
513 | is_auto = EINA_FALSE; /* can't do auto if func returns */ | 513 | is_auto = EINA_FALSE; /* can't do auto if func returns */ |
514 | def_ret = eolian_function_return_default_value_get(fid, ftype); | 514 | def_ret = eolian_function_return_default_value_get(fid, ftype); |
515 | rtpn = eolian_function_return_c_type_get(fid, ftype); | ||
515 | } | 516 | } |
516 | 517 | ||
517 | const char *func_suffix = ""; | 518 | const char *func_suffix = ""; |
@@ -528,9 +529,10 @@ _gen_func(const Eolian_Class *cl, const Eolian_Function *fid, | |||
528 | rtp = eolian_parameter_type_get(pr); | 529 | rtp = eolian_parameter_type_get(pr); |
529 | /* reflect only when returning 1 val */ | 530 | /* reflect only when returning 1 val */ |
530 | if (!eolian_parameter_is_by_ref(pr)) | 531 | if (!eolian_parameter_is_by_ref(pr)) |
531 | reflect_type = rtp; | 532 | reflect_param = pr; |
532 | var_as_ret = EINA_TRUE; | 533 | var_as_ret = EINA_TRUE; |
533 | def_ret = eolian_parameter_default_value_get(pr); | 534 | def_ret = eolian_parameter_default_value_get(pr); |
535 | rtpn = eolian_parameter_c_type_get(pr, EINA_TRUE); | ||
534 | } | 536 | } |
535 | eina_iterator_free(itr); | 537 | eina_iterator_free(itr); |
536 | } | 538 | } |
@@ -545,7 +547,7 @@ _gen_func(const Eolian_Class *cl, const Eolian_Function *fid, | |||
545 | { | 547 | { |
546 | Eolian_Function_Parameter *pr = d1; | 548 | Eolian_Function_Parameter *pr = d1; |
547 | if (!eolian_parameter_is_by_ref(pr)) | 549 | if (!eolian_parameter_is_by_ref(pr)) |
548 | reflect_type = eolian_parameter_type_get(pr); | 550 | reflect_param = pr; |
549 | } | 551 | } |
550 | eina_iterator_free(itr); | 552 | eina_iterator_free(itr); |
551 | } | 553 | } |
@@ -560,13 +562,12 @@ _gen_func(const Eolian_Class *cl, const Eolian_Function *fid, | |||
560 | { | 562 | { |
561 | Eina_Iterator *itr = eolian_property_keys_get(fid, ftype); | 563 | Eina_Iterator *itr = eolian_property_keys_get(fid, ftype); |
562 | if (itr) /* has keys: no reflection */ | 564 | if (itr) /* has keys: no reflection */ |
563 | reflect_type = NULL; | 565 | reflect_param = NULL; |
564 | Eolian_Function_Parameter *pr; | 566 | Eolian_Function_Parameter *pr; |
565 | EINA_ITERATOR_FOREACH(itr, pr) | 567 | EINA_ITERATOR_FOREACH(itr, pr) |
566 | { | 568 | { |
567 | const char *prn = eolian_parameter_name_get(pr); | 569 | const char *prn = eolian_parameter_name_get(pr); |
568 | const Eolian_Type *pt = eolian_parameter_type_get(pr); | 570 | Eina_Stringshare *ptn = eolian_parameter_c_type_get(pr, EINA_FALSE); |
569 | Eina_Stringshare *ptn = eolian_type_c_type_get(pt, EOLIAN_C_TYPE_PARAM); | ||
570 | 571 | ||
571 | if (eina_strbuf_length_get(params)) | 572 | if (eina_strbuf_length_get(params)) |
572 | eina_strbuf_append(params, ", "); | 573 | eina_strbuf_append(params, ", "); |
@@ -646,7 +647,7 @@ _gen_func(const Eolian_Class *cl, const Eolian_Function *fid, | |||
646 | const Eolian_Expression *dfv = eolian_parameter_default_value_get(pr); | 647 | const Eolian_Expression *dfv = eolian_parameter_default_value_get(pr); |
647 | const char *prn = eolian_parameter_name_get(pr); | 648 | const char *prn = eolian_parameter_name_get(pr); |
648 | const Eolian_Type *pt = eolian_parameter_type_get(pr); | 649 | const Eolian_Type *pt = eolian_parameter_type_get(pr); |
649 | Eina_Stringshare *ptn = eolian_type_c_type_get(pt, EOLIAN_C_TYPE_PARAM); | 650 | Eina_Stringshare *ptn = eolian_parameter_c_type_get(pr, EINA_FALSE); |
650 | const Eolian_Typedecl *ptd = eolian_type_typedecl_get(pt); | 651 | const Eolian_Typedecl *ptd = eolian_type_typedecl_get(pt); |
651 | 652 | ||
652 | Eina_Bool had_star = ptn[strlen(ptn) - 1] == '*'; | 653 | Eina_Bool had_star = ptn[strlen(ptn) - 1] == '*'; |
@@ -720,8 +721,8 @@ _gen_func(const Eolian_Class *cl, const Eolian_Function *fid, | |||
720 | if (impl_same_class && eolian_implement_is_pure_virtual(impl, ftype)) | 721 | if (impl_same_class && eolian_implement_is_pure_virtual(impl, ftype)) |
721 | impl_need = EINA_FALSE; | 722 | impl_need = EINA_FALSE; |
722 | 723 | ||
723 | Eina_Stringshare *rtpn = rtp ? eolian_type_c_type_get(rtp, EOLIAN_C_TYPE_RETURN) | 724 | if (!rtpn) |
724 | : eina_stringshare_add("void"); | 725 | rtpn = eina_stringshare_add("void"); |
725 | 726 | ||
726 | char *cname = NULL, *cnamel = NULL, *ocnamel = NULL; | 727 | char *cname = NULL, *cnamel = NULL, *ocnamel = NULL; |
727 | eo_gen_class_names_get(cl, &cname, NULL, &cnamel); | 728 | eo_gen_class_names_get(cl, &cname, NULL, &cnamel); |
@@ -809,7 +810,7 @@ _gen_func(const Eolian_Class *cl, const Eolian_Function *fid, | |||
809 | if (rtp) | 810 | if (rtp) |
810 | { | 811 | { |
811 | eina_strbuf_append(buf, " return "); | 812 | eina_strbuf_append(buf, " return "); |
812 | _append_defval(buf, def_ret, rtp); | 813 | _append_defval(buf, def_ret, rtp, rtpn); |
813 | eina_strbuf_append(buf, ";\n"); | 814 | eina_strbuf_append(buf, ";\n"); |
814 | } | 815 | } |
815 | eina_strbuf_append(buf, "}\n\n"); | 816 | eina_strbuf_append(buf, "}\n\n"); |
@@ -837,12 +838,12 @@ _gen_func(const Eolian_Class *cl, const Eolian_Function *fid, | |||
837 | if (impl_same_class && !eolian_function_is_static(fid)) | 838 | if (impl_same_class && !eolian_function_is_static(fid)) |
838 | { | 839 | { |
839 | /* generate reflection implementation */ | 840 | /* generate reflection implementation */ |
840 | if (reflect_type) | 841 | if (reflect_param) |
841 | { | 842 | { |
842 | if (ftype == EOLIAN_PROP_GET) | 843 | if (ftype == EOLIAN_PROP_GET) |
843 | _gen_reflect_get(buf, cnamel, reflect_type, fid, refh); | 844 | _gen_reflect_get(buf, cnamel, reflect_param, fid, refh); |
844 | else | 845 | else |
845 | _gen_reflect_set(buf, cnamel, reflect_type, fid, refh); | 846 | _gen_reflect_set(buf, cnamel, reflect_param, fid, refh); |
846 | } | 847 | } |
847 | 848 | ||
848 | void *data; | 849 | void *data; |
@@ -893,7 +894,7 @@ _gen_func(const Eolian_Class *cl, const Eolian_Function *fid, | |||
893 | if (strcmp(rtpn, "void")) | 894 | if (strcmp(rtpn, "void")) |
894 | { | 895 | { |
895 | eina_strbuf_append_printf(buf, ", %s, ", rtpn); | 896 | eina_strbuf_append_printf(buf, ", %s, ", rtpn); |
896 | _append_defval(buf, def_ret, rtp); | 897 | _append_defval(buf, def_ret, rtp, rtpn); |
897 | } | 898 | } |
898 | 899 | ||
899 | if (fallback_free_ownership) | 900 | if (fallback_free_ownership) |
@@ -912,7 +913,7 @@ _gen_func(const Eolian_Class *cl, const Eolian_Function *fid, | |||
912 | eina_stringshare_del(eofn); | 913 | eina_stringshare_del(eofn); |
913 | } | 914 | } |
914 | if (impl_same_class && eolian_function_is_static(fid)) | 915 | if (impl_same_class && eolian_function_is_static(fid)) |
915 | _emit_class_function(buf, fid, rtp, params_full, ocnamel, func_suffix, params, eolian_function_full_c_name_get(fid, ftype)); | 916 | _emit_class_function(buf, fid, rtpn, params_full, ocnamel, func_suffix, params, eolian_function_full_c_name_get(fid, ftype)); |
916 | 917 | ||
917 | free(cname); | 918 | free(cname); |
918 | free(cnamel); | 919 | free(cnamel); |
@@ -1245,8 +1246,7 @@ _gen_params(const Eolian_Function *fid, Eolian_Function_Type ftype, | |||
1245 | EINA_ITERATOR_FOREACH(itr, pr) | 1246 | EINA_ITERATOR_FOREACH(itr, pr) |
1246 | { | 1247 | { |
1247 | const char *prn = eolian_parameter_name_get(pr); | 1248 | const char *prn = eolian_parameter_name_get(pr); |
1248 | const Eolian_Type *pt = eolian_parameter_type_get(pr); | 1249 | Eina_Stringshare *ptn = eolian_parameter_c_type_get(pr, EINA_FALSE); |
1249 | Eina_Stringshare *ptn = eolian_type_c_type_get(pt, EOLIAN_C_TYPE_PARAM); | ||
1250 | 1250 | ||
1251 | eina_strbuf_append(params, ", "); | 1251 | eina_strbuf_append(params, ", "); |
1252 | eina_strbuf_append(params, prn); | 1252 | eina_strbuf_append(params, prn); |
@@ -1276,7 +1276,7 @@ _gen_params(const Eolian_Function *fid, Eolian_Function_Type ftype, | |||
1276 | const char *prn = eolian_parameter_name_get(pr); | 1276 | const char *prn = eolian_parameter_name_get(pr); |
1277 | const Eolian_Type *pt = eolian_parameter_type_get(pr); | 1277 | const Eolian_Type *pt = eolian_parameter_type_get(pr); |
1278 | const Eolian_Typedecl *ptd = eolian_type_typedecl_get(pt); | 1278 | const Eolian_Typedecl *ptd = eolian_type_typedecl_get(pt); |
1279 | Eina_Stringshare *ptn = eolian_type_c_type_get(pt, EOLIAN_C_TYPE_PARAM); | 1279 | Eina_Stringshare *ptn = eolian_parameter_c_type_get(pr, EINA_FALSE); |
1280 | 1280 | ||
1281 | if (ptd && eolian_typedecl_type_get(ptd) == EOLIAN_TYPEDECL_FUNCTION_POINTER) | 1281 | if (ptd && eolian_typedecl_type_get(ptd) == EOLIAN_TYPEDECL_FUNCTION_POINTER) |
1282 | { | 1282 | { |
@@ -1339,6 +1339,7 @@ _gen_proto(const Eolian_Class *cl, const Eolian_Function *fid, | |||
1339 | 1339 | ||
1340 | Eina_Bool var_as_ret = EINA_FALSE; | 1340 | Eina_Bool var_as_ret = EINA_FALSE; |
1341 | const Eolian_Type *rtp = eolian_function_return_type_get(fid, ftype); | 1341 | const Eolian_Type *rtp = eolian_function_return_type_get(fid, ftype); |
1342 | Eina_Stringshare *rtpn = NULL; | ||
1342 | if ((ftype == EOLIAN_PROP_GET) && !rtp) | 1343 | if ((ftype == EOLIAN_PROP_GET) && !rtp) |
1343 | { | 1344 | { |
1344 | void *d1, *d2; | 1345 | void *d1, *d2; |
@@ -1347,6 +1348,7 @@ _gen_proto(const Eolian_Class *cl, const Eolian_Function *fid, | |||
1347 | { | 1348 | { |
1348 | Eolian_Function_Parameter *pr = d1; | 1349 | Eolian_Function_Parameter *pr = d1; |
1349 | rtp = eolian_parameter_type_get(pr); | 1350 | rtp = eolian_parameter_type_get(pr); |
1351 | rtpn = eolian_parameter_c_type_get(pr, EINA_FALSE); | ||
1350 | var_as_ret = EINA_TRUE; | 1352 | var_as_ret = EINA_TRUE; |
1351 | } | 1353 | } |
1352 | eina_iterator_free(itr); | 1354 | eina_iterator_free(itr); |
@@ -1355,7 +1357,8 @@ _gen_proto(const Eolian_Class *cl, const Eolian_Function *fid, | |||
1355 | eina_strbuf_append(buf, "EOLIAN static "); | 1357 | eina_strbuf_append(buf, "EOLIAN static "); |
1356 | if (rtp) | 1358 | if (rtp) |
1357 | { | 1359 | { |
1358 | Eina_Stringshare *rtpn = eolian_type_c_type_get(rtp, EOLIAN_C_TYPE_RETURN); | 1360 | if (!rtpn) |
1361 | rtpn = eolian_function_return_c_type_get(fid, ftype); | ||
1359 | eina_strbuf_append(buf, rtpn); | 1362 | eina_strbuf_append(buf, rtpn); |
1360 | eina_stringshare_del(rtpn); | 1363 | eina_stringshare_del(rtpn); |
1361 | } | 1364 | } |
diff --git a/src/bin/eolian/types.c b/src/bin/eolian/types.c index d45d1ba81b..e79b73b20c 100644 --- a/src/bin/eolian/types.c +++ b/src/bin/eolian/types.c | |||
@@ -41,9 +41,8 @@ _type_generate(const Eolian_State *state, const Eolian_Typedecl *tp, | |||
41 | Eina_Iterator *membs = eolian_typedecl_struct_fields_get(tp); | 41 | Eina_Iterator *membs = eolian_typedecl_struct_fields_get(tp); |
42 | EINA_ITERATOR_FOREACH(membs, memb) | 42 | EINA_ITERATOR_FOREACH(membs, memb) |
43 | { | 43 | { |
44 | const Eolian_Type *mtp = eolian_typedecl_struct_field_type_get(memb); | ||
45 | Eina_Stringshare *ct = NULL; | 44 | Eina_Stringshare *ct = NULL; |
46 | ct = eolian_type_c_type_get(mtp, EOLIAN_C_TYPE_DEFAULT); | 45 | ct = eolian_typedecl_struct_field_c_type_get(memb); |
47 | eina_strbuf_append_printf(buf, " %s%s%s;", | 46 | eina_strbuf_append_printf(buf, " %s%s%s;", |
48 | ct, strchr(ct, '*') ? "" : " ", | 47 | ct, strchr(ct, '*') ? "" : " ", |
49 | eolian_typedecl_struct_field_name_get(memb)); | 48 | eolian_typedecl_struct_field_name_get(memb)); |
@@ -137,8 +136,9 @@ _type_generate(const Eolian_State *state, const Eolian_Typedecl *tp, | |||
137 | eina_strbuf_append(buf, "void "); | 136 | eina_strbuf_append(buf, "void "); |
138 | else | 137 | else |
139 | { | 138 | { |
140 | Eina_Stringshare *ct = eolian_type_c_type_get(rtp, EOLIAN_C_TYPE_RETURN); | 139 | Eina_Stringshare *ct = eolian_function_return_c_type_get(fid, EOLIAN_FUNCTION_POINTER); |
141 | eina_strbuf_append_printf(buf, "%s ", ct); | 140 | eina_strbuf_append_printf(buf, "%s ", ct); |
141 | eina_stringshare_del(ct); | ||
142 | } | 142 | } |
143 | 143 | ||
144 | /* Function name */ | 144 | /* Function name */ |
diff --git a/src/tests/eolian/data/class_simple.eo b/src/tests/eolian/data/class_simple.eo index 8717145806..ad0589b3a7 100644 --- a/src/tests/eolian/data/class_simple.eo +++ b/src/tests/eolian/data/class_simple.eo | |||
@@ -31,9 +31,9 @@ class Class_Simple { | |||
31 | @in a: int; [[a]] | 31 | @in a: int; [[a]] |
32 | @inout b: char; | 32 | @inout b: char; |
33 | @out c: double (1337.6); | 33 | @out c: double (1337.6); |
34 | @in d: ptr(int); | 34 | @in d: int @by_ref; |
35 | } | 35 | } |
36 | return: ptr(char) (null); [[comment for method return]] | 36 | return: mstring (null); [[comment for method return]] |
37 | } | 37 | } |
38 | } | 38 | } |
39 | } | 39 | } |
diff --git a/src/tests/eolian/data/consts.eo b/src/tests/eolian/data/consts.eo index 2b2f9bf08e..9505e95387 100644 --- a/src/tests/eolian/data/consts.eo +++ b/src/tests/eolian/data/consts.eo | |||
@@ -7,7 +7,7 @@ class Consts { | |||
7 | @inout b: char; | 7 | @inout b: char; |
8 | @out c: double; | 8 | @out c: double; |
9 | } | 9 | } |
10 | return: ptr(char) (null); [[comment for method return]] | 10 | return: int; |
11 | } | 11 | } |
12 | } | 12 | } |
13 | } | 13 | } |
diff --git a/src/tests/eolian/data/object_impl.eo b/src/tests/eolian/data/object_impl.eo index db4c46d2b3..7fe8ce2e24 100644 --- a/src/tests/eolian/data/object_impl.eo +++ b/src/tests/eolian/data/object_impl.eo | |||
@@ -41,7 +41,7 @@ abstract Object_Impl extends Base { | |||
41 | @inout b: char; | 41 | @inout b: char; |
42 | @out c: double; | 42 | @out c: double; |
43 | } | 43 | } |
44 | return: ptr(char) (null); [[comment for method return]] | 44 | return: mstring (null); [[comment for method return]] |
45 | } | 45 | } |
46 | foo2 @const { | 46 | foo2 @const { |
47 | [[comment foo]] | 47 | [[comment foo]] |
diff --git a/src/tests/eolian/data/override.eo b/src/tests/eolian/data/override.eo index 221e12fc84..4cee6008d3 100644 --- a/src/tests/eolian/data/override.eo +++ b/src/tests/eolian/data/override.eo | |||
@@ -38,7 +38,7 @@ abstract Override extends Base { | |||
38 | params { | 38 | params { |
39 | @in idx: int; | 39 | @in idx: int; |
40 | @out a: int (250); | 40 | @out a: int (250); |
41 | @out str: ptr(char) (null); | 41 | @out str: mstring (null); |
42 | } | 42 | } |
43 | } | 43 | } |
44 | } | 44 | } |
diff --git a/src/tests/eolian/data/struct.eo b/src/tests/eolian/data/struct.eo index 80a4935ce3..57f250bdbe 100644 --- a/src/tests/eolian/data/struct.eo +++ b/src/tests/eolian/data/struct.eo | |||
@@ -1,5 +1,5 @@ | |||
1 | struct Named { | 1 | struct Named { |
2 | field: ptr(int); | 2 | field: int @by_ref; |
3 | something: string; | 3 | something: string; |
4 | } | 4 | } |
5 | 5 | ||
@@ -24,7 +24,7 @@ class Struct { | |||
24 | return: mstring @move; | 24 | return: mstring @move; |
25 | } | 25 | } |
26 | bar { | 26 | bar { |
27 | return: ptr(Named); | 27 | return: Named @by_ref; |
28 | } | 28 | } |
29 | } | 29 | } |
30 | } | 30 | } |
diff --git a/src/tests/eolian/eolian_parsing.c b/src/tests/eolian/eolian_parsing.c index 60d35150dc..7ef4387e1a 100644 --- a/src/tests/eolian/eolian_parsing.c +++ b/src/tests/eolian/eolian_parsing.c | |||
@@ -615,7 +615,6 @@ EFL_START_TEST(eolian_simple_parsing) | |||
615 | /* Method */ | 615 | /* Method */ |
616 | fail_if(!(fid = eolian_class_function_by_name_get(class, "foo", EOLIAN_METHOD))); | 616 | fail_if(!(fid = eolian_class_function_by_name_get(class, "foo", EOLIAN_METHOD))); |
617 | fail_if(!eolian_function_is_beta(fid)); | 617 | fail_if(!eolian_function_is_beta(fid)); |
618 | fail_if(!eolian_type_is_ptr(eolian_function_return_type_get(fid, EOLIAN_METHOD))); | ||
619 | /* Function return */ | 618 | /* Function return */ |
620 | tp = eolian_function_return_type_get(fid, EOLIAN_METHOD); | 619 | tp = eolian_function_return_type_get(fid, EOLIAN_METHOD); |
621 | fail_if(!tp); | 620 | fail_if(!tp); |
@@ -652,7 +651,7 @@ EFL_START_TEST(eolian_simple_parsing) | |||
652 | fail_if(!(eina_iterator_next(iter, (void**)¶m))); | 651 | fail_if(!(eina_iterator_next(iter, (void**)¶m))); |
653 | fail_if(eolian_parameter_direction_get(param) != EOLIAN_IN_PARAM); | 652 | fail_if(eolian_parameter_direction_get(param) != EOLIAN_IN_PARAM); |
654 | fail_if(strcmp(eolian_type_short_name_get(eolian_parameter_type_get(param)), "int")); | 653 | fail_if(strcmp(eolian_type_short_name_get(eolian_parameter_type_get(param)), "int")); |
655 | fail_if(!eolian_type_is_ptr(eolian_parameter_type_get(param))); | 654 | fail_if(!eolian_parameter_is_by_ref(param)); |
656 | fail_if(strcmp(eolian_parameter_name_get(param), "d")); | 655 | fail_if(strcmp(eolian_parameter_name_get(param), "d")); |
657 | fail_if(eina_iterator_next(iter, &dummy)); | 656 | fail_if(eina_iterator_next(iter, &dummy)); |
658 | eina_iterator_free(iter); | 657 | eina_iterator_free(iter); |
@@ -695,12 +694,12 @@ EFL_START_TEST(eolian_struct) | |||
695 | fail_if(strcmp(file, "struct.eo")); | 694 | fail_if(strcmp(file, "struct.eo")); |
696 | fail_if(!(field = eolian_typedecl_struct_field_get(tdl, "field"))); | 695 | fail_if(!(field = eolian_typedecl_struct_field_get(tdl, "field"))); |
697 | fail_if(!(ftype = eolian_typedecl_struct_field_type_get(field))); | 696 | fail_if(!(ftype = eolian_typedecl_struct_field_type_get(field))); |
698 | fail_if(!eolian_type_is_ptr(ftype)); | 697 | fail_if(!eolian_typedecl_struct_field_is_by_ref(field)); |
699 | fail_if(!(type_name = eolian_type_short_name_get(ftype))); | 698 | fail_if(!(type_name = eolian_type_short_name_get(ftype))); |
700 | fail_if(strcmp(type_name, "int")); | 699 | fail_if(strcmp(type_name, "int")); |
701 | fail_if(!(field = eolian_typedecl_struct_field_get(tdl, "something"))); | 700 | fail_if(!(field = eolian_typedecl_struct_field_get(tdl, "something"))); |
702 | fail_if(!(ftype = eolian_typedecl_struct_field_type_get(field))); | 701 | fail_if(!(ftype = eolian_typedecl_struct_field_type_get(field))); |
703 | fail_if(eolian_type_is_ptr(ftype)); | 702 | fail_if(eolian_typedecl_struct_field_is_by_ref(field)); |
704 | fail_if(!(type_name = eolian_typedecl_struct_field_c_type_get(field))); | 703 | fail_if(!(type_name = eolian_typedecl_struct_field_c_type_get(field))); |
705 | fail_if(strcmp(type_name, "const char *")); | 704 | fail_if(strcmp(type_name, "const char *")); |
706 | eina_stringshare_del(type_name); | 705 | eina_stringshare_del(type_name); |
@@ -728,7 +727,7 @@ EFL_START_TEST(eolian_struct) | |||
728 | fail_if(!(func = eolian_class_function_by_name_get(class, "bar", EOLIAN_METHOD))); | 727 | fail_if(!(func = eolian_class_function_by_name_get(class, "bar", EOLIAN_METHOD))); |
729 | fail_if(!(type = eolian_function_return_type_get(func, EOLIAN_METHOD))); | 728 | fail_if(!(type = eolian_function_return_type_get(func, EOLIAN_METHOD))); |
730 | fail_if(eolian_type_type_get(type) != EOLIAN_TYPE_REGULAR); | 729 | fail_if(eolian_type_type_get(type) != EOLIAN_TYPE_REGULAR); |
731 | fail_if(!eolian_type_is_ptr(type)); | 730 | fail_if(!eolian_function_return_is_by_ref(func, EOLIAN_METHOD)); |
732 | fail_if(!(tdl = eolian_type_typedecl_get(type))); | 731 | fail_if(!(tdl = eolian_type_typedecl_get(type))); |
733 | fail_if(eolian_typedecl_type_get(tdl) != EOLIAN_TYPEDECL_STRUCT); | 732 | fail_if(eolian_typedecl_type_get(tdl) != EOLIAN_TYPEDECL_STRUCT); |
734 | 733 | ||