summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2016-09-29 17:09:37 +0200
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2016-10-07 11:54:23 +0200
commit0306810d526137de063afa41d02a93717632c4ec (patch)
tree99e6076e46da610487d8a32cfb4b7154056d2d46
parent911a0847bec24ca1d1120970cf5f720536f19504 (diff)
eolian gen2: generate legacy API implementation stubs
-rw-r--r--src/bin/eolian2/sources.c72
1 files changed, 62 insertions, 10 deletions
diff --git a/src/bin/eolian2/sources.c b/src/bin/eolian2/sources.c
index b5c8b17bb2..5da860e3a5 100644
--- a/src/bin/eolian2/sources.c
+++ b/src/bin/eolian2/sources.c
@@ -37,7 +37,7 @@ _get_add_star(Eolian_Function_Type ftype, Eolian_Parameter_Dir pdir)
37static void 37static void
38_gen_func(const Eolian_Class *cl, const Eolian_Function *fid, 38_gen_func(const Eolian_Class *cl, const Eolian_Function *fid,
39 Eolian_Function_Type ftype, Eina_Strbuf *buf, 39 Eolian_Function_Type ftype, Eina_Strbuf *buf,
40 const Eolian_Implement *impl) 40 const Eolian_Implement *impl, Eina_Strbuf *lbuf)
41{ 41{
42 Eina_Bool is_empty = eolian_implement_is_empty(impl); 42 Eina_Bool is_empty = eolian_implement_is_empty(impl);
43 Eina_Bool is_auto = eolian_implement_is_auto(impl); 43 Eina_Bool is_auto = eolian_implement_is_auto(impl);
@@ -100,8 +100,15 @@ _gen_func(const Eolian_Class *cl, const Eolian_Function *fid,
100 eina_strbuf_append(params, ", "); 100 eina_strbuf_append(params, ", ");
101 eina_strbuf_append(params, prn); 101 eina_strbuf_append(params, prn);
102 102
103 eina_strbuf_append_printf(params_full, ", %s %s", ptn, prn); 103 eina_strbuf_append_printf(params_full, ", %s", ptn);
104 eina_strbuf_append_printf(params_full_imp, ", %s %s", ptn, prn); 104 eina_strbuf_append_printf(params_full_imp, ", %s", ptn);
105 if (!strchr(ptn, '*'))
106 {
107 eina_strbuf_append_char(params_full, ' ');
108 eina_strbuf_append_char(params_full_imp, ' ');
109 }
110 eina_strbuf_append(params_full, prn);
111 eina_strbuf_append(params_full_imp, prn);
105 if (is_empty) 112 if (is_empty)
106 eina_strbuf_append(params_full_imp, " EINA_UNUSED"); 113 eina_strbuf_append(params_full_imp, " EINA_UNUSED");
107 114
@@ -208,8 +215,8 @@ _gen_func(const Eolian_Class *cl, const Eolian_Function *fid,
208 Eina_Stringshare *rtpn = rtp ? eolian_type_c_type_get(rtp) 215 Eina_Stringshare *rtpn = rtp ? eolian_type_c_type_get(rtp)
209 : eina_stringshare_add("void"); 216 : eina_stringshare_add("void");
210 217
211 char *cnamel = NULL, *ocnamel = NULL; 218 char *cname = NULL, *cnameu = NULL, *cnamel = NULL, *ocnamel = NULL;
212 if (!eo_gen_class_names_get(cl, NULL, NULL, &cnamel)) 219 if (!eo_gen_class_names_get(cl, &cname, &cnameu, &cnamel))
213 goto end; 220 goto end;
214 if (!eo_gen_class_names_get(eolian_implement_class_get(impl), NULL, NULL, &ocnamel)) 221 if (!eo_gen_class_names_get(eolian_implement_class_get(impl), NULL, NULL, &ocnamel))
215 goto end; 222 goto end;
@@ -365,7 +372,6 @@ _gen_func(const Eolian_Class *cl, const Eolian_Function *fid,
365 372
366 Eina_Stringshare *eofn = eolian_function_full_c_name_get(fid, ftype, EINA_FALSE); 373 Eina_Stringshare *eofn = eolian_function_full_c_name_get(fid, ftype, EINA_FALSE);
367 eina_strbuf_append(buf, eofn); 374 eina_strbuf_append(buf, eofn);
368 eina_stringshare_del(eofn);
369 375
370 if (strcmp(rtpn, "void")) 376 if (strcmp(rtpn, "void"))
371 { 377 {
@@ -401,9 +407,48 @@ _gen_func(const Eolian_Class *cl, const Eolian_Function *fid,
401 "#define _EFL_OBJECT_API_BEFORE_HOOK\n#define _EFL_OBJECT_API_AFTER_HOOK\n" 407 "#define _EFL_OBJECT_API_BEFORE_HOOK\n#define _EFL_OBJECT_API_AFTER_HOOK\n"
402 "#define _EFL_OBJECT_API_CALL_HOOK(x) x\n"); 408 "#define _EFL_OBJECT_API_CALL_HOOK(x) x\n");
403 } 409 }
410
411 /* now try legacy */
412 Eina_Stringshare *lfn = eolian_function_full_c_name_get(fid, ftype, EINA_TRUE);
413 if (!eolian_function_is_beta(fid) && lfn)
414 {
415 eina_strbuf_append(lbuf, "\nEAPI ");
416 eina_strbuf_append(lbuf, rtpn);
417 eina_strbuf_append_char(lbuf, '\n');
418 eina_strbuf_append(lbuf, lfn);
419 /* param list */
420 eina_strbuf_append_char(lbuf, '(');
421 if (!eolian_function_is_class(fid))
422 {
423 if ((ftype == EOLIAN_PROP_GET) || eolian_function_object_is_const(fid))
424 eina_strbuf_append(lbuf, "const ");
425 eina_strbuf_append_printf(lbuf, "%s *obj", cname);
426 }
427 eina_strbuf_append(lbuf, eina_strbuf_string_get(params_full));
428 eina_strbuf_append(lbuf, ")\n{\n");
429 /* body */
430 if (strcmp(rtpn, "void"))
431 eina_strbuf_append(lbuf, " return ");
432 else
433 eina_strbuf_append(lbuf, " ");
434 eina_strbuf_append(lbuf, eofn);
435 eina_strbuf_append_char(lbuf, '(');
436 if (!eolian_function_is_class(fid))
437 eina_strbuf_append(lbuf, "obj");
438 else
439 eina_strbuf_append_printf(lbuf, "%s_%s", cnameu, _cl_type_str_get(cl));
440 if (has_params)
441 eina_strbuf_append_printf(lbuf, ", %s", eina_strbuf_string_get(params));
442 eina_strbuf_append(lbuf, ");\n}\n");
443 }
444
445 eina_stringshare_del(lfn);
446 eina_stringshare_del(eofn);
404 } 447 }
405 448
406end: 449end:
450 free(cname);
451 free(cnameu);
407 free(cnamel); 452 free(cnamel);
408 free(ocnamel); 453 free(ocnamel);
409 454
@@ -574,6 +619,8 @@ eo_gen_source_gen(const Eolian_Class *cl, Eina_Strbuf *buf)
574 eina_iterator_free(itr); 619 eina_iterator_free(itr);
575 } 620 }
576 621
622 Eina_Strbuf *lbuf = eina_strbuf_new();
623
577 /* method section */ 624 /* method section */
578 { 625 {
579 Eina_Iterator *itr = eolian_class_implements_get(cl); 626 Eina_Iterator *itr = eolian_class_implements_get(cl);
@@ -586,14 +633,14 @@ eo_gen_source_gen(const Eolian_Class *cl, Eina_Strbuf *buf)
586 { 633 {
587 case EOLIAN_PROP_GET: 634 case EOLIAN_PROP_GET:
588 case EOLIAN_PROP_SET: 635 case EOLIAN_PROP_SET:
589 _gen_func(cl, fid, ftype, buf, imp); 636 _gen_func(cl, fid, ftype, buf, imp, lbuf);
590 break; 637 break;
591 case EOLIAN_PROPERTY: 638 case EOLIAN_PROPERTY:
592 _gen_func(cl, fid, EOLIAN_PROP_SET, buf, imp); 639 _gen_func(cl, fid, EOLIAN_PROP_SET, buf, imp, lbuf);
593 _gen_func(cl, fid, EOLIAN_PROP_GET, buf, imp); 640 _gen_func(cl, fid, EOLIAN_PROP_GET, buf, imp, lbuf);
594 break; 641 break;
595 default: 642 default:
596 _gen_func(cl, fid, EOLIAN_UNRESOLVED, buf, imp); 643 _gen_func(cl, fid, EOLIAN_UNRESOLVED, buf, imp, lbuf);
597 } 644 }
598 } 645 }
599 eina_iterator_free(itr); 646 eina_iterator_free(itr);
@@ -664,6 +711,11 @@ eo_gen_source_gen(const Eolian_Class *cl, Eina_Strbuf *buf)
664 /* terminate inherits */ 711 /* terminate inherits */
665 eina_strbuf_append(buf, ", NULL);\n"); 712 eina_strbuf_append(buf, ", NULL);\n");
666 713
714 /* append legacy if there */
715 eina_strbuf_append(buf, eina_strbuf_string_get(lbuf));
716
717 eina_strbuf_free(lbuf);
718
667 /* and we're done */ 719 /* and we're done */
668 free(cname); 720 free(cname);
669 free(cnameu); 721 free(cnameu);