Skip to content

Make Choice recursive#42

Merged
lemontree55 merged 7 commits intomasterfrom
recursive-choice
Jan 2, 2025
Merged

Make Choice recursive#42
lemontree55 merged 7 commits intomasterfrom
recursive-choice

Conversation

@lemontree55
Copy link
Owner

Choice is now recursive when using a Wrapper:

class RecursiveModel < RASN1::Model
  choice :recursive,
         content: [
           octet_string(:present, implicit: 1),
           wrapper(model(:model, RecursiveModel), implicit: 2)
         ]
end

This method must generate inner element if wrapper is lazy. This is done in #element  by calling #lazy_generation
It now returns an empty array.
#do_parse and #do_parse_explicit are marked as private API.
Choice now implements a full #parse! method. It also
implements #do_parse and #der_to_value.

This is done to make #parse! only pase tag and length, and let element parse itself its content through #der_to_value.
Thus, parsing advances on DER string, and no more call #parse! recursively on the same DER string (which raised a stack error).
@lemontree55 lemontree55 mentioned this pull request Jan 2, 2025
@lemontree55 lemontree55 merged commit ee04c2b into master Jan 2, 2025
7 checks passed
@lemontree55 lemontree55 deleted the recursive-choice branch January 2, 2025 14:21
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.

1 participant