Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement loaned take #768

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 27 additions & 3 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ See details at :ref:`owned_types_concept`
.. c:function:: z_loaned_slice_t * z_view_slice_loan_mut(z_view_slice_t * slice)
.. c:function:: const z_loaned_slice_t * z_slice_loan(const z_owned_slice_t * slice)
.. c:function:: z_loaned_slice_t * z_slice_loan_mut(z_owned_slice_t * slice)

.. c:function:: z_result_t z_slice_take_from_loaned(z_owned_slice_t *dst, z_loaned_slice_t *src)

String
------
Expand Down Expand Up @@ -108,7 +108,7 @@ See details at :ref:`owned_types_concept`
.. c:function:: z_loaned_string_t * z_view_string_loan_mut(z_view_string_t * string)
.. c:function:: const z_loaned_string_t * z_string_loan(const z_owned_string_t * string)
.. c:function:: z_loaned_string_t * z_string_loan_mut(z_owned_string_t * string)

.. c:function:: z_result_t z_string_take_from_loaned(z_owned_string_t *dst, z_loaned_string_t *src)

String Array
------------
Expand Down Expand Up @@ -142,6 +142,7 @@ See details at :ref:`owned_types_concept`
.. c:function:: void z_string_array_clone(z_owned_string_array_t * dst, const z_loaned_string_array_t * string_array)
.. c:function:: const z_loaned_string_array_t * z_string_array_loan(const z_owned_string_array_t * string_array)
.. c:function:: z_loaned_string_array_t * z_string_array_loan_mut(z_owned_string_array_t * string_array)
.. c:function:: z_result_t z_string_array_take_from_loaned(z_owned_string_array_t *dst, z_loaned_string_array_t *src)


Common
Expand Down Expand Up @@ -205,6 +206,7 @@ See details at :ref:`owned_types_concept`
.. c:function:: z_loaned_keyexpr_t * z_view_keyexpr_loan_mut(z_view_keyexpr_t * keyexpr)
.. c:function:: const z_loaned_keyexpr_t * z_keyexpr_loan(const z_owned_keyexpr_t * keyexpr)
.. c:function:: z_loaned_keyexpr_t * z_keyexpr_loan_mut(z_owned_keyexpr_t * keyexpr)
.. c:function:: z_result_t z_keyexpr_take_from_loaned(z_owned_keyexpr_t *dst, z_loaned_keyexpr_t *src)

Payload
-------
Expand Down Expand Up @@ -261,11 +263,13 @@ See details at :ref:`owned_types_concept`
.. c:function:: void z_bytes_clone(z_owned_bytes_t * dst, const z_loaned_bytes_t * bytes)
.. c:function:: const z_loaned_bytes_t * z_bytes_loan(const z_owned_bytes_t * bytes)
.. c:function:: z_loaned_bytes_t * z_bytes_loan_mut(z_owned_bytes_t * bytes)
.. c:function:: z_result_t z_bytes_take_from_loaned(z_owned_bytes_t *dst, z_loaned_bytes_t *src)

.. c:function:: void z_bytes_writer_drop(z_moved_bytes_writer_t * bytes_writer)
.. c:function:: void z_bytes_writer_clone(z_owned_bytes_writer_t * dst, const z_loaned_bytes_writer_t * bytes_writer)
.. c:function:: const z_loaned_bytes_writer_t * z_bytes_writer_loan(const z_owned_bytes_writer_t * bytes_writer)
.. c:function:: z_loaned_bytes_writer_t * z_bytes_writer_loan_mut(z_owned_bytes_writer_t * bytes_writer)
.. c:function:: z_result_t z_bytes_writer_take_from_loaned(z_owned_bytes_writer_t *dst, z_loaned_bytes_writer_t *src)

Encoding
--------
Expand Down Expand Up @@ -300,6 +304,7 @@ See details at :ref:`owned_types_concept`
.. c:function:: void z_encoding_clone(z_owned_encoding_t * dst, const z_loaned_encoding_t * encoding)
.. c:function:: const z_loaned_encoding_t * z_encoding_loan(const z_owned_encoding_t * encoding)
.. c:function:: z_loaned_encoding_t * z_encoding_loan_mut(z_owned_encoding_t * encoding)
.. c:function:: z_result_t z_encoding_take_from_loaned(z_owned_encoding_t *dst, z_loaned_encoding_t *src)


