-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
zcbor.py: Add support for unordered maps in generated code
Add support for the --unordered-maps option to zcbor code which makes use of the zcbor_unordered_maps_*() API in generated code. Signed-off-by: Øyvind Rønningstad <[email protected]>
- Loading branch information
1 parent
4906c54
commit c41c056
Showing
14 changed files
with
534 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
; | ||
; Copyright (c) 2023 Nordic Semiconductor ASA | ||
; | ||
; SPDX-License-Identifier: Apache-2.0 | ||
; | ||
|
||
UnorderedMap1 = { | ||
1 => "one", | ||
2 => "two", | ||
int => bstr, | ||
"foo" => "bar", | ||
bazboz, | ||
*bstr => intlist, | ||
} | ||
|
||
bazboz = ("baz" => "boz") | ||
intlist = [*int] | ||
|
||
UnorderedMap2 = { | ||
+typeUnion, | ||
"map" => { | ||
?-1 => bstr, | ||
?-2 => bstr, | ||
?bool => int, | ||
} | ||
} | ||
|
||
typeUnion = type1 / type2 / typeDefault | ||
type1 = 1 => tstr | ||
type2 = 2 => tstr | ||
typeDefault = int => nil | ||
|
||
UnorderedMap3 = { | ||
1*2000 uint => uint, | ||
1*2000 nint => nint, | ||
} | ||
|
||
group1 = ( | ||
uint => tstr, | ||
nint => bstr, | ||
) | ||
type3 = 3*3group1 | ||
|
||
UnorderedMap4 = { | ||
3*3group1, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# | ||
# Copyright (c) 2021 Nordic Semiconductor ASA | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
cmake_minimum_required(VERSION 3.13.1) | ||
|
||
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) | ||
project(test9_manifest14) | ||
set(MAP_SEARCH_FLAGS ON) # Because of --unordered maps | ||
set(MAP_SMART_SEARCH ON) | ||
include(../../cmake/test_template.cmake) | ||
|
||
set(py_command | ||
${PYTHON_EXECUTABLE} | ||
${CMAKE_CURRENT_LIST_DIR}/../../../zcbor/zcbor.py | ||
code | ||
-c ${CMAKE_CURRENT_LIST_DIR}/../../cases/unordered_map.cddl | ||
--output-cmake ${PROJECT_BINARY_DIR}/unordered_map.cmake | ||
-t | ||
UnorderedMap1 | ||
UnorderedMap2 | ||
UnorderedMap3 | ||
UnorderedMap4 | ||
-d | ||
${bit_arg} | ||
--unordered-maps | ||
) | ||
|
||
execute_process( | ||
COMMAND | ||
${py_command} | ||
COMMAND_ERROR_IS_FATAL ANY | ||
) | ||
|
||
include(${PROJECT_BINARY_DIR}/unordered_map.cmake) | ||
|
||
target_link_libraries(unordered_map PRIVATE zephyr_interface) | ||
target_link_libraries(app PRIVATE unordered_map) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# | ||
# Copyright (c) 2021 Nordic Semiconductor ASA | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
CONFIG_ZTEST=y | ||
CONFIG_ZTEST_STACK_SIZE=131072 |
Oops, something went wrong.