Files
dolt/nomdl/codegen/enum.tmpl
Erik Arvidsson a72ce41a1d Go: TypeRef -> Type
Remaining identifiers
2015-11-13 17:54:53 -05:00

51 lines
1.1 KiB
Cheetah

{{$typesPackage := .TypesPackage}}
// {{.Name}}
type {{.Name}} uint32
{{$name := .Name}}
const ({{range $index, $id := .Ids}}
{{title $id}}{{if eq $index 0}} {{$name}} = iota{{end}}{{end}}
)
func New{{.Name}}() {{.Name}} {
return {{.Name}}(0)
}
var __typeFor{{.Name}} {{$typesPackage}}Type
func (e {{.Name}}) Type() {{$typesPackage}}Type {
return __typeFor{{.Name}}
}
func init() {
__typeFor{{.Name}} = {{$typesPackage}}MakeType(__{{.PackageName}}PackageInFile_{{.FileID}}_CachedRef, {{.Ordinal}})
{{$typesPackage}}RegisterEnum(__typeFor{{.Name}}, builderFor{{.Name}}, readerFor{{.Name}})
}
func builderFor{{.Name}}(v uint32) {{$typesPackage}}Value {
return {{.Name}}(v)
}
func readerFor{{.Name}}(v {{$typesPackage}}Value) uint32 {
return uint32(v.({{.Name}}))
}
func (e {{.Name}}) Equals(other {{$typesPackage}}Value) bool {
return e == other
}
func (e {{.Name}}) Ref() ref.Ref {
throwaway := ref.Ref{}
return {{$typesPackage}}EnsureRef(&throwaway, e)
}
func (e {{.Name}}) Chunks() []ref.Ref {
return nil
}
func (e {{.Name}}) ChildValues() []{{$typesPackage}}Value {
return nil
}