summaryrefslogtreecommitdiff
path: root/src/lib/ecore_con
diff options
context:
space:
mode:
authorGustavo Sverzut Barbieri <barbieri@profusion.mobi>2016-12-19 15:27:34 -0200
committerGustavo Sverzut Barbieri <barbieri@profusion.mobi>2016-12-19 15:30:56 -0200
commitdd5cdda64b5fd3966718af62d417117942e2f323 (patch)
tree28e5ff6f8b5f4fc76fcefce709790b4a91def65b /src/lib/ecore_con
parent25a9e1d886054d3907fb43e3682525b1a3901209 (diff)
more eo simplified to use Eina_Slice instead of pointer to.
Working directly with Eina_Slice is easier than a pointer to it, requires no validation of the pointers and is cheap since it's just putting together size_t + void*. However we can't hint the user of 'const(Eina.Slice)' properties as Eolian is incorrectly generating getters as: const Eina_Slice class_property_get(...) which is makes compilers complain about ignored qualifiers: ../src/lib/ecore/efl_io_copier.eo.h:329:7: warning: 'const' type qualifier on return type has no effect [-Wignored-qualifiers] Leave some TODO so @q66 can fix those.
Diffstat (limited to 'src/lib/ecore_con')
-rw-r--r--src/lib/ecore_con/efl_net_dialer_simple.c18
-rw-r--r--src/lib/ecore_con/efl_net_ip_address.c17
-rw-r--r--src/lib/ecore_con/efl_net_ip_address.eo3
3 files changed, 19 insertions, 19 deletions
diff --git a/src/lib/ecore_con/efl_net_dialer_simple.c b/src/lib/ecore_con/efl_net_dialer_simple.c
index 317f972862..2aca537318 100644
--- a/src/lib/ecore_con/efl_net_dialer_simple.c
+++ b/src/lib/ecore_con/efl_net_dialer_simple.c
@@ -155,7 +155,7 @@ _efl_net_dialer_simple_efl_io_buffered_stream_inner_io_set(Eo *o, Efl_Net_Dialer
155 if (pd->pending.line_delimiter) 155 if (pd->pending.line_delimiter)
156 { 156 {
157 pd->pending.line_delimiter = EINA_FALSE; 157 pd->pending.line_delimiter = EINA_FALSE;
158 efl_io_buffered_stream_line_delimiter_set(o, &pd->line_delimiter); 158 efl_io_buffered_stream_line_delimiter_set(o, pd->line_delimiter);
159 free((void *)pd->line_delimiter.mem); 159 free((void *)pd->line_delimiter.mem);
160 pd->line_delimiter.mem = NULL; 160 pd->line_delimiter.mem = NULL;
161 } 161 }
@@ -313,14 +313,14 @@ _efl_net_dialer_simple_efl_io_buffered_stream_read_chunk_size_get(Eo *o, Efl_Net
313 313
314 314
315EOLIAN static void 315EOLIAN static void
316_efl_net_dialer_simple_efl_io_buffered_stream_line_delimiter_set(Eo *o, Efl_Net_Dialer_Simple_Data *pd, const Eina_Slice *slice) 316_efl_net_dialer_simple_efl_io_buffered_stream_line_delimiter_set(Eo *o, Efl_Net_Dialer_Simple_Data *pd, Eina_Slice slice)
317{ 317{
318 Eo *inner_io = efl_io_buffered_stream_inner_io_get(o); 318 Eo *inner_io = efl_io_buffered_stream_inner_io_get(o);
319 319
320 if (!inner_io) 320 if (!inner_io)
321 { 321 {
322 free((void *)pd->line_delimiter.mem); 322 free((void *)pd->line_delimiter.mem);
323 if ((!slice) || (!slice->len)) 323 if (!slice.len)
324 { 324 {
325 pd->line_delimiter.mem = NULL; 325 pd->line_delimiter.mem = NULL;
326 pd->line_delimiter.len = 0; 326 pd->line_delimiter.len = 0;
@@ -328,11 +328,11 @@ _efl_net_dialer_simple_efl_io_buffered_stream_line_delimiter_set(Eo *o, Efl_Net_
328 else 328 else
329 { 329 {
330 char *mem; 330 char *mem;
331 pd->line_delimiter.mem = mem = malloc(slice->len + 1); 331 pd->line_delimiter.mem = mem = malloc(slice.len + 1);
332 EINA_SAFETY_ON_NULL_RETURN(pd->line_delimiter.mem); 332 EINA_SAFETY_ON_NULL_RETURN(pd->line_delimiter.mem);
333 memcpy(mem, slice->mem, slice->len); 333 memcpy(mem, slice.mem, slice.len);
334 mem[slice->len] = '\0'; 334 mem[slice.len] = '\0';
335 pd->line_delimiter.len = slice->len; 335 pd->line_delimiter.len = slice.len;
336 } 336 }
337 337
338 pd->pending.line_delimiter = EINA_TRUE; 338 pd->pending.line_delimiter = EINA_TRUE;
@@ -341,11 +341,11 @@ _efl_net_dialer_simple_efl_io_buffered_stream_line_delimiter_set(Eo *o, Efl_Net_
341 efl_io_buffered_stream_line_delimiter_set(efl_super(o, MY_CLASS), slice); 341 efl_io_buffered_stream_line_delimiter_set(efl_super(o, MY_CLASS), slice);
342} 342}
343 343
344EOLIAN static const Eina_Slice * 344EOLIAN static Eina_Slice
345_efl_net_dialer_simple_efl_io_buffered_stream_line_delimiter_get(Eo *o, Efl_Net_Dialer_Simple_Data *pd) 345_efl_net_dialer_simple_efl_io_buffered_stream_line_delimiter_get(Eo *o, Efl_Net_Dialer_Simple_Data *pd)
346{ 346{
347 Eo *inner_io = efl_io_buffered_stream_inner_io_get(o); 347 Eo *inner_io = efl_io_buffered_stream_inner_io_get(o);
348 if (!inner_io) return &pd->line_delimiter; 348 if (!inner_io) return pd->line_delimiter;
349 return efl_io_buffered_stream_line_delimiter_get(efl_super(o, MY_CLASS)); 349 return efl_io_buffered_stream_line_delimiter_get(efl_super(o, MY_CLASS));
350} 350}
351 351
diff --git a/src/lib/ecore_con/efl_net_ip_address.c b/src/lib/ecore_con/efl_net_ip_address.c
index e76a3834aa..569b18d13e 100644
--- a/src/lib/ecore_con/efl_net_ip_address.c
+++ b/src/lib/ecore_con/efl_net_ip_address.c
@@ -126,20 +126,19 @@ _efl_net_ip_address_port_get(Eo *o EINA_UNUSED, Efl_Net_Ip_Address_Data *pd)
126} 126}
127 127
128EOLIAN static void 128EOLIAN static void
129_efl_net_ip_address_address_set(Eo *o EINA_UNUSED, Efl_Net_Ip_Address_Data *pd, const Eina_Slice *address) 129_efl_net_ip_address_address_set(Eo *o EINA_UNUSED, Efl_Net_Ip_Address_Data *pd, Eina_Slice address)
130{ 130{
131 Eina_Rw_Slice rw_slice; 131 Eina_Rw_Slice rw_slice;
132 size_t i; 132 size_t i;
133 133
134 EINA_SAFETY_ON_TRUE_RETURN(pd->addr.sa_family == 0); 134 EINA_SAFETY_ON_TRUE_RETURN(pd->addr.sa_family == 0);
135 EINA_SAFETY_ON_NULL_RETURN(address);
136 135
137 rw_slice.mem = (void *)pd->addr_slice.mem; 136 rw_slice.mem = (void *)pd->addr_slice.mem;
138 rw_slice.len = pd->addr_slice.len; 137 rw_slice.len = pd->addr_slice.len;
139 138
140 EINA_SAFETY_ON_TRUE_RETURN(rw_slice.len != address->len); 139 EINA_SAFETY_ON_TRUE_RETURN(rw_slice.len != address.len);
141 140
142 if (eina_slice_compare(eina_rw_slice_slice_get(rw_slice), *address) == 0) 141 if (eina_slice_compare(eina_rw_slice_slice_get(rw_slice), address) == 0)
143 return; 142 return;
144 143
145 for (i = 0; i < rw_slice.len; i++) 144 for (i = 0; i < rw_slice.len; i++)
@@ -154,7 +153,7 @@ _efl_net_ip_address_address_set(Eo *o EINA_UNUSED, Efl_Net_Ip_Address_Data *pd,
154 old_str[0] = '?'; 153 old_str[0] = '?';
155 old_str[1] = '\0'; 154 old_str[1] = '\0';
156 } 155 }
157 if (!inet_ntop(pd->addr.sa_family, address->mem, new_str, sizeof(new_str))) 156 if (!inet_ntop(pd->addr.sa_family, address.mem, new_str, sizeof(new_str)))
158 { 157 {
159 new_str[0] = '?'; 158 new_str[0] = '?';
160 new_str[1] = '\0'; 159 new_str[1] = '\0';
@@ -164,13 +163,13 @@ _efl_net_ip_address_address_set(Eo *o EINA_UNUSED, Efl_Net_Ip_Address_Data *pd,
164 } 163 }
165 } 164 }
166 165
167 eina_rw_slice_copy(rw_slice, *address); 166 eina_rw_slice_copy(rw_slice, address);
168} 167}
169 168
170EOLIAN static const Eina_Slice * 169EOLIAN static Eina_Slice
171_efl_net_ip_address_address_get(Eo *o EINA_UNUSED, Efl_Net_Ip_Address_Data *pd) 170_efl_net_ip_address_address_get(Eo *o EINA_UNUSED, Efl_Net_Ip_Address_Data *pd)
172{ 171{
173 return &pd->addr_slice; 172 return pd->addr_slice;
174} 173}
175 174
176EOLIAN static void 175EOLIAN static void
@@ -304,7 +303,7 @@ _efl_net_ip_address_create(Eo *cls, void *pd EINA_UNUSED, uint16_t port, const E
304 return efl_add(cls, NULL, 303 return efl_add(cls, NULL,
305 efl_net_ip_address_family_set(efl_added, family), 304 efl_net_ip_address_family_set(efl_added, family),
306 efl_net_ip_address_port_set(efl_added, port), 305 efl_net_ip_address_port_set(efl_added, port),
307 efl_net_ip_address_set(efl_added, &address)); 306 efl_net_ip_address_set(efl_added, address));
308} 307}
309 308
310EOLIAN static Efl_Net_Ip_Address * 309EOLIAN static Efl_Net_Ip_Address *
diff --git a/src/lib/ecore_con/efl_net_ip_address.eo b/src/lib/ecore_con/efl_net_ip_address.eo
index a9e2d7b3e3..e70b578038 100644
--- a/src/lib/ecore_con/efl_net_ip_address.eo
+++ b/src/lib/ecore_con/efl_net_ip_address.eo
@@ -161,7 +161,8 @@ class Efl.Net.Ip.Address (Efl.Object) {
161 Must be set after @.family. 161 Must be set after @.family.
162 ]] 162 ]]
163 values { 163 values {
164 address: const(ptr(Eina.Slice)) @nonull; [[Address bytes. If AF_INET it's 4 bytes. If AF_INET6, it's 16 bytes. This matches exactly what is in struct sockaddr_in::sin_addr or struct sockaddr_in6:sin6_addr, see @.sockaddr]] 164 // TODO: eolian generates wrong type for getter with const(Eina.Slice)
165 address: Eina.Slice; [[Address bytes. If AF_INET it's 4 bytes. If AF_INET6, it's 16 bytes. This matches exactly what is in struct sockaddr_in::sin_addr or struct sockaddr_in6:sin6_addr, see @.sockaddr]]
165 } 166 }
166 } 167 }
167 168