Files
dolt/types/enum.go
Erik Arvidsson 7d4e2df45d Add types.Enum
This is needed to be able to round trip enums.

If there is no codegen for an enum that is read from the datastore we
now return a types.Enum which can be serialized back to the same
sequence.
2015-11-04 16:40:07 -05:00

30 lines
472 B
Go

package types
import "github.com/attic-labs/noms/ref"
type Enum struct {
v uint32
t TypeRef
}
func newEnum(v uint32, t TypeRef) Enum {
return Enum{v, t}
}
func (e Enum) Equals(other Value) bool {
return other != nil && e.t.Equals(other.TypeRef()) && e.Ref() == other.Ref()
}
func (e Enum) Ref() ref.Ref {
throwaway := ref.Ref{}
return EnsureRef(&throwaway, e)
}
func (e Enum) Chunks() []ref.Ref {
return nil
}
func (e Enum) TypeRef() TypeRef {
return e.t
}