-
Notifications
You must be signed in to change notification settings - Fork 523
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
Adding support for the package attribute on the types element. #904
Conversation
@mjpt777 @tmontgomery Hi, subject to Your time permitting, I'd appreciate a 1st, rough review of this. Thanks. |
Sorry but we have been busy. We need to give priority to our commercial support customers. |
Sure, take your time. Just wanted to make sure this blipped on your radar. |
@@ -52,7 +52,8 @@ public CodeGenerator newInstance(final Ir ir, final String outputDir) | |||
"true".equals(System.getProperty(JAVA_GROUP_ORDER_ANNOTATION)), | |||
"true".equals(System.getProperty(JAVA_GENERATE_INTERFACES)), | |||
"true".equals(System.getProperty(DECODE_UNKNOWN_ENUM_VALUES)), | |||
new PackageOutputManager(outputDir, ir.applicableNamespace())); | |||
"true".equals(System.getProperty(TYPE_PACKAGE_OVERRIDE)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this default to true
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unless TYPE_PACKAGE_OVERRIDE
is explicitly set to true
, the generator will not respect package overrides, therefore behave like before this change - unless I am missing something here?
sbe-tool/src/main/java/uk/co/real_logic/sbe/generation/java/JavaOutputManager.java
Outdated
Show resolved
Hide resolved
{ | ||
|
||
private final String baseDirName; | ||
private final PackageOutputManager global; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Naming should be more explicit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Naming's difficult. But tried to do my best.
@@ -105,6 +107,7 @@ | |||
public Token( | |||
final Signal signal, | |||
final String name, | |||
final String packageName, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should come at end of string args as new.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@@ -361,6 +375,7 @@ public String toString() | |||
{ | |||
private Signal signal; | |||
private String name; | |||
private String packageName; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the default for packageName
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Set the default to null. Also added explanation to the javadoc.
sbe-tool/src/main/java/uk/co/real_logic/sbe/generation/java/JavaOutputManager.java
Outdated
Show resolved
Hide resolved
Created real-logic/agrona#266 for the required changes in agrona. |
…putManager). Should be replaced with a new version of Agrona.
@ratcashdev Agrona 1.17.0 was released and it contains real-logic/agrona#266. |
updated to latest master. |
actingPackageOutputManager = basePackageOutputManager; | ||
} | ||
|
||
@Override |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@OverRide not used in code style.
*/ | ||
public static String getTypesPackageAttribute(final Node elementNode) | ||
{ | ||
return getAttributeValue(elementNode.getParentNode(), "package", null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not likely to be sufficient for nested composites or ref types as the parent will be different.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True. I need to write a test case for this. So we speak about two cases as below?
...
<messageSchema package="composite.elements"
id="3"
semanticVersion="5.2"
description="Unit Test"
byteOrder="littleEndian">
<types package="specific.package.name">
<composite name="messageHeader" description="Message identifiers and length of message root">
<type name="blockLength" primitiveType="uint16"/>
<type name="templateId" primitiveType="uint16"/>
<type name="schemaId" primitiveType="uint16"/>
<type name="version" primitiveType="uint16"/>
</composite>
...
<!-- case number 1 -->
<enum name="booleanEnum" encodingType="uint8" semanticType="Boolean">
<validValue name="F">0</validValue>
<validValue name="T">1</validValue>
</enum>
<composite name="futuresPrice">
<type name="mantissa" primitiveType="int64" />
<type name="exponent" primitiveType="int8" />
<ref name="isSettlement" type="booleanEnum" offset="10" />
</composite>
<!-- case number 2 -->
<composite name="outer">
<enum name="enumOne" description="enum as uint8" encodingType="uint8" semanticType="int">
<validValue name="Value1">1</validValue>
<validValue name="Value10">10</validValue>
</enum>
<type name="zeroth" primitiveType="uint8"/>
<set name="setOne" description="set as uint32" encodingType="uint32" semanticType="int">
<choice name="Bit0">0</choice>
<choice name="Bit16">16</choice>
<choice name="Bit26">26</choice>
</set>
<composite name="inner">
<type name="first" primitiveType="int64"/>
<type name="second" primitiveType="int64"/>
</composite>
</composite>
</types>
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes these cases and consider the likes of: https://github.com/real-logic/simple-binary-encoding/blob/master/sbe-samples/src/main/resources/example-schema.xml#L32-L34
BTW I've pushed a change to better find the ancestor <types>
element.
Ok, will enhance the tests as a separate PR. Thanks for the fix. |
just realized, the case below also needs to be taken care of or at least tested (REF pointing to a type in a different package): <types package="specific.package.name.A">
<enum name="booleanEnum" encodingType="uint8" semanticType="Boolean">
<validValue name="F">0</validValue>
<validValue name="T">1</validValue>
</enum>
</types>
<types package="specific.package.name.B">
<composite name="futuresPrice">
<type name="mantissa" primitiveType="int64" />
<type name="exponent" primitiveType="int8" />
<ref name="isSettlement" type="booleanEnum" offset="10" />
</composite>
</types> |
Yes the |
When do you think you can address this? |
Apologies, got sick for the past week, still on meds. Fingers cross - this week. |
please have a look on #915 |
Implementation of #507 for Java.
The main idea is that we store the package attribute read from the XML to the IR, into token[0]. Then it's up to the generator to make use of that extra piece of information (controllable through
sbe.type.package.override
argument, defaulting tofalse
).The serialization of the IR is not touched, therefore the package information is not present in the serialized IR.
Some classes in this PR, like the
MultiPackageOutputManager
andStringWriterOutputManager
actually belong to agrona, but have been implemented here to have a testable code.Before merging, those files/classes should be moved and substituted with a new release of agrona.