summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Zaoui <daniel.zaoui@samsung.com>2016-03-01 17:32:58 +0200
committerDaniel Zaoui <daniel.zaoui@samsung.com>2016-03-01 17:32:58 +0200
commit4dab4f9f517c1657aca65b1a90ba5711a187744b (patch)
treed9e5102539fbea342a36a4f19e9930ca5ba9a6c2
parent127e0f56cada15bb24ecafa2083f7c09eca58312 (diff)
Separate contained items and objects in JSON file
An object can have items and an object a content. This creates conflicts.
-rw-r--r--src/lib/ea_json_generator.c29
-rw-r--r--src/lib/ea_json_parser.c23
2 files changed, 29 insertions, 23 deletions
diff --git a/src/lib/ea_json_generator.c b/src/lib/ea_json_generator.c
index 971bb8a..38b36d1 100644
--- a/src/lib/ea_json_generator.c
+++ b/src/lib/ea_json_generator.c
@@ -100,8 +100,8 @@ _func_params_json_generate(const Ea *ea_foo)
100 eolian_class_function_get_by_name(eolian_class_get_by_name(cl_str), foo_str, EOLIAN_UNRESOLVED) 100 eolian_class_function_get_by_name(eolian_class_get_by_name(cl_str), foo_str, EOLIAN_UNRESOLVED)
101 101
102 102
103static json_object * 103static void
104_containee_json_generate(Ea *ea_obj, Ea *ea_func, json_object *js_elts) 104_containee_json_generate(Ea *ea_obj, Ea *ea_func, json_object **js_contains, json_object **js_items)
105{ 105{
106 const Eolian_Function *eo_foo = ea_function_func_get(ea_func); 106 const Eolian_Function *eo_foo = ea_function_func_get(ea_func);
107 107
@@ -122,16 +122,16 @@ _containee_json_generate(Ea *ea_obj, Ea *ea_func, json_object *js_elts)
122 Ea_Function_Parameter *obj_par = ea_function_parameter_nth_get(ea_func, 0); 122 Ea_Function_Parameter *obj_par = ea_function_parameter_nth_get(ea_func, 0);
123 Eina_Stringshare *alias = 123 Eina_Stringshare *alias =
124 (obj_par && obj_par->type == EA_PARAM_OBJECT) ? ea_object_name_get(obj_par->obj) : NULL; 124 (obj_par && obj_par->type == EA_PARAM_OBJECT) ? ea_object_name_get(obj_par->obj) : NULL;
125 if (!js_elts) js_elts = json_object_new_array(); 125 if (!*js_contains) *js_contains = json_object_new_array();
126 json_object_array_add(js_elts, json_object_new_string(alias)); 126 json_object_array_add(*js_contains, json_object_new_string(alias));
127 } 127 }
128 if (eo_foo == box_pack) 128 if (eo_foo == box_pack)
129 { 129 {
130 Ea_Function_Parameter *obj_par = ea_function_parameter_nth_get(ea_func, 0); 130 Ea_Function_Parameter *obj_par = ea_function_parameter_nth_get(ea_func, 0);
131 Eina_Stringshare *alias = 131 Eina_Stringshare *alias =
132 (obj_par && obj_par->type == EA_PARAM_OBJECT) ? ea_object_name_get(obj_par->obj) : NULL; 132 (obj_par && obj_par->type == EA_PARAM_OBJECT) ? ea_object_name_get(obj_par->obj) : NULL;
133 if (!js_elts) js_elts = json_object_new_array(); 133 if (!*js_contains) *js_contains = json_object_new_array();
134 json_object_array_add(js_elts, json_object_new_string(alias)); 134 json_object_array_add(*js_contains, json_object_new_string(alias));
135 } 135 }
136 if (eo_foo == container_content) 136 if (eo_foo == container_content)
137 { 137 {
@@ -146,15 +146,14 @@ _containee_json_generate(Ea *ea_obj, Ea *ea_func, json_object *js_elts)
146 Eina_Stringshare *obj_name = 146 Eina_Stringshare *obj_name =
147 (obj_par && obj_par->type == EA_PARAM_OBJECT) ? 147 (obj_par && obj_par->type == EA_PARAM_OBJECT) ?
148 ea_object_name_get(obj_par->obj) : NULL; 148 ea_object_name_get(obj_par->obj) : NULL;
149 if (!js_elts) js_elts = json_object_new_object(); 149 if (!*js_contains) *js_contains = json_object_new_object();
150 json_object_object_add(js_elts, obj_name, js_val); 150 json_object_object_add(*js_contains, obj_name, js_val);
151 } 151 }
152 if (eo_foo == nv_it_push || eo_foo == tb_it_add) 152 if (eo_foo == nv_it_push || eo_foo == tb_it_add)
153 { 153 {
154 if (!js_elts) js_elts = json_object_new_array(); 154 if (!*js_items) *js_items = json_object_new_array();
155 json_object_array_add(js_elts, json_object_new_string(ea_object_name_get(ea_obj))); 155 json_object_array_add(*js_items, json_object_new_string(ea_object_name_get(ea_obj)));
156 } 156 }
157 return js_elts;
158} 157}
159 158
160static json_object * 159static json_object *
@@ -201,7 +200,7 @@ _object_json_generate(Ea *ea_obj)
201 eina_iterator_free(itr); 200 eina_iterator_free(itr);
202 if (js_elts) json_object_object_add(obj, "Properties", js_elts); 201 if (js_elts) json_object_object_add(obj, "Properties", js_elts);
203 202
204 js_elts = NULL; 203 json_object *js_contains = NULL, *js_items = NULL;
205 Ea_Container_Item *item; 204 Ea_Container_Item *item;
206 Ea *container = ea_object_container_get(ea_obj); 205 Ea *container = ea_object_container_get(ea_obj);
207 itr = ea_container_items_get(container); 206 itr = ea_container_items_get(container);
@@ -215,12 +214,12 @@ _object_json_generate(Ea *ea_obj)
215 func = ea_item_create_function_get(ea_containee); 214 func = ea_item_create_function_get(ea_containee);
216// if (ea_isa(ea_containee, "Elm.Naviframe_Item") 215// if (ea_isa(ea_containee, "Elm.Naviframe_Item")
217 } 216 }
218 js_elts = _containee_json_generate(ea_containee, func, js_elts); 217 _containee_json_generate(ea_containee, func, &js_contains, &js_items);
219 } 218 }
220 } 219 }
221 eina_iterator_free(itr); 220 eina_iterator_free(itr);
222 if (js_elts) json_object_object_add(obj, "Contains", js_elts); 221 if (js_contains) json_object_object_add(obj, "Contains", js_contains);
223 else json_object_put(js_elts); 222 if (js_items) json_object_object_add(obj, "Items", js_items);
224 223
225 Ea *callback = NULL; 224 Ea *callback = NULL;
226 js_elts = NULL; 225 js_elts = NULL;
diff --git a/src/lib/ea_json_parser.c b/src/lib/ea_json_parser.c
index 6888770..ca726f9 100644
--- a/src/lib/ea_json_parser.c
+++ b/src/lib/ea_json_parser.c
@@ -266,13 +266,13 @@ end:
266} 266}
267 267
268static Eina_Bool 268static Eina_Bool
269_container_parse(Ea *ea_obj, json_object *jparams) 269_container_parse(Ea *ea_obj, json_object *jparams, Eina_Bool is_obj_cont)
270{ 270{
271 Eina_Bool ret = EINA_TRUE; 271 Eina_Bool ret = EINA_TRUE;
272 const Eolian_Class *kl = ea_object_class_get(ea_obj); 272 const Eolian_Class *kl = ea_object_class_get(ea_obj);
273 Ea_Session *session = ea_object_session_get(ea_obj); 273 Ea_Session *session = ea_object_session_get(ea_obj);
274 Ea *container = ea_object_container_get(ea_obj); 274 Ea *container = ea_object_container_get(ea_obj);
275 if (_class_is_of_type(kl, "Win")) 275 if (_class_is_of_type(kl, "Win") && is_obj_cont)
276 { 276 {
277 if (!_win_resize_function) _win_resize_function = _find_function_by_full_name("Elm.Win.resize_object_add"); 277 if (!_win_resize_function) _win_resize_function = _find_function_by_full_name("Elm.Win.resize_object_add");
278 JSON_ARRAY_FOREACH(jparams, jsubobj) 278 JSON_ARRAY_FOREACH(jparams, jsubobj)
@@ -283,7 +283,7 @@ _container_parse(Ea *ea_obj, json_object *jparams)
283 ea_container_object_attach(container, subobj, func); 283 ea_container_object_attach(container, subobj, func);
284 } 284 }
285 } 285 }
286 else if (_class_is_of_type(kl, "Box")) 286 else if (_class_is_of_type(kl, "Box") && is_obj_cont)
287 { 287 {
288 if (!_box_pack_end_function) _box_pack_end_function = _find_function_by_full_name("Elm.Box.pack_end"); 288 if (!_box_pack_end_function) _box_pack_end_function = _find_function_by_full_name("Elm.Box.pack_end");
289 JSON_ARRAY_FOREACH(jparams, jsubobj) 289 JSON_ARRAY_FOREACH(jparams, jsubobj)
@@ -294,7 +294,7 @@ _container_parse(Ea *ea_obj, json_object *jparams)
294 ea_container_object_attach(container, subobj, func); 294 ea_container_object_attach(container, subobj, func);
295 } 295 }
296 } 296 }
297 else if (_class_is_of_type(kl, "Table")) 297 else if (_class_is_of_type(kl, "Table") && is_obj_cont)
298 { 298 {
299 if (!_table_pack_function) _table_pack_function = _find_function_by_full_name("Elm.Table.pack"); 299 if (!_table_pack_function) _table_pack_function = _find_function_by_full_name("Elm.Table.pack");
300 json_object_object_foreach(jparams, subobj_name, jcoords) 300 json_object_object_foreach(jparams, subobj_name, jcoords)
@@ -310,8 +310,9 @@ _container_parse(Ea *ea_obj, json_object *jparams)
310 ea_container_object_attach(container, subobj, func); 310 ea_container_object_attach(container, subobj, func);
311 } 311 }
312 } 312 }
313 else if (_class_is_of_type(kl, "Naviframe") || 313 else if ((_class_is_of_type(kl, "Naviframe") ||
314 _class_is_of_type(kl, "Toolbar")) 314 _class_is_of_type(kl, "Toolbar") ||
315 _class_is_of_type(kl, "Hoversel")) && !is_obj_cont)
315 { 316 {
316 JSON_ARRAY_FOREACH(jparams, jsubobj) 317 JSON_ARRAY_FOREACH(jparams, jsubobj)
317 { 318 {
@@ -319,7 +320,7 @@ _container_parse(Ea *ea_obj, json_object *jparams)
319 ea_container_object_attach(container, subobj, NULL); 320 ea_container_object_attach(container, subobj, NULL);
320 } 321 }
321 } 322 }
322 else if (_class_is_of_type(kl, "Container")) 323 else if (_class_is_of_type(kl, "Container") && is_obj_cont)
323 { 324 {
324 if (!_content_set_function) _content_set_function = _find_function_by_full_name("Elm.Container.content_set"); 325 if (!_content_set_function) _content_set_function = _find_function_by_full_name("Elm.Container.content_set");
325 json_object_object_foreach(jparams, subobj_name, jpart) 326 json_object_object_foreach(jparams, subobj_name, jpart)
@@ -627,7 +628,13 @@ _json_parse(Ea_Session *ea_session, const char *buffer)
627 jobj = JSON_GET(jwdg, "Contains"); 628 jobj = JSON_GET(jwdg, "Contains");
628 if (jobj) 629 if (jobj)
629 { 630 {
630 _container_parse(ea_obj, jobj); 631 _container_parse(ea_obj, jobj, EINA_TRUE);
632 }
633 /* Items */
634 jobj = JSON_GET(jwdg, "Items");
635 if (jobj)
636 {
637 _container_parse(ea_obj, jobj, EINA_FALSE);
631 } 638 }
632 /* FIXME Items */ 639 /* FIXME Items */
633 /* Callbacks */ 640 /* Callbacks */