NomDL: Make NomsValue a Value

This means that when we ReadValue we can now return a NomsValue

Towards #281
This commit is contained in:
Erik Arvidsson
2015-10-06 11:16:33 -07:00
parent 2dec53453e
commit 9cb7596409
31 changed files with 750 additions and 129 deletions
+15 -2
View File
@@ -67,6 +67,12 @@ func (m {{.Name}}) TypeRef() types.TypeRef {
return __typeRefFor{{.Name}}
}
func init() {
types.RegisterFromValFunction(__typeRefFor{{.Name}}, func(v types.Value) types.NomsValue {
return {{.Name}}FromVal(v)
})
}
func {{.Name}}FromVal(val types.Value) {{.Name}} {
// TODO: Validate here
return {{.Name}}{val.(types.Map)}
@@ -76,14 +82,21 @@ func (s {{.Name}}) NomsValue() types.Value {
return s.m
}
func (s {{.Name}}) Equals(other {{.Name}}) bool {
return s.m.Equals(other.m)
func (s {{.Name}}) Equals(other types.Value) bool {
if other, ok := other.({{.Name}}); ok {
return s.m.Equals(other.m)
}
return false
}
func (s {{.Name}}) Ref() ref.Ref {
return s.m.Ref()
}
func (s {{.Name}}) Chunks() []types.Future {
return s.m.Chunks()
}
{{$name := .Name}}
{{range $index, $field := .Fields}}
{{if .Optional}}