Skip to content

Commit

Permalink
feat(plc4go/gen): added byte support
Browse files Browse the repository at this point in the history
  • Loading branch information
sruehl committed Jun 13, 2023
1 parent 2931bd6 commit d06433b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions plc4go/tools/plc4xgenerator/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,8 @@ func (g *Generator) generate(typeName string) {
g.Printf(serializableFieldTemplate, "d."+field.name, fieldNameUntitled)
case *ast.Ident:
switch fieldType.Name {
case "byte":
g.Printf(byteFieldSerialize, "d."+field.name, fieldNameUntitled)
case "int":
g.Printf(int64FieldSerialize, "int64(d."+field.name+")", fieldNameUntitled)
case "int32":
Expand Down Expand Up @@ -534,6 +536,12 @@ var serializableFieldTemplate = `
}
`

var byteFieldSerialize = `
if err := writeBuffer.WriteByte(%[2]s, %[1]s); err != nil {
return err
}
`

var int32FieldSerialize = `
if err := writeBuffer.WriteInt32(%[2]s, 32, %[1]s); err != nil {
return err
Expand Down

0 comments on commit d06433b

Please sign in to comment.