summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYakov Goldberg <yakov.g@samsung.com>2014-05-27 13:40:55 +0300
committerYakov Goldberg <yakov.g@samsung.com>2014-05-27 14:03:18 +0300
commit4970857f5f1577fe46858498c5563b6009107be2 (patch)
treef334d04c3f5701fc91f70486d1644571d52b57e8
parent5f42b233b1ae928f32ecf2da6b16b4baf1f6b65e (diff)
add project_name as prefix to each sequence
-rw-r--r--src/bin/egui_gui/CMakeLists.txt1
-rw-r--r--src/bin/egui_gui/egui_layout_c.json8
-rw-r--r--src/bin/egui_gui/egui_layout_h.json8
-rw-r--r--src/bin/egui_gui/egui_logic.c10
-rw-r--r--src/lib/generator.c69
5 files changed, 55 insertions, 41 deletions
diff --git a/src/bin/egui_gui/CMakeLists.txt b/src/bin/egui_gui/CMakeLists.txt
index f985b99..6d21f00 100644
--- a/src/bin/egui_gui/CMakeLists.txt
+++ b/src/bin/egui_gui/CMakeLists.txt
@@ -105,7 +105,6 @@ add_executable(${TARGET2}
105 editor.c) 105 editor.c)
106# add this dependency to force build one after another, 106# add this dependency to force build one after another,
107# in order to delete and generate files in proper order 107# in order to delete and generate files in proper order
108add_dependencies(${TARGET2} ${TARGET})
109add_dependencies(${TARGET2} delete_files) 108add_dependencies(${TARGET2} delete_files)
110add_dependencies(${TARGET2} egui_cmd) 109add_dependencies(${TARGET2} egui_cmd)
111 110
diff --git a/src/bin/egui_gui/egui_layout_c.json b/src/bin/egui_gui/egui_layout_c.json
index 67e999b..4ece902 100644
--- a/src/bin/egui_gui/egui_layout_c.json
+++ b/src/bin/egui_gui/egui_layout_c.json
@@ -251,7 +251,7 @@ _create_gvc_win()
251 } 251 }
252@!egui */ 252@!egui */
253Eina_Bool 253Eina_Bool
254_sequence_graphviz_button_clicked_execute(void *data EINA_UNUSED, Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED) 254egui_layout_graphviz_button_clicked(void *data EINA_UNUSED, Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
255{ 255{
256 _create_gvc_win(); 256 _create_gvc_win();
257 257
@@ -396,7 +396,7 @@ _create_fs_win()
396 } 396 }
397@!egui */ 397@!egui */
398Eina_Bool 398Eina_Bool
399_sequence_fs_win_show_execute(void *data EINA_UNUSED, Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED) 399egui_layout_fs_win_show(void *data EINA_UNUSED, Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
400{ 400{
401 _create_fs_win(); 401 _create_fs_win();
402 402
@@ -1050,7 +1050,7 @@ _create_settings_win()
1050 } 1050 }
1051@!egui */ 1051@!egui */
1052Eina_Bool 1052Eina_Bool
1053_sequence_rm_win_show_execute(void *data EINA_UNUSED, Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED) 1053egui_layout_rm_win_show(void *data EINA_UNUSED, Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
1054{ 1054{
1055 _create_rm_win(); 1055 _create_rm_win();
1056 1056
@@ -1076,7 +1076,7 @@ _sequence_rm_win_show_execute(void *data EINA_UNUSED, Eo *obj EINA_UNUSED, const
1076 } 1076 }
1077@!egui */ 1077@!egui */
1078Eina_Bool 1078Eina_Bool
1079_sequence_settings_win_show_execute(void *data EINA_UNUSED, Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED) 1079egui_layout_settings_win_show(void *data EINA_UNUSED, Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
1080{ 1080{
1081 _create_settings_win(); 1081 _create_settings_win();
1082 1082
diff --git a/src/bin/egui_gui/egui_layout_h.json b/src/bin/egui_gui/egui_layout_h.json
index 8f8ace0..f8c1cb6 100644
--- a/src/bin/egui_gui/egui_layout_h.json
+++ b/src/bin/egui_gui/egui_layout_h.json
@@ -71,16 +71,16 @@ typedef struct
71} GUI; 71} GUI;
72 72
73Eina_Bool 73Eina_Bool
74_sequence_graphviz_button_clicked_execute(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info); 74egui_layout_graphviz_button_clicked(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info);
75 75
76Eina_Bool 76Eina_Bool
77_sequence_fs_win_show_execute(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info); 77egui_layout_fs_win_show(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info);
78 78
79Eina_Bool 79Eina_Bool
80_sequence_rm_win_show_execute(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info); 80egui_layout_rm_win_show(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info);
81 81
82Eina_Bool 82Eina_Bool
83_sequence_settings_win_show_execute(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info); 83egui_layout_settings_win_show(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info);
84 84
85GUI *egui_layout_gui_get(); 85GUI *egui_layout_gui_get();
86#endif 86#endif
diff --git a/src/bin/egui_gui/egui_logic.c b/src/bin/egui_gui/egui_logic.c
index a7848cd..707c844 100644
--- a/src/bin/egui_gui/egui_logic.c
+++ b/src/bin/egui_gui/egui_logic.c
@@ -187,7 +187,7 @@ end:
187static void 187static void
188_fs_save_as_open() 188_fs_save_as_open()
189{ 189{
190 _sequence_fs_win_show_execute(NULL, NULL, NULL, NULL); 190 egui_layout_fs_win_show(NULL, NULL, NULL, NULL);
191 eo_do(g->fileselector, elm_interface_fileselector_path_set(getenv("HOME")), 191 eo_do(g->fileselector, elm_interface_fileselector_path_set(getenv("HOME")),
192 elm_interface_fileselector_is_save_set(EINA_TRUE)); 192 elm_interface_fileselector_is_save_set(EINA_TRUE));
193 evas_object_smart_callback_add(g->fileselector, "done", _on_fs_done, g); 193 evas_object_smart_callback_add(g->fileselector, "done", _on_fs_done, g);
@@ -270,7 +270,7 @@ _on_factory_item_down(void *data, Eo *obj EINA_UNUSED, const Eo_Event_Descriptio
270static void 270static void
271_project_open() 271_project_open()
272{ 272{
273 _sequence_fs_win_show_execute(NULL, NULL, NULL, NULL); 273 egui_layout_fs_win_show(NULL, NULL, NULL, NULL);
274 eo_do(g->fileselector, elm_interface_fileselector_path_set(getenv("HOME")), 274 eo_do(g->fileselector, elm_interface_fileselector_path_set(getenv("HOME")),
275 elm_interface_fileselector_is_save_set(EINA_FALSE)); 275 elm_interface_fileselector_is_save_set(EINA_FALSE));
276 evas_object_smart_callback_add(g->fileselector, "done", _on_fs_done, g); 276 evas_object_smart_callback_add(g->fileselector, "done", _on_fs_done, g);
@@ -316,12 +316,12 @@ _toolbar_item_sel_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
316 } 316 }
317 case RSRC_MNGR: 317 case RSRC_MNGR:
318 { 318 {
319 _sequence_rm_win_show_execute(NULL, NULL, NULL, NULL); 319 egui_layout_rm_win_show(NULL, NULL, NULL, NULL);
320 break; 320 break;
321 } 321 }
322 case SETTINGS_WIN: 322 case SETTINGS_WIN:
323 { 323 {
324 _sequence_settings_win_show_execute(NULL, NULL, NULL, NULL); 324 egui_layout_settings_win_show(NULL, NULL, NULL, NULL);
325 break; 325 break;
326 } 326 }
327 case CTX_REFRESH: 327 case CTX_REFRESH:
@@ -556,7 +556,7 @@ _graphview_show_cb(void *data EINA_UNUSED, Evas_Object *_obj EINA_UNUSED, void *
556 agclose(ag); 556 agclose(ag);
557 gvFreeContext(gvc); 557 gvFreeContext(gvc);
558 558
559 _sequence_graphviz_button_clicked_execute(NULL, NULL, NULL, NULL); 559 egui_layout_graphviz_button_clicked(NULL, NULL, NULL, NULL);
560} 560}
561#endif 561#endif
562 562
diff --git a/src/lib/generator.c b/src/lib/generator.c
index b22f27f..f405e53 100644
--- a/src/lib/generator.c
+++ b/src/lib/generator.c
@@ -74,6 +74,21 @@ _is_in_list(Eina_List *lst, const char *str)
74 return EINA_FALSE; 74 return EINA_FALSE;
75} 75}
76 76
77/* Replaces spaces and dashes to underscore,
78 * and lowercase string*/
79static char*
80_project_name_format(char *in_str)
81{
82 Eina_Strbuf *buf = eina_strbuf_new();
83 eina_strbuf_append_printf(buf, "%s", in_str);
84 eina_strbuf_replace_all(buf, " ", "_");
85 eina_strbuf_replace_all(buf, "-", "_");
86 char *ret = strdup((char *) eina_strbuf_string_get(buf));
87 eina_str_tolower(&ret);
88 eina_strbuf_free(buf);
89 return ret;
90}
91
77/* Generate string for provided value */ 92/* Generate string for provided value */
78static void 93static void
79_format_string_add(const Gui_Context *ctx, Gui_Value *gui_value, Eina_Strbuf *p) 94_format_string_add(const Gui_Context *ctx, Gui_Value *gui_value, Eina_Strbuf *p)
@@ -173,7 +188,9 @@ _format_string_add(const Gui_Context *ctx, Gui_Value *gui_value, Eina_Strbuf *p)
173 res = gui_context_resource_get(ctx, RESOURCE_SEQUENCE, dep_id); 188 res = gui_context_resource_get(ctx, RESOURCE_SEQUENCE, dep_id);
174 if (res) 189 if (res)
175 { 190 {
176 eina_strbuf_append_printf(p, "%s", resource_value_get(res)); 191 char *formatted = (char *) _project_name_format((char *) gui_context_project_name_get(ctx));
192 eina_strbuf_append_printf(p, "%s_%s", formatted, resource_name_get(res));
193 free(formatted);
177 } 194 }
178 else 195 else
179 { 196 {
@@ -459,6 +476,7 @@ _sequence_generate(Gui_Session *session, Gui_Sequence *seq, Global_Gen_Context *
459{ 476{
460 Eina_List *itr; 477 Eina_List *itr;
461 Gui_Action *action; 478 Gui_Action *action;
479 const Gui_Context *ctx = gl_ctx->ctx;
462 480
463 const char *seq_name = sequence_name_get(seq); 481 const char *seq_name = sequence_name_get(seq);
464 printf("Generate %s\n", seq_name); 482 printf("Generate %s\n", seq_name);
@@ -489,8 +507,13 @@ _sequence_generate(Gui_Session *session, Gui_Sequence *seq, Global_Gen_Context *
489 /* if sequence is public, need to declare it in header. */ 507 /* if sequence is public, need to declare it in header. */
490 if (sequence_public_get(seq)) 508 if (sequence_public_get(seq))
491 { 509 {
492 Variable_Data *item_vd = VAR_DATA_NEW(VAR_SEQUENCE, seq_name); 510 char _buf[1000] = {'\0'};
511 char *formatted_project_name = _project_name_format((char *) gui_context_project_name_get(ctx));
512 sprintf(_buf, "%s_%s", formatted_project_name, sequence_name_get(seq));
513
514 Variable_Data *item_vd = VAR_DATA_NEW(VAR_SEQUENCE, _buf);
493 foo_ctx->gl_ctx->public_names = eina_list_append(foo_ctx->gl_ctx->public_names, item_vd); 515 foo_ctx->gl_ctx->public_names = eina_list_append(foo_ctx->gl_ctx->public_names, item_vd);
516 free(formatted_project_name);
494 } 517 }
495 EINA_LIST_FOREACH(sequence_actions_list_get(seq), itr, action) 518 EINA_LIST_FOREACH(sequence_actions_list_get(seq), itr, action)
496 { 519 {
@@ -520,7 +543,6 @@ _sequence_generate(Gui_Session *session, Gui_Sequence *seq, Global_Gen_Context *
520 } 543 }
521 case MODIF_ACTION: 544 case MODIF_ACTION:
522 { 545 {
523 const Gui_Context *ctx = gl_ctx->ctx;
524 Dep_Id wdg_id = action_widget_id_get(action); 546 Dep_Id wdg_id = action_widget_id_get(action);
525 const char *wdg_name = gui_context_dep_data_get(ctx, wdg_id); 547 const char *wdg_name = gui_context_dep_data_get(ctx, wdg_id);
526 Gui_Widget *wdg = wdg_get(ctx, wdg_id); 548 Gui_Widget *wdg = wdg_get(ctx, wdg_id);
@@ -599,16 +621,22 @@ _wdg_cb_add_generate(Gui_Session *session, const Gui_Widget *wdg, const Gui_Widg
599 Gui_Sequence *seq = sequence_get(wdg_context_get(wdg), dep_id); 621 Gui_Sequence *seq = sequence_get(wdg_context_get(wdg), dep_id);
600 622
601 const Gui_Resource *res = NULL; 623 const Gui_Resource *res = NULL;
624 char _buf[1000] = {'\0'};
602 if (seq) 625 if (seq)
603 { 626 {
604 _sequence_generate(session, seq, foo_ctx->gl_ctx); 627 _sequence_generate(session, seq, foo_ctx->gl_ctx);
605 res = gui_context_resource_get(ctx, RESOURCE_SEQUENCE, dep_id); 628 res = gui_context_resource_get(ctx, RESOURCE_SEQUENCE, dep_id);
629
630 char *formatted = (char *) _project_name_format((char *) gui_context_project_name_get(ctx));
631 sprintf(_buf, "%s_%s", formatted, resource_name_get(res));
632 free(formatted);
633 cb_name = _buf;
606 } 634 }
607 else 635 else
608 { 636 {
609 res = gui_context_resource_get(ctx, RESOURCE_EO_CALLBACK, dep_id); 637 res = gui_context_resource_get(ctx, RESOURCE_EO_CALLBACK, dep_id);
638 cb_name = resource_value_get(res);
610 } 639 }
611 cb_name = resource_value_get(res);
612 640
613 if (_export_mode & GENERATE_CODE) 641 if (_export_mode & GENERATE_CODE)
614 { 642 {
@@ -1390,27 +1418,12 @@ _c_generator_generator_interface_resource_generate(Eo *obj EINA_UNUSED, void *pd
1390 return EINA_TRUE; 1418 return EINA_TRUE;
1391} 1419}
1392 1420
1393/* Replaces spaces and dashes to underscore,
1394 * and lowercase string*/
1395static char*
1396_project_name_format(char *in_str)
1397{
1398 Eina_Strbuf *buf = eina_strbuf_new();
1399 eina_strbuf_append_printf(buf, "%s", in_str);
1400 eina_strbuf_replace_all(buf, " ", "_");
1401 eina_strbuf_replace_all(buf, "-", "_");
1402 char *ret = strdup((char *) eina_strbuf_string_get(buf));
1403 eina_str_tolower(&ret);
1404 eina_strbuf_free(buf);
1405 return ret;
1406}
1407
1408EOLIAN static Eina_Bool 1421EOLIAN static Eina_Bool
1409_c_generator_generator_interface_main_function_generate(Eo *obj EINA_UNUSED, void *pd EINA_UNUSED, const Gui_Context *ctx, Eina_Strbuf *buf) 1422_c_generator_generator_interface_main_function_generate(Eo *obj EINA_UNUSED, void *pd EINA_UNUSED, const Gui_Context *ctx, Eina_Strbuf *buf)
1410{ 1423{
1411 Dep_Id dep_id = gui_context_dep_data_get_id_by_name(ctx, "BigBang"); 1424 Dep_Id dep_id = gui_context_dep_data_get_id_by_name(ctx, BIGBANG_STR);
1412 const Gui_Resource *res = gui_context_resource_get(ctx, RESOURCE_SEQUENCE, dep_id); 1425 const Gui_Resource *res = gui_context_resource_get(ctx, RESOURCE_SEQUENCE, dep_id);
1413 const char *func_name = resource_value_get(res); 1426 const char *func_name = resource_name_get(res);
1414 1427
1415 char *project_name = (char *) gui_context_project_name_get(ctx); 1428 char *project_name = (char *) gui_context_project_name_get(ctx);
1416 char *formatted = _project_name_format(project_name); 1429 char *formatted = _project_name_format(project_name);
@@ -1421,10 +1434,10 @@ _c_generator_generator_interface_main_function_generate(Eo *obj EINA_UNUSED, voi
1421 " static Eina_Bool initialized = EINA_FALSE;\n" 1434 " static Eina_Bool initialized = EINA_FALSE;\n"
1422 " if (!initialized)\n" 1435 " if (!initialized)\n"
1423 " {\n" 1436 " {\n"
1424 " %s(NULL, NULL, NULL, NULL);\n" 1437 " %s_%s(NULL, NULL, NULL, NULL);\n"
1425 " initialized = EINA_TRUE;\n" 1438 " initialized = EINA_TRUE;\n"
1426 " }\n" 1439 " }\n"
1427 " return &%s;\n}", formatted, func_name, PUB_WIDGETS); 1440 " return &%s;\n}", formatted, formatted, func_name, PUB_WIDGETS);
1428 free(formatted); 1441 free(formatted);
1429 return EINA_TRUE; 1442 return EINA_TRUE;
1430} 1443}
@@ -1436,10 +1449,12 @@ _c_generator_generator_interface_sequence_begin_generate(Eo *obj EINA_UNUSED, vo
1436 const Gui_Context *ctx = sequence_ctx_get(seq); 1449 const Gui_Context *ctx = sequence_ctx_get(seq);
1437 Dep_Id seq_id = sequence_dep_id_get(seq); 1450 Dep_Id seq_id = sequence_dep_id_get(seq);
1438 const Gui_Resource *res = gui_context_resource_get(ctx, RESOURCE_SEQUENCE, seq_id); 1451 const Gui_Resource *res = gui_context_resource_get(ctx, RESOURCE_SEQUENCE, seq_id);
1439 const char *sequence_name = resource_value_get(res); 1452 const char *sequence_name = resource_name_get(res);
1453 char *formatted_project_name = _project_name_format((char *) gui_context_project_name_get(ctx));
1440 eina_strbuf_append_printf(buf, 1454 eina_strbuf_append_printf(buf,
1441 "%sEina_Bool\n%s(void *data EINA_UNUSED, Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)\n{\n", 1455 "%sEina_Bool\n%s_%s(void *data EINA_UNUSED, Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)\n{\n",
1442 sequence_public_get(seq) ? "" : "static ", sequence_name); 1456 sequence_public_get(seq) ? "" : "static ", formatted_project_name, sequence_name);
1457 free(formatted_project_name);
1443 return EINA_TRUE; 1458 return EINA_TRUE;
1444} 1459}
1445 1460
@@ -1667,7 +1682,7 @@ EOLIAN static Eina_Bool
1667_c_generator_generator_interface_header_sequence_generate(Eo *obj EINA_UNUSED, void *pd EINA_UNUSED, const char *seq_name, Eina_Strbuf *buf) 1682_c_generator_generator_interface_header_sequence_generate(Eo *obj EINA_UNUSED, void *pd EINA_UNUSED, const char *seq_name, Eina_Strbuf *buf)
1668{ 1683{
1669 /* Add get_gui function . */ 1684 /* Add get_gui function . */
1670 eina_strbuf_append_printf(buf, "Eina_Bool\n_sequence_%s_execute(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info);\n\n", 1685 eina_strbuf_append_printf(buf, "Eina_Bool\n%s(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info);\n\n",
1671 seq_name); 1686 seq_name);
1672 return EINA_TRUE; 1687 return EINA_TRUE;
1673} 1688}