mirror of
https://github.com/dolthub/dolt.git
synced 2026-01-31 20:38:55 -06:00
53 lines
1.4 KiB
Cheetah
53 lines
1.4 KiB
Cheetah
{{$typesPackage := .TypesPackage}}
|
|
|
|
// {{.Name}}
|
|
|
|
type {{.Name}} struct {
|
|
target ref.Ref
|
|
ref *ref.Ref
|
|
}
|
|
|
|
func New{{.Name}}(target ref.Ref) {{.Name}} {
|
|
return {{.Name}}{target, &ref.Ref{}}
|
|
}
|
|
|
|
func (r {{.Name}}) TargetRef() ref.Ref {
|
|
return r.target
|
|
}
|
|
|
|
func (r {{.Name}}) Ref() ref.Ref {
|
|
return {{$typesPackage}}EnsureRef(r.ref, r)
|
|
}
|
|
|
|
func (r {{.Name}}) Equals(other {{$typesPackage}}Value) bool {
|
|
return other != nil && __typeRefFor{{.Name}}.Equals(other.TypeRef()) && r.Ref() == other.Ref()
|
|
}
|
|
|
|
func (r {{.Name}}) Chunks() (chunks []ref.Ref) {
|
|
chunks = append(chunks, r.TypeRef().Chunks()...)
|
|
chunks = append(chunks, r.target)
|
|
return
|
|
}
|
|
|
|
// A Noms Value that describes {{.Name}}.
|
|
var __typeRefFor{{.Name}} {{$typesPackage}}TypeRef
|
|
|
|
func (m {{.Name}}) TypeRef() {{$typesPackage}}TypeRef {
|
|
return __typeRefFor{{.Name}}
|
|
}
|
|
|
|
func init() {
|
|
__typeRefFor{{.Name}} = {{toTypesTypeRef .Type .FileID .PackageName}}
|
|
{{$typesPackage}}RegisterFromValFunction(__typeRefFor{{.Name}}, func(v {{$typesPackage}}Value) {{$typesPackage}}Value {
|
|
return New{{.Name}}(v.({{$typesPackage}}Ref).TargetRef())
|
|
})
|
|
}
|
|
|
|
func (r {{.Name}}) TargetValue(cs chunks.ChunkSource) {{userType .ElemType}} {
|
|
return {{valueToUser (printf "%sReadValue(r.target, cs)" $typesPackage) .ElemType}}
|
|
}
|
|
|
|
func (r {{.Name}}) SetTargetValue(val {{userType .ElemType}}, cs chunks.ChunkSink) {{.Name}} {
|
|
return New{{.Name}}({{$typesPackage}}WriteValue({{userToValue "val" .ElemType}}, cs))
|
|
}
|