Efl.Io.{Queue,Buffer,Buffered_Stream}: slice_get is now a property.
Previously we couldn't return a slice, instead required the user to pass a slice and we'd fill it since Eolian couldn't generate fallbacks for structures. Since @q66 fixed eolian, we can now return the structure itself as initially wanted, ditching some TODO from the code.
This commit is contained in:
parent
6979be8215
commit
8c2013d090
|
@ -38,9 +38,7 @@ _command_next(void)
|
||||||
static void
|
static void
|
||||||
_receiver_data(void *data EINA_UNUSED, const Efl_Event *event)
|
_receiver_data(void *data EINA_UNUSED, const Efl_Event *event)
|
||||||
{
|
{
|
||||||
Eina_Slice slice;
|
Eina_Slice slice = efl_io_buffered_stream_slice_get(event->object);
|
||||||
|
|
||||||
if (!efl_io_buffered_stream_slice_get(event->object, &slice)) return;
|
|
||||||
|
|
||||||
/* this will happen when we're called when we issue our own
|
/* this will happen when we're called when we issue our own
|
||||||
* efl_io_buffered_stream_clear() below.
|
* efl_io_buffered_stream_clear() below.
|
||||||
|
|
|
@ -43,13 +43,7 @@ EFL_CALLBACKS_ARRAY_DEFINE(output_cbs,
|
||||||
static void
|
static void
|
||||||
_output_buffer_reallocated(void *data EINA_UNUSED, const Efl_Event *event)
|
_output_buffer_reallocated(void *data EINA_UNUSED, const Efl_Event *event)
|
||||||
{
|
{
|
||||||
Eina_Slice slice;
|
Eina_Slice slice = efl_io_buffer_slice_get(event->object);
|
||||||
|
|
||||||
if (!efl_io_buffer_slice_get(event->object, &slice))
|
|
||||||
{
|
|
||||||
fprintf(stderr, "ERROR: could not get buffer slice\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf(stderr, "INFO: output buffer reallocated=" EINA_SLICE_FMT "\n",
|
fprintf(stderr, "INFO: output buffer reallocated=" EINA_SLICE_FMT "\n",
|
||||||
EINA_SLICE_PRINT(slice));
|
EINA_SLICE_PRINT(slice));
|
||||||
|
@ -196,17 +190,13 @@ _copier_done(void *data EINA_UNUSED, const Efl_Event *event)
|
||||||
* an Eina_Binbuf, you own the ownership and must call
|
* an Eina_Binbuf, you own the ownership and must call
|
||||||
* eina_binbuf_free() to release it.
|
* eina_binbuf_free() to release it.
|
||||||
*/
|
*/
|
||||||
Eina_Slice slice;
|
Eina_Slice slice = efl_io_buffer_slice_get(destination);
|
||||||
|
fprintf(stderr,
|
||||||
if (!efl_io_buffer_slice_get(destination, &slice))
|
"INFO: :memory: resulted in slice=" EINA_SLICE_FMT ":"
|
||||||
fprintf(stderr, "ERROR: could not get buffer slice\n");
|
"\n--BEGIN DATA--\n"
|
||||||
else
|
EINA_SLICE_STR_FMT
|
||||||
fprintf(stderr,
|
"\n--END DATA--\n",
|
||||||
"INFO: :memory: resulted in slice=" EINA_SLICE_FMT ":"
|
EINA_SLICE_PRINT(slice), EINA_SLICE_STR_PRINT(slice));
|
||||||
"\n--BEGIN DATA--\n"
|
|
||||||
EINA_SLICE_STR_FMT
|
|
||||||
"\n--END DATA--\n",
|
|
||||||
EINA_SLICE_PRINT(slice), EINA_SLICE_STR_PRINT(slice));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr, "INFO: done\n");
|
fprintf(stderr, "INFO: done\n");
|
||||||
|
|
|
@ -39,9 +39,7 @@ _command_next(void)
|
||||||
static void
|
static void
|
||||||
_receiver_data(void *data EINA_UNUSED, const Efl_Event *event)
|
_receiver_data(void *data EINA_UNUSED, const Efl_Event *event)
|
||||||
{
|
{
|
||||||
Eina_Slice slice;
|
Eina_Slice slice = efl_io_queue_slice_get(event->object);
|
||||||
|
|
||||||
if (!efl_io_queue_slice_get(event->object, &slice)) return;
|
|
||||||
|
|
||||||
/* this will happen when we're called when we issue our own
|
/* this will happen when we're called when we issue our own
|
||||||
* efl_io_queue_clear() below.
|
* efl_io_queue_clear() below.
|
||||||
|
|
|
@ -28,22 +28,17 @@ _connected(void *data EINA_UNUSED, const Efl_Event *event)
|
||||||
static void
|
static void
|
||||||
_eos(void *data EINA_UNUSED, const Efl_Event *event)
|
_eos(void *data EINA_UNUSED, const Efl_Event *event)
|
||||||
{
|
{
|
||||||
Eina_Slice s;
|
|
||||||
|
|
||||||
fprintf(stderr, "INFO: end of stream.\n");
|
fprintf(stderr, "INFO: end of stream.\n");
|
||||||
|
|
||||||
/* on _error() we close it, then do not read as it has nothing */
|
/* on _error() we close it, then do not read as it has nothing */
|
||||||
if (efl_io_closer_closed_get(event->object))
|
if (efl_io_closer_closed_get(event->object))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (efl_io_buffered_stream_slice_get(event->object, &s))
|
fprintf(stderr,
|
||||||
{
|
"-- BEGIN RECEIVED DATA --\n"
|
||||||
fprintf(stderr,
|
EINA_SLICE_STR_FMT
|
||||||
"-- BEGIN RECEIVED DATA --\n"
|
"-- END RECEIVED DATA--\n",
|
||||||
EINA_SLICE_STR_FMT
|
EINA_SLICE_STR_PRINT(efl_io_buffered_stream_slice_get(event->object)));
|
||||||
"-- END RECEIVED DATA--\n",
|
|
||||||
EINA_SLICE_STR_PRINT(s));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -142,19 +142,16 @@ _send_copier_done(void *data, const Efl_Event *event)
|
||||||
Eo *buffer = efl_io_copier_source_get(copier);
|
Eo *buffer = efl_io_copier_source_get(copier);
|
||||||
Eo *client = efl_io_copier_destination_get(copier);
|
Eo *client = efl_io_copier_destination_get(copier);
|
||||||
Send_Recv_Data *d = data;
|
Send_Recv_Data *d = data;
|
||||||
Eina_Slice slice;
|
Eina_Slice slice = efl_io_buffer_slice_get(buffer);
|
||||||
|
|
||||||
/* show what we sent, just for debug */
|
/* show what we sent, just for debug */
|
||||||
if (!efl_io_buffer_slice_get(buffer, &slice))
|
fprintf(stderr,
|
||||||
fprintf(stderr, "ERROR: could not get buffer slice\n");
|
"INFO: sent to %s %zd bytes:"
|
||||||
else
|
"\n--BEGIN SENT DATA--\n"
|
||||||
fprintf(stderr,
|
EINA_SLICE_STR_FMT
|
||||||
"INFO: sent to %s %zd bytes:"
|
"\n--END SENT DATA--\n",
|
||||||
"\n--BEGIN SENT DATA--\n"
|
efl_net_socket_address_remote_get(client),
|
||||||
EINA_SLICE_STR_FMT
|
slice.len, EINA_SLICE_STR_PRINT(slice));
|
||||||
"\n--END SENT DATA--\n",
|
|
||||||
efl_net_socket_address_remote_get(client),
|
|
||||||
slice.len, EINA_SLICE_STR_PRINT(slice));
|
|
||||||
|
|
||||||
if (d->recv_copier)
|
if (d->recv_copier)
|
||||||
{
|
{
|
||||||
|
@ -175,7 +172,7 @@ _send_copier_error(void *data, const Efl_Event *event)
|
||||||
const Eina_Error *perr = event->info;
|
const Eina_Error *perr = event->info;
|
||||||
Send_Recv_Data *d = data;
|
Send_Recv_Data *d = data;
|
||||||
uint64_t offset;
|
uint64_t offset;
|
||||||
Eina_Slice slice;
|
Eina_Slice slice, remaining;
|
||||||
|
|
||||||
if (*perr == ETIMEDOUT)
|
if (*perr == ETIMEDOUT)
|
||||||
{
|
{
|
||||||
|
@ -188,30 +185,26 @@ _send_copier_error(void *data, const Efl_Event *event)
|
||||||
retval = EXIT_FAILURE;
|
retval = EXIT_FAILURE;
|
||||||
|
|
||||||
offset = efl_io_buffer_position_read_get(buffer);
|
offset = efl_io_buffer_position_read_get(buffer);
|
||||||
if (!efl_io_buffer_slice_get(buffer, &slice))
|
slice = efl_io_buffer_slice_get(buffer);
|
||||||
fprintf(stderr, "ERROR: could not get buffer slice\n");
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Eina_Slice remaining = slice;
|
|
||||||
|
|
||||||
remaining.bytes += offset;
|
remaining = slice;
|
||||||
remaining.len -= offset;
|
remaining.bytes += offset;
|
||||||
|
remaining.len -= offset;
|
||||||
|
|
||||||
slice.len = offset;
|
slice.len = offset;
|
||||||
|
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"ERROR: sent to %s only %zd bytes:"
|
"ERROR: sent to %s only %zd bytes:"
|
||||||
"\n--BEGIN SENT DATA--\n"
|
"\n--BEGIN SENT DATA--\n"
|
||||||
EINA_SLICE_STR_FMT
|
EINA_SLICE_STR_FMT
|
||||||
"\n--END SENT DATA--\n"
|
"\n--END SENT DATA--\n"
|
||||||
"Remaining %zd bytes:"
|
"Remaining %zd bytes:"
|
||||||
"\n--BEGIN REMAINING DATA--\n"
|
"\n--BEGIN REMAINING DATA--\n"
|
||||||
EINA_SLICE_STR_FMT
|
EINA_SLICE_STR_FMT
|
||||||
"\n--END REMAINING DATA--\n",
|
"\n--END REMAINING DATA--\n",
|
||||||
efl_net_socket_address_remote_get(client),
|
efl_net_socket_address_remote_get(client),
|
||||||
slice.len, EINA_SLICE_STR_PRINT(slice),
|
slice.len, EINA_SLICE_STR_PRINT(slice),
|
||||||
remaining.len, EINA_SLICE_STR_PRINT(remaining));
|
remaining.len, EINA_SLICE_STR_PRINT(remaining));
|
||||||
}
|
|
||||||
|
|
||||||
fprintf(stderr, "ERROR: send copier %p failed %d '%s', check if should close..\n",
|
fprintf(stderr, "ERROR: send copier %p failed %d '%s', check if should close..\n",
|
||||||
copier, *perr, eina_error_msg_get(*perr));
|
copier, *perr, eina_error_msg_get(*perr));
|
||||||
|
@ -229,7 +222,7 @@ _recv_copier_done(void *data, const Efl_Event *event)
|
||||||
Eo *client = efl_io_copier_source_get(copier);
|
Eo *client = efl_io_copier_source_get(copier);
|
||||||
Eo *buffer = efl_io_copier_destination_get(copier);
|
Eo *buffer = efl_io_copier_destination_get(copier);
|
||||||
Send_Recv_Data *d = data;
|
Send_Recv_Data *d = data;
|
||||||
Eina_Slice slice;
|
Eina_Slice slice = efl_io_buffer_slice_get(buffer);
|
||||||
|
|
||||||
/* show case, you could use a copier to Efl_Io_Stdout, a
|
/* show case, you could use a copier to Efl_Io_Stdout, a
|
||||||
* file... and get progressive processing.
|
* file... and get progressive processing.
|
||||||
|
@ -240,16 +233,13 @@ _recv_copier_done(void *data, const Efl_Event *event)
|
||||||
* You could also steal the binbuf with
|
* You could also steal the binbuf with
|
||||||
* efl_io_buffer_binbuf_steal()
|
* efl_io_buffer_binbuf_steal()
|
||||||
*/
|
*/
|
||||||
if (!efl_io_buffer_slice_get(buffer, &slice))
|
fprintf(stderr,
|
||||||
fprintf(stderr, "ERROR: could not get buffer slice\n");
|
"INFO: recv from %s %zd bytes:"
|
||||||
else
|
"\n--BEGIN RECV DATA--\n"
|
||||||
fprintf(stderr,
|
EINA_SLICE_STR_FMT "\n"
|
||||||
"INFO: recv from %s %zd bytes:"
|
"\n--END RECV DATA--\n",
|
||||||
"\n--BEGIN RECV DATA--\n"
|
efl_net_socket_address_remote_get(client),
|
||||||
EINA_SLICE_STR_FMT "\n"
|
slice.len, EINA_SLICE_STR_PRINT(slice));
|
||||||
"\n--END RECV DATA--\n",
|
|
||||||
efl_net_socket_address_remote_get(client),
|
|
||||||
slice.len, EINA_SLICE_STR_PRINT(slice));
|
|
||||||
|
|
||||||
fprintf(stderr, "INFO: receive copier done, check if should close %p\n", copier);
|
fprintf(stderr, "INFO: receive copier done, check if should close %p\n", copier);
|
||||||
_send_recv_done(d, copier);
|
_send_recv_done(d, copier);
|
||||||
|
@ -275,16 +265,14 @@ _recv_copier_error(void *data, const Efl_Event *event)
|
||||||
|
|
||||||
retval = EXIT_FAILURE;
|
retval = EXIT_FAILURE;
|
||||||
|
|
||||||
if (!efl_io_buffer_slice_get(buffer, &slice))
|
slice = efl_io_buffer_slice_get(buffer);
|
||||||
fprintf(stderr, "ERROR: could not get buffer slice\n");
|
fprintf(stderr,
|
||||||
else
|
"ERROR: recv to %s only %zd bytes:"
|
||||||
fprintf(stderr,
|
"\n--BEGIN RECV DATA--\n"
|
||||||
"ERROR: recv to %s only %zd bytes:"
|
EINA_SLICE_STR_FMT "\n"
|
||||||
"\n--BEGIN RECV DATA--\n"
|
"\n--END RECV DATA--\n",
|
||||||
EINA_SLICE_STR_FMT "\n"
|
efl_net_socket_address_remote_get(client),
|
||||||
"\n--END RECV DATA--\n",
|
slice.len, EINA_SLICE_STR_PRINT(slice));
|
||||||
efl_net_socket_address_remote_get(client),
|
|
||||||
slice.len, EINA_SLICE_STR_PRINT(slice));
|
|
||||||
|
|
||||||
fprintf(stderr, "ERROR: receive copier %p failed %d '%s', check if should close..\n",
|
fprintf(stderr, "ERROR: receive copier %p failed %d '%s', check if should close..\n",
|
||||||
copier, *perr, eina_error_msg_get(*perr));
|
copier, *perr, eina_error_msg_get(*perr));
|
||||||
|
|
|
@ -37,22 +37,17 @@ _client_eos(void *data EINA_UNUSED, const Efl_Event *event)
|
||||||
static void
|
static void
|
||||||
_client_read_finished(void *data EINA_UNUSED, const Efl_Event *event)
|
_client_read_finished(void *data EINA_UNUSED, const Efl_Event *event)
|
||||||
{
|
{
|
||||||
Eina_Slice s;
|
|
||||||
|
|
||||||
/* on _error() we close it, then do not read as it has nothing */
|
/* on _error() we close it, then do not read as it has nothing */
|
||||||
if (efl_io_closer_closed_get(event->object))
|
if (efl_io_closer_closed_get(event->object))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (echo) return;
|
if (echo) return;
|
||||||
|
|
||||||
if (efl_io_buffered_stream_slice_get(event->object, &s))
|
fprintf(stderr,
|
||||||
{
|
"-- BEGIN RECEIVED DATA --\n"
|
||||||
fprintf(stderr,
|
EINA_SLICE_STR_FMT
|
||||||
"-- BEGIN RECEIVED DATA --\n"
|
"-- END RECEIVED DATA--\n",
|
||||||
EINA_SLICE_STR_FMT
|
EINA_SLICE_STR_PRINT(efl_io_buffered_stream_slice_get(event->object)));
|
||||||
"-- END RECEIVED DATA--\n",
|
|
||||||
EINA_SLICE_STR_PRINT(s));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Reference in New Issue