Skip to content

Commit

Permalink
Remove default parameters from z_closure (#755)
Browse files Browse the repository at this point in the history
  • Loading branch information
sashacmc authored Oct 24, 2024
1 parent d1e63e4 commit df70c74
Show file tree
Hide file tree
Showing 25 changed files with 36 additions and 36 deletions.
2 changes: 1 addition & 1 deletion examples/espidf/z_get.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ void app_main() {
opts.payload = z_move(payload);
}
z_owned_closure_reply_t callback;
z_closure(&callback, reply_handler, reply_dropper);
z_closure(&callback, reply_handler, reply_dropper, NULL);
z_view_keyexpr_t ke;
z_view_keyexpr_from_str_unchecked(&ke, KEYEXPR);
if (z_get(z_loan(s), z_loan(ke), "", z_move(callback), &opts) < 0) {
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 @@ -169,7 +169,7 @@ void app_main() {
// Declare Zenoh queryable
printf("Declaring Queryable on %s...", KEYEXPR);
z_owned_closure_query_t callback;
z_closure(&callback, query_handler);
z_closure(&callback, query_handler, NULL, NULL);
z_owned_queryable_t qable;
z_view_keyexpr_t ke;
z_view_keyexpr_from_str_unchecked(&ke, KEYEXPR);
Expand Down
2 changes: 1 addition & 1 deletion examples/espidf/z_sub.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ void app_main() {

printf("Declaring Subscriber on '%s'...", KEYEXPR);
z_owned_closure_sample_t callback;
z_closure(&callback, data_handler);
z_closure(&callback, data_handler, NULL, NULL);
z_owned_subscriber_t sub;
z_view_keyexpr_t ke;
z_view_keyexpr_from_str_unchecked(&ke, KEYEXPR);
Expand Down
2 changes: 1 addition & 1 deletion examples/freertos_plus_tcp/z_get.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ void app_main(void) {
opts.payload = z_move(payload);
}
z_owned_closure_reply_t callback;
z_closure(&callback, reply_handler, reply_dropper);
z_closure(&callback, reply_handler, reply_dropper, NULL);
if (z_get(z_loan(s), z_loan(ke), "", z_move(callback), &opts) < 0) {
printf("Unable to send query.\n");
return;
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 @@ -85,7 +85,7 @@ void app_main(void) {

printf("Creating Queryable on '%s'...\n", KEYEXPR);
z_owned_closure_query_t callback;
z_closure(&callback, query_handler);
z_closure(&callback, query_handler, NULL, NULL);
z_owned_queryable_t qable;
if (z_declare_queryable(z_loan(s), &qable, z_loan(ke), z_move(callback), NULL) < 0) {
printf("Unable to create queryable.\n");
Expand Down
2 changes: 1 addition & 1 deletion examples/freertos_plus_tcp/z_sub.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void app_main(void) {
}

z_owned_closure_sample_t callback;
z_closure(&callback, data_handler);
z_closure(&callback, data_handler, NULL, NULL);
printf("Declaring Subscriber on '%s'...\n", KEYEXPR);
z_view_keyexpr_t ke;
z_view_keyexpr_from_str_unchecked(&ke, KEYEXPR);
Expand Down
2 changes: 1 addition & 1 deletion examples/freertos_plus_tcp/z_sub_st.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void app_main(void) {
}

z_owned_closure_sample_t callback;
z_closure(&callback, data_handler);
z_closure(&callback, data_handler, NULL, NULL);
printf("Declaring Subscriber on '%s'...\n", KEYEXPR);
z_view_keyexpr_t ke;
z_view_keyexpr_from_str_unchecked(&ke, KEYEXPR);
Expand Down
2 changes: 1 addition & 1 deletion examples/unix/c11/z_get.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ int main(int argc, char **argv) {
}

z_owned_closure_reply_t callback;
z_closure(&callback, reply_handler, reply_dropper);
z_closure(&callback, reply_handler, reply_dropper, NULL);
if (z_get(z_loan(s), z_loan(ke), "", z_move(callback), &opts) < 0) {
printf("Unable to send query.\n");
return -1;
Expand Down
2 changes: 1 addition & 1 deletion examples/unix/c11/z_get_attachment.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ int main(int argc, char **argv) {
opts.encoding = z_move(encoding);

z_owned_closure_reply_t callback;
z_closure(&callback, reply_handler, reply_dropper);
z_closure(&callback, reply_handler, reply_dropper, NULL);
if (z_get(z_loan(s), z_loan(ke), "", z_move(callback), &opts) < 0) {
printf("Unable to send query.\n");
return -1;
Expand Down
4 changes: 2 additions & 2 deletions examples/unix/c11/z_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,14 @@ int main(int argc, char **argv) {

printf("Routers IDs:\n");
z_owned_closure_zid_t callback;
z_closure(&callback, print_zid);
z_closure(&callback, print_zid, NULL, NULL);
z_info_routers_zid(z_loan(s), z_move(callback));

// `callback` has been `z_move`d just above, so it's safe to reuse the variable,
// we'll just have to make sure we `z_move` it again to avoid mem-leaks.
printf("Peers IDs:\n");
z_owned_closure_zid_t callback2;
z_closure(&callback2, print_zid);
z_closure(&callback2, print_zid, NULL, NULL);
z_info_peers_zid(z_loan(s), z_move(callback2));

z_drop(z_move(s));
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 @@ -146,7 +146,7 @@ int main(int argc, char **argv) {

printf("Creating Queryable on '%s'...\n", keyexpr);
z_owned_closure_query_t callback;
z_closure(&callback, query_handler);
z_closure(&callback, query_handler, NULL, NULL);
z_owned_queryable_t qable;
if (z_declare_queryable(z_loan(s), &qable, z_loan(ke), z_move(callback), NULL) < 0) {
printf("Unable to create queryable.\n");
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 @@ -186,7 +186,7 @@ int main(int argc, char **argv) {

printf("Creating Queryable on '%s'...\n", keyexpr);
z_owned_closure_query_t callback;
z_closure(&callback, query_handler);
z_closure(&callback, query_handler, NULL, NULL);
z_owned_queryable_t qable;
if (z_declare_queryable(z_loan(s), &qable, z_loan(ke), z_move(callback), NULL) < 0) {
printf("Unable to create queryable.\n");
Expand Down
2 changes: 1 addition & 1 deletion examples/unix/c11/z_sub.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ int main(int argc, char **argv) {
}

z_owned_closure_sample_t callback;
z_closure(&callback, data_handler);
z_closure(&callback, data_handler, NULL, NULL);
printf("Declaring Subscriber on '%s'...\n", keyexpr);
z_owned_subscriber_t sub;
z_view_keyexpr_t ke;
Expand Down
2 changes: 1 addition & 1 deletion examples/unix/c11/z_sub_attachment.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ int main(int argc, char **argv) {
}

z_owned_closure_sample_t callback;
z_closure(&callback, data_handler);
z_closure(&callback, data_handler, NULL, NULL);
printf("Declaring Subscriber on '%s'...\n", keyexpr);
z_owned_subscriber_t sub;
z_view_keyexpr_t ke;
Expand Down
2 changes: 1 addition & 1 deletion examples/unix/c11/z_sub_st.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ int main(int argc, char **argv) {
}

z_owned_closure_sample_t callback;
z_closure(&callback, data_handler);
z_closure(&callback, data_handler, NULL, NULL);
printf("Declaring Subscriber on '%s'...\n", keyexpr);
z_owned_subscriber_t sub;
z_view_keyexpr_t ke;
Expand Down
2 changes: 1 addition & 1 deletion examples/windows/z_get.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ int main(int argc, char **argv) {
opts.payload = z_move(payload);
}
z_owned_closure_reply_t callback;
z_closure(&callback, reply_handler, reply_dropper);
z_closure(&callback, reply_handler, reply_dropper, NULL);
if (z_get(z_loan(s), z_loan(ke), "", z_move(callback), &opts) < 0) {
printf("Unable to send query.\n");
return -1;
Expand Down
4 changes: 2 additions & 2 deletions examples/windows/z_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ int main(int argc, char **argv) {

printf("Routers IDs:\n");
z_owned_closure_zid_t callback;
z_closure(&callback, print_zid);
z_closure(&callback, print_zid, NULL, NULL);
z_info_routers_zid(z_loan(s), z_move(callback));

// `callback` has been `z_move`d just above, so it's safe to reuse the variable,
// we'll just have to make sure we `z_move` it again to avoid mem-leaks.
printf("Peers IDs:\n");
z_owned_closure_zid_t callback2;
z_closure(&callback2, print_zid);
z_closure(&callback2, print_zid, NULL, NULL);
z_info_peers_zid(z_loan(s), z_move(callback2));

z_drop(z_move(s));
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 @@ -79,7 +79,7 @@ int main(int argc, char **argv) {

printf("Creating Queryable on '%s'...\n", keyexpr);
z_owned_closure_query_t callback;
z_closure(&callback, query_handler);
z_closure(&callback, query_handler, NULL, NULL);
z_owned_queryable_t qable;
if (z_declare_queryable(z_loan(s), &qable, z_loan(ke), z_move(callback), NULL) < 0) {
printf("Unable to create queryable.\n");
Expand Down
2 changes: 1 addition & 1 deletion examples/windows/z_sub.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ int main(int argc, char **argv) {
}

z_owned_closure_sample_t callback;
z_closure(&callback, data_handler);
z_closure(&callback, data_handler, NULL, NULL);
printf("Declaring Subscriber on '%s'...\n", keyexpr);
z_owned_subscriber_t sub;
z_view_keyexpr_t ke;
Expand Down
2 changes: 1 addition & 1 deletion examples/windows/z_sub_st.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ int main(int argc, char **argv) {
}

z_owned_closure_sample_t callback;
z_closure(&callback, data_handler);
z_closure(&callback, data_handler, NULL, NULL);
printf("Declaring Subscriber on '%s'...\n", keyexpr);
z_owned_subscriber_t sub;
z_view_keyexpr_t ke;
Expand Down
2 changes: 1 addition & 1 deletion examples/zephyr/z_get.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ int main(int argc, char **argv) {
opts.payload = z_move(payload);
}
z_owned_closure_reply_t callback;
z_closure(&callback, reply_handler, reply_dropper);
z_closure(&callback, reply_handler, reply_dropper, NULL);
z_view_keyexpr_t ke;
z_view_keyexpr_from_str_unchecked(&ke, KEYEXPR);
if (z_get(z_loan(s), z_loan(ke), "", z_move(callback), &opts) < 0) {
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 @@ -82,7 +82,7 @@ int main(int argc, char **argv) {
// Declare Zenoh queryable
printf("Declaring Queryable on %s...", KEYEXPR);
z_owned_closure_query_t callback;
z_closure(&callback, query_handler);
z_closure(&callback, query_handler, NULL, NULL);
z_owned_queryable_t qable;
z_view_keyexpr_t ke;
z_view_keyexpr_from_str_unchecked(&ke, KEYEXPR);
Expand Down
2 changes: 1 addition & 1 deletion examples/zephyr/z_sub.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ int main(int argc, char **argv) {

printf("Declaring Subscriber on '%s'...", KEYEXPR);
z_owned_closure_sample_t callback;
z_closure(&callback, data_handler);
z_closure(&callback, data_handler, NULL, NULL);
z_view_keyexpr_t ke;
z_view_keyexpr_from_str_unchecked(&ke, KEYEXPR);
z_owned_subscriber_t sub;
Expand Down
20 changes: 10 additions & 10 deletions include/zenoh-pico/api/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -545,44 +545,44 @@ inline void z_call(const z_loaned_closure_zid_t &closure, const z_id_t *zid)
inline void z_closure(
z_owned_closure_hello_t* closure,
void (*call)(z_loaned_hello_t*, void*),
void (*drop)(void*) = NULL,
void *context = NULL) {
void (*drop)(void*),
void *context) {
closure->_val.context = context;
closure->_val.drop = drop;
closure->_val.call = call;
}
inline void z_closure(
z_owned_closure_query_t* closure,
void (*call)(z_loaned_query_t*, void*),
void (*drop)(void*) = NULL,
void *context = NULL) {
void (*drop)(void*),
void *context) {
closure->_val.context = context;
closure->_val.drop = drop;
closure->_val.call = call;
}
inline void z_closure(
z_owned_closure_reply_t* closure,
void (*call)(z_loaned_reply_t*, void*),
void (*drop)(void*) = NULL,
void *context = NULL) {
void (*drop)(void*),
void *context) {
closure->_val.context = context;
closure->_val.drop = drop;
closure->_val.call = call;
}
inline void z_closure(
z_owned_closure_sample_t* closure,
void (*call)(z_loaned_sample_t*, void*),
void (*drop)(void*) = NULL,
void *context = NULL) {
void (*drop)(void*),
void *context) {
closure->_val.context = context;
closure->_val.drop = drop;
closure->_val.call = call;
}
inline void z_closure(
z_owned_closure_zid_t* closure,
void (*call)(const z_id_t*, void*),
void (*drop)(void*) = NULL,
void *context = NULL) {
void (*drop)(void*),
void *context) {
closure->_val.context = context;
closure->_val.drop = drop;
closure->_val.call = call;
Expand Down
2 changes: 1 addition & 1 deletion tests/z_test_fragment_rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ int main(int argc, char **argv) {
}
// Declare subscriber
z_owned_closure_sample_t callback;
z_closure(&callback, data_handler);
z_closure(&callback, data_handler, NULL, NULL);
z_owned_subscriber_t sub;
z_view_keyexpr_t ke;
z_view_keyexpr_from_str(&ke, keyexpr);
Expand Down

0 comments on commit df70c74

Please sign in to comment.