Skip to content

Commit

Permalink
fix cpp-related macros and defines (#503)
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisBiryukov91 authored Jul 4, 2024
1 parent c67de6c commit 251da76
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 40 deletions.
77 changes: 37 additions & 40 deletions include/zenoh-pico/api/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,6 @@
// clang-format off

// z_loan definition

inline const z_loaned_keyexpr_t* z_loan(const z_owned_keyexpr_t& x) { return z_keyexpr_loan(&x); }
inline const z_loaned_keyexpr_t* z_loan(const z_view_keyexpr_t& x) { return z_view_keyexpr_loan(&x); }
inline const z_loaned_config_t* z_loan(const z_owned_config_t& x) { return z_config_loan(&x); }
Expand All @@ -333,6 +332,7 @@ inline const z_loaned_sample_t* z_loan(const z_owned_sample_t& x) { return z_sam
inline const z_loaned_query_t* z_loan(const z_owned_query_t& x) { return z_query_loan(&x); }
inline const z_loaned_slice_t* z_loan(const z_owned_slice_t& x) { return z_slice_loan(&x); }
inline const z_loaned_bytes_t* z_loan(const z_owned_bytes_t& x) { return z_bytes_loan(&x); }
inline const z_loaned_bytes_writer_t* z_loan(const z_owned_bytes_writer_t& x) { return z_bytes_writer_loan(&x); }
inline const z_loaned_encoding_t* z_loan(const z_owned_encoding_t& x) { return z_encoding_loan(&x); }
inline const z_loaned_task_t* z_loan(const z_owned_task_t& x) { return z_task_loan(&x); }
inline const z_loaned_mutex_t* z_loan(const z_owned_mutex_t& x) { return z_mutex_loan(&x); }
Expand All @@ -343,6 +343,13 @@ inline const z_loaned_closure_reply_t* z_loan(const z_owned_closure_reply_t& x)
inline const z_loaned_closure_query_t* z_loan(const z_owned_closure_query_t& x) { return z_closure_query_loan(&x); }
inline const z_loaned_closure_hello_t* z_loan(const z_owned_closure_hello_t& x) { return z_closure_hello_loan(&x); }
inline const z_loaned_closure_zid_t* z_loan(const z_owned_closure_zid_t& x) { return z_closure_zid_loan(&x); }
inline const z_loaned_fifo_handler_query_t* z_loan(const z_owned_fifo_handler_query_t& x) { return z_fifo_handler_query_loan(&x); };
inline const z_loaned_fifo_handler_reply_t* z_loan(const z_owned_fifo_handler_reply_t& x) { return z_fifo_handler_reply_loan(&x); };
inline const z_loaned_fifo_handler_sample_t* z_loan(const z_owned_fifo_handler_sample_t& x) { return z_fifo_handler_sample_loan(&x); };
inline const z_loaned_ring_handler_query_t* z_loan(const z_owned_ring_handler_query_t& x) { return z_ring_handler_query_loan(&x); };
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); };

// z_loan_mut definition
inline z_loaned_keyexpr_t* z_loan_mut(z_owned_keyexpr_t& x) { return z_keyexpr_loan_mut(&x); }
inline z_loaned_keyexpr_t* z_loan_mut(z_view_keyexpr_t& x) { return z_view_keyexpr_loan_mut(&x); }
Expand All @@ -359,6 +366,7 @@ inline z_loaned_sample_t* z_loan_mut(z_owned_sample_t& x) { return z_sample_loan
inline z_loaned_query_t* z_loan_mut(z_owned_query_t& x) { return z_query_loan_mut(&x); }
inline z_loaned_slice_t* z_loan_mut(z_owned_slice_t& x) { return z_slice_loan_mut(&x); }
inline z_loaned_bytes_t* z_loan_mut(z_owned_bytes_t& x) { return z_bytes_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); }
inline z_loaned_encoding_t* z_loan_mut(z_owned_encoding_t& x) { return z_encoding_loan_mut(&x); }
inline z_loaned_task_t* z_loan_mut(z_owned_task_t& x) { return z_task_loan_mut(&x); }
inline z_loaned_mutex_t* z_loan_mut(z_owned_mutex_t& x) { return z_mutex_loan_mut(&x); }
Expand All @@ -380,6 +388,7 @@ inline void z_drop(z_owned_string_array_t* v) { z_string_array_drop(v); }
inline void z_drop(z_owned_sample_t* v) { z_sample_drop(v); }
inline void z_drop(z_owned_query_t* v) { z_query_drop(v); }
inline void z_drop(z_owned_bytes_t* v) { z_bytes_drop(v); }
inline void z_drop(z_owned_bytes_writer_t* v) { z_bytes_writer_drop(v); }
inline void z_drop(z_owned_encoding_t* v) { z_encoding_drop(v); }
inline void z_drop(z_owned_mutex_t* v) { z_mutex_drop(v); }
inline void z_drop(z_owned_condvar_t* v) { z_condvar_drop(v); }
Expand All @@ -397,7 +406,6 @@ inline void z_drop(z_owned_ring_handler_reply_t* v) { z_ring_handler_reply_drop(
inline void z_drop(z_owned_fifo_handler_reply_t* v) { z_fifo_handler_reply_drop(v); }

// z_null definition

inline void z_null(z_owned_session_t* v) { z_session_null(v); }
inline void z_null(z_owned_publisher_t* v) { z_publisher_null(v); }
inline void z_null(z_owned_keyexpr_t* v) { z_keyexpr_null(v); }
Expand All @@ -410,14 +418,22 @@ inline void z_null(z_owned_reply_t* v) { z_reply_null(v); }
inline void z_null(z_owned_hello_t* v) { z_hello_null(v); }
inline void z_null(z_owned_string_t* v) { z_string_null(v); }
inline void z_null(z_owned_bytes_t* v) { z_bytes_null(v); }
inline void z_null(z_owned_bytes_writer_t* v) { z_bytes_writer_null(v); }
inline void z_null(z_owned_encoding_t* v) { z_encoding_null(v); }
inline void z_null(z_owned_reply_err_t* v) { z_reply_err_null(v); }
inline void z_null(z_owned_closure_sample_t* v) { z_closure_sample_null(v); }
inline void z_null(z_owned_closure_query_t* v) { z_closure_query_null(v); }
inline void z_null(z_owned_closure_reply_t* v) { z_closure_reply_null(v); }
inline void z_null(z_owned_closure_hello_t* v) { z_closure_hello_null(v); }
inline void z_null(z_owned_closure_zid_t* v) { z_closure_zid_null(v); }

inline void z_null(z_owned_ring_handler_query_t* v) { return z_ring_handler_query_null(v); };
inline void z_null(z_owned_ring_handler_reply_t* v) { return z_ring_handler_reply_null(v); };
inline void z_null(z_owned_ring_handler_sample_t* v) { return z_ring_handler_sample_null(v); };
inline void z_null(z_owned_fifo_handler_query_t* v) { return z_fifo_handler_query_null(v); };
inline void z_null(z_owned_fifo_handler_reply_t* v) { return z_fifo_handler_reply_null(v); };
inline void z_null(z_owned_fifo_handler_sample_t* v) { return z_fifo_handler_sample_null(v); };

// z_check definition
inline bool z_check(const z_owned_session_t& v) { return z_session_check(&v); }
inline bool z_check(const z_owned_publisher_t& v) { return z_publisher_check(&v); }
inline bool z_check(const z_owned_keyexpr_t& v) { return z_keyexpr_check(&v); }
Expand All @@ -430,11 +446,17 @@ inline bool z_check(const z_owned_hello_t& v) { return z_hello_check(&v); }
inline bool z_check(const z_owned_string_t& v) { return z_string_check(&v); }
inline bool z_check(const z_owned_sample_t& v) { return z_sample_check(&v); }
inline bool z_check(const z_owned_bytes_t& v) { return z_bytes_check(&v); }
inline bool z_check(const z_owned_bytes_writer_t& v) { return z_bytes_writer_check(&v); }
inline bool z_check(const z_owned_encoding_t& v) { return z_encoding_check(&v); }
inline bool z_check(const z_owned_reply_err_t& v) { return z_reply_err_check(&v); }
inline bool z_check(const z_owned_fifo_handler_query_t& v) { return z_fifo_handler_query_check(&v); };
inline bool z_check(const z_owned_fifo_handler_reply_t& v) { return z_fifo_handler_reply_check(&v); };
inline bool z_check(const z_owned_fifo_handler_sample_t& v) { return z_fifo_handler_sample_check(&v); };
inline bool z_check(const z_owned_ring_handler_query_t& v) { return z_ring_handler_query_check(&v); };
inline bool z_check(const z_owned_ring_handler_reply_t& v) { return z_ring_handler_reply_check(&v); };
inline bool z_check(const z_owned_ring_handler_sample_t& v) { return z_ring_handler_sample_check(&v); };

// z_call definition

inline void z_call(const z_loaned_closure_sample_t &closure, const z_loaned_sample_t *sample)
{ z_closure_sample_call(&closure, sample); }
inline void z_call(const z_loaned_closure_query_t &closure, const z_loaned_query_t *query)
Expand Down Expand Up @@ -534,6 +556,7 @@ inline bool z_recv(const z_loaned_ring_handler_sample_t* this_, z_owned_sample_t
// clang-format on

inline z_owned_bytes_t* z_move(z_owned_bytes_t& x) { return z_bytes_move(&x); };
inline z_owned_bytes_writer_t* z_move(z_owned_bytes_writer_t& x) { return z_bytes_writer_move(&x); };
inline z_owned_closure_hello_t* z_move(z_owned_closure_hello_t& closure) { return z_closure_hello_move(&closure); };
inline z_owned_closure_query_t* z_move(z_owned_closure_query_t& closure) { return z_closure_query_move(&closure); };
inline z_owned_closure_reply_t* z_move(z_owned_closure_reply_t& closure) { return z_closure_reply_move(&closure); };
Expand All @@ -554,6 +577,12 @@ inline z_owned_slice_t* z_move(z_owned_slice_t& x) { return z_slice_move(&x); };
inline z_owned_string_array_t* z_move(z_owned_string_array_t& x) { return z_string_array_move(&x); };
inline z_owned_string_t* z_move(z_owned_string_t& x) { return z_string_move(&x); };
inline z_owned_subscriber_t* z_move(z_owned_subscriber_t& x) { return z_subscriber_move(&x); };
inline z_owned_fifo_handler_query_t* z_move(z_owned_fifo_handler_query_t& x) { return (&x); };
inline z_owned_fifo_handler_reply_t* z_move(z_owned_fifo_handler_reply_t& x) { return (&x); };
inline z_owned_fifo_handler_sample_t* z_move(z_owned_fifo_handler_sample_t& x) { return (&x); };
inline z_owned_ring_handler_query_t* z_move(z_owned_ring_handler_query_t& x) { return (&x); };
inline z_owned_ring_handler_reply_t* z_move(z_owned_ring_handler_reply_t& x) { return (&x); };
inline z_owned_ring_handler_sample_t* z_move(z_owned_ring_handler_sample_t& x) { return (&x); };

template <class T>
struct z_loaned_to_owned_type_t {};
Expand All @@ -568,44 +597,12 @@ struct z_owned_to_loaned_type_t<z_owned_bytes_t> {
typedef z_loaned_bytes_t type;
};
template <>
struct z_loaned_to_owned_type_t<z_loaned_closure_hello_t> {
typedef z_owned_closure_hello_t type;
};
template <>
struct z_owned_to_loaned_type_t<z_owned_closure_hello_t> {
typedef z_loaned_closure_hello_t type;
struct z_loaned_to_owned_type_t<z_loaned_bytes_writer_t> {
typedef z_owned_bytes_writer_t type;
};
template <>
struct z_loaned_to_owned_type_t<z_loaned_closure_query_t> {
typedef z_owned_closure_query_t type;
};
template <>
struct z_owned_to_loaned_type_t<z_owned_closure_query_t> {
typedef z_loaned_closure_query_t type;
};
template <>
struct z_loaned_to_owned_type_t<z_loaned_closure_reply_t> {
typedef z_owned_closure_reply_t type;
};
template <>
struct z_owned_to_loaned_type_t<z_owned_closure_reply_t> {
typedef z_loaned_closure_reply_t type;
};
template <>
struct z_loaned_to_owned_type_t<z_loaned_closure_sample_t> {
typedef z_owned_closure_sample_t type;
};
template <>
struct z_owned_to_loaned_type_t<z_owned_closure_sample_t> {
typedef z_loaned_closure_sample_t type;
};
template <>
struct z_loaned_to_owned_type_t<z_loaned_closure_zid_t> {
typedef z_owned_closure_zid_t type;
};
template <>
struct z_owned_to_loaned_type_t<z_owned_closure_zid_t> {
typedef z_loaned_closure_zid_t type;
struct z_owned_to_loaned_type_t<z_owned_bytes_writer_t> {
typedef z_loaned_bytes_writer_t type;
};
template <>
struct z_loaned_to_owned_type_t<z_loaned_config_t> {
Expand Down
1 change: 1 addition & 0 deletions include/zenoh-pico/utils/result.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ typedef int8_t z_error_t;
/*------------------ Result Enums ------------------*/
typedef enum {
_Z_RES_OK = 0,
Z_OK = 0,
_Z_RES_CHANNEL_CLOSED = 1,

_Z_ERR_MESSAGE_DESERIALIZATION_FAILED = -119,
Expand Down

0 comments on commit 251da76

Please sign in to comment.