From 8c77c4cfa841dc02ea6a459babc1905894677d51 Mon Sep 17 00:00:00 2001 From: DenisBiryukov91 <155981813+DenisBiryukov91@users.noreply.github.com> Date: Fri, 20 Sep 2024 19:18:53 +0200 Subject: [PATCH] Encoding constants fix (#686) * Revert 'Move inline encoding functions to header (#685)' * temporary make encoding constants not inline to allow windows compilation --- include/zenoh-pico/api/encoding.h | 296 +++++++++++++----------------- src/api/encoding.c | 137 +++++++------- 2 files changed, 201 insertions(+), 232 deletions(-) diff --git a/include/zenoh-pico/api/encoding.h b/include/zenoh-pico/api/encoding.h index 9bed4c31b..0e46f4f46 100644 --- a/include/zenoh-pico/api/encoding.h +++ b/include/zenoh-pico/api/encoding.h @@ -41,74 +41,6 @@ extern "C" { */ #if Z_FEATURE_ENCODING_VALUES == 1 - -extern const z_owned_encoding_t ZP_ENCODING_ZENOH_BYTES; -extern const z_owned_encoding_t ZP_ENCODING_ZENOH_INT8; -extern const z_owned_encoding_t ZP_ENCODING_ZENOH_INT16; -extern const z_owned_encoding_t ZP_ENCODING_ZENOH_INT32; -extern const z_owned_encoding_t ZP_ENCODING_ZENOH_INT64; -extern const z_owned_encoding_t ZP_ENCODING_ZENOH_INT128; -extern const z_owned_encoding_t ZP_ENCODING_ZENOH_UINT8; -extern const z_owned_encoding_t ZP_ENCODING_ZENOH_UINT16; -extern const z_owned_encoding_t ZP_ENCODING_ZENOH_UINT32; -extern const z_owned_encoding_t ZP_ENCODING_ZENOH_UINT64; -extern const z_owned_encoding_t ZP_ENCODING_ZENOH_UINT128; -extern const z_owned_encoding_t ZP_ENCODING_ZENOH_FLOAT32; -extern const z_owned_encoding_t ZP_ENCODING_ZENOH_FLOAT64; -extern const z_owned_encoding_t ZP_ENCODING_ZENOH_BOOL; -extern const z_owned_encoding_t ZP_ENCODING_ZENOH_STRING; -extern const z_owned_encoding_t ZP_ENCODING_ZENOH_ERROR; -extern const z_owned_encoding_t ZP_ENCODING_APPLICATION_OCTET_STREAM; -extern const z_owned_encoding_t ZP_ENCODING_TEXT_PLAIN; -extern const z_owned_encoding_t ZP_ENCODING_APPLICATION_JSON; -extern const z_owned_encoding_t ZP_ENCODING_TEXT_JSON; -extern const z_owned_encoding_t ZP_ENCODING_APPLICATION_CDR; -extern const z_owned_encoding_t ZP_ENCODING_APPLICATION_CBOR; -extern const z_owned_encoding_t ZP_ENCODING_APPLICATION_YAML; -extern const z_owned_encoding_t ZP_ENCODING_TEXT_YAML; -extern const z_owned_encoding_t ZP_ENCODING_TEXT_JSON5; -extern const z_owned_encoding_t ZP_ENCODING_APPLICATION_PYTHON_SERIALIZED_OBJECT; -extern const z_owned_encoding_t ZP_ENCODING_APPLICATION_PROTOBUF; -extern const z_owned_encoding_t ZP_ENCODING_APPLICATION_JAVA_SERIALIZED_OBJECT; -extern const z_owned_encoding_t ZP_ENCODING_APPLICATION_OPENMETRICS_TEXT; -extern const z_owned_encoding_t ZP_ENCODING_IMAGE_PNG; -extern const z_owned_encoding_t ZP_ENCODING_IMAGE_JPEG; -extern const z_owned_encoding_t ZP_ENCODING_IMAGE_GIF; -extern const z_owned_encoding_t ZP_ENCODING_IMAGE_BMP; -extern const z_owned_encoding_t ZP_ENCODING_IMAGE_WEBP; -extern const z_owned_encoding_t ZP_ENCODING_APPLICATION_XML; -extern const z_owned_encoding_t ZP_ENCODING_APPLICATION_X_WWW_FORM_URLENCODED; -extern const z_owned_encoding_t ZP_ENCODING_TEXT_HTML; -extern const z_owned_encoding_t ZP_ENCODING_TEXT_XML; -extern const z_owned_encoding_t ZP_ENCODING_TEXT_CSS; -extern const z_owned_encoding_t ZP_ENCODING_TEXT_JAVASCRIPT; -extern const z_owned_encoding_t ZP_ENCODING_TEXT_MARKDOWN; -extern const z_owned_encoding_t ZP_ENCODING_TEXT_CSV; -extern const z_owned_encoding_t ZP_ENCODING_APPLICATION_SQL; -extern const z_owned_encoding_t ZP_ENCODING_APPLICATION_COAP_PAYLOAD; -extern const z_owned_encoding_t ZP_ENCODING_APPLICATION_JSON_PATCH_JSON; -extern const z_owned_encoding_t ZP_ENCODING_APPLICATION_JSON_SEQ; -extern const z_owned_encoding_t ZP_ENCODING_APPLICATION_JSONPATH; -extern const z_owned_encoding_t ZP_ENCODING_APPLICATION_JWT; -extern const z_owned_encoding_t ZP_ENCODING_APPLICATION_MP4; -extern const z_owned_encoding_t ZP_ENCODING_APPLICATION_SOAP_XML; -extern const z_owned_encoding_t ZP_ENCODING_APPLICATION_YANG; -extern const z_owned_encoding_t ZP_ENCODING_AUDIO_AAC; -extern const z_owned_encoding_t ZP_ENCODING_AUDIO_FLAC; -extern const z_owned_encoding_t ZP_ENCODING_AUDIO_MP4; -extern const z_owned_encoding_t ZP_ENCODING_AUDIO_OGG; -extern const z_owned_encoding_t ZP_ENCODING_AUDIO_VORBIS; -extern const z_owned_encoding_t ZP_ENCODING_VIDEO_H261; -extern const z_owned_encoding_t ZP_ENCODING_VIDEO_H263; -extern const z_owned_encoding_t ZP_ENCODING_VIDEO_H264; -extern const z_owned_encoding_t ZP_ENCODING_VIDEO_H265; -extern const z_owned_encoding_t ZP_ENCODING_VIDEO_H266; -extern const z_owned_encoding_t ZP_ENCODING_VIDEO_MP4; -extern const z_owned_encoding_t ZP_ENCODING_VIDEO_OGG; -extern const z_owned_encoding_t ZP_ENCODING_VIDEO_RAW; -extern const z_owned_encoding_t ZP_ENCODING_VIDEO_VP8; -extern const z_owned_encoding_t ZP_ENCODING_VIDEO_VP9; - // - Below are Primitives types, supported in all Zenoh bindings /** * Just some bytes. @@ -117,7 +49,8 @@ extern const z_owned_encoding_t ZP_ENCODING_VIDEO_VP9; * * Usually used for types: `uint8_t[]`. */ -static inline const z_loaned_encoding_t *z_encoding_zenoh_bytes(void) { return &ZP_ENCODING_ZENOH_BYTES._val; } +const z_loaned_encoding_t *z_encoding_zenoh_bytes(void); +extern const z_owned_encoding_t ZP_ENCODING_ZENOH_BYTES; /** * A VLE-encoded signed little-endian 8bit integer. Binary representation uses two's complement. @@ -125,7 +58,8 @@ static inline const z_loaned_encoding_t *z_encoding_zenoh_bytes(void) { return & * * Usually used for types: `int8_t`. */ -static inline const z_loaned_encoding_t *z_encoding_zenoh_int8(void) { return &ZP_ENCODING_ZENOH_INT8._val; } +const z_loaned_encoding_t *z_encoding_zenoh_int8(void); +extern const z_owned_encoding_t ZP_ENCODING_ZENOH_INT8; /** * A VLE-encoded signed little-endian 16bit integer. Binary representation uses two's complement. @@ -133,7 +67,8 @@ static inline const z_loaned_encoding_t *z_encoding_zenoh_int8(void) { return &Z * * Usually used for types: `int16_t`. */ -static inline const z_loaned_encoding_t *z_encoding_zenoh_int16(void) { return &ZP_ENCODING_ZENOH_INT16._val; } +const z_loaned_encoding_t *z_encoding_zenoh_int16(void); +extern const z_owned_encoding_t ZP_ENCODING_ZENOH_INT16; /** * A VLE-encoded signed little-endian 32bit integer. Binary representation uses two's complement. @@ -141,7 +76,8 @@ static inline const z_loaned_encoding_t *z_encoding_zenoh_int16(void) { return & * * Usually used for types: `int32_t`. */ -static inline const z_loaned_encoding_t *z_encoding_zenoh_int32(void) { return &ZP_ENCODING_ZENOH_INT32._val; } +const z_loaned_encoding_t *z_encoding_zenoh_int32(void); +extern const z_owned_encoding_t ZP_ENCODING_ZENOH_INT32; /** * A VLE-encoded signed little-endian 64bit integer. Binary representation uses two's complement. @@ -149,13 +85,15 @@ static inline const z_loaned_encoding_t *z_encoding_zenoh_int32(void) { return & * * Usually used for types: `int64_t`. */ -static inline const z_loaned_encoding_t *z_encoding_zenoh_int64(void) { return &ZP_ENCODING_ZENOH_INT64._val; } +const z_loaned_encoding_t *z_encoding_zenoh_int64(void); +extern const z_owned_encoding_t ZP_ENCODING_ZENOH_INT64; /** * A VLE-encoded signed little-endian 128bit integer. Binary representation uses two's complement. * Constant alias for string: `"zenoh/int128"`. */ -static inline const z_loaned_encoding_t *z_encoding_zenoh_int128(void) { return &ZP_ENCODING_ZENOH_INT128._val; } +const z_loaned_encoding_t *z_encoding_zenoh_int128(void); +extern const z_owned_encoding_t ZP_ENCODING_ZENOH_INT128; /** * A VLE-encoded unsigned little-endian 8bit integer. @@ -163,7 +101,8 @@ static inline const z_loaned_encoding_t *z_encoding_zenoh_int128(void) { return * * Usually used for types: `uint8_t`. */ -static inline const z_loaned_encoding_t *z_encoding_zenoh_uint8(void) { return &ZP_ENCODING_ZENOH_UINT8._val; } +const z_loaned_encoding_t *z_encoding_zenoh_uint8(void); +extern const z_owned_encoding_t ZP_ENCODING_ZENOH_UINT8; /** * A VLE-encoded unsigned little-endian 16bit integer. @@ -171,7 +110,8 @@ static inline const z_loaned_encoding_t *z_encoding_zenoh_uint8(void) { return & * * Usually used for types: `uint16_t`. */ -static inline const z_loaned_encoding_t *z_encoding_zenoh_uint16(void) { return &ZP_ENCODING_ZENOH_UINT16._val; } +const z_loaned_encoding_t *z_encoding_zenoh_uint16(void); +extern const z_owned_encoding_t ZP_ENCODING_ZENOH_UINT16; /** * A VLE-encoded unsigned little-endian 32bit integer. @@ -179,7 +119,8 @@ static inline const z_loaned_encoding_t *z_encoding_zenoh_uint16(void) { return * * Usually used for types: `uint32_t`. */ -static inline const z_loaned_encoding_t *z_encoding_zenoh_uint32(void) { return &ZP_ENCODING_ZENOH_UINT32._val; } +const z_loaned_encoding_t *z_encoding_zenoh_uint32(void); +extern const z_owned_encoding_t ZP_ENCODING_ZENOH_UINT32; /** * A VLE-encoded unsigned little-endian 64bit integer. @@ -187,13 +128,15 @@ static inline const z_loaned_encoding_t *z_encoding_zenoh_uint32(void) { return * * Usually used for types: `uint64_t`. */ -static inline const z_loaned_encoding_t *z_encoding_zenoh_uint64(void) { return &ZP_ENCODING_ZENOH_UINT64._val; } +const z_loaned_encoding_t *z_encoding_zenoh_uint64(void); +extern const z_owned_encoding_t ZP_ENCODING_ZENOH_UINT64; /** * A VLE-encoded unsigned little-endian 128bit integer. * Constant alias for string: `"zenoh/uint128"`. */ -static inline const z_loaned_encoding_t *z_encoding_zenoh_uint128(void) { return &ZP_ENCODING_ZENOH_UINT128._val; } +const z_loaned_encoding_t *z_encoding_zenoh_uint128(void); +extern const z_owned_encoding_t ZP_ENCODING_ZENOH_UINT128; /** * A VLE-encoded 32bit float. Binary representation uses *IEEE 754-2008* *binary32*. @@ -201,7 +144,8 @@ static inline const z_loaned_encoding_t *z_encoding_zenoh_uint128(void) { return * * Usually used for types: `float`. */ -static inline const z_loaned_encoding_t *z_encoding_zenoh_float32(void) { return &ZP_ENCODING_ZENOH_FLOAT32._val; } +const z_loaned_encoding_t *z_encoding_zenoh_float32(void); +extern const z_owned_encoding_t ZP_ENCODING_ZENOH_FLOAT32; /** * A VLE-encoded 64bit float. Binary representation uses *IEEE 754-2008* *binary64*. @@ -209,7 +153,8 @@ static inline const z_loaned_encoding_t *z_encoding_zenoh_float32(void) { return * * Usually used for types: `double`. */ -static inline const z_loaned_encoding_t *z_encoding_zenoh_float64(void) { return &ZP_ENCODING_ZENOH_FLOAT64._val; } +const z_loaned_encoding_t *z_encoding_zenoh_float64(void); +extern const z_owned_encoding_t ZP_ENCODING_ZENOH_FLOAT64; /** * A boolean. `0` is `false`, `1` is `true`. Other values are invalid. @@ -217,7 +162,8 @@ static inline const z_loaned_encoding_t *z_encoding_zenoh_float64(void) { return * * Usually used for types: `bool`. */ -static inline const z_loaned_encoding_t *z_encoding_zenoh_bool(void) { return &ZP_ENCODING_ZENOH_BOOL._val; } +const z_loaned_encoding_t *z_encoding_zenoh_bool(void); +extern const z_owned_encoding_t ZP_ENCODING_ZENOH_BOOL; /** * A UTF-8 string. @@ -225,7 +171,8 @@ static inline const z_loaned_encoding_t *z_encoding_zenoh_bool(void) { return &Z * * Usually used for types: `char[]`. */ -static inline const z_loaned_encoding_t *z_encoding_zenoh_string(void) { return &ZP_ENCODING_ZENOH_STRING._val; } +const z_loaned_encoding_t *z_encoding_zenoh_string(void); +extern const z_owned_encoding_t ZP_ENCODING_ZENOH_STRING; /** * A zenoh error. @@ -233,338 +180,359 @@ static inline const z_loaned_encoding_t *z_encoding_zenoh_string(void) { return * * Usually used for types: `z_reply_err_t`. */ -static inline const z_loaned_encoding_t *z_encoding_zenoh_error(void) { return &ZP_ENCODING_ZENOH_ERROR._val; } +const z_loaned_encoding_t *z_encoding_zenoh_error(void); +extern const z_owned_encoding_t ZP_ENCODING_ZENOH_ERROR; /** * An application-specific stream of bytes. * Constant alias for string: `"application/octet-stream"`. */ -static inline const z_loaned_encoding_t *z_encoding_application_octet_stream(void) { - return &ZP_ENCODING_APPLICATION_OCTET_STREAM._val; -} +const z_loaned_encoding_t *z_encoding_application_octet_stream(void); +extern const z_owned_encoding_t ENCODING_APPLICATION_OCTET_STREAM; /** * A textual file. * Constant alias for string: `"text/plain"`. */ -static inline const z_loaned_encoding_t *z_encoding_text_plain(void) { return &ZP_ENCODING_TEXT_PLAIN._val; } +const z_loaned_encoding_t *z_encoding_text_plain(void); +extern const z_owned_encoding_t ENCODING_TEXT_PLAIN; /** * JSON data intended to be consumed by an application. * Constant alias for string: `"application/json"`. */ -static inline const z_loaned_encoding_t *z_encoding_application_json(void) { - return &ZP_ENCODING_APPLICATION_JSON._val; -} +const z_loaned_encoding_t *z_encoding_application_json(void); +extern const z_owned_encoding_t ENCODING_APPLICATION_JSON; /** * JSON data intended to be human readable. * Constant alias for string: `"text/json"`. */ -static inline const z_loaned_encoding_t *z_encoding_text_json(void) { return &ZP_ENCODING_TEXT_JSON._val; } +const z_loaned_encoding_t *z_encoding_text_json(void); +extern const z_owned_encoding_t ENCODING_TEXT_JSON; /** * A Common Data Representation (CDR)-encoded data. * Constant alias for string: `"application/cdr"`. */ -static inline const z_loaned_encoding_t *z_encoding_application_cdr(void) { return &ZP_ENCODING_APPLICATION_CDR._val; } +const z_loaned_encoding_t *z_encoding_application_cdr(void); +extern const z_owned_encoding_t ENCODING_APPLICATION_CDR; /** * A Concise Binary Object Representation (CBOR)-encoded data. * Constant alias for string: `"application/cbor"`. */ -static inline const z_loaned_encoding_t *z_encoding_application_cbor(void) { - return &ZP_ENCODING_APPLICATION_CBOR._val; -} +const z_loaned_encoding_t *z_encoding_application_cbor(void); +extern const z_owned_encoding_t ENCODING_APPLICATION_CBOR; /** * YAML data intended to be consumed by an application. * Constant alias for string: `"application/yaml"`. */ -static inline const z_loaned_encoding_t *z_encoding_application_yaml(void) { - return &ZP_ENCODING_APPLICATION_YAML._val; -} +const z_loaned_encoding_t *z_encoding_application_yaml(void); +extern const z_owned_encoding_t ENCODING_APPLICATION_YAML; /** * YAML data intended to be human readable. * Constant alias for string: `"text/yaml"`. */ -static inline const z_loaned_encoding_t *z_encoding_text_yaml(void) { return &ZP_ENCODING_TEXT_YAML._val; } +const z_loaned_encoding_t *z_encoding_text_yaml(void); +extern const z_owned_encoding_t ENCODING_TEXT_YAML; /** * JSON5 encoded data that are human readable. * Constant alias for string: `"text/json5"`. */ -static inline const z_loaned_encoding_t *z_encoding_text_json5(void) { return &ZP_ENCODING_TEXT_JSON5._val; } +const z_loaned_encoding_t *z_encoding_text_json5(void); +extern const z_owned_encoding_t ENCODING_TEXT_JSON5; /** * A Python object serialized using [pickle](https://docs.python.org/3/library/pickle.html). * Constant alias for string: `"application/python-serialized-object"`. */ -static inline const z_loaned_encoding_t *z_encoding_application_python_serialized_object(void) { - return &ZP_ENCODING_APPLICATION_PYTHON_SERIALIZED_OBJECT._val; -} +const z_loaned_encoding_t *z_encoding_application_python_serialized_object(void); +extern const z_owned_encoding_t ENCODING_APPLICATION_PYTHON_SERIALIZED_OBJECT; /** * An application-specific protobuf-encoded data. * Constant alias for string: `"application/protobuf"`. */ -static inline const z_loaned_encoding_t *z_encoding_application_protobuf(void) { - return &ZP_ENCODING_APPLICATION_PROTOBUF._val; -} +const z_loaned_encoding_t *z_encoding_application_protobuf(void); +extern const z_owned_encoding_t ENCODING_APPLICATION_PROTOBUF; /** * A Java serialized object. * Constant alias for string: `"application/java-serialized-object"`. */ -static inline const z_loaned_encoding_t *z_encoding_application_java_serialized_object(void) { - return &ZP_ENCODING_APPLICATION_JAVA_SERIALIZED_OBJECT._val; -} +const z_loaned_encoding_t *z_encoding_application_java_serialized_object(void); +extern const z_owned_encoding_t ENCODING_APPLICATION_JAVA_SERIALIZED_OBJECT; /** * An [openmetrics](https://github.com/OpenObservability/OpenMetrics) data, commonly used by * [Prometheus](https://prometheus.io/). * Constant alias for string: `"application/openmetrics-text"`. */ -static inline const z_loaned_encoding_t *z_encoding_application_openmetrics_text(void) { - return &ZP_ENCODING_APPLICATION_OPENMETRICS_TEXT._val; -} +const z_loaned_encoding_t *z_encoding_application_openmetrics_text(void); +extern const z_owned_encoding_t ENCODING_APPLICATION_OPENMETRICS_TEXT; /** * A Portable Network Graphics (PNG) image. * Constant alias for string: `"image/png"`. */ -static inline const z_loaned_encoding_t *z_encoding_image_png(void) { return &ZP_ENCODING_IMAGE_PNG._val; } +const z_loaned_encoding_t *z_encoding_image_png(void); +extern const z_owned_encoding_t ENCODING_IMAGE_PNG; /** * A Joint Photographic Experts Group (JPEG) image. * Constant alias for string: `"image/jpeg"`. */ -static inline const z_loaned_encoding_t *z_encoding_image_jpeg(void) { return &ZP_ENCODING_IMAGE_JPEG._val; } +const z_loaned_encoding_t *z_encoding_image_jpeg(void); +extern const z_owned_encoding_t ENCODING_IMAGE_JPEG; /** * A Graphics Interchange Format (GIF) image. * Constant alias for string: `"image/gif"`. */ -static inline const z_loaned_encoding_t *z_encoding_image_gif(void) { return &ZP_ENCODING_IMAGE_GIF._val; } +const z_loaned_encoding_t *z_encoding_image_gif(void); +extern const z_owned_encoding_t ENCODING_IMAGE_GIF; /** * A BitMap (BMP) image. * Constant alias for string: `"image/bmp"`. */ -static inline const z_loaned_encoding_t *z_encoding_image_bmp(void) { return &ZP_ENCODING_IMAGE_BMP._val; } +const z_loaned_encoding_t *z_encoding_image_bmp(void); +extern const z_owned_encoding_t ENCODING_IMAGE_BMP; /** * A Web Portable (WebP) image. * Constant alias for string: `"image/webp"`. */ -static inline const z_loaned_encoding_t *z_encoding_image_webp(void) { return &ZP_ENCODING_IMAGE_WEBP._val; } +const z_loaned_encoding_t *z_encoding_image_webp(void); +extern const z_owned_encoding_t ENCODING_IMAGE_WEBP; /** * An XML file intended to be consumed by an application. * Constant alias for string: `"application/xml"`. */ -static inline const z_loaned_encoding_t *z_encoding_application_xml(void) { return &ZP_ENCODING_APPLICATION_XML._val; } +const z_loaned_encoding_t *z_encoding_application_xml(void); +extern const z_owned_encoding_t ENCODING_APPLICATION_XML; /** * An encoded list of tuples, each consisting of a name and a value. * Constant alias for string: `"application/x-www-form-urlencoded"`. */ -static inline const z_loaned_encoding_t *z_encoding_application_x_www_form_urlencoded(void) { - return &ZP_ENCODING_APPLICATION_X_WWW_FORM_URLENCODED._val; -} +const z_loaned_encoding_t *z_encoding_application_x_www_form_urlencoded(void); +extern const z_owned_encoding_t ENCODING_APPLICATION_X_WWW_FORM_URLENCODED; /** * An HTML file. * Constant alias for string: `"text/html"`. */ -static inline const z_loaned_encoding_t *z_encoding_text_html(void) { return &ZP_ENCODING_TEXT_HTML._val; } +const z_loaned_encoding_t *z_encoding_text_html(void); +extern const z_owned_encoding_t ENCODING_TEXT_HTML; /** * An XML file that is human-readable. * Constant alias for string: `"text/xml"`. */ -static inline const z_loaned_encoding_t *z_encoding_text_xml(void) { return &ZP_ENCODING_TEXT_XML._val; } +const z_loaned_encoding_t *z_encoding_text_xml(void); +extern const z_owned_encoding_t ENCODING_TEXT_XML; /** * A CSS file. * Constant alias for string: `"text/css"`. */ -static inline const z_loaned_encoding_t *z_encoding_text_css(void) { return &ZP_ENCODING_TEXT_CSS._val; } +const z_loaned_encoding_t *z_encoding_text_css(void); +extern const z_owned_encoding_t ENCODING_TEXT_CSS; /** * A JavaScript file. * Constant alias for string: `"text/javascript"`. */ -static inline const z_loaned_encoding_t *z_encoding_text_javascript(void) { return &ZP_ENCODING_TEXT_JAVASCRIPT._val; } +const z_loaned_encoding_t *z_encoding_text_javascript(void); +extern const z_owned_encoding_t ENCODING_TEXT_JAVASCRIPT; /** * A Markdown file. * Constant alias for string: `"text/markdown"`. */ -static inline const z_loaned_encoding_t *z_encoding_text_markdown(void) { return &ZP_ENCODING_TEXT_MARKDOWN._val; } +const z_loaned_encoding_t *z_encoding_text_markdown(void); +extern const z_owned_encoding_t ENCODING_TEXT_MARKDOWN; /** * A CSV file. * Constant alias for string: `"text/csv"`. */ -static inline const z_loaned_encoding_t *z_encoding_text_csv(void) { return &ZP_ENCODING_TEXT_CSV._val; } +const z_loaned_encoding_t *z_encoding_text_csv(void); +extern const z_owned_encoding_t ENCODING_TEXT_CSV; /** * An application-specific SQL query. * Constant alias for string: `"application/sql"`. */ -static inline const z_loaned_encoding_t *z_encoding_application_sql(void) { return &ZP_ENCODING_APPLICATION_SQL._val; } +const z_loaned_encoding_t *z_encoding_application_sql(void); +extern const z_owned_encoding_t ENCODING_APPLICATION_SQL; /** * Constrained Application Protocol (CoAP) data intended for CoAP-to-HTTP and HTTP-to-CoAP proxies. * Constant alias for string: `"application/coap-payload"`. */ -static inline const z_loaned_encoding_t *z_encoding_application_coap_payload(void) { - return &ZP_ENCODING_APPLICATION_COAP_PAYLOAD._val; -} +const z_loaned_encoding_t *z_encoding_application_coap_payload(void); +extern const z_owned_encoding_t ENCODING_APPLICATION_COAP_PAYLOAD; /** * Defines a JSON document structure for expressing a sequence of operations to apply to a JSON document. * Constant alias for string: `"application/json-patch+json"`. */ -static inline const z_loaned_encoding_t *z_encoding_application_json_patch_json(void) { - return &ZP_ENCODING_APPLICATION_JSON_PATCH_JSON._val; -} +const z_loaned_encoding_t *z_encoding_application_json_patch_json(void); +extern const z_owned_encoding_t ENCODING_APPLICATION_JSON_PATCH_JSON; /** * A JSON text sequence consists of any number of JSON texts, all encoded in UTF-8. * Constant alias for string: `"application/json-seq"`. */ -static inline const z_loaned_encoding_t *z_encoding_application_json_seq(void) { - return &ZP_ENCODING_APPLICATION_JSON_SEQ._val; -} +const z_loaned_encoding_t *z_encoding_application_json_seq(void); +extern const z_owned_encoding_t ENCODING_APPLICATION_JSON_SEQ; /** * A JSONPath defines a string syntax for selecting and extracting JSON values from within a given JSON value. * Constant alias for string: `"application/jsonpath"`. */ -static inline const z_loaned_encoding_t *z_encoding_application_jsonpath(void) { - return &ZP_ENCODING_APPLICATION_JSONPATH._val; -} +const z_loaned_encoding_t *z_encoding_application_jsonpath(void); +extern const z_owned_encoding_t ENCODING_APPLICATION_JSONPATH; /** * A JSON Web Token (JWT). * Constant alias for string: `"application/jwt"`. */ -static inline const z_loaned_encoding_t *z_encoding_application_jwt(void) { return &ZP_ENCODING_APPLICATION_JWT._val; } +const z_loaned_encoding_t *z_encoding_application_jwt(void); +extern const z_owned_encoding_t ENCODING_APPLICATION_JWT; /** * An application-specific MPEG-4 encoded data, either audio or video. * Constant alias for string: `"application/mp4"`. */ -static inline const z_loaned_encoding_t *z_encoding_application_mp4(void) { return &ZP_ENCODING_APPLICATION_MP4._val; } +const z_loaned_encoding_t *z_encoding_application_mp4(void); +extern const z_owned_encoding_t ENCODING_APPLICATION_MP4; /** * A SOAP 1.2 message serialized as XML 1.0. * Constant alias for string: `"application/soap+xml"`. */ -static inline const z_loaned_encoding_t *z_encoding_application_soap_xml(void) { - return &ZP_ENCODING_APPLICATION_SOAP_XML._val; -} +const z_loaned_encoding_t *z_encoding_application_soap_xml(void); +extern const z_owned_encoding_t ENCODING_APPLICATION_SOAP_XML; /** * A YANG-encoded data commonly used by the Network Configuration Protocol (NETCONF). * Constant alias for string: `"application/yang"`. */ -static inline const z_loaned_encoding_t *z_encoding_application_yang(void) { - return &ZP_ENCODING_APPLICATION_YANG._val; -} +const z_loaned_encoding_t *z_encoding_application_yang(void); +extern const z_owned_encoding_t ENCODING_APPLICATION_YANG; /** * A MPEG-4 Advanced Audio Coding (AAC) media. * Constant alias for string: `"audio/aac"`. */ -static inline const z_loaned_encoding_t *z_encoding_audio_aac(void) { return &ZP_ENCODING_AUDIO_AAC._val; } +const z_loaned_encoding_t *z_encoding_audio_aac(void); +extern const z_owned_encoding_t ENCODING_AUDIO_AAC; /** * A Free Lossless Audio Codec (FLAC) media. * Constant alias for string: `"audio/flac"`. */ -static inline const z_loaned_encoding_t *z_encoding_audio_flac(void) { return &ZP_ENCODING_AUDIO_FLAC._val; } +const z_loaned_encoding_t *z_encoding_audio_flac(void); +extern const z_owned_encoding_t ENCODING_AUDIO_FLAC; /** * An audio codec defined in MPEG-1, MPEG-2, MPEG-4, or registered at the MP4 registration authority. * Constant alias for string: `"audio/mp4"`. */ -static inline const z_loaned_encoding_t *z_encoding_audio_mp4(void) { return &ZP_ENCODING_AUDIO_MP4._val; } +const z_loaned_encoding_t *z_encoding_audio_mp4(void); +extern const z_owned_encoding_t ENCODING_AUDIO_MP4; /** * An Ogg-encapsulated audio stream. * Constant alias for string: `"audio/ogg"`. */ -static inline const z_loaned_encoding_t *z_encoding_audio_ogg(void) { return &ZP_ENCODING_AUDIO_OGG._val; } +const z_loaned_encoding_t *z_encoding_audio_ogg(void); +extern const z_owned_encoding_t ENCODING_AUDIO_OGG; /** * A Vorbis-encoded audio stream. * Constant alias for string: `"audio/vorbis"`. */ -static inline const z_loaned_encoding_t *z_encoding_audio_vorbis(void) { return &ZP_ENCODING_AUDIO_VORBIS._val; } +const z_loaned_encoding_t *z_encoding_audio_vorbis(void); +extern const z_owned_encoding_t ENCODING_AUDIO_VORBIS; /** * A h261-encoded video stream. * Constant alias for string: `"video/h261"`. */ -static inline const z_loaned_encoding_t *z_encoding_video_h261(void) { return &ZP_ENCODING_VIDEO_H261._val; } +const z_loaned_encoding_t *z_encoding_video_h261(void); +extern const z_owned_encoding_t ENCODING_VIDEO_H261; /** * A h263-encoded video stream. * Constant alias for string: `"video/h263"`. */ -static inline const z_loaned_encoding_t *z_encoding_video_h263(void) { return &ZP_ENCODING_VIDEO_H263._val; } +const z_loaned_encoding_t *z_encoding_video_h263(void); +extern const z_owned_encoding_t ENCODING_VIDEO_H263; /** * A h264-encoded video stream. * Constant alias for string: `"video/h264"`. */ -static inline const z_loaned_encoding_t *z_encoding_video_h264(void) { return &ZP_ENCODING_VIDEO_H264._val; } +const z_loaned_encoding_t *z_encoding_video_h264(void); +extern const z_owned_encoding_t ENCODING_VIDEO_H264; /** * A h265-encoded video stream. * Constant alias for string: `"video/h265"`. */ -static inline const z_loaned_encoding_t *z_encoding_video_h265(void) { return &ZP_ENCODING_VIDEO_H265._val; } +const z_loaned_encoding_t *z_encoding_video_h265(void); +extern const z_owned_encoding_t ENCODING_VIDEO_H265; /** * A h266-encoded video stream. * Constant alias for string: `"video/h266"`. */ -static inline const z_loaned_encoding_t *z_encoding_video_h266(void) { return &ZP_ENCODING_VIDEO_H266._val; } +const z_loaned_encoding_t *z_encoding_video_h266(void); +extern const z_owned_encoding_t ENCODING_VIDEO_H266; /** * A video codec defined in MPEG-1, MPEG-2, MPEG-4, or registered at the MP4 registration authority. * Constant alias for string: `"video/mp4"`. */ -static inline const z_loaned_encoding_t *z_encoding_video_mp4(void) { return &ZP_ENCODING_VIDEO_MP4._val; } +const z_loaned_encoding_t *z_encoding_video_mp4(void); +extern const z_owned_encoding_t ENCODING_VIDEO_MP4; /** * An Ogg-encapsulated video stream. * Constant alias for string: `"video/ogg"`. */ -static inline const z_loaned_encoding_t *z_encoding_video_ogg(void) { return &ZP_ENCODING_VIDEO_OGG._val; } +const z_loaned_encoding_t *z_encoding_video_ogg(void); +extern const z_owned_encoding_t ENCODING_VIDEO_OGG; /** * An uncompressed, studio-quality video stream. * Constant alias for string: `"video/raw"`. */ -static inline const z_loaned_encoding_t *z_encoding_video_raw(void) { return &ZP_ENCODING_VIDEO_RAW._val; } +const z_loaned_encoding_t *z_encoding_video_raw(void); +extern const z_owned_encoding_t ENCODING_VIDEO_RAW; /** * A VP8-encoded video stream. * Constant alias for string: `"video/vp8"`. */ -static inline const z_loaned_encoding_t *z_encoding_video_vp8(void) { return &ZP_ENCODING_VIDEO_VP8._val; } +const z_loaned_encoding_t *z_encoding_video_vp8(void); +extern const z_owned_encoding_t ENCODING_VIDEO_VP8; /** * A VP9-encoded video stream. * Constant alias for string: `"video/vp9"`. */ -static inline const z_loaned_encoding_t *z_encoding_video_vp9(void) { return &ZP_ENCODING_VIDEO_VP9._val; } +const z_loaned_encoding_t *z_encoding_video_vp9(void); +extern const z_owned_encoding_t ENCODING_VIDEO_VP9; #endif diff --git a/src/api/encoding.c b/src/api/encoding.c index e96b7bb7e..cf21bf035 100644 --- a/src/api/encoding.c +++ b/src/api/encoding.c @@ -23,79 +23,80 @@ #if Z_FEATURE_ENCODING_VALUES == 1 #define ENCODING_SCHEMA_SEPARATOR ';' -#define ENCODING_CONSTANT_MACRO(_cname, _id) \ +#define ENCODING_CONSTANT_MACRO(_cname, _fname, _id) \ const z_owned_encoding_t ZP_ENCODING_##_cname = { \ ._val = { \ .id = _id, \ .schema = {._slice = {.start = NULL, .len = 0, ._delete_context = {.deleter = NULL, .context = NULL}}}, \ - }}; + }}; \ + const z_loaned_encoding_t *z_encoding_##_fname(void) { return &ZP_ENCODING_##_cname._val; } -ENCODING_CONSTANT_MACRO(ZENOH_BYTES, 0) -ENCODING_CONSTANT_MACRO(ZENOH_INT8, 1) -ENCODING_CONSTANT_MACRO(ZENOH_INT16, 2) -ENCODING_CONSTANT_MACRO(ZENOH_INT32, 3) -ENCODING_CONSTANT_MACRO(ZENOH_INT64, 4) -ENCODING_CONSTANT_MACRO(ZENOH_INT128, 5) -ENCODING_CONSTANT_MACRO(ZENOH_UINT8, 6) -ENCODING_CONSTANT_MACRO(ZENOH_UINT16, 7) -ENCODING_CONSTANT_MACRO(ZENOH_UINT32, 8) -ENCODING_CONSTANT_MACRO(ZENOH_UINT64, 9) -ENCODING_CONSTANT_MACRO(ZENOH_UINT128, 10) -ENCODING_CONSTANT_MACRO(ZENOH_FLOAT32, 11) -ENCODING_CONSTANT_MACRO(ZENOH_FLOAT64, 12) -ENCODING_CONSTANT_MACRO(ZENOH_BOOL, 13) -ENCODING_CONSTANT_MACRO(ZENOH_STRING, 14) -ENCODING_CONSTANT_MACRO(ZENOH_ERROR, 15) -ENCODING_CONSTANT_MACRO(APPLICATION_OCTET_STREAM, 16) -ENCODING_CONSTANT_MACRO(TEXT_PLAIN, 17) -ENCODING_CONSTANT_MACRO(APPLICATION_JSON, 18) -ENCODING_CONSTANT_MACRO(TEXT_JSON, 19) -ENCODING_CONSTANT_MACRO(APPLICATION_CDR, 20) -ENCODING_CONSTANT_MACRO(APPLICATION_CBOR, 21) -ENCODING_CONSTANT_MACRO(APPLICATION_YAML, 22) -ENCODING_CONSTANT_MACRO(TEXT_YAML, 23) -ENCODING_CONSTANT_MACRO(TEXT_JSON5, 24) -ENCODING_CONSTANT_MACRO(APPLICATION_PYTHON_SERIALIZED_OBJECT, 25) -ENCODING_CONSTANT_MACRO(APPLICATION_PROTOBUF, 26) -ENCODING_CONSTANT_MACRO(APPLICATION_JAVA_SERIALIZED_OBJECT, 27) -ENCODING_CONSTANT_MACRO(APPLICATION_OPENMETRICS_TEXT, 28) -ENCODING_CONSTANT_MACRO(IMAGE_PNG, 29) -ENCODING_CONSTANT_MACRO(IMAGE_JPEG, 30) -ENCODING_CONSTANT_MACRO(IMAGE_GIF, 31) -ENCODING_CONSTANT_MACRO(IMAGE_BMP, 32) -ENCODING_CONSTANT_MACRO(IMAGE_WEBP, 33) -ENCODING_CONSTANT_MACRO(APPLICATION_XML, 34) -ENCODING_CONSTANT_MACRO(APPLICATION_X_WWW_FORM_URLENCODED, 35) -ENCODING_CONSTANT_MACRO(TEXT_HTML, 36) -ENCODING_CONSTANT_MACRO(TEXT_XML, 37) -ENCODING_CONSTANT_MACRO(TEXT_CSS, 38) -ENCODING_CONSTANT_MACRO(TEXT_JAVASCRIPT, 39) -ENCODING_CONSTANT_MACRO(TEXT_MARKDOWN, 40) -ENCODING_CONSTANT_MACRO(TEXT_CSV, 41) -ENCODING_CONSTANT_MACRO(APPLICATION_SQL, 42) -ENCODING_CONSTANT_MACRO(APPLICATION_COAP_PAYLOAD, 43) -ENCODING_CONSTANT_MACRO(APPLICATION_JSON_PATCH_JSON, 44) -ENCODING_CONSTANT_MACRO(APPLICATION_JSON_SEQ, 45) -ENCODING_CONSTANT_MACRO(APPLICATION_JSONPATH, 46) -ENCODING_CONSTANT_MACRO(APPLICATION_JWT, 47) -ENCODING_CONSTANT_MACRO(APPLICATION_MP4, 48) -ENCODING_CONSTANT_MACRO(APPLICATION_SOAP_XML, 49) -ENCODING_CONSTANT_MACRO(APPLICATION_YANG, 50) -ENCODING_CONSTANT_MACRO(AUDIO_AAC, 51) -ENCODING_CONSTANT_MACRO(AUDIO_FLAC, 52) -ENCODING_CONSTANT_MACRO(AUDIO_MP4, 53) -ENCODING_CONSTANT_MACRO(AUDIO_OGG, 54) -ENCODING_CONSTANT_MACRO(AUDIO_VORBIS, 55) -ENCODING_CONSTANT_MACRO(VIDEO_H261, 56) -ENCODING_CONSTANT_MACRO(VIDEO_H263, 57) -ENCODING_CONSTANT_MACRO(VIDEO_H264, 58) -ENCODING_CONSTANT_MACRO(VIDEO_H265, 59) -ENCODING_CONSTANT_MACRO(VIDEO_H266, 60) -ENCODING_CONSTANT_MACRO(VIDEO_MP4, 61) -ENCODING_CONSTANT_MACRO(VIDEO_OGG, 62) -ENCODING_CONSTANT_MACRO(VIDEO_RAW, 63) -ENCODING_CONSTANT_MACRO(VIDEO_VP8, 64) -ENCODING_CONSTANT_MACRO(VIDEO_VP9, 65) +ENCODING_CONSTANT_MACRO(ZENOH_BYTES, zenoh_bytes, 0) +ENCODING_CONSTANT_MACRO(ZENOH_INT8, zenoh_int8, 1) +ENCODING_CONSTANT_MACRO(ZENOH_INT16, zenoh_int16, 2) +ENCODING_CONSTANT_MACRO(ZENOH_INT32, zenoh_int32, 3) +ENCODING_CONSTANT_MACRO(ZENOH_INT64, zenoh_int64, 4) +ENCODING_CONSTANT_MACRO(ZENOH_INT128, zenoh_int128, 5) +ENCODING_CONSTANT_MACRO(ZENOH_UINT8, zenoh_uint8, 6) +ENCODING_CONSTANT_MACRO(ZENOH_UINT16, zenoh_uint16, 7) +ENCODING_CONSTANT_MACRO(ZENOH_UINT32, zenoh_uint32, 8) +ENCODING_CONSTANT_MACRO(ZENOH_UINT64, zenoh_uint64, 9) +ENCODING_CONSTANT_MACRO(ZENOH_UINT128, zenoh_uint128, 10) +ENCODING_CONSTANT_MACRO(ZENOH_FLOAT32, zenoh_float32, 11) +ENCODING_CONSTANT_MACRO(ZENOH_FLOAT64, zenoh_float64, 12) +ENCODING_CONSTANT_MACRO(ZENOH_BOOL, zenoh_bool, 13) +ENCODING_CONSTANT_MACRO(ZENOH_STRING, zenoh_string, 14) +ENCODING_CONSTANT_MACRO(ZENOH_ERROR, zenoh_error, 15) +ENCODING_CONSTANT_MACRO(APPLICATION_OCTET_STREAM, application_octet_stream, 16) +ENCODING_CONSTANT_MACRO(TEXT_PLAIN, text_plain, 17) +ENCODING_CONSTANT_MACRO(APPLICATION_JSON, application_json, 18) +ENCODING_CONSTANT_MACRO(TEXT_JSON, text_json, 19) +ENCODING_CONSTANT_MACRO(APPLICATION_CDR, application_cdr, 20) +ENCODING_CONSTANT_MACRO(APPLICATION_CBOR, application_cbor, 21) +ENCODING_CONSTANT_MACRO(APPLICATION_YAML, application_yaml, 22) +ENCODING_CONSTANT_MACRO(TEXT_YAML, text_yaml, 23) +ENCODING_CONSTANT_MACRO(TEXT_JSON5, text_json5, 24) +ENCODING_CONSTANT_MACRO(APPLICATION_PYTHON_SERIALIZED_OBJECT, application_python_serialized_object, 25) +ENCODING_CONSTANT_MACRO(APPLICATION_PROTOBUF, application_protobuf, 26) +ENCODING_CONSTANT_MACRO(APPLICATION_JAVA_SERIALIZED_OBJECT, application_java_serialized_object, 27) +ENCODING_CONSTANT_MACRO(APPLICATION_OPENMETRICS_TEXT, application_openmetrics_text, 28) +ENCODING_CONSTANT_MACRO(IMAGE_PNG, image_png, 29) +ENCODING_CONSTANT_MACRO(IMAGE_JPEG, image_jpeg, 30) +ENCODING_CONSTANT_MACRO(IMAGE_GIF, image_gif, 31) +ENCODING_CONSTANT_MACRO(IMAGE_BMP, image_bmp, 32) +ENCODING_CONSTANT_MACRO(IMAGE_WEBP, image_webp, 33) +ENCODING_CONSTANT_MACRO(APPLICATION_XML, application_xml, 34) +ENCODING_CONSTANT_MACRO(APPLICATION_X_WWW_FORM_URLENCODED, application_x_www_form_urlencoded, 35) +ENCODING_CONSTANT_MACRO(TEXT_HTML, text_html, 36) +ENCODING_CONSTANT_MACRO(TEXT_XML, text_xml, 37) +ENCODING_CONSTANT_MACRO(TEXT_CSS, text_css, 38) +ENCODING_CONSTANT_MACRO(TEXT_JAVASCRIPT, text_javascript, 39) +ENCODING_CONSTANT_MACRO(TEXT_MARKDOWN, text_markdown, 40) +ENCODING_CONSTANT_MACRO(TEXT_CSV, text_csv, 41) +ENCODING_CONSTANT_MACRO(APPLICATION_SQL, application_sql, 42) +ENCODING_CONSTANT_MACRO(APPLICATION_COAP_PAYLOAD, application_coap_payload, 43) +ENCODING_CONSTANT_MACRO(APPLICATION_JSON_PATCH_JSON, application_json_patch_json, 44) +ENCODING_CONSTANT_MACRO(APPLICATION_JSON_SEQ, application_json_seq, 45) +ENCODING_CONSTANT_MACRO(APPLICATION_JSONPATH, application_jsonpath, 46) +ENCODING_CONSTANT_MACRO(APPLICATION_JWT, application_jwt, 47) +ENCODING_CONSTANT_MACRO(APPLICATION_MP4, application_mp4, 48) +ENCODING_CONSTANT_MACRO(APPLICATION_SOAP_XML, application_soap_xml, 49) +ENCODING_CONSTANT_MACRO(APPLICATION_YANG, application_yang, 50) +ENCODING_CONSTANT_MACRO(AUDIO_AAC, audio_aac, 51) +ENCODING_CONSTANT_MACRO(AUDIO_FLAC, audio_flac, 52) +ENCODING_CONSTANT_MACRO(AUDIO_MP4, audio_mp4, 53) +ENCODING_CONSTANT_MACRO(AUDIO_OGG, audio_ogg, 54) +ENCODING_CONSTANT_MACRO(AUDIO_VORBIS, audio_vorbis, 55) +ENCODING_CONSTANT_MACRO(VIDEO_H261, video_h261, 56) +ENCODING_CONSTANT_MACRO(VIDEO_H263, video_h263, 57) +ENCODING_CONSTANT_MACRO(VIDEO_H264, video_h264, 58) +ENCODING_CONSTANT_MACRO(VIDEO_H265, video_h265, 59) +ENCODING_CONSTANT_MACRO(VIDEO_H266, video_h266, 60) +ENCODING_CONSTANT_MACRO(VIDEO_MP4, video_mp4, 61) +ENCODING_CONSTANT_MACRO(VIDEO_OGG, video_ogg, 62) +ENCODING_CONSTANT_MACRO(VIDEO_RAW, video_raw, 63) +ENCODING_CONSTANT_MACRO(VIDEO_VP8, video_vp8, 64) +ENCODING_CONSTANT_MACRO(VIDEO_VP9, video_vp9, 65) const char *ENCODING_VALUES_ID_TO_STR[] = { "zenoh/bytes",