diff --git a/examples/unix/c11/z_bytes.c b/examples/unix/c11/z_bytes.c index cef3b2113..983d95fb3 100644 --- a/examples/unix/c11/z_bytes.c +++ b/examples/unix/c11/z_bytes.c @@ -57,7 +57,7 @@ int main(void) { z_drop(z_move(payload)); z_drop(z_move(output_string)); } -#if defined(Z_FEATURE_UNSTABLE_API) + // Serialization { // Arithmetic types: uint8, uint16, uint32, uint64, int8, int16, int32, int64, float, double @@ -70,7 +70,7 @@ int main(void) { // Corresponding encoding to be used in operations options like `z_put()`, `z_get()`, etc. // const z_loaned_encoding* encoding = z_encoding_zenoh_uint32(); } -#endif + // Writer/reader for raw bytes { uint8_t input_writer[] = {0, 1, 2, 3, 4}; @@ -86,7 +86,7 @@ int main(void) { assert(0 == memcmp(input_writer, output_reader, sizeof(output_reader))); z_drop(z_move(payload)); } -#if defined(Z_FEATURE_UNSTABLE_API) + // Using serializer/deserializer for composite types { // A sequence of primitive types @@ -193,7 +193,7 @@ int main(void) { z_drop(z_move(c)); z_drop(z_move(payload)); } -#endif + // Slice iterator { /// Fill z_bytes with some data diff --git a/examples/unix/c11/z_get_attachment.c b/examples/unix/c11/z_get_attachment.c index c9490447e..8296f01b2 100644 --- a/examples/unix/c11/z_get_attachment.c +++ b/examples/unix/c11/z_get_attachment.c @@ -66,7 +66,6 @@ void reply_handler(z_loaned_reply_t *reply, void *ctx) { z_drop(z_move(replystr)); z_drop(z_move(encoding)); -#if defined(Z_FEATURE_UNSTABLE_API) // Check attachment const z_loaned_bytes_t *attachment = z_sample_attachment(sample); if (attachment == NULL) { @@ -85,7 +84,6 @@ void reply_handler(z_loaned_reply_t *reply, void *ctx) { } drop_attachment(kvp, attachment_len); free(kvp); -#endif } else { printf(">> Received an error\n"); } @@ -172,7 +170,6 @@ int main(int argc, char **argv) { opts.payload = z_bytes_move(&payload); } -#if defined(Z_FEATURE_UNSTABLE_API) // Add attachment value kv_pair_t kvs[1]; z_string_from_str(&kvs[0].key, "test_key", NULL, NULL); @@ -189,7 +186,7 @@ int main(int argc, char **argv) { drop_attachment(kvs, 1); ze_serializer_finish(z_move(serializer), &attachment); opts.attachment = z_move(attachment); -#endif + // Add encoding value z_owned_encoding_t encoding; z_encoding_from_str(&encoding, "zenoh/string;utf8"); diff --git a/examples/unix/c11/z_pub_attachment.c b/examples/unix/c11/z_pub_attachment.c index 1f7ca272f..3c99f8d90 100644 --- a/examples/unix/c11/z_pub_attachment.c +++ b/examples/unix/c11/z_pub_attachment.c @@ -113,11 +113,10 @@ int main(int argc, char **argv) { z_publisher_put_options_t options; z_publisher_put_options_default(&options); -#if defined(Z_FEATURE_UNSTABLE_API) // Allocate attachment kv_pair_t kvs[2]; kvs[0] = (kv_pair_t){.key = "source", .value = "C"}; -#endif + z_owned_bytes_t attachment; z_bytes_empty(&attachment); @@ -139,7 +138,7 @@ int main(int argc, char **argv) { // Create payload z_owned_bytes_t payload; z_bytes_copy_from_str(&payload, buf); -#if defined(Z_FEATURE_UNSTABLE_API) + // Add attachment value char buf_ind[16]; sprintf(buf_ind, "%d", idx); @@ -153,7 +152,7 @@ int main(int argc, char **argv) { } ze_serializer_finish(z_move(serializer), &attachment); options.attachment = z_move(attachment); -#endif + // Add encoding value z_encoding_from_str(&encoding, "zenoh/string;utf8"); options.encoding = z_move(encoding); diff --git a/examples/unix/c11/z_queryable_attachment.c b/examples/unix/c11/z_queryable_attachment.c index 6609995f1..6bb01edd4 100644 --- a/examples/unix/c11/z_queryable_attachment.c +++ b/examples/unix/c11/z_queryable_attachment.c @@ -65,7 +65,7 @@ void query_handler(z_loaned_query_t *query, void *ctx) { } z_drop(z_move(payload_string)); z_drop(z_move(encoding)); -#if defined(Z_FEATURE_UNSTABLE_API) + // Check attachment const z_loaned_bytes_t *attachment = z_query_attachment(query); if (attachment != NULL) { @@ -83,7 +83,6 @@ void query_handler(z_loaned_query_t *query, void *ctx) { drop_attachment(kvp, attachment_len); free(kvp); } -#endif // Reply payload z_owned_bytes_t reply_payload; @@ -91,7 +90,7 @@ void query_handler(z_loaned_query_t *query, void *ctx) { z_query_reply_options_t options; z_query_reply_options_default(&options); -#if defined(Z_FEATURE_UNSTABLE_API) + // Reply attachment z_owned_bytes_t reply_attachment; kv_pair_t kvs[1]; @@ -105,7 +104,7 @@ void query_handler(z_loaned_query_t *query, void *ctx) { ze_serializer_finish(z_move(serializer), &reply_attachment); options.attachment = z_move(reply_attachment); drop_attachment(kvs, 1); -#endif + // Reply encoding z_owned_encoding_t reply_encoding; z_encoding_from_str(&reply_encoding, "zenoh/string;utf8"); diff --git a/examples/unix/c11/z_sub_attachment.c b/examples/unix/c11/z_sub_attachment.c index 7ca79064b..3c0d47f26 100644 --- a/examples/unix/c11/z_sub_attachment.c +++ b/examples/unix/c11/z_sub_attachment.c @@ -64,7 +64,7 @@ void data_handler(z_loaned_sample_t *sample, void *ctx) { printf(" with timestamp: %" PRIu64 "\n", z_timestamp_ntp64_time(ts)); } // Check attachment -#if defined(Z_FEATURE_UNSTABLE_API) + const z_loaned_bytes_t *attachment = z_sample_attachment(sample); if (attachment != NULL) { ze_deserializer_t deserializer = ze_deserializer_from_bytes(attachment); @@ -81,7 +81,6 @@ void data_handler(z_loaned_sample_t *sample, void *ctx) { drop_attachment(kvp, attachment_len); free(kvp); } -#endif z_drop(z_move(value)); z_drop(z_move(encoding)); diff --git a/include/zenoh-pico/api/macros.h b/include/zenoh-pico/api/macros.h index 1a1363afd..4a438530e 100644 --- a/include/zenoh-pico/api/macros.h +++ b/include/zenoh-pico/api/macros.h @@ -24,11 +24,7 @@ #ifndef __cplusplus // clang-format off -#if defined (Z_FEATURE_UNSTABLE_API) -#define __ZP_ZE_LOAN ze_owned_serializer_t : ze_serializer_loan, -#else -#define __ZP_ZE_LOAN -#endif + /** * Defines a generic function for loaning any of the ``z_owned_X_t`` types. * @@ -73,17 +69,10 @@ z_owned_closure_query_t : z_closure_query_loan, \ z_owned_closure_hello_t : z_closure_hello_loan, \ z_owned_closure_zid_t : z_closure_zid_loan, \ - __ZP_ZE_LOAN \ + ze_owned_serializer_t : ze_serializer_loan, \ z_owned_bytes_writer_t : z_bytes_writer_loan \ )(&x) - -#if defined (Z_FEATURE_UNSTABLE_API) -#define __ZP_ZE_LOAN_MUT ze_owned_serializer_t : ze_serializer_loan_mut , -#else -#define __ZP_ZE_LOAN_MUT -#endif - \ #define z_loan_mut(x) _Generic((x), \ z_owned_keyexpr_t : z_keyexpr_loan_mut, \ z_owned_config_t : z_config_loan_mut, \ @@ -104,17 +93,10 @@ z_owned_mutex_t : z_mutex_loan_mut, \ z_owned_condvar_t : z_condvar_loan_mut, \ z_owned_reply_err_t : z_reply_err_loan_mut, \ - __ZP_ZE_LOAN_MUT \ + ze_owned_serializer_t : ze_serializer_loan_mut, \ z_owned_bytes_writer_t : z_bytes_writer_loan_mut \ )(&x) - -#if defined (Z_FEATURE_UNSTABLE_API) -#define __ZP_ZE_DROP ze_moved_serializer_t* : ze_serializer_drop, -#else -#define __ZP_ZE_DROP -#endif - /** * Defines a generic function for dropping any of the ``z_owned_X_t`` types. * @@ -152,17 +134,10 @@ z_moved_ring_handler_reply_t* : z_ring_handler_reply_drop, \ z_moved_ring_handler_sample_t* : z_ring_handler_sample_drop, \ z_moved_reply_err_t* : z_reply_err_drop, \ - __ZP_ZE_DROP \ + ze_moved_serializer_t* : ze_serializer_drop, \ z_moved_bytes_writer_t* : z_bytes_writer_drop \ )(x) - -#if defined (Z_FEATURE_UNSTABLE_API) -#define __ZP_ZE_CHECK ze_owned_serializer_t : ze_internal_serializer_check, -#else -#define __ZP_ZE_CHECK -#endif - /** * Defines a generic function for checking the validity of any of the ``z_owned_X_t`` types. * @@ -195,7 +170,7 @@ z_owned_sample_t : z_internal_sample_check, \ z_owned_query_t : z_internal_query_check, \ z_owned_encoding_t : z_internal_encoding_check, \ - __ZP_ZE_CHECK \ + ze_owned_serializer_t : ze_internal_serializer_check, \ z_owned_bytes_writer_t : z_internal_bytes_writer_check \ )(&x) @@ -233,12 +208,6 @@ const z_loaned_ring_handler_sample_t* : z_ring_handler_sample_recv \ )(x, __VA_ARGS__) -#if defined (Z_FEATURE_UNSTABLE_API) -#define __ZP_ZE_MOVE ze_owned_serializer_t : ze_serializer_move, -#else -#define __ZP_ZE_MOVE -#endif - /** * Defines a generic function for moving any of the ``z_owned_X_t`` types. * @@ -279,16 +248,10 @@ z_owned_fifo_handler_reply_t : z_fifo_handler_reply_move, \ z_owned_fifo_handler_sample_t : z_fifo_handler_sample_move, \ z_owned_reply_err_t : z_reply_err_move, \ - __ZP_ZE_MOVE \ + ze_owned_serializer_t : ze_serializer_move, \ z_owned_bytes_writer_t : z_bytes_writer_move \ )(&x) -#if defined (Z_FEATURE_UNSTABLE_API) -#define __ZP_ZE_TAKE ze_owned_serializer_t *: ze_serializer_take, -#else -#define __ZP_ZE_TAKE -#endif - /** * Defines a generic function for extracting the ``z_owned_X_t`` type from ``z_moved_X_t`` * @@ -330,7 +293,7 @@ z_owned_string_array_t *: z_string_array_take, \ z_owned_string_t *: z_string_take, \ z_owned_subscriber_t *: z_subscriber_take, \ - __ZP_ZE_TAKE \ + ze_owned_serializer_t *: ze_serializer_take, \ z_owned_bytes_writer_t *: z_bytes_writer_take \ )(this_, x) @@ -359,12 +322,6 @@ z_owned_config_t* : z_config_clone \ )(x, y) -#if defined (Z_FEATURE_UNSTABLE_API) -#define __ZP_ZE_NULL ze_owned_serializer_t * : ze_internal_serializer_null, -#else -#define __ZP_ZE_NULL -#endif - /** * Defines a generic function for making null object of any of the ``z_owned_X_t`` types. * @@ -393,7 +350,7 @@ z_owned_sample_t * : z_internal_sample_null, \ z_owned_encoding_t * : z_internal_encoding_null, \ z_owned_reply_err_t * : z_internal_reply_err_null, \ - __ZP_ZE_NULL \ + ze_owned_serializer_t * : ze_internal_serializer_null, \ z_owned_bytes_writer_t * : z_internal_bytes_writer_null \ )(x) @@ -458,9 +415,7 @@ inline const z_loaned_ring_handler_query_t* z_loan(const z_owned_ring_handler_qu inline const z_loaned_ring_handler_reply_t* z_loan(const z_owned_ring_handler_reply_t& x) { return z_ring_handler_reply_loan(&x); }; inline const z_loaned_ring_handler_sample_t* z_loan(const z_owned_ring_handler_sample_t& x) { return z_ring_handler_sample_loan(&x); }; inline const z_loaned_bytes_writer_t* z_loan(const z_owned_bytes_writer_t& x) { return z_bytes_writer_loan(&x); }; -#if defined(Z_FEATURE_UNSTABLE_API) inline const ze_loaned_serializer_t* z_loan(const ze_owned_serializer_t& x) { return ze_serializer_loan(&x); }; -#endif // z_loan_mut definition inline z_loaned_keyexpr_t* z_loan_mut(z_owned_keyexpr_t& x) { return z_keyexpr_loan_mut(&x); } @@ -485,9 +440,7 @@ inline z_loaned_mutex_t* z_loan_mut(z_owned_mutex_t& x) { return z_mutex_loan_mu inline z_loaned_condvar_t* z_loan_mut(z_owned_condvar_t& x) { return z_condvar_loan_mut(&x); } inline z_loaned_reply_err_t* z_loan_mut(z_owned_reply_err_t& x) { return z_reply_err_loan_mut(&x); } inline z_loaned_bytes_writer_t* z_loan_mut(z_owned_bytes_writer_t& x) { return z_bytes_writer_loan_mut(&x); }; -#if defined(Z_FEATURE_UNSTABLE_API) inline ze_loaned_serializer_t* z_loan_mut(ze_owned_serializer_t& x) { return ze_serializer_loan_mut(&x); }; -#endif // z_drop definition inline void z_drop(z_moved_session_t* v) { z_session_drop(v); } @@ -520,9 +473,7 @@ inline void z_drop(z_moved_fifo_handler_query_t* v) { z_fifo_handler_query_drop( inline void z_drop(z_moved_ring_handler_reply_t* v) { z_ring_handler_reply_drop(v); } inline void z_drop(z_moved_fifo_handler_reply_t* v) { z_fifo_handler_reply_drop(v); } inline void z_drop(z_moved_bytes_writer_t* v) { z_bytes_writer_drop(v); } -#if defined(Z_FEATURE_UNSTABLE_API) inline void z_drop(ze_moved_serializer_t* v) { ze_serializer_drop(v); } -#endif // z_internal_null definition inline void z_internal_null(z_owned_session_t* v) { z_internal_session_null(v); } @@ -551,9 +502,7 @@ inline void z_internal_null(z_owned_fifo_handler_query_t* v) { return z_internal inline void z_internal_null(z_owned_fifo_handler_reply_t* v) { return z_internal_fifo_handler_reply_null(v); }; inline void z_internal_null(z_owned_fifo_handler_sample_t* v) { return z_internal_fifo_handler_sample_null(v); }; inline void z_internal_null(z_owned_bytes_writer_t* v) { return z_internal_bytes_writer_null(v); }; -#if defined(Z_FEATURE_UNSTABLE_API) inline void z_internal_null(ze_owned_serializer_t* v) { return ze_internal_serializer_null(v); }; -#endif // z_internal_check definition inline bool z_internal_check(const z_owned_session_t& v) { return z_internal_session_check(&v); } @@ -577,9 +526,7 @@ inline bool z_internal_check(const z_owned_ring_handler_query_t& v) { return z_i inline bool z_internal_check(const z_owned_ring_handler_reply_t& v) { return z_internal_ring_handler_reply_check(&v); }; inline bool z_internal_check(const z_owned_ring_handler_sample_t& v) { return z_internal_ring_handler_sample_check(&v); }; inline bool z_internal_check(const z_owned_bytes_writer_t& v) { return z_internal_bytes_writer_check(&v); }; -#if defined(Z_FEATURE_UNSTABLE_API) inline bool z_internal_check(const ze_owned_serializer_t& v) { return ze_internal_serializer_check(&v); }; -#endif // z_call definition inline void z_call(const z_loaned_closure_sample_t &closure, z_loaned_sample_t *sample) @@ -712,9 +659,7 @@ inline z_moved_ring_handler_sample_t* z_move(z_owned_ring_handler_sample_t& x) { return z_ring_handler_sample_move(&x); }; inline z_moved_bytes_writer_t* z_move(z_owned_bytes_writer_t& x) { return z_bytes_writer_move(&x); }; -#if defined(Z_FEATURE_UNSTABLE_API) inline ze_moved_serializer_t* z_move(ze_owned_serializer_t& x) { return ze_serializer_move(&x); }; -#endif // z_take definition inline void z_take(z_owned_session_t* this_, z_moved_session_t* v) { return z_session_take(this_, v); } @@ -759,9 +704,7 @@ inline void z_take(z_owned_fifo_handler_reply_t* this_, z_moved_fifo_handler_rep z_fifo_handler_reply_take(this_, v); } inline void z_take(z_owned_bytes_writer_t* this_, z_moved_bytes_writer_t* v) { z_bytes_writer_take(this_, v); } -#if defined(Z_FEATURE_UNSTABLE_API) inline void z_take(ze_owned_serializer_t* this_, ze_moved_serializer_t* v) { ze_serializer_take(this_, v); } -#endif // z_clone definition inline z_result_t z_clone(z_owned_bytes_t* dst, z_loaned_bytes_t* this_) { return z_bytes_clone(dst, this_); }; @@ -1010,7 +953,6 @@ template <> struct z_owned_to_loaned_type_t { typedef z_loaned_bytes_writer_t type; }; -#if defined(Z_FEATURE_UNSTABLE_API) template <> struct z_loaned_to_owned_type_t { typedef ze_owned_serializer_t type; @@ -1019,7 +961,6 @@ template <> struct z_owned_to_loaned_type_t { typedef ze_loaned_serializer_t type; }; -#endif #endif diff --git a/include/zenoh-pico/api/serialization.h b/include/zenoh-pico/api/serialization.h index 4bc214860..d79be3ad7 100644 --- a/include/zenoh-pico/api/serialization.h +++ b/include/zenoh-pico/api/serialization.h @@ -19,14 +19,12 @@ #include "zenoh-pico/api/primitives.h" #include "zenoh-pico/utils/endianness.h" -#if defined(Z_FEATURE_UNSTABLE_API) - #ifdef __cplusplus extern "C" { #endif /** - * Represents a reader for serialized data (unstable). + * Represents a reader for serialized data. */ typedef struct ze_deserializer_t { z_bytes_reader_t _reader; @@ -37,12 +35,12 @@ typedef struct _ze_serializer_t { } _ze_serializer_t; /** - * Represents a writer for serialized data (unstable). + * Represents a writer for serialized data. */ _Z_OWNED_TYPE_VALUE_PREFIX(ze, _ze_serializer_t, serializer) /** - * Constructs an empty serializer (unstable). + * Constructs an empty serializer. * * Parameters: * serializer: An uninitialized memory location where serializer is to be constructed. @@ -53,7 +51,7 @@ _Z_OWNED_TYPE_VALUE_PREFIX(ze, _ze_serializer_t, serializer) z_result_t ze_serializer_empty(ze_owned_serializer_t *serializer); /** - * Finishes serialization and returns underlying bytes (unstable). + * Finishes serialization and returns underlying bytes. * * Parameters: * serializer: A data serializer. @@ -63,7 +61,7 @@ z_result_t ze_serializer_empty(ze_owned_serializer_t *serializer); void ze_serializer_finish(ze_moved_serializer_t *serializer, z_owned_bytes_t *bytes); /** - * Returns a deserializer for :c:type:`z_loaned_bytes_t` (unstable). + * Returns a deserializer for :c:type:`z_loaned_bytes_t`. * * The `bytes` should outlive the reader and should not be modified, while reader is in use. * @@ -76,7 +74,7 @@ void ze_serializer_finish(ze_moved_serializer_t *serializer, z_owned_bytes_t *by ze_deserializer_t ze_deserializer_from_bytes(const z_loaned_bytes_t *bytes); /** - * Checks if deserializer parsed all of its data (unstable). + * Checks if deserializer parsed all of its data. * * Parameters: * deserializer: A deserializer instance. @@ -87,7 +85,7 @@ ze_deserializer_t ze_deserializer_from_bytes(const z_loaned_bytes_t *bytes); bool ze_deserializer_is_done(const ze_deserializer_t *deserializer); /** - * Writes a serialized :c:type:`uint8_t` into underlying :c:type:`z_owned_bytes_t` (unstable). + * Writes a serialized :c:type:`uint8_t` into underlying :c:type:`z_owned_bytes_t`. * * Parameters: * serializer: A serializer instance. @@ -101,7 +99,7 @@ static inline z_result_t ze_serializer_serialize_uint8(ze_loaned_serializer_t *s } /** - * Writes a serialized :c:type:`uint16_t` into underlying :c:type:`z_owned_bytes_t` (unstable). + * Writes a serialized :c:type:`uint16_t` into underlying :c:type:`z_owned_bytes_t`. * * Parameters: * serializer: A serializer instance. @@ -116,7 +114,7 @@ static inline z_result_t ze_serializer_serialize_uint16(ze_loaned_serializer_t * } /** - * Writes a serialized :c:type:`uint32_t` into underlying :c:type:`z_owned_bytes_t` (unstable). + * Writes a serialized :c:type:`uint32_t` into underlying :c:type:`z_owned_bytes_t`. * * Parameters: * serializer: A serializer instance. @@ -131,7 +129,7 @@ static inline z_result_t ze_serializer_serialize_uint32(ze_loaned_serializer_t * } /** - * Writes a serialized :c:type:`uint64_t` into underlying :c:type:`z_owned_bytes_t` (unstable). + * Writes a serialized :c:type:`uint64_t` into underlying :c:type:`z_owned_bytes_t`. * * Parameters: * serializer: A serializer instance. @@ -146,7 +144,7 @@ static inline z_result_t ze_serializer_serialize_uint64(ze_loaned_serializer_t * } /** - * Writes a serialized :c:type:`float` into underlying :c:type:`z_owned_bytes_t` (unstable). + * Writes a serialized :c:type:`float` into underlying :c:type:`z_owned_bytes_t`. * * Parameters: * serializer: A serializer instance. @@ -160,7 +158,7 @@ static inline z_result_t ze_serializer_serialize_float(ze_loaned_serializer_t *s } /** - * Writes a serialized :c:type:`double` into underlying :c:type:`z_owned_bytes_t` (unstable). + * Writes a serialized :c:type:`double` into underlying :c:type:`z_owned_bytes_t`. * * Parameters: * serializer: A serializer instance. @@ -174,7 +172,7 @@ static inline z_result_t ze_serializer_serialize_double(ze_loaned_serializer_t * } /** - * Writes a serialized :c:type:`int8_t` into underlying :c:type:`z_owned_bytes_t` (unstable). + * Writes a serialized :c:type:`int8_t` into underlying :c:type:`z_owned_bytes_t`. * * Parameters: * serializer: A serializer instance. @@ -202,7 +200,7 @@ static inline z_result_t ze_serializer_serialize_int16(ze_loaned_serializer_t *s } /** - * Writes a serialized :c:type:`int32_t` into underlying :c:type:`z_owned_bytes_t` (unstable). + * Writes a serialized :c:type:`int32_t` into underlying :c:type:`z_owned_bytes_t`. * * Parameters: * serializer: A serializer instance. @@ -216,7 +214,7 @@ static inline z_result_t ze_serializer_serialize_int32(ze_loaned_serializer_t *s } /** - * Writes a serialized :c:type:`int64_t` into underlying :c:type:`z_owned_bytes_t` (unstable). + * Writes a serialized :c:type:`int64_t` into underlying :c:type:`z_owned_bytes_t`. * * Parameters: * serializer: A serializer instance. @@ -230,7 +228,7 @@ static inline z_result_t ze_serializer_serialize_int64(ze_loaned_serializer_t *s } /** - * Deserializes next portion of data into a `uint8_t` (unstable). + * Deserializes next portion of data into a `uint8_t`. * * Parameters: * deserializer: A deserializer instance. @@ -244,7 +242,7 @@ static inline z_result_t ze_deserializer_deserialize_uint8(ze_deserializer_t *de } /** - * Deserializes next portion of data into a `uint16_t` (unstable). + * Deserializes next portion of data into a `uint16_t`. * * Parameters: * deserializer: A deserializer instance. @@ -262,7 +260,7 @@ static inline z_result_t ze_deserializer_deserialize_uint16(ze_deserializer_t *d } /** - * Deserializes next portion of data into a `uint32_t` (unstable). + * Deserializes next portion of data into a `uint32_t`. * * Parameters: * deserializer: A deserializer instance. @@ -280,7 +278,7 @@ static inline z_result_t ze_deserializer_deserialize_uint32(ze_deserializer_t *d } /** - * Deserializes next portion of data into a `uint64_t` (unstable). + * Deserializes next portion of data into a `uint64_t`. * * Parameters: * deserializer: A deserializer instance. @@ -298,7 +296,7 @@ static inline z_result_t ze_deserializer_deserialize_uint64(ze_deserializer_t *d } /** - * Deserializes next portion of data into a `float` (unstable). + * Deserializes next portion of data into a `float`. * * Parameters: * deserializer: A deserializer instance. @@ -315,7 +313,7 @@ static inline z_result_t ze_deserializer_deserialize_float(ze_deserializer_t *de } /** - * Deserializes next portion of data into a `double` (unstable). + * Deserializes next portion of data into a `double`. * * Parameters: * deserializer: A deserializer instance. @@ -332,7 +330,7 @@ static inline z_result_t ze_deserializer_deserialize_double(ze_deserializer_t *d } /** - * Deserializes next portion of data into a `int8_t` (unstable). + * Deserializes next portion of data into a `int8_t`. * * Parameters: * deserializer: A deserializer instance. @@ -346,7 +344,7 @@ static inline z_result_t ze_deserializer_deserialize_int8(ze_deserializer_t *des } /** - * Deserializes next portion of data into a `int16_t` (unstable). + * Deserializes next portion of data into a `int16_t`. * * Parameters: * deserializer: A deserializer instance. @@ -360,7 +358,7 @@ static inline z_result_t ze_deserializer_deserialize_int16(ze_deserializer_t *de } /** - * Deserializes next portion of data into a `int32_t` (unstable). + * Deserializes next portion of data into a `int32_t`. * * Parameters: * deserializer: A deserializer instance. @@ -374,7 +372,7 @@ static inline z_result_t ze_deserializer_deserialize_int32(ze_deserializer_t *de } /** - * Deserializes next portion of data into a `int64_t` (unstable). + * Deserializes next portion of data into a `int64_t`. * * Parameters: * deserializer: A deserializer instance. @@ -388,7 +386,7 @@ static inline z_result_t ze_deserializer_deserialize_int64(ze_deserializer_t *de } /** - * Serializes array of bytes and writes it into an underlying :c:type:`z_owned_bytes_t` (unstable). + * Serializes array of bytes and writes it into an underlying :c:type:`z_owned_bytes_t`. * * Parameters: * serializer: A serializer instance. @@ -401,7 +399,7 @@ static inline z_result_t ze_deserializer_deserialize_int64(ze_deserializer_t *de z_result_t ze_serializer_serialize_buf(ze_loaned_serializer_t *serializer, const uint8_t *val, size_t len); /** - * Serializes slice and writes it into an underlying :c:type:`z_owned_bytes_t` (unstable). + * Serializes slice and writes it into an underlying :c:type:`z_owned_bytes_t`. * * Parameters: * serializer: A serializer instance. @@ -414,7 +412,7 @@ z_result_t ze_serializer_serialize_buf(ze_loaned_serializer_t *serializer, const z_result_t ze_serializer_serialize_slice(ze_loaned_serializer_t *serializer, const z_loaned_slice_t *val); /** - * Deserializes next portion of data and advances the reader position (unstable). + * Deserializes next portion of data and advances the reader position. * * Parameters: * deserializer: A deserializer instance. @@ -426,7 +424,7 @@ z_result_t ze_serializer_serialize_slice(ze_loaned_serializer_t *serializer, con z_result_t ze_deserializer_deserialize_slice(ze_deserializer_t *deserializer, z_owned_slice_t *val); /** - * Serializes a null-terminated string and writes it into an underlying :c:type:`z_owned_bytes_t` (unstable). + * Serializes a null-terminated string and writes it into an underlying :c:type:`z_owned_bytes_t`. * * Parameters: * serializer: A serializer instance. @@ -438,7 +436,7 @@ z_result_t ze_deserializer_deserialize_slice(ze_deserializer_t *deserializer, z_ z_result_t ze_serializer_serialize_str(ze_loaned_serializer_t *serializer, const char *val); /** - * Serializes a string and writes it into an underlying :c:type:`z_owned_bytes_t` (unstable). + * Serializes a string and writes it into an underlying :c:type:`z_owned_bytes_t`. * * Parameters: * serializer: A serializer instance. @@ -450,7 +448,7 @@ z_result_t ze_serializer_serialize_str(ze_loaned_serializer_t *serializer, const z_result_t ze_serializer_serialize_string(ze_loaned_serializer_t *serializer, const z_loaned_string_t *val); /** - * Deserializes next portion of data and advances the reader position (unstable). + * Deserializes next portion of data and advances the reader position. * * Parameters: * deserializer: A deserializer instance. @@ -462,7 +460,7 @@ z_result_t ze_serializer_serialize_string(ze_loaned_serializer_t *serializer, co z_result_t ze_deserializer_deserialize_string(ze_deserializer_t *deserializer, z_owned_string_t *val); /** - * Initiate serialization of a sequence of multiple elements (unstable). + * Initiate serialization of a sequence of multiple elements. * * Parameters: * serializer: A serializer instance. @@ -475,7 +473,7 @@ z_result_t ze_deserializer_deserialize_string(ze_deserializer_t *deserializer, z z_result_t ze_serializer_serialize_sequence_length(ze_loaned_serializer_t *serializer, size_t len); /** - * Initiate deserialization of a sequence of multiple elements (unstable). + * Initiate deserialization of a sequence of multiple elements. * * Parameters: * deserializer: A deserializer instance. @@ -488,7 +486,7 @@ z_result_t ze_serializer_serialize_sequence_length(ze_loaned_serializer_t *seria z_result_t ze_deserializer_deserialize_sequence_length(ze_deserializer_t *deserializer, size_t *len); /** - * Serializes data into a :c:type:`z_owned_bytes_t` (unstable). + * Serializes data into a :c:type:`z_owned_bytes_t`. * * Parameters: * bytes: An uninitialized :c:type:`z_owned_bytes_t` to contain the serialized data. @@ -501,7 +499,7 @@ z_result_t ze_deserializer_deserialize_sequence_length(ze_deserializer_t *deseri z_result_t ze_serialize_buf(z_owned_bytes_t *bytes, const uint8_t *data, size_t len); /** - * Serializes a string into a :c:type:`z_owned_bytes_t` (unstable). + * Serializes a string into a :c:type:`z_owned_bytes_t`. * * Parameters: * bytes: An uninitialized :c:type:`z_owned_bytes_t` to contain the serialized string. @@ -513,7 +511,7 @@ z_result_t ze_serialize_buf(z_owned_bytes_t *bytes, const uint8_t *data, size_t z_result_t ze_serialize_string(z_owned_bytes_t *bytes, const z_loaned_string_t *s); /** - * Serializes a null-terminated string into a :c:type:`z_owned_bytes_t` (unstable). + * Serializes a null-terminated string into a :c:type:`z_owned_bytes_t`. * * Parameters: * bytes: An uninitialized :c:type:`z_owned_bytes_t` to contain the serialized string. @@ -525,7 +523,7 @@ z_result_t ze_serialize_string(z_owned_bytes_t *bytes, const z_loaned_string_t * z_result_t ze_serialize_str(z_owned_bytes_t *bytes, const char *value); /** - * Serializes a slice into a :c:type:`z_owned_bytes_t` (unstable). + * Serializes a slice into a :c:type:`z_owned_bytes_t`. * * Parameters: * bytes: An uninitialized :c:type:`z_owned_bytes_t` to contain the serialized slice. @@ -537,7 +535,7 @@ z_result_t ze_serialize_str(z_owned_bytes_t *bytes, const char *value); z_result_t ze_serialize_slice(z_owned_bytes_t *bytes, const z_loaned_slice_t *slice); /** - * Serializes a :c:type:`int8_t` into a :c:type:`z_owned_bytes_t` (unstable). + * Serializes a :c:type:`int8_t` into a :c:type:`z_owned_bytes_t` . * * Parameters: * bytes: An uninitialized :c:type:`z_owned_bytes_t` to contain the serialized int. @@ -549,7 +547,7 @@ z_result_t ze_serialize_slice(z_owned_bytes_t *bytes, const z_loaned_slice_t *sl z_result_t ze_serialize_int8(z_owned_bytes_t *bytes, int8_t val); /** - * Serializes a :c:type:`int16_t` into a :c:type:`z_owned_bytes_t` (unstable). + * Serializes a :c:type:`int16_t` into a :c:type:`z_owned_bytes_t`. * * Parameters: * bytes: An uninitialized :c:type:`z_owned_bytes_t` to contain the serialized int. @@ -561,7 +559,7 @@ z_result_t ze_serialize_int8(z_owned_bytes_t *bytes, int8_t val); z_result_t ze_serialize_int16(z_owned_bytes_t *bytes, int16_t val); /** - * Serializes a :c:type:`int32_t` into a :c:type:`z_owned_bytes_t` (unstable). + * Serializes a :c:type:`int32_t` into a :c:type:`z_owned_bytes_t`. * * Parameters: * bytes: An uninitialized :c:type:`z_owned_bytes_t` to contain the serialized int. @@ -573,7 +571,7 @@ z_result_t ze_serialize_int16(z_owned_bytes_t *bytes, int16_t val); z_result_t ze_serialize_int32(z_owned_bytes_t *bytes, int32_t val); /** - * Serializes a :c:type:`int64_t` into a :c:type:`z_owned_bytes_t` (unstable). + * Serializes a :c:type:`int64_t` into a :c:type:`z_owned_bytes_t`. * * Parameters: * bytes: An uninitialized :c:type:`z_owned_bytes_t` to contain the serialized int. @@ -585,7 +583,7 @@ z_result_t ze_serialize_int32(z_owned_bytes_t *bytes, int32_t val); z_result_t ze_serialize_int64(z_owned_bytes_t *bytes, int64_t val); /** - * Serializes a :c:type:`uint8_t` into a :c:type:`z_owned_bytes_t` (unstable). + * Serializes a :c:type:`uint8_t` into a :c:type:`z_owned_bytes_t`. * * Parameters: * bytes: An uninitialized :c:type:`z_owned_bytes_t` to contain the serialized int. @@ -597,7 +595,7 @@ z_result_t ze_serialize_int64(z_owned_bytes_t *bytes, int64_t val); z_result_t ze_serialize_uint8(z_owned_bytes_t *bytes, uint8_t val); /** - * Serializes a :c:type:`uint16_t` into a :c:type:`z_owned_bytes_t` (unstable). + * Serializes a :c:type:`uint16_t` into a :c:type:`z_owned_bytes_t`. * * Parameters: * bytes: An uninitialized :c:type:`z_owned_bytes_t` to contain the serialized int. @@ -609,7 +607,7 @@ z_result_t ze_serialize_uint8(z_owned_bytes_t *bytes, uint8_t val); z_result_t ze_serialize_uint16(z_owned_bytes_t *bytes, uint16_t val); /** - * Serializes a :c:type:`uint32_t` into a :c:type:`z_owned_bytes_t` (unstable). + * Serializes a :c:type:`uint32_t` into a :c:type:`z_owned_bytes_t`. * * Parameters: * bytes: An uninitialized :c:type:`z_owned_bytes_t` to contain the serialized int. @@ -621,7 +619,7 @@ z_result_t ze_serialize_uint16(z_owned_bytes_t *bytes, uint16_t val); z_result_t ze_serialize_uint32(z_owned_bytes_t *bytes, uint32_t val); /** - * Serializes a :c:type:`uint64_t` into a :c:type:`z_owned_bytes_t` (unstable). + * Serializes a :c:type:`uint64_t` into a :c:type:`z_owned_bytes_t`. * * Parameters: * bytes: An uninitialized :c:type:`z_owned_bytes_t` to contain the serialized int. @@ -633,7 +631,7 @@ z_result_t ze_serialize_uint32(z_owned_bytes_t *bytes, uint32_t val); z_result_t ze_serialize_uint64(z_owned_bytes_t *bytes, uint64_t val); /** - * Serializes a :c:type:`float` into a :c:type:`z_owned_bytes_t` (unstable). + * Serializes a :c:type:`float` into a :c:type:`z_owned_bytes_t`. * * Parameters: * bytes: An uninitialized :c:type:`z_owned_bytes_t` to contain the serialized int. @@ -645,7 +643,7 @@ z_result_t ze_serialize_uint64(z_owned_bytes_t *bytes, uint64_t val); z_result_t ze_serialize_float(z_owned_bytes_t *bytes, float val); /** - * Serializes a :c:type:`double` into a :c:type:`z_owned_bytes_t` (unstable). + * Serializes a :c:type:`double` into a :c:type:`z_owned_bytes_t`. * * Parameters: * bytes: An uninitialized :c:type:`z_owned_bytes_t` to contain the serialized int. @@ -657,7 +655,7 @@ z_result_t ze_serialize_float(z_owned_bytes_t *bytes, float val); z_result_t ze_serialize_double(z_owned_bytes_t *bytes, double val); /** - * Deserializes data into a :c:type:`z_owned_slice_t` (unstable). + * Deserializes data into a :c:type:`z_owned_slice_t`. * * Parameters: * bytes: Pointer to a :c:type:`z_loaned_bytes_t` to deserialize. @@ -669,7 +667,7 @@ z_result_t ze_serialize_double(z_owned_bytes_t *bytes, double val); z_result_t ze_deserialize_slice(const z_loaned_bytes_t *bytes, z_owned_slice_t *dst); /** - * Deserializes data into a :c:type:`z_owned_string_t` (unstable). + * Deserializes data into a :c:type:`z_owned_string_t`. * * Parameters: * bytes: Pointer to a :c:type:`z_loaned_bytes_t` to deserialize. @@ -681,7 +679,7 @@ z_result_t ze_deserialize_slice(const z_loaned_bytes_t *bytes, z_owned_slice_t * z_result_t ze_deserialize_string(const z_loaned_bytes_t *bytes, z_owned_string_t *str); /** - * Deserializes data into a `:c:type:`int8_t` (unstable). + * Deserializes data into a `:c:type:`int8_t`. * * Parameters: * bytes: Pointer to a :c:type:`z_loaned_bytes_t` to deserialize. @@ -693,7 +691,7 @@ z_result_t ze_deserialize_string(const z_loaned_bytes_t *bytes, z_owned_string_t z_result_t ze_deserialize_int8(const z_loaned_bytes_t *bytes, int8_t *dst); /** - * Deserializes data into a :c:type:`int16_t` (unstable). + * Deserializes data into a :c:type:`int16_t`. * * Parameters: * bytes: Pointer to a :c:type:`z_loaned_bytes_t` to deserialize. @@ -705,7 +703,7 @@ z_result_t ze_deserialize_int8(const z_loaned_bytes_t *bytes, int8_t *dst); z_result_t ze_deserialize_int16(const z_loaned_bytes_t *bytes, int16_t *dst); /** - * Deserializes data into a :c:type:`int32_t` (unstable). + * Deserializes data into a :c:type:`int32_t`. * * Parameters: * bytes: Pointer to a :c:type:`z_loaned_bytes_t` to deserialize. @@ -717,7 +715,7 @@ z_result_t ze_deserialize_int16(const z_loaned_bytes_t *bytes, int16_t *dst); z_result_t ze_deserialize_int32(const z_loaned_bytes_t *bytes, int32_t *dst); /** - * Deserializes data into a :c:type:`int64_t` (unstable). + * Deserializes data into a :c:type:`int64_t`. * * Parameters: * bytes: Pointer to a :c:type:`z_loaned_bytes_t` to deserialize. @@ -729,7 +727,7 @@ z_result_t ze_deserialize_int32(const z_loaned_bytes_t *bytes, int32_t *dst); z_result_t ze_deserialize_int64(const z_loaned_bytes_t *bytes, int64_t *dst); /** - * Deserializes data into a :c:type:`uint8_t` (unstable). + * Deserializes data into a :c:type:`uint8_t`. * * Parameters: * bytes: Pointer to a :c:type:`z_loaned_bytes_t` to deserialize. @@ -741,7 +739,7 @@ z_result_t ze_deserialize_int64(const z_loaned_bytes_t *bytes, int64_t *dst); z_result_t ze_deserialize_uint8(const z_loaned_bytes_t *bytes, uint8_t *dst); /** - * Deserializes data into a :c:type:`uint16_t` (unstable). + * Deserializes data into a :c:type:`uint16_t`. * * Parameters: * bytes: Pointer to a :c:type:`z_loaned_bytes_t` to deserialize. @@ -753,7 +751,7 @@ z_result_t ze_deserialize_uint8(const z_loaned_bytes_t *bytes, uint8_t *dst); z_result_t ze_deserialize_uint16(const z_loaned_bytes_t *bytes, uint16_t *dst); /** - * Deserializes data into a :c:type:`uint32_t` (unstable). + * Deserializes data into a :c:type:`uint32_t`. * * Parameters: * bytes: Pointer to a :c:type:`z_loaned_bytes_t` to deserialize. @@ -765,7 +763,7 @@ z_result_t ze_deserialize_uint16(const z_loaned_bytes_t *bytes, uint16_t *dst); z_result_t ze_deserialize_uint32(const z_loaned_bytes_t *bytes, uint32_t *dst); /** - * Deserializes data into a `:c:type:`uint64_t` (unstable). + * Deserializes data into a `:c:type:`uint64_t`. * * Parameters: * bytes: Pointer to a :c:type:`z_loaned_bytes_t` to deserialize. @@ -777,7 +775,7 @@ z_result_t ze_deserialize_uint32(const z_loaned_bytes_t *bytes, uint32_t *dst); z_result_t ze_deserialize_uint64(const z_loaned_bytes_t *bytes, uint64_t *dst); /** - * Deserializes data into a `:c:type:`float` (unstable). + * Deserializes data into a `:c:type:`float`. * * Parameters: * bytes: Pointer to a :c:type:`z_loaned_bytes_t` to deserialize. @@ -789,7 +787,7 @@ z_result_t ze_deserialize_uint64(const z_loaned_bytes_t *bytes, uint64_t *dst); z_result_t ze_deserialize_float(const z_loaned_bytes_t *bytes, float *dst); /** - * Deserializes data into a :c:type:`double` (unstable). + * Deserializes data into a :c:type:`double`. * * Parameters: * bytes: Pointer to a :c:type:`z_loaned_bytes_t` to deserialize. @@ -806,4 +804,3 @@ _Z_OWNED_FUNCTIONS_NO_COPY_DEF_PREFIX(ze, serializer) #endif #endif -#endif diff --git a/src/api/serialization.c b/src/api/serialization.c index 96af3370e..eae4040a8 100644 --- a/src/api/serialization.c +++ b/src/api/serialization.c @@ -10,14 +10,12 @@ // // Contributors: // ZettaScale Zenoh Team, - #include "zenoh-pico/api/serialization.h" #include #include "zenoh-pico/protocol/codec/core.h" -#if defined(Z_FEATURE_UNSTABLE_API) bool _ze_serializer_check(const _ze_serializer_t *serializer) { return _z_bytes_writer_check(&serializer->_writer); } _ze_serializer_t _ze_serializer_empty(void) { @@ -166,4 +164,3 @@ _Z_IMPLEMENT_ZBYTES_ARITHMETIC(double, double) bool ze_deserializer_is_done(const ze_deserializer_t *deserializer) { return _z_bytes_reader_remaining(&deserializer->_reader) == 0; } -#endif diff --git a/tests/z_api_bytes_test.c b/tests/z_api_bytes_test.c index 4b241d99b..28cec80bd 100644 --- a/tests/z_api_bytes_test.c +++ b/tests/z_api_bytes_test.c @@ -188,7 +188,7 @@ void test_slice(void) { z_bytes_from_static_buf(&payload5, data, 10); assert(z_check_and_drop_payload(&payload5, data, 10)); } -#if defined(Z_FEATURE_UNSTABLE_API) + #define TEST_ARITHMETIC(TYPE, EXT, VAL) \ { \ TYPE in = VAL, out; \ @@ -213,7 +213,7 @@ void test_arithmetic(void) { TEST_ARITHMETIC(float, float, 10.1f); TEST_ARITHMETIC(double, double, -105.001); } -#endif + bool check_slice(const z_loaned_bytes_t *b, const uint8_t *data, size_t len) { z_bytes_slice_iterator_t it = z_bytes_get_slice_iterator(b); uint8_t *data_out = (uint8_t *)malloc(len); @@ -257,7 +257,7 @@ void test_slices(void) { assert(check_slice(z_bytes_loan(&payload), data, 10)); z_bytes_drop(z_bytes_move(&payload)); } -#if defined(Z_FEATURE_UNSTABLE_API) + void test_serialize_simple(void) { z_owned_bytes_t b; @@ -313,7 +313,7 @@ void test_serialize_sequence(void) { assert(ze_deserializer_is_done(&deserializer)); z_bytes_drop(z_bytes_move(&b)); } -#endif + int main(void) { test_reader_seek(); test_reader_read(); @@ -321,9 +321,7 @@ int main(void) { test_slice(); test_append(); test_slices(); -#if defined(Z_FEATURE_UNSTABLE_API) test_arithmetic(); test_serialize_simple(); test_serialize_sequence(); -#endif } diff --git a/tests/z_api_null_drop_test.c b/tests/z_api_null_drop_test.c index 8168af075..43cd4db15 100644 --- a/tests/z_api_null_drop_test.c +++ b/tests/z_api_null_drop_test.c @@ -32,13 +32,13 @@ // make sure that v is null now #define TEST(name) \ { \ - z_owned_##name##_t v; \ + name v; \ memset(&v, -1, sizeof(v)); \ z_internal_null(&v); \ assert(!z_internal_check(v)); \ z_drop(z_move(v)); \ z_drop(z_move(v)); \ - z_owned_##name##_t v1; \ + name v1; \ z_internal_null(&v1); \ memset(&v, -1, sizeof(v)); \ z_take(&v1, z_move(v)); \ @@ -46,38 +46,40 @@ } int main(void) { - TEST(session) - TEST(keyexpr) - TEST(config) - TEST(hello) - TEST(closure_sample) - TEST(closure_query) - TEST(closure_reply) - TEST(closure_hello) - TEST(closure_zid) - TEST(string) - TEST(string_array) - TEST(sample) - TEST(slice) - TEST(bytes) - TEST(encoding) + TEST(z_owned_session_t) + TEST(z_owned_keyexpr_t) + TEST(z_owned_config_t) + TEST(z_owned_hello_t) + TEST(z_owned_closure_sample_t) + TEST(z_owned_closure_query_t) + TEST(z_owned_closure_reply_t) + TEST(z_owned_closure_hello_t) + TEST(z_owned_closure_zid_t) + TEST(z_owned_string_t) + TEST(z_owned_string_array_t) + TEST(z_owned_sample_t) + TEST(z_owned_slice_t) + TEST(z_owned_bytes_t) + TEST(z_owned_bytes_writer_t) + TEST(ze_owned_serializer_t) + TEST(z_owned_encoding_t) #if Z_FEATURE_PUBLICATION == 1 - TEST(publisher) + TEST(z_owned_publisher_t) #endif #if Z_FEATURE_SUBSCRIPTION == 1 - TEST(subscriber) + TEST(z_owned_subscriber_t) #endif #if Z_FEATURE_QUERYABLE == 1 - TEST(query) - TEST(queryable) + TEST(z_owned_query_t) + TEST(z_owned_queryable_t) #endif #if Z_FEATURE_QUERY == 1 - TEST(reply) + TEST(z_owned_reply_t) #endif // Double drop not supported for these types - // TEST(task) - // TEST(mutex) - // TEST(condvar) + // TEST(z_owned_task_t) + // TEST(z_owned_mutex_t) + // TEST(z_owned_condvar_t) return 0; }