-
Notifications
You must be signed in to change notification settings - Fork 58
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
[Feature request] Declare named bit string positions #196
Comments
@usr3-1415 can you please evaluate the complexity? If you can reuse the mechanisms used for named integers or enumerant with values, I'm in favour of supporting this ASN.1 syntax, which proves useful in some situations. |
feature implemented |
Thank you! I did find a few issues, given this grammar:
and then there are questions related to the Ada version: This is not compatible with the type you generate:
you generate an unsigned_64 constant, which cannot be used with the bit string defined like this:
I think you should rather generate the constants like this:
In order to be able to use them:
However, the current representation of the bit string causes an another issue: because of the custom
If you had a definition of BitArray like this:
....then the bitwise operators would work. The drawback is that existing projects using values 1 and 0 because of the current BIT type would need to be updated to use |
The C version cannot work either with the pattern suggested by @hmpcabral |
One more thing, quoting the book from Mr. Dubuisson:
This seems to comply to the Ada representation (arrary of bits/boolean) but not to the current constants generated in C |
|
@usr3-1415 More insight on this issue:
To illustrate concretely with the generated code:
How can
This is the form used for the generation of ASN.1 constants if you write in the ASN.1 grammar:
However the generated code fails with an error when you try to compile it:
These two functions try to access the array out of range and gnat detects it:
I create two "equivalent" types, one with a
In principle because of the "named bits", BIT STRINGS should be a better option, since for the However at code level we have two different representations (while memory wise they are probably identical):
vs
This little difference however allows SEQUENCE OF BOOLEAN to use Ada built-in bitwise operators on the
I hope this clarifies the point - basically it would be resolved by using the BOOLEAN type instead of the BIT type for BIT STRINGs. |
Update: unfortunately even if the proposed replacement of BIT with BOOLEAN would improve the usability of the type from user perspective, a bigger problem has been found related to a mis-alignment between C and Ada memory layout of the BIT STRING construct. See #290 |
It would be helpful to generate
#define
s for named bit string positions, as in:Which could become something like:
(I tried to understand how to add this feature myself, but unfortunately I have no F# experience and I couldn't quite figure out how to implement it.)
The text was updated successfully, but these errors were encountered: