aboutsummaryrefslogtreecommitdiffstats
path: root/sysgen
diff options
context:
space:
mode:
authorAndrey Konovalov <andreyknvl@google.com>2017-01-23 15:02:47 +0100
committerAndrey Konovalov <andreyknvl@google.com>2017-01-23 18:13:06 +0100
commitb323c5aaa9b926ba43a9c5435b62b4fce992ff94 (patch)
tree2620c3928f0b1b27f401565eb3d162dd2f254b11 /sysgen
parentcd23722cf2dabd28d83fa321c3cbf50a956d3fb7 (diff)
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.
Diffstat (limited to 'sysgen')
-rw-r--r--sysgen/sysgen.go10
1 files changed, 3 insertions, 7 deletions
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().