v0.0.185 add Meta() to enums
This commit is contained in:
parent
d8270e53ed
commit
0971f60c30
@ -293,15 +293,7 @@ func fmtOutput(cs string, enums []EnumDef, pkgname string) string {
|
||||
str += "" + "\n"
|
||||
|
||||
str += "func (e " + enumdef.EnumTypeName + ") ValuesMeta() []EnumMetaValue {" + "\n"
|
||||
str += " return []EnumMetaValue{" + "\n"
|
||||
for _, v := range enumdef.Values {
|
||||
if hasDescr {
|
||||
str += " " + fmt.Sprintf("EnumMetaValue{VarName: \"%s\", Value: %s, Description: langext.Ptr(\"%s\")},", v.VarName, v.VarName, strings.TrimSpace(*v.Description)) + "\n"
|
||||
} else {
|
||||
str += " " + fmt.Sprintf("EnumMetaValue{VarName: \"%s\", Value: %s, Description: nil},", v.VarName, v.VarName) + "\n"
|
||||
}
|
||||
}
|
||||
str += " }" + "\n"
|
||||
str += " return " + enumdef.EnumTypeName + "ValuesMeta()"
|
||||
str += "}" + "\n"
|
||||
str += "" + "\n"
|
||||
|
||||
@ -330,6 +322,15 @@ func fmtOutput(cs string, enums []EnumDef, pkgname string) string {
|
||||
str += "}" + "\n"
|
||||
str += "" + "\n"
|
||||
|
||||
str += "func (e " + enumdef.EnumTypeName + ") Meta() EnumMetaValue {" + "\n"
|
||||
if hasDescr {
|
||||
str += " return EnumMetaValue{VarName: e.VarName(), Value: e, Description: langext.Ptr(e.Description())}"
|
||||
} else {
|
||||
str += " return EnumMetaValue{VarName: e.VarName(), Value: e, Description: nil}"
|
||||
}
|
||||
str += "}" + "\n"
|
||||
str += "" + "\n"
|
||||
|
||||
str += "func Parse" + enumdef.EnumTypeName + "(vv string) (" + enumdef.EnumTypeName + ", bool) {" + "\n"
|
||||
str += " for _, ev := range __" + enumdef.EnumTypeName + "Values {" + "\n"
|
||||
str += " if string(ev) == vv {" + "\n"
|
||||
@ -348,11 +349,7 @@ func fmtOutput(cs string, enums []EnumDef, pkgname string) string {
|
||||
str += "func " + enumdef.EnumTypeName + "ValuesMeta() []EnumMetaValue {" + "\n"
|
||||
str += " return []EnumMetaValue{" + "\n"
|
||||
for _, v := range enumdef.Values {
|
||||
if hasDescr {
|
||||
str += " " + fmt.Sprintf("EnumMetaValue{VarName: \"%s\", Value: %s, Description: langext.Ptr(\"%s\")},", v.VarName, v.VarName, strings.TrimSpace(*v.Description)) + "\n"
|
||||
} else {
|
||||
str += " " + fmt.Sprintf("EnumMetaValue{VarName: \"%s\", Value: %s, Description: nil},", v.VarName, v.VarName) + "\n"
|
||||
}
|
||||
str += " " + v.VarName + ".Meta(),\n"
|
||||
}
|
||||
str += " }" + "\n"
|
||||
str += "}" + "\n"
|
||||
|
@ -1,5 +1,5 @@
|
||||
package goext
|
||||
|
||||
const GoextVersion = "0.0.184"
|
||||
const GoextVersion = "0.0.185"
|
||||
|
||||
const GoextVersionTimestamp = "2023-07-19T19:29:59+0200"
|
||||
const GoextVersionTimestamp = "2023-07-19T19:34:39+0200"
|
||||
|
Loading…
Reference in New Issue
Block a user