Repository navigation
[Java] Set presence on enum encodings in IR. - #1146
Open
d0ra-1h3-3xpl0ra wants to merge 1 commit into
Open
d0ra-1h3-3xpl0ra wants to merge 1 commit into
d0ra-1h3-3xpl0ra wants to merge 1 commit into
Conversation
The BEGIN_ENUM/END_ENUM tokens always carried REQUIRED presence because IrGenerator never set it on the enum encoding. They are now OPTIONAL when the enum type is optional, either through its own presence attribute or because its encodingType names an optional type, e.g. uInt8NULL in CME iLink schemas. A field's presence remains on the BEGIN_FIELD token only.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1063.
IrGeneratornever set presence on theBEGIN_ENUM/END_ENUMencoding, so it was alwaysREQUIRED. It is nowOPTIONALwhen the enum type is optional: either its ownpresenceattribute is optional, or itsencodingTypenames an optional type (e.g.uInt8NULLin the CME iLink schemas). Everything else staysREQUIRED;constantis not propagated.A field's own
presencestays on theBEGIN_FIELDtoken, where generators already read it. The enum token describes the type, like compositeENCODINGtokens, and it is shared throughIr.types(), so it shouldn't depend on which field referenced it. OTF users read the value from theBEGIN_ENUMtoken (tokens[fromIndex]inonEnum).Generated code: I generated all 84 valid schemas in the repo before and after, for Java (+DTOs), C++ (+DTOs, +IR), C, C#, Go (struct and flyweight) and Rust, and the sources are byte-identical. Only the
.sbeirof the 5 schemas that use an optional enum changes. One case no repo schema covers is an optional enum inside a composite:PRESENCEmeta attribute becomes"optional";<name>_optsetter thatRustGeneratoralready has a branch for. The generated crate compiles.The Java build and tests pass. I didn't run the C++/C, Go and C# test suites locally.