summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYakov Goldberg <yakov.g@samsung.com>2014-05-22 16:34:57 +0300
committerYakov Goldberg <yakov.g@samsung.com>2014-05-22 16:34:57 +0300
commit374590f25588c0175a156a805f4fcc118f895d93 (patch)
treee5128d8a34727ba6f957c4b1f85da5c01c1975be
parent962b98accddd15e756dc3000bdbb922b3138b6ec (diff)
add JSON generation of Settings section
-rw-r--r--src/lib/generator.c40
1 files changed, 35 insertions, 5 deletions
diff --git a/src/lib/generator.c b/src/lib/generator.c
index 02ec7b9..674627f 100644
--- a/src/lib/generator.c
+++ b/src/lib/generator.c
@@ -613,6 +613,30 @@ _resources_to_json(const Gui_Context *ctx)
613 return ret; 613 return ret;
614} 614}
615 615
616/* Create JSON Object/string for Settings. */
617static char*
618_settings_to_json(const Gui_Context *ctx)
619{
620 char *ret = NULL;
621 Eina_Json_Value *obj = eina_json_object_new(), *cur;
622
623 cur = eina_json_object_new();
624 eina_json_object_append(cur, "type", eina_json_string_new("settings"));
625 eina_json_object_append(obj, "Desc", cur);
626
627 cur = eina_json_object_new();
628 eina_json_object_append(cur, "project", eina_json_string_new(gui_context_project_name_get(ctx)));
629 eina_json_object_append(obj, "Settings", cur);
630
631 /* Create root object. */
632 cur = eina_json_object_new();
633 eina_json_object_append(cur, "Settings", obj);
634
635 ret = eina_json_format_string_get(cur, EINA_JSON_FORMAT_BASIC);
636 eina_json_value_free(cur);
637 return ret;
638}
639
616/* Save context into "project" files. */ 640/* Save context into "project" files. */
617static void 641static void
618_ctx_to_file_save(Gui_Context *ctx, const char *path) 642_ctx_to_file_save(Gui_Context *ctx, const char *path)
@@ -652,12 +676,18 @@ _ctx_to_file_save(Gui_Context *ctx, const char *path)
652 eina_strbuf_append_printf(gl_gen_ctx.buf, "__GLOBAL_NAMES__"); 676 eina_strbuf_append_printf(gl_gen_ctx.buf, "__GLOBAL_NAMES__");
653 677
654 /*Add generation of Resources. */ 678 /*Add generation of Resources. */
655 char *res_str = NULL; 679 char *json_str = NULL;
656 res_str = _resources_to_json(ctx); 680 json_str = _resources_to_json(ctx);
657 if (res_str) 681 if (json_str)
682 {
683 eina_strbuf_append_printf(gl_gen_ctx.buf, "/* @egui\n%s\n@!egui */\n", json_str);
684 free(json_str);
685 }
686 json_str = _settings_to_json(ctx);
687 if (json_str)
658 { 688 {
659 eina_strbuf_append_printf(gl_gen_ctx.buf, "/* @egui\n%s\n@!egui */\n", res_str); 689 eina_strbuf_append_printf(gl_gen_ctx.buf, "/* @egui\n%s\n@!egui */\n", json_str);
660 free(res_str); 690 free(json_str);
661 } 691 }
662 692
663 /* Add declarations of resource callbacks. */ 693 /* Add declarations of resource callbacks. */