Skip to content

Commit

Permalink
fix(plc4go): fix issue with generator
Browse files Browse the repository at this point in the history
  • Loading branch information
sruehl committed Aug 1, 2023
1 parent 52ed7ed commit aff7788
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion plc4go/internal/cbus/Subscriber_plc4xgen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plc4go/internal/opcua/Subscriber_plc4xgen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 7 additions & 4 deletions plc4go/tools/plc4xgenerator/gen.go
Expand Up @@ -350,15 +350,18 @@ func (g *Generator) generate(typeName string) {
g.Printf("if err := writeBuffer.PushContext(%s, utils.WithRenderAsList(true)); err != nil {\n\t\treturn err\n\t}\n", fieldNameUntitled)
// TODO: we use serializable or strings as we don't want to over-complex this
g.Printf("for _name, elem := range d.%s {\n", fieldName)
if ident, ok := fieldType.Key.(*ast.Ident); !ok || ident.Name != "string" {
switch ident.Name {
switch keyType := fieldType.Key.(type) {
case *ast.Ident:
switch keyType.Name {
case "uint", "uint8", "uint16", "uint32", "uint64", "int", "int8", "int16", "int32", "int64": // TODO: add other types
g.Printf("\t\tname := fmt.Sprintf(\"%s\", _name)\n", "%v")
case "string":
g.Printf("\t\tname := _name\n")
default:
g.Printf("\t\tname := fmt.Sprintf(\"%s\", &_name)\n", "%v")
}
} else {
g.Printf("\t\tname := _name\n")
default:
g.Printf("\t\tname := fmt.Sprintf(\"%s\", &_name)\n", "%v")
}
switch eltType := fieldType.Value.(type) {
case *ast.StarExpr, *ast.SelectorExpr:
Expand Down

0 comments on commit aff7788

Please sign in to comment.