summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Zaoui <daniel.zaoui@samsung.com>2016-03-02 10:29:15 +0200
committerDaniel Zaoui <daniel.zaoui@samsung.com>2016-03-02 10:29:15 +0200
commitd3641da8ad0338f7ed9cca81f7d160e398c6b332 (patch)
treeaa7dc85633890ae279212196448908c4af4841b6
parent93e69739b2a9cbc32eb43fd90aa8da0ca6d8854f (diff)
Generate callbacks section only if needed
i.e only if actions are inside the callbacks
-rw-r--r--src/lib/ea_json_generator.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/lib/ea_json_generator.c b/src/lib/ea_json_generator.c
index 26db7cc..24d4acf 100644
--- a/src/lib/ea_json_generator.c
+++ b/src/lib/ea_json_generator.c
@@ -224,21 +224,24 @@ _object_json_generate(Ea *ea_obj)
224 if (js_items) json_object_object_add(obj, "Items", js_items); 224 if (js_items) json_object_object_add(obj, "Items", js_items);
225 225
226 Ea *callback = NULL; 226 Ea *callback = NULL;
227 json_object *jactions = NULL;
227 js_elts = NULL; 228 js_elts = NULL;
228 itr = ea_object_callbacks_get(ea_obj); 229 itr = ea_object_callbacks_get(ea_obj);
229 EINA_ITERATOR_FOREACH(itr, callback) 230 EINA_ITERATOR_FOREACH(itr, callback)
230 { 231 {
231 Ea *action; 232 Ea *action;
232 Eina_Iterator *itr2;
233 const char *event_name = eolian_event_name_get(ea_callback_event_get(callback));
234 Eina_Bool add_iter = !!ea_callback_next_get(callback); 233 Eina_Bool add_iter = !!ea_callback_next_get(callback);
235 json_object *jactions = json_object_new_array();
236 if (!js_elts) js_elts = json_object_new_object();
237 json_object_object_add(js_elts, event_name, jactions);
238 do 234 do
239 { 235 {
240 itr2 = ea_callback_actions_get(callback); 236 Eina_Iterator *itr2 = ea_callback_actions_get(callback);
241 if (add_iter) json_object_array_add(jactions, 237 if (itr2 && !jactions)
238 {
239 const char *event_name = eolian_event_name_get(ea_callback_event_get(callback));
240 jactions = json_object_new_array();
241 js_elts = json_object_new_object();
242 json_object_object_add(js_elts, event_name, jactions);
243 }
244 if (itr2 && add_iter) json_object_array_add(jactions,
242 json_object_new_int(ea_callback_iteration_get(callback))); 245 json_object_new_int(ea_callback_iteration_get(callback)));
243 EINA_ITERATOR_FOREACH(itr2, action) 246 EINA_ITERATOR_FOREACH(itr2, action)
244 { 247 {