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
@@ -66,6 +66,12 @@ func (m EnumStruct) TypeRef() types.TypeRef {
return __typeRefForEnumStruct
}
func init() {
types.RegisterFromValFunction(__typeRefForEnumStruct, func(v types.Value) types.NomsValue {
return EnumStructFromVal(v)
})
}
func EnumStructFromVal(val types.Value) EnumStruct {
// TODO: Validate here
return EnumStruct{val.(types.Map)}
@@ -75,14 +81,21 @@ func (s EnumStruct) NomsValue() types.Value {
return s.m
}
func (s EnumStruct) Equals(other EnumStruct) bool {
return s.m.Equals(other.m)
func (s EnumStruct) Equals(other types.Value) bool {
if other, ok := other.(EnumStruct); ok {
return s.m.Equals(other.m)
}
return false
}
func (s EnumStruct) Ref() ref.Ref {
return s.m.Ref()
}
func (s EnumStruct) Chunks() []types.Future {
return s.m.Chunks()
}
func (s EnumStruct) Hand() Handedness {
return Handedness(s.m.Get(types.NewString("hand")).(types.UInt32))
}