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

Making a map item optional worsens it's structure format #416

Open
jnz86 opened this issue Apr 10, 2024 · 1 comment
Open

Making a map item optional worsens it's structure format #416

jnz86 opened this issue Apr 10, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@jnz86
Copy link

jnz86 commented Apr 10, 2024

base = (map_base_t)

map_base_t = {
    first     : ("a" => bstr),
    second    : ("b" => bstr),
    ?third    : ("c" => bstr), 
}

I didn't have time to make it a more simple example. I suspect this is still an issue when removing the sub-types.

In C:

base.first.value = some_pointer;       // OK
base.second.len = 100;                 // OK
base.third_present == true             // OK
base.third.third.value = some_pointer; // Why third.third.?

In types.h:

struct map_base_t_third {
	struct zcbor_string third;
};

struct map_base_t {
	struct zcbor_string first;
	struct zcbor_string second;
	struct map_envelope_t_third third;
	bool third_present;
};

As soon as a map member is made optional, instead of a member like the others, it becomes a map type itself.

Am I doing something wrong with the CDDL? Is this intended behavior? Workaround to get better structure naming?

@oyvindronningstad
Copy link
Collaborator

Thanks for the report and testcase. Will look into this a bit to see if I can improve it.

@oyvindronningstad oyvindronningstad added the enhancement New feature or request label Aug 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants