Skip to content

Commit

Permalink
fix: modularity compilation issues
Browse files Browse the repository at this point in the history
  • Loading branch information
jean-roland committed Jun 18, 2024
1 parent a2a14a3 commit 1face7f
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 14 deletions.
25 changes: 14 additions & 11 deletions src/api/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,17 +246,6 @@ void z_encoding_drop(z_owned_encoding_t *encoding) {

const z_loaned_encoding_t *z_encoding_loan(const z_owned_encoding_t *encoding) { return encoding->_val; }

// Convert a user owned encoding to an internal encoding, return default encoding if value invalid
static _z_encoding_t _z_encoding_from_owned(const z_owned_encoding_t *encoding) {
if (encoding == NULL) {
return _z_encoding_null();
}
if (encoding->_val == NULL) {
return _z_encoding_null();
}
return *encoding->_val;
}

const z_loaned_bytes_t *z_value_payload(const z_loaned_value_t *value) { return &value->payload; }

const uint8_t *z_slice_data(const z_loaned_slice_t *slice) { return slice->start; }
Expand Down Expand Up @@ -736,6 +725,8 @@ VIEW_FUNCTIONS_PTR(_z_string_vec_t, string_array)
OWNED_FUNCTIONS_PTR(_z_slice_t, slice, _z_slice_copy, _z_slice_free)
OWNED_FUNCTIONS_PTR(_z_bytes_t, bytes, _z_bytes_copy, _z_bytes_free)

#if Z_FEATURE_PUBLICATION == 1 || Z_FEATURE_QUERYABLE == 1 || Z_FEATURE_QUERY == 1
// Convert a user owned bytes payload to an internal bytes payload, returning an empty one if value invalid
static _z_bytes_t _z_bytes_from_owned_bytes(z_owned_bytes_t *bytes) {
_z_bytes_t b = _z_bytes_null();
if ((bytes != NULL) && (bytes->_val != NULL)) {
Expand All @@ -744,6 +735,18 @@ static _z_bytes_t _z_bytes_from_owned_bytes(z_owned_bytes_t *bytes) {
return b;
}

// Convert a user owned encoding to an internal encoding, return default encoding if value invalid
static _z_encoding_t _z_encoding_from_owned(const z_owned_encoding_t *encoding) {
if (encoding == NULL) {
return _z_encoding_null();
}
if (encoding->_val == NULL) {
return _z_encoding_null();
}
return *encoding->_val;
}
#endif

OWNED_FUNCTIONS_RC(sample)
OWNED_FUNCTIONS_RC(session)

Expand Down
5 changes: 4 additions & 1 deletion src/session/push.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,15 @@ int8_t _z_trigger_push(_z_session_t *zn, _z_n_msg_push_t *push) {
int8_t ret = _Z_RES_OK;

// TODO check body to know where to dispatch
#if Z_FEATURE_SUBSCRIPTION == 1
_z_slice_t payload = push->_body._is_put ? push->_body._body._put._payload : _z_slice_empty();
_z_encoding_t encoding = push->_body._is_put ? push->_body._body._put._encoding : _z_encoding_null();
size_t kind = push->_body._is_put ? Z_SAMPLE_KIND_PUT : Z_SAMPLE_KIND_DELETE;
#if Z_FEATURE_SUBSCRIPTION == 1
ret = _z_trigger_subscriptions(zn, push->_key, payload, encoding, kind, push->_timestamp, push->_qos,
push->_body._body._put._attachment);
#else
_ZP_UNUSED(zn);
_ZP_UNUSED(push);
#endif
return ret;
}
6 changes: 6 additions & 0 deletions src/session/reply.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ int8_t _z_trigger_reply_partial(_z_session_t *zn, _z_zint_t id, _z_keyexpr_t key
} else {
ret = _Z_ERR_GENERIC;
}
#else
_ZP_UNUSED(zn);
_ZP_UNUSED(id);
_ZP_UNUSED(key);
_ZP_UNUSED(reply);
#endif
return ret;
}
Expand All @@ -42,6 +47,7 @@ int8_t _z_trigger_reply_final(_z_session_t *zn, _z_n_msg_response_final_t *final
_z_zint_t id = final->_request_id;
_z_trigger_query_reply_final(zn, id);
#else
_ZP_UNUSED(zn);
_ZP_UNUSED(final);
#endif
return ret;
Expand Down
4 changes: 2 additions & 2 deletions src/session/rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ int8_t _z_handle_network_message(_z_session_t *zn, _z_zenoh_message_t *msg, uint
#endif
} break;
case _Z_REQUEST_PUT: {
_z_msg_put_t put = req._body._put;
#if Z_FEATURE_SUBSCRIPTION == 1
_z_msg_put_t put = req._body._put;
ret = _z_trigger_subscriptions(zn, req._key, put._payload, put._encoding, Z_SAMPLE_KIND_PUT,
put._commons._timestamp, req._ext_qos, put._attachment);
#endif
Expand All @@ -109,8 +109,8 @@ int8_t _z_handle_network_message(_z_session_t *zn, _z_zenoh_message_t *msg, uint
}
} break;
case _Z_REQUEST_DEL: {
_z_msg_del_t del = req._body._del;
#if Z_FEATURE_SUBSCRIPTION == 1
_z_msg_del_t del = req._body._del;
ret = _z_trigger_subscriptions(zn, req._key, _z_slice_empty(), _z_encoding_null(),
Z_SAMPLE_KIND_DELETE, del._commons._timestamp, req._ext_qos,
_z_bytes_null());
Expand Down
1 change: 1 addition & 0 deletions src/session/subscription.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ void _z_trigger_local_subscriptions(_z_session_t *zn, const _z_keyexpr_t keyexpr
_ZP_UNUSED(payload);
_ZP_UNUSED(payload_len);
_ZP_UNUSED(qos);
_ZP_UNUSED(att);
}

#endif // Z_FEATURE_SUBSCRIPTION == 1

0 comments on commit 1face7f

Please sign in to comment.