Skip to content

Commit 2f4c399

Browse files
committed
tinycbor: Pulling in patch from mynewt upstream PR
- Pulling in code from intel/tinycbor#83 as a patch to zephyr's ext/tinycbor. This is to facilitate the use of chained buffers functionality for tinycbor while it is in development on https://github.com/intel/tinycbor - Bring tinycbor up to date with mynewt tinycbor - Changing implementation of cbor_encoder_get_extra_bytes_needed() and cbor_encoder_get_buffer_size() as part of cbor_buf_writer APIs - Move bytes_needed field from CborEncoder to the buf writer, this is needed by the tests mainly. - Fix cbor_buf_cmp to do memcmp and return complemented result iterate_string_chunks(): fixing NULL compare at the end of string and moving it out of the iterate_string_chunks(). This is to avoid buffer specific parser calls in the function - cbor_value_get_next_byte() is removed in mynewt version of tinycbor, so, we track offsets of the buffer which can be used for comparison in the parser tests instead of calculating the offset - Making the decoder and parser APIs backwards compatible - Adding encoder writer and parser reader as part of the encoder and parser structure. This is to make the encoder and parser use new function of encoder_writer and decoder_reader without breaking backwards compatibility. - Making the old API use flat buffers by default - Adding APIs for initializing encoder and parser with custom writer and reader - Make the default writer and reader conditional based on NO_DFLT_READER/WRITER define. This is because we want a default reader/writer to avoid API changes. - Use it->offset instead of it->ptr to track buffer offsets - Update resolve_indicator() static api parameters to use cbor value and access offsets instead of taking pointers as input parameters - In validate_container() do a byte by byte comparison instead of memcmp since we no longer have access to the buffer directly - Also, use offsets instead of pointers to validate sorted maps - Added a new define for conditionally compiling in float support (NO_FLOAT_SUPPORT). - This is because we want the float support to be compiled in by default. - Use static_assert macro instead of Static_assert. Changed to avoid build failures. - Add api to get string chunk, this is a callback which can be used by buffer implementations to grab a string that is divided in chunks which spans across multiple chained buffers - Add KConfig and CMakeList files for configuration and build - Delete .gitignore and .gitattributes - Remove tools, tests and examples as they are not really needed for building the library Signed-off-by: Vipul Rahane <[email protected]>
1 parent 3f85f24 commit 2f4c399

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+978
-5236
lines changed

ext/Kconfig

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ source "ext/hal/Kconfig"
1212

1313
source "ext/lib/crypto/Kconfig"
1414

15+
source "ext/lib/encoding/Kconfig"
16+
1517
source "ext/debug/Kconfig"
1618

1719
endmenu

ext/lib/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
add_subdirectory(crypto)
2+
add_subdirectory(encoding)

ext/lib/encoding/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
add_subdirectory_if_kconfig(tinycbor)

ext/lib/encoding/Kconfig

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing,
13+
# software distributed under the License is distributed on an
14+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
# KIND, either express or implied. See the License for the
16+
# specific language governing permissions and limitations
17+
# under the License.
18+
#
19+
20+
menu "Encoding"
21+
22+
source "ext/lib/encoding/tinycbor/Kconfig"
23+
24+
endmenu

ext/lib/encoding/tinycbor/.appveyor.yml

-35
This file was deleted.

ext/lib/encoding/tinycbor/.gitattributes

-4
This file was deleted.

ext/lib/encoding/tinycbor/.gitignore

-81
This file was deleted.

ext/lib/encoding/tinycbor/.tag

-1
This file was deleted.

ext/lib/encoding/tinycbor/.travis.yml

-60
This file was deleted.
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
zephyr_interface_library_named(TINYCBOR)
2+
3+
target_include_directories(TINYCBOR INTERFACE src)
4+
5+
zephyr_library()
6+
zephyr_library_sources(
7+
src/cbor_buf_reader.c
8+
src/cbor_buf_writer.c
9+
src/cborencoder.c
10+
src/cborerrorstrings.c
11+
src/cborparser.c
12+
)
13+
zephyr_library_link_libraries(TINYCBOR)
14+
target_link_libraries(TINYCBOR INTERFACE zephyr_interface)

ext/lib/encoding/tinycbor/Kconfig

+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing,
13+
# software distributed under the License is distributed on an
14+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
# KIND, either express or implied. See the License for the
16+
# specific language governing permissions and limitations
17+
# under the License.
18+
#
19+
20+
config TINYCBOR
21+
bool
22+
prompt "tinyCBOR Support"
23+
default n
24+
help
25+
This option enables the tinyCBOR library.
26+
27+
config CBOR_NO_DFLT_WRITER
28+
bool
29+
depends on TINYCBOR
30+
prompt "No default writer"
31+
default n
32+
help
33+
This option specifies whether a default writer exists.
34+
35+
config CBOR_NO_DFLT_READER
36+
bool
37+
depends on TINYCBOR
38+
prompt "No default reader"
39+
default n
40+
help
41+
This option specifies whether a default reader exists.
42+
43+
config CBOR_ENCODER_NO_CHECK_USER
44+
bool
45+
depends on TINYCBOR
46+
prompt "No check user for cbor encoder"
47+
default n
48+
help
49+
This option specifies whether a check user exists for a cbor encoder.
50+
51+
config CBOR_PARSER_MAX_RECURSIONS
52+
int
53+
depends on TINYCBOR
54+
prompt "Parser max recursions"
55+
default 1024
56+
help
57+
This option specifies max recursions for the parser.
58+
59+
config CBOR_PARSER_NO_STRICT_CHECKS
60+
bool
61+
depends on TINYCBOR
62+
prompt "No strict parser checks"
63+
default n
64+
help
65+
This option enables the strict parser checks.
66+
67+
config CBOR_NO_FLOATING_POINT
68+
bool
69+
depends on TINYCBOR
70+
prompt "No floating point support"
71+
default n
72+
help
73+
This option enables floating point support.
74+
75+
config CBOR_NO_HALF_FLOAT_TYPE
76+
bool
77+
depends on TINYCBOR
78+
prompt "No half float type"
79+
default n
80+
help
81+
This option enables half float type support.
82+
83+
config CBOR_WITHOUT_OPEN_MEMSTREAM
84+
bool
85+
depends on TINYCBOR
86+
prompt "without open memstream"
87+
default n
88+
help
89+
This option enables open memstream support.

0 commit comments

Comments
 (0)