mirror of
https://github.com/cloudflare/cloudflared.git
synced 2025-07-28 16:39:57 +00:00
TUN-528: Move cloudflared into a separate repo
This commit is contained in:
55
vendor/zombiezen.com/go/capnproto2/capnpc-go/templates/enum
generated
vendored
Normal file
55
vendor/zombiezen.com/go/capnproto2/capnpc-go/templates/enum
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
{{with .Annotations.Doc -}}
|
||||
// {{.}}
|
||||
{{end -}}
|
||||
type {{.Node.Name}} uint16
|
||||
|
||||
{{ template "_typeid" .Node }}
|
||||
|
||||
{{with .EnumValues -}}
|
||||
// Values of {{$.Node.Name}}.
|
||||
const (
|
||||
{{range . -}}
|
||||
{{.FullName}} {{$.Node.Name}} = {{.Val}}
|
||||
{{end}}
|
||||
)
|
||||
|
||||
// String returns the enum's constant name.
|
||||
func (c {{$.Node.Name}}) String() string {
|
||||
switch c {
|
||||
{{range . -}}
|
||||
{{if .Tag}}case {{.FullName}}: return {{printf "%q" .Tag}}
|
||||
{{end}}
|
||||
{{- end}}
|
||||
default: return ""
|
||||
}
|
||||
}
|
||||
|
||||
// {{$.Node.Name}}FromString returns the enum value with a name,
|
||||
// or the zero value if there's no such value.
|
||||
func {{$.Node.Name}}FromString(c string) {{$.Node.Name}} {
|
||||
switch c {
|
||||
{{range . -}}
|
||||
{{if .Tag}}case {{printf "%q" .Tag}}: return {{.FullName}}
|
||||
{{end}}
|
||||
{{- end}}
|
||||
default: return 0
|
||||
}
|
||||
}
|
||||
{{end}}
|
||||
|
||||
type {{.Node.Name}}_List struct { {{$.G.Capnp}}.List }
|
||||
|
||||
func New{{.Node.Name}}_List(s *{{$.G.Capnp}}.Segment, sz int32) ({{.Node.Name}}_List, error) {
|
||||
l, err := {{.G.Capnp}}.NewUInt16List(s, sz)
|
||||
return {{.Node.Name}}_List{l.List}, err
|
||||
}
|
||||
|
||||
func (l {{.Node.Name}}_List) At(i int) {{.Node.Name}} {
|
||||
ul := {{.G.Capnp}}.UInt16List{List: l.List}
|
||||
return {{.Node.Name}}(ul.At(i))
|
||||
}
|
||||
|
||||
func (l {{.Node.Name}}_List) Set(i int, v {{.Node.Name}}) {
|
||||
ul := {{.G.Capnp}}.UInt16List{List: l.List}
|
||||
ul.Set(i, uint16(v))
|
||||
}
|
Reference in New Issue
Block a user