summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuilherme Lepsch <lepsch@expertisesolutions.com.br>2015-03-19 11:30:23 -0300
committerGuilherme Lepsch <lepsch@expertisesolutions.com.br>2015-03-19 11:30:23 -0300
commit50f24cedfdfbfcec60fc9f7618ab168557ba9175 (patch)
treed72e79cc2dd931311f309ffccaf2262cd787c9a1
parent9b93f36e323682a553848b197b24bbf13374bd5f (diff)
Emodel API changesHEADmaster
-rw-r--r--src/lib/soap_model.c28
-rw-r--r--src/lib/soap_model.eo2
-rw-r--r--src/tests/soap_model_test_soap_model.c41
3 files changed, 38 insertions, 33 deletions
diff --git a/src/lib/soap_model.c b/src/lib/soap_model.c
index e2f760a..9dcdcc5 100644
--- a/src/lib/soap_model.c
+++ b/src/lib/soap_model.c
@@ -148,15 +148,15 @@ _soap_model_eo_base_destructor(Eo *obj, Soap_Model_Data *pd)
148} 148}
149 149
150static Emodel_Load_Status 150static Emodel_Load_Status
151_soap_model_emodel_properties_list_get(Eo *obj EINA_UNUSED, 151_soap_model_emodel_properties_get(Eo *obj EINA_UNUSED,
152 Soap_Model_Data *pd, 152 Soap_Model_Data *pd,
153 Eina_Array * const* properties_array) 153 Eina_Array * const* properties_array)
154{ 154{
155 DBG("(%p)", obj); 155 DBG("(%p)", obj);
156 EINA_SAFETY_ON_NULL_RETURN_VAL(pd, EMODEL_LOAD_STATUS_ERROR); 156 EINA_SAFETY_ON_NULL_RETURN_VAL(pd, EMODEL_LOAD_STATUS_ERROR);
157 EINA_SAFETY_ON_NULL_RETURN_VAL(pd->obj, EMODEL_LOAD_STATUS_ERROR); 157 EINA_SAFETY_ON_NULL_RETURN_VAL(pd->obj, EMODEL_LOAD_STATUS_ERROR);
158 158
159 eo_do(pd->xml, emodel_properties_list_get(properties_array)); 159 eo_do(pd->xml, emodel_properties_get(properties_array));
160 return pd->load.status; 160 return pd->load.status;
161} 161}
162 162
@@ -187,10 +187,10 @@ static Emodel_Load_Status
187_soap_model_emodel_property_set(Eo *obj EINA_UNUSED, 187_soap_model_emodel_property_set(Eo *obj EINA_UNUSED,
188 Soap_Model_Data *pd, 188 Soap_Model_Data *pd,
189 const char *property, 189 const char *property,
190 Eina_Value value) 190 const Eina_Value *value)
191{ 191{
192 Emodel_Load_Status status = eo_do(pd->xml, 192 Emodel_Load_Status status;
193 emodel_property_set(property, value)); 193 eo_do(pd->xml, status = emodel_property_set(property, value));
194 EINA_SAFETY_ON_FALSE_RETURN_VAL(status != EMODEL_LOAD_STATUS_ERROR, EMODEL_LOAD_STATUS_ERROR); 194 EINA_SAFETY_ON_FALSE_RETURN_VAL(status != EMODEL_LOAD_STATUS_ERROR, EMODEL_LOAD_STATUS_ERROR);
195 return pd->load.status; 195 return pd->load.status;
196} 196}
@@ -199,10 +199,10 @@ static Emodel_Load_Status
199_soap_model_emodel_property_get(Eo *obj EINA_UNUSED, 199_soap_model_emodel_property_get(Eo *obj EINA_UNUSED,
200 Soap_Model_Data *pd, 200 Soap_Model_Data *pd,
201 const char *property, 201 const char *property,
202 Eina_Value *value) 202 const Eina_Value **value)
203{ 203{
204 Emodel_Load_Status status = eo_do(pd->xml, 204 Emodel_Load_Status status;
205 emodel_property_get(property, value)); 205 eo_do(pd->xml, status = emodel_property_get(property, value));
206 EINA_SAFETY_ON_FALSE_RETURN_VAL(status != EMODEL_LOAD_STATUS_ERROR, EMODEL_LOAD_STATUS_ERROR); 206 EINA_SAFETY_ON_FALSE_RETURN_VAL(status != EMODEL_LOAD_STATUS_ERROR, EMODEL_LOAD_STATUS_ERROR);
207 return pd->load.status; 207 return pd->load.status;
208} 208}
@@ -309,14 +309,14 @@ _soap_model_children_load(Soap_Model_Data *pd)
309 309
310 emodel_load_set(pd->obj, &pd->load, EMODEL_LOAD_STATUS_LOADING_CHILDREN); 310 emodel_load_set(pd->obj, &pd->load, EMODEL_LOAD_STATUS_LOADING_CHILDREN);
311 311
312 Eina_Value xml_value; 312 const Eina_Value *xml_value;
313 Emodel_Load_Status status = eo_do(pd->xml, emodel_property_get("/", &xml_value)); 313 Emodel_Load_Status status;
314 eo_do(pd->xml, status = emodel_property_get("/", &xml_value));
314 EINA_SAFETY_ON_FALSE_RETURN(EMODEL_LOAD_STATUS_LOADED_PROPERTIES & status); 315 EINA_SAFETY_ON_FALSE_RETURN(EMODEL_LOAD_STATUS_LOADED_PROPERTIES & status);
315 316
316 const char *xml = NULL; 317 const char *xml = NULL;
317 eina_value_get(&xml_value, &xml); 318 eina_value_get(xml_value, &xml);
318 _soap_model_perform(pd, xml); 319 _soap_model_perform(pd, xml);
319 eina_value_flush(&xml_value);
320} 320}
321 321
322static Eina_Bool 322static Eina_Bool
diff --git a/src/lib/soap_model.eo b/src/lib/soap_model.eo
index 57aef24..3a5dae0 100644
--- a/src/lib/soap_model.eo
+++ b/src/lib/soap_model.eo
@@ -18,7 +18,7 @@ class Soap.Model (Eo.Base, Emodel) {
18 implements { 18 implements {
19 Eo.Base.constructor; 19 Eo.Base.constructor;
20 Eo.Base.destructor; 20 Eo.Base.destructor;
21 Emodel.properties_list.get; 21 Emodel.properties.get;
22 Emodel.properties_load; 22 Emodel.properties_load;
23 Emodel.property.set; 23 Emodel.property.set;
24 Emodel.property.get; 24 Emodel.property.get;
diff --git a/src/tests/soap_model_test_soap_model.c b/src/tests/soap_model_test_soap_model.c
index 40dfc03..a36ec38 100644
--- a/src/tests/soap_model_test_soap_model.c
+++ b/src/tests/soap_model_test_soap_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) == expected_status) return; 46 if ((expected_status & actual_status) == expected_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,7 +53,7 @@ _wait_until_load_status(Emodel *emodel, Emodel_Load_Status expected_status)
52static void 53static void
53_check_value_type_cannot_have_children(Emodel *model) 54_check_value_type_cannot_have_children(Emodel *model)
54{ 55{
55 Emodel *child = eo_do(model, emodel_child_add()); 56 Emodel *child = eo_do_ret(model, child, emodel_child_add());
56 ck_assert_ptr_eq(NULL, child); 57 ck_assert_ptr_eq(NULL, child);
57} 58}
58 59
@@ -67,42 +68,43 @@ _check_emodel_children_count_eq(Emodel *model, unsigned int expected_children_co
67static void 68static void
68_check_emodel_property_int_eq(Emodel *emodel, const char *property, int64_t expected_value) 69_check_emodel_property_int_eq(Emodel *emodel, const char *property, int64_t expected_value)
69{ 70{
70 Eina_Value value; 71 const Eina_Value *value;
71 Emodel_Load_Status status = eo_do(emodel, emodel_property_get(property, &value)); 72 Emodel_Load_Status status;
73 eo_do(emodel, status = emodel_property_get(property, &value));
72 ck_assert_int_eq(EMODEL_LOAD_STATUS_LOADED, status); 74 ck_assert_int_eq(EMODEL_LOAD_STATUS_LOADED, status);
75 ck_assert_ptr_ne(NULL, value);
73 76
74 const Eina_Value_Type *property_type = eina_value_type_get(&value); 77 const Eina_Value_Type *property_type = eina_value_type_get(value);
75 ck_assert_ptr_eq(EINA_VALUE_TYPE_INT64, property_type); 78 ck_assert_ptr_eq(EINA_VALUE_TYPE_INT64, property_type);
76 79
77 int64_t actual_value = 0; 80 int64_t actual_value = 0;
78 eina_value_get(&value, &actual_value); 81 eina_value_get(value, &actual_value);
79 ck_assert_int_eq(expected_value, actual_value); 82 ck_assert_int_eq(expected_value, actual_value);
80
81 eina_value_flush(&value);
82} 83}
83 84
84static void 85static void
85_check_emodel_property_str_eq(Emodel *emodel, const char *property, const char *expected_value) 86_check_emodel_property_str_eq(Emodel *emodel, const char *property, const char *expected_value)
86{ 87{
87 Eina_Value value; 88 const Eina_Value *value;
88 Emodel_Load_Status status = eo_do(emodel, emodel_property_get(property, &value)); 89 Emodel_Load_Status status;
90 eo_do(emodel, status = emodel_property_get(property, &value));
89 ck_assert_int_eq(EMODEL_LOAD_STATUS_LOADED, status); 91 ck_assert_int_eq(EMODEL_LOAD_STATUS_LOADED, status);
92 ck_assert_ptr_ne(NULL, value);
90 93
91 const Eina_Value_Type *property_type = eina_value_type_get(&value); 94 const Eina_Value_Type *property_type = eina_value_type_get(value);
92 fail_if(EINA_VALUE_TYPE_STRING != property_type && EINA_VALUE_TYPE_STRINGSHARE != property_type); 95 fail_if(EINA_VALUE_TYPE_STRING != property_type && EINA_VALUE_TYPE_STRINGSHARE != property_type);
93 96
94 const char *actual_value = NULL; 97 const char *actual_value = NULL;
95 eina_value_get(&value, &actual_value); 98 eina_value_get(value, &actual_value);
96 ck_assert_str_eq(expected_value, actual_value); 99 ck_assert_str_eq(expected_value, actual_value);
97
98 eina_value_flush(&value);
99} 100}
100 101
101static Emodel * 102static Emodel *
102_emodel_nth_child_get(Emodel *emodel, unsigned int n) 103_emodel_nth_child_get(Emodel *emodel, unsigned int n)
103{ 104{
104 Eina_Accessor *accessor; 105 Eina_Accessor *accessor;
105 Emodel_Load_Status status = eo_do(emodel, emodel_children_slice_get(n, 1, &accessor)); 106 Emodel_Load_Status status;
107 eo_do(emodel, status = emodel_children_slice_get(n, 1, &accessor));
106 ck_assert_int_eq(EMODEL_LOAD_STATUS_LOADED, status); 108 ck_assert_int_eq(EMODEL_LOAD_STATUS_LOADED, status);
107 ck_assert_ptr_ne(NULL, accessor); 109 ck_assert_ptr_ne(NULL, accessor);
108 Emodel *child = NULL; 110 Emodel *child = NULL;
@@ -124,7 +126,8 @@ static void
124_check_emodel_properties(Emodel *model, const char *expected_properties[]) 126_check_emodel_properties(Emodel *model, const char *expected_properties[])
125{ 127{
126 Eina_Array *properties = NULL; 128 Eina_Array *properties = NULL;
127 Emodel_Load_Status status = eo_do(model, emodel_properties_list_get(&properties)); 129 Emodel_Load_Status status;
130 eo_do(model, status = emodel_properties_get(&properties));
128 ck_assert_int_eq(EMODEL_LOAD_STATUS_LOADED, status); 131 ck_assert_int_eq(EMODEL_LOAD_STATUS_LOADED, status);
129 ck_assert_ptr_ne(NULL, properties); 132 ck_assert_ptr_ne(NULL, properties);
130 133
@@ -148,7 +151,8 @@ static void
148_check_properties_count_eq(Emodel *model, unsigned int expected_properties_count) 151_check_properties_count_eq(Emodel *model, unsigned int expected_properties_count)
149{ 152{
150 Eina_Array *properties = NULL; 153 Eina_Array *properties = NULL;
151 Emodel_Load_Status status = eo_do(model, emodel_properties_list_get(&properties)); 154 Emodel_Load_Status status;
155 eo_do(model, status = emodel_properties_get(&properties));
152 ck_assert_int_ne(EMODEL_LOAD_STATUS_ERROR, status); 156 ck_assert_int_ne(EMODEL_LOAD_STATUS_ERROR, status);
153 if (!expected_properties_count && !properties) 157 if (!expected_properties_count && !properties)
154 return; 158 return;
@@ -182,7 +186,8 @@ _check_string_property_set(Emodel *model, const char *property, const char *v)
182 Eina_Value value; 186 Eina_Value value;
183 eina_value_setup(&value, EINA_VALUE_TYPE_STRING); 187 eina_value_setup(&value, EINA_VALUE_TYPE_STRING);
184 eina_value_set(&value, v); 188 eina_value_set(&value, v);
185 Emodel_Load_Status status = eo_do(model, emodel_property_set(property, value)); 189 Emodel_Load_Status status;
190 eo_do(model, status = emodel_property_set(property, &value));
186 eina_value_flush(&value); 191 eina_value_flush(&value);
187 ck_assert(EMODEL_LOAD_STATUS_LOADED_PROPERTIES & status); 192 ck_assert(EMODEL_LOAD_STATUS_LOADED_PROPERTIES & status);
188} 193}