summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYakov Goldberg <yakov.g@samsung.com>2014-05-22 19:46:38 +0300
committerYakov Goldberg <yakov.g@samsung.com>2014-05-25 15:57:49 +0300
commit1b721005b3636f0674f9c0a4dca339a3467af6ea (patch)
treef185907e397da098bdd75f74377a303ff15214a0
parent374590f25588c0175a156a805f4fcc118f895d93 (diff)
generator: generate code, json or both
-rw-r--r--src/bin/egui_gui/egui_logic.c4
-rw-r--r--src/bin/main.c44
-rw-r--r--src/lib/generator.c211
-rw-r--r--src/lib/generator.h16
4 files changed, 194 insertions, 81 deletions
diff --git a/src/bin/egui_gui/egui_logic.c b/src/bin/egui_gui/egui_logic.c
index 46283e8..cd0c72b 100644
--- a/src/bin/egui_gui/egui_logic.c
+++ b/src/bin/egui_gui/egui_logic.c
@@ -174,7 +174,7 @@ _on_fs_done(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event)
174 { 174 {
175 gui_context_project_name_set(_active_context_get(), filename); 175 gui_context_project_name_set(_active_context_get(), filename);
176 gui_context_project_path_set(_active_context_get(), (const char *) parent_dir); 176 gui_context_project_path_set(_active_context_get(), (const char *) parent_dir);
177 generator_ctx_source_generate(_active_context_get(), parent_dir); 177 generator_ctx_source_generate(_active_context_get(), parent_dir, GENERATION_C, GENERATE_JSON_CODE);
178 _canvas_name_update(_active_context_get()); 178 _canvas_name_update(_active_context_get());
179 } 179 }
180 free(parent_dir); 180 free(parent_dir);
@@ -286,7 +286,7 @@ _project_save(Gui_Context *ctx)
286 _fs_save_as_open(); 286 _fs_save_as_open();
287 return; 287 return;
288 } 288 }
289 generator_ctx_source_generate(ctx, dir); 289 generator_ctx_source_generate(ctx, dir, GENERATION_C, GENERATE_JSON_CODE);
290} 290}
291 291
292static void 292static void
diff --git a/src/bin/main.c b/src/bin/main.c
index fce270e..4e23f59 100644
--- a/src/bin/main.c
+++ b/src/bin/main.c
@@ -11,7 +11,7 @@
11#endif 11#endif
12 12
13static Eina_Bool 13static Eina_Bool
14_generate(const char *filename, const char* path, const char *new_project_name) 14_generate(const char *filename, const char* path, const char *new_project_name, Generator_Export_Format format, Generator_Export_Mode mode)
15{ 15{
16 Gui_Context *ctx; 16 Gui_Context *ctx;
17 ctx = gui_context_new();; 17 ctx = gui_context_new();;
@@ -32,7 +32,7 @@ _generate(const char *filename, const char* path, const char *new_project_name)
32 { 32 {
33 gui_context_project_name_set(ctx, new_project_name); 33 gui_context_project_name_set(ctx, new_project_name);
34 } 34 }
35 generator_ctx_source_generate(ctx, path); 35 generator_ctx_source_generate(ctx, path, format, mode);
36 gui_context_del(ctx); 36 gui_context_del(ctx);
37 return EINA_TRUE; 37 return EINA_TRUE;
38} 38}
@@ -88,7 +88,8 @@ _help()
88 "Options:\n" 88 "Options:\n"
89 " -f FILENAME\n" 89 " -f FILENAME\n"
90 " -s - simulate\n" 90 " -s - simulate\n"
91 " -g - generate\n" 91 " -e - export format. (-e c)\n"
92 " --json - insert JSON descriptions into code\n"
92 " -p PATH in generate mode. Current dir by default\n" 93 " -p PATH in generate mode. Current dir by default\n"
93 " -o NAME in generate mode\n"); 94 " -o NAME in generate mode\n");
94} 95}
@@ -104,6 +105,8 @@ main(int argc, char **argv)
104 const char *path = ".", *new_project_name = NULL, *target_name = NULL; 105 const char *path = ".", *new_project_name = NULL, *target_name = NULL;
105 char *filename = NULL; 106 char *filename = NULL;
106 const char *mode = NULL; 107 const char *mode = NULL;
108 Generator_Export_Format export_format = GENERATION_C;
109 Generator_Export_Mode export_mode = GENERATE_NONE;
107 int i; 110 int i;
108 111
109 elm_init(argc, argv); 112 elm_init(argc, argv);
@@ -134,19 +137,35 @@ main(int argc, char **argv)
134 goto end; 137 goto end;
135 } 138 }
136 } 139 }
137 else if ((!strcmp(argv[i], "-s"))) 140 else if (!strcmp(argv[i], "-s"))
138 { 141 {
139 mode = "-s"; 142 mode = "-s";
140 } 143 }
141 else if ((!strcmp(argv[i], "-g")))
142 {
143 mode = "-g";
144 }
145 else if ((!strcmp(argv[i], "-p")) && (i < (argc - 1))) 144 else if ((!strcmp(argv[i], "-p")) && (i < (argc - 1)))
146 { 145 {
147 i++; 146 i++;
148 path = argv[i]; 147 path = argv[i];
149 } 148 }
149 else if ((!strcmp(argv[i], "-e")) && (i < (argc - 1)))
150 {
151 mode = "-e";
152 i++;
153 const char* format = argv[i];
154 export_mode = export_mode | GENERATE_CODE;
155 if (!strcmp(format, "cpp"))
156 {
157 export_format = GENERATION_CPP;
158 }
159 else if (!strcmp(format, "c"))
160 {
161 export_format = GENERATION_C;
162 }
163 else
164 {
165 _help();
166 return 1;
167 }
168 }
150 else if ((!strcmp(argv[i], "-t")) && (i < (argc - 1))) 169 else if ((!strcmp(argv[i], "-t")) && (i < (argc - 1)))
151 { 170 {
152 i++; 171 i++;
@@ -157,6 +176,11 @@ main(int argc, char **argv)
157 i++; 176 i++;
158 new_project_name = argv[i]; 177 new_project_name = argv[i];
159 } 178 }
179 else if (!strcmp(argv[i], "--json"))
180 {
181 mode = "-e";
182 export_mode = export_mode | GENERATE_JSON;
183 }
160 } 184 }
161 185
162 if (mode == NULL) 186 if (mode == NULL)
@@ -179,7 +203,7 @@ main(int argc, char **argv)
179 if (!target_name) target_name = "Desktop"; 203 if (!target_name) target_name = "Desktop";
180 _simulate(filename, target_name); 204 _simulate(filename, target_name);
181 } 205 }
182 else if (!strcmp(mode, "-g")) 206 else if (!strcmp(mode, "-e"))
183 { 207 {
184 if (!filename) 208 if (!filename)
185 { 209 {
@@ -188,7 +212,7 @@ main(int argc, char **argv)
188 } 212 }
189 else 213 else
190 { 214 {
191 _generate(filename, path, new_project_name); 215 _generate(filename, path, new_project_name, export_format, export_mode);
192 } 216 }
193 } 217 }
194 218
diff --git a/src/lib/generator.c b/src/lib/generator.c
index 674627f..50d48ab 100644
--- a/src/lib/generator.c
+++ b/src/lib/generator.c
@@ -21,6 +21,9 @@ typedef enum
21 VAR_SEQUENCE 21 VAR_SEQUENCE
22} Variable_Type; 22} Variable_Type;
23 23
24
25static Generator_Export_Mode _export_mode;
26
24/* Structure to save variable's names of widgets and items, 27/* Structure to save variable's names of widgets and items,
25 * which must be declared in the beginning of func or globally. */ 28 * which must be declared in the beginning of func or globally. */
26typedef struct 29typedef struct
@@ -209,15 +212,25 @@ _format_string_add(const Gui_Context *ctx, Gui_Value *gui_value, Eina_Strbuf *p)
209static Eina_Bool 212static Eina_Bool
210_wdg_prop_add_generate(Gui_Session *session EINA_UNUSED, const Gui_Widget *wdg, const Gui_Widget_Property *prop, void *data) 213_wdg_prop_add_generate(Gui_Session *session EINA_UNUSED, const Gui_Widget *wdg, const Gui_Widget_Property *prop, void *data)
211{ 214{
215 Eina_Bool ret = EINA_TRUE;
212 Function_Context *foo_ctx = data; 216 Function_Context *foo_ctx = data;
213 return eo_do(C_generator, generator_interface_widget_property_add(wdg, prop, foo_ctx->buf)); 217 if (_export_mode & GENERATE_CODE)
218 {
219 ret = eo_do(C_generator, generator_interface_widget_property_add(wdg, prop, foo_ctx->buf));
220 }
221 return ret;
214} 222}
215 223
216static Eina_Bool 224static Eina_Bool
217_content_set_generate(Gui_Session *session EINA_UNUSED, const Gui_Widget *wdg, const Gui_Widget_Property *prop, void *data) 225_content_set_generate(Gui_Session *session EINA_UNUSED, const Gui_Widget *wdg, const Gui_Widget_Property *prop, void *data)
218{ 226{
219 Function_Context *foo_ctx = data; 227 Function_Context *foo_ctx = data;
220 return eo_do(C_generator, generator_interface_widget_content_set(wdg, prop, foo_ctx->buf)); 228 Eina_Bool ret = EINA_TRUE;
229 if (_export_mode & GENERATE_CODE)
230 {
231 eo_do(C_generator, ret = generator_interface_widget_content_set(wdg, prop, foo_ctx->buf));
232 }
233 return ret;
221} 234}
222 235
223/* Recursively iteration function, generate items creation code. */ 236/* Recursively iteration function, generate items creation code. */
@@ -277,7 +290,10 @@ _item_iterate(Gui_Session *session, Function_Context *foo_ctx, const Gui_Widget_
277 foo_ctx->declarations = eina_list_append(foo_ctx->declarations, item_vd); 290 foo_ctx->declarations = eina_list_append(foo_ctx->declarations, item_vd);
278 } 291 }
279 292
280 eo_do(C_generator, generator_interface_widget_item_add(wdg, wit, wit_name, foo_ctx->buf)); 293 if (_export_mode & GENERATE_CODE)
294 {
295 eo_do(C_generator, generator_interface_widget_item_add(wdg, wit, wit_name, foo_ctx->buf));
296 }
281 297
282 if (wdg_item_public_get(wit)) 298 if (wdg_item_public_get(wit))
283 { 299 {
@@ -333,7 +349,13 @@ _wdg_add_generate(Gui_Session *session, const Gui_Widget *wdg, void *data)
333 } 349 }
334 350
335 Function_Context *foo_ctx = data; 351 Function_Context *foo_ctx = data;
336 if (eo_do(C_generator, generator_interface_widget_create(wdg, foo_ctx->buf))) 352 Eina_Bool ret = EINA_TRUE;
353
354 if (_export_mode & GENERATE_CODE)
355 {
356 ret = eo_do(C_generator, ret = generator_interface_widget_create(wdg, foo_ctx->buf));
357 }
358 if (ret)
337 { 359 {
338 session_wdg_existence_set(session, wdg, EINA_TRUE); 360 session_wdg_existence_set(session, wdg, EINA_TRUE);
339 if (wdg_public_get(wdg)) 361 if (wdg_public_get(wdg))
@@ -360,10 +382,14 @@ _iter_widget(Gui_Session *session, Global_Gen_Context *gl_ctx, Function_Context
360 Variable_Data *vd = VAR_DATA_NEW(VAR_EO, wdg_name_get(wdg)); 382 Variable_Data *vd = VAR_DATA_NEW(VAR_EO, wdg_name_get(wdg));
361 foo_ctx->declarations = eina_list_append(foo_ctx->declarations, vd); 383 foo_ctx->declarations = eina_list_append(foo_ctx->declarations, vd);
362 384
385
363 /* Generate and save json description. */ 386 /* Generate and save json description. */
364 char *jsnstr = _wdg_to_json_str_get(wdg); 387 if (_export_mode & GENERATE_JSON)
365 eina_strbuf_append_printf(foo_ctx->buf, "/* @egui\n%s\n@!egui */\n", jsnstr); 388 {
366 free(jsnstr); 389 char *jsnstr = _wdg_to_json_str_get(wdg);
390 eina_strbuf_append_printf(foo_ctx->buf, "/* @egui\n%s\n@!egui */\n", jsnstr);
391 free(jsnstr);
392 }
367 393
368 if (manager_widget_create(session, wdg, MODE_GENERATOR, foo_ctx)) 394 if (manager_widget_create(session, wdg, MODE_GENERATOR, foo_ctx))
369 { 395 {
@@ -379,7 +405,6 @@ _iter_widget(Gui_Session *session, Global_Gen_Context *gl_ctx, Function_Context
379 _wdg_prop_add_generate(session, wdg, prop, foo_ctx); 405 _wdg_prop_add_generate(session, wdg, prop, foo_ctx);
380 } 406 }
381 } 407 }
382
383} 408}
384 409
385/* Generate a creation function for a widget. */ 410/* Generate a creation function for a widget. */
@@ -397,30 +422,36 @@ _wdg_creation_function_generate(Gui_Session *session, Gui_Widget *wdg, Global_Ge
397 422
398 _iter_widget(session, gl_ctx, foo_ctx, wdg); 423 _iter_widget(session, gl_ctx, foo_ctx, wdg);
399 424
400 eina_strbuf_append_printf(gl_ctx->buf, "static void\n_create_%s()\n{\n", wdg_name); 425 if (_export_mode & GENERATE_CODE)
401
402 /* Add definitions of variables */
403 Variable_Data *vd;
404 EINA_LIST_FOREACH(foo_ctx->declarations, itr, vd)
405 { 426 {
406 if (vd->var_type == VAR_EO) 427 eina_strbuf_append_printf(gl_ctx->buf, "static void\n_create_%s()\n{\n", wdg_name);
428
429 /* Add definitions of variables */
430 Variable_Data *vd;
431 EINA_LIST_FOREACH(foo_ctx->declarations, itr, vd)
407 { 432 {
408 if (_is_in_list(gl_ctx->global_names, vd->var_name)) 433 if (vd->var_type == VAR_EO)
409 { 434 {
410 continue; 435 if (_is_in_list(gl_ctx->global_names, vd->var_name))
436 {
437 continue;
438 }
439 eina_strbuf_append_printf(gl_ctx->buf, " Eo *%s;\n", vd->var_name);
440 }
441 else if (vd->var_type == VAR_ITEM)
442 {
443 eina_strbuf_append_printf(gl_ctx->buf, " Elm_Object_Item *%s;\n", vd->var_name);
411 } 444 }
412 eina_strbuf_append_printf(gl_ctx->buf, " Eo *%s;\n", vd->var_name);
413 }
414 else if (vd->var_type == VAR_ITEM)
415 {
416 eina_strbuf_append_printf(gl_ctx->buf, " Elm_Object_Item *%s;\n", vd->var_name);
417 } 445 }
418 } 446 }
447
419 eina_strbuf_append_printf(gl_ctx->buf, "\n%s", eina_strbuf_string_get(foo_ctx->buf)); 448 eina_strbuf_append_printf(gl_ctx->buf, "\n%s", eina_strbuf_string_get(foo_ctx->buf));
449 if (_export_mode & GENERATE_CODE)
450 {
451 eina_strbuf_append_printf(gl_ctx->buf, "}\n\n");
452 }
420 453
421 _function_ctx_free(foo_ctx); 454 _function_ctx_free(foo_ctx);
422
423 eina_strbuf_append_printf(gl_ctx->buf, "}\n\n");
424} 455}
425 456
426static void 457static void
@@ -443,11 +474,17 @@ _sequence_generate(Gui_Session *session, Gui_Sequence *seq, Global_Gen_Context *
443 foo_ctx->gl_ctx = gl_ctx; 474 foo_ctx->gl_ctx = gl_ctx;
444 475
445 /* Generate and save json description. */ 476 /* Generate and save json description. */
446 char *jsnstr = _seq_to_json_str_get(seq); 477 if (_export_mode & GENERATE_JSON)
447 eina_strbuf_append_printf(foo_ctx->buf, "/* @egui\n%s\n@!egui */\n", jsnstr); 478 {
448 free(jsnstr); 479 char *jsnstr = _seq_to_json_str_get(seq);
480 eina_strbuf_append_printf(foo_ctx->buf, "/* @egui\n%s\n@!egui */\n", jsnstr);
481 free(jsnstr);
482 }
449 483
450 eo_do(C_generator, generator_interface_sequence_begin_generate(seq, foo_ctx->buf)); 484 if (_export_mode & GENERATE_CODE)
485 {
486 eo_do(C_generator, generator_interface_sequence_begin_generate(seq, foo_ctx->buf));
487 }
451 488
452 /* if sequence is public, need to declare it in header. */ 489 /* if sequence is public, need to declare it in header. */
453 if (sequence_public_get(seq)) 490 if (sequence_public_get(seq))
@@ -475,7 +512,10 @@ _sequence_generate(Gui_Session *session, Gui_Sequence *seq, Global_Gen_Context *
475 gl_ctx->global_names = eina_list_append(gl_ctx->global_names, vd); 512 gl_ctx->global_names = eina_list_append(gl_ctx->global_names, vd);
476 } 513 }
477 _wdg_creation_function_generate(session, w, gl_ctx); 514 _wdg_creation_function_generate(session, w, gl_ctx);
478 eo_do(C_generator, generator_interface_widget_creation_invoke(w, foo_ctx->buf)); 515 if (_export_mode & GENERATE_CODE)
516 {
517 eo_do(C_generator, generator_interface_widget_creation_invoke(w, foo_ctx->buf));
518 }
479 break; 519 break;
480 } 520 }
481 case MODIF_ACTION: 521 case MODIF_ACTION:
@@ -517,7 +557,10 @@ _sequence_generate(Gui_Session *session, Gui_Sequence *seq, Global_Gen_Context *
517 } 557 }
518 case USER_ACTION: 558 case USER_ACTION:
519 { 559 {
520 eo_do(C_generator, generator_interface_user_callback_invoke(action, foo_ctx->buf)); 560 if (_export_mode & GENERATE_CODE)
561 {
562 eo_do(C_generator, generator_interface_user_callback_invoke(action, foo_ctx->buf));
563 }
521 break; 564 break;
522 } 565 }
523 case NO_ACTION: 566 case NO_ACTION:
@@ -526,8 +569,10 @@ _sequence_generate(Gui_Session *session, Gui_Sequence *seq, Global_Gen_Context *
526 printf("ZZZ - Fix here %s-%d\n", __FUNCTION__, __LINE__); 569 printf("ZZZ - Fix here %s-%d\n", __FUNCTION__, __LINE__);
527 } 570 }
528 } 571 }
529 572 if (_export_mode & GENERATE_CODE)
530 eo_do(C_generator, generator_interface_sequence_end_generate(seq, foo_ctx->buf)); 573 {
574 eo_do(C_generator, generator_interface_sequence_end_generate(seq, foo_ctx->buf));
575 }
531 576
532 eina_strbuf_append_printf(gl_ctx->buf, "\n%s", eina_strbuf_string_get(foo_ctx->buf)); 577 eina_strbuf_append_printf(gl_ctx->buf, "\n%s", eina_strbuf_string_get(foo_ctx->buf));
533 578
@@ -565,11 +610,14 @@ _wdg_cb_add_generate(Gui_Session *session, const Gui_Widget *wdg, const Gui_Widg
565 } 610 }
566 cb_name = resource_value_get(res); 611 cb_name = resource_value_get(res);
567 612
568 const char *event_name = _c_plugin_eo_event_name_get(wdg_class_name_get(wdg), cb_type); 613 if (_export_mode & GENERATE_CODE)
569 if (event_name) 614 {
570 eina_strbuf_append_printf(foo_ctx->buf, " eo_do(%s, eo_event_callback_add(%s, %s, NULL));\n", 615 const char *event_name = _c_plugin_eo_event_name_get(wdg_class_name_get(wdg), cb_type);
571 wdg_name_get(wdg), event_name, 616 if (event_name)
572 cb_name); 617 eina_strbuf_append_printf(foo_ctx->buf, " eo_do(%s, eo_event_callback_add(%s, %s, NULL));\n",
618 wdg_name_get(wdg), event_name,
619 cb_name);
620 }
573 621
574 return ret; 622 return ret;
575} 623}
@@ -672,43 +720,51 @@ _ctx_to_file_save(Gui_Context *ctx, const char *path)
672 gl_gen_ctx.global_names = NULL; 720 gl_gen_ctx.global_names = NULL;
673 gl_gen_ctx.public_names = NULL; 721 gl_gen_ctx.public_names = NULL;
674 722
675 eo_do(C_generator, generator_interface_source_preamble_generate(project, gl_gen_ctx.buf)); 723 if (_export_mode & GENERATE_CODE)
676 eina_strbuf_append_printf(gl_gen_ctx.buf, "__GLOBAL_NAMES__");
677
678 /*Add generation of Resources. */
679 char *json_str = NULL;
680 json_str = _resources_to_json(ctx);
681 if (json_str)
682 { 724 {
683 eina_strbuf_append_printf(gl_gen_ctx.buf, "/* @egui\n%s\n@!egui */\n", json_str); 725 eo_do(C_generator, generator_interface_source_preamble_generate(project, gl_gen_ctx.buf));
684 free(json_str); 726 eina_strbuf_append_printf(gl_gen_ctx.buf, "__GLOBAL_NAMES__");
685 } 727 }
686 json_str = _settings_to_json(ctx); 728
687 if (json_str) 729 /*Add generation of Resources. */
730 if (_export_mode & GENERATE_JSON)
688 { 731 {
689 eina_strbuf_append_printf(gl_gen_ctx.buf, "/* @egui\n%s\n@!egui */\n", json_str); 732 char *json_str = NULL;
690 free(json_str); 733 json_str = _resources_to_json(ctx);
734 if (json_str)
735 {
736 eina_strbuf_append_printf(gl_gen_ctx.buf, "/* @egui\n%s\n@!egui */\n", json_str);
737 free(json_str);
738 }
739 json_str = _settings_to_json(ctx);
740 if (json_str)
741 {
742 eina_strbuf_append_printf(gl_gen_ctx.buf, "/* @egui\n%s\n@!egui */\n", json_str);
743 free(json_str);
744 }
691 } 745 }
692 746
693 /* Add declarations of resource callbacks. */ 747 /* Add declarations of resource callbacks. */
694 Gui_Resource *res; 748 if (_export_mode & GENERATE_CODE)
695 Eina_List *res_lst = (Eina_List *) gui_context_resource_list_get(ctx, RESOURCE_EO_CALLBACK);
696 EINA_LIST_FOREACH(res_lst, itr, res)
697 { 749 {
698 eo_do(C_generator, generator_interface_resource_generate(res, gl_gen_ctx.buf)); 750 Gui_Resource *res;
699 } 751 Eina_List *res_lst = (Eina_List *) gui_context_resource_list_get(ctx, RESOURCE_EO_CALLBACK);
700 res_lst = (Eina_List *) gui_context_resource_list_get(ctx, RESOURCE_EVAS_SMART_CALLBACK); 752 EINA_LIST_FOREACH(res_lst, itr, res)
701 EINA_LIST_FOREACH(res_lst, itr, res) 753 {
702 { 754 eo_do(C_generator, generator_interface_resource_generate(res, gl_gen_ctx.buf));
703 eo_do(C_generator, generator_interface_resource_generate(res, gl_gen_ctx.buf)); 755 }
704 } 756 res_lst = (Eina_List *) gui_context_resource_list_get(ctx, RESOURCE_EVAS_SMART_CALLBACK);
705 res_lst = (Eina_List *) gui_context_resource_list_get(ctx, RESOURCE_EVAS_CALLBACK); 757 EINA_LIST_FOREACH(res_lst, itr, res)
706 EINA_LIST_FOREACH(res_lst, itr, res) 758 {
707 { 759 eo_do(C_generator, generator_interface_resource_generate(res, gl_gen_ctx.buf));
708 eo_do(C_generator, generator_interface_resource_generate(res, gl_gen_ctx.buf)); 760 }
761 res_lst = (Eina_List *) gui_context_resource_list_get(ctx, RESOURCE_EVAS_CALLBACK);
762 EINA_LIST_FOREACH(res_lst, itr, res)
763 {
764 eo_do(C_generator, generator_interface_resource_generate(res, gl_gen_ctx.buf));
765 }
709 } 766 }
710 767
711
712 Gui_Session *session = session_new(); 768 Gui_Session *session = session_new();
713 /* Generate sequences */ 769 /* Generate sequences */
714 Eina_List* seqs_list = gui_context_seq_list_get(ctx); 770 Eina_List* seqs_list = gui_context_seq_list_get(ctx);
@@ -721,7 +777,10 @@ _ctx_to_file_save(Gui_Context *ctx, const char *path)
721 eina_strbuf_replace_first(gl_gen_ctx.buf, "__GLOBAL_NAMES__", eina_strbuf_string_get(global_names_buf)); 777 eina_strbuf_replace_first(gl_gen_ctx.buf, "__GLOBAL_NAMES__", eina_strbuf_string_get(global_names_buf));
722 eina_strbuf_free(global_names_buf); 778 eina_strbuf_free(global_names_buf);
723 779
724 eo_do(C_generator, generator_interface_main_function_generate(ctx, project, gl_gen_ctx.buf)); 780 if (_export_mode & GENERATE_CODE)
781 {
782 eo_do(C_generator, generator_interface_main_function_generate(ctx, project, gl_gen_ctx.buf));
783 }
725 784
726 /* Print all data from buffer into the file. */ 785 /* Print all data from buffer into the file. */
727 fprintf(fp_c, "%s", eina_strbuf_string_get(gl_gen_ctx.buf)); 786 fprintf(fp_c, "%s", eina_strbuf_string_get(gl_gen_ctx.buf));
@@ -767,7 +826,7 @@ end:
767} 826}
768 827
769void 828void
770generator_ctx_source_generate(Gui_Context *ctx, const char *path) 829generator_ctx_source_generate(Gui_Context *ctx, const char *path, Generator_Export_Format format, Generator_Export_Mode mode)
771{ 830{
772 if (!gui_context_win_list_get(ctx)) 831 if (!gui_context_win_list_get(ctx))
773 { 832 {
@@ -775,9 +834,24 @@ generator_ctx_source_generate(Gui_Context *ctx, const char *path)
775 return; 834 return;
776 } 835 }
777 836
778 if (!C_generator) 837 switch (format)
779 { 838 {
780 C_generator = eo_add(C_GENERATOR_CLASS, NULL); 839 case GENERATION_C:
840 {
841 if (!C_generator)
842 {
843 C_generator = eo_add(C_GENERATOR_CLASS, NULL);
844 }
845 break;
846 }
847 case GENERATION_CPP:
848 {
849 ERR("Geration Format not supported");
850 return;
851 break;
852 }
853 default:
854 ERR("switch - default");
781 } 855 }
782 Action_Functions *funcs = manager_action_functions_get(MODE_GENERATOR); 856 Action_Functions *funcs = manager_action_functions_get(MODE_GENERATOR);
783 funcs->wdg_add = _wdg_add_generate; 857 funcs->wdg_add = _wdg_add_generate;
@@ -786,6 +860,7 @@ generator_ctx_source_generate(Gui_Context *ctx, const char *path)
786 funcs->content_set = _content_set_generate; 860 funcs->content_set = _content_set_generate;
787 funcs->item_add = _item_add_generate; 861 funcs->item_add = _item_add_generate;
788 862
863 _export_mode = mode;
789 _ctx_to_file_save(ctx, path); 864 _ctx_to_file_save(ctx, path);
790} 865}
791 866
diff --git a/src/lib/generator.h b/src/lib/generator.h
index dc82a35..372fce9 100644
--- a/src/lib/generator.h
+++ b/src/lib/generator.h
@@ -12,6 +12,20 @@ typedef struct
12 Eina_Hash *created_sequences_hash; 12 Eina_Hash *created_sequences_hash;
13} Global_Gen_Context; 13} Global_Gen_Context;
14 14
15typedef enum
16{
17 GENERATION_C,
18 GENERATION_CPP
19} Generator_Export_Format;
20
21typedef enum
22{
23 GENERATE_NONE,
24 GENERATE_JSON = 1 << 0,
25 GENERATE_CODE = GENERATE_JSON << 1,
26 GENERATE_JSON_CODE = GENERATE_JSON | GENERATE_CODE
27} Generator_Export_Mode;
28
15/* Structure to hold data about func being generated. */ 29/* Structure to hold data about func being generated. */
16typedef struct 30typedef struct
17{ 31{
@@ -27,6 +41,6 @@ typedef struct
27 41
28/* Generate sources for context*/ 42/* Generate sources for context*/
29void 43void
30generator_ctx_source_generate(Gui_Context *ctx, const char *path); 44generator_ctx_source_generate(Gui_Context *ctx, const char *path, Generator_Export_Format format, Generator_Export_Mode mode);
31 45
32#endif 46#endif