mirror of
https://github.com/dolthub/dolt.git
synced 2026-02-05 02:59:44 -06:00
We now do a recursive call which bottoms out with a ref.Ref for RefKind Values. This means that we traverse into nested structures consistently. The effect of this is that we get all the refs that the current chunk references.
49 lines
1.2 KiB
Cheetah
49 lines
1.2 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
|
|
}
|
|
|
|
func {{.Name}}FromVal(val {{$typesPackage}}Value) {{.Name}} {
|
|
// TODO: Do we still need FromVal?
|
|
if val, ok := val.({{.Name}}); ok {
|
|
return val
|
|
}
|
|
return New{{.Name}}(val.({{$typesPackage}}Ref).TargetRef())
|
|
}
|
|
|
|
{{template "type_ref.tmpl" .}}
|
|
|
|
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))
|
|
}
|