diff --git a/bfcodegen/enum-generate.template b/bfcodegen/enum-generate.template index 11c3249..f98b77b 100644 --- a/bfcodegen/enum-generate.template +++ b/bfcodegen/enum-generate.template @@ -75,6 +75,12 @@ func (e {{.EnumTypeName}}) Meta() enums.EnumMetaValue { {{if $hasDescr}} return enums.EnumMetaValue{VarName: e.VarName(), Value: e, Description: langext.Ptr(e.Description())} {{else}} return enums.EnumMetaValue{VarName: e.VarName(), Value: e, Description: nil} {{end}} } +{{if $hasDescr}} +func (e {{.EnumTypeName}}) DescriptionMeta() enums.EnumDescriptionMetaValue { + return enums.EnumDescriptionMetaValue{VarName: e.VarName(), Value: e.String(), Description: e.Description()} +} +{{end}} + func Parse{{.EnumTypeName}}(vv string) ({{.EnumTypeName}}, bool) { for _, ev := range __{{.EnumTypeName}}Values { if string(ev) == vv { @@ -94,4 +100,12 @@ func {{.EnumTypeName}}ValuesMeta() []enums.EnumMetaValue { } } +{{if $hasDescr}} +func (e {{.EnumTypeName}}) ValuesDescriptionMeta() []enums.EnumDescriptionMetaValue { + return []enums.EnumMetaValue{ {{range .Values}} + {{.VarName}}.DescriptionMeta(), {{end}} + } +} +{{end}} + {{end}} \ No newline at end of file diff --git a/enums/enum.go b/enums/enum.go index 0a44196..72de61b 100644 --- a/enums/enum.go +++ b/enums/enum.go @@ -15,10 +15,17 @@ type StringEnum interface { type DescriptionEnum interface { Enum Description() string + DescriptionMeta() EnumDescriptionMetaValue } type EnumMetaValue struct { VarName string `json:"varName"` - Value any `json:"value"` + Value Enum `json:"value"` Description *string `json:"description"` } + +type EnumDescriptionMetaValue struct { + VarName string `json:"varName"` + Value Enum `json:"value"` + Description string `json:"description"` +} diff --git a/goextVersion.go b/goextVersion.go index d8d5ae8..4584137 100644 --- a/goextVersion.go +++ b/goextVersion.go @@ -1,5 +1,5 @@ package goext -const GoextVersion = "0.0.334" +const GoextVersion = "0.0.335" -const GoextVersionTimestamp = "2023-12-05T19:23:27+0100" +const GoextVersionTimestamp = "2023-12-05T19:38:03+0100"