mirror of
https://github.com/mappu/miqt.git
synced 2024-12-22 17:08:38 +00:00
genbindings/go: simpler enum naming
This commit is contained in:
parent
d0e28fa69c
commit
6a958309b0
@ -405,8 +405,18 @@ import "C"
|
|||||||
continue // Removed by transformRedundant AST pass
|
continue // Removed by transformRedundant AST pass
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fully qualified name of the enum itself
|
||||||
goEnumName := cabiClassName(e.EnumName)
|
goEnumName := cabiClassName(e.EnumName)
|
||||||
|
|
||||||
|
// Shorter name, so that enum elements are reachable from the surrounding
|
||||||
|
// namespace
|
||||||
|
// Strip back one single :: pair from the generated variable name
|
||||||
|
nameParts := strings.Split(e.EnumName, `::`)
|
||||||
|
if len(nameParts) > 1 {
|
||||||
|
nameParts = nameParts[0 : len(nameParts)-1]
|
||||||
|
}
|
||||||
|
goEnumShortName := cabiClassName(strings.Join(nameParts, `::`))
|
||||||
|
|
||||||
ret.WriteString(`
|
ret.WriteString(`
|
||||||
type ` + goEnumName + ` ` + e.UnderlyingType.RenderTypeGo() + `
|
type ` + goEnumName + ` ` + e.UnderlyingType.RenderTypeGo() + `
|
||||||
`)
|
`)
|
||||||
@ -416,7 +426,7 @@ import "C"
|
|||||||
ret.WriteString("const (\n")
|
ret.WriteString("const (\n")
|
||||||
|
|
||||||
for _, ee := range e.Entries {
|
for _, ee := range e.Entries {
|
||||||
ret.WriteString(cabiClassName(goEnumName+"::"+ee.EntryName) + " " + goEnumName + " = " + ee.EntryValue + "\n")
|
ret.WriteString(titleCase(cabiClassName(goEnumShortName+"::"+ee.EntryName)) + " " + goEnumName + " = " + ee.EntryValue + "\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
ret.WriteString("\n)\n\n")
|
ret.WriteString("\n)\n\n")
|
||||||
|
Loading…
Reference in New Issue
Block a user