summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorYossi Kantor <yossi.kantor@samsung.com>2014-02-19 10:40:52 +0200
committerDaniel Zaoui <daniel.zaoui@samsung.com>2014-03-03 14:09:56 +0200
commitc7beca12eca4e05fee1a3e633d3194c8e2b853d1 (patch)
tree5c99a72d92eca1dcd3f08c355fd3a3a39c92b898 /src/bin
parent748a01c47fa44441ac163b3d12cd87a3ce320337 (diff)
Eolian: Class type and class constructor/destructor generation added
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/eolian/eo1_generator.c65
1 files changed, 60 insertions, 5 deletions
diff --git a/src/bin/eolian/eo1_generator.c b/src/bin/eolian/eo1_generator.c
index da6c27563d..5340ef5ead 100644
--- a/src/bin/eolian/eo1_generator.c
+++ b/src/bin/eolian/eo1_generator.c
@@ -14,19 +14,29 @@ EAPI Eo_Op @#OBJCLASS_BASE_ID = EO_NOOP;\n\
14"; 14";
15 15
16static const char 16static const char
17tmpl_dtor[] = "\
18_gen_@#class_class_destructor(Eo_Class *klass)\n\
19{\n\
20 _@#class_class_destructor(klass);\n\
21}\n\
22\n\
23";
24
25static const char
17tmpl_eo_src_end[] = "\ 26tmpl_eo_src_end[] = "\
18@#list_ctors_body\ 27@#list_ctors_body\
19\n\ 28\n\
20static void\n\ 29static void\n\
21_@#class_class_constructor(Eo_Class *klass)\n\ 30_gen_@#class_class_constructor(Eo_Class *klass)\n\
22{\n\ 31{\n\
23 const Eo_Op_Func_Description func_desc[] = {@#list_func\n\ 32 const Eo_Op_Func_Description func_desc[] = {@#list_func\n\
24 EO_OP_FUNC_SENTINEL\n\ 33 EO_OP_FUNC_SENTINEL\n\
25 };\n\ 34 };\n\
26 eo_class_funcs_set(klass, func_desc);\n\ 35 eo_class_funcs_set(klass, func_desc);\n\
27 _user_@#class_class_constructor(klass);\n\ 36@#ctor_func\
28}\n\ 37}\n\
29\n\ 38\n\
39@#dtor_func\
30static const Eo_Op_Description @#class_op_desc[] = {@#list_op\n\ 40static const Eo_Op_Description @#class_op_desc[] = {@#list_op\n\
31 EO_OP_DESCRIPTION_SENTINEL\n\ 41 EO_OP_DESCRIPTION_SENTINEL\n\
32};\n\ 42};\n\
@@ -38,12 +48,12 @@ static const Eo_Event_Description *@#class_event_desc[] = {@#list_evdesc\n\
38static const Eo_Class_Description @#class_class_desc = {\n\ 48static const Eo_Class_Description @#class_class_desc = {\n\
39 EO_VERSION,\n\ 49 EO_VERSION,\n\
40 \"@#Class\",\n\ 50 \"@#Class\",\n\
41 EO_CLASS_TYPE_REGULAR,\n\ 51 @#type_class,\n\
42 EO_CLASS_DESCRIPTION_OPS(&@#OBJCLASS_BASE_ID, @#class_op_desc, @#OBJCLASS_SUB_ID_LAST),\n\ 52 EO_CLASS_DESCRIPTION_OPS(&@#OBJCLASS_BASE_ID, @#class_op_desc, @#OBJCLASS_SUB_ID_LAST),\n\
43 @#class_event_desc,\n\ 53 @#class_event_desc,\n\
44 sizeof(@#Class_Data),\n\ 54 sizeof(@#Class_Data),\n\
45 _@#class_class_constructor,\n\ 55 _gen_@#class_class_constructor,\n\
46 NULL\n\ 56 @#dtor_name\n\
47};\n\ 57};\n\
48\n\ 58\n\
49EO_DEFINE_CLASS(@#objclass_class_get, &@#class_class_desc, @#list_inheritNULL);\ 59EO_DEFINE_CLASS(@#objclass_class_get, &@#class_class_desc, @#list_inheritNULL);\
@@ -477,6 +487,31 @@ eo1_source_end_generate(const char *classname, Eina_Strbuf *buf)
477 const Eina_List *itr; 487 const Eina_List *itr;
478 Eolian_Function fn; 488 Eolian_Function fn;
479 489
490 const char *str_classtype = NULL;
491 switch(eolian_class_type_get(classname))
492 {
493 case EOLIAN_CLASS_REGULAR:
494 str_classtype = "EO_CLASS_TYPE_REGULAR";
495 break;
496 case EOLIAN_CLASS_ABSTRACT:
497 str_classtype = "EO_CLASS_TYPE_REGULAR_NO_INSTANT";
498 break;
499 case EOLIAN_CLASS_MIXIN:
500 str_classtype = "EO_CLASS_TYPE_MIXIN";
501 break;
502 case EOLIAN_CLASS_INTERFACE:
503 str_classtype = "EO_CLASS_TYPE_INTERFACE";
504 break;
505 default:
506 break;
507 }
508
509 if (!str_classtype)
510 {
511 printf ("Unknown class type for class %s !\n", classname);
512 return EINA_FALSE;
513 }
514
480 Eina_Strbuf *str_end = eina_strbuf_new(); 515 Eina_Strbuf *str_end = eina_strbuf_new();
481 Eina_Strbuf *tmpbuf = eina_strbuf_new(); 516 Eina_Strbuf *tmpbuf = eina_strbuf_new();
482 Eina_Strbuf *str_op = eina_strbuf_new(); 517 Eina_Strbuf *str_op = eina_strbuf_new();
@@ -486,6 +521,26 @@ eo1_source_end_generate(const char *classname, Eina_Strbuf *buf)
486 521
487 _template_fill(str_end, tmpl_eo_src_end, classname, "", EINA_TRUE); 522 _template_fill(str_end, tmpl_eo_src_end, classname, "", EINA_TRUE);
488 523
524 eina_strbuf_replace_all(str_end, "@#type_class", str_classtype);
525
526 if (eolian_class_dtor_enable_get(classname))
527 {
528 _template_fill(tmpbuf, tmpl_dtor, classname, "", EINA_TRUE);
529 eina_strbuf_replace_all(str_end, "@#dtor_func", eina_strbuf_string_get(tmpbuf));
530 _template_fill(tmpbuf, "_gen_@#class_class_destructor", classname, "", EINA_TRUE);
531 eina_strbuf_replace_all(str_end, "@#dtor_name", eina_strbuf_string_get(tmpbuf));
532 }
533 else
534 {
535 eina_strbuf_replace_all(str_end, "@#dtor_func", "");
536 eina_strbuf_replace_all(str_end, "@#dtor_name", "NULL");
537 }
538
539 eina_strbuf_reset(tmpbuf);
540 if (eolian_class_ctor_enable_get(classname))
541 _template_fill(tmpbuf, " _@#class_class_constructor(klass);\n", classname, "", EINA_TRUE);
542 eina_strbuf_replace_all(str_end, "@#ctor_func", eina_strbuf_string_get(tmpbuf));
543
489 // default constructor 544 // default constructor
490 Eolian_Function ctor_fn = eolian_class_default_constructor_get(classname); 545 Eolian_Function ctor_fn = eolian_class_default_constructor_get(classname);
491 if (ctor_fn) 546 if (ctor_fn)