summaryrefslogtreecommitdiff
path: root/src/bin/eolian/types_generator.c
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2015-06-05 12:15:51 +0100
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2015-06-05 12:15:51 +0100
commitac0113ba2b8fc9515448be594cc0dc3a9b1fa492 (patch)
tree59be45637446ac3c889425efdab90a707cede448 /src/bin/eolian/types_generator.c
parent51d9760fe648179aa660c893dbb965a7e5cc7f18 (diff)
eolian/generator: generation for new documentation system
This commit adds the necessary generator logic to emit doc comments from the new doc syntax. Old doc comments are kept in for the time being as they're used within the EFL but they will be removed eventually. This new generator focuses all the important code in one place, making usage easy. @feature
Diffstat (limited to '')
-rw-r--r--src/bin/eolian/types_generator.c46
1 files changed, 40 insertions, 6 deletions
diff --git a/src/bin/eolian/types_generator.c b/src/bin/eolian/types_generator.c
index d18a0df6d6..35e741d928 100644
--- a/src/bin/eolian/types_generator.c
+++ b/src/bin/eolian/types_generator.c
@@ -8,6 +8,7 @@
8 8
9#include "Eolian.h" 9#include "Eolian.h"
10#include "types_generator.h" 10#include "types_generator.h"
11#include "docs_generator.h"
11#include "common_funcs.h" 12#include "common_funcs.h"
12 13
13static char * 14static char *
@@ -48,8 +49,19 @@ _desc_generate(const char *desc, Eina_Strbuf *buf)
48static Eina_Strbuf * 49static Eina_Strbuf *
49_type_generate(const Eolian_Type *tp, Eina_Bool full) 50_type_generate(const Eolian_Type *tp, Eina_Bool full)
50{ 51{
51 Eina_Strbuf *buf = eina_strbuf_new(); 52 const char *cdesc = eolian_type_description_get(tp);
52 _desc_generate(eolian_type_description_get(tp), buf); 53 Eina_Strbuf *buf;
54 if (cdesc)
55 {
56 buf = eina_strbuf_new();
57 _desc_generate(cdesc, buf);
58 }
59 else
60 {
61 buf = docs_generate_full(eolian_type_documentation_get(tp), 0);
62 if (!buf) buf = eina_strbuf_new();
63 else eina_strbuf_append_char(buf, '\n');
64 }
53 Eolian_Type_Type tp_type = eolian_type_type_get(tp); 65 Eolian_Type_Type tp_type = eolian_type_type_get(tp);
54 switch(tp_type) 66 switch(tp_type)
55 { 67 {
@@ -78,13 +90,24 @@ _type_generate(const Eolian_Type *tp, Eina_Bool full)
78 Eina_Iterator *members = eolian_type_struct_fields_get(tp); 90 Eina_Iterator *members = eolian_type_struct_fields_get(tp);
79 EINA_ITERATOR_FOREACH(members, member) 91 EINA_ITERATOR_FOREACH(members, member)
80 { 92 {
81 const char *desc = eolian_type_struct_field_description_get(member);
82 const Eolian_Type *type = eolian_type_struct_field_type_get(member); 93 const Eolian_Type *type = eolian_type_struct_field_type_get(member);
83 Eina_Stringshare *c_type = eolian_type_c_type_get(type); 94 Eina_Stringshare *c_type = eolian_type_c_type_get(type);
84 eina_strbuf_append_printf(buf, " %s%s%s;", 95 eina_strbuf_append_printf(buf, " %s%s%s;",
85 c_type, strchr(c_type, '*')?"":" ", 96 c_type, strchr(c_type, '*')?"":" ",
86 eolian_type_struct_field_name_get(member)); 97 eolian_type_struct_field_name_get(member));
87 if (desc) eina_strbuf_append_printf(buf, " /** %s */", desc); 98 const char *fdesc = eolian_type_struct_field_description_get(member);
99 const Eolian_Documentation *fdoc
100 = eolian_type_struct_field_documentation_get(member);
101 if (fdesc) eina_strbuf_append_printf(buf, " /** %s */", fdesc);
102 else if (fdoc)
103 {
104 const char *obuf = eina_strbuf_string_get(buf);
105 Eina_Strbuf *fbuf = docs_generate_full(fdoc,
106 strrchr(obuf, '\n') - obuf + 1);
107 if (fbuf) eina_strbuf_append_printf(buf, " %s",
108 eina_strbuf_string_get(fbuf));
109 eina_strbuf_free(fbuf);
110 }
88 eina_strbuf_append(buf, "\n"); 111 eina_strbuf_append(buf, "\n");
89 } 112 }
90 eina_iterator_free(members); 113 eina_iterator_free(members);
@@ -111,7 +134,6 @@ _type_generate(const Eolian_Type *tp, Eina_Bool full)
111 Eina_Strbuf *membuf = eina_strbuf_new(); 134 Eina_Strbuf *membuf = eina_strbuf_new();
112 while (next) 135 while (next)
113 { 136 {
114 const char *desc = eolian_type_enum_field_description_get(member);
115 const Eolian_Expression *value = eolian_type_enum_field_value_get(member, EINA_FALSE); 137 const Eolian_Expression *value = eolian_type_enum_field_value_get(member, EINA_FALSE);
116 char *memb_u = strdup(eolian_type_enum_field_name_get(member)); 138 char *memb_u = strdup(eolian_type_enum_field_name_get(member));
117 eina_str_toupper(&memb_u); 139 eina_str_toupper(&memb_u);
@@ -138,7 +160,19 @@ _type_generate(const Eolian_Type *tp, Eina_Bool full)
138 next = eina_iterator_next(members, (void**)&member); 160 next = eina_iterator_next(members, (void**)&member);
139 if (next) 161 if (next)
140 eina_strbuf_append(buf, ","); 162 eina_strbuf_append(buf, ",");
141 if (desc) eina_strbuf_append_printf(buf, " /** %s */", desc); 163 const char *fdesc = eolian_type_enum_field_description_get(member);
164 const Eolian_Documentation *fdoc
165 = eolian_type_enum_field_documentation_get(member);
166 if (fdesc) eina_strbuf_append_printf(buf, " /** %s */", fdesc);
167 else if (fdoc)
168 {
169 const char *obuf = eina_strbuf_string_get(buf);
170 Eina_Strbuf *fbuf = docs_generate_full(fdoc,
171 strrchr(obuf, '\n') - obuf + 1);
172 if (fbuf) eina_strbuf_append_printf(buf, " %s",
173 eina_strbuf_string_get(fbuf));
174 eina_strbuf_free(fbuf);
175 }
142 eina_strbuf_append(buf, "\n"); 176 eina_strbuf_append(buf, "\n");
143 } 177 }
144 eina_strbuf_append_printf(buf, "} %s", name); 178 eina_strbuf_append_printf(buf, "} %s", name);