Skip to content

Commit

Permalink
fix(plc4py): Fix inline if statements and enable integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hutcheb committed May 7, 2024
1 parent 90c8e81 commit 5e74355
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
2 changes: 0 additions & 2 deletions code-generation/language-python/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@
<description>Code generation template for generating Python code</description>

<properties>
<!-- Disabled for now as the python code doesn't seem to build -->
<skip-code-generation-tests>false</skip-code-generation-tests>
<project.build.outputTimestamp>2024-02-16T14:53:02Z</project.build.outputTimestamp>
</properties>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -768,18 +768,10 @@ private String toTernaryTermExpression(Field field, TypeReference fieldType, Ter
Term b = ternaryTerm.getB();
Term c = ternaryTerm.getC();
String castExpressionForTypeReference = getCastExpressionForTypeReference(fieldType);
String inlineIf = "utils.InlineIf(" + toExpression(field, new DefaultBooleanTypeReference(), a, parserArguments, serializerArguments, serialize, false) + ", " +
"func() any {return " + castExpressionForTypeReference + "(" + toExpression(field, fieldType, b, parserArguments, serializerArguments, serialize, false) + ")}, " +
"func() any {return " + castExpressionForTypeReference + "(" + toExpression(field, fieldType, c, parserArguments, serializerArguments, serialize, false) + ")})";
if (fieldType != null) {
if (fieldType instanceof ByteOrderTypeReference) {
return tracer.dive("byteordertypereference") + "(" + inlineIf + ").(binary.ByteOrder)";
}
if (fieldType.isNonSimpleTypeReference()) {
return tracer.dive("nonsimpletypereference") + castExpressionForTypeReference + "(" + inlineIf + ")";
}
return tracer + inlineIf + ".(" + castExpressionForTypeReference + ")";
}
String inlineIf = toExpression(field, fieldType, b, parserArguments, serializerArguments, serialize, false) + " if " +
toExpression(field, new DefaultBooleanTypeReference(), a, parserArguments, serializerArguments, serialize, false) + " else " +
toExpression(field, fieldType, c, parserArguments, serializerArguments, serialize, false);

return tracer + inlineIf;
} else {
throw new FreemarkerException("Unsupported ternary operation type " + ternaryTerm.getOperation());
Expand Down

0 comments on commit 5e74355

Please sign in to comment.