summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuilherme Lepsch <lepsch@expertisesolutions.com.br>2015-03-19 09:46:38 -0300
committerGuilherme Lepsch <lepsch@expertisesolutions.com.br>2015-03-19 09:46:38 -0300
commitd27e66ef9ca71a470349ccd97647f6847e79806f (patch)
treeb1b45ef6161cf819e85086b69f6dfacf9cad5b20
parentfc9a7b2366e3fe1f161e177469588f43bba59e33 (diff)
Emodel API changesHEADmaster
-rw-r--r--src/lib/Ejson.h1
-rw-r--r--src/lib/ejson_model.c223
-rw-r--r--src/lib/ejson_model.eo2
-rw-r--r--src/lib/ejson_model_private.h3
-rw-r--r--src/tests/ejson_suite.h4
-rw-r--r--src/tests/ejson_test_ejson_model.c86
-rw-r--r--src/tests/ejson_test_ejson_model.h4
7 files changed, 182 insertions, 141 deletions
diff --git a/src/lib/Ejson.h b/src/lib/Ejson.h
index d6cdefe..9bb49c4 100644
--- a/src/lib/Ejson.h
+++ b/src/lib/Ejson.h
@@ -28,6 +28,7 @@ typedef enum {
28 * @return 1 or greater on success, 0 otherwise 28 * @return 1 or greater on success, 0 otherwise
29 */ 29 */
30EAPI int ejson_init(void); 30EAPI int ejson_init(void);
31
31/** 32/**
32 * @brief Shutdown ejson. 33 * @brief Shutdown ejson.
33 * 34 *
diff --git a/src/lib/ejson_model.c b/src/lib/ejson_model.c
index 312d36e..2bf3a26 100644
--- a/src/lib/ejson_model.c
+++ b/src/lib/ejson_model.c
@@ -21,15 +21,15 @@ static void _ejson_model_children_load(Ejson_Model_Data *);
21static bool _ejson_model_init(Ejson_Model_Data *); 21static bool _ejson_model_init(Ejson_Model_Data *);
22static void _ejson_model_clear(Ejson_Model_Data *); 22static void _ejson_model_clear(Ejson_Model_Data *);
23static void _ejson_model_properties_setup(Ejson_Model_Data *); 23static void _ejson_model_properties_setup(Ejson_Model_Data *);
24static void _ejson_model_properties_setup_cb(void *, int, Eina_Value_Struct_Member *);
25static Ejson_Model_Type _ejson_model_parent_type_get(Ejson_Model_Data *); 24static Ejson_Model_Type _ejson_model_parent_type_get(Ejson_Model_Data *);
26static void _ejson_model_children_hash_free(void *); 25static void _ejson_model_children_hash_free(Ejson_Model_Child_Data *);
27static bool _ejson_model_name_property_set(Ejson_Model_Data *, Eina_Value *); 26static void _ejson_model_properties_hash_free(Eina_Value *);
28static bool _ejson_model_value_property_set(Ejson_Model_Data *, Eina_Value *); 27static bool _ejson_model_name_property_set(Ejson_Model_Data *, const Eina_Value *);
29static bool _ejson_model_json_property_set(Ejson_Model_Data *, Eina_Value *); 28static bool _ejson_model_value_property_set(Ejson_Model_Data *, const Eina_Value *);
29static bool _ejson_model_json_property_set(Ejson_Model_Data *, const Eina_Value *);
30static void _ejson_model_invalidate(Ejson_Model_Data *); 30static void _ejson_model_invalidate(Ejson_Model_Data *);
31static bool _ejson_model_stream_load(Ejson_Model_Data *); 31static bool _ejson_model_stream_load(Ejson_Model_Data *);
32static Eina_Bool _ejson_model_eina_value_as(Eina_Value *, const Eina_Value_Type *, void *); 32static Eina_Bool _ejson_model_eina_value_as(const Eina_Value *, const Eina_Value_Type *, void *);
33static Ejson_Model_Type _ejson_model_type_from_json_object(json_object *json); 33static Ejson_Model_Type _ejson_model_type_from_json_object(json_object *json);
34static bool _ejson_model_object_child_add(Ejson_Model_Data *, Ejson_Model_Data *, const char *); 34static bool _ejson_model_object_child_add(Ejson_Model_Data *, Ejson_Model_Data *, const char *);
35static bool _ejson_model_array_child_add(Ejson_Model_Data *, Ejson_Model_Data *, int); 35static bool _ejson_model_array_child_add(Ejson_Model_Data *, Ejson_Model_Data *, int);
@@ -49,10 +49,9 @@ _ejson_model_eo_base_constructor(Eo *obj, Ejson_Model_Data *pd)
49 pd->load.status = EMODEL_LOAD_STATUS_UNLOADED; 49 pd->load.status = EMODEL_LOAD_STATUS_UNLOADED;
50 pd->json = NULL; 50 pd->json = NULL;
51 pd->properties_array = NULL; 51 pd->properties_array = NULL;
52 pd->properties_desc = NULL; 52 pd->properties_hash = eina_hash_string_superfast_new(EINA_FREE_CB(_ejson_model_properties_hash_free));
53 pd->properties = NULL;
54 pd->children_list = NULL; 53 pd->children_list = NULL;
55 pd->children_hash = eina_hash_pointer_new(_ejson_model_children_hash_free); 54 pd->children_hash = eina_hash_pointer_new(EINA_FREE_CB(_ejson_model_children_hash_free));
56 pd->stream = NULL; 55 pd->stream = NULL;
57 pd->type = EJSON_MODEL_TYPE_NULL; 56 pd->type = EJSON_MODEL_TYPE_NULL;
58 pd->properties_calc = eina_array_new(1); 57 pd->properties_calc = eina_array_new(1);
@@ -77,15 +76,16 @@ _ejson_model_eo_base_destructor(Eo *obj, Ejson_Model_Data *pd)
77 _ejson_model_clear(pd); 76 _ejson_model_clear(pd);
78 77
79 eina_hash_free(pd->children_hash); 78 eina_hash_free(pd->children_hash);
79 eina_hash_free(pd->properties_hash);
80 eina_array_free(pd->properties_calc); 80 eina_array_free(pd->properties_calc);
81 81
82 eo_do_super(obj, MY_CLASS, eo_destructor()); 82 eo_do_super(obj, MY_CLASS, eo_destructor());
83} 83}
84 84
85static Emodel_Load_Status 85static Emodel_Load_Status
86_ejson_model_emodel_properties_list_get(Eo *obj EINA_UNUSED, 86_ejson_model_emodel_properties_get(Eo *obj EINA_UNUSED,
87 Ejson_Model_Data *pd, 87 Ejson_Model_Data *pd,
88 Eina_Array * const* properties_array) 88 Eina_Array * const* properties_array)
89{ 89{
90 DBG("(%p)", obj); 90 DBG("(%p)", obj);
91 EINA_SAFETY_ON_NULL_RETURN_VAL(pd, EMODEL_LOAD_STATUS_ERROR); 91 EINA_SAFETY_ON_NULL_RETURN_VAL(pd, EMODEL_LOAD_STATUS_ERROR);
@@ -120,6 +120,7 @@ _ejson_model_properties_load(Ejson_Model_Data *pd)
120 if (!pd->json) 120 if (!pd->json)
121 return; 121 return;
122 122
123 Eina_Array *changed_properties = eina_array_new(1);
123 Eina_Value *value = NULL; 124 Eina_Value *value = NULL;
124 switch (pd->type) 125 switch (pd->type)
125 { 126 {
@@ -127,30 +128,38 @@ _ejson_model_properties_load(Ejson_Model_Data *pd)
127 break; 128 break;
128 case EJSON_MODEL_TYPE_BOOLEAN: 129 case EJSON_MODEL_TYPE_BOOLEAN:
129 { 130 {
131 value = eina_hash_find(pd->properties_hash, EJSON_MODEL_VALUE_PROPERTY);
132 EINA_SAFETY_ON_NULL_GOTO(value, on_error);
130 json_bool v = json_object_get_boolean(pd->json); 133 json_bool v = json_object_get_boolean(pd->json);
131 value = eina_value_new(EINA_VALUE_TYPE_INT); 134 Eina_Bool ret = eina_value_set(value, v);
132 eina_value_set(value, v); 135 EINA_SAFETY_ON_FALSE_GOTO(ret, on_error);
133 break; 136 break;
134 } 137 }
135 case EJSON_MODEL_TYPE_DOUBLE: 138 case EJSON_MODEL_TYPE_DOUBLE:
136 { 139 {
140 value = eina_hash_find(pd->properties_hash, EJSON_MODEL_VALUE_PROPERTY);
141 EINA_SAFETY_ON_NULL_GOTO(value, on_error);
137 double v = json_object_get_boolean(pd->json); 142 double v = json_object_get_boolean(pd->json);
138 value = eina_value_new(EINA_VALUE_TYPE_DOUBLE); 143 Eina_Bool ret = eina_value_set(value, v);
139 eina_value_set(value, v); 144 EINA_SAFETY_ON_FALSE_GOTO(ret, on_error);
140 break; 145 break;
141 } 146 }
142 case EJSON_MODEL_TYPE_INT: 147 case EJSON_MODEL_TYPE_INT:
143 { 148 {
149 value = eina_hash_find(pd->properties_hash, EJSON_MODEL_VALUE_PROPERTY);
150 EINA_SAFETY_ON_NULL_GOTO(value, on_error);
144 int64_t v = json_object_get_int64(pd->json); 151 int64_t v = json_object_get_int64(pd->json);
145 value = eina_value_new(EINA_VALUE_TYPE_INT64); 152 Eina_Bool ret = eina_value_set(value, v);
146 eina_value_set(value, v); 153 EINA_SAFETY_ON_FALSE_GOTO(ret, on_error);
147 break; 154 break;
148 } 155 }
149 case EJSON_MODEL_TYPE_STRING: 156 case EJSON_MODEL_TYPE_STRING:
150 { 157 {
158 value = eina_hash_find(pd->properties_hash, EJSON_MODEL_VALUE_PROPERTY);
159 EINA_SAFETY_ON_NULL_GOTO(value, on_error);
151 const char *v = json_object_get_string(pd->json); 160 const char *v = json_object_get_string(pd->json);
152 value = eina_value_new(EINA_VALUE_TYPE_STRING); 161 Eina_Bool ret = eina_value_set(value, v);
153 eina_value_set(value, v); 162 EINA_SAFETY_ON_FALSE_GOTO(ret, on_error);
154 break; 163 break;
155 } 164 }
156 case EJSON_MODEL_TYPE_OBJECT: 165 case EJSON_MODEL_TYPE_OBJECT:
@@ -160,57 +169,60 @@ _ejson_model_properties_load(Ejson_Model_Data *pd)
160 } 169 }
161 170
162 if (value) 171 if (value)
163 { 172 eina_array_push(changed_properties, EJSON_MODEL_VALUE_PROPERTY);
164 Eina_Bool ret = eina_value_struct_value_set(pd->properties,
165 EJSON_MODEL_VALUE_PROPERTY,
166 value);
167 eina_value_free(value);
168 EINA_SAFETY_ON_FALSE_RETURN(ret);
169 }
170 173
171 if (EJSON_MODEL_TYPE_OBJECT == _ejson_model_parent_type_get(pd)) 174 if (EJSON_MODEL_TYPE_OBJECT == _ejson_model_parent_type_get(pd))
172 { 175 {
173 Eo *parent = eo_do(pd->obj, eo_parent_get()); 176 Eo *parent = eo_do_ret(pd->obj, parent, eo_parent_get());
174 177
175 Ejson_Model_Data *parent_pd = eo_data_scope_get(parent, EJSON_MODEL_CLASS); 178 Ejson_Model_Data *parent_pd = eo_data_scope_get(parent, EJSON_MODEL_CLASS);
176 EINA_SAFETY_ON_NULL_RETURN(parent_pd); 179 EINA_SAFETY_ON_NULL_GOTO(parent_pd, on_error);
177 180
178 Ejson_Model_Child_Data *child_data = eina_hash_find(parent_pd->children_hash, &pd->obj); 181 Ejson_Model_Child_Data *child_data = eina_hash_find(parent_pd->children_hash, &pd->obj);
179 EINA_SAFETY_ON_NULL_RETURN(child_data); 182 EINA_SAFETY_ON_NULL_GOTO(child_data, on_error);
183
184 value = eina_hash_find(pd->properties_hash, EJSON_MODEL_NAME_PROPERTY);
185 EINA_SAFETY_ON_NULL_GOTO(value, on_error);
180 186
181 Eina_Bool ret = eina_value_struct_set(pd->properties, 187 Eina_Bool ret = eina_value_set(value, child_data->name);
182 EJSON_MODEL_NAME_PROPERTY, 188 EINA_SAFETY_ON_FALSE_GOTO(ret, on_error);
183 child_data->name); 189
184 EINA_SAFETY_ON_FALSE_RETURN(ret); 190 ret = eina_array_push(changed_properties, EJSON_MODEL_NAME_PROPERTY);
191 EINA_SAFETY_ON_FALSE_GOTO(ret, on_error);
185 } 192 }
186 193
187 Emodel_Property_Event evt = {.changed_properties = pd->properties, 194 Emodel_Property_Event evt = {.changed_properties = changed_properties,
188 .invalidated_properties = pd->properties_calc}; 195 .invalidated_properties = pd->properties_calc};
189 eo_do(pd->obj, eo_event_callback_call(EMODEL_EVENT_PROPERTIES_CHANGED, &evt)); 196 eo_do(pd->obj, eo_event_callback_call(EMODEL_EVENT_PROPERTIES_CHANGED, &evt));
197
198on_error:
199 eina_array_free(changed_properties);
190} 200}
191 201
192static Emodel_Load_Status 202static Emodel_Load_Status
193_ejson_model_emodel_property_set(Eo *obj, 203_ejson_model_emodel_property_set(Eo *obj,
194 Ejson_Model_Data *pd, 204 Ejson_Model_Data *pd,
195 const char *property, 205 const char *property,
196 Eina_Value value) 206 const Eina_Value *value)
197{ 207{
198 EINA_SAFETY_ON_NULL_RETURN_VAL(property, EMODEL_LOAD_STATUS_ERROR); 208 EINA_SAFETY_ON_NULL_RETURN_VAL(property, EMODEL_LOAD_STATUS_ERROR);
199 DBG("(%p): property=%s", obj, property); 209 DBG("(%p): property=%s", obj, property);
200 210
211 Eina_Array *changed_properties = eina_array_new(1);
201 const bool is_json_property = strcmp(EJSON_MODEL_JSON_PROPERTY, property) == 0; 212 const bool is_json_property = strcmp(EJSON_MODEL_JSON_PROPERTY, property) == 0;
202 if (is_json_property) 213 if (is_json_property)
203 { 214 {
204 if (!_ejson_model_json_property_set(pd, &value)) 215 if (!_ejson_model_json_property_set(pd, value))
205 return EMODEL_LOAD_STATUS_ERROR; 216 goto on_error;
206 217
207 if (!(pd->load.status & EMODEL_LOAD_STATUS_LOADED)) 218 // only notify properties_changed if loaded
208 return pd->load.status; 219 if (pd->load.status & EMODEL_LOAD_STATUS_LOADED)
220 eina_array_push(changed_properties, EJSON_MODEL_JSON_PROPERTY);
209 } 221 }
210 else 222 else
211 { 223 {
212 if (!(pd->load.status & EMODEL_LOAD_STATUS_LOADED_PROPERTIES)) 224 if (!(pd->load.status & EMODEL_LOAD_STATUS_LOADED_PROPERTIES))
213 return EMODEL_LOAD_STATUS_ERROR; 225 goto on_error;
214 226
215 const bool is_name_property = strcmp(EJSON_MODEL_NAME_PROPERTY, property) == 0; 227 const bool is_name_property = strcmp(EJSON_MODEL_NAME_PROPERTY, property) == 0;
216 const bool is_value_property = strcmp(EJSON_MODEL_VALUE_PROPERTY, property) == 0; 228 const bool is_value_property = strcmp(EJSON_MODEL_VALUE_PROPERTY, property) == 0;
@@ -218,31 +230,41 @@ _ejson_model_emodel_property_set(Eo *obj,
218 if (!is_name_property && !is_value_property) 230 if (!is_name_property && !is_value_property)
219 { 231 {
220 ERR("Unrecognized property: %s", property); 232 ERR("Unrecognized property: %s", property);
221 return EMODEL_LOAD_STATUS_ERROR; 233 goto on_error;
222 } 234 }
223 235
224 if (is_name_property) 236 if (is_name_property)
225 { 237 {
226 if (!_ejson_model_name_property_set(pd, &value)) 238 if (!_ejson_model_name_property_set(pd, value))
227 return EMODEL_LOAD_STATUS_ERROR; 239 goto on_error;
240 eina_array_push(changed_properties, EJSON_MODEL_NAME_PROPERTY);
228 } 241 }
229 else if (is_value_property) 242 else if (is_value_property)
230 { 243 {
231 if (!_ejson_model_value_property_set(pd, &value)) 244 if (!_ejson_model_value_property_set(pd, value))
232 return EMODEL_LOAD_STATUS_ERROR; 245 goto on_error;
246 eina_array_push(changed_properties, EJSON_MODEL_VALUE_PROPERTY);
233 } 247 }
234 } 248 }
235 249
236 pd->json_property_valid = false; 250 if (eina_array_count(changed_properties))
237 Emodel_Property_Event evt = {.changed_properties = pd->properties, 251 {
238 .invalidated_properties = pd->properties_calc}; 252 pd->json_property_valid = false;
239 eo_do(pd->obj, eo_event_callback_call(EMODEL_EVENT_PROPERTIES_CHANGED, &evt)); 253 Emodel_Property_Event evt = {.changed_properties = changed_properties,
254 .invalidated_properties = pd->properties_calc};
255 eo_do(pd->obj, eo_event_callback_call(EMODEL_EVENT_PROPERTIES_CHANGED, &evt));
256 }
240 257
258 eina_array_free(changed_properties);
241 return pd->load.status; 259 return pd->load.status;
260
261on_error:
262 eina_array_free(changed_properties);
263 return EMODEL_LOAD_STATUS_ERROR;
242} 264}
243 265
244static bool 266static bool
245_ejson_model_name_property_set(Ejson_Model_Data *pd, Eina_Value *value) 267_ejson_model_name_property_set(Ejson_Model_Data *pd, const Eina_Value *value)
246{ 268{
247 DBG("(%p)", pd->obj); 269 DBG("(%p)", pd->obj);
248 Ejson_Model_Type parent_type = _ejson_model_parent_type_get(pd); 270 Ejson_Model_Type parent_type = _ejson_model_parent_type_get(pd);
@@ -252,14 +274,18 @@ _ejson_model_name_property_set(Ejson_Model_Data *pd, Eina_Value *value)
252 return false; 274 return false;
253 } 275 }
254 276
255 Eina_Bool ret = eina_value_struct_value_set(pd->properties, EJSON_MODEL_NAME_PROPERTY, value); 277 Eina_Value *prop_value = eina_hash_find(pd->properties_hash, EJSON_MODEL_NAME_PROPERTY);
278 EINA_SAFETY_ON_NULL_RETURN_VAL(prop_value, false);
279
280 eina_value_flush(prop_value);
281 Eina_Bool ret = eina_value_copy(value, prop_value);
256 EINA_SAFETY_ON_FALSE_RETURN_VAL(ret, false); 282 EINA_SAFETY_ON_FALSE_RETURN_VAL(ret, false);
257 283
258 return true; 284 return true;
259} 285}
260 286
261static bool 287static bool
262_ejson_model_value_property_set(Ejson_Model_Data *pd, Eina_Value *value) 288_ejson_model_value_property_set(Ejson_Model_Data *pd, const Eina_Value *value)
263{ 289{
264 DBG("(%p)", pd->obj); 290 DBG("(%p)", pd->obj);
265 const Eina_Value_Type * const value_type = eina_value_type_get(value); 291 const Eina_Value_Type * const value_type = eina_value_type_get(value);
@@ -312,7 +338,11 @@ _ejson_model_value_property_set(Ejson_Model_Data *pd, Eina_Value *value)
312 return false; 338 return false;
313 } 339 }
314 340
315 Eina_Bool ret = eina_value_struct_value_set(pd->properties, EJSON_MODEL_VALUE_PROPERTY, value); 341 Eina_Value *prop_value = eina_hash_find(pd->properties_hash, EJSON_MODEL_VALUE_PROPERTY);
342 EINA_SAFETY_ON_NULL_GOTO(prop_value, on_error);
343
344 eina_value_flush(prop_value);
345 Eina_Bool ret = eina_value_copy(value, prop_value);
316 EINA_SAFETY_ON_FALSE_GOTO(ret, on_error); 346 EINA_SAFETY_ON_FALSE_GOTO(ret, on_error);
317 347
318 json_object_put(pd->json); 348 json_object_put(pd->json);
@@ -326,7 +356,7 @@ on_error:
326} 356}
327 357
328static bool 358static bool
329_ejson_model_json_property_set(Ejson_Model_Data *pd, Eina_Value *value) 359_ejson_model_json_property_set(Ejson_Model_Data *pd, const Eina_Value *value)
330{ 360{
331 DBG("(%p)", pd->obj); 361 DBG("(%p)", pd->obj);
332 char *stream = eina_value_to_string(value); 362 char *stream = eina_value_to_string(value);
@@ -367,7 +397,7 @@ static Emodel_Load_Status
367_ejson_model_emodel_property_get(Eo *obj EINA_UNUSED, 397_ejson_model_emodel_property_get(Eo *obj EINA_UNUSED,
368 Ejson_Model_Data *pd, 398 Ejson_Model_Data *pd,
369 const char *property, 399 const char *property,
370 Eina_Value *value) 400 const Eina_Value **value)
371{ 401{
372 EINA_SAFETY_ON_NULL_RETURN_VAL(property, EMODEL_LOAD_STATUS_ERROR); 402 EINA_SAFETY_ON_NULL_RETURN_VAL(property, EMODEL_LOAD_STATUS_ERROR);
373 EINA_SAFETY_ON_NULL_RETURN_VAL(value, EMODEL_LOAD_STATUS_ERROR); 403 EINA_SAFETY_ON_NULL_RETURN_VAL(value, EMODEL_LOAD_STATUS_ERROR);
@@ -376,28 +406,21 @@ _ejson_model_emodel_property_get(Eo *obj EINA_UNUSED,
376 if (!(pd->load.status & EMODEL_LOAD_STATUS_LOADED_PROPERTIES)) 406 if (!(pd->load.status & EMODEL_LOAD_STATUS_LOADED_PROPERTIES))
377 return EMODEL_LOAD_STATUS_ERROR; 407 return EMODEL_LOAD_STATUS_ERROR;
378 408
379 if (strcmp(EJSON_MODEL_NAME_PROPERTY, property) == 0 || 409 *value = eina_hash_find(pd->properties_hash, property);
380 strcmp(EJSON_MODEL_VALUE_PROPERTY, property) == 0) 410 if (!(*value))
381 { 411 return EMODEL_LOAD_STATUS_ERROR;
382 if (!eina_value_struct_value_get(pd->properties, property, value))
383 return EMODEL_LOAD_STATUS_ERROR;
384 return pd->load.status;
385 }
386 412
387 if (strcmp(EJSON_MODEL_JSON_PROPERTY, property) == 0) 413 if ((strcmp(EJSON_MODEL_JSON_PROPERTY, property) == 0) && !pd->json_property_valid)
388 { 414 {
389 if (!pd->json_property_valid) 415 const char *json = json_object_to_json_string(pd->json);
390 { 416 Eina_Bool ret = eina_value_set((Eina_Value*)*value, json);
391 const char *json = json_object_to_json_string(pd->json); 417 pd->json_property_valid = EINA_TRUE == ret;
392 pd->json_property_valid = eina_value_struct_set(pd->properties, property, json) == EINA_TRUE;
393 }
394 418
395 if (!pd->json_property_valid || !eina_value_struct_value_get(pd->properties, property, value)) 419 if (!pd->json_property_valid)
396 return EMODEL_LOAD_STATUS_ERROR; 420 return EMODEL_LOAD_STATUS_ERROR;
397 return pd->load.status;
398 } 421 }
399 422
400 return EMODEL_LOAD_STATUS_ERROR; 423 return pd->load.status;
401} 424}
402 425
403static void 426static void
@@ -456,7 +479,8 @@ _ejson_model_child_properties_changed_cb(void *data,
456 //eo_do(child, eo_event_callback_del(EMODEL_EVENT_PROPERTIES_CHANGED, _ejson_model_child_properties_changed_cb, pd)); 479 //eo_do(child, eo_event_callback_del(EMODEL_EVENT_PROPERTIES_CHANGED, _ejson_model_child_properties_changed_cb, pd));
457 480
458 // Only user changes count 481 // Only user changes count
459 Emodel_Load_Status child_status = eo_do(child, emodel_load_status_get()); 482 Emodel_Load_Status child_status;
483 eo_do(child, child_status = emodel_load_status_get());
460 if (!(child_status & EMODEL_LOAD_STATUS_LOADED_PROPERTIES)) 484 if (!(child_status & EMODEL_LOAD_STATUS_LOADED_PROPERTIES))
461 return EO_CALLBACK_CONTINUE; 485 return EO_CALLBACK_CONTINUE;
462 486
@@ -466,9 +490,10 @@ _ejson_model_child_properties_changed_cb(void *data,
466 const char *current_name = NULL; 490 const char *current_name = NULL;
467 if (EJSON_MODEL_TYPE_OBJECT == pd->type) 491 if (EJSON_MODEL_TYPE_OBJECT == pd->type)
468 { 492 {
469 Eina_Bool ret = eina_value_struct_get(child_pd->properties, 493 Eina_Value *value = eina_hash_find(child_pd->properties_hash, EJSON_MODEL_NAME_PROPERTY);
470 EJSON_MODEL_NAME_PROPERTY, 494 EINA_SAFETY_ON_NULL_RETURN_VAL(value, EO_CALLBACK_STOP);
471 &current_name); 495
496 Eina_Bool ret = eina_value_get(value, &current_name);
472 EINA_SAFETY_ON_FALSE_RETURN_VAL(ret, EO_CALLBACK_STOP); 497 EINA_SAFETY_ON_FALSE_RETURN_VAL(ret, EO_CALLBACK_STOP);
473 498
474 // Continue only if the name is already assigned 499 // Continue only if the name is already assigned
@@ -637,7 +662,7 @@ _ejson_model_emodel_child_del(Eo *obj,
637 662
638 pd->json_property_valid = false; 663 pd->json_property_valid = false;
639 unsigned int count = eina_list_count(pd->children_list); 664 unsigned int count = eina_list_count(pd->children_list);
640 Emodel_Property_Event prop_event = {.changed_properties = pd->properties, 665 Emodel_Property_Event prop_event = {.changed_properties = pd->properties_array,
641 .invalidated_properties = pd->properties_calc}; 666 .invalidated_properties = pd->properties_calc};
642 Emodel_Children_Event added_event = {.child = child, .index = count}; 667 Emodel_Children_Event added_event = {.child = child, .index = count};
643 eo_do(obj, eo_event_callback_call(EMODEL_EVENT_PROPERTIES_CHANGED, &prop_event), 668 eo_do(obj, eo_event_callback_call(EMODEL_EVENT_PROPERTIES_CHANGED, &prop_event),
@@ -807,8 +832,7 @@ _ejson_model_clear(Ejson_Model_Data *pd)
807 EINA_LIST_FREE(pd->children_list, child) 832 EINA_LIST_FREE(pd->children_list, child)
808 eo_del(child); 833 eo_del(child);
809 834
810 eina_value_free(pd->properties); 835 eina_hash_free_buckets(pd->properties_hash);
811 pd->properties = NULL;
812 836
813 if (pd->properties_array) 837 if (pd->properties_array)
814 { 838 {
@@ -822,8 +846,6 @@ _ejson_model_clear(Ejson_Model_Data *pd)
822 846
823 free(pd->stream); 847 free(pd->stream);
824 pd->stream = NULL; 848 pd->stream = NULL;
825
826 emodel_value_struct_desc_free(pd->properties_desc);
827} 849}
828 850
829typedef struct _Ejson_Model_Properties_Setup 851typedef struct _Ejson_Model_Properties_Setup
@@ -889,24 +911,26 @@ _ejson_model_properties_setup(Ejson_Model_Data *pd)
889 } 911 }
890 912
891 pd->properties_array = eina_array_new(member_count); 913 pd->properties_array = eina_array_new(member_count);
892 pd->properties_desc = emodel_value_struct_desc_new(member_count, _ejson_model_properties_setup_cb, &setup); 914 for (size_t i = 0; i < member_count; ++i)
893 pd->properties = eina_value_struct_new(pd->properties_desc); 915 {
894 DBG("(%p) Properties setup done", pd->obj); 916 Eina_Bool ret = eina_array_push(pd->properties_array, setup.member_name[i]);
895} 917 EINA_SAFETY_ON_FALSE_RETURN(ret);
896 918
897static void 919 const Eina_Value_Type *type = setup.member_type[i];
898_ejson_model_properties_setup_cb(void *data, int index, Eina_Value_Struct_Member *member) 920 Eina_Value *value = eina_value_new(type);
899{ 921 EINA_SAFETY_ON_NULL_RETURN(value);
900 Ejson_Model_Properties_Setup *setup = (Ejson_Model_Properties_Setup*)data; 922
901 member->name = eina_stringshare_add(setup->member_name[index]); 923 ret = eina_hash_add(pd->properties_hash, setup.member_name[i], value);
902 member->type = setup->member_type[index]; 924 EINA_SAFETY_ON_FALSE_RETURN(ret);
903 eina_array_push(setup->pd->properties_array, setup->member_name[index]); 925 }
926
927 DBG("(%p) Properties setup done", pd->obj);
904} 928}
905 929
906static Ejson_Model_Type 930static Ejson_Model_Type
907_ejson_model_parent_type_get(Ejson_Model_Data *pd) 931_ejson_model_parent_type_get(Ejson_Model_Data *pd)
908{ 932{
909 Eo *parent = eo_do(pd->obj, eo_parent_get()); 933 Eo *parent = eo_do_ret(pd->obj, parent, eo_parent_get());
910 if (!parent) 934 if (!parent)
911 return EJSON_MODEL_TYPE_NULL; 935 return EJSON_MODEL_TYPE_NULL;
912 936
@@ -917,18 +941,23 @@ _ejson_model_parent_type_get(Ejson_Model_Data *pd)
917} 941}
918 942
919static void 943static void
920_ejson_model_children_hash_free(void *data) 944_ejson_model_children_hash_free(Ejson_Model_Child_Data *child)
921{ 945{
922 Ejson_Model_Child_Data *child = (Ejson_Model_Child_Data*)data;
923 eina_stringshare_del(child->name); 946 eina_stringshare_del(child->name);
924 free(child); 947 free(child);
925} 948}
926 949
927static void 950static void
951_ejson_model_properties_hash_free(Eina_Value *value)
952{
953 eina_value_free(value);
954}
955
956static void
928_ejson_model_invalidate(Ejson_Model_Data *pd) 957_ejson_model_invalidate(Ejson_Model_Data *pd)
929{ 958{
930 Eo *parent = pd->obj; 959 Eo *parent = pd->obj;
931 while ((parent = eo_do(parent, eo_parent_get()))) 960 while ((parent = eo_do_ret(parent, parent, eo_parent_get())))
932 { 961 {
933 Ejson_Model_Data *parent_pd = eo_data_scope_get(parent, EJSON_MODEL_CLASS); 962 Ejson_Model_Data *parent_pd = eo_data_scope_get(parent, EJSON_MODEL_CLASS);
934 parent_pd->json_property_valid = false; 963 parent_pd->json_property_valid = false;
@@ -975,7 +1004,7 @@ _ejson_model_type_from_json_object(json_object *json)
975} 1004}
976 1005
977static Eina_Bool 1006static Eina_Bool
978_ejson_model_eina_value_as(Eina_Value *value, const Eina_Value_Type *type, void *mem) 1007_ejson_model_eina_value_as(const Eina_Value *value, const Eina_Value_Type *type, void *mem)
979{ 1008{
980 const Eina_Value_Type * const value_type = eina_value_type_get(value); 1009 const Eina_Value_Type * const value_type = eina_value_type_get(value);
981 EINA_SAFETY_ON_NULL_RETURN_VAL(value_type, false); 1010 EINA_SAFETY_ON_NULL_RETURN_VAL(value_type, false);
diff --git a/src/lib/ejson_model.eo b/src/lib/ejson_model.eo
index 218ed63..ad0848c 100644
--- a/src/lib/ejson_model.eo
+++ b/src/lib/ejson_model.eo
@@ -23,7 +23,7 @@ class Ejson.Model (Eo.Base, Emodel) {
23 implements { 23 implements {
24 Eo.Base.constructor; 24 Eo.Base.constructor;
25 Eo.Base.destructor; 25 Eo.Base.destructor;
26 Emodel.properties_list.get; 26 Emodel.properties.get;
27 Emodel.properties_load; 27 Emodel.properties_load;
28 Emodel.property.set; 28 Emodel.property.set;
29 Emodel.property.get; 29 Emodel.property.get;
diff --git a/src/lib/ejson_model_private.h b/src/lib/ejson_model_private.h
index 36bab35..5342fe9 100644
--- a/src/lib/ejson_model_private.h
+++ b/src/lib/ejson_model_private.h
@@ -21,8 +21,7 @@ struct _Ejson_Model_Data
21 Emodel_Load load; 21 Emodel_Load load;
22 json_object *json; 22 json_object *json;
23 Eina_Array *properties_array; 23 Eina_Array *properties_array;
24 Eina_Value_Struct_Desc *properties_desc; 24 Eina_Hash *properties_hash;
25 Eina_Value *properties;
26 Eina_List *children_list; 25 Eina_List *children_list;
27 Eina_Hash *children_hash; 26 Eina_Hash *children_hash;
28 Ejson_Model_Type type; 27 Ejson_Model_Type type;
diff --git a/src/tests/ejson_suite.h b/src/tests/ejson_suite.h
index c91fc31..ac1dbcd 100644
--- a/src/tests/ejson_suite.h
+++ b/src/tests/ejson_suite.h
@@ -1,5 +1,5 @@
1#ifndef _ESQL_SUITE_H 1#ifndef _EJSON_SUITE_H
2#define _ESQL_SUITE_H 2#define _EJSON_SUITE_H
3 3
4#include <check.h> 4#include <check.h>
5 5
diff --git a/src/tests/ejson_test_ejson_model.c b/src/tests/ejson_test_ejson_model.c
index ec01d0a..ed75413 100644
--- a/src/tests/ejson_test_ejson_model.c
+++ b/src/tests/ejson_test_ejson_model.c
@@ -41,7 +41,8 @@ _eo_event_load_status_cb(void *data, Eo *obj EINA_UNUSED,
41static void 41static void
42_wait_until_load_status(Emodel *emodel, Emodel_Load_Status expected_status) 42_wait_until_load_status(Emodel *emodel, Emodel_Load_Status expected_status)
43{ 43{
44 Emodel_Load_Status actual_status = eo_do(emodel, emodel_load_status_get()); 44 Emodel_Load_Status actual_status;
45 eo_do(emodel, actual_status = emodel_load_status_get());
45 if (expected_status == actual_status) return; 46 if (expected_status == actual_status) return;
46 47
47 eo_do(emodel, eo_event_callback_add(EMODEL_EVENT_LOAD_STATUS, _eo_event_load_status_cb, &expected_status)); 48 eo_do(emodel, eo_event_callback_add(EMODEL_EVENT_LOAD_STATUS, _eo_event_load_status_cb, &expected_status));
@@ -52,21 +53,22 @@ _wait_until_load_status(Emodel *emodel, Emodel_Load_Status expected_status)
52static void 53static void
53_check_json_string(Emodel *model, const char *expected_json_string) 54_check_json_string(Emodel *model, const char *expected_json_string)
54{ 55{
55 Eina_Value json_value; 56 const Eina_Value *json_value;
56 Emodel_Load_Status status = eo_do(model, emodel_property_get(EJSON_MODEL_JSON_PROPERTY, &json_value)); 57 Emodel_Load_Status status;
58 eo_do(model, status = emodel_property_get(EJSON_MODEL_JSON_PROPERTY, &json_value));
57 ck_assert_int_eq(EMODEL_LOAD_STATUS_LOADED_PROPERTIES, status & EMODEL_LOAD_STATUS_LOADED_PROPERTIES); 59 ck_assert_int_eq(EMODEL_LOAD_STATUS_LOADED_PROPERTIES, status & EMODEL_LOAD_STATUS_LOADED_PROPERTIES);
60 ck_assert_ptr_ne(NULL, json_value);
58 61
59 const char *actual_json_string; 62 const char *actual_json_string;
60 fail_unless(eina_value_get(&json_value, &actual_json_string)); 63 fail_unless(eina_value_get(json_value, &actual_json_string));
61 64
62 ck_assert_str_eq(expected_json_string, actual_json_string); 65 ck_assert_str_eq(expected_json_string, actual_json_string);
63 eina_value_flush(&json_value);
64} 66}
65 67
66static void 68static void
67_check_value_type_cannot_have_children(Emodel *model) 69_check_value_type_cannot_have_children(Emodel *model)
68{ 70{
69 Emodel *child = eo_do(model, emodel_child_add()); 71 Emodel *child = eo_do_ret(model, child, emodel_child_add());
70 ck_assert_ptr_eq(NULL, child); 72 ck_assert_ptr_eq(NULL, child);
71} 73}
72 74
@@ -76,7 +78,8 @@ _json_property_set(Emodel *model, const char *v)
76 Eina_Value json; 78 Eina_Value json;
77 eina_value_setup(&json, EINA_VALUE_TYPE_STRING); 79 eina_value_setup(&json, EINA_VALUE_TYPE_STRING);
78 eina_value_set(&json, v); 80 eina_value_set(&json, v);
79 Emodel_Load_Status status = eo_do(model, emodel_property_set(EJSON_MODEL_JSON_PROPERTY, json)); 81 Emodel_Load_Status status;
82 eo_do(model, status = emodel_property_set(EJSON_MODEL_JSON_PROPERTY, &json));
80 eina_value_flush(&json); 83 eina_value_flush(&json);
81 return status; 84 return status;
82} 85}
@@ -87,7 +90,8 @@ _check_name_property_set(Emodel *model, const char *v)
87 Eina_Value name; 90 Eina_Value name;
88 eina_value_setup(&name, EINA_VALUE_TYPE_STRING); 91 eina_value_setup(&name, EINA_VALUE_TYPE_STRING);
89 eina_value_set(&name, v); 92 eina_value_set(&name, v);
90 Emodel_Load_Status status = eo_do(model, emodel_property_set(EJSON_MODEL_NAME_PROPERTY, name)); 93 Emodel_Load_Status status;
94 eo_do(model, status = emodel_property_set(EJSON_MODEL_NAME_PROPERTY, &name));
91 ck_assert_int_eq(EMODEL_LOAD_STATUS_LOADED, status); 95 ck_assert_int_eq(EMODEL_LOAD_STATUS_LOADED, status);
92 eina_value_flush(&name); 96 eina_value_flush(&name);
93} 97}
@@ -99,7 +103,8 @@ _check_int_value_property_set(Emodel *model, int64_t v)
99 eina_value_setup(&value, EINA_VALUE_TYPE_INT64); 103 eina_value_setup(&value, EINA_VALUE_TYPE_INT64);
100 eina_value_set(&value, v); 104 eina_value_set(&value, v);
101 105
102 Emodel_Load_Status status = eo_do(model, emodel_property_set(EJSON_MODEL_VALUE_PROPERTY, value)); 106 Emodel_Load_Status status;
107 eo_do(model, status = emodel_property_set(EJSON_MODEL_VALUE_PROPERTY, &value));
103 ck_assert_int_eq(EMODEL_LOAD_STATUS_LOADED, status); 108 ck_assert_int_eq(EMODEL_LOAD_STATUS_LOADED, status);
104 109
105 char buf[64]; 110 char buf[64];
@@ -117,7 +122,8 @@ _check_bool_value_property_set(Emodel *model, bool v)
117 eina_value_setup(&value, EINA_VALUE_TYPE_INT); 122 eina_value_setup(&value, EINA_VALUE_TYPE_INT);
118 eina_value_set(&value, (int)v); 123 eina_value_set(&value, (int)v);
119 124
120 Emodel_Load_Status status = eo_do(model, emodel_property_set(EJSON_MODEL_VALUE_PROPERTY, value)); 125 Emodel_Load_Status status;
126 eo_do(model, status = emodel_property_set(EJSON_MODEL_VALUE_PROPERTY, &value));
121 ck_assert_int_eq(EMODEL_LOAD_STATUS_LOADED, status); 127 ck_assert_int_eq(EMODEL_LOAD_STATUS_LOADED, status);
122 128
123 _check_json_string(model, v ? "true" : "false"); 129 _check_json_string(model, v ? "true" : "false");
@@ -132,7 +138,8 @@ _check_string_value_property_set(Emodel *model, const char *v)
132 eina_value_setup(&value, EINA_VALUE_TYPE_STRING); 138 eina_value_setup(&value, EINA_VALUE_TYPE_STRING);
133 eina_value_set(&value, v); 139 eina_value_set(&value, v);
134 140
135 Emodel_Load_Status status = eo_do(model, emodel_property_set(EJSON_MODEL_VALUE_PROPERTY, value)); 141 Emodel_Load_Status status;
142 eo_do(model, status = emodel_property_set(EJSON_MODEL_VALUE_PROPERTY, &value));
136 ck_assert_int_eq(EMODEL_LOAD_STATUS_LOADED, status); 143 ck_assert_int_eq(EMODEL_LOAD_STATUS_LOADED, status);
137 144
138 size_t len = 1 + strlen(v) + 1 + 1; 145 size_t len = 1 + strlen(v) + 1 + 1;
@@ -155,42 +162,43 @@ _check_emodel_children_count_eq(Emodel *model, unsigned int expected_children_co
155static void 162static void
156_check_emodel_property_int_eq(Emodel *emodel, const char *property, int64_t expected_value) 163_check_emodel_property_int_eq(Emodel *emodel, const char *property, int64_t expected_value)
157{ 164{
158 Eina_Value value; 165 const Eina_Value *value;
159 Emodel_Load_Status status = eo_do(emodel, emodel_property_get(property, &value)); 166 Emodel_Load_Status status;
167 eo_do(emodel, status = emodel_property_get(property, &value));
160 ck_assert_int_eq(EMODEL_LOAD_STATUS_LOADED, status); 168 ck_assert_int_eq(EMODEL_LOAD_STATUS_LOADED, status);
169 ck_assert_ptr_ne(NULL, value);
161 170
162 const Eina_Value_Type *property_type = eina_value_type_get(&value); 171 const Eina_Value_Type *property_type = eina_value_type_get(value);
163 ck_assert_ptr_eq(EINA_VALUE_TYPE_INT64, property_type); 172 ck_assert_ptr_eq(EINA_VALUE_TYPE_INT64, property_type);
164 173
165 int64_t actual_value = 0; 174 int64_t actual_value = 0;
166 eina_value_get(&value, &actual_value); 175 eina_value_get(value, &actual_value);
167 ck_assert_int_eq(expected_value, actual_value); 176 ck_assert_int_eq(expected_value, actual_value);
168
169 eina_value_flush(&value);
170} 177}
171 178
172static void 179static void
173_check_emodel_property_str_eq(Emodel *emodel, const char *property, const char *expected_value) 180_check_emodel_property_str_eq(Emodel *emodel, const char *property, const char *expected_value)
174{ 181{
175 Eina_Value value; 182 const Eina_Value *value;
176 Emodel_Load_Status status = eo_do(emodel, emodel_property_get(property, &value)); 183 Emodel_Load_Status status;
184 eo_do(emodel, status = emodel_property_get(property, &value));
177 ck_assert_int_eq(EMODEL_LOAD_STATUS_LOADED, status); 185 ck_assert_int_eq(EMODEL_LOAD_STATUS_LOADED, status);
186 ck_assert_ptr_ne(NULL, value);
178 187
179 const Eina_Value_Type *property_type = eina_value_type_get(&value); 188 const Eina_Value_Type *property_type = eina_value_type_get(value);
180 fail_if(EINA_VALUE_TYPE_STRING != property_type && EINA_VALUE_TYPE_STRINGSHARE != property_type); 189 fail_if(EINA_VALUE_TYPE_STRING != property_type && EINA_VALUE_TYPE_STRINGSHARE != property_type);
181 190
182 const char *actual_value = NULL; 191 const char *actual_value = NULL;
183 eina_value_get(&value, &actual_value); 192 eina_value_get(value, &actual_value);
184 ck_assert_str_eq(expected_value, actual_value); 193 ck_assert_str_eq(expected_value, actual_value);
185
186 eina_value_flush(&value);
187} 194}
188 195
189static Emodel * 196static Emodel *
190_emodel_nth_child_get(Emodel *emodel, unsigned int n) 197_emodel_nth_child_get(Emodel *emodel, unsigned int n)
191{ 198{
192 Eina_Accessor *accessor; 199 Eina_Accessor *accessor;
193 Emodel_Load_Status status = eo_do(emodel, emodel_children_slice_get(n, 1, &accessor)); 200 Emodel_Load_Status status;
201 eo_do(emodel, status = emodel_children_slice_get(n, 1, &accessor));
194 ck_assert_int_eq(EMODEL_LOAD_STATUS_LOADED, status); 202 ck_assert_int_eq(EMODEL_LOAD_STATUS_LOADED, status);
195 ck_assert_ptr_ne(NULL, accessor); 203 ck_assert_ptr_ne(NULL, accessor);
196 Emodel *child = NULL; 204 Emodel *child = NULL;
@@ -204,7 +212,8 @@ _emodel_nth_child_get(Emodel *emodel, unsigned int n)
204static void 212static void
205_check_ejson_type(Emodel *model, Ejson_Model_Type expected_type) 213_check_ejson_type(Emodel *model, Ejson_Model_Type expected_type)
206{ 214{
207 Ejson_Model_Type actual_type = eo_do(model, ejson_model_type_get()); 215 Ejson_Model_Type actual_type;
216 eo_do(model, actual_type = ejson_model_type_get());
208 ck_assert_int_eq(expected_type, actual_type); 217 ck_assert_int_eq(expected_type, actual_type);
209} 218}
210 219
@@ -219,7 +228,8 @@ static void
219_check_emodel_properties(Emodel *model, const char *expected_properties[]) 228_check_emodel_properties(Emodel *model, const char *expected_properties[])
220{ 229{
221 Eina_Array *properties = NULL; 230 Eina_Array *properties = NULL;
222 Emodel_Load_Status status = eo_do(model, emodel_properties_list_get(&properties)); 231 Emodel_Load_Status status;
232 eo_do(model, status = emodel_properties_get(&properties));
223 ck_assert_int_eq(EMODEL_LOAD_STATUS_LOADED, status); 233 ck_assert_int_eq(EMODEL_LOAD_STATUS_LOADED, status);
224 ck_assert_ptr_ne(NULL, properties); 234 ck_assert_ptr_ne(NULL, properties);
225 235
@@ -243,7 +253,8 @@ static void
243_check_properties_count_eq(Emodel *model, unsigned int expected_properties_count) 253_check_properties_count_eq(Emodel *model, unsigned int expected_properties_count)
244{ 254{
245 Eina_Array *properties = NULL; 255 Eina_Array *properties = NULL;
246 Emodel_Load_Status status = eo_do(model, emodel_properties_list_get(&properties)); 256 Emodel_Load_Status status;
257 eo_do(model, status = emodel_properties_get(&properties));
247 ck_assert_int_ne(EMODEL_LOAD_STATUS_ERROR, status); 258 ck_assert_int_ne(EMODEL_LOAD_STATUS_ERROR, status);
248 if (!expected_properties_count && !properties) 259 if (!expected_properties_count && !properties)
249 return; 260 return;
@@ -285,15 +296,15 @@ START_TEST(object_property_set)
285 296
286 _check_json_string(json, "{ }"); 297 _check_json_string(json, "{ }");
287 298
288 Emodel *child = eo_do(json, emodel_child_add()); 299 Emodel *child = eo_do_ret(json, child, emodel_child_add());
289 ck_assert_ptr_ne(NULL, child); 300 ck_assert_ptr_ne(NULL, child);
290 301
291 _check_json_string(json, "{ }"); 302 _check_json_string(json, "{ }");
292 303
293 Ejson_Model_Type type = eo_do(child, ejson_model_type_get()); 304 Ejson_Model_Type type = eo_do_ret(child, type, ejson_model_type_get());
294 ck_assert_int_eq(EJSON_MODEL_TYPE_NULL, type); 305 ck_assert_int_eq(EJSON_MODEL_TYPE_NULL, type);
295 eo_do(child, ejson_model_type_set(EJSON_MODEL_TYPE_INT)); 306 eo_do(child, ejson_model_type_set(EJSON_MODEL_TYPE_INT));
296 type = eo_do(child, ejson_model_type_get()); 307 eo_do(child, type = ejson_model_type_get());
297 ck_assert_int_eq(EJSON_MODEL_TYPE_INT, type); 308 ck_assert_int_eq(EJSON_MODEL_TYPE_INT, type);
298 309
299 _check_emodel_load(child); 310 _check_emodel_load(child);
@@ -328,15 +339,15 @@ START_TEST(array_object_property_set)
328 339
329 _check_json_string(json, "[ ]"); 340 _check_json_string(json, "[ ]");
330 341
331 Emodel *child = eo_do(json, emodel_child_add()); 342 Emodel *child = eo_do_ret(json, child, emodel_child_add());
332 ck_assert_ptr_ne(NULL, child); 343 ck_assert_ptr_ne(NULL, child);
333 344
334 _check_json_string(json, "[ ]"); 345 _check_json_string(json, "[ ]");
335 346
336 Ejson_Model_Type type = eo_do(child, ejson_model_type_get()); 347 Ejson_Model_Type type = eo_do_ret(child, type, ejson_model_type_get());
337 ck_assert_int_eq(EJSON_MODEL_TYPE_NULL, type); 348 ck_assert_int_eq(EJSON_MODEL_TYPE_NULL, type);
338 eo_do(child, ejson_model_type_set(EJSON_MODEL_TYPE_INT)); 349 eo_do(child, ejson_model_type_set(EJSON_MODEL_TYPE_INT));
339 type = eo_do(child, ejson_model_type_get()); 350 eo_do(child, type = ejson_model_type_get());
340 ck_assert_int_eq(EJSON_MODEL_TYPE_INT, type); 351 ck_assert_int_eq(EJSON_MODEL_TYPE_INT, type);
341 352
342 _check_emodel_load(child); 353 _check_emodel_load(child);
@@ -487,12 +498,13 @@ START_TEST(load_status_get)
487 ejson_model_constructor(EJSON_MODEL_TYPE_NULL)); 498 ejson_model_constructor(EJSON_MODEL_TYPE_NULL));
488 ck_assert_ptr_ne(NULL, json); 499 ck_assert_ptr_ne(NULL, json);
489 500
490 Emodel_Load_Status status = eo_do(json, emodel_load_status_get()); 501 Emodel_Load_Status status;
502 eo_do(json, status = emodel_load_status_get());
491 ck_assert_int_eq(EMODEL_LOAD_STATUS_UNLOADED, status); 503 ck_assert_int_eq(EMODEL_LOAD_STATUS_UNLOADED, status);
492 504
493 _check_emodel_load(json); 505 _check_emodel_load(json);
494 506
495 status = eo_do(json, emodel_load_status_get()); 507 eo_do(json, status = emodel_load_status_get());
496 ck_assert_int_eq(EMODEL_LOAD_STATUS_LOADED, status); 508 ck_assert_int_eq(EMODEL_LOAD_STATUS_LOADED, status);
497 509
498 eo_unref(json); 510 eo_unref(json);
@@ -525,7 +537,7 @@ _create_model_with_all_json_types()
525 return json; 537 return json;
526} 538}
527 539
528START_TEST(properties_list_get) 540START_TEST(properties_get)
529{ 541{
530 Emodel *json = _create_model_with_all_json_types(); 542 Emodel *json = _create_model_with_all_json_types();
531 543
@@ -738,7 +750,7 @@ ejson_test_ejson_model(TCase *tc)
738 tcase_add_test(tc, json_object_property_set); 750 tcase_add_test(tc, json_object_property_set);
739 tcase_add_test(tc, json_array_property_set); 751 tcase_add_test(tc, json_array_property_set);
740 tcase_add_test(tc, load_status_get); 752 tcase_add_test(tc, load_status_get);
741 tcase_add_test(tc, properties_list_get); 753 tcase_add_test(tc, properties_get);
742 tcase_add_test(tc, unload); 754 tcase_add_test(tc, unload);
743 tcase_add_test(tc, properties_load); 755 tcase_add_test(tc, properties_load);
744 tcase_add_test(tc, children_load); 756 tcase_add_test(tc, children_load);
diff --git a/src/tests/ejson_test_ejson_model.h b/src/tests/ejson_test_ejson_model.h
index 9098151..ea5c939 100644
--- a/src/tests/ejson_test_ejson_model.h
+++ b/src/tests/ejson_test_ejson_model.h
@@ -1,5 +1,5 @@
1#ifndef _ESQL_TEST_ESQL_MODEL_H 1#ifndef _EJSON_TEST_EJSON_MODEL_H
2#define _ESQL_TEST_ESQL_MODEL_H 2#define _EJSON_TEST_EJSON_MODEL_H
3 3
4#include <Ejson.h> 4#include <Ejson.h>
5 5