Skip to content

Commit

Permalink
feat(codegen): Fixed how data-io fields are referenced
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisdutz committed Feb 25, 2022
1 parent 27feac1 commit 9ba8cf2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -965,7 +965,7 @@ func ${type.name}Parse(readBuffer utils.ReadBuffer<#if hasParserArguments>, ${pa
<#assign implicitField = field.asImplicitField().orElseThrow()>
<#assign simpleTypeReference = implicitField.type.asSimpleTypeReference().orElseThrow()>

// Implicit Field (${implicitField.name}) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
// Implicit Field (${implicitField.name}) (Used for parsing, but its value is not stored as it's implicitly given by the objects content)
${implicitField.name}, _${implicitField.name}Err := ${helper.getReadBufferReadMethodCall(implicitField.name, simpleTypeReference, implicitField)}
_ = ${implicitField.name}
if _${implicitField.name}Err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,12 @@ public String getLanguageTypeNameForTypeReference(TypeReference typeReference, b
return "List<" + getLanguageTypeNameForTypeReference(arrayTypeReference.getElementTypeReference(), false) + ">";
}
}
if (!(typeReference instanceof SimpleTypeReference)) {
return ((NonSimpleTypeReference) typeReference).getName();
// DataIo data-types always have properties of type PlcValue
if (typeReference.isDataIoTypeReference()) {
return "PlcValue";
}
if (typeReference.isNonSimpleTypeReference()) {
return typeReference.asNonSimpleTypeReference().orElseThrow().getName();
}
SimpleTypeReference simpleTypeReference = (SimpleTypeReference) typeReference;
switch (simpleTypeReference.getBaseType()) {
Expand Down Expand Up @@ -379,6 +383,11 @@ public String getDataReaderCall(TypeReference typeReference, String resolverMeth
ComplexTypeReference complexTypeReference = typeReference.asComplexTypeReference().orElseThrow(IllegalStateException::new);
ComplexTypeDefinition typeDefinition = complexTypeReference.getTypeDefinition();
String parserCallString = getLanguageTypeNameForTypeReference(typeReference);
// In case of DataIo we actually need to use the type name and not what above returns.
// (In this case the mspec type name and the result type name differ)
if(typeReference.isDataIoTypeReference()) {
parserCallString = typeReference.asDataIoTypeReference().orElseThrow().getName();
}
if (typeDefinition.isDiscriminatedChildTypeDefinition()) {
parserCallString = "(" + getLanguageTypeNameForTypeReference(typeReference) + ") " + typeDefinition.getParentType().orElseThrow().getName();
}
Expand Down

0 comments on commit 9ba8cf2

Please sign in to comment.