You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by cd...@apache.org on 2022/08/25 08:32:25 UTC
[plc4x] 03/05: chore(code-gen): Fixed some problems related to using startPos and curPos in expressions
This is an automated email from the ASF dual-hosted git repository.
cdutz pushed a commit to branch feature/ads-symbol-discovery
in repository https://gitbox.apache.org/repos/asf/plc4x.git
commit e2c2a90cdb73f70970218914c82d436bbe633538
Author: Christofer Dutz <ch...@c-ware.de>
AuthorDate: Thu Aug 25 10:29:03 2022 +0200
chore(code-gen): Fixed some problems related to using startPos and curPos in expressions
---
.../src/main/resources/templates/go/complex-type-template.go.ftlh | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/code-generation/language-go/src/main/resources/templates/go/complex-type-template.go.ftlh b/code-generation/language-go/src/main/resources/templates/go/complex-type-template.go.ftlh
index d7f09f89f..ea2e9ae40 100644
--- a/code-generation/language-go/src/main/resources/templates/go/complex-type-template.go.ftlh
+++ b/code-generation/language-go/src/main/resources/templates/go/complex-type-template.go.ftlh
@@ -753,8 +753,11 @@ func ${type.name}Parse(readBuffer utils.ReadBuffer<#if hasParserArguments>, ${pa
}
currentPos := positionAware.GetPos()
_ = currentPos
- <#if helper.requiresStartPosAndCurPos()>
+ <#if helper.requiresStartPos() || helper.requiresCurPos()>
var startPos = positionAware.GetPos()
+ _ = startPos
+ </#if>
+ <#if helper.requiresCurPos()>
var curPos uint16
</#if>
<#assign reservedFieldIndex=0>
@@ -996,7 +999,7 @@ func ${type.name}Parse(readBuffer utils.ReadBuffer<#if hasParserArguments>, ${pa
return nil, errors.Wrap(_${constField.name}Err, "Error parsing '${constField.name}' field of ${type.name}")<@emitImport import="github.com/pkg/errors" />
}
if ${constField.name} != ${type.name}_${constField.name?upper_case} {
- return nil, errors.New("Expected constant value " + fmt.Sprintf("%d", ${type.name}_${constField.name?upper_case}) + " but got " + fmt.Sprintf("%d", ${constField.name}))<@emitImport import="github.com/pkg/errors" /><@emitImport import="fmt" />
+ return nil, errors.New("Expected constant value " + fmt.Sprintf("%<#if constField.type.isBooleanTypeReference()>t<#else>d</#if>", ${type.name}_${constField.name?upper_case}) + " but got " + fmt.Sprintf("%<#if constField.type.isBooleanTypeReference()>t<#else>d</#if>", ${constField.name}))<@emitImport import="github.com/pkg/errors" /><@emitImport import="fmt" />
}
<#break>
<#case "discriminator">