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

Generic support for all types #99

Open
rooooooooob opened this issue Sep 27, 2022 · 1 comment
Open

Generic support for all types #99

rooooooooob opened this issue Sep 27, 2022 · 1 comment
Labels
bug Something isn't working CDDL feature Feature that is required for proper parsing of CDDL files

Comments

@rooooooooob
Copy link
Collaborator

rooooooooob commented Sep 27, 2022

For example in [a] or [* a] it seems only for generics we ignore the * and always end up with a single element array. In the non-generic case this is handled properly (I'm not sure which PR fixed this because it used to be an issue for non-generics too with it always interpreting [a] as [* a], i.e. the opposite problem as now)

Consider the following:

single_field_struct = [uint]
uint_array = [*uint]
generic_single_field_struct<a> = [a]
generic_array<a> = [*a]
occurence_test = [
	single_field_struct,
	uint_array,
	gen_single_field: generic_single_field_struct<uint>,
	gen_array: generic_array<uint>,
]

the fields single_field_struct and uint_array correctly generate as a single-uint struct and a Vec<uint> respectively, but the last two fields both generate as a single uint struct even though gen_array should be handled as a Vec<uint> here.

We should always respect the occurrence operators to decide what kind of array (expandable vs fixed single element) in all cases.

@rooooooooob rooooooooob added the bug Something isn't working label Sep 27, 2022
@rooooooooob rooooooooob changed the title Respect occurences for arrays properly Respect occurences for generic arrays properly Sep 28, 2022
@rooooooooob rooooooooob changed the title Respect occurences for generic arrays properly Generic support for all types Sep 28, 2022
@rooooooooob
Copy link
Collaborator Author

It seems this isn't limited to arrays. We should support generics in all types. We have a todo!() for T / null generics too. The current implementation doesn't resolve for RustType::GroupChoice or RustType::Wrapper but at least we should handle the types we claim to support (arrays/tables/type choices) without issues.

@SebastienGllmt SebastienGllmt added the CDDL feature Feature that is required for proper parsing of CDDL files label Feb 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working CDDL feature Feature that is required for proper parsing of CDDL files
Projects
None yet
Development

No branches or pull requests

2 participants