Files
dolt/nomdl/codegen/ref.tmpl
Erik Arvidsson 9cb7596409 NomDL: Make NomsValue a Value
This means that when we ReadValue we can now return a NomsValue

Towards #281
2015-10-06 16:38:11 -07:00

44 lines
877 B
Cheetah

// {{.Name}}
type {{.Name}} struct {
r ref.Ref
}
func New{{.Name}}(r ref.Ref) {{.Name}} {
return {{.Name}}{r}
}
func (r {{.Name}}) Ref() ref.Ref {
return r.r
}
func (r {{.Name}}) Equals(other types.Value) bool {
if other, ok := other.({{.Name}}); ok {
return r.r == other.r
}
return false
}
func (r {{.Name}}) Chunks() []types.Future {
return nil
}
func (r {{.Name}}) NomsValue() types.Value {
return types.Ref{R: r.r}
}
func {{.Name}}FromVal(p types.Value) {{.Name}} {
return {{.Name}}{p.(types.Ref).Ref()}
}
{{template "type_ref.tmpl" .}}
func (r {{.Name}}) GetValue(cs chunks.ChunkSource) {{userType .ElemType}} {
return {{valueToUser "types.ReadValue(r.r, cs)" .ElemType}}
}
func (r {{.Name}}) SetValue(val {{userType .ElemType}}, cs chunks.ChunkSink) {{.Name}} {
ref := types.WriteValue({{userToValue "val" .ElemType}}, cs)
return {{.Name}}{ref}
}