You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by sr...@apache.org on 2023/04/24 09:08:09 UTC
[plc4x] branch develop updated: fix(plc4go/gen): star delegates should now work.
This is an automated email from the ASF dual-hosted git repository.
sruehl pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/plc4x.git
The following commit(s) were added to refs/heads/develop by this push:
new ca5452c402 fix(plc4go/gen): star delegates should now work.
ca5452c402 is described below
commit ca5452c4026ca1535a875c5121a50b9a96103ef7
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Mon Apr 24 11:08:01 2023 +0200
fix(plc4go/gen): star delegates should now work.
---
plc4go/tools/plc4xgenerator/gen.go | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/plc4go/tools/plc4xgenerator/gen.go b/plc4go/tools/plc4xgenerator/gen.go
index e982c20c56..b7eedec04e 100644
--- a/plc4go/tools/plc4xgenerator/gen.go
+++ b/plc4go/tools/plc4xgenerator/gen.go
@@ -396,14 +396,27 @@ func (f *File) genDecl(node ast.Node) bool {
}
if len(field.Names) == 0 {
fmt.Printf("\t adding delegate\n")
- if _, ok := field.Type.(*ast.Ident); ok {
+ switch ft := field.Type.(type) {
+ case *ast.Ident:
f.fields = append(f.fields, Field{
- fieldType: field.Type,
+ fieldType: ft,
isDelegate: true,
isStringer: isStringer,
})
continue
- } else {
+ case *ast.StarExpr:
+ switch set := ft.X.(type) {
+ case *ast.Ident:
+ f.fields = append(f.fields, Field{
+ fieldType: set,
+ isDelegate: true,
+ isStringer: isStringer,
+ })
+ continue
+ default:
+ panic(fmt.Sprintf("Only pointer to struct delegates supported now. Type %T", field.Type))
+ }
+ default:
panic(fmt.Sprintf("Only struct delegates supported now. Type %T", field.Type))
}
}