-
Notifications
You must be signed in to change notification settings - Fork 18
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
asn-compiler: Getting started with Tags resolution (#75) #86
base: master
Are you sure you want to change the base?
Conversation
c32bf99
to
60fb844
Compare
Hey, I'm back a little bit on the CCSDS-SLE thing, and I was looking to complete the BER encoding.
For example in this definition:
Rec1.age has the tag 10 whereas the Rec2.age has the tag 8 coming from MyInt. In the currently generated code, both those sequences make reference to the MyInt type which has tag 8. Not sure how you want to go about this one: |
Answering my own points: pub(crate) struct Asn1ResolvedTag {
num: u32,
class: Asn1TagClass,
mode: Asn1TagMode,
} For the point of overridden definitions it does not make sense to duplicate the type because in our Rust generated code we don't want to end up with two definitions of MyInt. So we can add the tag into the Asn1ResolvedType::Reference(). |
@xpromache : Sorry to get back late to you about this (traveling). I am out of context with this PR and I won't be able to make progress in the near future. Do you think it will help if I merge this open PR so that you can start a new PR? I can do that. |
no need to merge, I started from the branch and I will make a pull request that will include everything. |
@gabhijit I need your advice on something: do you think it is worth turning the asn.1 modules into Rust modules in the generated code? From what I can see now all modules are generated flat in the same file, resulting basically in one Rust module. Splitting in Rust modules may help avoiding some name clashes. It may also help me with the tag definitions - the tag mode (implicit/explicit/auto) are inherited from the module definition and can be overriden in the individual type definition. |
@xpromache : That is indeed a very good idea. I had this in mind as well, but have not been able to spend time on it for a few months due to some other commitments. One big advantage of that is compile time would improve substantially, which is kind of bad at the moment. The way I would typically go about it is - have a top level module say A couple of things that would need to be kept in mind is - when the code is generated the public facing modules ( Makes sense? |
Yes, make sense. I will put the BER encoding aside for a moment and look at the generation of modules. |
@xpromache : We can approach it either way, if it is convenient to split into modules first we can do that. Once we have that support we'll need to increase the minor version number anyways, I was thinking of increasing it on BER support, But if this goes in first that's fine too. |
402783b
to
a919536
Compare
@xpromache : Are you working on this issue and if you have anything that can be merged (it's okay even if it's in partially complete form). I was thinking of picking up this again in the coming days. Let me know if you are in the middle of something and would want to merge something in the next week or so. |
Sorry, I have stared at it for a couple of days not being sure what to do to minimize the amount of changes. Finally I thought I would do this: pub(crate) struct Resolver {
// Resolved definitions
pub(crate) resolved_defs: BTreeMap<String, Asn1ResolvedDefinition>,
// Unresolved Parameterized Definitions used by individual 'Type's to resolve themselves.
pub(crate) parameterized_defs: HashMap<String, Asn1Definition>,
// Object Classes: Used by Objects and Object Sets to resolves themselves.
pub(crate) classes: HashMap<String, Asn1Definition>,
pub(crate) modules: HashMap<String, ResolvedAsn1Module>,
}
struct ResolvedAsn1Module {
// Resolved definitions
pub(crate) resolved_defs: BTreeMap<String, Asn1ResolvedDefinition>,
// Unresolved Parameterized Definitions used by individual 'Type's to resolve themselves.
pub(crate) parameterized_defs: HashMap<String, Asn1Definition>,
// Object Classes: Used by Objects and Object Sets to resolves themselves.
pub(crate) classes: HashMap<String, Asn1Definition>,
} and in the Resolver::resolve_definitions I would move the resolved_defs/parameterized_defs/classes into a new ResolvedAsn1Module. But then I had to switch to something else and didn't check if this idea would actually work.... Pretty sure there would be some more things to adapt when locking up things from modules. |
One idea that I can think of is keeping the module name in the I was planning to take a look at the BER (and Tag resolution) part, is it okay if I keep pushing changes to this? FYI: There were a few fixes that I have rebased this branch against. |
Please go whichever way you see fit. I'm currently busy with some other stuff, I will come back to this when time allows maybe in a couple of months. |
Currently you have resolved_defs: BTreeMap<String, Asn1ResolvedDefinition> what if two definitions in different modules have the same name? |
a919536
to
40a52c4
Compare
Added `Asn1ResolvedTag` to a base type as an `Option`. In the 'resolve' value of each ingeger etc, we'll be resolving the actual tag if present (or the module level support suggests `IMPLICIT/EXPLICIT` tags etc. Right now just basic structure definitions etc.
40a52c4
to
b0a11e1
Compare
Added
Asn1ResolvedTag
to a base type as anOption
. In the 'resolve' value of each ingeger etc, we'll be resolving the actual tag if present (or the module level support suggestsIMPLICIT/EXPLICIT
tags etc.Right now just basic structure definitions etc.