Skip to content

Commit

Permalink
Fixes for Zenoh-cpp compatibility (#434)
Browse files Browse the repository at this point in the history
* fix z_owned_closure_hello_t to accept z_loaned_hello_t

* remove unneeded NULLs

* fix example

* void unused arg

* renamed value -> reply_err;
updated macros for zenoh-cpp;

* format

* alignment test fixes

* fixes

* merge
  • Loading branch information
DenisBiryukov91 authored Jun 19, 2024
1 parent b60080b commit 0b38e0f
Show file tree
Hide file tree
Showing 17 changed files with 449 additions and 172 deletions.
15 changes: 9 additions & 6 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ TODO: owned type description
Represents the encoding of a payload, in a MIME-like format.

.. c:type:: z_owned_value_t
.. c:type:: z_owned_reply_err_t
Represents a Zenoh value.
Represents a Zenoh reply error value.

.. c:type:: z_owned_sample_t
Expand Down Expand Up @@ -182,9 +182,9 @@ TODO: loaned type description
Represents the encoding of a payload, in a MIME-like format.

.. c:type:: z_loaned_value_t
.. c:type:: z_loaned_reply_err_t
Represents a Zenoh value.
Represents a Zenoh reply error.

.. c:type:: z_loaned_sample_t
Expand Down Expand Up @@ -287,9 +287,11 @@ Primitives
.. autocfunction:: primitives.h::z_encoding_check
.. autocfunction:: primitives.h::z_encoding_drop
.. autocfunction:: primitives.h::z_encoding_loan
.. autocfunction:: primitives.h::z_encoding_loan_mut
.. autocfunction:: primitives.h::z_encoding_move
.. autocfunction:: primitives.h::z_encoding_null
.. autocfunction:: primitives.h::z_value_payload
.. autocfunction:: primitives.h::z_reply_err_payload
.. autocfunction:: primitives.h::z_reply_err_encoding
.. autocfunction:: primitives.h::z_slice_data
.. autocfunction:: primitives.h::z_slice_len
.. autocfunction:: primitives.h::z_bytes_deserialize_into_int8
Expand Down Expand Up @@ -326,7 +328,8 @@ Primitives
.. autocfunction:: primitives.h::z_query_consolidation_monotonic
.. autocfunction:: primitives.h::z_query_consolidation_none
.. autocfunction:: primitives.h::z_query_parameters
.. autocfunction:: primitives.h::z_query_value
.. autocfunction:: primitives.h::z_query_payload
.. autocfunction:: primitives.h::z_query_encoding
.. autocfunction:: primitives.h::z_query_attachment
.. autocfunction:: primitives.h::z_query_keyexpr
.. autocfunction:: primitives.h::z_closure_sample
Expand Down
2 changes: 1 addition & 1 deletion examples/arduino/z_queryable.ino
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void query_handler(const z_loaned_query_t *query, void *arg) {

// Process value
z_owned_string_t payload_string;
z_bytes_deserialize_into_string(z_value_payload(z_query_value(query)), &payload_string);
z_bytes_deserialize_into_string(z_query_payload(query), &payload_string);
if (z_string_len(z_string_loan(&payload_string)) > 1) {
Serial.print(" with value '");
Serial.print(z_string_data(z_string_loan(&payload_string)));
Expand Down
2 changes: 1 addition & 1 deletion examples/espidf/z_queryable.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ void query_handler(const z_loaned_query_t *query, void *ctx) {
z_loan(params)->val);
// Process value
z_owned_string_t payload_string;
z_bytes_deserialize_into_string(z_value_payload(z_query_value(query)), &payload_string);
z_bytes_deserialize_into_string(z_query_payload(query), &payload_string);
if (z_string_len(z_loan(payload_string)) > 1) {
printf(" with value '%s'\n", z_string_data(z_loan(payload_string)));
}
Expand Down
2 changes: 1 addition & 1 deletion examples/freertos_plus_tcp/z_queryable.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void query_handler(const z_loaned_query_t *query, void *ctx) {
z_loan(params)->val);
// Process value
z_owned_string_t payload_string;
z_bytes_deserialize_into_string(z_value_payload(z_query_value(query)), &payload_string);
z_bytes_deserialize_into_string(z_query_payload(query), &payload_string);
if (z_string_len(z_loan(payload_string)) > 1) {
printf(" with value '%s'\n", z_string_data(z_loan(payload_string)));
}
Expand Down
2 changes: 1 addition & 1 deletion examples/mbed/z_queryable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ void query_handler(const z_loaned_query_t *query, void *ctx) {
(int)z_view_string_loan(&pred)->len, z_view_string_loan(&pred)->val);
// Process value
z_owned_string_t payload_string;
z_bytes_deserialize_into_string(z_value_payload(z_query_value(query)), &payload_string);
z_bytes_deserialize_into_string(z_query_payload(query), &payload_string);
if (z_string_len(z_string_loan(&payload_string)) > 1) {
printf(" with value '%s'\n", z_string_data(z_string_loan(&payload_string)));
}
Expand Down
2 changes: 1 addition & 1 deletion examples/unix/c11/z_queryable.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ void query_handler(const z_loaned_query_t *query, void *ctx) {
z_loan(params)->val);
// Process value
z_owned_string_t payload_string;
z_bytes_deserialize_into_string(z_value_payload(z_query_value(query)), &payload_string);
z_bytes_deserialize_into_string(z_query_payload(query), &payload_string);
if (z_string_len(z_loan(payload_string)) > 1) {
printf(" with value '%s'\n", z_string_data(z_loan(payload_string)));
}
Expand Down
2 changes: 1 addition & 1 deletion examples/unix/c11/z_queryable_attachment.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ void query_handler(const z_loaned_query_t *query, void *ctx) {
z_loan(params)->val);
// Process value
z_owned_string_t payload_string;
z_bytes_deserialize_into_string(z_value_payload(z_query_value(query)), &payload_string);
z_bytes_deserialize_into_string(z_query_payload(query), &payload_string);
if (z_string_len(z_loan(payload_string)) > 1) {
printf(" with value '%s'\n", z_string_data(z_loan(payload_string)));
}
Expand Down
2 changes: 1 addition & 1 deletion examples/unix/c11/z_queryable_channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ int main(int argc, char **argv) {
(int)z_loan(params)->len, z_loan(params)->val);
// Process value
z_owned_string_t payload_string;
z_bytes_deserialize_into_string(z_value_payload(z_query_value(z_loan(query))), &payload_string);
z_bytes_deserialize_into_string(z_query_payload(z_loan(query)), &payload_string);
if (z_string_len(z_loan(payload_string)) > 1) {
printf(" with value '%s'\n", z_string_data(z_loan(payload_string)));
}
Expand Down
2 changes: 1 addition & 1 deletion examples/unix/c99/z_queryable.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ void query_handler(const z_loaned_query_t *query, void *ctx) {
(int)z_view_string_loan(&params)->len, z_view_string_loan(&params)->val);
// Process value
z_owned_string_t payload_string;
z_bytes_deserialize_into_string(z_value_payload(z_query_value(query)), &payload_string);
z_bytes_deserialize_into_string(z_query_payload(query), &payload_string);
if (z_string_len(z_string_loan(&payload_string)) > 1) {
printf(" with value '%s'\n", z_string_data(z_string_loan(&payload_string)));
}
Expand Down
2 changes: 1 addition & 1 deletion examples/windows/z_queryable.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ void query_handler(const z_loaned_query_t *query, void *ctx) {
z_loan(params)->val);
// Process value
z_owned_string_t payload_string;
z_bytes_deserialize_into_string(z_value_payload(z_query_value(query)), &payload_string);
z_bytes_deserialize_into_string(z_query_payload(query), &payload_string);
if (z_string_len(z_loan(payload_string)) > 1) {
printf(" with value '%s'\n", z_string_data(z_loan(payload_string)));
}
Expand Down
2 changes: 1 addition & 1 deletion examples/zephyr/z_queryable.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ void query_handler(const z_loaned_query_t *query, void *ctx) {
z_loan(params)->val);
// Process value
z_owned_string_t payload_string;
z_bytes_deserialize_into_string(z_value_payload(z_query_value(query)), &payload_string);
z_bytes_deserialize_into_string(z_query_payload(query), &payload_string);
if (z_string_len(z_loan(payload_string)) > 1) {
printf(" with value '%s'\n", z_string_data(z_loan(payload_string)));
}
Expand Down
Loading

0 comments on commit 0b38e0f

Please sign in to comment.