From af38b06d2213dc8a7b81d01218d6a93fd93e73ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Schw=C3=B6rer?= Date: Tue, 5 Dec 2023 19:38:03 +0100 Subject: [PATCH] v0.0.335 added `DescriptionMeta` to enum codegen --- bfcodegen/enum-generate.template | 14 ++++++++++++++ enums/enum.go | 9 ++++++++- goextVersion.go | 4 ++-- 3 files changed, 24 insertions(+), 3 deletions(-) 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"