Predefined Encodings
Expand Down Expand Up @@ -385,7 +390,8 @@ See details at :ref:`owned_types_concept`
.. c:function:: void z_reply_err_drop(z_moved_reply_err_t * reply_err)
.. c:function:: void z_reply_err_clone(z_owned_reply_err_t * dst, const z_loaned_reply_err_t * reply_err)
.. c:function:: const z_loaned_reply_err_t * z_reply_err_loan(const z_owned_reply_err_t * reply_err)

.. c:function:: z_loaned_reply_err_t * z_reply_err_loan_mut(z_owned_reply_err_t * reply_err)
.. c:function:: z_result_t z_reply_err_take_from_loaned(z_owned_reply_err_t *dst, z_loaned_reply_err_t *src)

Sample
------
Expand Down Expand Up @@ -424,6 +430,8 @@ See details at :ref:`owned_types_concept`
.. c:function:: void z_sample_drop(z_moved_sample_t * sample)
.. c:function:: void z_sample_clone(z_owned_sample_t * dst, const z_loaned_sample_t * sample)
.. c:function:: const z_loaned_sample_t * z_sample_loan(const z_owned_sample_t * sample)
.. c:function:: z_loaned_sample_t * z_sample_loan_mut(z_owned_sample_t * sample)
.. c:function:: z_result_t z_sample_take_from_loaned(z_owned_sample_t *dst, z_loaned_sample_t *src)


Timestamp
Expand Down Expand Up @@ -1103,6 +1111,8 @@ See details at :ref:`owned_types_concept`
.. c:function:: void z_query_drop(z_moved_query_t * query)
.. c:function:: void z_query_clone(z_owned_query_t * dst, const z_loaned_query_t * query)
.. c:function:: const z_loaned_query_t * z_query_loan(const z_owned_query_t * query)
.. c:function:: z_loaned_query_t * z_query_loan_mut(z_owned_query_t * query)
.. c:function:: z_result_t z_query_take_from_loaned(z_owned_query_t *dst, z_loaned_query_t *src)

Query
=====
Expand Down Expand Up @@ -1149,6 +1159,8 @@ See details at :ref:`owned_types_concept`
.. c:function:: void z_reply_drop(z_moved_reply_t * reply)
.. c:function:: void z_reply_clone(z_owned_reply_t * dst, const z_loaned_reply_t * reply)
.. c:function:: const z_loaned_reply_t * z_reply_loan(const z_owned_reply_t * reply)
.. c:function:: z_loaned_reply_t * z_reply_loan_mut(z_owned_reply_t * reply)
.. c:function:: z_result_t z_reply_take_from_loaned(z_owned_reply_t *dst, z_loaned_reply_t *src)


Scouting
Expand Down Expand Up @@ -1187,6 +1199,8 @@ See details at :ref:`owned_types_concept`
.. c:function:: void z_hello_drop(z_moved_hello_t * hello)
.. c:function:: void z_hello_clone(z_owned_hello_t * dst, const z_loaned_hello_t * hello)
.. c:function:: const z_loaned_hello_t * z_hello_loan(const z_owned_hello_t * hello)
.. c:function:: z_loaned_hello_t * z_hello_loan(z_owned_hello_t * hello)
.. c:function:: z_result_t z_hello_take_from_loaned(z_owned_hello_t *dst, z_loaned_hello_t *src)


Serialization
Expand Down Expand Up @@ -1270,6 +1284,16 @@ Functions
.. autocfunction:: serialization.h::ze_serialize_str
.. autocfunction:: serialization.h::ze_serialize_substr

Ownership Functions
^^^^^^^^^^^^^^^^^^^

See details at :ref:`owned_types_concept`

