From b323c5aaa9b926ba43a9c5435b62b4fce992ff94 Mon Sep 17 00:00:00 2001 From: Andrey Konovalov Date: Mon, 23 Jan 2017 15:02:47 +0100 Subject: prog: add FieldName to Type FieldName() is the name of the struct field or union option with this type. TypeName() is now always the name of the type. --- sysgen/sysgen.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'sysgen') diff --git a/sysgen/sysgen.go b/sysgen/sysgen.go index 867561ad7..6906c7697 100644 --- a/sysgen/sysgen.go +++ b/sysgen/sysgen.go @@ -265,10 +265,6 @@ func generateStructEntry(str Struct, key structKey, out io.Writer) { if str.IsUnion { typ = "UnionType" } - name := key.field - if name == "" { - name = key.name - } packed := "" if str.Packed { packed = ", packed: true" @@ -281,8 +277,8 @@ func generateStructEntry(str Struct, key structKey, out io.Writer) { if str.Align != 0 { align = fmt.Sprintf(", align: %v", str.Align) } - fmt.Fprintf(out, "\"%v\": &%v{TypeCommon: TypeCommon{TypeName: \"%v\", ArgDir: %v, IsOptional: %v} %v %v %v},\n", - key, typ, name, fmtDir(key.dir), false, packed, align, varlen) + fmt.Fprintf(out, "\"%v\": &%v{TypeCommon: TypeCommon{TypeName: \"%v\", FldName: \"%v\", ArgDir: %v, IsOptional: %v} %v %v %v},\n", + key, typ, key.name, key.field, fmtDir(key.dir), false, packed, align, varlen) } func generateStructFields(str Struct, key structKey, desc *Description, consts map[string]uint64, out io.Writer) { @@ -379,7 +375,7 @@ func generateArg( } } common := func() string { - return fmt.Sprintf("TypeCommon: TypeCommon{TypeName: %v, ArgDir: %v, IsOptional: %v}", name, fmtDir(dir), opt) + return fmt.Sprintf("TypeCommon: TypeCommon{TypeName: \"%v\", FldName: %v, ArgDir: %v, IsOptional: %v}", typ, name, fmtDir(dir), opt) } intCommon := func(typeSize uint64, bigEndian bool, bitfieldLen uint64) string { // BitfieldOff and BitfieldLst will be filled in in initAlign(). -- cgit mrf-deployment