forked from mirror/enumer
use constant names
This commit is contained in:
parent
56342fda5f
commit
9793e421ce
|
@ -61,7 +61,7 @@ func (g *Generator) buildBasicExtras(runs [][]Value, typeName string, runsThresh
|
|||
g.Printf("\nvar _%sValues = []%s{", typeName, typeName)
|
||||
for _, values := range runs {
|
||||
for _, value := range values {
|
||||
g.Printf("\t%s, ", value.str)
|
||||
g.Printf("\t%s, ", value.originalName)
|
||||
}
|
||||
}
|
||||
g.Printf("}\n\n")
|
||||
|
@ -98,8 +98,8 @@ func (g *Generator) printValueMap(runs [][]Value, typeName string, runsThreshold
|
|||
}
|
||||
|
||||
for _, value := range values {
|
||||
g.Printf("\t_%sName%s[%d:%d]: %s,\n", typeName, runID, n, n+len(value.name), &value)
|
||||
g.Printf("\t_%sLowerName%s[%d:%d]: %s,\n", typeName, runID, n, n+len(value.name), &value)
|
||||
g.Printf("\t_%sName%s[%d:%d]: %s,\n", typeName, runID, n, n+len(value.name), value.originalName)
|
||||
g.Printf("\t_%sLowerName%s[%d:%d]: %s,\n", typeName, runID, n, n+len(value.name), value.originalName)
|
||||
n += len(value.name)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -508,6 +508,7 @@ func (g *Generator) format() []byte {
|
|||
|
||||
// Value represents a declared constant.
|
||||
type Value struct {
|
||||
originalName string // The name of the constant before transformation
|
||||
name string // The name of the constant after transformation (i.e. camel case => snake case)
|
||||
// The value is stored as a bit pattern alone. The boolean tells us
|
||||
// whether to interpret it as an int64 or a uint64; the only place
|
||||
|
@ -602,6 +603,7 @@ func (f *File) genDecl(node ast.Node) bool {
|
|||
u64 = uint64(i64)
|
||||
}
|
||||
v := Value{
|
||||
originalName: n.Name,
|
||||
name: n.Name,
|
||||
value: u64,
|
||||
signed: info&types.IsUnsigned == 0,
|
||||
|
|
Loading…
Reference in New Issue