.. c:function:: void ze_serializer_drop(ze_moved_serializer_t * serializer)
.. c:function:: void ze_serializer_clone(ze_owned_serializer_t * dst, const ze_loaned_serializer_t * serializer)
.. c:function:: const ze_loaned_serializer_t * ze_serializer_loan(const ze_owned_serializer_t * serializer)
.. c:function:: ze_loaned_serializer_t * ze_serializer_loan_mut(ze_owned_serializer_t * serializer)
.. c:function:: z_result_t ze_serializer_take_from_loaned(ze_owned_serializer_t *dst, ze_loaned_serializer_t *src)

Others
======
Expand Down
52 changes: 26 additions & 26 deletions include/zenoh-pico/api/handlers.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ extern "C" {
return h; \
} \
\
_Z_OWNED_FUNCTIONS_VALUE_NO_COPY_INLINE_IMPL(handler_type, handler_name, _z_##handler_name##_check, \
_z_##handler_name##_null, _z_##handler_name##_clear) \
_Z_OWNED_FUNCTIONS_VALUE_NO_COPY_NO_MOVE_INLINE_IMPL(handler_type, handler_name, _z_##handler_name##_check, \
_z_##handler_name##_null, _z_##handler_name##_clear) \
\
static inline z_result_t handler_new_f_name(callback_type *callback, z_owned_##handler_name##_t *handler, \
size_t capacity) { \
Expand Down Expand Up @@ -145,30 +145,30 @@ extern "C" {
/* elem_drop_f */ z_##item_name##_drop, \
/* elem_null */ z_internal_##item_name##_null)

#define _Z_CHANNEL_DUMMY_IMPL(handler_type, handler_name, item_name) \
_Z_OWNED_TYPE_VALUE(handler_type, handler_name) \
static inline void _z_##handler_name##_clear(handler_type *handler) { _ZP_UNUSED(handler); } \
static inline bool _z_##handler_name##_check(const handler_type *handler) { \
_ZP_UNUSED(handler); \
return false; \
} \
static inline handler_type _z_##handler_name##_null(void) { \
handler_type h = {0}; \
return h; \
} \
_Z_OWNED_FUNCTIONS_VALUE_NO_COPY_INLINE_IMPL(handler_type, handler_name, _z_##handler_name##_check, \
_z_##handler_name##_null, _z_##handler_name##_clear) \
static inline z_result_t z_##handler_name##_try_recv(const z_loaned_##handler_name##_t *handler, \
z_owned_##item_name##_t *e) { \
_ZP_UNUSED(handler); \
_ZP_UNUSED(e); \
return Z_CHANNEL_DISCONNECTED; \
} \
static inline z_result_t z_##handler_name##_recv(const z_loaned_##handler_name##_t *handler, \
z_owned_##item_name##_t *e) { \
_ZP_UNUSED(handler); \
_ZP_UNUSED(e); \
return Z_CHANNEL_DISCONNECTED; \
#define _Z_CHANNEL_DUMMY_IMPL(handler_type, handler_name, item_name) \
_Z_OWNED_TYPE_VALUE(handler_type, handler_name) \
static inline void _z_##handler_name##_clear(handler_type *handler) { _ZP_UNUSED(handler); } \
static inline bool _z_##handler_name##_check(const handler_type *handler) { \
_ZP_UNUSED(handler); \
return false; \
} \
static inline handler_type _z_##handler_name##_null(void) { \
handler_type h = {0}; \
return h; \
} \
_Z_OWNED_FUNCTIONS_VALUE_NO_COPY_NO_MOVE_INLINE_IMPL(handler_type, handler_name, _z_##handler_name##_check, \
_z_##handler_name##_null, _z_##handler_name##_clear) \
static inline z_result_t z_##handler_name##_try_recv(const z_loaned_##handler_name##_t *handler, \
z_owned_##item_name##_t *e) { \
_ZP_UNUSED(handler); \
_ZP_UNUSED(e); \
return Z_CHANNEL_DISCONNECTED; \
} \
static inline z_result_t z_##handler_name##_recv(const z_loaned_##handler_name##_t *handler, \
z_owned_##item_name##_t *e) { \
_ZP_UNUSED(handler); \
_ZP_UNUSED(e); \
return Z_CHANNEL_DISCONNECTED; \
}

#define _Z_CHANNEL_DEFINE_DUMMY(item_name, kind_name) \
Expand Down
Loading
Loading