3rdparty: update TinyCBOR to v0.6.1
[ChangeLog][Third-Party Code] The copy of TinyCBOR in Qt was updated to 0.6.1. Manual conflict resolution for 6.9: - worked around 34f60877bdb54786c62fd1bf5b44a81430aa411f not having been picked to older branches Pick-to: 6.9.0 6.8 6.8.3 6.5 5.15 Change-Id: If5d5ef6220874ae8858efffd1712a567597b6317 Reviewed-by: Marc Mutz <marc.mutz@qt.io> (cherry picked from commit 7df128675a22391bc3ade2a45b558bc38eee1c67)
This commit is contained in:
parent
6d2421d812
commit
cd395a7999
@ -1,79 +0,0 @@
|
|||||||
From b6e2caf7452bf2b695583196fd7b346c1663d798 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Marc Mutz <marc.mutz@qt.io>
|
|
||||||
Date: Mon, 7 Aug 2023 16:24:13 +0200
|
|
||||||
Subject: [PATCH] tst_Encoder: port away from Q_FOREACH
|
|
||||||
|
|
||||||
Qt is defaulting to QT_NO_FOREACH these days, so make sure we
|
|
||||||
integrate nicely with downstream and fix the single Q_FOREACH/foreach
|
|
||||||
user, in tst_encoder.cpp.
|
|
||||||
|
|
||||||
Unfortunately, the container's initialization code doesn't exactly
|
|
||||||
lend itself to making the container const (not even IILE
|
|
||||||
(Immediately-Invoked Lambda Expression) would help here, due to the
|
|
||||||
interdependency with `len`), so the idiomatic solution would be to use
|
|
||||||
std::as_const()/qAsConst().
|
|
||||||
|
|
||||||
The former is available from C++17, which we don't require, yet, and
|
|
||||||
the latter is not available under QT_NO_AS_CONST (the default for Qt
|
|
||||||
these days), so grab the nettle and implement a t17::as_const() that
|
|
||||||
switches between a manual implementation of std::as_const and the real
|
|
||||||
thing, depending on __cpp_lib_as_const. The `t17` here mimicks the qNN
|
|
||||||
(q20::remove_cvref_t/q23::forward_like/etc) mechanism used in Qt
|
|
||||||
itself for backports, with s/q/t/ because ... _T_inyCbor.
|
|
||||||
|
|
||||||
The t17 implementation is local to tst_encoder.cpp, but can easily be
|
|
||||||
extracted into a separate header once more users emerge.
|
|
||||||
---
|
|
||||||
tests/encoder/encoder.pro | 2 ++
|
|
||||||
tests/encoder/tst_encoder.cpp | 15 ++++++++++++++-
|
|
||||||
2 files changed, 16 insertions(+), 1 deletion(-)
|
|
||||||
|
|
||||||
diff --git a/tests/encoder/encoder.pro b/tests/encoder/encoder.pro
|
|
||||||
index 62d9b7e..180f0d7 100644
|
|
||||||
--- a/tests/encoder/encoder.pro
|
|
||||||
+++ b/tests/encoder/encoder.pro
|
|
||||||
@@ -3,6 +3,8 @@ SOURCES += tst_encoder.cpp
|
|
||||||
CONFIG += testcase parallel_test c++11
|
|
||||||
QT = core testlib
|
|
||||||
|
|
||||||
+DEFINES += QT_NO_FOREACH QT_NO_AS_CONST
|
|
||||||
+
|
|
||||||
INCLUDEPATH += ../../src
|
|
||||||
msvc: POST_TARGETDEPS = ../../lib/tinycbor.lib
|
|
||||||
else: POST_TARGETDEPS += ../../lib/libtinycbor.a
|
|
||||||
diff --git a/tests/encoder/tst_encoder.cpp b/tests/encoder/tst_encoder.cpp
|
|
||||||
index 31c2915..61ce9c9 100644
|
|
||||||
--- a/tests/encoder/tst_encoder.cpp
|
|
||||||
+++ b/tests/encoder/tst_encoder.cpp
|
|
||||||
@@ -29,6 +29,19 @@
|
|
||||||
#include <qfloat16.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
+#include <utility>
|
|
||||||
+namespace t17 {
|
|
||||||
+#ifdef __cpp_lib_as_const
|
|
||||||
+ using std::as_const;
|
|
||||||
+#else
|
|
||||||
+ template <typename T>
|
|
||||||
+ constexpr typename std::add_const<T>::type &as_const(T &t) noexcept { return t; }
|
|
||||||
+ // prevent rvalue arguments:
|
|
||||||
+ template <typename T>
|
|
||||||
+ void as_const(const T &&) = delete;
|
|
||||||
+#endif // __cpp_lib_as_const
|
|
||||||
+} // namespace t17
|
|
||||||
+
|
|
||||||
Q_DECLARE_METATYPE(CborError)
|
|
||||||
namespace QTest {
|
|
||||||
template<> char *toString<CborError>(const CborError &err)
|
|
||||||
@@ -153,7 +166,7 @@ CborError encodeVariant(CborEncoder *encoder, const QVariant &v)
|
|
||||||
CborError err = cbor_encoder_create_array(encoder, &sub, len);
|
|
||||||
if (err && !isOomError(err))
|
|
||||||
return err;
|
|
||||||
- foreach (const QVariant &v2, list) {
|
|
||||||
+ for (const QVariant &v2 : t17::as_const(list)) {
|
|
||||||
err = static_cast<CborError>(err | encodeVariant(&sub, v2));
|
|
||||||
if (err && !isOomError(err))
|
|
||||||
return err;
|
|
||||||
--
|
|
||||||
2.25.1
|
|
||||||
|
|
4
src/3rdparty/tinycbor/qt_attribution.json
vendored
4
src/3rdparty/tinycbor/qt_attribution.json
vendored
@ -10,9 +10,9 @@
|
|||||||
"License": "MIT License",
|
"License": "MIT License",
|
||||||
"LicenseId": "MIT",
|
"LicenseId": "MIT",
|
||||||
"LicenseFile": "LICENSE",
|
"LicenseFile": "LICENSE",
|
||||||
"DownloadLocation": "https://github.com/intel/tinycbor/archive/v0.6.0/tinycbor-0.6.0.tar.gz",
|
"DownloadLocation": "https://github.com/intel/tinycbor/archive/v0.6.1/tinycbor-0.6.1.tar.gz",
|
||||||
"PURL": "pkg:github/intel/tinycbor@v$<VERSION>",
|
"PURL": "pkg:github/intel/tinycbor@v$<VERSION>",
|
||||||
"CPE": "cpe:2.3:a:tinycbor:tinycbor:$<VERSION>:*:*:*:*:*:*:*",
|
"CPE": "cpe:2.3:a:tinycbor:tinycbor:$<VERSION>:*:*:*:*:*:*:*",
|
||||||
"Version": "0.6.0",
|
"Version": "0.6.1",
|
||||||
"Copyright": "Copyright (C) 2015-2021 Intel Corporation"
|
"Copyright": "Copyright (C) 2015-2021 Intel Corporation"
|
||||||
}
|
}
|
||||||
|
4
src/3rdparty/tinycbor/src/cbor.h
vendored
4
src/3rdparty/tinycbor/src/cbor.h
vendored
@ -34,6 +34,10 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#ifdef CBOR_EXTERNAL_CFG
|
||||||
|
#include "cbor_cfg.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "tinycbor-version.h"
|
#include "tinycbor-version.h"
|
||||||
|
|
||||||
#define TINYCBOR_VERSION ((TINYCBOR_VERSION_MAJOR << 16) | (TINYCBOR_VERSION_MINOR << 8) | TINYCBOR_VERSION_PATCH)
|
#define TINYCBOR_VERSION ((TINYCBOR_VERSION_MAJOR << 16) | (TINYCBOR_VERSION_MINOR << 8) | TINYCBOR_VERSION_PATCH)
|
||||||
|
6
src/3rdparty/tinycbor/src/cborencoder.c
vendored
6
src/3rdparty/tinycbor/src/cborencoder.c
vendored
@ -31,6 +31,7 @@
|
|||||||
#ifndef __STDC_LIMIT_MACROS
|
#ifndef __STDC_LIMIT_MACROS
|
||||||
# define __STDC_LIMIT_MACROS 1
|
# define __STDC_LIMIT_MACROS 1
|
||||||
#endif
|
#endif
|
||||||
|
#define __STDC_WANT_IEC_60559_TYPES_EXT__
|
||||||
|
|
||||||
#include "cbor.h"
|
#include "cbor.h"
|
||||||
#include "cborinternal_p.h"
|
#include "cborinternal_p.h"
|
||||||
@ -101,7 +102,7 @@
|
|||||||
* complete the encoding. At the end, you can obtain that count by calling
|
* complete the encoding. At the end, you can obtain that count by calling
|
||||||
* cbor_encoder_get_extra_bytes_needed().
|
* cbor_encoder_get_extra_bytes_needed().
|
||||||
*
|
*
|
||||||
* \section1 Finalizing the encoding
|
* \section Finalizing the encoding
|
||||||
*
|
*
|
||||||
* Once all items have been appended and the containers have all been properly
|
* Once all items have been appended and the containers have all been properly
|
||||||
* closed, the user-supplied buffer will contain the CBOR stream and may be
|
* closed, the user-supplied buffer will contain the CBOR stream and may be
|
||||||
@ -212,6 +213,7 @@ void cbor_encoder_init_writer(CborEncoder *encoder, CborEncoderWriteFunction wri
|
|||||||
{
|
{
|
||||||
#ifdef CBOR_ENCODER_WRITE_FUNCTION
|
#ifdef CBOR_ENCODER_WRITE_FUNCTION
|
||||||
(void) writer;
|
(void) writer;
|
||||||
|
encoder->data.writer = CBOR_NULLPTR;
|
||||||
#else
|
#else
|
||||||
encoder->data.writer = writer;
|
encoder->data.writer = writer;
|
||||||
#endif
|
#endif
|
||||||
@ -544,7 +546,7 @@ CborError cbor_encoder_create_array(CborEncoder *parentEncoder, CborEncoder *arr
|
|||||||
* when creating the map, the constant \ref CborIndefiniteLength may be passed as
|
* when creating the map, the constant \ref CborIndefiniteLength may be passed as
|
||||||
* length instead, and an indefinite length map is created.
|
* length instead, and an indefinite length map is created.
|
||||||
*
|
*
|
||||||
* \b{Implementation limitation:} TinyCBOR cannot encode more than SIZE_MAX/2
|
* <b>Implementation limitation:</b> TinyCBOR cannot encode more than SIZE_MAX/2
|
||||||
* key-value pairs in the stream. If the length \a length is larger than this
|
* key-value pairs in the stream. If the length \a length is larger than this
|
||||||
* value (and is not \ref CborIndefiniteLength), this function returns error
|
* value (and is not \ref CborIndefiniteLength), this function returns error
|
||||||
* CborErrorDataTooLarge.
|
* CborErrorDataTooLarge.
|
||||||
|
29
src/3rdparty/tinycbor/src/cborinternal_p.h
vendored
29
src/3rdparty/tinycbor/src/cborinternal_p.h
vendored
@ -25,11 +25,19 @@
|
|||||||
#ifndef CBORINTERNAL_P_H
|
#ifndef CBORINTERNAL_P_H
|
||||||
#define CBORINTERNAL_P_H
|
#define CBORINTERNAL_P_H
|
||||||
|
|
||||||
|
/* Dependent source files (*.c) must define __STDC_WANT_IEC_60559_TYPES_EXT__
|
||||||
|
* before <float.h> is (transitively) first included.
|
||||||
|
*/
|
||||||
|
#if !defined(__STDC_WANT_IEC_60559_TYPES_EXT__)
|
||||||
|
# error __STDC_WANT_IEC_60559_TYPES_EXT__ not defined
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "compilersupport_p.h"
|
#include "compilersupport_p.h"
|
||||||
|
|
||||||
#ifndef CBOR_NO_FLOATING_POINT
|
#ifndef CBOR_NO_FLOATING_POINT
|
||||||
# include <float.h>
|
# include <float.h>
|
||||||
# include <math.h>
|
# include <math.h>
|
||||||
|
# include <string.h>
|
||||||
#else
|
#else
|
||||||
# ifndef CBOR_NO_HALF_FLOAT_TYPE
|
# ifndef CBOR_NO_HALF_FLOAT_TYPE
|
||||||
# define CBOR_NO_HALF_FLOAT_TYPE 1
|
# define CBOR_NO_HALF_FLOAT_TYPE 1
|
||||||
@ -37,7 +45,26 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CBOR_NO_HALF_FLOAT_TYPE
|
#ifndef CBOR_NO_HALF_FLOAT_TYPE
|
||||||
# if defined(__F16C__) || defined(__AVX2__)
|
/* Check for FLT16_MANT_DIG using integer comparison. Clang headers incorrectly
|
||||||
|
* define this macro unconditionally when __STDC_WANT_IEC_60559_TYPES_EXT__
|
||||||
|
* is defined (regardless of actual support for _Float16).
|
||||||
|
*/
|
||||||
|
# if FLT16_MANT_DIG > 0 || __FLT16_MANT_DIG__ > 0
|
||||||
|
static inline unsigned short encode_half(float x)
|
||||||
|
{
|
||||||
|
unsigned short h;
|
||||||
|
_Float16 f = (_Float16)x;
|
||||||
|
memcpy(&h, &f, 2);
|
||||||
|
return h;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline float decode_half(unsigned short x)
|
||||||
|
{
|
||||||
|
_Float16 f;
|
||||||
|
memcpy(&f, &x, 2);
|
||||||
|
return (float)f;
|
||||||
|
}
|
||||||
|
# elif defined(__F16C__) || defined(__AVX2__)
|
||||||
# include <immintrin.h>
|
# include <immintrin.h>
|
||||||
static inline unsigned short encode_half(float val)
|
static inline unsigned short encode_half(float val)
|
||||||
{
|
{
|
||||||
|
45
src/3rdparty/tinycbor/src/cborparser.c
vendored
45
src/3rdparty/tinycbor/src/cborparser.c
vendored
@ -31,6 +31,7 @@
|
|||||||
#ifndef __STDC_LIMIT_MACROS
|
#ifndef __STDC_LIMIT_MACROS
|
||||||
# define __STDC_LIMIT_MACROS 1
|
# define __STDC_LIMIT_MACROS 1
|
||||||
#endif
|
#endif
|
||||||
|
#define __STDC_WANT_IEC_60559_TYPES_EXT__
|
||||||
|
|
||||||
#include "cbor.h"
|
#include "cbor.h"
|
||||||
#include "cborinternal_p.h"
|
#include "cborinternal_p.h"
|
||||||
@ -93,7 +94,7 @@
|
|||||||
*
|
*
|
||||||
* The code above does not execute a range-check either: it is possible that
|
* The code above does not execute a range-check either: it is possible that
|
||||||
* the value decoded from the CBOR stream encodes a number larger than what can
|
* the value decoded from the CBOR stream encodes a number larger than what can
|
||||||
* be represented in a variable of type \c{int}. If detecting that case is
|
* be represented in a variable of type \c int. If detecting that case is
|
||||||
* important, the code should call cbor_value_get_int_checked() instead.
|
* important, the code should call cbor_value_get_int_checked() instead.
|
||||||
*
|
*
|
||||||
* <h3 class="groupheader">Memory and parsing constraints</h3>
|
* <h3 class="groupheader">Memory and parsing constraints</h3>
|
||||||
@ -133,12 +134,10 @@
|
|||||||
*
|
*
|
||||||
* \if privatedocs
|
* \if privatedocs
|
||||||
* Implementation details: the CborValue contains these fields:
|
* Implementation details: the CborValue contains these fields:
|
||||||
* \list
|
* - ptr: pointer to the actual data
|
||||||
* \li ptr: pointer to the actual data
|
* - flags: flags from the decoder
|
||||||
* \li flags: flags from the decoder
|
* - extra: partially decoded integer value (0, 1 or 2 bytes)
|
||||||
* \li extra: partially decoded integer value (0, 1 or 2 bytes)
|
* - remaining: remaining items in this collection after this item or UINT32_MAX if length is unknown
|
||||||
* \li remaining: remaining items in this collection after this item or UINT32_MAX if length is unknown
|
|
||||||
* \endlist
|
|
||||||
* \endif
|
* \endif
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -232,7 +231,7 @@ static CborError preparse_value(CborValue *it)
|
|||||||
case SinglePrecisionFloat:
|
case SinglePrecisionFloat:
|
||||||
case DoublePrecisionFloat:
|
case DoublePrecisionFloat:
|
||||||
it->flags |= CborIteratorFlag_IntegerValueTooLarge;
|
it->flags |= CborIteratorFlag_IntegerValueTooLarge;
|
||||||
Q_FALLTHROUGH();
|
CBOR_FALLTHROUGH;
|
||||||
case TrueValue:
|
case TrueValue:
|
||||||
case NullValue:
|
case NullValue:
|
||||||
case UndefinedValue:
|
case UndefinedValue:
|
||||||
@ -428,12 +427,10 @@ CborError cbor_value_reparse(CborValue *it)
|
|||||||
* will appear during parsing.
|
* will appear during parsing.
|
||||||
*
|
*
|
||||||
* A basic validation checks for:
|
* A basic validation checks for:
|
||||||
* \list
|
* - absence of undefined additional information bytes;
|
||||||
* \li absence of undefined additional information bytes;
|
* - well-formedness of all numbers, lengths, and simple values;
|
||||||
* \li well-formedness of all numbers, lengths, and simple values;
|
* - string contents match reported sizes;
|
||||||
* \li string contents match reported sizes;
|
* - arrays and maps contain the number of elements they are reported to have;
|
||||||
* \li arrays and maps contain the number of elements they are reported to have;
|
|
||||||
* \endlist
|
|
||||||
*
|
*
|
||||||
* For further checks, see cbor_value_validate().
|
* For further checks, see cbor_value_validate().
|
||||||
*
|
*
|
||||||
@ -744,7 +741,7 @@ CborError cbor_value_leave_container(CborValue *it, const CborValue *recursed)
|
|||||||
* \ref cbor_value_is_integer is recommended.
|
* \ref cbor_value_is_integer is recommended.
|
||||||
*
|
*
|
||||||
* Note that this function does not do range-checking: integral values that do
|
* Note that this function does not do range-checking: integral values that do
|
||||||
* not fit in a variable of type \c{int} are silently truncated to fit. Use
|
* not fit in a variable of type \c int are silently truncated to fit. Use
|
||||||
* cbor_value_get_int_checked() if that is not acceptable.
|
* cbor_value_get_int_checked() if that is not acceptable.
|
||||||
*
|
*
|
||||||
* \sa cbor_value_get_type(), cbor_value_is_valid(), cbor_value_is_integer()
|
* \sa cbor_value_get_type(), cbor_value_is_valid(), cbor_value_is_integer()
|
||||||
@ -759,7 +756,7 @@ CborError cbor_value_leave_container(CborValue *it, const CborValue *recursed)
|
|||||||
* \ref cbor_value_is_integer is recommended.
|
* \ref cbor_value_is_integer is recommended.
|
||||||
*
|
*
|
||||||
* Note that this function does not do range-checking: integral values that do
|
* Note that this function does not do range-checking: integral values that do
|
||||||
* not fit in a variable of type \c{int64_t} are silently truncated to fit. Use
|
* not fit in a variable of type \c int64_t are silently truncated to fit. Use
|
||||||
* cbor_value_get_int64_checked() that is not acceptable.
|
* cbor_value_get_int64_checked() that is not acceptable.
|
||||||
*
|
*
|
||||||
* \sa cbor_value_get_type(), cbor_value_is_valid(), cbor_value_is_integer()
|
* \sa cbor_value_get_type(), cbor_value_is_valid(), cbor_value_is_integer()
|
||||||
@ -790,7 +787,7 @@ CborError cbor_value_leave_container(CborValue *it, const CborValue *recursed)
|
|||||||
* If the integer is unsigned (that is, if cbor_value_is_unsigned_integer()
|
* If the integer is unsigned (that is, if cbor_value_is_unsigned_integer()
|
||||||
* returns true), then \a result will contain the actual value. If the integer
|
* returns true), then \a result will contain the actual value. If the integer
|
||||||
* is negative, then \a result will contain the absolute value of that integer,
|
* is negative, then \a result will contain the absolute value of that integer,
|
||||||
* minus one. That is, \c {actual = -result - 1}. On architectures using two's
|
* minus one. That is, <tt>actual = -result - 1</tt>. On architectures using two's
|
||||||
* complement for representation of negative integers, it is equivalent to say
|
* complement for representation of negative integers, it is equivalent to say
|
||||||
* that \a result will contain the bitwise negation of the actual value.
|
* that \a result will contain the bitwise negation of the actual value.
|
||||||
*
|
*
|
||||||
@ -1211,7 +1208,7 @@ static CborError iterate_string_chunks(const CborValue *value, char *buffer, siz
|
|||||||
return CborErrorDataTooLarge;
|
return CborErrorDataTooLarge;
|
||||||
|
|
||||||
if (*result && *buflen >= newTotal)
|
if (*result && *buflen >= newTotal)
|
||||||
*result = !!func(buffer + total, (const uint8_t *)ptr, chunkLen);
|
*result = !!func(buffer == NULL ? buffer : buffer + total, (const uint8_t *)ptr, chunkLen);
|
||||||
else
|
else
|
||||||
*result = false;
|
*result = false;
|
||||||
|
|
||||||
@ -1221,7 +1218,7 @@ static CborError iterate_string_chunks(const CborValue *value, char *buffer, siz
|
|||||||
/* is there enough room for the ending NUL byte? */
|
/* is there enough room for the ending NUL byte? */
|
||||||
if (*result && *buflen > total) {
|
if (*result && *buflen > total) {
|
||||||
uint8_t nul[] = { 0 };
|
uint8_t nul[] = { 0 };
|
||||||
*result = !!func(buffer + total, nul, 1);
|
*result = !!func(buffer == NULL ? buffer : buffer + total, nul, 1);
|
||||||
}
|
}
|
||||||
*buflen = total;
|
*buflen = total;
|
||||||
return _cbor_value_finish_string_iteration(next);
|
return _cbor_value_finish_string_iteration(next);
|
||||||
@ -1243,10 +1240,10 @@ static CborError iterate_string_chunks(const CborValue *value, char *buffer, siz
|
|||||||
* of the string in order to preallocate a buffer, use
|
* of the string in order to preallocate a buffer, use
|
||||||
* cbor_value_calculate_string_length().
|
* cbor_value_calculate_string_length().
|
||||||
*
|
*
|
||||||
* On success, this function sets the number of bytes copied to \c{*buflen}. If
|
* On success, this function sets the number of bytes copied to \c *buflen. If
|
||||||
* the buffer is large enough, this function will insert a null byte after the
|
* the buffer is large enough, this function will insert a null byte after the
|
||||||
* last copied byte, to facilitate manipulation of text strings. That byte is
|
* last copied byte, to facilitate manipulation of text strings. That byte is
|
||||||
* not included in the returned value of \c{*buflen}. If there was no space for
|
* not included in the returned value of \c *buflen. If there was no space for
|
||||||
* the terminating null, no error is returned, so callers must check the value
|
* the terminating null, no error is returned, so callers must check the value
|
||||||
* of *buflen after the call, before relying on the '\0'; if it has not been
|
* of *buflen after the call, before relying on the '\0'; if it has not been
|
||||||
* changed by the call, there is no '\0'-termination on the buffer's contents.
|
* changed by the call, there is no '\0'-termination on the buffer's contents.
|
||||||
@ -1280,10 +1277,10 @@ static CborError iterate_string_chunks(const CborValue *value, char *buffer, siz
|
|||||||
* of the string in order to preallocate a buffer, use
|
* of the string in order to preallocate a buffer, use
|
||||||
* cbor_value_calculate_string_length().
|
* cbor_value_calculate_string_length().
|
||||||
*
|
*
|
||||||
* On success, this function sets the number of bytes copied to \c{*buflen}. If
|
* On success, this function sets the number of bytes copied to \c *buflen. If
|
||||||
* the buffer is large enough, this function will insert a null byte after the
|
* the buffer is large enough, this function will insert a null byte after the
|
||||||
* last copied byte, to facilitate manipulation of null-terminated strings.
|
* last copied byte, to facilitate manipulation of null-terminated strings.
|
||||||
* That byte is not included in the returned value of \c{*buflen}.
|
* That byte is not included in the returned value of \c *buflen.
|
||||||
*
|
*
|
||||||
* The \a next pointer, if not null, will be updated to point to the next item
|
* The \a next pointer, if not null, will be updated to point to the next item
|
||||||
* after this string. If \a value points to the last item, then \a next will be
|
* after this string. If \a value points to the last item, then \a next will be
|
||||||
@ -1520,7 +1517,7 @@ error:
|
|||||||
* cbor_value_is_half_float is recommended.
|
* cbor_value_is_half_float is recommended.
|
||||||
*
|
*
|
||||||
* Note: since the C language does not have a standard type for half-precision
|
* Note: since the C language does not have a standard type for half-precision
|
||||||
* floating point, this function takes a \c{void *} as a parameter for the
|
* floating point, this function takes a <tt>void *</tt> as a parameter for the
|
||||||
* storage area, which must be at least 16 bits wide.
|
* storage area, which must be at least 16 bits wide.
|
||||||
*
|
*
|
||||||
* \sa cbor_value_get_type(), cbor_value_is_valid(), cbor_value_is_half_float(), cbor_value_get_half_float_as_float(), cbor_value_get_float()
|
* \sa cbor_value_get_type(), cbor_value_is_valid(), cbor_value_is_half_float(), cbor_value_get_half_float_as_float(), cbor_value_get_float()
|
||||||
|
51
src/3rdparty/tinycbor/src/compilersupport_p.h
vendored
51
src/3rdparty/tinycbor/src/compilersupport_p.h
vendored
@ -44,14 +44,28 @@
|
|||||||
# include <stdbool.h>
|
# include <stdbool.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if __STDC_VERSION__ >= 201112L || (defined(__cplusplus) && __cplusplus >= 201103L) || (defined(__cpp_static_assert) && __cpp_static_assert >= 200410)
|
#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || (defined(__cplusplus) && __cplusplus >= 201103L) || (defined(__cpp_static_assert) && __cpp_static_assert >= 200410)
|
||||||
# define cbor_static_assert(x) static_assert(x, #x)
|
# define cbor_static_assert(x) static_assert(x, #x)
|
||||||
#elif !defined(__cplusplus) && defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 406) && (__STDC_VERSION__ > 199901L)
|
#elif !defined(__cplusplus) && defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 406) && (__STDC_VERSION__ > 199901L)
|
||||||
# define cbor_static_assert(x) _Static_assert(x, #x)
|
# define cbor_static_assert(x) _Static_assert(x, #x)
|
||||||
#else
|
#else
|
||||||
# define cbor_static_assert(x) ((void)sizeof(char[2*!!(x) - 1]))
|
# define cbor_static_assert(x) ((void)sizeof(char[2*!!(x) - 1]))
|
||||||
#endif
|
#endif
|
||||||
#if __STDC_VERSION__ >= 199901L || defined(__cplusplus)
|
|
||||||
|
#if defined(__has_cpp_attribute) // C23 and C++17
|
||||||
|
# if __has_cpp_attribute(fallthrough)
|
||||||
|
# define CBOR_FALLTHROUGH [[fallthrough]]
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
#ifndef CBOR_FALLTHROUGH
|
||||||
|
# ifdef __GNUC__
|
||||||
|
# define CBOR_FALLTHROUGH __attribute__((fallthrough))
|
||||||
|
# else
|
||||||
|
# define CBOR_FALLTHROUGH do { } while (0)
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__cplusplus)
|
||||||
/* inline is a keyword */
|
/* inline is a keyword */
|
||||||
#else
|
#else
|
||||||
/* use the definition from cbor.h */
|
/* use the definition from cbor.h */
|
||||||
@ -128,6 +142,23 @@
|
|||||||
# define cbor_htonl _byteswap_ulong
|
# define cbor_htonl _byteswap_ulong
|
||||||
# define cbor_ntohs _byteswap_ushort
|
# define cbor_ntohs _byteswap_ushort
|
||||||
# define cbor_htons _byteswap_ushort
|
# define cbor_htons _byteswap_ushort
|
||||||
|
#elif defined(__ICCARM__)
|
||||||
|
# if __LITTLE_ENDIAN__ == 1
|
||||||
|
# include <intrinsics.h>
|
||||||
|
# define ntohll(x) ((__REV((uint32_t)(x)) * UINT64_C(0x100000000)) + (__REV((x) >> 32)))
|
||||||
|
# define htonll ntohll
|
||||||
|
# define cbor_ntohl __REV
|
||||||
|
# define cbor_htonl __REV
|
||||||
|
# define cbor_ntohs __REVSH
|
||||||
|
# define cbor_htons __REVSH
|
||||||
|
# else
|
||||||
|
# define cbor_ntohll
|
||||||
|
# define cbor_htonll
|
||||||
|
# define cbor_ntohl
|
||||||
|
# define cbor_htonl
|
||||||
|
# define cbor_ntohs
|
||||||
|
# define cbor_htons
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
#ifndef cbor_ntohs
|
#ifndef cbor_ntohs
|
||||||
# include <arpa/inet.h>
|
# include <arpa/inet.h>
|
||||||
@ -156,7 +187,7 @@
|
|||||||
(defined(BYTE_ORDER) && defined(LITTLE_ENDIAN) && BYTE_ORDER == LITTLE_ENDIAN) || \
|
(defined(BYTE_ORDER) && defined(LITTLE_ENDIAN) && BYTE_ORDER == LITTLE_ENDIAN) || \
|
||||||
defined(_LITTLE_ENDIAN) || defined(__LITTLE_ENDIAN__) || defined(__ARMEL__) || defined(__MIPSEL__) || \
|
defined(_LITTLE_ENDIAN) || defined(__LITTLE_ENDIAN__) || defined(__ARMEL__) || defined(__MIPSEL__) || \
|
||||||
defined(__i386) || defined(__i386__) || defined(__x86_64) || defined(__x86_64__) || defined(__amd64)
|
defined(__i386) || defined(__i386__) || defined(__x86_64) || defined(__x86_64__) || defined(__amd64)
|
||||||
# define ntohll(x) ((ntohl((uint32_t)(x)) * UINT64_C(0x100000000)) + (ntohl((x) >> 32)))
|
# define ntohll(x) ((cbor_ntohl((uint32_t)(x)) * UINT64_C(0x100000000)) + (cbor_ntohl((x) >> 32)))
|
||||||
# define htonll ntohll
|
# define htonll ntohll
|
||||||
# else
|
# else
|
||||||
# error "Unable to determine byte order!"
|
# error "Unable to determine byte order!"
|
||||||
@ -167,9 +198,11 @@
|
|||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
# define CONST_CAST(t, v) const_cast<t>(v)
|
# define CONST_CAST(t, v) const_cast<t>(v)
|
||||||
|
# define CBOR_NULLPTR nullptr
|
||||||
#else
|
#else
|
||||||
/* C-style const_cast without triggering a warning with -Wcast-qual */
|
/* C-style const_cast without triggering a warning with -Wcast-qual */
|
||||||
# define CONST_CAST(t, v) (t)(uintptr_t)(v)
|
# define CONST_CAST(t, v) (t)(uintptr_t)(v)
|
||||||
|
# define CBOR_NULLPTR NULL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
@ -201,5 +234,15 @@ static inline bool add_check_overflow(size_t v1, size_t v2, size_t *r)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* COMPILERSUPPORT_H */
|
static inline bool mul_check_overflow(size_t v1, size_t v2, size_t *r)
|
||||||
|
{
|
||||||
|
#if ((defined(__GNUC__) && (__GNUC__ >= 5)) && !defined(__INTEL_COMPILER)) || __has_builtin(__builtin_add_overflow)
|
||||||
|
return __builtin_mul_overflow(v1, v2, r);
|
||||||
|
#else
|
||||||
|
/* unsigned multiplications are well-defined */
|
||||||
|
*r = v1 * v2;
|
||||||
|
return *r > v1 && *r > v2;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* COMPILERSUPPORT_H */
|
||||||
|
@ -106,6 +106,8 @@ private slots:
|
|||||||
// validation & errors
|
// validation & errors
|
||||||
void checkedIntegers_data();
|
void checkedIntegers_data();
|
||||||
void checkedIntegers();
|
void checkedIntegers();
|
||||||
|
void validationValid_data() { arrays_data(); }
|
||||||
|
void validationValid();
|
||||||
void validation_data();
|
void validation_data();
|
||||||
void validation();
|
void validation();
|
||||||
void strictValidation_data();
|
void strictValidation_data();
|
||||||
@ -256,7 +258,7 @@ CborError parseOneChunk(CborValue *it, QString *parsed)
|
|||||||
if (text)
|
if (text)
|
||||||
*parsed = '"' + QString::fromUtf8(text, len) + '"';
|
*parsed = '"' + QString::fromUtf8(text, len) + '"';
|
||||||
} else {
|
} else {
|
||||||
Q_ASSERT(false);
|
Q_UNREACHABLE();
|
||||||
}
|
}
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
@ -1337,6 +1339,21 @@ void tst_Parser::checkedIntegers()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tst_Parser::validationValid()
|
||||||
|
{
|
||||||
|
// verify that all valid data validate properly
|
||||||
|
QFETCH(QByteArray, data);
|
||||||
|
|
||||||
|
QString decoded;
|
||||||
|
ParserWrapper w;
|
||||||
|
CborError err = w.init(data);
|
||||||
|
QVERIFY2(!err, QByteArray("Got error \"") + cbor_error_string(err) + "\"");
|
||||||
|
|
||||||
|
QCOMPARE(cbor_value_validate_basic(&w.first), CborNoError);
|
||||||
|
QCOMPARE(cbor_value_validate(&w.first, CborValidateBasic), CborNoError);
|
||||||
|
QCOMPARE(cbor_value_validate(&w.first, CborValidateCompleteData), CborNoError);
|
||||||
|
}
|
||||||
|
|
||||||
void tst_Parser::validation_data()
|
void tst_Parser::validation_data()
|
||||||
{
|
{
|
||||||
addValidationColumns();
|
addValidationColumns();
|
||||||
|
@ -32,6 +32,7 @@ QT_WARNING_DISABLE_GCC("-Wunused-function")
|
|||||||
QT_WARNING_DISABLE_CLANG("-Wunused-function")
|
QT_WARNING_DISABLE_CLANG("-Wunused-function")
|
||||||
QT_WARNING_DISABLE_CLANG("-Wundefined-internal")
|
QT_WARNING_DISABLE_CLANG("-Wundefined-internal")
|
||||||
|
|
||||||
|
#define CBOR_NO_HALF_FLOAT_TYPE 1
|
||||||
#define CBOR_NO_VALIDATION_API 1
|
#define CBOR_NO_VALIDATION_API 1
|
||||||
#define CBOR_NO_PRETTY_API 1
|
#define CBOR_NO_PRETTY_API 1
|
||||||
#define CBOR_API static inline
|
#define CBOR_API static inline
|
||||||
|
@ -1487,6 +1487,7 @@ QT_WARNING_DISABLE_CLANG("-Wunused-function")
|
|||||||
QT_WARNING_DISABLE_CLANG("-Wundefined-internal")
|
QT_WARNING_DISABLE_CLANG("-Wundefined-internal")
|
||||||
QT_WARNING_DISABLE_MSVC(4334) // '<<': result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)
|
QT_WARNING_DISABLE_MSVC(4334) // '<<': result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)
|
||||||
|
|
||||||
|
#define CBOR_NO_HALF_FLOAT_TYPE 1
|
||||||
#define CBOR_ENCODER_WRITER_CONTROL 1
|
#define CBOR_ENCODER_WRITER_CONTROL 1
|
||||||
#define CBOR_ENCODER_WRITE_FUNCTION CborDevice::callback
|
#define CBOR_ENCODER_WRITE_FUNCTION CborDevice::callback
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user