Files
dolt/nomgen/struct.tmpl
2015-08-05 18:43:47 -07:00

30 lines
690 B
Cheetah

// {{.StructName}}
type {{.StructName}} struct {
m types.Map
}
func New{{.StructName}}() {{.StructName}} {
return {{.StructName}}{
types.NewMap(types.NewString("$name"), types.NewString("{{.StructName}}")),
}
}
func {{.StructName}}FromVal(v types.Value) {{.StructName}} {
return {{.StructName}}{v.(types.Map)}
}
// TODO: This was going to be called Value() but it collides with root.value. We need some other place to put the built-in fields like Value() and Equals().
func (s {{.StructName}}) NomsValue() types.Map {
return s.m
}
func (s {{.StructName}}) Equals(p {{.StructName}}) bool {
return s.m.Equals(p.m)
}
func (s {{.StructName}}) Ref() ref.Ref {
return s.m.Ref()
}