summaryrefslogtreecommitdiff
path: root/src/bin/eolian/main.c
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2015-10-12 11:35:59 +0100
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2015-10-12 11:35:59 +0100
commit89acf82bff2368dd310397fd788aa9db0d872716 (patch)
tree2d8fdbe55ec128051f679604aad13bbfbe58e8c9 /src/bin/eolian/main.c
parent3a600030e05ff99b761f3ffa9e9a1859d00b0beb (diff)
eolian generator: merge legacy and eo header gen entry points
Diffstat (limited to '')
-rw-r--r--src/bin/eolian/main.c74
1 files changed, 15 insertions, 59 deletions
diff --git a/src/bin/eolian/main.c b/src/bin/eolian/main.c
index 76de4681ca..61b2da6d6a 100644
--- a/src/bin/eolian/main.c
+++ b/src/bin/eolian/main.c
@@ -110,13 +110,13 @@ _write_file(char *filename, const Eina_Strbuf *buffer, Eina_Bool append)
110} 110}
111 111
112static Eina_Bool 112static Eina_Bool
113_generate_eo_header_file(char *filename, const char *eo_filename) 113_generate_header_file(char *filename, const char *eo_filename, Eina_Bool legacy)
114{ 114{
115 Eina_Bool ret = EINA_FALSE; 115 Eina_Bool ret = EINA_FALSE;
116 116
117 Eina_Strbuf *buffer = eina_strbuf_new(); 117 Eina_Strbuf *buffer = eina_strbuf_new();
118 118
119 if (!types_header_generate(eo_filename, buffer, EINA_TRUE, EINA_FALSE)) 119 if (!types_header_generate(eo_filename, buffer, EINA_TRUE, legacy))
120 { 120 {
121 fprintf(stderr, "eolian: could not generate types of '%s'\n", eo_filename); 121 fprintf(stderr, "eolian: could not generate types of '%s'\n", eo_filename);
122 goto end; 122 goto end;
@@ -138,7 +138,9 @@ _generate_eo_header_file(char *filename, const char *eo_filename)
138 const Eolian_Class *class = eolian_class_get_by_file(eo_filename); 138 const Eolian_Class *class = eolian_class_get_by_file(eo_filename);
139 if (class) 139 if (class)
140 { 140 {
141 if (!eo_header_generate(class, buffer)) 141 Eina_Bool gret = legacy ? legacy_header_generate(class, buffer)
142 : eo_header_generate(class, buffer);
143 if (!gret)
142 { 144 {
143 fprintf(stderr, "eolian: could not generate header for '%s'\n", 145 fprintf(stderr, "eolian: could not generate header for '%s'\n",
144 eolian_class_name_get(class)); 146 eolian_class_name_get(class));
@@ -146,9 +148,12 @@ _generate_eo_header_file(char *filename, const char *eo_filename)
146 } 148 }
147 } 149 }
148 150
149 buffer = _include_guard_enclose(_filename_get(filename), NULL, buffer); 151 if (class || !legacy)
150 if (_write_file(filename, buffer, EINA_FALSE)) 152 {
151 ret = EINA_TRUE; 153 buffer = _include_guard_enclose(_filename_get(filename), NULL, buffer);
154 if (_write_file(filename, buffer, EINA_FALSE))
155 ret = EINA_TRUE;
156 }
152end: 157end:
153 eina_strbuf_free(buffer); 158 eina_strbuf_free(buffer);
154 159
@@ -245,52 +250,6 @@ _generate_impl_c_file(char *filename, const char *eo_filename)
245 return ret; 250 return ret;
246} 251}
247 252
248// TODO join with header gen.
249static Eina_Bool
250_generate_legacy_header_file(char *filename, const char *eo_filename)
251{
252 Eina_Bool ret = EINA_FALSE;
253
254 Eina_Strbuf *buffer = eina_strbuf_new();
255
256 if (!types_header_generate(eo_filename, buffer, EINA_TRUE, EINA_TRUE))
257 {
258 fprintf(stderr, "eolian: could not generate types of '%s'\n", eo_filename);
259 goto end;
260 }
261 else
262 {
263 buffer = _include_guard_enclose(eo_filename, "TYPES", buffer);
264 }
265
266 Eina_Strbuf *ctbuf = eina_strbuf_new();
267 if (types_class_typedef_generate(eo_filename, ctbuf))
268 {
269 ctbuf = _include_guard_enclose(eo_filename, "CLASS_TYPE", ctbuf);
270 eina_strbuf_append_char(ctbuf, '\n');
271 eina_strbuf_prepend(buffer, eina_strbuf_string_get(ctbuf));
272 }
273 eina_strbuf_free(ctbuf);
274
275 const Eolian_Class *class = eolian_class_get_by_file(eo_filename);
276 if (class)
277 {
278 if (!legacy_header_generate(class, buffer))
279 {
280 fprintf(stderr, "eolian: could not generate header for '%s'\n",
281 eolian_class_name_get(class));
282 goto end;
283 }
284
285 buffer = _include_guard_enclose(_filename_get(filename), NULL, buffer);
286 if (_write_file(filename, buffer, EINA_FALSE))
287 ret = EINA_TRUE;
288 }
289end:
290 eina_strbuf_free(buffer);
291 return ret;
292}
293
294enum 253enum
295{ 254{
296 NO_WAY_GEN, 255 NO_WAY_GEN,
@@ -429,28 +388,25 @@ int main(int argc, char **argv)
429 case H_GEN: 388 case H_GEN:
430 { 389 {
431 INF("Generating header file %s\n", output_filename); 390 INF("Generating header file %s\n", output_filename);
432 if (legacy_support) 391 ret = !_generate_header_file(output_filename, eo_file_basename, legacy_support);
433 ret = ( _generate_legacy_header_file(output_filename, eo_file_basename) ? 0 : 1 );
434 else
435 ret = ( _generate_eo_header_file(output_filename, eo_file_basename) ? 0 : 1 );
436 break; 392 break;
437 } 393 }
438 case H_STUB_GEN: 394 case H_STUB_GEN:
439 { 395 {
440 INF("Generating stubs header file %s\n", output_filename); 396 INF("Generating stubs header file %s\n", output_filename);
441 ret = _generate_stub_header_file(output_filename, eo_file_basename) ? 0 : 1; 397 ret = !_generate_stub_header_file(output_filename, eo_file_basename);
442 break; 398 break;
443 } 399 }
444 case C_GEN: 400 case C_GEN:
445 { 401 {
446 INF("Generating source file %s\n", output_filename); 402 INF("Generating source file %s\n", output_filename);
447 ret = _generate_c_file(output_filename, eo_file_basename, !!legacy_support)?0:1; 403 ret = !_generate_c_file(output_filename, eo_file_basename, !!legacy_support);
448 break; 404 break;
449 } 405 }
450 case C_IMPL_GEN: 406 case C_IMPL_GEN:
451 { 407 {
452 INF("Generating user source file %s\n", output_filename); 408 INF("Generating user source file %s\n", output_filename);
453 ret = _generate_impl_c_file(output_filename, eo_file_basename) ? 0 : 1; 409 ret = !_generate_impl_c_file(output_filename, eo_file_basename);
454 break; 410 break;
455 } 411 }
456 default: 412 default: