stream = efl_add(EFL_IO_BUFFERED_STREAM_CLASS, loop,
efl_name_set(efl_added, "stream"),
efl_io_buffered_stream_inner_io_set(efl_added, dialer), /* mandatory! */
- efl_io_buffered_stream_line_delimiter_set(efl_added, &line_delimiter),
+ efl_io_buffered_stream_line_delimiter_set(efl_added, line_delimiter),
efl_io_buffered_stream_max_queue_size_input_set(efl_added, buffer_limit),
efl_io_buffered_stream_max_queue_size_output_set(efl_added, buffer_limit),
efl_event_callback_array_add(efl_added, stream_cbs(), NULL));
copier = efl_add(EFL_IO_COPIER_CLASS, ecore_main_loop_get(),
efl_io_copier_source_set(efl_added, input), /* mandatory */
efl_io_copier_destination_set(efl_added, output), /* optional, see :none: */
- efl_io_copier_line_delimiter_set(efl_added, &line_delm_slice), /* optional */
+ efl_io_copier_line_delimiter_set(efl_added, line_delm_slice), /* optional */
efl_io_copier_buffer_limit_set(efl_added, buffer_limit), /* optional, defaults to unlimited */
efl_io_copier_read_chunk_size_set(efl_added, read_chunk_size), /* optional, defaults to 4096 */
efl_io_copier_timeout_inactivity_set(efl_added, timeout), /* optional, defaults to 0.0 (disabled) */
/* sender: send_queue->network */
sender = efl_add(EFL_IO_COPIER_CLASS, loop,
efl_name_set(efl_added, "sender"),
- efl_io_copier_line_delimiter_set(efl_added, &line_delimiter),
+ efl_io_copier_line_delimiter_set(efl_added, line_delimiter),
efl_io_copier_source_set(efl_added, send_queue),
efl_io_copier_destination_set(efl_added, dialer),
efl_event_callback_array_add(efl_added, copier_cbs(), NULL));
/* receiver: network->receive_queue */
receiver = efl_add(EFL_IO_COPIER_CLASS, loop,
efl_name_set(efl_added, "receiver"),
- efl_io_copier_line_delimiter_set(efl_added, &line_delimiter),
+ efl_io_copier_line_delimiter_set(efl_added, line_delimiter),
efl_io_copier_source_set(efl_added, dialer),
efl_io_copier_destination_set(efl_added, receive_queue),
efl_event_callback_array_add(efl_added, copier_cbs(), NULL));
input = efl_add(EFL_IO_STDIN_CLASS, ecore_main_loop_get());
copier = efl_add(EFL_IO_COPIER_CLASS, ecore_main_loop_get(),
efl_io_copier_source_set(efl_added, input),
- efl_io_copier_line_delimiter_set(efl_added, &line_delimiter),
+ efl_io_copier_line_delimiter_set(efl_added, line_delimiter),
efl_io_copier_buffer_limit_set(efl_added, 8192),
efl_io_copier_read_chunk_size_set(efl_added, 8192),
efl_event_callback_add(efl_added, EFL_IO_COPIER_EVENT_LINE, _cmd_line, ctl));
dialer = efl_add(EFL_NET_DIALER_SIMPLE_CLASS, loop,
efl_name_set(efl_added, "dialer"),
efl_net_dialer_simple_inner_class_set(efl_added, cls), /* alternatively you could create the inner dialer and set with efl_io_buffered_stream_inner_io_set() */
- efl_io_buffered_stream_line_delimiter_set(efl_added, &line_delm_slice), /* optional */
+ efl_io_buffered_stream_line_delimiter_set(efl_added, line_delm_slice), /* optional */
efl_io_buffered_stream_max_queue_size_input_set(efl_added, buffer_limit), /* optional, defaults to unlimited */
efl_io_buffered_stream_max_queue_size_output_set(efl_added, buffer_limit), /* optional, defaults to unlimited */
efl_io_buffered_stream_read_chunk_size_set(efl_added, read_chunk_size), /* optional, defaults to 4096 */
static void
_print_ip_addr_info(const Eo *o)
{
- const Eina_Slice *addr;
+ Eina_Slice addr;
const struct sockaddr *sa;
char buf[INET6_ADDRSTRLEN] = "?";
uint16_t port;
printf("INFO: - port: %hu\n", efl_net_ip_address_port_get(o));
addr = efl_net_ip_address_get(o);
- printf("INFO: - address %zd bytes:", addr->len);
- for (i = 0; i < addr->len; i++)
- printf(" %#hhx", addr->bytes[i]);
+ printf("INFO: - address %zd bytes:", addr.len);
+ for (i = 0; i < addr.len; i++)
+ printf(" %#hhx", addr.bytes[i]);
putchar('\n');
sa = efl_net_ip_address_sockaddr_get(o);
}
EOLIAN static void
-_efl_io_buffered_stream_line_delimiter_set(Eo *o EINA_UNUSED, Efl_Io_Buffered_Stream_Data *pd, const Eina_Slice *slice)
+_efl_io_buffered_stream_line_delimiter_set(Eo *o EINA_UNUSED, Efl_Io_Buffered_Stream_Data *pd, Eina_Slice slice)
{
if (!pd->receiver)
{
- DBG("%p inner_io=%p (%s) is not Efl.Io.Reader, slice=%p ignored", o, pd->inner_io, efl_class_name_get(efl_class_get(pd->inner_io)), slice);
+ DBG("%p inner_io=%p (%s) is not Efl.Io.Reader, slice=" EINA_SLICE_FMT " ignored", o, pd->inner_io, efl_class_name_get(efl_class_get(pd->inner_io)), EINA_SLICE_PRINT(slice));
return;
}
efl_io_copier_line_delimiter_set(pd->receiver, slice);
}
-EOLIAN static const Eina_Slice *
+EOLIAN static Eina_Slice
_efl_io_buffered_stream_line_delimiter_get(Eo *o EINA_UNUSED, Efl_Io_Buffered_Stream_Data *pd)
{
- if (!pd->receiver) return NULL;
+ if (!pd->receiver) return (Eina_Slice){};
return efl_io_copier_line_delimiter_get(pd->receiver);
}
[[If set, incoming data will be checked for the delimiter and "line" events are The line may include the delimiter, unless it's end-of-stream on @.max_queue_size_input was reached.]]
get { }
set {
- [[Change line delimiter to use. If NULL or empty, no delimiter is to be used]]
+ [[Change line delimiter to use. If empty, no delimiter is to be used]]
}
values {
- slice: ptr(const(Eina.Slice)); [[The contents may contain \0 and will be copied]]
+ // TODO: eolian generates wrong type for getter with const(Eina.Slice)
+ slice: Eina.Slice; [[The contents may contain \0 and will be copied]]
}
}
}
EOLIAN static void
-_efl_io_copier_line_delimiter_set(Eo *o EINA_UNUSED, Efl_Io_Copier_Data *pd, const Eina_Slice *slice)
+_efl_io_copier_line_delimiter_set(Eo *o EINA_UNUSED, Efl_Io_Copier_Data *pd, Eina_Slice slice)
{
- EINA_SAFETY_ON_NULL_RETURN(slice);
- if (pd->line_delimiter.mem == slice->mem)
+ if (pd->line_delimiter.mem == slice.mem)
{
- pd->line_delimiter.len = slice->len;
+ pd->line_delimiter.len = slice.len;
return;
}
free((void *)pd->line_delimiter.mem);
- if (slice->len == 0)
+ if (slice.len == 0)
{
pd->line_delimiter.mem = NULL;
pd->line_delimiter.len = 0;
}
else
{
- Eina_Rw_Slice rw_slice = eina_slice_dup(*slice);
+ Eina_Rw_Slice rw_slice = eina_slice_dup(slice);
pd->line_delimiter = eina_rw_slice_slice_get(rw_slice);
}
}
-EOLIAN static const Eina_Slice *
+EOLIAN static Eina_Slice
_efl_io_copier_line_delimiter_get(Eo *o EINA_UNUSED, Efl_Io_Copier_Data *pd)
{
- return &pd->line_delimiter;
+ return pd->line_delimiter;
}
[[If there is a line delimiter, the reads will buffer/queue up to the line delimiter before calling @Efl.Io.Writer.write on the @.destination and the event line is emitted with current line. The line may include the delimiter, unless it's end-of-stream on @.source or @.buffer_limit was reached.]]
get { }
set {
- [[Change line delimiter to use. If NULL or empty, no delimiter is to be used]]
+ [[Change line delimiter to use. If empty, no delimiter is to be used]]
}
values {
- slice: ptr(const(Eina.Slice)); [[The contents may contain \0 and will be copied]]
+ // TODO: eolian generates wrong type for getter with const(Eina.Slice)
+ slice: Eina.Slice; [[The contents may contain \0 and will be copied]]
}
}
if (pd->pending.line_delimiter)
{
pd->pending.line_delimiter = EINA_FALSE;
- efl_io_buffered_stream_line_delimiter_set(o, &pd->line_delimiter);
+ efl_io_buffered_stream_line_delimiter_set(o, pd->line_delimiter);
free((void *)pd->line_delimiter.mem);
pd->line_delimiter.mem = NULL;
}
EOLIAN static void
-_efl_net_dialer_simple_efl_io_buffered_stream_line_delimiter_set(Eo *o, Efl_Net_Dialer_Simple_Data *pd, const Eina_Slice *slice)
+_efl_net_dialer_simple_efl_io_buffered_stream_line_delimiter_set(Eo *o, Efl_Net_Dialer_Simple_Data *pd, Eina_Slice slice)
{
Eo *inner_io = efl_io_buffered_stream_inner_io_get(o);
if (!inner_io)
{
free((void *)pd->line_delimiter.mem);
- if ((!slice) || (!slice->len))
+ if (!slice.len)
{
pd->line_delimiter.mem = NULL;
pd->line_delimiter.len = 0;
else
{
char *mem;
- pd->line_delimiter.mem = mem = malloc(slice->len + 1);
+ pd->line_delimiter.mem = mem = malloc(slice.len + 1);
EINA_SAFETY_ON_NULL_RETURN(pd->line_delimiter.mem);
- memcpy(mem, slice->mem, slice->len);
- mem[slice->len] = '\0';
- pd->line_delimiter.len = slice->len;
+ memcpy(mem, slice.mem, slice.len);
+ mem[slice.len] = '\0';
+ pd->line_delimiter.len = slice.len;
}
pd->pending.line_delimiter = EINA_TRUE;
efl_io_buffered_stream_line_delimiter_set(efl_super(o, MY_CLASS), slice);
}
-EOLIAN static const Eina_Slice *
+EOLIAN static Eina_Slice
_efl_net_dialer_simple_efl_io_buffered_stream_line_delimiter_get(Eo *o, Efl_Net_Dialer_Simple_Data *pd)
{
Eo *inner_io = efl_io_buffered_stream_inner_io_get(o);
- if (!inner_io) return &pd->line_delimiter;
+ if (!inner_io) return pd->line_delimiter;
return efl_io_buffered_stream_line_delimiter_get(efl_super(o, MY_CLASS));
}
}
EOLIAN static void
-_efl_net_ip_address_address_set(Eo *o EINA_UNUSED, Efl_Net_Ip_Address_Data *pd, const Eina_Slice *address)
+_efl_net_ip_address_address_set(Eo *o EINA_UNUSED, Efl_Net_Ip_Address_Data *pd, Eina_Slice address)
{
Eina_Rw_Slice rw_slice;
size_t i;
EINA_SAFETY_ON_TRUE_RETURN(pd->addr.sa_family == 0);
- EINA_SAFETY_ON_NULL_RETURN(address);
rw_slice.mem = (void *)pd->addr_slice.mem;
rw_slice.len = pd->addr_slice.len;
- EINA_SAFETY_ON_TRUE_RETURN(rw_slice.len != address->len);
+ EINA_SAFETY_ON_TRUE_RETURN(rw_slice.len != address.len);
- if (eina_slice_compare(eina_rw_slice_slice_get(rw_slice), *address) == 0)
+ if (eina_slice_compare(eina_rw_slice_slice_get(rw_slice), address) == 0)
return;
for (i = 0; i < rw_slice.len; i++)
old_str[0] = '?';
old_str[1] = '\0';
}
- if (!inet_ntop(pd->addr.sa_family, address->mem, new_str, sizeof(new_str)))
+ if (!inet_ntop(pd->addr.sa_family, address.mem, new_str, sizeof(new_str)))
{
new_str[0] = '?';
new_str[1] = '\0';
}
}
- eina_rw_slice_copy(rw_slice, *address);
+ eina_rw_slice_copy(rw_slice, address);
}
-EOLIAN static const Eina_Slice *
+EOLIAN static Eina_Slice
_efl_net_ip_address_address_get(Eo *o EINA_UNUSED, Efl_Net_Ip_Address_Data *pd)
{
- return &pd->addr_slice;
+ return pd->addr_slice;
}
EOLIAN static void
return efl_add(cls, NULL,
efl_net_ip_address_family_set(efl_added, family),
efl_net_ip_address_port_set(efl_added, port),
- efl_net_ip_address_set(efl_added, &address));
+ efl_net_ip_address_set(efl_added, address));
}
EOLIAN static Efl_Net_Ip_Address *
Must be set after @.family.
]]
values {
- 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]]
+ // TODO: eolian generates wrong type for getter with const(Eina.Slice)
+ 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]]
}
}
_ipv4_check(Eo *o, const struct sockaddr_in *addr)
{
Eina_Slice slice = { .mem = &addr->sin_addr, .len = sizeof(addr->sin_addr) };
- const Eina_Slice *rs;
+ Eina_Slice rs;
char buf[INET_ADDRSTRLEN + sizeof(":65536")] = "";
ck_assert_ptr_ne(o, NULL);
ck_assert_int_eq(efl_net_ip_address_port_get(o), ntohs(addr->sin_port));
rs = efl_net_ip_address_get(o);
- ck_assert_ptr_ne(rs, NULL);
- ck_assert_int_eq(eina_slice_compare(*rs, slice), 0);
+ ck_assert_int_eq(eina_slice_compare(rs, slice), 0);
inet_ntop(AF_INET, slice.mem, buf, INET_ADDRSTRLEN);
o = efl_add(EFL_NET_IP_ADDRESS_CLASS, NULL,
efl_net_ip_address_family_set(efl_added, AF_INET),
efl_net_ip_address_port_set(efl_added, ntohs(addr.sin_port)),
- efl_net_ip_address_set(efl_added, &slice));
+ efl_net_ip_address_set(efl_added, slice));
_ipv4_check(o, &addr);
efl_del(o);
o = efl_add(EFL_NET_IP_ADDRESS_CLASS, NULL,
efl_net_ip_address_family_set(efl_added, AF_INET),
efl_net_ip_address_port_set(efl_added, ntohs(addr.sin_port)),
- efl_net_ip_address_set(efl_added, &slice));
+ efl_net_ip_address_set(efl_added, slice));
_ipv4_check(o, &addr);
efl_del(o);
addr.sin_addr.s_addr = htonl(0x12345678);
o = efl_add(EFL_NET_IP_ADDRESS_CLASS, NULL,
efl_net_ip_address_family_set(efl_added, AF_INET),
- efl_net_ip_address_set(efl_added, &slice));
+ efl_net_ip_address_set(efl_added, slice));
_ipv4_check(o, &addr);
efl_del(o);
TRAP_ERRORS_BEGIN(eina_safety, ERR, "safety check failed: pd->addr.sa_family == 0 is true");
o = efl_add(EFL_NET_IP_ADDRESS_CLASS, NULL,
- efl_net_ip_address_set(efl_added, &wrong_slice));
+ efl_net_ip_address_set(efl_added, wrong_slice));
ck_assert_ptr_eq(o, NULL);
TRAP_ERRORS_FINISH(2);
TRAP_ERRORS_BEGIN(eina_safety, ERR, "safety check failed: pd->addr.sa_family == 0 is true");
o = efl_add(EFL_NET_IP_ADDRESS_CLASS, NULL,
efl_net_ip_address_port_set(efl_added, 1234),
- efl_net_ip_address_set(efl_added, &wrong_slice));
+ efl_net_ip_address_set(efl_added, wrong_slice));
ck_assert_ptr_eq(o, NULL);
TRAP_ERRORS_FINISH(3);
- TRAP_ERRORS_BEGIN(eina_safety, ERR, "safety check failed: rw_slice.len != address->len is true");
+ TRAP_ERRORS_BEGIN(eina_safety, ERR, "safety check failed: rw_slice.len != address.len is true");
o = efl_add(EFL_NET_IP_ADDRESS_CLASS, NULL,
efl_net_ip_address_family_set(efl_added, AF_INET),
- efl_net_ip_address_set(efl_added, &wrong_slice));
+ efl_net_ip_address_set(efl_added, wrong_slice));
_ipv4_check(o, &addr);
efl_del(o);
TRAP_ERRORS_FINISH(1);
o = efl_add(EFL_NET_IP_ADDRESS_CLASS, NULL,
efl_net_ip_address_family_set(efl_added, AF_INET),
efl_net_ip_address_port_set(efl_added, ntohs(addr.sin_port)),
- efl_net_ip_address_set(efl_added, &slice));
+ efl_net_ip_address_set(efl_added, slice));
_ipv4_check(o, &addr);
TRAP_ERRORS_BEGIN(ecore_con, ERR, "port already set to %hu, new %hu");
efl_net_ip_address_port_set(o, 999);
TRAP_ERRORS_FINISH(1);
- TRAP_ERRORS_BEGIN(eina_safety, ERR, "safety check failed: address == NULL");
- efl_net_ip_address_set(o, NULL);
- TRAP_ERRORS_FINISH(1);
-
- TRAP_ERRORS_BEGIN(eina_safety, ERR, "safety check failed: rw_slice.len != address->len is true");
+ TRAP_ERRORS_BEGIN(eina_safety, ERR, "safety check failed: rw_slice.len != address.len is true");
slice.len = 1;
- efl_net_ip_address_set(o, &slice);
+ efl_net_ip_address_set(o, slice);
TRAP_ERRORS_FINISH(1);
TRAP_ERRORS_BEGIN(ecore_con, ERR, "address already set to %s, new %s");
slice.len = sizeof(addr.sin_addr.s_addr);
- efl_net_ip_address_set(o, &slice);
+ efl_net_ip_address_set(o, slice);
TRAP_ERRORS_FINISH(0);
TRAP_ERRORS_BEGIN(ecore_con, ERR, "address already set to %s, new %s");
addr.sin_addr.s_addr = htonl(0x12345678);
slice.len = sizeof(addr.sin_addr.s_addr);
- efl_net_ip_address_set(o, &slice);
+ efl_net_ip_address_set(o, slice);
TRAP_ERRORS_FINISH(1);
efl_del(o);
_ipv6_check(Eo *o, const struct sockaddr_in6 *addr)
{
Eina_Slice slice = { .mem = &addr->sin6_addr, .len = sizeof(addr->sin6_addr) };
- const Eina_Slice *rs;
+ Eina_Slice rs;
char buf[INET6_ADDRSTRLEN + sizeof("[]:65536")] = "";
ck_assert_ptr_ne(o, NULL);
ck_assert_int_eq(efl_net_ip_address_port_get(o), ntohs(addr->sin6_port));
rs = efl_net_ip_address_get(o);
- ck_assert_ptr_ne(rs, NULL);
- ck_assert_int_eq(eina_slice_compare(*rs, slice), 0);
+ ck_assert_int_eq(eina_slice_compare(rs, slice), 0);
buf[0] = '[';
inet_ntop(AF_INET6, slice.mem, buf + 1, INET6_ADDRSTRLEN);
o = efl_add(EFL_NET_IP_ADDRESS_CLASS, NULL,
efl_net_ip_address_family_set(efl_added, AF_INET6),
efl_net_ip_address_port_set(efl_added, ntohs(addr.sin6_port)),
- efl_net_ip_address_set(efl_added, &slice));
+ efl_net_ip_address_set(efl_added, slice));
_ipv6_check(o, &addr);
efl_del(o);
o = efl_add(EFL_NET_IP_ADDRESS_CLASS, NULL,
efl_net_ip_address_family_set(efl_added, AF_INET6),
efl_net_ip_address_port_set(efl_added, ntohs(addr.sin6_port)),
- efl_net_ip_address_set(efl_added, &slice));
+ efl_net_ip_address_set(efl_added, slice));
_ipv6_check(o, &addr);
efl_del(o);
/* generic errors checked at ecore_test_efl_net_ip_address_ipv4_manual_fail */
- TRAP_ERRORS_BEGIN(eina_safety, ERR, "safety check failed: rw_slice.len != address->len is true");
+ TRAP_ERRORS_BEGIN(eina_safety, ERR, "safety check failed: rw_slice.len != address.len is true");
o = efl_add(EFL_NET_IP_ADDRESS_CLASS, NULL,
efl_net_ip_address_family_set(efl_added, AF_INET6),
- efl_net_ip_address_set(efl_added, &wrong_slice));
+ efl_net_ip_address_set(efl_added, wrong_slice));
_ipv6_check(o, &addr);
efl_del(o);
TRAP_ERRORS_FINISH(1);
o = efl_add(EFL_NET_IP_ADDRESS_CLASS, NULL,
efl_net_ip_address_family_set(efl_added, AF_INET6),
efl_net_ip_address_port_set(efl_added, ntohs(addr.sin6_port)),
- efl_net_ip_address_set(efl_added, &slice));
+ efl_net_ip_address_set(efl_added, slice));
_ipv6_check(o, &addr);
TRAP_ERRORS_BEGIN(ecore_con, ERR, "port already set to %hu, new %hu");
efl_net_ip_address_port_set(o, 999);
TRAP_ERRORS_FINISH(1);
- TRAP_ERRORS_BEGIN(eina_safety, ERR, "safety check failed: rw_slice.len != address->len is true");
+ TRAP_ERRORS_BEGIN(eina_safety, ERR, "safety check failed: rw_slice.len != address.len is true");
slice.len = 1;
- efl_net_ip_address_set(o, &slice);
+ efl_net_ip_address_set(o, slice);
TRAP_ERRORS_FINISH(1);
TRAP_ERRORS_BEGIN(ecore_con, ERR, "address already set to %s, new %s");
slice.len = sizeof(addr.sin6_addr);
- efl_net_ip_address_set(o, &slice);
+ efl_net_ip_address_set(o, slice);
TRAP_ERRORS_FINISH(0);
TRAP_ERRORS_BEGIN(ecore_con, ERR, "address already set to %s, new %s");
_ipv6_set(&addr, 1, 2, 3, 4, 5, 6, 7, 8);
slice.len = sizeof(addr.sin6_addr);
- efl_net_ip_address_set(o, &slice);
+ efl_net_ip_address_set(o, slice);
TRAP_ERRORS_FINISH(1);
efl_del(o);