Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zcbor.py: Add support for unordered maps in generated code #425

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

oyvindronningstad
Copy link
Collaborator

@oyvindronningstad oyvindronningstad commented Apr 30, 2024

Add support for the --unordered-maps option to zcbor code
which makes use of the zcbor_unordered_maps_*() API in generated code.

Fixes #411

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]>
@simensrostad
Copy link

@oyvindronningstad Any traction here? Will we get this for NCS 2.8?

@@ -530,7 +530,7 @@ static inline size_t zcbor_flags_to_states(size_t num_flags)
#define ZCBOR_FLAG_STATES(n_flags) zcbor_flags_to_states(n_flags)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes to zcbor.py is using ZCBOR_FLAG_STATES() in the states[] array size. The IAR C Compiler does not allow inline methods in array size declarations. I was able to work around this by expanding the ZCBOR_FLAG_STATES() macro and not calling zcbor_flags_to_states() (which is then unused and can be removed) . Not sure if that is the best solution, but seems to be working:

#define ZCBOR_ROUND_UP(x, align) (((x) + (align) - 1) / (align) * (align))
#define ZCBOR_FLAG_STATES(num_flags) (ZCBOR_ROUND_UP(num_flags, sizeof(zcbor_state_t) * ZCBOR_BITS_PER_BYTE) / (sizeof(zcbor_state_t) * ZCBOR_BITS_PER_BYTE))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

How does decoding unordered maps work?
3 participants