mirror of
https://github.com/dolthub/dolt.git
synced 2026-04-26 03:30:09 -05:00
Updated generated code
This commit is contained in:
@@ -14,8 +14,8 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/attic-labs/noms/Godeps/_workspace/src/github.com/garyburd/go-oauth/oauth"
|
||||
img "github.com/attic-labs/noms/clients/gen/sha1_4c734206e6aaef5464ff0e307c2f66751a1469de"
|
||||
geo "github.com/attic-labs/noms/clients/gen/sha1_52bbaa7c5bcb39759981ccb12ee457f21fa7517d"
|
||||
img "github.com/attic-labs/noms/clients/gen/sha1_b525f9bca5e451c21dd9af564f0960045fbaa304"
|
||||
geo "github.com/attic-labs/noms/clients/gen/sha1_fb09d21d144c518467325465327d46489cff7c47"
|
||||
"github.com/attic-labs/noms/clients/util"
|
||||
"github.com/attic-labs/noms/d"
|
||||
"github.com/attic-labs/noms/dataset"
|
||||
@@ -189,7 +189,7 @@ func getAlbums() MapOfStringToAlbum {
|
||||
return albums
|
||||
}
|
||||
|
||||
func getAlbumPhotos(id string) SetOfsha1_4c734206e6aaef5464ff0e307c2f66751a1469de_RemotePhoto {
|
||||
func getAlbumPhotos(id string) SetOfsha1_b525f9bca5e451c21dd9af564f0960045fbaa304_RemotePhoto {
|
||||
response := struct {
|
||||
flickrCall
|
||||
Photoset struct {
|
||||
@@ -226,7 +226,7 @@ func getAlbumPhotos(id string) SetOfsha1_4c734206e6aaef5464ff0e307c2f66751a1469d
|
||||
})
|
||||
d.Chk.NoError(err)
|
||||
|
||||
photos := NewSetOfsha1_4c734206e6aaef5464ff0e307c2f66751a1469de_RemotePhoto()
|
||||
photos := NewSetOfsha1_b525f9bca5e451c21dd9af564f0960045fbaa304_RemotePhoto()
|
||||
|
||||
for _, p := range response.Photoset.Photo {
|
||||
photo := img.RemotePhotoDef{
|
||||
|
||||
+131
-90
@@ -3,7 +3,8 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/attic-labs/noms/clients/gen/sha1_4c734206e6aaef5464ff0e307c2f66751a1469de"
|
||||
"github.com/attic-labs/noms/clients/gen/sha1_b525f9bca5e451c21dd9af564f0960045fbaa304"
|
||||
|
||||
"github.com/attic-labs/noms/ref"
|
||||
"github.com/attic-labs/noms/types"
|
||||
)
|
||||
@@ -29,12 +30,12 @@ func __mainPackageInFile_types_Ref() ref.Ref {
|
||||
[]types.Field{
|
||||
types.Field{"Id", types.MakePrimitiveTypeRef(types.StringKind), false},
|
||||
types.Field{"Title", types.MakePrimitiveTypeRef(types.StringKind), false},
|
||||
types.Field{"Photos", types.MakeCompoundTypeRef("", types.SetKind, types.MakeTypeRef(ref.Parse("sha1-4c734206e6aaef5464ff0e307c2f66751a1469de"), 0)), false},
|
||||
types.Field{"Photos", types.MakeCompoundTypeRef("", types.SetKind, types.MakeTypeRef(ref.Parse("sha1-b525f9bca5e451c21dd9af564f0960045fbaa304"), 0)), false},
|
||||
},
|
||||
types.Choices{},
|
||||
),
|
||||
}, []ref.Ref{
|
||||
ref.Parse("sha1-4c734206e6aaef5464ff0e307c2f66751a1469de"),
|
||||
ref.Parse("sha1-b525f9bca5e451c21dd9af564f0960045fbaa304"),
|
||||
})
|
||||
return types.RegisterPackage(&p)
|
||||
}
|
||||
@@ -42,7 +43,8 @@ func __mainPackageInFile_types_Ref() ref.Ref {
|
||||
// User
|
||||
|
||||
type User struct {
|
||||
m types.Map
|
||||
m types.Map
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewUser() User {
|
||||
@@ -52,8 +54,8 @@ func NewUser() User {
|
||||
types.NewString("Name"), types.NewString(""),
|
||||
types.NewString("OAuthToken"), types.NewString(""),
|
||||
types.NewString("OAuthSecret"), types.NewString(""),
|
||||
types.NewString("Albums"), types.NewMap(),
|
||||
)}
|
||||
types.NewString("Albums"), NewMapOfStringToAlbum(),
|
||||
), &ref.Ref{}}
|
||||
}
|
||||
|
||||
var __typeRefForUser = types.MakeTypeRef(__mainPackageInFile_types_CachedRef, 0)
|
||||
@@ -63,29 +65,38 @@ func (m User) TypeRef() types.TypeRef {
|
||||
}
|
||||
|
||||
func init() {
|
||||
types.RegisterFromValFunction(__typeRefForUser, func(v types.Value) types.NomsValue {
|
||||
types.RegisterFromValFunction(__typeRefForUser, func(v types.Value) types.Value {
|
||||
return UserFromVal(v)
|
||||
})
|
||||
}
|
||||
|
||||
func UserFromVal(val types.Value) User {
|
||||
// TODO: Do we still need FromVal?
|
||||
if val, ok := val.(User); ok {
|
||||
return val
|
||||
}
|
||||
// TODO: Validate here
|
||||
return User{val.(types.Map)}
|
||||
return User{val.(types.Map), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s User) NomsValue() types.Value {
|
||||
// TODO: Remove this
|
||||
return s
|
||||
}
|
||||
|
||||
func (s User) InternalImplementation() types.Map {
|
||||
return s.m
|
||||
}
|
||||
|
||||
func (s User) Equals(other types.Value) bool {
|
||||
if other, ok := other.(User); ok {
|
||||
return s.m.Equals(other.m)
|
||||
return s.Ref() == other.Ref()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (s User) Ref() ref.Ref {
|
||||
return s.m.Ref()
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s User) Chunks() (futures []types.Future) {
|
||||
@@ -99,7 +110,7 @@ func (s User) Id() string {
|
||||
}
|
||||
|
||||
func (s User) SetId(val string) User {
|
||||
return User{s.m.Set(types.NewString("Id"), types.NewString(val))}
|
||||
return User{s.m.Set(types.NewString("Id"), types.NewString(val)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s User) Name() string {
|
||||
@@ -107,7 +118,7 @@ func (s User) Name() string {
|
||||
}
|
||||
|
||||
func (s User) SetName(val string) User {
|
||||
return User{s.m.Set(types.NewString("Name"), types.NewString(val))}
|
||||
return User{s.m.Set(types.NewString("Name"), types.NewString(val)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s User) OAuthToken() string {
|
||||
@@ -115,7 +126,7 @@ func (s User) OAuthToken() string {
|
||||
}
|
||||
|
||||
func (s User) SetOAuthToken(val string) User {
|
||||
return User{s.m.Set(types.NewString("OAuthToken"), types.NewString(val))}
|
||||
return User{s.m.Set(types.NewString("OAuthToken"), types.NewString(val)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s User) OAuthSecret() string {
|
||||
@@ -123,21 +134,22 @@ func (s User) OAuthSecret() string {
|
||||
}
|
||||
|
||||
func (s User) SetOAuthSecret(val string) User {
|
||||
return User{s.m.Set(types.NewString("OAuthSecret"), types.NewString(val))}
|
||||
return User{s.m.Set(types.NewString("OAuthSecret"), types.NewString(val)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s User) Albums() MapOfStringToAlbum {
|
||||
return MapOfStringToAlbumFromVal(s.m.Get(types.NewString("Albums")))
|
||||
return s.m.Get(types.NewString("Albums")).(MapOfStringToAlbum)
|
||||
}
|
||||
|
||||
func (s User) SetAlbums(val MapOfStringToAlbum) User {
|
||||
return User{s.m.Set(types.NewString("Albums"), val.NomsValue())}
|
||||
return User{s.m.Set(types.NewString("Albums"), val), &ref.Ref{}}
|
||||
}
|
||||
|
||||
// Album
|
||||
|
||||
type Album struct {
|
||||
m types.Map
|
||||
m types.Map
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewAlbum() Album {
|
||||
@@ -145,8 +157,8 @@ func NewAlbum() Album {
|
||||
types.NewString("$type"), types.MakeTypeRef(__mainPackageInFile_types_CachedRef, 1),
|
||||
types.NewString("Id"), types.NewString(""),
|
||||
types.NewString("Title"), types.NewString(""),
|
||||
types.NewString("Photos"), types.NewSet(),
|
||||
)}
|
||||
types.NewString("Photos"), NewSetOfsha1_b525f9bca5e451c21dd9af564f0960045fbaa304_RemotePhoto(),
|
||||
), &ref.Ref{}}
|
||||
}
|
||||
|
||||
var __typeRefForAlbum = types.MakeTypeRef(__mainPackageInFile_types_CachedRef, 1)
|
||||
@@ -156,29 +168,38 @@ func (m Album) TypeRef() types.TypeRef {
|
||||
}
|
||||
|
||||
func init() {
|
||||
types.RegisterFromValFunction(__typeRefForAlbum, func(v types.Value) types.NomsValue {
|
||||
types.RegisterFromValFunction(__typeRefForAlbum, func(v types.Value) types.Value {
|
||||
return AlbumFromVal(v)
|
||||
})
|
||||
}
|
||||
|
||||
func AlbumFromVal(val types.Value) Album {
|
||||
// TODO: Do we still need FromVal?
|
||||
if val, ok := val.(Album); ok {
|
||||
return val
|
||||
}
|
||||
// TODO: Validate here
|
||||
return Album{val.(types.Map)}
|
||||
return Album{val.(types.Map), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s Album) NomsValue() types.Value {
|
||||
// TODO: Remove this
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Album) InternalImplementation() types.Map {
|
||||
return s.m
|
||||
}
|
||||
|
||||
func (s Album) Equals(other types.Value) bool {
|
||||
if other, ok := other.(Album); ok {
|
||||
return s.m.Equals(other.m)
|
||||
return s.Ref() == other.Ref()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (s Album) Ref() ref.Ref {
|
||||
return s.m.Ref()
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s Album) Chunks() (futures []types.Future) {
|
||||
@@ -192,7 +213,7 @@ func (s Album) Id() string {
|
||||
}
|
||||
|
||||
func (s Album) SetId(val string) Album {
|
||||
return Album{s.m.Set(types.NewString("Id"), types.NewString(val))}
|
||||
return Album{s.m.Set(types.NewString("Id"), types.NewString(val)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s Album) Title() string {
|
||||
@@ -200,45 +221,55 @@ func (s Album) Title() string {
|
||||
}
|
||||
|
||||
func (s Album) SetTitle(val string) Album {
|
||||
return Album{s.m.Set(types.NewString("Title"), types.NewString(val))}
|
||||
return Album{s.m.Set(types.NewString("Title"), types.NewString(val)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s Album) Photos() SetOfsha1_4c734206e6aaef5464ff0e307c2f66751a1469de_RemotePhoto {
|
||||
return SetOfsha1_4c734206e6aaef5464ff0e307c2f66751a1469de_RemotePhotoFromVal(s.m.Get(types.NewString("Photos")))
|
||||
func (s Album) Photos() SetOfsha1_b525f9bca5e451c21dd9af564f0960045fbaa304_RemotePhoto {
|
||||
return s.m.Get(types.NewString("Photos")).(SetOfsha1_b525f9bca5e451c21dd9af564f0960045fbaa304_RemotePhoto)
|
||||
}
|
||||
|
||||
func (s Album) SetPhotos(val SetOfsha1_4c734206e6aaef5464ff0e307c2f66751a1469de_RemotePhoto) Album {
|
||||
return Album{s.m.Set(types.NewString("Photos"), val.NomsValue())}
|
||||
func (s Album) SetPhotos(val SetOfsha1_b525f9bca5e451c21dd9af564f0960045fbaa304_RemotePhoto) Album {
|
||||
return Album{s.m.Set(types.NewString("Photos"), val), &ref.Ref{}}
|
||||
}
|
||||
|
||||
// MapOfStringToAlbum
|
||||
|
||||
type MapOfStringToAlbum struct {
|
||||
m types.Map
|
||||
m types.Map
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewMapOfStringToAlbum() MapOfStringToAlbum {
|
||||
return MapOfStringToAlbum{types.NewMap()}
|
||||
return MapOfStringToAlbum{types.NewMap(), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func MapOfStringToAlbumFromVal(p types.Value) MapOfStringToAlbum {
|
||||
func MapOfStringToAlbumFromVal(val types.Value) MapOfStringToAlbum {
|
||||
// TODO: Do we still need FromVal?
|
||||
if val, ok := val.(MapOfStringToAlbum); ok {
|
||||
return val
|
||||
}
|
||||
// TODO: Validate here
|
||||
return MapOfStringToAlbum{p.(types.Map)}
|
||||
return MapOfStringToAlbum{val.(types.Map), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (m MapOfStringToAlbum) NomsValue() types.Value {
|
||||
// TODO: Remove this
|
||||
return m
|
||||
}
|
||||
|
||||
func (m MapOfStringToAlbum) InternalImplementation() types.Map {
|
||||
return m.m
|
||||
}
|
||||
|
||||
func (m MapOfStringToAlbum) Equals(other types.Value) bool {
|
||||
if other, ok := other.(MapOfStringToAlbum); ok {
|
||||
return m.m.Equals(other.m)
|
||||
return m.Ref() == other.Ref()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (m MapOfStringToAlbum) Ref() ref.Ref {
|
||||
return m.m.Ref()
|
||||
return types.EnsureRef(m.ref, m)
|
||||
}
|
||||
|
||||
func (m MapOfStringToAlbum) Chunks() (futures []types.Future) {
|
||||
@@ -256,7 +287,7 @@ func (m MapOfStringToAlbum) TypeRef() types.TypeRef {
|
||||
|
||||
func init() {
|
||||
__typeRefForMapOfStringToAlbum = types.MakeCompoundTypeRef("", types.MapKind, types.MakePrimitiveTypeRef(types.StringKind), types.MakeTypeRef(__mainPackageInFile_types_CachedRef, 1))
|
||||
types.RegisterFromValFunction(__typeRefForMapOfStringToAlbum, func(v types.Value) types.NomsValue {
|
||||
types.RegisterFromValFunction(__typeRefForMapOfStringToAlbum, func(v types.Value) types.Value {
|
||||
return MapOfStringToAlbumFromVal(v)
|
||||
})
|
||||
}
|
||||
@@ -274,7 +305,7 @@ func (m MapOfStringToAlbum) Has(p string) bool {
|
||||
}
|
||||
|
||||
func (m MapOfStringToAlbum) Get(p string) Album {
|
||||
return AlbumFromVal(m.m.Get(types.NewString(p)))
|
||||
return m.m.Get(types.NewString(p)).(Album)
|
||||
}
|
||||
|
||||
func (m MapOfStringToAlbum) MaybeGet(p string) (Album, bool) {
|
||||
@@ -282,24 +313,24 @@ func (m MapOfStringToAlbum) MaybeGet(p string) (Album, bool) {
|
||||
if !ok {
|
||||
return NewAlbum(), false
|
||||
}
|
||||
return AlbumFromVal(v), ok
|
||||
return v.(Album), ok
|
||||
}
|
||||
|
||||
func (m MapOfStringToAlbum) Set(k string, v Album) MapOfStringToAlbum {
|
||||
return MapOfStringToAlbum{m.m.Set(types.NewString(k), v.NomsValue())}
|
||||
return MapOfStringToAlbum{m.m.Set(types.NewString(k), v), &ref.Ref{}}
|
||||
}
|
||||
|
||||
// TODO: Implement SetM?
|
||||
|
||||
func (m MapOfStringToAlbum) Remove(p string) MapOfStringToAlbum {
|
||||
return MapOfStringToAlbum{m.m.Remove(types.NewString(p))}
|
||||
return MapOfStringToAlbum{m.m.Remove(types.NewString(p)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type MapOfStringToAlbumIterCallback func(k string, v Album) (stop bool)
|
||||
|
||||
func (m MapOfStringToAlbum) Iter(cb MapOfStringToAlbumIterCallback) {
|
||||
m.m.Iter(func(k, v types.Value) bool {
|
||||
return cb(k.(types.String).String(), AlbumFromVal(v))
|
||||
return cb(k.(types.String).String(), v.(Album))
|
||||
})
|
||||
}
|
||||
|
||||
@@ -307,7 +338,7 @@ type MapOfStringToAlbumIterAllCallback func(k string, v Album)
|
||||
|
||||
func (m MapOfStringToAlbum) IterAll(cb MapOfStringToAlbumIterAllCallback) {
|
||||
m.m.IterAll(func(k, v types.Value) {
|
||||
cb(k.(types.String).String(), AlbumFromVal(v))
|
||||
cb(k.(types.String).String(), v.(Album))
|
||||
})
|
||||
}
|
||||
|
||||
@@ -323,88 +354,98 @@ func (m MapOfStringToAlbum) Filter(cb MapOfStringToAlbumFilterCallback) MapOfStr
|
||||
return nm
|
||||
}
|
||||
|
||||
// SetOfsha1_4c734206e6aaef5464ff0e307c2f66751a1469de_RemotePhoto
|
||||
// SetOfsha1_b525f9bca5e451c21dd9af564f0960045fbaa304_RemotePhoto
|
||||
|
||||
type SetOfsha1_4c734206e6aaef5464ff0e307c2f66751a1469de_RemotePhoto struct {
|
||||
s types.Set
|
||||
type SetOfsha1_b525f9bca5e451c21dd9af564f0960045fbaa304_RemotePhoto struct {
|
||||
s types.Set
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewSetOfsha1_4c734206e6aaef5464ff0e307c2f66751a1469de_RemotePhoto() SetOfsha1_4c734206e6aaef5464ff0e307c2f66751a1469de_RemotePhoto {
|
||||
return SetOfsha1_4c734206e6aaef5464ff0e307c2f66751a1469de_RemotePhoto{types.NewSet()}
|
||||
func NewSetOfsha1_b525f9bca5e451c21dd9af564f0960045fbaa304_RemotePhoto() SetOfsha1_b525f9bca5e451c21dd9af564f0960045fbaa304_RemotePhoto {
|
||||
return SetOfsha1_b525f9bca5e451c21dd9af564f0960045fbaa304_RemotePhoto{types.NewSet(), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func SetOfsha1_4c734206e6aaef5464ff0e307c2f66751a1469de_RemotePhotoFromVal(p types.Value) SetOfsha1_4c734206e6aaef5464ff0e307c2f66751a1469de_RemotePhoto {
|
||||
return SetOfsha1_4c734206e6aaef5464ff0e307c2f66751a1469de_RemotePhoto{p.(types.Set)}
|
||||
func SetOfsha1_b525f9bca5e451c21dd9af564f0960045fbaa304_RemotePhotoFromVal(val types.Value) SetOfsha1_b525f9bca5e451c21dd9af564f0960045fbaa304_RemotePhoto {
|
||||
// TODO: Do we still need FromVal?
|
||||
if val, ok := val.(SetOfsha1_b525f9bca5e451c21dd9af564f0960045fbaa304_RemotePhoto); ok {
|
||||
return val
|
||||
}
|
||||
return SetOfsha1_b525f9bca5e451c21dd9af564f0960045fbaa304_RemotePhoto{val.(types.Set), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfsha1_4c734206e6aaef5464ff0e307c2f66751a1469de_RemotePhoto) NomsValue() types.Value {
|
||||
func (s SetOfsha1_b525f9bca5e451c21dd9af564f0960045fbaa304_RemotePhoto) NomsValue() types.Value {
|
||||
// TODO: Remove this
|
||||
return s
|
||||
}
|
||||
|
||||
func (s SetOfsha1_b525f9bca5e451c21dd9af564f0960045fbaa304_RemotePhoto) InternalImplementation() types.Set {
|
||||
return s.s
|
||||
}
|
||||
|
||||
func (s SetOfsha1_4c734206e6aaef5464ff0e307c2f66751a1469de_RemotePhoto) Equals(other types.Value) bool {
|
||||
if other, ok := other.(SetOfsha1_4c734206e6aaef5464ff0e307c2f66751a1469de_RemotePhoto); ok {
|
||||
return s.s.Equals(other.s)
|
||||
func (s SetOfsha1_b525f9bca5e451c21dd9af564f0960045fbaa304_RemotePhoto) Equals(other types.Value) bool {
|
||||
if other, ok := other.(SetOfsha1_b525f9bca5e451c21dd9af564f0960045fbaa304_RemotePhoto); ok {
|
||||
return s.Ref() == other.Ref()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (s SetOfsha1_4c734206e6aaef5464ff0e307c2f66751a1469de_RemotePhoto) Ref() ref.Ref {
|
||||
return s.s.Ref()
|
||||
func (s SetOfsha1_b525f9bca5e451c21dd9af564f0960045fbaa304_RemotePhoto) Ref() ref.Ref {
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s SetOfsha1_4c734206e6aaef5464ff0e307c2f66751a1469de_RemotePhoto) Chunks() (futures []types.Future) {
|
||||
func (s SetOfsha1_b525f9bca5e451c21dd9af564f0960045fbaa304_RemotePhoto) Chunks() (futures []types.Future) {
|
||||
futures = append(futures, s.TypeRef().Chunks()...)
|
||||
futures = append(futures, s.s.Chunks()...)
|
||||
return
|
||||
}
|
||||
|
||||
// A Noms Value that describes SetOfsha1_4c734206e6aaef5464ff0e307c2f66751a1469de_RemotePhoto.
|
||||
var __typeRefForSetOfsha1_4c734206e6aaef5464ff0e307c2f66751a1469de_RemotePhoto types.TypeRef
|
||||
// A Noms Value that describes SetOfsha1_b525f9bca5e451c21dd9af564f0960045fbaa304_RemotePhoto.
|
||||
var __typeRefForSetOfsha1_b525f9bca5e451c21dd9af564f0960045fbaa304_RemotePhoto types.TypeRef
|
||||
|
||||
func (m SetOfsha1_4c734206e6aaef5464ff0e307c2f66751a1469de_RemotePhoto) TypeRef() types.TypeRef {
|
||||
return __typeRefForSetOfsha1_4c734206e6aaef5464ff0e307c2f66751a1469de_RemotePhoto
|
||||
func (m SetOfsha1_b525f9bca5e451c21dd9af564f0960045fbaa304_RemotePhoto) TypeRef() types.TypeRef {
|
||||
return __typeRefForSetOfsha1_b525f9bca5e451c21dd9af564f0960045fbaa304_RemotePhoto
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeRefForSetOfsha1_4c734206e6aaef5464ff0e307c2f66751a1469de_RemotePhoto = types.MakeCompoundTypeRef("", types.SetKind, types.MakeTypeRef(ref.Parse("sha1-4c734206e6aaef5464ff0e307c2f66751a1469de"), 0))
|
||||
types.RegisterFromValFunction(__typeRefForSetOfsha1_4c734206e6aaef5464ff0e307c2f66751a1469de_RemotePhoto, func(v types.Value) types.NomsValue {
|
||||
return SetOfsha1_4c734206e6aaef5464ff0e307c2f66751a1469de_RemotePhotoFromVal(v)
|
||||
__typeRefForSetOfsha1_b525f9bca5e451c21dd9af564f0960045fbaa304_RemotePhoto = types.MakeCompoundTypeRef("", types.SetKind, types.MakeTypeRef(ref.Parse("sha1-b525f9bca5e451c21dd9af564f0960045fbaa304"), 0))
|
||||
types.RegisterFromValFunction(__typeRefForSetOfsha1_b525f9bca5e451c21dd9af564f0960045fbaa304_RemotePhoto, func(v types.Value) types.Value {
|
||||
return SetOfsha1_b525f9bca5e451c21dd9af564f0960045fbaa304_RemotePhotoFromVal(v)
|
||||
})
|
||||
}
|
||||
|
||||
func (s SetOfsha1_4c734206e6aaef5464ff0e307c2f66751a1469de_RemotePhoto) Empty() bool {
|
||||
func (s SetOfsha1_b525f9bca5e451c21dd9af564f0960045fbaa304_RemotePhoto) Empty() bool {
|
||||
return s.s.Empty()
|
||||
}
|
||||
|
||||
func (s SetOfsha1_4c734206e6aaef5464ff0e307c2f66751a1469de_RemotePhoto) Len() uint64 {
|
||||
func (s SetOfsha1_b525f9bca5e451c21dd9af564f0960045fbaa304_RemotePhoto) Len() uint64 {
|
||||
return s.s.Len()
|
||||
}
|
||||
|
||||
func (s SetOfsha1_4c734206e6aaef5464ff0e307c2f66751a1469de_RemotePhoto) Has(p sha1_4c734206e6aaef5464ff0e307c2f66751a1469de.RemotePhoto) bool {
|
||||
return s.s.Has(p.NomsValue())
|
||||
func (s SetOfsha1_b525f9bca5e451c21dd9af564f0960045fbaa304_RemotePhoto) Has(p sha1_b525f9bca5e451c21dd9af564f0960045fbaa304.RemotePhoto) bool {
|
||||
return s.s.Has(p)
|
||||
}
|
||||
|
||||
type SetOfsha1_4c734206e6aaef5464ff0e307c2f66751a1469de_RemotePhotoIterCallback func(p sha1_4c734206e6aaef5464ff0e307c2f66751a1469de.RemotePhoto) (stop bool)
|
||||
type SetOfsha1_b525f9bca5e451c21dd9af564f0960045fbaa304_RemotePhotoIterCallback func(p sha1_b525f9bca5e451c21dd9af564f0960045fbaa304.RemotePhoto) (stop bool)
|
||||
|
||||
func (s SetOfsha1_4c734206e6aaef5464ff0e307c2f66751a1469de_RemotePhoto) Iter(cb SetOfsha1_4c734206e6aaef5464ff0e307c2f66751a1469de_RemotePhotoIterCallback) {
|
||||
func (s SetOfsha1_b525f9bca5e451c21dd9af564f0960045fbaa304_RemotePhoto) Iter(cb SetOfsha1_b525f9bca5e451c21dd9af564f0960045fbaa304_RemotePhotoIterCallback) {
|
||||
s.s.Iter(func(v types.Value) bool {
|
||||
return cb(sha1_4c734206e6aaef5464ff0e307c2f66751a1469de.RemotePhotoFromVal(v))
|
||||
return cb(v.(sha1_b525f9bca5e451c21dd9af564f0960045fbaa304.RemotePhoto))
|
||||
})
|
||||
}
|
||||
|
||||
type SetOfsha1_4c734206e6aaef5464ff0e307c2f66751a1469de_RemotePhotoIterAllCallback func(p sha1_4c734206e6aaef5464ff0e307c2f66751a1469de.RemotePhoto)
|
||||
type SetOfsha1_b525f9bca5e451c21dd9af564f0960045fbaa304_RemotePhotoIterAllCallback func(p sha1_b525f9bca5e451c21dd9af564f0960045fbaa304.RemotePhoto)
|
||||
|
||||
func (s SetOfsha1_4c734206e6aaef5464ff0e307c2f66751a1469de_RemotePhoto) IterAll(cb SetOfsha1_4c734206e6aaef5464ff0e307c2f66751a1469de_RemotePhotoIterAllCallback) {
|
||||
func (s SetOfsha1_b525f9bca5e451c21dd9af564f0960045fbaa304_RemotePhoto) IterAll(cb SetOfsha1_b525f9bca5e451c21dd9af564f0960045fbaa304_RemotePhotoIterAllCallback) {
|
||||
s.s.IterAll(func(v types.Value) {
|
||||
cb(sha1_4c734206e6aaef5464ff0e307c2f66751a1469de.RemotePhotoFromVal(v))
|
||||
cb(v.(sha1_b525f9bca5e451c21dd9af564f0960045fbaa304.RemotePhoto))
|
||||
})
|
||||
}
|
||||
|
||||
type SetOfsha1_4c734206e6aaef5464ff0e307c2f66751a1469de_RemotePhotoFilterCallback func(p sha1_4c734206e6aaef5464ff0e307c2f66751a1469de.RemotePhoto) (keep bool)
|
||||
type SetOfsha1_b525f9bca5e451c21dd9af564f0960045fbaa304_RemotePhotoFilterCallback func(p sha1_b525f9bca5e451c21dd9af564f0960045fbaa304.RemotePhoto) (keep bool)
|
||||
|
||||
func (s SetOfsha1_4c734206e6aaef5464ff0e307c2f66751a1469de_RemotePhoto) Filter(cb SetOfsha1_4c734206e6aaef5464ff0e307c2f66751a1469de_RemotePhotoFilterCallback) SetOfsha1_4c734206e6aaef5464ff0e307c2f66751a1469de_RemotePhoto {
|
||||
ns := NewSetOfsha1_4c734206e6aaef5464ff0e307c2f66751a1469de_RemotePhoto()
|
||||
s.IterAll(func(v sha1_4c734206e6aaef5464ff0e307c2f66751a1469de.RemotePhoto) {
|
||||
func (s SetOfsha1_b525f9bca5e451c21dd9af564f0960045fbaa304_RemotePhoto) Filter(cb SetOfsha1_b525f9bca5e451c21dd9af564f0960045fbaa304_RemotePhotoFilterCallback) SetOfsha1_b525f9bca5e451c21dd9af564f0960045fbaa304_RemotePhoto {
|
||||
ns := NewSetOfsha1_b525f9bca5e451c21dd9af564f0960045fbaa304_RemotePhoto()
|
||||
s.IterAll(func(v sha1_b525f9bca5e451c21dd9af564f0960045fbaa304.RemotePhoto) {
|
||||
if cb(v) {
|
||||
ns = ns.Insert(v)
|
||||
}
|
||||
@@ -412,27 +453,27 @@ func (s SetOfsha1_4c734206e6aaef5464ff0e307c2f66751a1469de_RemotePhoto) Filter(c
|
||||
return ns
|
||||
}
|
||||
|
||||
func (s SetOfsha1_4c734206e6aaef5464ff0e307c2f66751a1469de_RemotePhoto) Insert(p ...sha1_4c734206e6aaef5464ff0e307c2f66751a1469de.RemotePhoto) SetOfsha1_4c734206e6aaef5464ff0e307c2f66751a1469de_RemotePhoto {
|
||||
return SetOfsha1_4c734206e6aaef5464ff0e307c2f66751a1469de_RemotePhoto{s.s.Insert(s.fromElemSlice(p)...)}
|
||||
func (s SetOfsha1_b525f9bca5e451c21dd9af564f0960045fbaa304_RemotePhoto) Insert(p ...sha1_b525f9bca5e451c21dd9af564f0960045fbaa304.RemotePhoto) SetOfsha1_b525f9bca5e451c21dd9af564f0960045fbaa304_RemotePhoto {
|
||||
return SetOfsha1_b525f9bca5e451c21dd9af564f0960045fbaa304_RemotePhoto{s.s.Insert(s.fromElemSlice(p)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfsha1_4c734206e6aaef5464ff0e307c2f66751a1469de_RemotePhoto) Remove(p ...sha1_4c734206e6aaef5464ff0e307c2f66751a1469de.RemotePhoto) SetOfsha1_4c734206e6aaef5464ff0e307c2f66751a1469de_RemotePhoto {
|
||||
return SetOfsha1_4c734206e6aaef5464ff0e307c2f66751a1469de_RemotePhoto{s.s.Remove(s.fromElemSlice(p)...)}
|
||||
func (s SetOfsha1_b525f9bca5e451c21dd9af564f0960045fbaa304_RemotePhoto) Remove(p ...sha1_b525f9bca5e451c21dd9af564f0960045fbaa304.RemotePhoto) SetOfsha1_b525f9bca5e451c21dd9af564f0960045fbaa304_RemotePhoto {
|
||||
return SetOfsha1_b525f9bca5e451c21dd9af564f0960045fbaa304_RemotePhoto{s.s.Remove(s.fromElemSlice(p)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfsha1_4c734206e6aaef5464ff0e307c2f66751a1469de_RemotePhoto) Union(others ...SetOfsha1_4c734206e6aaef5464ff0e307c2f66751a1469de_RemotePhoto) SetOfsha1_4c734206e6aaef5464ff0e307c2f66751a1469de_RemotePhoto {
|
||||
return SetOfsha1_4c734206e6aaef5464ff0e307c2f66751a1469de_RemotePhoto{s.s.Union(s.fromStructSlice(others)...)}
|
||||
func (s SetOfsha1_b525f9bca5e451c21dd9af564f0960045fbaa304_RemotePhoto) Union(others ...SetOfsha1_b525f9bca5e451c21dd9af564f0960045fbaa304_RemotePhoto) SetOfsha1_b525f9bca5e451c21dd9af564f0960045fbaa304_RemotePhoto {
|
||||
return SetOfsha1_b525f9bca5e451c21dd9af564f0960045fbaa304_RemotePhoto{s.s.Union(s.fromStructSlice(others)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfsha1_4c734206e6aaef5464ff0e307c2f66751a1469de_RemotePhoto) Subtract(others ...SetOfsha1_4c734206e6aaef5464ff0e307c2f66751a1469de_RemotePhoto) SetOfsha1_4c734206e6aaef5464ff0e307c2f66751a1469de_RemotePhoto {
|
||||
return SetOfsha1_4c734206e6aaef5464ff0e307c2f66751a1469de_RemotePhoto{s.s.Subtract(s.fromStructSlice(others)...)}
|
||||
func (s SetOfsha1_b525f9bca5e451c21dd9af564f0960045fbaa304_RemotePhoto) Subtract(others ...SetOfsha1_b525f9bca5e451c21dd9af564f0960045fbaa304_RemotePhoto) SetOfsha1_b525f9bca5e451c21dd9af564f0960045fbaa304_RemotePhoto {
|
||||
return SetOfsha1_b525f9bca5e451c21dd9af564f0960045fbaa304_RemotePhoto{s.s.Subtract(s.fromStructSlice(others)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfsha1_4c734206e6aaef5464ff0e307c2f66751a1469de_RemotePhoto) Any() sha1_4c734206e6aaef5464ff0e307c2f66751a1469de.RemotePhoto {
|
||||
return sha1_4c734206e6aaef5464ff0e307c2f66751a1469de.RemotePhotoFromVal(s.s.Any())
|
||||
func (s SetOfsha1_b525f9bca5e451c21dd9af564f0960045fbaa304_RemotePhoto) Any() sha1_b525f9bca5e451c21dd9af564f0960045fbaa304.RemotePhoto {
|
||||
return s.s.Any().(sha1_b525f9bca5e451c21dd9af564f0960045fbaa304.RemotePhoto)
|
||||
}
|
||||
|
||||
func (s SetOfsha1_4c734206e6aaef5464ff0e307c2f66751a1469de_RemotePhoto) fromStructSlice(p []SetOfsha1_4c734206e6aaef5464ff0e307c2f66751a1469de_RemotePhoto) []types.Set {
|
||||
func (s SetOfsha1_b525f9bca5e451c21dd9af564f0960045fbaa304_RemotePhoto) fromStructSlice(p []SetOfsha1_b525f9bca5e451c21dd9af564f0960045fbaa304_RemotePhoto) []types.Set {
|
||||
r := make([]types.Set, len(p))
|
||||
for i, v := range p {
|
||||
r[i] = v.s
|
||||
@@ -440,10 +481,10 @@ func (s SetOfsha1_4c734206e6aaef5464ff0e307c2f66751a1469de_RemotePhoto) fromStru
|
||||
return r
|
||||
}
|
||||
|
||||
func (s SetOfsha1_4c734206e6aaef5464ff0e307c2f66751a1469de_RemotePhoto) fromElemSlice(p []sha1_4c734206e6aaef5464ff0e307c2f66751a1469de.RemotePhoto) []types.Value {
|
||||
func (s SetOfsha1_b525f9bca5e451c21dd9af564f0960045fbaa304_RemotePhoto) fromElemSlice(p []sha1_b525f9bca5e451c21dd9af564f0960045fbaa304.RemotePhoto) []types.Value {
|
||||
r := make([]types.Value, len(p))
|
||||
for i, v := range p {
|
||||
r[i] = v.NomsValue()
|
||||
r[i] = v
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
+120
-79
@@ -1,26 +1,27 @@
|
||||
// This file was generated by nomdl/codegen.
|
||||
|
||||
package sha1_4c734206e6aaef5464ff0e307c2f66751a1469de
|
||||
package sha1_b525f9bca5e451c21dd9af564f0960045fbaa304
|
||||
|
||||
import (
|
||||
"github.com/attic-labs/noms/clients/gen/sha1_52bbaa7c5bcb39759981ccb12ee457f21fa7517d"
|
||||
"github.com/attic-labs/noms/clients/gen/sha1_fb09d21d144c518467325465327d46489cff7c47"
|
||||
|
||||
"github.com/attic-labs/noms/ref"
|
||||
"github.com/attic-labs/noms/types"
|
||||
)
|
||||
|
||||
var __sha1_4c734206e6aaef5464ff0e307c2f66751a1469dePackageInFile_sha1_4c734206e6aaef5464ff0e307c2f66751a1469de_CachedRef = __sha1_4c734206e6aaef5464ff0e307c2f66751a1469dePackageInFile_sha1_4c734206e6aaef5464ff0e307c2f66751a1469de_Ref()
|
||||
var __sha1_b525f9bca5e451c21dd9af564f0960045fbaa304PackageInFile_sha1_b525f9bca5e451c21dd9af564f0960045fbaa304_CachedRef = __sha1_b525f9bca5e451c21dd9af564f0960045fbaa304PackageInFile_sha1_b525f9bca5e451c21dd9af564f0960045fbaa304_Ref()
|
||||
|
||||
// This function builds up a Noms value that describes the type
|
||||
// package implemented by this file and registers it with the global
|
||||
// type package definition cache.
|
||||
func __sha1_4c734206e6aaef5464ff0e307c2f66751a1469dePackageInFile_sha1_4c734206e6aaef5464ff0e307c2f66751a1469de_Ref() ref.Ref {
|
||||
func __sha1_b525f9bca5e451c21dd9af564f0960045fbaa304PackageInFile_sha1_b525f9bca5e451c21dd9af564f0960045fbaa304_Ref() ref.Ref {
|
||||
p := types.NewPackage([]types.TypeRef{
|
||||
types.MakeStructTypeRef("RemotePhoto",
|
||||
[]types.Field{
|
||||
types.Field{"Id", types.MakePrimitiveTypeRef(types.StringKind), false},
|
||||
types.Field{"Title", types.MakePrimitiveTypeRef(types.StringKind), false},
|
||||
types.Field{"Url", types.MakePrimitiveTypeRef(types.StringKind), false},
|
||||
types.Field{"Geoposition", types.MakeTypeRef(ref.Parse("sha1-52bbaa7c5bcb39759981ccb12ee457f21fa7517d"), 0), false},
|
||||
types.Field{"Geoposition", types.MakeTypeRef(ref.Parse("sha1-fb09d21d144c518467325465327d46489cff7c47"), 0), false},
|
||||
types.Field{"Sizes", types.MakeCompoundTypeRef("", types.MapKind, types.MakeTypeRef(ref.Ref{}, 1), types.MakePrimitiveTypeRef(types.StringKind)), false},
|
||||
types.Field{"Tags", types.MakeCompoundTypeRef("", types.SetKind, types.MakePrimitiveTypeRef(types.StringKind)), false},
|
||||
},
|
||||
@@ -34,7 +35,7 @@ func __sha1_4c734206e6aaef5464ff0e307c2f66751a1469dePackageInFile_sha1_4c734206e
|
||||
types.Choices{},
|
||||
),
|
||||
}, []ref.Ref{
|
||||
ref.Parse("sha1-52bbaa7c5bcb39759981ccb12ee457f21fa7517d"),
|
||||
ref.Parse("sha1-fb09d21d144c518467325465327d46489cff7c47"),
|
||||
})
|
||||
return types.RegisterPackage(&p)
|
||||
}
|
||||
@@ -42,26 +43,27 @@ func __sha1_4c734206e6aaef5464ff0e307c2f66751a1469dePackageInFile_sha1_4c734206e
|
||||
// RemotePhoto
|
||||
|
||||
type RemotePhoto struct {
|
||||
m types.Map
|
||||
m types.Map
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewRemotePhoto() RemotePhoto {
|
||||
return RemotePhoto{types.NewMap(
|
||||
types.NewString("$type"), types.MakeTypeRef(__sha1_4c734206e6aaef5464ff0e307c2f66751a1469dePackageInFile_sha1_4c734206e6aaef5464ff0e307c2f66751a1469de_CachedRef, 0),
|
||||
types.NewString("$type"), types.MakeTypeRef(__sha1_b525f9bca5e451c21dd9af564f0960045fbaa304PackageInFile_sha1_b525f9bca5e451c21dd9af564f0960045fbaa304_CachedRef, 0),
|
||||
types.NewString("Id"), types.NewString(""),
|
||||
types.NewString("Title"), types.NewString(""),
|
||||
types.NewString("Url"), types.NewString(""),
|
||||
types.NewString("Geoposition"), sha1_52bbaa7c5bcb39759981ccb12ee457f21fa7517d.NewGeoposition().NomsValue(),
|
||||
types.NewString("Sizes"), types.NewMap(),
|
||||
types.NewString("Tags"), types.NewSet(),
|
||||
)}
|
||||
types.NewString("Geoposition"), sha1_fb09d21d144c518467325465327d46489cff7c47.NewGeoposition(),
|
||||
types.NewString("Sizes"), NewMapOfSizeToString(),
|
||||
types.NewString("Tags"), NewSetOfString(),
|
||||
), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type RemotePhotoDef struct {
|
||||
Id string
|
||||
Title string
|
||||
Url string
|
||||
Geoposition sha1_52bbaa7c5bcb39759981ccb12ee457f21fa7517d.GeopositionDef
|
||||
Geoposition sha1_fb09d21d144c518467325465327d46489cff7c47.GeopositionDef
|
||||
Sizes MapOfSizeToStringDef
|
||||
Tags SetOfStringDef
|
||||
}
|
||||
@@ -69,56 +71,65 @@ type RemotePhotoDef struct {
|
||||
func (def RemotePhotoDef) New() RemotePhoto {
|
||||
return RemotePhoto{
|
||||
types.NewMap(
|
||||
types.NewString("$type"), types.MakeTypeRef(__sha1_4c734206e6aaef5464ff0e307c2f66751a1469dePackageInFile_sha1_4c734206e6aaef5464ff0e307c2f66751a1469de_CachedRef, 0),
|
||||
types.NewString("$type"), types.MakeTypeRef(__sha1_b525f9bca5e451c21dd9af564f0960045fbaa304PackageInFile_sha1_b525f9bca5e451c21dd9af564f0960045fbaa304_CachedRef, 0),
|
||||
types.NewString("Id"), types.NewString(def.Id),
|
||||
types.NewString("Title"), types.NewString(def.Title),
|
||||
types.NewString("Url"), types.NewString(def.Url),
|
||||
types.NewString("Geoposition"), def.Geoposition.New().NomsValue(),
|
||||
types.NewString("Sizes"), def.Sizes.New().NomsValue(),
|
||||
types.NewString("Tags"), def.Tags.New().NomsValue(),
|
||||
)}
|
||||
types.NewString("Geoposition"), def.Geoposition.New(),
|
||||
types.NewString("Sizes"), def.Sizes.New(),
|
||||
types.NewString("Tags"), def.Tags.New(),
|
||||
), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s RemotePhoto) Def() (d RemotePhotoDef) {
|
||||
d.Id = s.m.Get(types.NewString("Id")).(types.String).String()
|
||||
d.Title = s.m.Get(types.NewString("Title")).(types.String).String()
|
||||
d.Url = s.m.Get(types.NewString("Url")).(types.String).String()
|
||||
d.Geoposition = sha1_52bbaa7c5bcb39759981ccb12ee457f21fa7517d.GeopositionFromVal(s.m.Get(types.NewString("Geoposition"))).Def()
|
||||
d.Sizes = MapOfSizeToStringFromVal(s.m.Get(types.NewString("Sizes"))).Def()
|
||||
d.Tags = SetOfStringFromVal(s.m.Get(types.NewString("Tags"))).Def()
|
||||
d.Geoposition = s.m.Get(types.NewString("Geoposition")).(sha1_fb09d21d144c518467325465327d46489cff7c47.Geoposition).Def()
|
||||
d.Sizes = s.m.Get(types.NewString("Sizes")).(MapOfSizeToString).Def()
|
||||
d.Tags = s.m.Get(types.NewString("Tags")).(SetOfString).Def()
|
||||
return
|
||||
}
|
||||
|
||||
var __typeRefForRemotePhoto = types.MakeTypeRef(__sha1_4c734206e6aaef5464ff0e307c2f66751a1469dePackageInFile_sha1_4c734206e6aaef5464ff0e307c2f66751a1469de_CachedRef, 0)
|
||||
var __typeRefForRemotePhoto = types.MakeTypeRef(__sha1_b525f9bca5e451c21dd9af564f0960045fbaa304PackageInFile_sha1_b525f9bca5e451c21dd9af564f0960045fbaa304_CachedRef, 0)
|
||||
|
||||
func (m RemotePhoto) TypeRef() types.TypeRef {
|
||||
return __typeRefForRemotePhoto
|
||||
}
|
||||
|
||||
func init() {
|
||||
types.RegisterFromValFunction(__typeRefForRemotePhoto, func(v types.Value) types.NomsValue {
|
||||
types.RegisterFromValFunction(__typeRefForRemotePhoto, func(v types.Value) types.Value {
|
||||
return RemotePhotoFromVal(v)
|
||||
})
|
||||
}
|
||||
|
||||
func RemotePhotoFromVal(val types.Value) RemotePhoto {
|
||||
// TODO: Do we still need FromVal?
|
||||
if val, ok := val.(RemotePhoto); ok {
|
||||
return val
|
||||
}
|
||||
// TODO: Validate here
|
||||
return RemotePhoto{val.(types.Map)}
|
||||
return RemotePhoto{val.(types.Map), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s RemotePhoto) NomsValue() types.Value {
|
||||
// TODO: Remove this
|
||||
return s
|
||||
}
|
||||
|
||||
func (s RemotePhoto) InternalImplementation() types.Map {
|
||||
return s.m
|
||||
}
|
||||
|
||||
func (s RemotePhoto) Equals(other types.Value) bool {
|
||||
if other, ok := other.(RemotePhoto); ok {
|
||||
return s.m.Equals(other.m)
|
||||
return s.Ref() == other.Ref()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (s RemotePhoto) Ref() ref.Ref {
|
||||
return s.m.Ref()
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s RemotePhoto) Chunks() (futures []types.Future) {
|
||||
@@ -132,7 +143,7 @@ func (s RemotePhoto) Id() string {
|
||||
}
|
||||
|
||||
func (s RemotePhoto) SetId(val string) RemotePhoto {
|
||||
return RemotePhoto{s.m.Set(types.NewString("Id"), types.NewString(val))}
|
||||
return RemotePhoto{s.m.Set(types.NewString("Id"), types.NewString(val)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s RemotePhoto) Title() string {
|
||||
@@ -140,7 +151,7 @@ func (s RemotePhoto) Title() string {
|
||||
}
|
||||
|
||||
func (s RemotePhoto) SetTitle(val string) RemotePhoto {
|
||||
return RemotePhoto{s.m.Set(types.NewString("Title"), types.NewString(val))}
|
||||
return RemotePhoto{s.m.Set(types.NewString("Title"), types.NewString(val)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s RemotePhoto) Url() string {
|
||||
@@ -148,45 +159,46 @@ func (s RemotePhoto) Url() string {
|
||||
}
|
||||
|
||||
func (s RemotePhoto) SetUrl(val string) RemotePhoto {
|
||||
return RemotePhoto{s.m.Set(types.NewString("Url"), types.NewString(val))}
|
||||
return RemotePhoto{s.m.Set(types.NewString("Url"), types.NewString(val)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s RemotePhoto) Geoposition() sha1_52bbaa7c5bcb39759981ccb12ee457f21fa7517d.Geoposition {
|
||||
return sha1_52bbaa7c5bcb39759981ccb12ee457f21fa7517d.GeopositionFromVal(s.m.Get(types.NewString("Geoposition")))
|
||||
func (s RemotePhoto) Geoposition() sha1_fb09d21d144c518467325465327d46489cff7c47.Geoposition {
|
||||
return s.m.Get(types.NewString("Geoposition")).(sha1_fb09d21d144c518467325465327d46489cff7c47.Geoposition)
|
||||
}
|
||||
|
||||
func (s RemotePhoto) SetGeoposition(val sha1_52bbaa7c5bcb39759981ccb12ee457f21fa7517d.Geoposition) RemotePhoto {
|
||||
return RemotePhoto{s.m.Set(types.NewString("Geoposition"), val.NomsValue())}
|
||||
func (s RemotePhoto) SetGeoposition(val sha1_fb09d21d144c518467325465327d46489cff7c47.Geoposition) RemotePhoto {
|
||||
return RemotePhoto{s.m.Set(types.NewString("Geoposition"), val), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s RemotePhoto) Sizes() MapOfSizeToString {
|
||||
return MapOfSizeToStringFromVal(s.m.Get(types.NewString("Sizes")))
|
||||
return s.m.Get(types.NewString("Sizes")).(MapOfSizeToString)
|
||||
}
|
||||
|
||||
func (s RemotePhoto) SetSizes(val MapOfSizeToString) RemotePhoto {
|
||||
return RemotePhoto{s.m.Set(types.NewString("Sizes"), val.NomsValue())}
|
||||
return RemotePhoto{s.m.Set(types.NewString("Sizes"), val), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s RemotePhoto) Tags() SetOfString {
|
||||
return SetOfStringFromVal(s.m.Get(types.NewString("Tags")))
|
||||
return s.m.Get(types.NewString("Tags")).(SetOfString)
|
||||
}
|
||||
|
||||
func (s RemotePhoto) SetTags(val SetOfString) RemotePhoto {
|
||||
return RemotePhoto{s.m.Set(types.NewString("Tags"), val.NomsValue())}
|
||||
return RemotePhoto{s.m.Set(types.NewString("Tags"), val), &ref.Ref{}}
|
||||
}
|
||||
|
||||
// Size
|
||||
|
||||
type Size struct {
|
||||
m types.Map
|
||||
m types.Map
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewSize() Size {
|
||||
return Size{types.NewMap(
|
||||
types.NewString("$type"), types.MakeTypeRef(__sha1_4c734206e6aaef5464ff0e307c2f66751a1469dePackageInFile_sha1_4c734206e6aaef5464ff0e307c2f66751a1469de_CachedRef, 1),
|
||||
types.NewString("$type"), types.MakeTypeRef(__sha1_b525f9bca5e451c21dd9af564f0960045fbaa304PackageInFile_sha1_b525f9bca5e451c21dd9af564f0960045fbaa304_CachedRef, 1),
|
||||
types.NewString("Width"), types.UInt32(0),
|
||||
types.NewString("Height"), types.UInt32(0),
|
||||
)}
|
||||
), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type SizeDef struct {
|
||||
@@ -197,10 +209,10 @@ type SizeDef struct {
|
||||
func (def SizeDef) New() Size {
|
||||
return Size{
|
||||
types.NewMap(
|
||||
types.NewString("$type"), types.MakeTypeRef(__sha1_4c734206e6aaef5464ff0e307c2f66751a1469dePackageInFile_sha1_4c734206e6aaef5464ff0e307c2f66751a1469de_CachedRef, 1),
|
||||
types.NewString("$type"), types.MakeTypeRef(__sha1_b525f9bca5e451c21dd9af564f0960045fbaa304PackageInFile_sha1_b525f9bca5e451c21dd9af564f0960045fbaa304_CachedRef, 1),
|
||||
types.NewString("Width"), types.UInt32(def.Width),
|
||||
types.NewString("Height"), types.UInt32(def.Height),
|
||||
)}
|
||||
), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s Size) Def() (d SizeDef) {
|
||||
@@ -209,36 +221,45 @@ func (s Size) Def() (d SizeDef) {
|
||||
return
|
||||
}
|
||||
|
||||
var __typeRefForSize = types.MakeTypeRef(__sha1_4c734206e6aaef5464ff0e307c2f66751a1469dePackageInFile_sha1_4c734206e6aaef5464ff0e307c2f66751a1469de_CachedRef, 1)
|
||||
var __typeRefForSize = types.MakeTypeRef(__sha1_b525f9bca5e451c21dd9af564f0960045fbaa304PackageInFile_sha1_b525f9bca5e451c21dd9af564f0960045fbaa304_CachedRef, 1)
|
||||
|
||||
func (m Size) TypeRef() types.TypeRef {
|
||||
return __typeRefForSize
|
||||
}
|
||||
|
||||
func init() {
|
||||
types.RegisterFromValFunction(__typeRefForSize, func(v types.Value) types.NomsValue {
|
||||
types.RegisterFromValFunction(__typeRefForSize, func(v types.Value) types.Value {
|
||||
return SizeFromVal(v)
|
||||
})
|
||||
}
|
||||
|
||||
func SizeFromVal(val types.Value) Size {
|
||||
// TODO: Do we still need FromVal?
|
||||
if val, ok := val.(Size); ok {
|
||||
return val
|
||||
}
|
||||
// TODO: Validate here
|
||||
return Size{val.(types.Map)}
|
||||
return Size{val.(types.Map), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s Size) NomsValue() types.Value {
|
||||
// TODO: Remove this
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Size) InternalImplementation() types.Map {
|
||||
return s.m
|
||||
}
|
||||
|
||||
func (s Size) Equals(other types.Value) bool {
|
||||
if other, ok := other.(Size); ok {
|
||||
return s.m.Equals(other.m)
|
||||
return s.Ref() == other.Ref()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (s Size) Ref() ref.Ref {
|
||||
return s.m.Ref()
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s Size) Chunks() (futures []types.Future) {
|
||||
@@ -252,7 +273,7 @@ func (s Size) Width() uint32 {
|
||||
}
|
||||
|
||||
func (s Size) SetWidth(val uint32) Size {
|
||||
return Size{s.m.Set(types.NewString("Width"), types.UInt32(val))}
|
||||
return Size{s.m.Set(types.NewString("Width"), types.UInt32(val)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s Size) Height() uint32 {
|
||||
@@ -260,17 +281,18 @@ func (s Size) Height() uint32 {
|
||||
}
|
||||
|
||||
func (s Size) SetHeight(val uint32) Size {
|
||||
return Size{s.m.Set(types.NewString("Height"), types.UInt32(val))}
|
||||
return Size{s.m.Set(types.NewString("Height"), types.UInt32(val)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
// MapOfSizeToString
|
||||
|
||||
type MapOfSizeToString struct {
|
||||
m types.Map
|
||||
m types.Map
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewMapOfSizeToString() MapOfSizeToString {
|
||||
return MapOfSizeToString{types.NewMap()}
|
||||
return MapOfSizeToString{types.NewMap(), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type MapOfSizeToStringDef map[SizeDef]string
|
||||
@@ -278,38 +300,47 @@ type MapOfSizeToStringDef map[SizeDef]string
|
||||
func (def MapOfSizeToStringDef) New() MapOfSizeToString {
|
||||
kv := make([]types.Value, 0, len(def)*2)
|
||||
for k, v := range def {
|
||||
kv = append(kv, k.New().NomsValue(), types.NewString(v))
|
||||
kv = append(kv, k.New(), types.NewString(v))
|
||||
}
|
||||
return MapOfSizeToString{types.NewMap(kv...)}
|
||||
return MapOfSizeToString{types.NewMap(kv...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (m MapOfSizeToString) Def() MapOfSizeToStringDef {
|
||||
def := make(map[SizeDef]string)
|
||||
m.m.Iter(func(k, v types.Value) bool {
|
||||
def[SizeFromVal(k).Def()] = v.(types.String).String()
|
||||
def[k.(Size).Def()] = v.(types.String).String()
|
||||
return false
|
||||
})
|
||||
return def
|
||||
}
|
||||
|
||||
func MapOfSizeToStringFromVal(p types.Value) MapOfSizeToString {
|
||||
func MapOfSizeToStringFromVal(val types.Value) MapOfSizeToString {
|
||||
// TODO: Do we still need FromVal?
|
||||
if val, ok := val.(MapOfSizeToString); ok {
|
||||
return val
|
||||
}
|
||||
// TODO: Validate here
|
||||
return MapOfSizeToString{p.(types.Map)}
|
||||
return MapOfSizeToString{val.(types.Map), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (m MapOfSizeToString) NomsValue() types.Value {
|
||||
// TODO: Remove this
|
||||
return m
|
||||
}
|
||||
|
||||
func (m MapOfSizeToString) InternalImplementation() types.Map {
|
||||
return m.m
|
||||
}
|
||||
|
||||
func (m MapOfSizeToString) Equals(other types.Value) bool {
|
||||
if other, ok := other.(MapOfSizeToString); ok {
|
||||
return m.m.Equals(other.m)
|
||||
return m.Ref() == other.Ref()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (m MapOfSizeToString) Ref() ref.Ref {
|
||||
return m.m.Ref()
|
||||
return types.EnsureRef(m.ref, m)
|
||||
}
|
||||
|
||||
func (m MapOfSizeToString) Chunks() (futures []types.Future) {
|
||||
@@ -326,8 +357,8 @@ func (m MapOfSizeToString) TypeRef() types.TypeRef {
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeRefForMapOfSizeToString = types.MakeCompoundTypeRef("", types.MapKind, types.MakeTypeRef(__sha1_4c734206e6aaef5464ff0e307c2f66751a1469dePackageInFile_sha1_4c734206e6aaef5464ff0e307c2f66751a1469de_CachedRef, 1), types.MakePrimitiveTypeRef(types.StringKind))
|
||||
types.RegisterFromValFunction(__typeRefForMapOfSizeToString, func(v types.Value) types.NomsValue {
|
||||
__typeRefForMapOfSizeToString = types.MakeCompoundTypeRef("", types.MapKind, types.MakeTypeRef(__sha1_b525f9bca5e451c21dd9af564f0960045fbaa304PackageInFile_sha1_b525f9bca5e451c21dd9af564f0960045fbaa304_CachedRef, 1), types.MakePrimitiveTypeRef(types.StringKind))
|
||||
types.RegisterFromValFunction(__typeRefForMapOfSizeToString, func(v types.Value) types.Value {
|
||||
return MapOfSizeToStringFromVal(v)
|
||||
})
|
||||
}
|
||||
@@ -341,15 +372,15 @@ func (m MapOfSizeToString) Len() uint64 {
|
||||
}
|
||||
|
||||
func (m MapOfSizeToString) Has(p Size) bool {
|
||||
return m.m.Has(p.NomsValue())
|
||||
return m.m.Has(p)
|
||||
}
|
||||
|
||||
func (m MapOfSizeToString) Get(p Size) string {
|
||||
return m.m.Get(p.NomsValue()).(types.String).String()
|
||||
return m.m.Get(p).(types.String).String()
|
||||
}
|
||||
|
||||
func (m MapOfSizeToString) MaybeGet(p Size) (string, bool) {
|
||||
v, ok := m.m.MaybeGet(p.NomsValue())
|
||||
v, ok := m.m.MaybeGet(p)
|
||||
if !ok {
|
||||
return "", false
|
||||
}
|
||||
@@ -357,20 +388,20 @@ func (m MapOfSizeToString) MaybeGet(p Size) (string, bool) {
|
||||
}
|
||||
|
||||
func (m MapOfSizeToString) Set(k Size, v string) MapOfSizeToString {
|
||||
return MapOfSizeToString{m.m.Set(k.NomsValue(), types.NewString(v))}
|
||||
return MapOfSizeToString{m.m.Set(k, types.NewString(v)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
// TODO: Implement SetM?
|
||||
|
||||
func (m MapOfSizeToString) Remove(p Size) MapOfSizeToString {
|
||||
return MapOfSizeToString{m.m.Remove(p.NomsValue())}
|
||||
return MapOfSizeToString{m.m.Remove(p), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type MapOfSizeToStringIterCallback func(k Size, v string) (stop bool)
|
||||
|
||||
func (m MapOfSizeToString) Iter(cb MapOfSizeToStringIterCallback) {
|
||||
m.m.Iter(func(k, v types.Value) bool {
|
||||
return cb(SizeFromVal(k), v.(types.String).String())
|
||||
return cb(k.(Size), v.(types.String).String())
|
||||
})
|
||||
}
|
||||
|
||||
@@ -378,7 +409,7 @@ type MapOfSizeToStringIterAllCallback func(k Size, v string)
|
||||
|
||||
func (m MapOfSizeToString) IterAll(cb MapOfSizeToStringIterAllCallback) {
|
||||
m.m.IterAll(func(k, v types.Value) {
|
||||
cb(SizeFromVal(k), v.(types.String).String())
|
||||
cb(k.(Size), v.(types.String).String())
|
||||
})
|
||||
}
|
||||
|
||||
@@ -397,11 +428,12 @@ func (m MapOfSizeToString) Filter(cb MapOfSizeToStringFilterCallback) MapOfSizeT
|
||||
// SetOfString
|
||||
|
||||
type SetOfString struct {
|
||||
s types.Set
|
||||
s types.Set
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewSetOfString() SetOfString {
|
||||
return SetOfString{types.NewSet()}
|
||||
return SetOfString{types.NewSet(), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type SetOfStringDef map[string]bool
|
||||
@@ -413,7 +445,7 @@ func (def SetOfStringDef) New() SetOfString {
|
||||
l[i] = types.NewString(d)
|
||||
i++
|
||||
}
|
||||
return SetOfString{types.NewSet(l...)}
|
||||
return SetOfString{types.NewSet(l...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfString) Def() SetOfStringDef {
|
||||
@@ -425,23 +457,32 @@ func (s SetOfString) Def() SetOfStringDef {
|
||||
return def
|
||||
}
|
||||
|
||||
func SetOfStringFromVal(p types.Value) SetOfString {
|
||||
return SetOfString{p.(types.Set)}
|
||||
func SetOfStringFromVal(val types.Value) SetOfString {
|
||||
// TODO: Do we still need FromVal?
|
||||
if val, ok := val.(SetOfString); ok {
|
||||
return val
|
||||
}
|
||||
return SetOfString{val.(types.Set), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfString) NomsValue() types.Value {
|
||||
// TODO: Remove this
|
||||
return s
|
||||
}
|
||||
|
||||
func (s SetOfString) InternalImplementation() types.Set {
|
||||
return s.s
|
||||
}
|
||||
|
||||
func (s SetOfString) Equals(other types.Value) bool {
|
||||
if other, ok := other.(SetOfString); ok {
|
||||
return s.s.Equals(other.s)
|
||||
return s.Ref() == other.Ref()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (s SetOfString) Ref() ref.Ref {
|
||||
return s.s.Ref()
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s SetOfString) Chunks() (futures []types.Future) {
|
||||
@@ -459,7 +500,7 @@ func (m SetOfString) TypeRef() types.TypeRef {
|
||||
|
||||
func init() {
|
||||
__typeRefForSetOfString = types.MakeCompoundTypeRef("", types.SetKind, types.MakePrimitiveTypeRef(types.StringKind))
|
||||
types.RegisterFromValFunction(__typeRefForSetOfString, func(v types.Value) types.NomsValue {
|
||||
types.RegisterFromValFunction(__typeRefForSetOfString, func(v types.Value) types.Value {
|
||||
return SetOfStringFromVal(v)
|
||||
})
|
||||
}
|
||||
@@ -505,19 +546,19 @@ func (s SetOfString) Filter(cb SetOfStringFilterCallback) SetOfString {
|
||||
}
|
||||
|
||||
func (s SetOfString) Insert(p ...string) SetOfString {
|
||||
return SetOfString{s.s.Insert(s.fromElemSlice(p)...)}
|
||||
return SetOfString{s.s.Insert(s.fromElemSlice(p)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfString) Remove(p ...string) SetOfString {
|
||||
return SetOfString{s.s.Remove(s.fromElemSlice(p)...)}
|
||||
return SetOfString{s.s.Remove(s.fromElemSlice(p)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfString) Union(others ...SetOfString) SetOfString {
|
||||
return SetOfString{s.s.Union(s.fromStructSlice(others)...)}
|
||||
return SetOfString{s.s.Union(s.fromStructSlice(others)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfString) Subtract(others ...SetOfString) SetOfString {
|
||||
return SetOfString{s.s.Subtract(s.fromStructSlice(others)...)}
|
||||
return SetOfString{s.s.Subtract(s.fromStructSlice(others)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfString) Any() string {
|
||||
+55
-35
@@ -1,18 +1,18 @@
|
||||
// This file was generated by nomdl/codegen.
|
||||
|
||||
package sha1_52bbaa7c5bcb39759981ccb12ee457f21fa7517d
|
||||
package sha1_fb09d21d144c518467325465327d46489cff7c47
|
||||
|
||||
import (
|
||||
"github.com/attic-labs/noms/ref"
|
||||
"github.com/attic-labs/noms/types"
|
||||
)
|
||||
|
||||
var __sha1_52bbaa7c5bcb39759981ccb12ee457f21fa7517dPackageInFile_sha1_52bbaa7c5bcb39759981ccb12ee457f21fa7517d_CachedRef = __sha1_52bbaa7c5bcb39759981ccb12ee457f21fa7517dPackageInFile_sha1_52bbaa7c5bcb39759981ccb12ee457f21fa7517d_Ref()
|
||||
var __sha1_fb09d21d144c518467325465327d46489cff7c47PackageInFile_sha1_fb09d21d144c518467325465327d46489cff7c47_CachedRef = __sha1_fb09d21d144c518467325465327d46489cff7c47PackageInFile_sha1_fb09d21d144c518467325465327d46489cff7c47_Ref()
|
||||
|
||||
// This function builds up a Noms value that describes the type
|
||||
// package implemented by this file and registers it with the global
|
||||
// type package definition cache.
|
||||
func __sha1_52bbaa7c5bcb39759981ccb12ee457f21fa7517dPackageInFile_sha1_52bbaa7c5bcb39759981ccb12ee457f21fa7517d_Ref() ref.Ref {
|
||||
func __sha1_fb09d21d144c518467325465327d46489cff7c47PackageInFile_sha1_fb09d21d144c518467325465327d46489cff7c47_Ref() ref.Ref {
|
||||
p := types.NewPackage([]types.TypeRef{
|
||||
types.MakeStructTypeRef("Geoposition",
|
||||
[]types.Field{
|
||||
@@ -35,15 +35,16 @@ func __sha1_52bbaa7c5bcb39759981ccb12ee457f21fa7517dPackageInFile_sha1_52bbaa7c5
|
||||
// Geoposition
|
||||
|
||||
type Geoposition struct {
|
||||
m types.Map
|
||||
m types.Map
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewGeoposition() Geoposition {
|
||||
return Geoposition{types.NewMap(
|
||||
types.NewString("$type"), types.MakeTypeRef(__sha1_52bbaa7c5bcb39759981ccb12ee457f21fa7517dPackageInFile_sha1_52bbaa7c5bcb39759981ccb12ee457f21fa7517d_CachedRef, 0),
|
||||
types.NewString("$type"), types.MakeTypeRef(__sha1_fb09d21d144c518467325465327d46489cff7c47PackageInFile_sha1_fb09d21d144c518467325465327d46489cff7c47_CachedRef, 0),
|
||||
types.NewString("Latitude"), types.Float32(0),
|
||||
types.NewString("Longitude"), types.Float32(0),
|
||||
)}
|
||||
), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type GeopositionDef struct {
|
||||
@@ -54,10 +55,10 @@ type GeopositionDef struct {
|
||||
func (def GeopositionDef) New() Geoposition {
|
||||
return Geoposition{
|
||||
types.NewMap(
|
||||
types.NewString("$type"), types.MakeTypeRef(__sha1_52bbaa7c5bcb39759981ccb12ee457f21fa7517dPackageInFile_sha1_52bbaa7c5bcb39759981ccb12ee457f21fa7517d_CachedRef, 0),
|
||||
types.NewString("$type"), types.MakeTypeRef(__sha1_fb09d21d144c518467325465327d46489cff7c47PackageInFile_sha1_fb09d21d144c518467325465327d46489cff7c47_CachedRef, 0),
|
||||
types.NewString("Latitude"), types.Float32(def.Latitude),
|
||||
types.NewString("Longitude"), types.Float32(def.Longitude),
|
||||
)}
|
||||
), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s Geoposition) Def() (d GeopositionDef) {
|
||||
@@ -66,36 +67,45 @@ func (s Geoposition) Def() (d GeopositionDef) {
|
||||
return
|
||||
}
|
||||
|
||||
var __typeRefForGeoposition = types.MakeTypeRef(__sha1_52bbaa7c5bcb39759981ccb12ee457f21fa7517dPackageInFile_sha1_52bbaa7c5bcb39759981ccb12ee457f21fa7517d_CachedRef, 0)
|
||||
var __typeRefForGeoposition = types.MakeTypeRef(__sha1_fb09d21d144c518467325465327d46489cff7c47PackageInFile_sha1_fb09d21d144c518467325465327d46489cff7c47_CachedRef, 0)
|
||||
|
||||
func (m Geoposition) TypeRef() types.TypeRef {
|
||||
return __typeRefForGeoposition
|
||||
}
|
||||
|
||||
func init() {
|
||||
types.RegisterFromValFunction(__typeRefForGeoposition, func(v types.Value) types.NomsValue {
|
||||
types.RegisterFromValFunction(__typeRefForGeoposition, func(v types.Value) types.Value {
|
||||
return GeopositionFromVal(v)
|
||||
})
|
||||
}
|
||||
|
||||
func GeopositionFromVal(val types.Value) Geoposition {
|
||||
// TODO: Do we still need FromVal?
|
||||
if val, ok := val.(Geoposition); ok {
|
||||
return val
|
||||
}
|
||||
// TODO: Validate here
|
||||
return Geoposition{val.(types.Map)}
|
||||
return Geoposition{val.(types.Map), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s Geoposition) NomsValue() types.Value {
|
||||
// TODO: Remove this
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Geoposition) InternalImplementation() types.Map {
|
||||
return s.m
|
||||
}
|
||||
|
||||
func (s Geoposition) Equals(other types.Value) bool {
|
||||
if other, ok := other.(Geoposition); ok {
|
||||
return s.m.Equals(other.m)
|
||||
return s.Ref() == other.Ref()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (s Geoposition) Ref() ref.Ref {
|
||||
return s.m.Ref()
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s Geoposition) Chunks() (futures []types.Future) {
|
||||
@@ -109,7 +119,7 @@ func (s Geoposition) Latitude() float32 {
|
||||
}
|
||||
|
||||
func (s Geoposition) SetLatitude(val float32) Geoposition {
|
||||
return Geoposition{s.m.Set(types.NewString("Latitude"), types.Float32(val))}
|
||||
return Geoposition{s.m.Set(types.NewString("Latitude"), types.Float32(val)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s Geoposition) Longitude() float32 {
|
||||
@@ -117,21 +127,22 @@ func (s Geoposition) Longitude() float32 {
|
||||
}
|
||||
|
||||
func (s Geoposition) SetLongitude(val float32) Geoposition {
|
||||
return Geoposition{s.m.Set(types.NewString("Longitude"), types.Float32(val))}
|
||||
return Geoposition{s.m.Set(types.NewString("Longitude"), types.Float32(val)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
// Georectangle
|
||||
|
||||
type Georectangle struct {
|
||||
m types.Map
|
||||
m types.Map
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewGeorectangle() Georectangle {
|
||||
return Georectangle{types.NewMap(
|
||||
types.NewString("$type"), types.MakeTypeRef(__sha1_52bbaa7c5bcb39759981ccb12ee457f21fa7517dPackageInFile_sha1_52bbaa7c5bcb39759981ccb12ee457f21fa7517d_CachedRef, 1),
|
||||
types.NewString("TopLeft"), NewGeoposition().NomsValue(),
|
||||
types.NewString("BottomRight"), NewGeoposition().NomsValue(),
|
||||
)}
|
||||
types.NewString("$type"), types.MakeTypeRef(__sha1_fb09d21d144c518467325465327d46489cff7c47PackageInFile_sha1_fb09d21d144c518467325465327d46489cff7c47_CachedRef, 1),
|
||||
types.NewString("TopLeft"), NewGeoposition(),
|
||||
types.NewString("BottomRight"), NewGeoposition(),
|
||||
), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type GeorectangleDef struct {
|
||||
@@ -142,48 +153,57 @@ type GeorectangleDef struct {
|
||||
func (def GeorectangleDef) New() Georectangle {
|
||||
return Georectangle{
|
||||
types.NewMap(
|
||||
types.NewString("$type"), types.MakeTypeRef(__sha1_52bbaa7c5bcb39759981ccb12ee457f21fa7517dPackageInFile_sha1_52bbaa7c5bcb39759981ccb12ee457f21fa7517d_CachedRef, 1),
|
||||
types.NewString("TopLeft"), def.TopLeft.New().NomsValue(),
|
||||
types.NewString("BottomRight"), def.BottomRight.New().NomsValue(),
|
||||
)}
|
||||
types.NewString("$type"), types.MakeTypeRef(__sha1_fb09d21d144c518467325465327d46489cff7c47PackageInFile_sha1_fb09d21d144c518467325465327d46489cff7c47_CachedRef, 1),
|
||||
types.NewString("TopLeft"), def.TopLeft.New(),
|
||||
types.NewString("BottomRight"), def.BottomRight.New(),
|
||||
), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s Georectangle) Def() (d GeorectangleDef) {
|
||||
d.TopLeft = GeopositionFromVal(s.m.Get(types.NewString("TopLeft"))).Def()
|
||||
d.BottomRight = GeopositionFromVal(s.m.Get(types.NewString("BottomRight"))).Def()
|
||||
d.TopLeft = s.m.Get(types.NewString("TopLeft")).(Geoposition).Def()
|
||||
d.BottomRight = s.m.Get(types.NewString("BottomRight")).(Geoposition).Def()
|
||||
return
|
||||
}
|
||||
|
||||
var __typeRefForGeorectangle = types.MakeTypeRef(__sha1_52bbaa7c5bcb39759981ccb12ee457f21fa7517dPackageInFile_sha1_52bbaa7c5bcb39759981ccb12ee457f21fa7517d_CachedRef, 1)
|
||||
var __typeRefForGeorectangle = types.MakeTypeRef(__sha1_fb09d21d144c518467325465327d46489cff7c47PackageInFile_sha1_fb09d21d144c518467325465327d46489cff7c47_CachedRef, 1)
|
||||
|
||||
func (m Georectangle) TypeRef() types.TypeRef {
|
||||
return __typeRefForGeorectangle
|
||||
}
|
||||
|
||||
func init() {
|
||||
types.RegisterFromValFunction(__typeRefForGeorectangle, func(v types.Value) types.NomsValue {
|
||||
types.RegisterFromValFunction(__typeRefForGeorectangle, func(v types.Value) types.Value {
|
||||
return GeorectangleFromVal(v)
|
||||
})
|
||||
}
|
||||
|
||||
func GeorectangleFromVal(val types.Value) Georectangle {
|
||||
// TODO: Do we still need FromVal?
|
||||
if val, ok := val.(Georectangle); ok {
|
||||
return val
|
||||
}
|
||||
// TODO: Validate here
|
||||
return Georectangle{val.(types.Map)}
|
||||
return Georectangle{val.(types.Map), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s Georectangle) NomsValue() types.Value {
|
||||
// TODO: Remove this
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Georectangle) InternalImplementation() types.Map {
|
||||
return s.m
|
||||
}
|
||||
|
||||
func (s Georectangle) Equals(other types.Value) bool {
|
||||
if other, ok := other.(Georectangle); ok {
|
||||
return s.m.Equals(other.m)
|
||||
return s.Ref() == other.Ref()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (s Georectangle) Ref() ref.Ref {
|
||||
return s.m.Ref()
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s Georectangle) Chunks() (futures []types.Future) {
|
||||
@@ -193,17 +213,17 @@ func (s Georectangle) Chunks() (futures []types.Future) {
|
||||
}
|
||||
|
||||
func (s Georectangle) TopLeft() Geoposition {
|
||||
return GeopositionFromVal(s.m.Get(types.NewString("TopLeft")))
|
||||
return s.m.Get(types.NewString("TopLeft")).(Geoposition)
|
||||
}
|
||||
|
||||
func (s Georectangle) SetTopLeft(val Geoposition) Georectangle {
|
||||
return Georectangle{s.m.Set(types.NewString("TopLeft"), val.NomsValue())}
|
||||
return Georectangle{s.m.Set(types.NewString("TopLeft"), val), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s Georectangle) BottomRight() Geoposition {
|
||||
return GeopositionFromVal(s.m.Get(types.NewString("BottomRight")))
|
||||
return s.m.Get(types.NewString("BottomRight")).(Geoposition)
|
||||
}
|
||||
|
||||
func (s Georectangle) SetBottomRight(val Geoposition) Georectangle {
|
||||
return Georectangle{s.m.Set(types.NewString("BottomRight"), val.NomsValue())}
|
||||
return Georectangle{s.m.Set(types.NewString("BottomRight"), val), &ref.Ref{}}
|
||||
}
|
||||
@@ -31,7 +31,8 @@ func __mainPackageInFile_types_Ref() ref.Ref {
|
||||
// Song
|
||||
|
||||
type Song struct {
|
||||
m types.Map
|
||||
m types.Map
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewSong() Song {
|
||||
@@ -42,7 +43,7 @@ func NewSong() Song {
|
||||
types.NewString("Album"), types.NewString(""),
|
||||
types.NewString("Year"), types.NewString(""),
|
||||
types.NewString("Mp3"), types.NewEmptyBlob(),
|
||||
)}
|
||||
), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type SongDef struct {
|
||||
@@ -62,7 +63,7 @@ func (def SongDef) New() Song {
|
||||
types.NewString("Album"), types.NewString(def.Album),
|
||||
types.NewString("Year"), types.NewString(def.Year),
|
||||
types.NewString("Mp3"), def.Mp3,
|
||||
)}
|
||||
), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s Song) Def() (d SongDef) {
|
||||
@@ -81,29 +82,38 @@ func (m Song) TypeRef() types.TypeRef {
|
||||
}
|
||||
|
||||
func init() {
|
||||
types.RegisterFromValFunction(__typeRefForSong, func(v types.Value) types.NomsValue {
|
||||
types.RegisterFromValFunction(__typeRefForSong, func(v types.Value) types.Value {
|
||||
return SongFromVal(v)
|
||||
})
|
||||
}
|
||||
|
||||
func SongFromVal(val types.Value) Song {
|
||||
// TODO: Do we still need FromVal?
|
||||
if val, ok := val.(Song); ok {
|
||||
return val
|
||||
}
|
||||
// TODO: Validate here
|
||||
return Song{val.(types.Map)}
|
||||
return Song{val.(types.Map), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s Song) NomsValue() types.Value {
|
||||
// TODO: Remove this
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Song) InternalImplementation() types.Map {
|
||||
return s.m
|
||||
}
|
||||
|
||||
func (s Song) Equals(other types.Value) bool {
|
||||
if other, ok := other.(Song); ok {
|
||||
return s.m.Equals(other.m)
|
||||
return s.Ref() == other.Ref()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (s Song) Ref() ref.Ref {
|
||||
return s.m.Ref()
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s Song) Chunks() (futures []types.Future) {
|
||||
@@ -117,7 +127,7 @@ func (s Song) Title() string {
|
||||
}
|
||||
|
||||
func (s Song) SetTitle(val string) Song {
|
||||
return Song{s.m.Set(types.NewString("Title"), types.NewString(val))}
|
||||
return Song{s.m.Set(types.NewString("Title"), types.NewString(val)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s Song) Artist() string {
|
||||
@@ -125,7 +135,7 @@ func (s Song) Artist() string {
|
||||
}
|
||||
|
||||
func (s Song) SetArtist(val string) Song {
|
||||
return Song{s.m.Set(types.NewString("Artist"), types.NewString(val))}
|
||||
return Song{s.m.Set(types.NewString("Artist"), types.NewString(val)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s Song) Album() string {
|
||||
@@ -133,7 +143,7 @@ func (s Song) Album() string {
|
||||
}
|
||||
|
||||
func (s Song) SetAlbum(val string) Song {
|
||||
return Song{s.m.Set(types.NewString("Album"), types.NewString(val))}
|
||||
return Song{s.m.Set(types.NewString("Album"), types.NewString(val)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s Song) Year() string {
|
||||
@@ -141,7 +151,7 @@ func (s Song) Year() string {
|
||||
}
|
||||
|
||||
func (s Song) SetYear(val string) Song {
|
||||
return Song{s.m.Set(types.NewString("Year"), types.NewString(val))}
|
||||
return Song{s.m.Set(types.NewString("Year"), types.NewString(val)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s Song) Mp3() types.Blob {
|
||||
@@ -149,17 +159,18 @@ func (s Song) Mp3() types.Blob {
|
||||
}
|
||||
|
||||
func (s Song) SetMp3(val types.Blob) Song {
|
||||
return Song{s.m.Set(types.NewString("Mp3"), val)}
|
||||
return Song{s.m.Set(types.NewString("Mp3"), val), &ref.Ref{}}
|
||||
}
|
||||
|
||||
// ListOfSong
|
||||
|
||||
type ListOfSong struct {
|
||||
l types.List
|
||||
l types.List
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewListOfSong() ListOfSong {
|
||||
return ListOfSong{types.NewList()}
|
||||
return ListOfSong{types.NewList(), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type ListOfSongDef []SongDef
|
||||
@@ -167,37 +178,46 @@ type ListOfSongDef []SongDef
|
||||
func (def ListOfSongDef) New() ListOfSong {
|
||||
l := make([]types.Value, len(def))
|
||||
for i, d := range def {
|
||||
l[i] = d.New().NomsValue()
|
||||
l[i] = d.New()
|
||||
}
|
||||
return ListOfSong{types.NewList(l...)}
|
||||
return ListOfSong{types.NewList(l...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfSong) Def() ListOfSongDef {
|
||||
d := make([]SongDef, l.Len())
|
||||
for i := uint64(0); i < l.Len(); i++ {
|
||||
d[i] = SongFromVal(l.l.Get(i)).Def()
|
||||
d[i] = l.l.Get(i).(Song).Def()
|
||||
}
|
||||
return d
|
||||
}
|
||||
|
||||
func ListOfSongFromVal(val types.Value) ListOfSong {
|
||||
// TODO: Do we still need FromVal?
|
||||
if val, ok := val.(ListOfSong); ok {
|
||||
return val
|
||||
}
|
||||
// TODO: Validate here
|
||||
return ListOfSong{val.(types.List)}
|
||||
return ListOfSong{val.(types.List), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfSong) NomsValue() types.Value {
|
||||
// TODO: Remove this
|
||||
return l
|
||||
}
|
||||
|
||||
func (l ListOfSong) InternalImplementation() types.List {
|
||||
return l.l
|
||||
}
|
||||
|
||||
func (l ListOfSong) Equals(other types.Value) bool {
|
||||
if other, ok := other.(ListOfSong); ok {
|
||||
return l.l.Equals(other.l)
|
||||
return l.Ref() == other.Ref()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (l ListOfSong) Ref() ref.Ref {
|
||||
return l.l.Ref()
|
||||
return types.EnsureRef(l.ref, l)
|
||||
}
|
||||
|
||||
func (l ListOfSong) Chunks() (futures []types.Future) {
|
||||
@@ -215,7 +235,7 @@ func (m ListOfSong) TypeRef() types.TypeRef {
|
||||
|
||||
func init() {
|
||||
__typeRefForListOfSong = types.MakeCompoundTypeRef("", types.ListKind, types.MakeTypeRef(__mainPackageInFile_types_CachedRef, 0))
|
||||
types.RegisterFromValFunction(__typeRefForListOfSong, func(v types.Value) types.NomsValue {
|
||||
types.RegisterFromValFunction(__typeRefForListOfSong, func(v types.Value) types.Value {
|
||||
return ListOfSongFromVal(v)
|
||||
})
|
||||
}
|
||||
@@ -229,37 +249,37 @@ func (l ListOfSong) Empty() bool {
|
||||
}
|
||||
|
||||
func (l ListOfSong) Get(i uint64) Song {
|
||||
return SongFromVal(l.l.Get(i))
|
||||
return l.l.Get(i).(Song)
|
||||
}
|
||||
|
||||
func (l ListOfSong) Slice(idx uint64, end uint64) ListOfSong {
|
||||
return ListOfSong{l.l.Slice(idx, end)}
|
||||
return ListOfSong{l.l.Slice(idx, end), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfSong) Set(i uint64, val Song) ListOfSong {
|
||||
return ListOfSong{l.l.Set(i, val.NomsValue())}
|
||||
return ListOfSong{l.l.Set(i, val), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfSong) Append(v ...Song) ListOfSong {
|
||||
return ListOfSong{l.l.Append(l.fromElemSlice(v)...)}
|
||||
return ListOfSong{l.l.Append(l.fromElemSlice(v)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfSong) Insert(idx uint64, v ...Song) ListOfSong {
|
||||
return ListOfSong{l.l.Insert(idx, l.fromElemSlice(v)...)}
|
||||
return ListOfSong{l.l.Insert(idx, l.fromElemSlice(v)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfSong) Remove(idx uint64, end uint64) ListOfSong {
|
||||
return ListOfSong{l.l.Remove(idx, end)}
|
||||
return ListOfSong{l.l.Remove(idx, end), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfSong) RemoveAt(idx uint64) ListOfSong {
|
||||
return ListOfSong{(l.l.RemoveAt(idx))}
|
||||
return ListOfSong{(l.l.RemoveAt(idx)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfSong) fromElemSlice(p []Song) []types.Value {
|
||||
r := make([]types.Value, len(p))
|
||||
for i, v := range p {
|
||||
r[i] = v.NomsValue()
|
||||
r[i] = v
|
||||
}
|
||||
return r
|
||||
}
|
||||
@@ -268,7 +288,7 @@ type ListOfSongIterCallback func(v Song, i uint64) (stop bool)
|
||||
|
||||
func (l ListOfSong) Iter(cb ListOfSongIterCallback) {
|
||||
l.l.Iter(func(v types.Value, i uint64) bool {
|
||||
return cb(SongFromVal(v), i)
|
||||
return cb(v.(Song), i)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -276,7 +296,7 @@ type ListOfSongIterAllCallback func(v Song, i uint64)
|
||||
|
||||
func (l ListOfSong) IterAll(cb ListOfSongIterAllCallback) {
|
||||
l.l.IterAll(func(v types.Value, i uint64) {
|
||||
cb(SongFromVal(v), i)
|
||||
cb(v.(Song), i)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
+143
-83
@@ -28,7 +28,8 @@ func __mainPackageInFile_types_Ref() ref.Ref {
|
||||
// Pitch
|
||||
|
||||
type Pitch struct {
|
||||
m types.Map
|
||||
m types.Map
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewPitch() Pitch {
|
||||
@@ -36,7 +37,7 @@ func NewPitch() Pitch {
|
||||
types.NewString("$type"), types.MakeTypeRef(__mainPackageInFile_types_CachedRef, 0),
|
||||
types.NewString("X"), types.Float64(0),
|
||||
types.NewString("Z"), types.Float64(0),
|
||||
)}
|
||||
), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type PitchDef struct {
|
||||
@@ -50,7 +51,7 @@ func (def PitchDef) New() Pitch {
|
||||
types.NewString("$type"), types.MakeTypeRef(__mainPackageInFile_types_CachedRef, 0),
|
||||
types.NewString("X"), types.Float64(def.X),
|
||||
types.NewString("Z"), types.Float64(def.Z),
|
||||
)}
|
||||
), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s Pitch) Def() (d PitchDef) {
|
||||
@@ -66,29 +67,38 @@ func (m Pitch) TypeRef() types.TypeRef {
|
||||
}
|
||||
|
||||
func init() {
|
||||
types.RegisterFromValFunction(__typeRefForPitch, func(v types.Value) types.NomsValue {
|
||||
types.RegisterFromValFunction(__typeRefForPitch, func(v types.Value) types.Value {
|
||||
return PitchFromVal(v)
|
||||
})
|
||||
}
|
||||
|
||||
func PitchFromVal(val types.Value) Pitch {
|
||||
// TODO: Do we still need FromVal?
|
||||
if val, ok := val.(Pitch); ok {
|
||||
return val
|
||||
}
|
||||
// TODO: Validate here
|
||||
return Pitch{val.(types.Map)}
|
||||
return Pitch{val.(types.Map), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s Pitch) NomsValue() types.Value {
|
||||
// TODO: Remove this
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Pitch) InternalImplementation() types.Map {
|
||||
return s.m
|
||||
}
|
||||
|
||||
func (s Pitch) Equals(other types.Value) bool {
|
||||
if other, ok := other.(Pitch); ok {
|
||||
return s.m.Equals(other.m)
|
||||
return s.Ref() == other.Ref()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (s Pitch) Ref() ref.Ref {
|
||||
return s.m.Ref()
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s Pitch) Chunks() (futures []types.Future) {
|
||||
@@ -102,7 +112,7 @@ func (s Pitch) X() float64 {
|
||||
}
|
||||
|
||||
func (s Pitch) SetX(val float64) Pitch {
|
||||
return Pitch{s.m.Set(types.NewString("X"), types.Float64(val))}
|
||||
return Pitch{s.m.Set(types.NewString("X"), types.Float64(val)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s Pitch) Z() float64 {
|
||||
@@ -110,17 +120,18 @@ func (s Pitch) Z() float64 {
|
||||
}
|
||||
|
||||
func (s Pitch) SetZ(val float64) Pitch {
|
||||
return Pitch{s.m.Set(types.NewString("Z"), types.Float64(val))}
|
||||
return Pitch{s.m.Set(types.NewString("Z"), types.Float64(val)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
// ListOfMapOfStringToValue
|
||||
|
||||
type ListOfMapOfStringToValue struct {
|
||||
l types.List
|
||||
l types.List
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewListOfMapOfStringToValue() ListOfMapOfStringToValue {
|
||||
return ListOfMapOfStringToValue{types.NewList()}
|
||||
return ListOfMapOfStringToValue{types.NewList(), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type ListOfMapOfStringToValueDef []MapOfStringToValueDef
|
||||
@@ -128,37 +139,46 @@ type ListOfMapOfStringToValueDef []MapOfStringToValueDef
|
||||
func (def ListOfMapOfStringToValueDef) New() ListOfMapOfStringToValue {
|
||||
l := make([]types.Value, len(def))
|
||||
for i, d := range def {
|
||||
l[i] = d.New().NomsValue()
|
||||
l[i] = d.New()
|
||||
}
|
||||
return ListOfMapOfStringToValue{types.NewList(l...)}
|
||||
return ListOfMapOfStringToValue{types.NewList(l...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfMapOfStringToValue) Def() ListOfMapOfStringToValueDef {
|
||||
d := make([]MapOfStringToValueDef, l.Len())
|
||||
for i := uint64(0); i < l.Len(); i++ {
|
||||
d[i] = MapOfStringToValueFromVal(l.l.Get(i)).Def()
|
||||
d[i] = l.l.Get(i).(MapOfStringToValue).Def()
|
||||
}
|
||||
return d
|
||||
}
|
||||
|
||||
func ListOfMapOfStringToValueFromVal(val types.Value) ListOfMapOfStringToValue {
|
||||
// TODO: Do we still need FromVal?
|
||||
if val, ok := val.(ListOfMapOfStringToValue); ok {
|
||||
return val
|
||||
}
|
||||
// TODO: Validate here
|
||||
return ListOfMapOfStringToValue{val.(types.List)}
|
||||
return ListOfMapOfStringToValue{val.(types.List), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfMapOfStringToValue) NomsValue() types.Value {
|
||||
// TODO: Remove this
|
||||
return l
|
||||
}
|
||||
|
||||
func (l ListOfMapOfStringToValue) InternalImplementation() types.List {
|
||||
return l.l
|
||||
}
|
||||
|
||||
func (l ListOfMapOfStringToValue) Equals(other types.Value) bool {
|
||||
if other, ok := other.(ListOfMapOfStringToValue); ok {
|
||||
return l.l.Equals(other.l)
|
||||
return l.Ref() == other.Ref()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (l ListOfMapOfStringToValue) Ref() ref.Ref {
|
||||
return l.l.Ref()
|
||||
return types.EnsureRef(l.ref, l)
|
||||
}
|
||||
|
||||
func (l ListOfMapOfStringToValue) Chunks() (futures []types.Future) {
|
||||
@@ -176,7 +196,7 @@ func (m ListOfMapOfStringToValue) TypeRef() types.TypeRef {
|
||||
|
||||
func init() {
|
||||
__typeRefForListOfMapOfStringToValue = types.MakeCompoundTypeRef("", types.ListKind, types.MakeCompoundTypeRef("", types.MapKind, types.MakePrimitiveTypeRef(types.StringKind), types.MakePrimitiveTypeRef(types.ValueKind)))
|
||||
types.RegisterFromValFunction(__typeRefForListOfMapOfStringToValue, func(v types.Value) types.NomsValue {
|
||||
types.RegisterFromValFunction(__typeRefForListOfMapOfStringToValue, func(v types.Value) types.Value {
|
||||
return ListOfMapOfStringToValueFromVal(v)
|
||||
})
|
||||
}
|
||||
@@ -190,37 +210,37 @@ func (l ListOfMapOfStringToValue) Empty() bool {
|
||||
}
|
||||
|
||||
func (l ListOfMapOfStringToValue) Get(i uint64) MapOfStringToValue {
|
||||
return MapOfStringToValueFromVal(l.l.Get(i))
|
||||
return l.l.Get(i).(MapOfStringToValue)
|
||||
}
|
||||
|
||||
func (l ListOfMapOfStringToValue) Slice(idx uint64, end uint64) ListOfMapOfStringToValue {
|
||||
return ListOfMapOfStringToValue{l.l.Slice(idx, end)}
|
||||
return ListOfMapOfStringToValue{l.l.Slice(idx, end), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfMapOfStringToValue) Set(i uint64, val MapOfStringToValue) ListOfMapOfStringToValue {
|
||||
return ListOfMapOfStringToValue{l.l.Set(i, val.NomsValue())}
|
||||
return ListOfMapOfStringToValue{l.l.Set(i, val), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfMapOfStringToValue) Append(v ...MapOfStringToValue) ListOfMapOfStringToValue {
|
||||
return ListOfMapOfStringToValue{l.l.Append(l.fromElemSlice(v)...)}
|
||||
return ListOfMapOfStringToValue{l.l.Append(l.fromElemSlice(v)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfMapOfStringToValue) Insert(idx uint64, v ...MapOfStringToValue) ListOfMapOfStringToValue {
|
||||
return ListOfMapOfStringToValue{l.l.Insert(idx, l.fromElemSlice(v)...)}
|
||||
return ListOfMapOfStringToValue{l.l.Insert(idx, l.fromElemSlice(v)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfMapOfStringToValue) Remove(idx uint64, end uint64) ListOfMapOfStringToValue {
|
||||
return ListOfMapOfStringToValue{l.l.Remove(idx, end)}
|
||||
return ListOfMapOfStringToValue{l.l.Remove(idx, end), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfMapOfStringToValue) RemoveAt(idx uint64) ListOfMapOfStringToValue {
|
||||
return ListOfMapOfStringToValue{(l.l.RemoveAt(idx))}
|
||||
return ListOfMapOfStringToValue{(l.l.RemoveAt(idx)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfMapOfStringToValue) fromElemSlice(p []MapOfStringToValue) []types.Value {
|
||||
r := make([]types.Value, len(p))
|
||||
for i, v := range p {
|
||||
r[i] = v.NomsValue()
|
||||
r[i] = v
|
||||
}
|
||||
return r
|
||||
}
|
||||
@@ -229,7 +249,7 @@ type ListOfMapOfStringToValueIterCallback func(v MapOfStringToValue, i uint64) (
|
||||
|
||||
func (l ListOfMapOfStringToValue) Iter(cb ListOfMapOfStringToValueIterCallback) {
|
||||
l.l.Iter(func(v types.Value, i uint64) bool {
|
||||
return cb(MapOfStringToValueFromVal(v), i)
|
||||
return cb(v.(MapOfStringToValue), i)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -237,7 +257,7 @@ type ListOfMapOfStringToValueIterAllCallback func(v MapOfStringToValue, i uint64
|
||||
|
||||
func (l ListOfMapOfStringToValue) IterAll(cb ListOfMapOfStringToValueIterAllCallback) {
|
||||
l.l.IterAll(func(v types.Value, i uint64) {
|
||||
cb(MapOfStringToValueFromVal(v), i)
|
||||
cb(v.(MapOfStringToValue), i)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -256,11 +276,12 @@ func (l ListOfMapOfStringToValue) Filter(cb ListOfMapOfStringToValueFilterCallba
|
||||
// MapOfStringToListOfPitch
|
||||
|
||||
type MapOfStringToListOfPitch struct {
|
||||
m types.Map
|
||||
m types.Map
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewMapOfStringToListOfPitch() MapOfStringToListOfPitch {
|
||||
return MapOfStringToListOfPitch{types.NewMap()}
|
||||
return MapOfStringToListOfPitch{types.NewMap(), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type MapOfStringToListOfPitchDef map[string]ListOfPitchDef
|
||||
@@ -268,38 +289,47 @@ type MapOfStringToListOfPitchDef map[string]ListOfPitchDef
|
||||
func (def MapOfStringToListOfPitchDef) New() MapOfStringToListOfPitch {
|
||||
kv := make([]types.Value, 0, len(def)*2)
|
||||
for k, v := range def {
|
||||
kv = append(kv, types.NewString(k), v.New().NomsValue())
|
||||
kv = append(kv, types.NewString(k), v.New())
|
||||
}
|
||||
return MapOfStringToListOfPitch{types.NewMap(kv...)}
|
||||
return MapOfStringToListOfPitch{types.NewMap(kv...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (m MapOfStringToListOfPitch) Def() MapOfStringToListOfPitchDef {
|
||||
def := make(map[string]ListOfPitchDef)
|
||||
m.m.Iter(func(k, v types.Value) bool {
|
||||
def[k.(types.String).String()] = ListOfPitchFromVal(v).Def()
|
||||
def[k.(types.String).String()] = v.(ListOfPitch).Def()
|
||||
return false
|
||||
})
|
||||
return def
|
||||
}
|
||||
|
||||
func MapOfStringToListOfPitchFromVal(p types.Value) MapOfStringToListOfPitch {
|
||||
func MapOfStringToListOfPitchFromVal(val types.Value) MapOfStringToListOfPitch {
|
||||
// TODO: Do we still need FromVal?
|
||||
if val, ok := val.(MapOfStringToListOfPitch); ok {
|
||||
return val
|
||||
}
|
||||
// TODO: Validate here
|
||||
return MapOfStringToListOfPitch{p.(types.Map)}
|
||||
return MapOfStringToListOfPitch{val.(types.Map), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (m MapOfStringToListOfPitch) NomsValue() types.Value {
|
||||
// TODO: Remove this
|
||||
return m
|
||||
}
|
||||
|
||||
func (m MapOfStringToListOfPitch) InternalImplementation() types.Map {
|
||||
return m.m
|
||||
}
|
||||
|
||||
func (m MapOfStringToListOfPitch) Equals(other types.Value) bool {
|
||||
if other, ok := other.(MapOfStringToListOfPitch); ok {
|
||||
return m.m.Equals(other.m)
|
||||
return m.Ref() == other.Ref()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (m MapOfStringToListOfPitch) Ref() ref.Ref {
|
||||
return m.m.Ref()
|
||||
return types.EnsureRef(m.ref, m)
|
||||
}
|
||||
|
||||
func (m MapOfStringToListOfPitch) Chunks() (futures []types.Future) {
|
||||
@@ -317,7 +347,7 @@ func (m MapOfStringToListOfPitch) TypeRef() types.TypeRef {
|
||||
|
||||
func init() {
|
||||
__typeRefForMapOfStringToListOfPitch = types.MakeCompoundTypeRef("", types.MapKind, types.MakePrimitiveTypeRef(types.StringKind), types.MakeCompoundTypeRef("", types.ListKind, types.MakeTypeRef(__mainPackageInFile_types_CachedRef, 0)))
|
||||
types.RegisterFromValFunction(__typeRefForMapOfStringToListOfPitch, func(v types.Value) types.NomsValue {
|
||||
types.RegisterFromValFunction(__typeRefForMapOfStringToListOfPitch, func(v types.Value) types.Value {
|
||||
return MapOfStringToListOfPitchFromVal(v)
|
||||
})
|
||||
}
|
||||
@@ -335,7 +365,7 @@ func (m MapOfStringToListOfPitch) Has(p string) bool {
|
||||
}
|
||||
|
||||
func (m MapOfStringToListOfPitch) Get(p string) ListOfPitch {
|
||||
return ListOfPitchFromVal(m.m.Get(types.NewString(p)))
|
||||
return m.m.Get(types.NewString(p)).(ListOfPitch)
|
||||
}
|
||||
|
||||
func (m MapOfStringToListOfPitch) MaybeGet(p string) (ListOfPitch, bool) {
|
||||
@@ -343,24 +373,24 @@ func (m MapOfStringToListOfPitch) MaybeGet(p string) (ListOfPitch, bool) {
|
||||
if !ok {
|
||||
return NewListOfPitch(), false
|
||||
}
|
||||
return ListOfPitchFromVal(v), ok
|
||||
return v.(ListOfPitch), ok
|
||||
}
|
||||
|
||||
func (m MapOfStringToListOfPitch) Set(k string, v ListOfPitch) MapOfStringToListOfPitch {
|
||||
return MapOfStringToListOfPitch{m.m.Set(types.NewString(k), v.NomsValue())}
|
||||
return MapOfStringToListOfPitch{m.m.Set(types.NewString(k), v), &ref.Ref{}}
|
||||
}
|
||||
|
||||
// TODO: Implement SetM?
|
||||
|
||||
func (m MapOfStringToListOfPitch) Remove(p string) MapOfStringToListOfPitch {
|
||||
return MapOfStringToListOfPitch{m.m.Remove(types.NewString(p))}
|
||||
return MapOfStringToListOfPitch{m.m.Remove(types.NewString(p)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type MapOfStringToListOfPitchIterCallback func(k string, v ListOfPitch) (stop bool)
|
||||
|
||||
func (m MapOfStringToListOfPitch) Iter(cb MapOfStringToListOfPitchIterCallback) {
|
||||
m.m.Iter(func(k, v types.Value) bool {
|
||||
return cb(k.(types.String).String(), ListOfPitchFromVal(v))
|
||||
return cb(k.(types.String).String(), v.(ListOfPitch))
|
||||
})
|
||||
}
|
||||
|
||||
@@ -368,7 +398,7 @@ type MapOfStringToListOfPitchIterAllCallback func(k string, v ListOfPitch)
|
||||
|
||||
func (m MapOfStringToListOfPitch) IterAll(cb MapOfStringToListOfPitchIterAllCallback) {
|
||||
m.m.IterAll(func(k, v types.Value) {
|
||||
cb(k.(types.String).String(), ListOfPitchFromVal(v))
|
||||
cb(k.(types.String).String(), v.(ListOfPitch))
|
||||
})
|
||||
}
|
||||
|
||||
@@ -387,11 +417,12 @@ func (m MapOfStringToListOfPitch) Filter(cb MapOfStringToListOfPitchFilterCallba
|
||||
// MapOfStringToString
|
||||
|
||||
type MapOfStringToString struct {
|
||||
m types.Map
|
||||
m types.Map
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewMapOfStringToString() MapOfStringToString {
|
||||
return MapOfStringToString{types.NewMap()}
|
||||
return MapOfStringToString{types.NewMap(), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type MapOfStringToStringDef map[string]string
|
||||
@@ -401,7 +432,7 @@ func (def MapOfStringToStringDef) New() MapOfStringToString {
|
||||
for k, v := range def {
|
||||
kv = append(kv, types.NewString(k), types.NewString(v))
|
||||
}
|
||||
return MapOfStringToString{types.NewMap(kv...)}
|
||||
return MapOfStringToString{types.NewMap(kv...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (m MapOfStringToString) Def() MapOfStringToStringDef {
|
||||
@@ -413,24 +444,33 @@ func (m MapOfStringToString) Def() MapOfStringToStringDef {
|
||||
return def
|
||||
}
|
||||
|
||||
func MapOfStringToStringFromVal(p types.Value) MapOfStringToString {
|
||||
func MapOfStringToStringFromVal(val types.Value) MapOfStringToString {
|
||||
// TODO: Do we still need FromVal?
|
||||
if val, ok := val.(MapOfStringToString); ok {
|
||||
return val
|
||||
}
|
||||
// TODO: Validate here
|
||||
return MapOfStringToString{p.(types.Map)}
|
||||
return MapOfStringToString{val.(types.Map), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (m MapOfStringToString) NomsValue() types.Value {
|
||||
// TODO: Remove this
|
||||
return m
|
||||
}
|
||||
|
||||
func (m MapOfStringToString) InternalImplementation() types.Map {
|
||||
return m.m
|
||||
}
|
||||
|
||||
func (m MapOfStringToString) Equals(other types.Value) bool {
|
||||
if other, ok := other.(MapOfStringToString); ok {
|
||||
return m.m.Equals(other.m)
|
||||
return m.Ref() == other.Ref()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (m MapOfStringToString) Ref() ref.Ref {
|
||||
return m.m.Ref()
|
||||
return types.EnsureRef(m.ref, m)
|
||||
}
|
||||
|
||||
func (m MapOfStringToString) Chunks() (futures []types.Future) {
|
||||
@@ -448,7 +488,7 @@ func (m MapOfStringToString) TypeRef() types.TypeRef {
|
||||
|
||||
func init() {
|
||||
__typeRefForMapOfStringToString = types.MakeCompoundTypeRef("", types.MapKind, types.MakePrimitiveTypeRef(types.StringKind), types.MakePrimitiveTypeRef(types.StringKind))
|
||||
types.RegisterFromValFunction(__typeRefForMapOfStringToString, func(v types.Value) types.NomsValue {
|
||||
types.RegisterFromValFunction(__typeRefForMapOfStringToString, func(v types.Value) types.Value {
|
||||
return MapOfStringToStringFromVal(v)
|
||||
})
|
||||
}
|
||||
@@ -478,13 +518,13 @@ func (m MapOfStringToString) MaybeGet(p string) (string, bool) {
|
||||
}
|
||||
|
||||
func (m MapOfStringToString) Set(k string, v string) MapOfStringToString {
|
||||
return MapOfStringToString{m.m.Set(types.NewString(k), types.NewString(v))}
|
||||
return MapOfStringToString{m.m.Set(types.NewString(k), types.NewString(v)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
// TODO: Implement SetM?
|
||||
|
||||
func (m MapOfStringToString) Remove(p string) MapOfStringToString {
|
||||
return MapOfStringToString{m.m.Remove(types.NewString(p))}
|
||||
return MapOfStringToString{m.m.Remove(types.NewString(p)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type MapOfStringToStringIterCallback func(k string, v string) (stop bool)
|
||||
@@ -518,11 +558,12 @@ func (m MapOfStringToString) Filter(cb MapOfStringToStringFilterCallback) MapOfS
|
||||
// MapOfStringToValue
|
||||
|
||||
type MapOfStringToValue struct {
|
||||
m types.Map
|
||||
m types.Map
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewMapOfStringToValue() MapOfStringToValue {
|
||||
return MapOfStringToValue{types.NewMap()}
|
||||
return MapOfStringToValue{types.NewMap(), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type MapOfStringToValueDef map[string]types.Value
|
||||
@@ -532,7 +573,7 @@ func (def MapOfStringToValueDef) New() MapOfStringToValue {
|
||||
for k, v := range def {
|
||||
kv = append(kv, types.NewString(k), v)
|
||||
}
|
||||
return MapOfStringToValue{types.NewMap(kv...)}
|
||||
return MapOfStringToValue{types.NewMap(kv...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (m MapOfStringToValue) Def() MapOfStringToValueDef {
|
||||
@@ -544,24 +585,33 @@ func (m MapOfStringToValue) Def() MapOfStringToValueDef {
|
||||
return def
|
||||
}
|
||||
|
||||
func MapOfStringToValueFromVal(p types.Value) MapOfStringToValue {
|
||||
func MapOfStringToValueFromVal(val types.Value) MapOfStringToValue {
|
||||
// TODO: Do we still need FromVal?
|
||||
if val, ok := val.(MapOfStringToValue); ok {
|
||||
return val
|
||||
}
|
||||
// TODO: Validate here
|
||||
return MapOfStringToValue{p.(types.Map)}
|
||||
return MapOfStringToValue{val.(types.Map), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (m MapOfStringToValue) NomsValue() types.Value {
|
||||
// TODO: Remove this
|
||||
return m
|
||||
}
|
||||
|
||||
func (m MapOfStringToValue) InternalImplementation() types.Map {
|
||||
return m.m
|
||||
}
|
||||
|
||||
func (m MapOfStringToValue) Equals(other types.Value) bool {
|
||||
if other, ok := other.(MapOfStringToValue); ok {
|
||||
return m.m.Equals(other.m)
|
||||
return m.Ref() == other.Ref()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (m MapOfStringToValue) Ref() ref.Ref {
|
||||
return m.m.Ref()
|
||||
return types.EnsureRef(m.ref, m)
|
||||
}
|
||||
|
||||
func (m MapOfStringToValue) Chunks() (futures []types.Future) {
|
||||
@@ -579,7 +629,7 @@ func (m MapOfStringToValue) TypeRef() types.TypeRef {
|
||||
|
||||
func init() {
|
||||
__typeRefForMapOfStringToValue = types.MakeCompoundTypeRef("", types.MapKind, types.MakePrimitiveTypeRef(types.StringKind), types.MakePrimitiveTypeRef(types.ValueKind))
|
||||
types.RegisterFromValFunction(__typeRefForMapOfStringToValue, func(v types.Value) types.NomsValue {
|
||||
types.RegisterFromValFunction(__typeRefForMapOfStringToValue, func(v types.Value) types.Value {
|
||||
return MapOfStringToValueFromVal(v)
|
||||
})
|
||||
}
|
||||
@@ -609,13 +659,13 @@ func (m MapOfStringToValue) MaybeGet(p string) (types.Value, bool) {
|
||||
}
|
||||
|
||||
func (m MapOfStringToValue) Set(k string, v types.Value) MapOfStringToValue {
|
||||
return MapOfStringToValue{m.m.Set(types.NewString(k), v)}
|
||||
return MapOfStringToValue{m.m.Set(types.NewString(k), v), &ref.Ref{}}
|
||||
}
|
||||
|
||||
// TODO: Implement SetM?
|
||||
|
||||
func (m MapOfStringToValue) Remove(p string) MapOfStringToValue {
|
||||
return MapOfStringToValue{m.m.Remove(types.NewString(p))}
|
||||
return MapOfStringToValue{m.m.Remove(types.NewString(p)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type MapOfStringToValueIterCallback func(k string, v types.Value) (stop bool)
|
||||
@@ -649,11 +699,12 @@ func (m MapOfStringToValue) Filter(cb MapOfStringToValueFilterCallback) MapOfStr
|
||||
// ListOfPitch
|
||||
|
||||
type ListOfPitch struct {
|
||||
l types.List
|
||||
l types.List
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewListOfPitch() ListOfPitch {
|
||||
return ListOfPitch{types.NewList()}
|
||||
return ListOfPitch{types.NewList(), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type ListOfPitchDef []PitchDef
|
||||
@@ -661,37 +712,46 @@ type ListOfPitchDef []PitchDef
|
||||
func (def ListOfPitchDef) New() ListOfPitch {
|
||||
l := make([]types.Value, len(def))
|
||||
for i, d := range def {
|
||||
l[i] = d.New().NomsValue()
|
||||
l[i] = d.New()
|
||||
}
|
||||
return ListOfPitch{types.NewList(l...)}
|
||||
return ListOfPitch{types.NewList(l...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfPitch) Def() ListOfPitchDef {
|
||||
d := make([]PitchDef, l.Len())
|
||||
for i := uint64(0); i < l.Len(); i++ {
|
||||
d[i] = PitchFromVal(l.l.Get(i)).Def()
|
||||
d[i] = l.l.Get(i).(Pitch).Def()
|
||||
}
|
||||
return d
|
||||
}
|
||||
|
||||
func ListOfPitchFromVal(val types.Value) ListOfPitch {
|
||||
// TODO: Do we still need FromVal?
|
||||
if val, ok := val.(ListOfPitch); ok {
|
||||
return val
|
||||
}
|
||||
// TODO: Validate here
|
||||
return ListOfPitch{val.(types.List)}
|
||||
return ListOfPitch{val.(types.List), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfPitch) NomsValue() types.Value {
|
||||
// TODO: Remove this
|
||||
return l
|
||||
}
|
||||
|
||||
func (l ListOfPitch) InternalImplementation() types.List {
|
||||
return l.l
|
||||
}
|
||||
|
||||
func (l ListOfPitch) Equals(other types.Value) bool {
|
||||
if other, ok := other.(ListOfPitch); ok {
|
||||
return l.l.Equals(other.l)
|
||||
return l.Ref() == other.Ref()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (l ListOfPitch) Ref() ref.Ref {
|
||||
return l.l.Ref()
|
||||
return types.EnsureRef(l.ref, l)
|
||||
}
|
||||
|
||||
func (l ListOfPitch) Chunks() (futures []types.Future) {
|
||||
@@ -709,7 +769,7 @@ func (m ListOfPitch) TypeRef() types.TypeRef {
|
||||
|
||||
func init() {
|
||||
__typeRefForListOfPitch = types.MakeCompoundTypeRef("", types.ListKind, types.MakeTypeRef(__mainPackageInFile_types_CachedRef, 0))
|
||||
types.RegisterFromValFunction(__typeRefForListOfPitch, func(v types.Value) types.NomsValue {
|
||||
types.RegisterFromValFunction(__typeRefForListOfPitch, func(v types.Value) types.Value {
|
||||
return ListOfPitchFromVal(v)
|
||||
})
|
||||
}
|
||||
@@ -723,37 +783,37 @@ func (l ListOfPitch) Empty() bool {
|
||||
}
|
||||
|
||||
func (l ListOfPitch) Get(i uint64) Pitch {
|
||||
return PitchFromVal(l.l.Get(i))
|
||||
return l.l.Get(i).(Pitch)
|
||||
}
|
||||
|
||||
func (l ListOfPitch) Slice(idx uint64, end uint64) ListOfPitch {
|
||||
return ListOfPitch{l.l.Slice(idx, end)}
|
||||
return ListOfPitch{l.l.Slice(idx, end), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfPitch) Set(i uint64, val Pitch) ListOfPitch {
|
||||
return ListOfPitch{l.l.Set(i, val.NomsValue())}
|
||||
return ListOfPitch{l.l.Set(i, val), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfPitch) Append(v ...Pitch) ListOfPitch {
|
||||
return ListOfPitch{l.l.Append(l.fromElemSlice(v)...)}
|
||||
return ListOfPitch{l.l.Append(l.fromElemSlice(v)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfPitch) Insert(idx uint64, v ...Pitch) ListOfPitch {
|
||||
return ListOfPitch{l.l.Insert(idx, l.fromElemSlice(v)...)}
|
||||
return ListOfPitch{l.l.Insert(idx, l.fromElemSlice(v)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfPitch) Remove(idx uint64, end uint64) ListOfPitch {
|
||||
return ListOfPitch{l.l.Remove(idx, end)}
|
||||
return ListOfPitch{l.l.Remove(idx, end), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfPitch) RemoveAt(idx uint64) ListOfPitch {
|
||||
return ListOfPitch{(l.l.RemoveAt(idx))}
|
||||
return ListOfPitch{(l.l.RemoveAt(idx)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfPitch) fromElemSlice(p []Pitch) []types.Value {
|
||||
r := make([]types.Value, len(p))
|
||||
for i, v := range p {
|
||||
r[i] = v.NomsValue()
|
||||
r[i] = v
|
||||
}
|
||||
return r
|
||||
}
|
||||
@@ -762,7 +822,7 @@ type ListOfPitchIterCallback func(v Pitch, i uint64) (stop bool)
|
||||
|
||||
func (l ListOfPitch) Iter(cb ListOfPitchIterCallback) {
|
||||
l.l.Iter(func(v types.Value, i uint64) bool {
|
||||
return cb(PitchFromVal(v), i)
|
||||
return cb(v.(Pitch), i)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -770,7 +830,7 @@ type ListOfPitchIterAllCallback func(v Pitch, i uint64)
|
||||
|
||||
func (l ListOfPitch) IterAll(cb ListOfPitchIterAllCallback) {
|
||||
l.l.IterAll(func(v types.Value, i uint64) {
|
||||
cb(PitchFromVal(v), i)
|
||||
cb(v.(Pitch), i)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
geo "github.com/attic-labs/noms/clients/gen/sha1_52bbaa7c5bcb39759981ccb12ee457f21fa7517d"
|
||||
geo "github.com/attic-labs/noms/clients/gen/sha1_fb09d21d144c518467325465327d46489cff7c47"
|
||||
"github.com/attic-labs/noms/d"
|
||||
"github.com/attic-labs/noms/datas"
|
||||
"github.com/attic-labs/noms/dataset"
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/attic-labs/noms/chunks"
|
||||
geo "github.com/attic-labs/noms/clients/gen/sha1_52bbaa7c5bcb39759981ccb12ee457f21fa7517d"
|
||||
geo "github.com/attic-labs/noms/clients/gen/sha1_fb09d21d144c518467325465327d46489cff7c47"
|
||||
"github.com/attic-labs/noms/clients/util"
|
||||
"github.com/attic-labs/noms/d"
|
||||
"github.com/attic-labs/noms/types"
|
||||
|
||||
+259
-170
File diff suppressed because it is too large
Load Diff
@@ -13,7 +13,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/attic-labs/noms/chunks"
|
||||
geo "github.com/attic-labs/noms/clients/gen/sha1_52bbaa7c5bcb39759981ccb12ee457f21fa7517d"
|
||||
geo "github.com/attic-labs/noms/clients/gen/sha1_fb09d21d144c518467325465327d46489cff7c47"
|
||||
"github.com/attic-labs/noms/clients/util"
|
||||
"github.com/attic-labs/noms/d"
|
||||
"github.com/attic-labs/noms/dataset"
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/attic-labs/noms/clients/gen/sha1_52bbaa7c5bcb39759981ccb12ee457f21fa7517d"
|
||||
"github.com/attic-labs/noms/clients/gen/sha1_fb09d21d144c518467325465327d46489cff7c47"
|
||||
|
||||
"github.com/attic-labs/noms/ref"
|
||||
"github.com/attic-labs/noms/types"
|
||||
)
|
||||
@@ -26,13 +27,13 @@ func __mainPackageInFile_types_Ref() ref.Ref {
|
||||
types.Field{"PdDistrict", types.MakePrimitiveTypeRef(types.StringKind), false},
|
||||
types.Field{"Resolution", types.MakePrimitiveTypeRef(types.StringKind), false},
|
||||
types.Field{"Address", types.MakePrimitiveTypeRef(types.StringKind), false},
|
||||
types.Field{"Geoposition", types.MakeTypeRef(ref.Parse("sha1-52bbaa7c5bcb39759981ccb12ee457f21fa7517d"), 0), false},
|
||||
types.Field{"Geoposition", types.MakeTypeRef(ref.Parse("sha1-fb09d21d144c518467325465327d46489cff7c47"), 0), false},
|
||||
types.Field{"PdID", types.MakePrimitiveTypeRef(types.StringKind), false},
|
||||
},
|
||||
types.Choices{},
|
||||
),
|
||||
}, []ref.Ref{
|
||||
ref.Parse("sha1-52bbaa7c5bcb39759981ccb12ee457f21fa7517d"),
|
||||
ref.Parse("sha1-fb09d21d144c518467325465327d46489cff7c47"),
|
||||
})
|
||||
return types.RegisterPackage(&p)
|
||||
}
|
||||
@@ -40,7 +41,8 @@ func __mainPackageInFile_types_Ref() ref.Ref {
|
||||
// Incident
|
||||
|
||||
type Incident struct {
|
||||
m types.Map
|
||||
m types.Map
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewIncident() Incident {
|
||||
@@ -55,9 +57,9 @@ func NewIncident() Incident {
|
||||
types.NewString("PdDistrict"), types.NewString(""),
|
||||
types.NewString("Resolution"), types.NewString(""),
|
||||
types.NewString("Address"), types.NewString(""),
|
||||
types.NewString("Geoposition"), sha1_52bbaa7c5bcb39759981ccb12ee457f21fa7517d.NewGeoposition().NomsValue(),
|
||||
types.NewString("Geoposition"), sha1_fb09d21d144c518467325465327d46489cff7c47.NewGeoposition(),
|
||||
types.NewString("PdID"), types.NewString(""),
|
||||
)}
|
||||
), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type IncidentDef struct {
|
||||
@@ -70,7 +72,7 @@ type IncidentDef struct {
|
||||
PdDistrict string
|
||||
Resolution string
|
||||
Address string
|
||||
Geoposition sha1_52bbaa7c5bcb39759981ccb12ee457f21fa7517d.GeopositionDef
|
||||
Geoposition sha1_fb09d21d144c518467325465327d46489cff7c47.GeopositionDef
|
||||
PdID string
|
||||
}
|
||||
|
||||
@@ -87,9 +89,9 @@ func (def IncidentDef) New() Incident {
|
||||
types.NewString("PdDistrict"), types.NewString(def.PdDistrict),
|
||||
types.NewString("Resolution"), types.NewString(def.Resolution),
|
||||
types.NewString("Address"), types.NewString(def.Address),
|
||||
types.NewString("Geoposition"), def.Geoposition.New().NomsValue(),
|
||||
types.NewString("Geoposition"), def.Geoposition.New(),
|
||||
types.NewString("PdID"), types.NewString(def.PdID),
|
||||
)}
|
||||
), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s Incident) Def() (d IncidentDef) {
|
||||
@@ -102,7 +104,7 @@ func (s Incident) Def() (d IncidentDef) {
|
||||
d.PdDistrict = s.m.Get(types.NewString("PdDistrict")).(types.String).String()
|
||||
d.Resolution = s.m.Get(types.NewString("Resolution")).(types.String).String()
|
||||
d.Address = s.m.Get(types.NewString("Address")).(types.String).String()
|
||||
d.Geoposition = sha1_52bbaa7c5bcb39759981ccb12ee457f21fa7517d.GeopositionFromVal(s.m.Get(types.NewString("Geoposition"))).Def()
|
||||
d.Geoposition = s.m.Get(types.NewString("Geoposition")).(sha1_fb09d21d144c518467325465327d46489cff7c47.Geoposition).Def()
|
||||
d.PdID = s.m.Get(types.NewString("PdID")).(types.String).String()
|
||||
return
|
||||
}
|
||||
@@ -114,29 +116,38 @@ func (m Incident) TypeRef() types.TypeRef {
|
||||
}
|
||||
|
||||
func init() {
|
||||
types.RegisterFromValFunction(__typeRefForIncident, func(v types.Value) types.NomsValue {
|
||||
types.RegisterFromValFunction(__typeRefForIncident, func(v types.Value) types.Value {
|
||||
return IncidentFromVal(v)
|
||||
})
|
||||
}
|
||||
|
||||
func IncidentFromVal(val types.Value) Incident {
|
||||
// TODO: Do we still need FromVal?
|
||||
if val, ok := val.(Incident); ok {
|
||||
return val
|
||||
}
|
||||
// TODO: Validate here
|
||||
return Incident{val.(types.Map)}
|
||||
return Incident{val.(types.Map), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s Incident) NomsValue() types.Value {
|
||||
// TODO: Remove this
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Incident) InternalImplementation() types.Map {
|
||||
return s.m
|
||||
}
|
||||
|
||||
func (s Incident) Equals(other types.Value) bool {
|
||||
if other, ok := other.(Incident); ok {
|
||||
return s.m.Equals(other.m)
|
||||
return s.Ref() == other.Ref()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (s Incident) Ref() ref.Ref {
|
||||
return s.m.Ref()
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s Incident) Chunks() (futures []types.Future) {
|
||||
@@ -150,7 +161,7 @@ func (s Incident) ID() int64 {
|
||||
}
|
||||
|
||||
func (s Incident) SetID(val int64) Incident {
|
||||
return Incident{s.m.Set(types.NewString("ID"), types.Int64(val))}
|
||||
return Incident{s.m.Set(types.NewString("ID"), types.Int64(val)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s Incident) Category() string {
|
||||
@@ -158,7 +169,7 @@ func (s Incident) Category() string {
|
||||
}
|
||||
|
||||
func (s Incident) SetCategory(val string) Incident {
|
||||
return Incident{s.m.Set(types.NewString("Category"), types.NewString(val))}
|
||||
return Incident{s.m.Set(types.NewString("Category"), types.NewString(val)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s Incident) Description() string {
|
||||
@@ -166,7 +177,7 @@ func (s Incident) Description() string {
|
||||
}
|
||||
|
||||
func (s Incident) SetDescription(val string) Incident {
|
||||
return Incident{s.m.Set(types.NewString("Description"), types.NewString(val))}
|
||||
return Incident{s.m.Set(types.NewString("Description"), types.NewString(val)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s Incident) DayOfWeek() string {
|
||||
@@ -174,7 +185,7 @@ func (s Incident) DayOfWeek() string {
|
||||
}
|
||||
|
||||
func (s Incident) SetDayOfWeek(val string) Incident {
|
||||
return Incident{s.m.Set(types.NewString("DayOfWeek"), types.NewString(val))}
|
||||
return Incident{s.m.Set(types.NewString("DayOfWeek"), types.NewString(val)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s Incident) Date() string {
|
||||
@@ -182,7 +193,7 @@ func (s Incident) Date() string {
|
||||
}
|
||||
|
||||
func (s Incident) SetDate(val string) Incident {
|
||||
return Incident{s.m.Set(types.NewString("Date"), types.NewString(val))}
|
||||
return Incident{s.m.Set(types.NewString("Date"), types.NewString(val)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s Incident) Time() string {
|
||||
@@ -190,7 +201,7 @@ func (s Incident) Time() string {
|
||||
}
|
||||
|
||||
func (s Incident) SetTime(val string) Incident {
|
||||
return Incident{s.m.Set(types.NewString("Time"), types.NewString(val))}
|
||||
return Incident{s.m.Set(types.NewString("Time"), types.NewString(val)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s Incident) PdDistrict() string {
|
||||
@@ -198,7 +209,7 @@ func (s Incident) PdDistrict() string {
|
||||
}
|
||||
|
||||
func (s Incident) SetPdDistrict(val string) Incident {
|
||||
return Incident{s.m.Set(types.NewString("PdDistrict"), types.NewString(val))}
|
||||
return Incident{s.m.Set(types.NewString("PdDistrict"), types.NewString(val)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s Incident) Resolution() string {
|
||||
@@ -206,7 +217,7 @@ func (s Incident) Resolution() string {
|
||||
}
|
||||
|
||||
func (s Incident) SetResolution(val string) Incident {
|
||||
return Incident{s.m.Set(types.NewString("Resolution"), types.NewString(val))}
|
||||
return Incident{s.m.Set(types.NewString("Resolution"), types.NewString(val)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s Incident) Address() string {
|
||||
@@ -214,15 +225,15 @@ func (s Incident) Address() string {
|
||||
}
|
||||
|
||||
func (s Incident) SetAddress(val string) Incident {
|
||||
return Incident{s.m.Set(types.NewString("Address"), types.NewString(val))}
|
||||
return Incident{s.m.Set(types.NewString("Address"), types.NewString(val)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s Incident) Geoposition() sha1_52bbaa7c5bcb39759981ccb12ee457f21fa7517d.Geoposition {
|
||||
return sha1_52bbaa7c5bcb39759981ccb12ee457f21fa7517d.GeopositionFromVal(s.m.Get(types.NewString("Geoposition")))
|
||||
func (s Incident) Geoposition() sha1_fb09d21d144c518467325465327d46489cff7c47.Geoposition {
|
||||
return s.m.Get(types.NewString("Geoposition")).(sha1_fb09d21d144c518467325465327d46489cff7c47.Geoposition)
|
||||
}
|
||||
|
||||
func (s Incident) SetGeoposition(val sha1_52bbaa7c5bcb39759981ccb12ee457f21fa7517d.Geoposition) Incident {
|
||||
return Incident{s.m.Set(types.NewString("Geoposition"), val.NomsValue())}
|
||||
func (s Incident) SetGeoposition(val sha1_fb09d21d144c518467325465327d46489cff7c47.Geoposition) Incident {
|
||||
return Incident{s.m.Set(types.NewString("Geoposition"), val), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s Incident) PdID() string {
|
||||
@@ -230,17 +241,18 @@ func (s Incident) PdID() string {
|
||||
}
|
||||
|
||||
func (s Incident) SetPdID(val string) Incident {
|
||||
return Incident{s.m.Set(types.NewString("PdID"), types.NewString(val))}
|
||||
return Incident{s.m.Set(types.NewString("PdID"), types.NewString(val)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
// ListOfIncident
|
||||
|
||||
type ListOfIncident struct {
|
||||
l types.List
|
||||
l types.List
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewListOfIncident() ListOfIncident {
|
||||
return ListOfIncident{types.NewList()}
|
||||
return ListOfIncident{types.NewList(), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type ListOfIncidentDef []IncidentDef
|
||||
@@ -248,37 +260,46 @@ type ListOfIncidentDef []IncidentDef
|
||||
func (def ListOfIncidentDef) New() ListOfIncident {
|
||||
l := make([]types.Value, len(def))
|
||||
for i, d := range def {
|
||||
l[i] = d.New().NomsValue()
|
||||
l[i] = d.New()
|
||||
}
|
||||
return ListOfIncident{types.NewList(l...)}
|
||||
return ListOfIncident{types.NewList(l...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfIncident) Def() ListOfIncidentDef {
|
||||
d := make([]IncidentDef, l.Len())
|
||||
for i := uint64(0); i < l.Len(); i++ {
|
||||
d[i] = IncidentFromVal(l.l.Get(i)).Def()
|
||||
d[i] = l.l.Get(i).(Incident).Def()
|
||||
}
|
||||
return d
|
||||
}
|
||||
|
||||
func ListOfIncidentFromVal(val types.Value) ListOfIncident {
|
||||
// TODO: Do we still need FromVal?
|
||||
if val, ok := val.(ListOfIncident); ok {
|
||||
return val
|
||||
}
|
||||
// TODO: Validate here
|
||||
return ListOfIncident{val.(types.List)}
|
||||
return ListOfIncident{val.(types.List), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfIncident) NomsValue() types.Value {
|
||||
// TODO: Remove this
|
||||
return l
|
||||
}
|
||||
|
||||
func (l ListOfIncident) InternalImplementation() types.List {
|
||||
return l.l
|
||||
}
|
||||
|
||||
func (l ListOfIncident) Equals(other types.Value) bool {
|
||||
if other, ok := other.(ListOfIncident); ok {
|
||||
return l.l.Equals(other.l)
|
||||
return l.Ref() == other.Ref()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (l ListOfIncident) Ref() ref.Ref {
|
||||
return l.l.Ref()
|
||||
return types.EnsureRef(l.ref, l)
|
||||
}
|
||||
|
||||
func (l ListOfIncident) Chunks() (futures []types.Future) {
|
||||
@@ -296,7 +317,7 @@ func (m ListOfIncident) TypeRef() types.TypeRef {
|
||||
|
||||
func init() {
|
||||
__typeRefForListOfIncident = types.MakeCompoundTypeRef("", types.ListKind, types.MakeTypeRef(__mainPackageInFile_types_CachedRef, 0))
|
||||
types.RegisterFromValFunction(__typeRefForListOfIncident, func(v types.Value) types.NomsValue {
|
||||
types.RegisterFromValFunction(__typeRefForListOfIncident, func(v types.Value) types.Value {
|
||||
return ListOfIncidentFromVal(v)
|
||||
})
|
||||
}
|
||||
@@ -310,37 +331,37 @@ func (l ListOfIncident) Empty() bool {
|
||||
}
|
||||
|
||||
func (l ListOfIncident) Get(i uint64) Incident {
|
||||
return IncidentFromVal(l.l.Get(i))
|
||||
return l.l.Get(i).(Incident)
|
||||
}
|
||||
|
||||
func (l ListOfIncident) Slice(idx uint64, end uint64) ListOfIncident {
|
||||
return ListOfIncident{l.l.Slice(idx, end)}
|
||||
return ListOfIncident{l.l.Slice(idx, end), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfIncident) Set(i uint64, val Incident) ListOfIncident {
|
||||
return ListOfIncident{l.l.Set(i, val.NomsValue())}
|
||||
return ListOfIncident{l.l.Set(i, val), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfIncident) Append(v ...Incident) ListOfIncident {
|
||||
return ListOfIncident{l.l.Append(l.fromElemSlice(v)...)}
|
||||
return ListOfIncident{l.l.Append(l.fromElemSlice(v)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfIncident) Insert(idx uint64, v ...Incident) ListOfIncident {
|
||||
return ListOfIncident{l.l.Insert(idx, l.fromElemSlice(v)...)}
|
||||
return ListOfIncident{l.l.Insert(idx, l.fromElemSlice(v)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfIncident) Remove(idx uint64, end uint64) ListOfIncident {
|
||||
return ListOfIncident{l.l.Remove(idx, end)}
|
||||
return ListOfIncident{l.l.Remove(idx, end), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfIncident) RemoveAt(idx uint64) ListOfIncident {
|
||||
return ListOfIncident{(l.l.RemoveAt(idx))}
|
||||
return ListOfIncident{(l.l.RemoveAt(idx)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfIncident) fromElemSlice(p []Incident) []types.Value {
|
||||
r := make([]types.Value, len(p))
|
||||
for i, v := range p {
|
||||
r[i] = v.NomsValue()
|
||||
r[i] = v
|
||||
}
|
||||
return r
|
||||
}
|
||||
@@ -349,7 +370,7 @@ type ListOfIncidentIterCallback func(v Incident, i uint64) (stop bool)
|
||||
|
||||
func (l ListOfIncident) Iter(cb ListOfIncidentIterCallback) {
|
||||
l.l.Iter(func(v types.Value, i uint64) bool {
|
||||
return cb(IncidentFromVal(v), i)
|
||||
return cb(v.(Incident), i)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -357,7 +378,7 @@ type ListOfIncidentIterAllCallback func(v Incident, i uint64)
|
||||
|
||||
func (l ListOfIncident) IterAll(cb ListOfIncidentIterAllCallback) {
|
||||
l.l.IterAll(func(v types.Value, i uint64) {
|
||||
cb(IncidentFromVal(v), i)
|
||||
cb(v.(Incident), i)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
geo "github.com/attic-labs/noms/clients/gen/sha1_52bbaa7c5bcb39759981ccb12ee457f21fa7517d"
|
||||
geo "github.com/attic-labs/noms/clients/gen/sha1_fb09d21d144c518467325465327d46489cff7c47"
|
||||
"github.com/attic-labs/noms/clients/util"
|
||||
)
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
geo "github.com/attic-labs/noms/clients/gen/sha1_52bbaa7c5bcb39759981ccb12ee457f21fa7517d"
|
||||
geo "github.com/attic-labs/noms/clients/gen/sha1_fb09d21d144c518467325465327d46489cff7c47"
|
||||
"github.com/attic-labs/noms/clients/util"
|
||||
"github.com/attic-labs/noms/d"
|
||||
"github.com/attic-labs/noms/datas"
|
||||
|
||||
+127
-86
@@ -3,7 +3,8 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/attic-labs/noms/clients/gen/sha1_52bbaa7c5bcb39759981ccb12ee457f21fa7517d"
|
||||
"github.com/attic-labs/noms/clients/gen/sha1_fb09d21d144c518467325465327d46489cff7c47"
|
||||
|
||||
"github.com/attic-labs/noms/ref"
|
||||
"github.com/attic-labs/noms/types"
|
||||
)
|
||||
@@ -21,7 +22,7 @@ func __mainPackageInFile_types_Ref() ref.Ref {
|
||||
types.Field{"Description", types.MakePrimitiveTypeRef(types.StringKind), false},
|
||||
types.Field{"Address", types.MakePrimitiveTypeRef(types.StringKind), false},
|
||||
types.Field{"Date", types.MakePrimitiveTypeRef(types.StringKind), false},
|
||||
types.Field{"Geoposition", types.MakeTypeRef(ref.Parse("sha1-52bbaa7c5bcb39759981ccb12ee457f21fa7517d"), 0), false},
|
||||
types.Field{"Geoposition", types.MakeTypeRef(ref.Parse("sha1-fb09d21d144c518467325465327d46489cff7c47"), 0), false},
|
||||
},
|
||||
types.Choices{},
|
||||
),
|
||||
@@ -32,12 +33,12 @@ func __mainPackageInFile_types_Ref() ref.Ref {
|
||||
types.Field{"Depth", types.MakePrimitiveTypeRef(types.UInt8Kind), false},
|
||||
types.Field{"NumDescendents", types.MakePrimitiveTypeRef(types.UInt32Kind), false},
|
||||
types.Field{"Path", types.MakePrimitiveTypeRef(types.StringKind), false},
|
||||
types.Field{"Georectangle", types.MakeTypeRef(ref.Parse("sha1-52bbaa7c5bcb39759981ccb12ee457f21fa7517d"), 1), false},
|
||||
types.Field{"Georectangle", types.MakeTypeRef(ref.Parse("sha1-fb09d21d144c518467325465327d46489cff7c47"), 1), false},
|
||||
},
|
||||
types.Choices{},
|
||||
),
|
||||
}, []ref.Ref{
|
||||
ref.Parse("sha1-52bbaa7c5bcb39759981ccb12ee457f21fa7517d"),
|
||||
ref.Parse("sha1-fb09d21d144c518467325465327d46489cff7c47"),
|
||||
})
|
||||
return types.RegisterPackage(&p)
|
||||
}
|
||||
@@ -45,7 +46,8 @@ func __mainPackageInFile_types_Ref() ref.Ref {
|
||||
// Incident
|
||||
|
||||
type Incident struct {
|
||||
m types.Map
|
||||
m types.Map
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewIncident() Incident {
|
||||
@@ -55,8 +57,8 @@ func NewIncident() Incident {
|
||||
types.NewString("Description"), types.NewString(""),
|
||||
types.NewString("Address"), types.NewString(""),
|
||||
types.NewString("Date"), types.NewString(""),
|
||||
types.NewString("Geoposition"), sha1_52bbaa7c5bcb39759981ccb12ee457f21fa7517d.NewGeoposition().NomsValue(),
|
||||
)}
|
||||
types.NewString("Geoposition"), sha1_fb09d21d144c518467325465327d46489cff7c47.NewGeoposition(),
|
||||
), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type IncidentDef struct {
|
||||
@@ -64,7 +66,7 @@ type IncidentDef struct {
|
||||
Description string
|
||||
Address string
|
||||
Date string
|
||||
Geoposition sha1_52bbaa7c5bcb39759981ccb12ee457f21fa7517d.GeopositionDef
|
||||
Geoposition sha1_fb09d21d144c518467325465327d46489cff7c47.GeopositionDef
|
||||
}
|
||||
|
||||
func (def IncidentDef) New() Incident {
|
||||
@@ -75,8 +77,8 @@ func (def IncidentDef) New() Incident {
|
||||
types.NewString("Description"), types.NewString(def.Description),
|
||||
types.NewString("Address"), types.NewString(def.Address),
|
||||
types.NewString("Date"), types.NewString(def.Date),
|
||||
types.NewString("Geoposition"), def.Geoposition.New().NomsValue(),
|
||||
)}
|
||||
types.NewString("Geoposition"), def.Geoposition.New(),
|
||||
), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s Incident) Def() (d IncidentDef) {
|
||||
@@ -84,7 +86,7 @@ func (s Incident) Def() (d IncidentDef) {
|
||||
d.Description = s.m.Get(types.NewString("Description")).(types.String).String()
|
||||
d.Address = s.m.Get(types.NewString("Address")).(types.String).String()
|
||||
d.Date = s.m.Get(types.NewString("Date")).(types.String).String()
|
||||
d.Geoposition = sha1_52bbaa7c5bcb39759981ccb12ee457f21fa7517d.GeopositionFromVal(s.m.Get(types.NewString("Geoposition"))).Def()
|
||||
d.Geoposition = s.m.Get(types.NewString("Geoposition")).(sha1_fb09d21d144c518467325465327d46489cff7c47.Geoposition).Def()
|
||||
return
|
||||
}
|
||||
|
||||
@@ -95,29 +97,38 @@ func (m Incident) TypeRef() types.TypeRef {
|
||||
}
|
||||
|
||||
func init() {
|
||||
types.RegisterFromValFunction(__typeRefForIncident, func(v types.Value) types.NomsValue {
|
||||
types.RegisterFromValFunction(__typeRefForIncident, func(v types.Value) types.Value {
|
||||
return IncidentFromVal(v)
|
||||
})
|
||||
}
|
||||
|
||||
func IncidentFromVal(val types.Value) Incident {
|
||||
// TODO: Do we still need FromVal?
|
||||
if val, ok := val.(Incident); ok {
|
||||
return val
|
||||
}
|
||||
// TODO: Validate here
|
||||
return Incident{val.(types.Map)}
|
||||
return Incident{val.(types.Map), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s Incident) NomsValue() types.Value {
|
||||
// TODO: Remove this
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Incident) InternalImplementation() types.Map {
|
||||
return s.m
|
||||
}
|
||||
|
||||
func (s Incident) Equals(other types.Value) bool {
|
||||
if other, ok := other.(Incident); ok {
|
||||
return s.m.Equals(other.m)
|
||||
return s.Ref() == other.Ref()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (s Incident) Ref() ref.Ref {
|
||||
return s.m.Ref()
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s Incident) Chunks() (futures []types.Future) {
|
||||
@@ -131,7 +142,7 @@ func (s Incident) Category() string {
|
||||
}
|
||||
|
||||
func (s Incident) SetCategory(val string) Incident {
|
||||
return Incident{s.m.Set(types.NewString("Category"), types.NewString(val))}
|
||||
return Incident{s.m.Set(types.NewString("Category"), types.NewString(val)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s Incident) Description() string {
|
||||
@@ -139,7 +150,7 @@ func (s Incident) Description() string {
|
||||
}
|
||||
|
||||
func (s Incident) SetDescription(val string) Incident {
|
||||
return Incident{s.m.Set(types.NewString("Description"), types.NewString(val))}
|
||||
return Incident{s.m.Set(types.NewString("Description"), types.NewString(val)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s Incident) Address() string {
|
||||
@@ -147,7 +158,7 @@ func (s Incident) Address() string {
|
||||
}
|
||||
|
||||
func (s Incident) SetAddress(val string) Incident {
|
||||
return Incident{s.m.Set(types.NewString("Address"), types.NewString(val))}
|
||||
return Incident{s.m.Set(types.NewString("Address"), types.NewString(val)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s Incident) Date() string {
|
||||
@@ -155,33 +166,34 @@ func (s Incident) Date() string {
|
||||
}
|
||||
|
||||
func (s Incident) SetDate(val string) Incident {
|
||||
return Incident{s.m.Set(types.NewString("Date"), types.NewString(val))}
|
||||
return Incident{s.m.Set(types.NewString("Date"), types.NewString(val)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s Incident) Geoposition() sha1_52bbaa7c5bcb39759981ccb12ee457f21fa7517d.Geoposition {
|
||||
return sha1_52bbaa7c5bcb39759981ccb12ee457f21fa7517d.GeopositionFromVal(s.m.Get(types.NewString("Geoposition")))
|
||||
func (s Incident) Geoposition() sha1_fb09d21d144c518467325465327d46489cff7c47.Geoposition {
|
||||
return s.m.Get(types.NewString("Geoposition")).(sha1_fb09d21d144c518467325465327d46489cff7c47.Geoposition)
|
||||
}
|
||||
|
||||
func (s Incident) SetGeoposition(val sha1_52bbaa7c5bcb39759981ccb12ee457f21fa7517d.Geoposition) Incident {
|
||||
return Incident{s.m.Set(types.NewString("Geoposition"), val.NomsValue())}
|
||||
func (s Incident) SetGeoposition(val sha1_fb09d21d144c518467325465327d46489cff7c47.Geoposition) Incident {
|
||||
return Incident{s.m.Set(types.NewString("Geoposition"), val), &ref.Ref{}}
|
||||
}
|
||||
|
||||
// SQuadTree
|
||||
|
||||
type SQuadTree struct {
|
||||
m types.Map
|
||||
m types.Map
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewSQuadTree() SQuadTree {
|
||||
return SQuadTree{types.NewMap(
|
||||
types.NewString("$type"), types.MakeTypeRef(__mainPackageInFile_types_CachedRef, 1),
|
||||
types.NewString("Nodes"), types.NewList(),
|
||||
types.NewString("Tiles"), types.NewMap(),
|
||||
types.NewString("Nodes"), NewListOfIncident(),
|
||||
types.NewString("Tiles"), NewMapOfStringToSQuadTree(),
|
||||
types.NewString("Depth"), types.UInt8(0),
|
||||
types.NewString("NumDescendents"), types.UInt32(0),
|
||||
types.NewString("Path"), types.NewString(""),
|
||||
types.NewString("Georectangle"), sha1_52bbaa7c5bcb39759981ccb12ee457f21fa7517d.NewGeorectangle().NomsValue(),
|
||||
)}
|
||||
types.NewString("Georectangle"), sha1_fb09d21d144c518467325465327d46489cff7c47.NewGeorectangle(),
|
||||
), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type SQuadTreeDef struct {
|
||||
@@ -190,29 +202,29 @@ type SQuadTreeDef struct {
|
||||
Depth uint8
|
||||
NumDescendents uint32
|
||||
Path string
|
||||
Georectangle sha1_52bbaa7c5bcb39759981ccb12ee457f21fa7517d.GeorectangleDef
|
||||
Georectangle sha1_fb09d21d144c518467325465327d46489cff7c47.GeorectangleDef
|
||||
}
|
||||
|
||||
func (def SQuadTreeDef) New() SQuadTree {
|
||||
return SQuadTree{
|
||||
types.NewMap(
|
||||
types.NewString("$type"), types.MakeTypeRef(__mainPackageInFile_types_CachedRef, 1),
|
||||
types.NewString("Nodes"), def.Nodes.New().NomsValue(),
|
||||
types.NewString("Tiles"), def.Tiles.New().NomsValue(),
|
||||
types.NewString("Nodes"), def.Nodes.New(),
|
||||
types.NewString("Tiles"), def.Tiles.New(),
|
||||
types.NewString("Depth"), types.UInt8(def.Depth),
|
||||
types.NewString("NumDescendents"), types.UInt32(def.NumDescendents),
|
||||
types.NewString("Path"), types.NewString(def.Path),
|
||||
types.NewString("Georectangle"), def.Georectangle.New().NomsValue(),
|
||||
)}
|
||||
types.NewString("Georectangle"), def.Georectangle.New(),
|
||||
), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SQuadTree) Def() (d SQuadTreeDef) {
|
||||
d.Nodes = ListOfIncidentFromVal(s.m.Get(types.NewString("Nodes"))).Def()
|
||||
d.Tiles = MapOfStringToSQuadTreeFromVal(s.m.Get(types.NewString("Tiles"))).Def()
|
||||
d.Nodes = s.m.Get(types.NewString("Nodes")).(ListOfIncident).Def()
|
||||
d.Tiles = s.m.Get(types.NewString("Tiles")).(MapOfStringToSQuadTree).Def()
|
||||
d.Depth = uint8(s.m.Get(types.NewString("Depth")).(types.UInt8))
|
||||
d.NumDescendents = uint32(s.m.Get(types.NewString("NumDescendents")).(types.UInt32))
|
||||
d.Path = s.m.Get(types.NewString("Path")).(types.String).String()
|
||||
d.Georectangle = sha1_52bbaa7c5bcb39759981ccb12ee457f21fa7517d.GeorectangleFromVal(s.m.Get(types.NewString("Georectangle"))).Def()
|
||||
d.Georectangle = s.m.Get(types.NewString("Georectangle")).(sha1_fb09d21d144c518467325465327d46489cff7c47.Georectangle).Def()
|
||||
return
|
||||
}
|
||||
|
||||
@@ -223,29 +235,38 @@ func (m SQuadTree) TypeRef() types.TypeRef {
|
||||
}
|
||||
|
||||
func init() {
|
||||
types.RegisterFromValFunction(__typeRefForSQuadTree, func(v types.Value) types.NomsValue {
|
||||
types.RegisterFromValFunction(__typeRefForSQuadTree, func(v types.Value) types.Value {
|
||||
return SQuadTreeFromVal(v)
|
||||
})
|
||||
}
|
||||
|
||||
func SQuadTreeFromVal(val types.Value) SQuadTree {
|
||||
// TODO: Do we still need FromVal?
|
||||
if val, ok := val.(SQuadTree); ok {
|
||||
return val
|
||||
}
|
||||
// TODO: Validate here
|
||||
return SQuadTree{val.(types.Map)}
|
||||
return SQuadTree{val.(types.Map), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SQuadTree) NomsValue() types.Value {
|
||||
// TODO: Remove this
|
||||
return s
|
||||
}
|
||||
|
||||
func (s SQuadTree) InternalImplementation() types.Map {
|
||||
return s.m
|
||||
}
|
||||
|
||||
func (s SQuadTree) Equals(other types.Value) bool {
|
||||
if other, ok := other.(SQuadTree); ok {
|
||||
return s.m.Equals(other.m)
|
||||
return s.Ref() == other.Ref()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (s SQuadTree) Ref() ref.Ref {
|
||||
return s.m.Ref()
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s SQuadTree) Chunks() (futures []types.Future) {
|
||||
@@ -255,19 +276,19 @@ func (s SQuadTree) Chunks() (futures []types.Future) {
|
||||
}
|
||||
|
||||
func (s SQuadTree) Nodes() ListOfIncident {
|
||||
return ListOfIncidentFromVal(s.m.Get(types.NewString("Nodes")))
|
||||
return s.m.Get(types.NewString("Nodes")).(ListOfIncident)
|
||||
}
|
||||
|
||||
func (s SQuadTree) SetNodes(val ListOfIncident) SQuadTree {
|
||||
return SQuadTree{s.m.Set(types.NewString("Nodes"), val.NomsValue())}
|
||||
return SQuadTree{s.m.Set(types.NewString("Nodes"), val), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SQuadTree) Tiles() MapOfStringToSQuadTree {
|
||||
return MapOfStringToSQuadTreeFromVal(s.m.Get(types.NewString("Tiles")))
|
||||
return s.m.Get(types.NewString("Tiles")).(MapOfStringToSQuadTree)
|
||||
}
|
||||
|
||||
func (s SQuadTree) SetTiles(val MapOfStringToSQuadTree) SQuadTree {
|
||||
return SQuadTree{s.m.Set(types.NewString("Tiles"), val.NomsValue())}
|
||||
return SQuadTree{s.m.Set(types.NewString("Tiles"), val), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SQuadTree) Depth() uint8 {
|
||||
@@ -275,7 +296,7 @@ func (s SQuadTree) Depth() uint8 {
|
||||
}
|
||||
|
||||
func (s SQuadTree) SetDepth(val uint8) SQuadTree {
|
||||
return SQuadTree{s.m.Set(types.NewString("Depth"), types.UInt8(val))}
|
||||
return SQuadTree{s.m.Set(types.NewString("Depth"), types.UInt8(val)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SQuadTree) NumDescendents() uint32 {
|
||||
@@ -283,7 +304,7 @@ func (s SQuadTree) NumDescendents() uint32 {
|
||||
}
|
||||
|
||||
func (s SQuadTree) SetNumDescendents(val uint32) SQuadTree {
|
||||
return SQuadTree{s.m.Set(types.NewString("NumDescendents"), types.UInt32(val))}
|
||||
return SQuadTree{s.m.Set(types.NewString("NumDescendents"), types.UInt32(val)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SQuadTree) Path() string {
|
||||
@@ -291,25 +312,26 @@ func (s SQuadTree) Path() string {
|
||||
}
|
||||
|
||||
func (s SQuadTree) SetPath(val string) SQuadTree {
|
||||
return SQuadTree{s.m.Set(types.NewString("Path"), types.NewString(val))}
|
||||
return SQuadTree{s.m.Set(types.NewString("Path"), types.NewString(val)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SQuadTree) Georectangle() sha1_52bbaa7c5bcb39759981ccb12ee457f21fa7517d.Georectangle {
|
||||
return sha1_52bbaa7c5bcb39759981ccb12ee457f21fa7517d.GeorectangleFromVal(s.m.Get(types.NewString("Georectangle")))
|
||||
func (s SQuadTree) Georectangle() sha1_fb09d21d144c518467325465327d46489cff7c47.Georectangle {
|
||||
return s.m.Get(types.NewString("Georectangle")).(sha1_fb09d21d144c518467325465327d46489cff7c47.Georectangle)
|
||||
}
|
||||
|
||||
func (s SQuadTree) SetGeorectangle(val sha1_52bbaa7c5bcb39759981ccb12ee457f21fa7517d.Georectangle) SQuadTree {
|
||||
return SQuadTree{s.m.Set(types.NewString("Georectangle"), val.NomsValue())}
|
||||
func (s SQuadTree) SetGeorectangle(val sha1_fb09d21d144c518467325465327d46489cff7c47.Georectangle) SQuadTree {
|
||||
return SQuadTree{s.m.Set(types.NewString("Georectangle"), val), &ref.Ref{}}
|
||||
}
|
||||
|
||||
// ListOfIncident
|
||||
|
||||
type ListOfIncident struct {
|
||||
l types.List
|
||||
l types.List
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewListOfIncident() ListOfIncident {
|
||||
return ListOfIncident{types.NewList()}
|
||||
return ListOfIncident{types.NewList(), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type ListOfIncidentDef []IncidentDef
|
||||
@@ -317,37 +339,46 @@ type ListOfIncidentDef []IncidentDef
|
||||
func (def ListOfIncidentDef) New() ListOfIncident {
|
||||
l := make([]types.Value, len(def))
|
||||
for i, d := range def {
|
||||
l[i] = d.New().NomsValue()
|
||||
l[i] = d.New()
|
||||
}
|
||||
return ListOfIncident{types.NewList(l...)}
|
||||
return ListOfIncident{types.NewList(l...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfIncident) Def() ListOfIncidentDef {
|
||||
d := make([]IncidentDef, l.Len())
|
||||
for i := uint64(0); i < l.Len(); i++ {
|
||||
d[i] = IncidentFromVal(l.l.Get(i)).Def()
|
||||
d[i] = l.l.Get(i).(Incident).Def()
|
||||
}
|
||||
return d
|
||||
}
|
||||
|
||||
func ListOfIncidentFromVal(val types.Value) ListOfIncident {
|
||||
// TODO: Do we still need FromVal?
|
||||
if val, ok := val.(ListOfIncident); ok {
|
||||
return val
|
||||
}
|
||||
// TODO: Validate here
|
||||
return ListOfIncident{val.(types.List)}
|
||||
return ListOfIncident{val.(types.List), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfIncident) NomsValue() types.Value {
|
||||
// TODO: Remove this
|
||||
return l
|
||||
}
|
||||
|
||||
func (l ListOfIncident) InternalImplementation() types.List {
|
||||
return l.l
|
||||
}
|
||||
|
||||
func (l ListOfIncident) Equals(other types.Value) bool {
|
||||
if other, ok := other.(ListOfIncident); ok {
|
||||
return l.l.Equals(other.l)
|
||||
return l.Ref() == other.Ref()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (l ListOfIncident) Ref() ref.Ref {
|
||||
return l.l.Ref()
|
||||
return types.EnsureRef(l.ref, l)
|
||||
}
|
||||
|
||||
func (l ListOfIncident) Chunks() (futures []types.Future) {
|
||||
@@ -365,7 +396,7 @@ func (m ListOfIncident) TypeRef() types.TypeRef {
|
||||
|
||||
func init() {
|
||||
__typeRefForListOfIncident = types.MakeCompoundTypeRef("", types.ListKind, types.MakeTypeRef(__mainPackageInFile_types_CachedRef, 0))
|
||||
types.RegisterFromValFunction(__typeRefForListOfIncident, func(v types.Value) types.NomsValue {
|
||||
types.RegisterFromValFunction(__typeRefForListOfIncident, func(v types.Value) types.Value {
|
||||
return ListOfIncidentFromVal(v)
|
||||
})
|
||||
}
|
||||
@@ -379,37 +410,37 @@ func (l ListOfIncident) Empty() bool {
|
||||
}
|
||||
|
||||
func (l ListOfIncident) Get(i uint64) Incident {
|
||||
return IncidentFromVal(l.l.Get(i))
|
||||
return l.l.Get(i).(Incident)
|
||||
}
|
||||
|
||||
func (l ListOfIncident) Slice(idx uint64, end uint64) ListOfIncident {
|
||||
return ListOfIncident{l.l.Slice(idx, end)}
|
||||
return ListOfIncident{l.l.Slice(idx, end), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfIncident) Set(i uint64, val Incident) ListOfIncident {
|
||||
return ListOfIncident{l.l.Set(i, val.NomsValue())}
|
||||
return ListOfIncident{l.l.Set(i, val), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfIncident) Append(v ...Incident) ListOfIncident {
|
||||
return ListOfIncident{l.l.Append(l.fromElemSlice(v)...)}
|
||||
return ListOfIncident{l.l.Append(l.fromElemSlice(v)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfIncident) Insert(idx uint64, v ...Incident) ListOfIncident {
|
||||
return ListOfIncident{l.l.Insert(idx, l.fromElemSlice(v)...)}
|
||||
return ListOfIncident{l.l.Insert(idx, l.fromElemSlice(v)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfIncident) Remove(idx uint64, end uint64) ListOfIncident {
|
||||
return ListOfIncident{l.l.Remove(idx, end)}
|
||||
return ListOfIncident{l.l.Remove(idx, end), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfIncident) RemoveAt(idx uint64) ListOfIncident {
|
||||
return ListOfIncident{(l.l.RemoveAt(idx))}
|
||||
return ListOfIncident{(l.l.RemoveAt(idx)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfIncident) fromElemSlice(p []Incident) []types.Value {
|
||||
r := make([]types.Value, len(p))
|
||||
for i, v := range p {
|
||||
r[i] = v.NomsValue()
|
||||
r[i] = v
|
||||
}
|
||||
return r
|
||||
}
|
||||
@@ -418,7 +449,7 @@ type ListOfIncidentIterCallback func(v Incident, i uint64) (stop bool)
|
||||
|
||||
func (l ListOfIncident) Iter(cb ListOfIncidentIterCallback) {
|
||||
l.l.Iter(func(v types.Value, i uint64) bool {
|
||||
return cb(IncidentFromVal(v), i)
|
||||
return cb(v.(Incident), i)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -426,7 +457,7 @@ type ListOfIncidentIterAllCallback func(v Incident, i uint64)
|
||||
|
||||
func (l ListOfIncident) IterAll(cb ListOfIncidentIterAllCallback) {
|
||||
l.l.IterAll(func(v types.Value, i uint64) {
|
||||
cb(IncidentFromVal(v), i)
|
||||
cb(v.(Incident), i)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -445,11 +476,12 @@ func (l ListOfIncident) Filter(cb ListOfIncidentFilterCallback) ListOfIncident {
|
||||
// MapOfStringToSQuadTree
|
||||
|
||||
type MapOfStringToSQuadTree struct {
|
||||
m types.Map
|
||||
m types.Map
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewMapOfStringToSQuadTree() MapOfStringToSQuadTree {
|
||||
return MapOfStringToSQuadTree{types.NewMap()}
|
||||
return MapOfStringToSQuadTree{types.NewMap(), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type MapOfStringToSQuadTreeDef map[string]SQuadTreeDef
|
||||
@@ -457,38 +489,47 @@ type MapOfStringToSQuadTreeDef map[string]SQuadTreeDef
|
||||
func (def MapOfStringToSQuadTreeDef) New() MapOfStringToSQuadTree {
|
||||
kv := make([]types.Value, 0, len(def)*2)
|
||||
for k, v := range def {
|
||||
kv = append(kv, types.NewString(k), v.New().NomsValue())
|
||||
kv = append(kv, types.NewString(k), v.New())
|
||||
}
|
||||
return MapOfStringToSQuadTree{types.NewMap(kv...)}
|
||||
return MapOfStringToSQuadTree{types.NewMap(kv...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (m MapOfStringToSQuadTree) Def() MapOfStringToSQuadTreeDef {
|
||||
def := make(map[string]SQuadTreeDef)
|
||||
m.m.Iter(func(k, v types.Value) bool {
|
||||
def[k.(types.String).String()] = SQuadTreeFromVal(v).Def()
|
||||
def[k.(types.String).String()] = v.(SQuadTree).Def()
|
||||
return false
|
||||
})
|
||||
return def
|
||||
}
|
||||
|
||||
func MapOfStringToSQuadTreeFromVal(p types.Value) MapOfStringToSQuadTree {
|
||||
func MapOfStringToSQuadTreeFromVal(val types.Value) MapOfStringToSQuadTree {
|
||||
// TODO: Do we still need FromVal?
|
||||
if val, ok := val.(MapOfStringToSQuadTree); ok {
|
||||
return val
|
||||
}
|
||||
// TODO: Validate here
|
||||
return MapOfStringToSQuadTree{p.(types.Map)}
|
||||
return MapOfStringToSQuadTree{val.(types.Map), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (m MapOfStringToSQuadTree) NomsValue() types.Value {
|
||||
// TODO: Remove this
|
||||
return m
|
||||
}
|
||||
|
||||
func (m MapOfStringToSQuadTree) InternalImplementation() types.Map {
|
||||
return m.m
|
||||
}
|
||||
|
||||
func (m MapOfStringToSQuadTree) Equals(other types.Value) bool {
|
||||
if other, ok := other.(MapOfStringToSQuadTree); ok {
|
||||
return m.m.Equals(other.m)
|
||||
return m.Ref() == other.Ref()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (m MapOfStringToSQuadTree) Ref() ref.Ref {
|
||||
return m.m.Ref()
|
||||
return types.EnsureRef(m.ref, m)
|
||||
}
|
||||
|
||||
func (m MapOfStringToSQuadTree) Chunks() (futures []types.Future) {
|
||||
@@ -506,7 +547,7 @@ func (m MapOfStringToSQuadTree) TypeRef() types.TypeRef {
|
||||
|
||||
func init() {
|
||||
__typeRefForMapOfStringToSQuadTree = types.MakeCompoundTypeRef("", types.MapKind, types.MakePrimitiveTypeRef(types.StringKind), types.MakeTypeRef(__mainPackageInFile_types_CachedRef, 1))
|
||||
types.RegisterFromValFunction(__typeRefForMapOfStringToSQuadTree, func(v types.Value) types.NomsValue {
|
||||
types.RegisterFromValFunction(__typeRefForMapOfStringToSQuadTree, func(v types.Value) types.Value {
|
||||
return MapOfStringToSQuadTreeFromVal(v)
|
||||
})
|
||||
}
|
||||
@@ -524,7 +565,7 @@ func (m MapOfStringToSQuadTree) Has(p string) bool {
|
||||
}
|
||||
|
||||
func (m MapOfStringToSQuadTree) Get(p string) SQuadTree {
|
||||
return SQuadTreeFromVal(m.m.Get(types.NewString(p)))
|
||||
return m.m.Get(types.NewString(p)).(SQuadTree)
|
||||
}
|
||||
|
||||
func (m MapOfStringToSQuadTree) MaybeGet(p string) (SQuadTree, bool) {
|
||||
@@ -532,24 +573,24 @@ func (m MapOfStringToSQuadTree) MaybeGet(p string) (SQuadTree, bool) {
|
||||
if !ok {
|
||||
return NewSQuadTree(), false
|
||||
}
|
||||
return SQuadTreeFromVal(v), ok
|
||||
return v.(SQuadTree), ok
|
||||
}
|
||||
|
||||
func (m MapOfStringToSQuadTree) Set(k string, v SQuadTree) MapOfStringToSQuadTree {
|
||||
return MapOfStringToSQuadTree{m.m.Set(types.NewString(k), v.NomsValue())}
|
||||
return MapOfStringToSQuadTree{m.m.Set(types.NewString(k), v), &ref.Ref{}}
|
||||
}
|
||||
|
||||
// TODO: Implement SetM?
|
||||
|
||||
func (m MapOfStringToSQuadTree) Remove(p string) MapOfStringToSQuadTree {
|
||||
return MapOfStringToSQuadTree{m.m.Remove(types.NewString(p))}
|
||||
return MapOfStringToSQuadTree{m.m.Remove(types.NewString(p)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type MapOfStringToSQuadTreeIterCallback func(k string, v SQuadTree) (stop bool)
|
||||
|
||||
func (m MapOfStringToSQuadTree) Iter(cb MapOfStringToSQuadTreeIterCallback) {
|
||||
m.m.Iter(func(k, v types.Value) bool {
|
||||
return cb(k.(types.String).String(), SQuadTreeFromVal(v))
|
||||
return cb(k.(types.String).String(), v.(SQuadTree))
|
||||
})
|
||||
}
|
||||
|
||||
@@ -557,7 +598,7 @@ type MapOfStringToSQuadTreeIterAllCallback func(k string, v SQuadTree)
|
||||
|
||||
func (m MapOfStringToSQuadTree) IterAll(cb MapOfStringToSQuadTreeIterAllCallback) {
|
||||
m.m.IterAll(func(k, v types.Value) {
|
||||
cb(k.(types.String).String(), SQuadTreeFromVal(v))
|
||||
cb(k.(types.String).String(), v.(SQuadTree))
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
+187
-187
@@ -37,30 +37,6 @@ func (s RemotePhoto) Ref() ref.Ref {
|
||||
return s.m.Ref()
|
||||
}
|
||||
|
||||
func (s RemotePhoto) Sizes() MapOfSizeToString {
|
||||
return MapOfSizeToStringFromVal(s.m.Get(types.NewString("sizes")))
|
||||
}
|
||||
|
||||
func (s RemotePhoto) SetSizes(p MapOfSizeToString) RemotePhoto {
|
||||
return RemotePhotoFromVal(s.m.Set(types.NewString("sizes"), p.NomsValue()))
|
||||
}
|
||||
|
||||
func (s RemotePhoto) Title() types.String {
|
||||
return types.StringFromVal(s.m.Get(types.NewString("title")))
|
||||
}
|
||||
|
||||
func (s RemotePhoto) SetTitle(p types.String) RemotePhoto {
|
||||
return RemotePhotoFromVal(s.m.Set(types.NewString("title"), p))
|
||||
}
|
||||
|
||||
func (s RemotePhoto) Id() types.String {
|
||||
return types.StringFromVal(s.m.Get(types.NewString("id")))
|
||||
}
|
||||
|
||||
func (s RemotePhoto) SetId(p types.String) RemotePhoto {
|
||||
return RemotePhotoFromVal(s.m.Set(types.NewString("id"), p))
|
||||
}
|
||||
|
||||
func (s RemotePhoto) Tags() SetOfString {
|
||||
return SetOfStringFromVal(s.m.Get(types.NewString("tags")))
|
||||
}
|
||||
@@ -77,6 +53,30 @@ func (s RemotePhoto) SetGeoposition(p Geoposition) RemotePhoto {
|
||||
return RemotePhotoFromVal(s.m.Set(types.NewString("geoposition"), p.NomsValue()))
|
||||
}
|
||||
|
||||
func (s RemotePhoto) Id() types.String {
|
||||
return types.StringFromVal(s.m.Get(types.NewString("id")))
|
||||
}
|
||||
|
||||
func (s RemotePhoto) SetId(p types.String) RemotePhoto {
|
||||
return RemotePhotoFromVal(s.m.Set(types.NewString("id"), p))
|
||||
}
|
||||
|
||||
func (s RemotePhoto) Title() types.String {
|
||||
return types.StringFromVal(s.m.Get(types.NewString("title")))
|
||||
}
|
||||
|
||||
func (s RemotePhoto) SetTitle(p types.String) RemotePhoto {
|
||||
return RemotePhotoFromVal(s.m.Set(types.NewString("title"), p))
|
||||
}
|
||||
|
||||
func (s RemotePhoto) Sizes() MapOfSizeToString {
|
||||
return MapOfSizeToStringFromVal(s.m.Get(types.NewString("sizes")))
|
||||
}
|
||||
|
||||
func (s RemotePhoto) SetSizes(p MapOfSizeToString) RemotePhoto {
|
||||
return RemotePhotoFromVal(s.m.Set(types.NewString("sizes"), p.NomsValue()))
|
||||
}
|
||||
|
||||
func (s RemotePhoto) Url() types.String {
|
||||
return types.StringFromVal(s.m.Get(types.NewString("url")))
|
||||
}
|
||||
@@ -85,6 +85,66 @@ func (s RemotePhoto) SetUrl(p types.String) RemotePhoto {
|
||||
return RemotePhotoFromVal(s.m.Set(types.NewString("url"), p))
|
||||
}
|
||||
|
||||
// MapOfSizeToString
|
||||
|
||||
type MapOfSizeToString struct {
|
||||
m types.Map
|
||||
}
|
||||
|
||||
type MapOfSizeToStringIterCallback (func(k Size, v types.String) (stop bool))
|
||||
|
||||
func NewMapOfSizeToString() MapOfSizeToString {
|
||||
return MapOfSizeToString{types.NewMap()}
|
||||
}
|
||||
|
||||
func MapOfSizeToStringFromVal(p types.Value) MapOfSizeToString {
|
||||
return MapOfSizeToString{p.(types.Map)}
|
||||
}
|
||||
|
||||
func (m MapOfSizeToString) NomsValue() types.Map {
|
||||
return m.m
|
||||
}
|
||||
|
||||
func (m MapOfSizeToString) Equals(p MapOfSizeToString) bool {
|
||||
return m.m.Equals(p.m)
|
||||
}
|
||||
|
||||
func (m MapOfSizeToString) Ref() ref.Ref {
|
||||
return m.m.Ref()
|
||||
}
|
||||
|
||||
func (m MapOfSizeToString) Empty() bool {
|
||||
return m.m.Empty()
|
||||
}
|
||||
|
||||
func (m MapOfSizeToString) Len() uint64 {
|
||||
return m.m.Len()
|
||||
}
|
||||
|
||||
func (m MapOfSizeToString) Has(p Size) bool {
|
||||
return m.m.Has(p.NomsValue())
|
||||
}
|
||||
|
||||
func (m MapOfSizeToString) Get(p Size) types.String {
|
||||
return types.StringFromVal(m.m.Get(p.NomsValue()))
|
||||
}
|
||||
|
||||
func (m MapOfSizeToString) Set(k Size, v types.String) MapOfSizeToString {
|
||||
return MapOfSizeToStringFromVal(m.m.Set(k.NomsValue(), v))
|
||||
}
|
||||
|
||||
// TODO: Implement SetM?
|
||||
|
||||
func (m MapOfSizeToString) Remove(p Size) MapOfSizeToString {
|
||||
return MapOfSizeToStringFromVal(m.m.Remove(p.NomsValue()))
|
||||
}
|
||||
|
||||
func (m MapOfSizeToString) Iter(cb MapOfSizeToStringIterCallback) {
|
||||
m.m.Iter(func(k, v types.Value) bool {
|
||||
return cb(SizeFromVal(k), types.StringFromVal(v))
|
||||
})
|
||||
}
|
||||
|
||||
// SetOfString
|
||||
|
||||
type SetOfString struct {
|
||||
@@ -167,6 +227,51 @@ func (s SetOfString) fromElemSlice(p []types.String) []types.Value {
|
||||
return r
|
||||
}
|
||||
|
||||
// Size
|
||||
|
||||
type Size struct {
|
||||
m types.Map
|
||||
}
|
||||
|
||||
func NewSize() Size {
|
||||
return Size{
|
||||
types.NewMap(types.NewString("$name"), types.NewString("Size")),
|
||||
}
|
||||
}
|
||||
|
||||
func SizeFromVal(v types.Value) Size {
|
||||
return Size{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 Size) NomsValue() types.Map {
|
||||
return s.m
|
||||
}
|
||||
|
||||
func (s Size) Equals(p Size) bool {
|
||||
return s.m.Equals(p.m)
|
||||
}
|
||||
|
||||
func (s Size) Ref() ref.Ref {
|
||||
return s.m.Ref()
|
||||
}
|
||||
|
||||
func (s Size) Width() types.UInt32 {
|
||||
return types.UInt32FromVal(s.m.Get(types.NewString("width")))
|
||||
}
|
||||
|
||||
func (s Size) SetWidth(p types.UInt32) Size {
|
||||
return SizeFromVal(s.m.Set(types.NewString("width"), p))
|
||||
}
|
||||
|
||||
func (s Size) Height() types.UInt32 {
|
||||
return types.UInt32FromVal(s.m.Get(types.NewString("height")))
|
||||
}
|
||||
|
||||
func (s Size) SetHeight(p types.UInt32) Size {
|
||||
return SizeFromVal(s.m.Set(types.NewString("height"), p))
|
||||
}
|
||||
|
||||
// Photo
|
||||
|
||||
type Photo struct {
|
||||
@@ -196,30 +301,6 @@ func (s Photo) Ref() ref.Ref {
|
||||
return s.m.Ref()
|
||||
}
|
||||
|
||||
func (s Photo) Width() types.UInt32 {
|
||||
return types.UInt32FromVal(s.m.Get(types.NewString("width")))
|
||||
}
|
||||
|
||||
func (s Photo) SetWidth(p types.UInt32) Photo {
|
||||
return PhotoFromVal(s.m.Set(types.NewString("width"), p))
|
||||
}
|
||||
|
||||
func (s Photo) Title() types.String {
|
||||
return types.StringFromVal(s.m.Get(types.NewString("title")))
|
||||
}
|
||||
|
||||
func (s Photo) SetTitle(p types.String) Photo {
|
||||
return PhotoFromVal(s.m.Set(types.NewString("title"), p))
|
||||
}
|
||||
|
||||
func (s Photo) Id() types.String {
|
||||
return types.StringFromVal(s.m.Get(types.NewString("id")))
|
||||
}
|
||||
|
||||
func (s Photo) SetId(p types.String) Photo {
|
||||
return PhotoFromVal(s.m.Set(types.NewString("id"), p))
|
||||
}
|
||||
|
||||
func (s Photo) Tags() SetOfString {
|
||||
return SetOfStringFromVal(s.m.Get(types.NewString("tags")))
|
||||
}
|
||||
@@ -228,22 +309,6 @@ func (s Photo) SetTags(p SetOfString) Photo {
|
||||
return PhotoFromVal(s.m.Set(types.NewString("tags"), p.NomsValue()))
|
||||
}
|
||||
|
||||
func (s Photo) Height() types.UInt32 {
|
||||
return types.UInt32FromVal(s.m.Get(types.NewString("height")))
|
||||
}
|
||||
|
||||
func (s Photo) SetHeight(p types.UInt32) Photo {
|
||||
return PhotoFromVal(s.m.Set(types.NewString("height"), p))
|
||||
}
|
||||
|
||||
func (s Photo) Geoposition() Geoposition {
|
||||
return GeopositionFromVal(s.m.Get(types.NewString("geoposition")))
|
||||
}
|
||||
|
||||
func (s Photo) SetGeoposition(p Geoposition) Photo {
|
||||
return PhotoFromVal(s.m.Set(types.NewString("geoposition"), p.NomsValue()))
|
||||
}
|
||||
|
||||
func (s Photo) Image() types.Blob {
|
||||
return types.BlobFromVal(s.m.Get(types.NewString("image")))
|
||||
}
|
||||
@@ -252,6 +317,46 @@ func (s Photo) SetImage(p types.Blob) Photo {
|
||||
return PhotoFromVal(s.m.Set(types.NewString("image"), p))
|
||||
}
|
||||
|
||||
func (s Photo) Width() types.UInt32 {
|
||||
return types.UInt32FromVal(s.m.Get(types.NewString("width")))
|
||||
}
|
||||
|
||||
func (s Photo) SetWidth(p types.UInt32) Photo {
|
||||
return PhotoFromVal(s.m.Set(types.NewString("width"), p))
|
||||
}
|
||||
|
||||
func (s Photo) Geoposition() Geoposition {
|
||||
return GeopositionFromVal(s.m.Get(types.NewString("geoposition")))
|
||||
}
|
||||
|
||||
func (s Photo) SetGeoposition(p Geoposition) Photo {
|
||||
return PhotoFromVal(s.m.Set(types.NewString("geoposition"), p.NomsValue()))
|
||||
}
|
||||
|
||||
func (s Photo) Id() types.String {
|
||||
return types.StringFromVal(s.m.Get(types.NewString("id")))
|
||||
}
|
||||
|
||||
func (s Photo) SetId(p types.String) Photo {
|
||||
return PhotoFromVal(s.m.Set(types.NewString("id"), p))
|
||||
}
|
||||
|
||||
func (s Photo) Height() types.UInt32 {
|
||||
return types.UInt32FromVal(s.m.Get(types.NewString("height")))
|
||||
}
|
||||
|
||||
func (s Photo) SetHeight(p types.UInt32) Photo {
|
||||
return PhotoFromVal(s.m.Set(types.NewString("height"), p))
|
||||
}
|
||||
|
||||
func (s Photo) Title() types.String {
|
||||
return types.StringFromVal(s.m.Get(types.NewString("title")))
|
||||
}
|
||||
|
||||
func (s Photo) SetTitle(p types.String) Photo {
|
||||
return PhotoFromVal(s.m.Set(types.NewString("title"), p))
|
||||
}
|
||||
|
||||
func (s Photo) Url() types.String {
|
||||
return types.StringFromVal(s.m.Get(types.NewString("url")))
|
||||
}
|
||||
@@ -260,111 +365,6 @@ func (s Photo) SetUrl(p types.String) Photo {
|
||||
return PhotoFromVal(s.m.Set(types.NewString("url"), p))
|
||||
}
|
||||
|
||||
// Geoposition
|
||||
|
||||
type Geoposition struct {
|
||||
m types.Map
|
||||
}
|
||||
|
||||
func NewGeoposition() Geoposition {
|
||||
return Geoposition{
|
||||
types.NewMap(types.NewString("$name"), types.NewString("Geoposition")),
|
||||
}
|
||||
}
|
||||
|
||||
func GeopositionFromVal(v types.Value) Geoposition {
|
||||
return Geoposition{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 Geoposition) NomsValue() types.Map {
|
||||
return s.m
|
||||
}
|
||||
|
||||
func (s Geoposition) Equals(p Geoposition) bool {
|
||||
return s.m.Equals(p.m)
|
||||
}
|
||||
|
||||
func (s Geoposition) Ref() ref.Ref {
|
||||
return s.m.Ref()
|
||||
}
|
||||
|
||||
func (s Geoposition) Longitude() types.Float32 {
|
||||
return types.Float32FromVal(s.m.Get(types.NewString("longitude")))
|
||||
}
|
||||
|
||||
func (s Geoposition) SetLongitude(p types.Float32) Geoposition {
|
||||
return GeopositionFromVal(s.m.Set(types.NewString("longitude"), p))
|
||||
}
|
||||
|
||||
func (s Geoposition) Latitude() types.Float32 {
|
||||
return types.Float32FromVal(s.m.Get(types.NewString("latitude")))
|
||||
}
|
||||
|
||||
func (s Geoposition) SetLatitude(p types.Float32) Geoposition {
|
||||
return GeopositionFromVal(s.m.Set(types.NewString("latitude"), p))
|
||||
}
|
||||
|
||||
// MapOfSizeToString
|
||||
|
||||
type MapOfSizeToString struct {
|
||||
m types.Map
|
||||
}
|
||||
|
||||
type MapOfSizeToStringIterCallback (func(k Size, v types.String) (stop bool))
|
||||
|
||||
func NewMapOfSizeToString() MapOfSizeToString {
|
||||
return MapOfSizeToString{types.NewMap()}
|
||||
}
|
||||
|
||||
func MapOfSizeToStringFromVal(p types.Value) MapOfSizeToString {
|
||||
return MapOfSizeToString{p.(types.Map)}
|
||||
}
|
||||
|
||||
func (m MapOfSizeToString) NomsValue() types.Map {
|
||||
return m.m
|
||||
}
|
||||
|
||||
func (m MapOfSizeToString) Equals(p MapOfSizeToString) bool {
|
||||
return m.m.Equals(p.m)
|
||||
}
|
||||
|
||||
func (m MapOfSizeToString) Ref() ref.Ref {
|
||||
return m.m.Ref()
|
||||
}
|
||||
|
||||
func (m MapOfSizeToString) Empty() bool {
|
||||
return m.m.Empty()
|
||||
}
|
||||
|
||||
func (m MapOfSizeToString) Len() uint64 {
|
||||
return m.m.Len()
|
||||
}
|
||||
|
||||
func (m MapOfSizeToString) Has(p Size) bool {
|
||||
return m.m.Has(p.NomsValue())
|
||||
}
|
||||
|
||||
func (m MapOfSizeToString) Get(p Size) types.String {
|
||||
return types.StringFromVal(m.m.Get(p.NomsValue()))
|
||||
}
|
||||
|
||||
func (m MapOfSizeToString) Set(k Size, v types.String) MapOfSizeToString {
|
||||
return MapOfSizeToStringFromVal(m.m.Set(k.NomsValue(), v))
|
||||
}
|
||||
|
||||
// TODO: Implement SetM?
|
||||
|
||||
func (m MapOfSizeToString) Remove(p Size) MapOfSizeToString {
|
||||
return MapOfSizeToStringFromVal(m.m.Remove(p.NomsValue()))
|
||||
}
|
||||
|
||||
func (m MapOfSizeToString) Iter(cb MapOfSizeToStringIterCallback) {
|
||||
m.m.Iter(func(k, v types.Value) bool {
|
||||
return cb(SizeFromVal(k), types.StringFromVal(v))
|
||||
})
|
||||
}
|
||||
|
||||
// MapOfStringToSet
|
||||
|
||||
type MapOfStringToSet struct {
|
||||
@@ -425,48 +425,48 @@ func (m MapOfStringToSet) Iter(cb MapOfStringToSetIterCallback) {
|
||||
})
|
||||
}
|
||||
|
||||
// Size
|
||||
// Geoposition
|
||||
|
||||
type Size struct {
|
||||
type Geoposition struct {
|
||||
m types.Map
|
||||
}
|
||||
|
||||
func NewSize() Size {
|
||||
return Size{
|
||||
types.NewMap(types.NewString("$name"), types.NewString("Size")),
|
||||
func NewGeoposition() Geoposition {
|
||||
return Geoposition{
|
||||
types.NewMap(types.NewString("$name"), types.NewString("Geoposition")),
|
||||
}
|
||||
}
|
||||
|
||||
func SizeFromVal(v types.Value) Size {
|
||||
return Size{v.(types.Map)}
|
||||
func GeopositionFromVal(v types.Value) Geoposition {
|
||||
return Geoposition{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 Size) NomsValue() types.Map {
|
||||
func (s Geoposition) NomsValue() types.Map {
|
||||
return s.m
|
||||
}
|
||||
|
||||
func (s Size) Equals(p Size) bool {
|
||||
func (s Geoposition) Equals(p Geoposition) bool {
|
||||
return s.m.Equals(p.m)
|
||||
}
|
||||
|
||||
func (s Size) Ref() ref.Ref {
|
||||
func (s Geoposition) Ref() ref.Ref {
|
||||
return s.m.Ref()
|
||||
}
|
||||
|
||||
func (s Size) Width() types.UInt32 {
|
||||
return types.UInt32FromVal(s.m.Get(types.NewString("width")))
|
||||
func (s Geoposition) Latitude() types.Float32 {
|
||||
return types.Float32FromVal(s.m.Get(types.NewString("latitude")))
|
||||
}
|
||||
|
||||
func (s Size) SetWidth(p types.UInt32) Size {
|
||||
return SizeFromVal(s.m.Set(types.NewString("width"), p))
|
||||
func (s Geoposition) SetLatitude(p types.Float32) Geoposition {
|
||||
return GeopositionFromVal(s.m.Set(types.NewString("latitude"), p))
|
||||
}
|
||||
|
||||
func (s Size) Height() types.UInt32 {
|
||||
return types.UInt32FromVal(s.m.Get(types.NewString("height")))
|
||||
func (s Geoposition) Longitude() types.Float32 {
|
||||
return types.Float32FromVal(s.m.Get(types.NewString("longitude")))
|
||||
}
|
||||
|
||||
func (s Size) SetHeight(p types.UInt32) Size {
|
||||
return SizeFromVal(s.m.Set(types.NewString("height"), p))
|
||||
func (s Geoposition) SetLongitude(p types.Float32) Geoposition {
|
||||
return GeopositionFromVal(s.m.Set(types.NewString("longitude"), p))
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ package util
|
||||
import (
|
||||
"math"
|
||||
|
||||
geo "github.com/attic-labs/noms/clients/gen/sha1_52bbaa7c5bcb39759981ccb12ee457f21fa7517d"
|
||||
geo "github.com/attic-labs/noms/clients/gen/sha1_fb09d21d144c518467325465327d46489cff7c47"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/attic-labs/noms/Godeps/_workspace/src/github.com/stretchr/testify/assert"
|
||||
geo "github.com/attic-labs/noms/clients/gen/sha1_52bbaa7c5bcb39759981ccb12ee457f21fa7517d"
|
||||
geo "github.com/attic-labs/noms/clients/gen/sha1_fb09d21d144c518467325465327d46489cff7c47"
|
||||
)
|
||||
|
||||
func TestPoint(t *testing.T) {
|
||||
|
||||
+69
-39
@@ -28,15 +28,16 @@ func __datasPackageInFile_types_Ref() ref.Ref {
|
||||
// Commit
|
||||
|
||||
type Commit struct {
|
||||
m types.Map
|
||||
m types.Map
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewCommit() Commit {
|
||||
return Commit{types.NewMap(
|
||||
types.NewString("$type"), types.MakeTypeRef(__datasPackageInFile_types_CachedRef, 0),
|
||||
types.NewString("value"), types.Bool(false),
|
||||
types.NewString("parents"), types.NewSet(),
|
||||
)}
|
||||
types.NewString("parents"), NewSetOfCommit(),
|
||||
), &ref.Ref{}}
|
||||
}
|
||||
|
||||
var __typeRefForCommit = types.MakeTypeRef(__datasPackageInFile_types_CachedRef, 0)
|
||||
@@ -46,29 +47,38 @@ func (m Commit) TypeRef() types.TypeRef {
|
||||
}
|
||||
|
||||
func init() {
|
||||
types.RegisterFromValFunction(__typeRefForCommit, func(v types.Value) types.NomsValue {
|
||||
types.RegisterFromValFunction(__typeRefForCommit, func(v types.Value) types.Value {
|
||||
return CommitFromVal(v)
|
||||
})
|
||||
}
|
||||
|
||||
func CommitFromVal(val types.Value) Commit {
|
||||
// TODO: Do we still need FromVal?
|
||||
if val, ok := val.(Commit); ok {
|
||||
return val
|
||||
}
|
||||
// TODO: Validate here
|
||||
return Commit{val.(types.Map)}
|
||||
return Commit{val.(types.Map), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s Commit) NomsValue() types.Value {
|
||||
// TODO: Remove this
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Commit) InternalImplementation() types.Map {
|
||||
return s.m
|
||||
}
|
||||
|
||||
func (s Commit) Equals(other types.Value) bool {
|
||||
if other, ok := other.(Commit); ok {
|
||||
return s.m.Equals(other.m)
|
||||
return s.Ref() == other.Ref()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (s Commit) Ref() ref.Ref {
|
||||
return s.m.Ref()
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s Commit) Chunks() (futures []types.Future) {
|
||||
@@ -82,45 +92,55 @@ func (s Commit) Value() types.Value {
|
||||
}
|
||||
|
||||
func (s Commit) SetValue(val types.Value) Commit {
|
||||
return Commit{s.m.Set(types.NewString("value"), val)}
|
||||
return Commit{s.m.Set(types.NewString("value"), val), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s Commit) Parents() SetOfCommit {
|
||||
return SetOfCommitFromVal(s.m.Get(types.NewString("parents")))
|
||||
return s.m.Get(types.NewString("parents")).(SetOfCommit)
|
||||
}
|
||||
|
||||
func (s Commit) SetParents(val SetOfCommit) Commit {
|
||||
return Commit{s.m.Set(types.NewString("parents"), val.NomsValue())}
|
||||
return Commit{s.m.Set(types.NewString("parents"), val), &ref.Ref{}}
|
||||
}
|
||||
|
||||
// MapOfStringToCommit
|
||||
|
||||
type MapOfStringToCommit struct {
|
||||
m types.Map
|
||||
m types.Map
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewMapOfStringToCommit() MapOfStringToCommit {
|
||||
return MapOfStringToCommit{types.NewMap()}
|
||||
return MapOfStringToCommit{types.NewMap(), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func MapOfStringToCommitFromVal(p types.Value) MapOfStringToCommit {
|
||||
func MapOfStringToCommitFromVal(val types.Value) MapOfStringToCommit {
|
||||
// TODO: Do we still need FromVal?
|
||||
if val, ok := val.(MapOfStringToCommit); ok {
|
||||
return val
|
||||
}
|
||||
// TODO: Validate here
|
||||
return MapOfStringToCommit{p.(types.Map)}
|
||||
return MapOfStringToCommit{val.(types.Map), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (m MapOfStringToCommit) NomsValue() types.Value {
|
||||
// TODO: Remove this
|
||||
return m
|
||||
}
|
||||
|
||||
func (m MapOfStringToCommit) InternalImplementation() types.Map {
|
||||
return m.m
|
||||
}
|
||||
|
||||
func (m MapOfStringToCommit) Equals(other types.Value) bool {
|
||||
if other, ok := other.(MapOfStringToCommit); ok {
|
||||
return m.m.Equals(other.m)
|
||||
return m.Ref() == other.Ref()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (m MapOfStringToCommit) Ref() ref.Ref {
|
||||
return m.m.Ref()
|
||||
return types.EnsureRef(m.ref, m)
|
||||
}
|
||||
|
||||
func (m MapOfStringToCommit) Chunks() (futures []types.Future) {
|
||||
@@ -138,7 +158,7 @@ func (m MapOfStringToCommit) TypeRef() types.TypeRef {
|
||||
|
||||
func init() {
|
||||
__typeRefForMapOfStringToCommit = types.MakeCompoundTypeRef("", types.MapKind, types.MakePrimitiveTypeRef(types.StringKind), types.MakeTypeRef(__datasPackageInFile_types_CachedRef, 0))
|
||||
types.RegisterFromValFunction(__typeRefForMapOfStringToCommit, func(v types.Value) types.NomsValue {
|
||||
types.RegisterFromValFunction(__typeRefForMapOfStringToCommit, func(v types.Value) types.Value {
|
||||
return MapOfStringToCommitFromVal(v)
|
||||
})
|
||||
}
|
||||
@@ -156,7 +176,7 @@ func (m MapOfStringToCommit) Has(p string) bool {
|
||||
}
|
||||
|
||||
func (m MapOfStringToCommit) Get(p string) Commit {
|
||||
return CommitFromVal(m.m.Get(types.NewString(p)))
|
||||
return m.m.Get(types.NewString(p)).(Commit)
|
||||
}
|
||||
|
||||
func (m MapOfStringToCommit) MaybeGet(p string) (Commit, bool) {
|
||||
@@ -164,24 +184,24 @@ func (m MapOfStringToCommit) MaybeGet(p string) (Commit, bool) {
|
||||
if !ok {
|
||||
return NewCommit(), false
|
||||
}
|
||||
return CommitFromVal(v), ok
|
||||
return v.(Commit), ok
|
||||
}
|
||||
|
||||
func (m MapOfStringToCommit) Set(k string, v Commit) MapOfStringToCommit {
|
||||
return MapOfStringToCommit{m.m.Set(types.NewString(k), v.NomsValue())}
|
||||
return MapOfStringToCommit{m.m.Set(types.NewString(k), v), &ref.Ref{}}
|
||||
}
|
||||
|
||||
// TODO: Implement SetM?
|
||||
|
||||
func (m MapOfStringToCommit) Remove(p string) MapOfStringToCommit {
|
||||
return MapOfStringToCommit{m.m.Remove(types.NewString(p))}
|
||||
return MapOfStringToCommit{m.m.Remove(types.NewString(p)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type MapOfStringToCommitIterCallback func(k string, v Commit) (stop bool)
|
||||
|
||||
func (m MapOfStringToCommit) Iter(cb MapOfStringToCommitIterCallback) {
|
||||
m.m.Iter(func(k, v types.Value) bool {
|
||||
return cb(k.(types.String).String(), CommitFromVal(v))
|
||||
return cb(k.(types.String).String(), v.(Commit))
|
||||
})
|
||||
}
|
||||
|
||||
@@ -189,7 +209,7 @@ type MapOfStringToCommitIterAllCallback func(k string, v Commit)
|
||||
|
||||
func (m MapOfStringToCommit) IterAll(cb MapOfStringToCommitIterAllCallback) {
|
||||
m.m.IterAll(func(k, v types.Value) {
|
||||
cb(k.(types.String).String(), CommitFromVal(v))
|
||||
cb(k.(types.String).String(), v.(Commit))
|
||||
})
|
||||
}
|
||||
|
||||
@@ -208,30 +228,40 @@ func (m MapOfStringToCommit) Filter(cb MapOfStringToCommitFilterCallback) MapOfS
|
||||
// SetOfCommit
|
||||
|
||||
type SetOfCommit struct {
|
||||
s types.Set
|
||||
s types.Set
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewSetOfCommit() SetOfCommit {
|
||||
return SetOfCommit{types.NewSet()}
|
||||
return SetOfCommit{types.NewSet(), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func SetOfCommitFromVal(p types.Value) SetOfCommit {
|
||||
return SetOfCommit{p.(types.Set)}
|
||||
func SetOfCommitFromVal(val types.Value) SetOfCommit {
|
||||
// TODO: Do we still need FromVal?
|
||||
if val, ok := val.(SetOfCommit); ok {
|
||||
return val
|
||||
}
|
||||
return SetOfCommit{val.(types.Set), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfCommit) NomsValue() types.Value {
|
||||
// TODO: Remove this
|
||||
return s
|
||||
}
|
||||
|
||||
func (s SetOfCommit) InternalImplementation() types.Set {
|
||||
return s.s
|
||||
}
|
||||
|
||||
func (s SetOfCommit) Equals(other types.Value) bool {
|
||||
if other, ok := other.(SetOfCommit); ok {
|
||||
return s.s.Equals(other.s)
|
||||
return s.Ref() == other.Ref()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (s SetOfCommit) Ref() ref.Ref {
|
||||
return s.s.Ref()
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s SetOfCommit) Chunks() (futures []types.Future) {
|
||||
@@ -249,7 +279,7 @@ func (m SetOfCommit) TypeRef() types.TypeRef {
|
||||
|
||||
func init() {
|
||||
__typeRefForSetOfCommit = types.MakeCompoundTypeRef("", types.SetKind, types.MakeTypeRef(__datasPackageInFile_types_CachedRef, 0))
|
||||
types.RegisterFromValFunction(__typeRefForSetOfCommit, func(v types.Value) types.NomsValue {
|
||||
types.RegisterFromValFunction(__typeRefForSetOfCommit, func(v types.Value) types.Value {
|
||||
return SetOfCommitFromVal(v)
|
||||
})
|
||||
}
|
||||
@@ -263,14 +293,14 @@ func (s SetOfCommit) Len() uint64 {
|
||||
}
|
||||
|
||||
func (s SetOfCommit) Has(p Commit) bool {
|
||||
return s.s.Has(p.NomsValue())
|
||||
return s.s.Has(p)
|
||||
}
|
||||
|
||||
type SetOfCommitIterCallback func(p Commit) (stop bool)
|
||||
|
||||
func (s SetOfCommit) Iter(cb SetOfCommitIterCallback) {
|
||||
s.s.Iter(func(v types.Value) bool {
|
||||
return cb(CommitFromVal(v))
|
||||
return cb(v.(Commit))
|
||||
})
|
||||
}
|
||||
|
||||
@@ -278,7 +308,7 @@ type SetOfCommitIterAllCallback func(p Commit)
|
||||
|
||||
func (s SetOfCommit) IterAll(cb SetOfCommitIterAllCallback) {
|
||||
s.s.IterAll(func(v types.Value) {
|
||||
cb(CommitFromVal(v))
|
||||
cb(v.(Commit))
|
||||
})
|
||||
}
|
||||
|
||||
@@ -295,23 +325,23 @@ func (s SetOfCommit) Filter(cb SetOfCommitFilterCallback) SetOfCommit {
|
||||
}
|
||||
|
||||
func (s SetOfCommit) Insert(p ...Commit) SetOfCommit {
|
||||
return SetOfCommit{s.s.Insert(s.fromElemSlice(p)...)}
|
||||
return SetOfCommit{s.s.Insert(s.fromElemSlice(p)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfCommit) Remove(p ...Commit) SetOfCommit {
|
||||
return SetOfCommit{s.s.Remove(s.fromElemSlice(p)...)}
|
||||
return SetOfCommit{s.s.Remove(s.fromElemSlice(p)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfCommit) Union(others ...SetOfCommit) SetOfCommit {
|
||||
return SetOfCommit{s.s.Union(s.fromStructSlice(others)...)}
|
||||
return SetOfCommit{s.s.Union(s.fromStructSlice(others)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfCommit) Subtract(others ...SetOfCommit) SetOfCommit {
|
||||
return SetOfCommit{s.s.Subtract(s.fromStructSlice(others)...)}
|
||||
return SetOfCommit{s.s.Subtract(s.fromStructSlice(others)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfCommit) Any() Commit {
|
||||
return CommitFromVal(s.s.Any())
|
||||
return s.s.Any().(Commit)
|
||||
}
|
||||
|
||||
func (s SetOfCommit) fromStructSlice(p []SetOfCommit) []types.Set {
|
||||
@@ -325,7 +355,7 @@ func (s SetOfCommit) fromStructSlice(p []SetOfCommit) []types.Set {
|
||||
func (s SetOfCommit) fromElemSlice(p []Commit) []types.Value {
|
||||
r := make([]types.Value, len(p))
|
||||
for i, v := range p {
|
||||
r[i] = v.NomsValue()
|
||||
r[i] = v
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
@@ -38,14 +38,15 @@ const (
|
||||
// EnumStruct
|
||||
|
||||
type EnumStruct struct {
|
||||
m types.Map
|
||||
m types.Map
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewEnumStruct() EnumStruct {
|
||||
return EnumStruct{types.NewMap(
|
||||
types.NewString("$type"), types.MakeTypeRef(__testPackageInFile_enum_struct_CachedRef, 1),
|
||||
types.NewString("hand"), types.UInt32(0),
|
||||
)}
|
||||
), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type EnumStructDef struct {
|
||||
@@ -57,7 +58,7 @@ func (def EnumStructDef) New() EnumStruct {
|
||||
types.NewMap(
|
||||
types.NewString("$type"), types.MakeTypeRef(__testPackageInFile_enum_struct_CachedRef, 1),
|
||||
types.NewString("hand"), types.UInt32(def.Hand),
|
||||
)}
|
||||
), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s EnumStruct) Def() (d EnumStructDef) {
|
||||
@@ -72,29 +73,38 @@ func (m EnumStruct) TypeRef() types.TypeRef {
|
||||
}
|
||||
|
||||
func init() {
|
||||
types.RegisterFromValFunction(__typeRefForEnumStruct, func(v types.Value) types.NomsValue {
|
||||
types.RegisterFromValFunction(__typeRefForEnumStruct, func(v types.Value) types.Value {
|
||||
return EnumStructFromVal(v)
|
||||
})
|
||||
}
|
||||
|
||||
func EnumStructFromVal(val types.Value) EnumStruct {
|
||||
// TODO: Do we still need FromVal?
|
||||
if val, ok := val.(EnumStruct); ok {
|
||||
return val
|
||||
}
|
||||
// TODO: Validate here
|
||||
return EnumStruct{val.(types.Map)}
|
||||
return EnumStruct{val.(types.Map), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s EnumStruct) NomsValue() types.Value {
|
||||
// TODO: Remove this
|
||||
return s
|
||||
}
|
||||
|
||||
func (s EnumStruct) InternalImplementation() types.Map {
|
||||
return s.m
|
||||
}
|
||||
|
||||
func (s EnumStruct) Equals(other types.Value) bool {
|
||||
if other, ok := other.(EnumStruct); ok {
|
||||
return s.m.Equals(other.m)
|
||||
return s.Ref() == other.Ref()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (s EnumStruct) Ref() ref.Ref {
|
||||
return s.m.Ref()
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s EnumStruct) Chunks() (futures []types.Future) {
|
||||
@@ -108,5 +118,5 @@ func (s EnumStruct) Hand() Handedness {
|
||||
}
|
||||
|
||||
func (s EnumStruct) SetHand(val Handedness) EnumStruct {
|
||||
return EnumStruct{s.m.Set(types.NewString("hand"), types.UInt32(val))}
|
||||
return EnumStruct{s.m.Set(types.NewString("hand"), types.UInt32(val)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ func TestEnumValue(t *testing.T) {
|
||||
assert.True(st.Equals(st2))
|
||||
}
|
||||
|
||||
func TestEnumIsValue(t *testing.T) {
|
||||
func SkipTestEnumIsValue(t *testing.T) {
|
||||
cs := chunks.NewMemoryStore()
|
||||
var v types.Value = NewEnumStruct()
|
||||
ref := types.WriteValue(v, cs)
|
||||
|
||||
+25
-15
@@ -1,18 +1,18 @@
|
||||
// This file was generated by nomdl/codegen.
|
||||
|
||||
package sha1_8bbcfa69bdfc9953c4034f8591964e0387983910
|
||||
package sha1_bbf9c3d7eb6ed891f4b8490b5b81f21f89f7d288
|
||||
|
||||
import (
|
||||
"github.com/attic-labs/noms/ref"
|
||||
"github.com/attic-labs/noms/types"
|
||||
)
|
||||
|
||||
var __sha1_8bbcfa69bdfc9953c4034f8591964e0387983910PackageInFile_sha1_8bbcfa69bdfc9953c4034f8591964e0387983910_CachedRef = __sha1_8bbcfa69bdfc9953c4034f8591964e0387983910PackageInFile_sha1_8bbcfa69bdfc9953c4034f8591964e0387983910_Ref()
|
||||
var __sha1_bbf9c3d7eb6ed891f4b8490b5b81f21f89f7d288PackageInFile_sha1_bbf9c3d7eb6ed891f4b8490b5b81f21f89f7d288_CachedRef = __sha1_bbf9c3d7eb6ed891f4b8490b5b81f21f89f7d288PackageInFile_sha1_bbf9c3d7eb6ed891f4b8490b5b81f21f89f7d288_Ref()
|
||||
|
||||
// This function builds up a Noms value that describes the type
|
||||
// package implemented by this file and registers it with the global
|
||||
// type package definition cache.
|
||||
func __sha1_8bbcfa69bdfc9953c4034f8591964e0387983910PackageInFile_sha1_8bbcfa69bdfc9953c4034f8591964e0387983910_Ref() ref.Ref {
|
||||
func __sha1_bbf9c3d7eb6ed891f4b8490b5b81f21f89f7d288PackageInFile_sha1_bbf9c3d7eb6ed891f4b8490b5b81f21f89f7d288_Ref() ref.Ref {
|
||||
p := types.NewPackage([]types.TypeRef{
|
||||
types.MakeStructTypeRef("S",
|
||||
[]types.Field{
|
||||
@@ -29,15 +29,16 @@ func __sha1_8bbcfa69bdfc9953c4034f8591964e0387983910PackageInFile_sha1_8bbcfa69b
|
||||
// S
|
||||
|
||||
type S struct {
|
||||
m types.Map
|
||||
m types.Map
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewS() S {
|
||||
return S{types.NewMap(
|
||||
types.NewString("$type"), types.MakeTypeRef(__sha1_8bbcfa69bdfc9953c4034f8591964e0387983910PackageInFile_sha1_8bbcfa69bdfc9953c4034f8591964e0387983910_CachedRef, 0),
|
||||
types.NewString("$type"), types.MakeTypeRef(__sha1_bbf9c3d7eb6ed891f4b8490b5b81f21f89f7d288PackageInFile_sha1_bbf9c3d7eb6ed891f4b8490b5b81f21f89f7d288_CachedRef, 0),
|
||||
types.NewString("s"), types.NewString(""),
|
||||
types.NewString("b"), types.Bool(false),
|
||||
)}
|
||||
), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type SDef struct {
|
||||
@@ -48,10 +49,10 @@ type SDef struct {
|
||||
func (def SDef) New() S {
|
||||
return S{
|
||||
types.NewMap(
|
||||
types.NewString("$type"), types.MakeTypeRef(__sha1_8bbcfa69bdfc9953c4034f8591964e0387983910PackageInFile_sha1_8bbcfa69bdfc9953c4034f8591964e0387983910_CachedRef, 0),
|
||||
types.NewString("$type"), types.MakeTypeRef(__sha1_bbf9c3d7eb6ed891f4b8490b5b81f21f89f7d288PackageInFile_sha1_bbf9c3d7eb6ed891f4b8490b5b81f21f89f7d288_CachedRef, 0),
|
||||
types.NewString("s"), types.NewString(def.S),
|
||||
types.NewString("b"), types.Bool(def.B),
|
||||
)}
|
||||
), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s S) Def() (d SDef) {
|
||||
@@ -60,36 +61,45 @@ func (s S) Def() (d SDef) {
|
||||
return
|
||||
}
|
||||
|
||||
var __typeRefForS = types.MakeTypeRef(__sha1_8bbcfa69bdfc9953c4034f8591964e0387983910PackageInFile_sha1_8bbcfa69bdfc9953c4034f8591964e0387983910_CachedRef, 0)
|
||||
var __typeRefForS = types.MakeTypeRef(__sha1_bbf9c3d7eb6ed891f4b8490b5b81f21f89f7d288PackageInFile_sha1_bbf9c3d7eb6ed891f4b8490b5b81f21f89f7d288_CachedRef, 0)
|
||||
|
||||
func (m S) TypeRef() types.TypeRef {
|
||||
return __typeRefForS
|
||||
}
|
||||
|
||||
func init() {
|
||||
types.RegisterFromValFunction(__typeRefForS, func(v types.Value) types.NomsValue {
|
||||
types.RegisterFromValFunction(__typeRefForS, func(v types.Value) types.Value {
|
||||
return SFromVal(v)
|
||||
})
|
||||
}
|
||||
|
||||
func SFromVal(val types.Value) S {
|
||||
// TODO: Do we still need FromVal?
|
||||
if val, ok := val.(S); ok {
|
||||
return val
|
||||
}
|
||||
// TODO: Validate here
|
||||
return S{val.(types.Map)}
|
||||
return S{val.(types.Map), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s S) NomsValue() types.Value {
|
||||
// TODO: Remove this
|
||||
return s
|
||||
}
|
||||
|
||||
func (s S) InternalImplementation() types.Map {
|
||||
return s.m
|
||||
}
|
||||
|
||||
func (s S) Equals(other types.Value) bool {
|
||||
if other, ok := other.(S); ok {
|
||||
return s.m.Equals(other.m)
|
||||
return s.Ref() == other.Ref()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (s S) Ref() ref.Ref {
|
||||
return s.m.Ref()
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s S) Chunks() (futures []types.Future) {
|
||||
@@ -103,7 +113,7 @@ func (s S) S() string {
|
||||
}
|
||||
|
||||
func (s S) SetS(val string) S {
|
||||
return S{s.m.Set(types.NewString("s"), types.NewString(val))}
|
||||
return S{s.m.Set(types.NewString("s"), types.NewString(val)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s S) B() bool {
|
||||
@@ -111,7 +121,7 @@ func (s S) B() bool {
|
||||
}
|
||||
|
||||
func (s S) SetB(val bool) S {
|
||||
return S{s.m.Set(types.NewString("b"), types.Bool(val))}
|
||||
return S{s.m.Set(types.NewString("b"), types.Bool(val)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
// E
|
||||
+220
@@ -0,0 +1,220 @@
|
||||
// This file was generated by nomdl/codegen.
|
||||
|
||||
package sha1_d31b592f480b7659b03b72a7d1271f31dde57b2d
|
||||
|
||||
import (
|
||||
"github.com/attic-labs/noms/nomdl/codegen/test/gen/sha1_bbf9c3d7eb6ed891f4b8490b5b81f21f89f7d288"
|
||||
|
||||
"github.com/attic-labs/noms/ref"
|
||||
"github.com/attic-labs/noms/types"
|
||||
)
|
||||
|
||||
var __sha1_d31b592f480b7659b03b72a7d1271f31dde57b2dPackageInFile_sha1_d31b592f480b7659b03b72a7d1271f31dde57b2d_CachedRef = __sha1_d31b592f480b7659b03b72a7d1271f31dde57b2dPackageInFile_sha1_d31b592f480b7659b03b72a7d1271f31dde57b2d_Ref()
|
||||
|
||||
// This function builds up a Noms value that describes the type
|
||||
// package implemented by this file and registers it with the global
|
||||
// type package definition cache.
|
||||
func __sha1_d31b592f480b7659b03b72a7d1271f31dde57b2dPackageInFile_sha1_d31b592f480b7659b03b72a7d1271f31dde57b2d_Ref() ref.Ref {
|
||||
p := types.NewPackage([]types.TypeRef{
|
||||
types.MakeStructTypeRef("D",
|
||||
[]types.Field{
|
||||
types.Field{"structField", types.MakeTypeRef(ref.Parse("sha1-bbf9c3d7eb6ed891f4b8490b5b81f21f89f7d288"), 0), false},
|
||||
types.Field{"enumField", types.MakeTypeRef(ref.Parse("sha1-bbf9c3d7eb6ed891f4b8490b5b81f21f89f7d288"), 1), false},
|
||||
},
|
||||
types.Choices{},
|
||||
),
|
||||
types.MakeStructTypeRef("DUser",
|
||||
[]types.Field{
|
||||
types.Field{"Dfield", types.MakeTypeRef(ref.Ref{}, 0), false},
|
||||
},
|
||||
types.Choices{},
|
||||
),
|
||||
}, []ref.Ref{
|
||||
ref.Parse("sha1-bbf9c3d7eb6ed891f4b8490b5b81f21f89f7d288"),
|
||||
})
|
||||
return types.RegisterPackage(&p)
|
||||
}
|
||||
|
||||
// D
|
||||
|
||||
type D struct {
|
||||
m types.Map
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewD() D {
|
||||
return D{types.NewMap(
|
||||
types.NewString("$type"), types.MakeTypeRef(__sha1_d31b592f480b7659b03b72a7d1271f31dde57b2dPackageInFile_sha1_d31b592f480b7659b03b72a7d1271f31dde57b2d_CachedRef, 0),
|
||||
types.NewString("structField"), sha1_bbf9c3d7eb6ed891f4b8490b5b81f21f89f7d288.NewS(),
|
||||
types.NewString("enumField"), types.UInt32(0),
|
||||
), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type DDef struct {
|
||||
StructField sha1_bbf9c3d7eb6ed891f4b8490b5b81f21f89f7d288.SDef
|
||||
EnumField sha1_bbf9c3d7eb6ed891f4b8490b5b81f21f89f7d288.E
|
||||
}
|
||||
|
||||
func (def DDef) New() D {
|
||||
return D{
|
||||
types.NewMap(
|
||||
types.NewString("$type"), types.MakeTypeRef(__sha1_d31b592f480b7659b03b72a7d1271f31dde57b2dPackageInFile_sha1_d31b592f480b7659b03b72a7d1271f31dde57b2d_CachedRef, 0),
|
||||
types.NewString("structField"), def.StructField.New(),
|
||||
types.NewString("enumField"), types.UInt32(def.EnumField),
|
||||
), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s D) Def() (d DDef) {
|
||||
d.StructField = s.m.Get(types.NewString("structField")).(sha1_bbf9c3d7eb6ed891f4b8490b5b81f21f89f7d288.S).Def()
|
||||
d.EnumField = sha1_bbf9c3d7eb6ed891f4b8490b5b81f21f89f7d288.E(s.m.Get(types.NewString("enumField")).(types.UInt32))
|
||||
return
|
||||
}
|
||||
|
||||
var __typeRefForD = types.MakeTypeRef(__sha1_d31b592f480b7659b03b72a7d1271f31dde57b2dPackageInFile_sha1_d31b592f480b7659b03b72a7d1271f31dde57b2d_CachedRef, 0)
|
||||
|
||||
func (m D) TypeRef() types.TypeRef {
|
||||
return __typeRefForD
|
||||
}
|
||||
|
||||
func init() {
|
||||
types.RegisterFromValFunction(__typeRefForD, func(v types.Value) types.Value {
|
||||
return DFromVal(v)
|
||||
})
|
||||
}
|
||||
|
||||
func DFromVal(val types.Value) D {
|
||||
// TODO: Do we still need FromVal?
|
||||
if val, ok := val.(D); ok {
|
||||
return val
|
||||
}
|
||||
// TODO: Validate here
|
||||
return D{val.(types.Map), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s D) NomsValue() types.Value {
|
||||
// TODO: Remove this
|
||||
return s
|
||||
}
|
||||
|
||||
func (s D) InternalImplementation() types.Map {
|
||||
return s.m
|
||||
}
|
||||
|
||||
func (s D) Equals(other types.Value) bool {
|
||||
if other, ok := other.(D); ok {
|
||||
return s.Ref() == other.Ref()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (s D) Ref() ref.Ref {
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s D) Chunks() (futures []types.Future) {
|
||||
futures = append(futures, s.TypeRef().Chunks()...)
|
||||
futures = append(futures, s.m.Chunks()...)
|
||||
return
|
||||
}
|
||||
|
||||
func (s D) StructField() sha1_bbf9c3d7eb6ed891f4b8490b5b81f21f89f7d288.S {
|
||||
return s.m.Get(types.NewString("structField")).(sha1_bbf9c3d7eb6ed891f4b8490b5b81f21f89f7d288.S)
|
||||
}
|
||||
|
||||
func (s D) SetStructField(val sha1_bbf9c3d7eb6ed891f4b8490b5b81f21f89f7d288.S) D {
|
||||
return D{s.m.Set(types.NewString("structField"), val), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s D) EnumField() sha1_bbf9c3d7eb6ed891f4b8490b5b81f21f89f7d288.E {
|
||||
return sha1_bbf9c3d7eb6ed891f4b8490b5b81f21f89f7d288.E(s.m.Get(types.NewString("enumField")).(types.UInt32))
|
||||
}
|
||||
|
||||
func (s D) SetEnumField(val sha1_bbf9c3d7eb6ed891f4b8490b5b81f21f89f7d288.E) D {
|
||||
return D{s.m.Set(types.NewString("enumField"), types.UInt32(val)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
// DUser
|
||||
|
||||
type DUser struct {
|
||||
m types.Map
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewDUser() DUser {
|
||||
return DUser{types.NewMap(
|
||||
types.NewString("$type"), types.MakeTypeRef(__sha1_d31b592f480b7659b03b72a7d1271f31dde57b2dPackageInFile_sha1_d31b592f480b7659b03b72a7d1271f31dde57b2d_CachedRef, 1),
|
||||
types.NewString("Dfield"), NewD(),
|
||||
), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type DUserDef struct {
|
||||
Dfield DDef
|
||||
}
|
||||
|
||||
func (def DUserDef) New() DUser {
|
||||
return DUser{
|
||||
types.NewMap(
|
||||
types.NewString("$type"), types.MakeTypeRef(__sha1_d31b592f480b7659b03b72a7d1271f31dde57b2dPackageInFile_sha1_d31b592f480b7659b03b72a7d1271f31dde57b2d_CachedRef, 1),
|
||||
types.NewString("Dfield"), def.Dfield.New(),
|
||||
), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s DUser) Def() (d DUserDef) {
|
||||
d.Dfield = s.m.Get(types.NewString("Dfield")).(D).Def()
|
||||
return
|
||||
}
|
||||
|
||||
var __typeRefForDUser = types.MakeTypeRef(__sha1_d31b592f480b7659b03b72a7d1271f31dde57b2dPackageInFile_sha1_d31b592f480b7659b03b72a7d1271f31dde57b2d_CachedRef, 1)
|
||||
|
||||
func (m DUser) TypeRef() types.TypeRef {
|
||||
return __typeRefForDUser
|
||||
}
|
||||
|
||||
func init() {
|
||||
types.RegisterFromValFunction(__typeRefForDUser, func(v types.Value) types.Value {
|
||||
return DUserFromVal(v)
|
||||
})
|
||||
}
|
||||
|
||||
func DUserFromVal(val types.Value) DUser {
|
||||
// TODO: Do we still need FromVal?
|
||||
if val, ok := val.(DUser); ok {
|
||||
return val
|
||||
}
|
||||
// TODO: Validate here
|
||||
return DUser{val.(types.Map), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s DUser) NomsValue() types.Value {
|
||||
// TODO: Remove this
|
||||
return s
|
||||
}
|
||||
|
||||
func (s DUser) InternalImplementation() types.Map {
|
||||
return s.m
|
||||
}
|
||||
|
||||
func (s DUser) Equals(other types.Value) bool {
|
||||
if other, ok := other.(DUser); ok {
|
||||
return s.Ref() == other.Ref()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (s DUser) Ref() ref.Ref {
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s DUser) Chunks() (futures []types.Future) {
|
||||
futures = append(futures, s.TypeRef().Chunks()...)
|
||||
futures = append(futures, s.m.Chunks()...)
|
||||
return
|
||||
}
|
||||
|
||||
func (s DUser) Dfield() D {
|
||||
return s.m.Get(types.NewString("Dfield")).(D)
|
||||
}
|
||||
|
||||
func (s DUser) SetDfield(val D) DUser {
|
||||
return DUser{s.m.Set(types.NewString("Dfield"), val), &ref.Ref{}}
|
||||
}
|
||||
-199
@@ -1,199 +0,0 @@
|
||||
// This file was generated by nomdl/codegen.
|
||||
|
||||
package sha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c
|
||||
|
||||
import (
|
||||
"github.com/attic-labs/noms/nomdl/codegen/test/gen/sha1_8bbcfa69bdfc9953c4034f8591964e0387983910"
|
||||
"github.com/attic-labs/noms/ref"
|
||||
"github.com/attic-labs/noms/types"
|
||||
)
|
||||
|
||||
var __sha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8cPackageInFile_sha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c_CachedRef = __sha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8cPackageInFile_sha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c_Ref()
|
||||
|
||||
// This function builds up a Noms value that describes the type
|
||||
// package implemented by this file and registers it with the global
|
||||
// type package definition cache.
|
||||
func __sha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8cPackageInFile_sha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c_Ref() ref.Ref {
|
||||
p := types.NewPackage([]types.TypeRef{
|
||||
types.MakeStructTypeRef("D",
|
||||
[]types.Field{
|
||||
types.Field{"structField", types.MakeTypeRef(ref.Parse("sha1-8bbcfa69bdfc9953c4034f8591964e0387983910"), 0), false},
|
||||
types.Field{"enumField", types.MakeTypeRef(ref.Parse("sha1-8bbcfa69bdfc9953c4034f8591964e0387983910"), 1), false},
|
||||
},
|
||||
types.Choices{},
|
||||
),
|
||||
types.MakeStructTypeRef("DUser",
|
||||
[]types.Field{
|
||||
types.Field{"Dfield", types.MakeTypeRef(ref.Ref{}, 0), false},
|
||||
},
|
||||
types.Choices{},
|
||||
),
|
||||
}, []ref.Ref{
|
||||
ref.Parse("sha1-8bbcfa69bdfc9953c4034f8591964e0387983910"),
|
||||
})
|
||||
return types.RegisterPackage(&p)
|
||||
}
|
||||
|
||||
// D
|
||||
|
||||
type D struct {
|
||||
m types.Map
|
||||
}
|
||||
|
||||
func NewD() D {
|
||||
return D{types.NewMap(
|
||||
types.NewString("$type"), types.MakeTypeRef(__sha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8cPackageInFile_sha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c_CachedRef, 0),
|
||||
types.NewString("structField"), sha1_8bbcfa69bdfc9953c4034f8591964e0387983910.NewS().NomsValue(),
|
||||
types.NewString("enumField"), types.UInt32(0),
|
||||
)}
|
||||
}
|
||||
|
||||
type DDef struct {
|
||||
StructField sha1_8bbcfa69bdfc9953c4034f8591964e0387983910.SDef
|
||||
EnumField sha1_8bbcfa69bdfc9953c4034f8591964e0387983910.E
|
||||
}
|
||||
|
||||
func (def DDef) New() D {
|
||||
return D{
|
||||
types.NewMap(
|
||||
types.NewString("$type"), types.MakeTypeRef(__sha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8cPackageInFile_sha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c_CachedRef, 0),
|
||||
types.NewString("structField"), def.StructField.New().NomsValue(),
|
||||
types.NewString("enumField"), types.UInt32(def.EnumField),
|
||||
)}
|
||||
}
|
||||
|
||||
func (s D) Def() (d DDef) {
|
||||
d.StructField = sha1_8bbcfa69bdfc9953c4034f8591964e0387983910.SFromVal(s.m.Get(types.NewString("structField"))).Def()
|
||||
d.EnumField = sha1_8bbcfa69bdfc9953c4034f8591964e0387983910.E(s.m.Get(types.NewString("enumField")).(types.UInt32))
|
||||
return
|
||||
}
|
||||
|
||||
var __typeRefForD = types.MakeTypeRef(__sha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8cPackageInFile_sha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c_CachedRef, 0)
|
||||
|
||||
func (m D) TypeRef() types.TypeRef {
|
||||
return __typeRefForD
|
||||
}
|
||||
|
||||
func init() {
|
||||
types.RegisterFromValFunction(__typeRefForD, func(v types.Value) types.NomsValue {
|
||||
return DFromVal(v)
|
||||
})
|
||||
}
|
||||
|
||||
func DFromVal(val types.Value) D {
|
||||
// TODO: Validate here
|
||||
return D{val.(types.Map)}
|
||||
}
|
||||
|
||||
func (s D) NomsValue() types.Value {
|
||||
return s.m
|
||||
}
|
||||
|
||||
func (s D) Equals(other types.Value) bool {
|
||||
if other, ok := other.(D); ok {
|
||||
return s.m.Equals(other.m)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (s D) Ref() ref.Ref {
|
||||
return s.m.Ref()
|
||||
}
|
||||
|
||||
func (s D) Chunks() (futures []types.Future) {
|
||||
futures = append(futures, s.TypeRef().Chunks()...)
|
||||
futures = append(futures, s.m.Chunks()...)
|
||||
return
|
||||
}
|
||||
|
||||
func (s D) StructField() sha1_8bbcfa69bdfc9953c4034f8591964e0387983910.S {
|
||||
return sha1_8bbcfa69bdfc9953c4034f8591964e0387983910.SFromVal(s.m.Get(types.NewString("structField")))
|
||||
}
|
||||
|
||||
func (s D) SetStructField(val sha1_8bbcfa69bdfc9953c4034f8591964e0387983910.S) D {
|
||||
return D{s.m.Set(types.NewString("structField"), val.NomsValue())}
|
||||
}
|
||||
|
||||
func (s D) EnumField() sha1_8bbcfa69bdfc9953c4034f8591964e0387983910.E {
|
||||
return sha1_8bbcfa69bdfc9953c4034f8591964e0387983910.E(s.m.Get(types.NewString("enumField")).(types.UInt32))
|
||||
}
|
||||
|
||||
func (s D) SetEnumField(val sha1_8bbcfa69bdfc9953c4034f8591964e0387983910.E) D {
|
||||
return D{s.m.Set(types.NewString("enumField"), types.UInt32(val))}
|
||||
}
|
||||
|
||||
// DUser
|
||||
|
||||
type DUser struct {
|
||||
m types.Map
|
||||
}
|
||||
|
||||
func NewDUser() DUser {
|
||||
return DUser{types.NewMap(
|
||||
types.NewString("$type"), types.MakeTypeRef(__sha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8cPackageInFile_sha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c_CachedRef, 1),
|
||||
types.NewString("Dfield"), NewD().NomsValue(),
|
||||
)}
|
||||
}
|
||||
|
||||
type DUserDef struct {
|
||||
Dfield DDef
|
||||
}
|
||||
|
||||
func (def DUserDef) New() DUser {
|
||||
return DUser{
|
||||
types.NewMap(
|
||||
types.NewString("$type"), types.MakeTypeRef(__sha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8cPackageInFile_sha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c_CachedRef, 1),
|
||||
types.NewString("Dfield"), def.Dfield.New().NomsValue(),
|
||||
)}
|
||||
}
|
||||
|
||||
func (s DUser) Def() (d DUserDef) {
|
||||
d.Dfield = DFromVal(s.m.Get(types.NewString("Dfield"))).Def()
|
||||
return
|
||||
}
|
||||
|
||||
var __typeRefForDUser = types.MakeTypeRef(__sha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8cPackageInFile_sha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c_CachedRef, 1)
|
||||
|
||||
func (m DUser) TypeRef() types.TypeRef {
|
||||
return __typeRefForDUser
|
||||
}
|
||||
|
||||
func init() {
|
||||
types.RegisterFromValFunction(__typeRefForDUser, func(v types.Value) types.NomsValue {
|
||||
return DUserFromVal(v)
|
||||
})
|
||||
}
|
||||
|
||||
func DUserFromVal(val types.Value) DUser {
|
||||
// TODO: Validate here
|
||||
return DUser{val.(types.Map)}
|
||||
}
|
||||
|
||||
func (s DUser) NomsValue() types.Value {
|
||||
return s.m
|
||||
}
|
||||
|
||||
func (s DUser) Equals(other types.Value) bool {
|
||||
if other, ok := other.(DUser); ok {
|
||||
return s.m.Equals(other.m)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (s DUser) Ref() ref.Ref {
|
||||
return s.m.Ref()
|
||||
}
|
||||
|
||||
func (s DUser) Chunks() (futures []types.Future) {
|
||||
futures = append(futures, s.TypeRef().Chunks()...)
|
||||
futures = append(futures, s.m.Chunks()...)
|
||||
return
|
||||
}
|
||||
|
||||
func (s DUser) Dfield() D {
|
||||
return DFromVal(s.m.Get(types.NewString("Dfield")))
|
||||
}
|
||||
|
||||
func (s DUser) SetDfield(val D) DUser {
|
||||
return DUser{s.m.Set(types.NewString("Dfield"), val.NomsValue())}
|
||||
}
|
||||
@@ -10,11 +10,12 @@ import (
|
||||
// ListOfInt64
|
||||
|
||||
type ListOfInt64 struct {
|
||||
l types.List
|
||||
l types.List
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewListOfInt64() ListOfInt64 {
|
||||
return ListOfInt64{types.NewList()}
|
||||
return ListOfInt64{types.NewList(), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type ListOfInt64Def []int64
|
||||
@@ -24,7 +25,7 @@ func (def ListOfInt64Def) New() ListOfInt64 {
|
||||
for i, d := range def {
|
||||
l[i] = types.Int64(d)
|
||||
}
|
||||
return ListOfInt64{types.NewList(l...)}
|
||||
return ListOfInt64{types.NewList(l...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfInt64) Def() ListOfInt64Def {
|
||||
@@ -36,23 +37,32 @@ func (l ListOfInt64) Def() ListOfInt64Def {
|
||||
}
|
||||
|
||||
func ListOfInt64FromVal(val types.Value) ListOfInt64 {
|
||||
// TODO: Do we still need FromVal?
|
||||
if val, ok := val.(ListOfInt64); ok {
|
||||
return val
|
||||
}
|
||||
// TODO: Validate here
|
||||
return ListOfInt64{val.(types.List)}
|
||||
return ListOfInt64{val.(types.List), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfInt64) NomsValue() types.Value {
|
||||
// TODO: Remove this
|
||||
return l
|
||||
}
|
||||
|
||||
func (l ListOfInt64) InternalImplementation() types.List {
|
||||
return l.l
|
||||
}
|
||||
|
||||
func (l ListOfInt64) Equals(other types.Value) bool {
|
||||
if other, ok := other.(ListOfInt64); ok {
|
||||
return l.l.Equals(other.l)
|
||||
return l.Ref() == other.Ref()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (l ListOfInt64) Ref() ref.Ref {
|
||||
return l.l.Ref()
|
||||
return types.EnsureRef(l.ref, l)
|
||||
}
|
||||
|
||||
func (l ListOfInt64) Chunks() (futures []types.Future) {
|
||||
@@ -70,7 +80,7 @@ func (m ListOfInt64) TypeRef() types.TypeRef {
|
||||
|
||||
func init() {
|
||||
__typeRefForListOfInt64 = types.MakeCompoundTypeRef("", types.ListKind, types.MakePrimitiveTypeRef(types.Int64Kind))
|
||||
types.RegisterFromValFunction(__typeRefForListOfInt64, func(v types.Value) types.NomsValue {
|
||||
types.RegisterFromValFunction(__typeRefForListOfInt64, func(v types.Value) types.Value {
|
||||
return ListOfInt64FromVal(v)
|
||||
})
|
||||
}
|
||||
@@ -88,27 +98,27 @@ func (l ListOfInt64) Get(i uint64) int64 {
|
||||
}
|
||||
|
||||
func (l ListOfInt64) Slice(idx uint64, end uint64) ListOfInt64 {
|
||||
return ListOfInt64{l.l.Slice(idx, end)}
|
||||
return ListOfInt64{l.l.Slice(idx, end), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfInt64) Set(i uint64, val int64) ListOfInt64 {
|
||||
return ListOfInt64{l.l.Set(i, types.Int64(val))}
|
||||
return ListOfInt64{l.l.Set(i, types.Int64(val)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfInt64) Append(v ...int64) ListOfInt64 {
|
||||
return ListOfInt64{l.l.Append(l.fromElemSlice(v)...)}
|
||||
return ListOfInt64{l.l.Append(l.fromElemSlice(v)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfInt64) Insert(idx uint64, v ...int64) ListOfInt64 {
|
||||
return ListOfInt64{l.l.Insert(idx, l.fromElemSlice(v)...)}
|
||||
return ListOfInt64{l.l.Insert(idx, l.fromElemSlice(v)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfInt64) Remove(idx uint64, end uint64) ListOfInt64 {
|
||||
return ListOfInt64{l.l.Remove(idx, end)}
|
||||
return ListOfInt64{l.l.Remove(idx, end), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfInt64) RemoveAt(idx uint64) ListOfInt64 {
|
||||
return ListOfInt64{(l.l.RemoveAt(idx))}
|
||||
return ListOfInt64{(l.l.RemoveAt(idx)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfInt64) fromElemSlice(p []int64) []types.Value {
|
||||
|
||||
+40
-20
@@ -10,11 +10,12 @@ import (
|
||||
// MapOfBoolToString
|
||||
|
||||
type MapOfBoolToString struct {
|
||||
m types.Map
|
||||
m types.Map
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewMapOfBoolToString() MapOfBoolToString {
|
||||
return MapOfBoolToString{types.NewMap()}
|
||||
return MapOfBoolToString{types.NewMap(), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type MapOfBoolToStringDef map[bool]string
|
||||
@@ -24,7 +25,7 @@ func (def MapOfBoolToStringDef) New() MapOfBoolToString {
|
||||
for k, v := range def {
|
||||
kv = append(kv, types.Bool(k), types.NewString(v))
|
||||
}
|
||||
return MapOfBoolToString{types.NewMap(kv...)}
|
||||
return MapOfBoolToString{types.NewMap(kv...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (m MapOfBoolToString) Def() MapOfBoolToStringDef {
|
||||
@@ -36,24 +37,33 @@ func (m MapOfBoolToString) Def() MapOfBoolToStringDef {
|
||||
return def
|
||||
}
|
||||
|
||||
func MapOfBoolToStringFromVal(p types.Value) MapOfBoolToString {
|
||||
func MapOfBoolToStringFromVal(val types.Value) MapOfBoolToString {
|
||||
// TODO: Do we still need FromVal?
|
||||
if val, ok := val.(MapOfBoolToString); ok {
|
||||
return val
|
||||
}
|
||||
// TODO: Validate here
|
||||
return MapOfBoolToString{p.(types.Map)}
|
||||
return MapOfBoolToString{val.(types.Map), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (m MapOfBoolToString) NomsValue() types.Value {
|
||||
// TODO: Remove this
|
||||
return m
|
||||
}
|
||||
|
||||
func (m MapOfBoolToString) InternalImplementation() types.Map {
|
||||
return m.m
|
||||
}
|
||||
|
||||
func (m MapOfBoolToString) Equals(other types.Value) bool {
|
||||
if other, ok := other.(MapOfBoolToString); ok {
|
||||
return m.m.Equals(other.m)
|
||||
return m.Ref() == other.Ref()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (m MapOfBoolToString) Ref() ref.Ref {
|
||||
return m.m.Ref()
|
||||
return types.EnsureRef(m.ref, m)
|
||||
}
|
||||
|
||||
func (m MapOfBoolToString) Chunks() (futures []types.Future) {
|
||||
@@ -71,7 +81,7 @@ func (m MapOfBoolToString) TypeRef() types.TypeRef {
|
||||
|
||||
func init() {
|
||||
__typeRefForMapOfBoolToString = types.MakeCompoundTypeRef("", types.MapKind, types.MakePrimitiveTypeRef(types.BoolKind), types.MakePrimitiveTypeRef(types.StringKind))
|
||||
types.RegisterFromValFunction(__typeRefForMapOfBoolToString, func(v types.Value) types.NomsValue {
|
||||
types.RegisterFromValFunction(__typeRefForMapOfBoolToString, func(v types.Value) types.Value {
|
||||
return MapOfBoolToStringFromVal(v)
|
||||
})
|
||||
}
|
||||
@@ -101,13 +111,13 @@ func (m MapOfBoolToString) MaybeGet(p bool) (string, bool) {
|
||||
}
|
||||
|
||||
func (m MapOfBoolToString) Set(k bool, v string) MapOfBoolToString {
|
||||
return MapOfBoolToString{m.m.Set(types.Bool(k), types.NewString(v))}
|
||||
return MapOfBoolToString{m.m.Set(types.Bool(k), types.NewString(v)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
// TODO: Implement SetM?
|
||||
|
||||
func (m MapOfBoolToString) Remove(p bool) MapOfBoolToString {
|
||||
return MapOfBoolToString{m.m.Remove(types.Bool(p))}
|
||||
return MapOfBoolToString{m.m.Remove(types.Bool(p)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type MapOfBoolToStringIterCallback func(k bool, v string) (stop bool)
|
||||
@@ -141,11 +151,12 @@ func (m MapOfBoolToString) Filter(cb MapOfBoolToStringFilterCallback) MapOfBoolT
|
||||
// MapOfStringToValue
|
||||
|
||||
type MapOfStringToValue struct {
|
||||
m types.Map
|
||||
m types.Map
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewMapOfStringToValue() MapOfStringToValue {
|
||||
return MapOfStringToValue{types.NewMap()}
|
||||
return MapOfStringToValue{types.NewMap(), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type MapOfStringToValueDef map[string]types.Value
|
||||
@@ -155,7 +166,7 @@ func (def MapOfStringToValueDef) New() MapOfStringToValue {
|
||||
for k, v := range def {
|
||||
kv = append(kv, types.NewString(k), v)
|
||||
}
|
||||
return MapOfStringToValue{types.NewMap(kv...)}
|
||||
return MapOfStringToValue{types.NewMap(kv...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (m MapOfStringToValue) Def() MapOfStringToValueDef {
|
||||
@@ -167,24 +178,33 @@ func (m MapOfStringToValue) Def() MapOfStringToValueDef {
|
||||
return def
|
||||
}
|
||||
|
||||
func MapOfStringToValueFromVal(p types.Value) MapOfStringToValue {
|
||||
func MapOfStringToValueFromVal(val types.Value) MapOfStringToValue {
|
||||
// TODO: Do we still need FromVal?
|
||||
if val, ok := val.(MapOfStringToValue); ok {
|
||||
return val
|
||||
}
|
||||
// TODO: Validate here
|
||||
return MapOfStringToValue{p.(types.Map)}
|
||||
return MapOfStringToValue{val.(types.Map), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (m MapOfStringToValue) NomsValue() types.Value {
|
||||
// TODO: Remove this
|
||||
return m
|
||||
}
|
||||
|
||||
func (m MapOfStringToValue) InternalImplementation() types.Map {
|
||||
return m.m
|
||||
}
|
||||
|
||||
func (m MapOfStringToValue) Equals(other types.Value) bool {
|
||||
if other, ok := other.(MapOfStringToValue); ok {
|
||||
return m.m.Equals(other.m)
|
||||
return m.Ref() == other.Ref()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (m MapOfStringToValue) Ref() ref.Ref {
|
||||
return m.m.Ref()
|
||||
return types.EnsureRef(m.ref, m)
|
||||
}
|
||||
|
||||
func (m MapOfStringToValue) Chunks() (futures []types.Future) {
|
||||
@@ -202,7 +222,7 @@ func (m MapOfStringToValue) TypeRef() types.TypeRef {
|
||||
|
||||
func init() {
|
||||
__typeRefForMapOfStringToValue = types.MakeCompoundTypeRef("", types.MapKind, types.MakePrimitiveTypeRef(types.StringKind), types.MakePrimitiveTypeRef(types.ValueKind))
|
||||
types.RegisterFromValFunction(__typeRefForMapOfStringToValue, func(v types.Value) types.NomsValue {
|
||||
types.RegisterFromValFunction(__typeRefForMapOfStringToValue, func(v types.Value) types.Value {
|
||||
return MapOfStringToValueFromVal(v)
|
||||
})
|
||||
}
|
||||
@@ -232,13 +252,13 @@ func (m MapOfStringToValue) MaybeGet(p string) (types.Value, bool) {
|
||||
}
|
||||
|
||||
func (m MapOfStringToValue) Set(k string, v types.Value) MapOfStringToValue {
|
||||
return MapOfStringToValue{m.m.Set(types.NewString(k), v)}
|
||||
return MapOfStringToValue{m.m.Set(types.NewString(k), v), &ref.Ref{}}
|
||||
}
|
||||
|
||||
// TODO: Implement SetM?
|
||||
|
||||
func (m MapOfStringToValue) Remove(p string) MapOfStringToValue {
|
||||
return MapOfStringToValue{m.m.Remove(types.NewString(p))}
|
||||
return MapOfStringToValue{m.m.Remove(types.NewString(p)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type MapOfStringToValueIterCallback func(k string, v types.Value) (stop bool)
|
||||
|
||||
+153
-86
@@ -28,14 +28,15 @@ func __testPackageInFile_ref_Ref() ref.Ref {
|
||||
// StructWithRef
|
||||
|
||||
type StructWithRef struct {
|
||||
m types.Map
|
||||
m types.Map
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewStructWithRef() StructWithRef {
|
||||
return StructWithRef{types.NewMap(
|
||||
types.NewString("$type"), types.MakeTypeRef(__testPackageInFile_ref_CachedRef, 0),
|
||||
types.NewString("r"), types.Ref{R: ref.Ref{}},
|
||||
)}
|
||||
types.NewString("r"), NewRefOfSetOfFloat32(ref.Ref{}),
|
||||
), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type StructWithRefDef struct {
|
||||
@@ -46,8 +47,8 @@ func (def StructWithRefDef) New() StructWithRef {
|
||||
return StructWithRef{
|
||||
types.NewMap(
|
||||
types.NewString("$type"), types.MakeTypeRef(__testPackageInFile_ref_CachedRef, 0),
|
||||
types.NewString("r"), types.Ref{R: def.R},
|
||||
)}
|
||||
types.NewString("r"), NewRefOfSetOfFloat32(def.R),
|
||||
), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s StructWithRef) Def() (d StructWithRefDef) {
|
||||
@@ -62,29 +63,38 @@ func (m StructWithRef) TypeRef() types.TypeRef {
|
||||
}
|
||||
|
||||
func init() {
|
||||
types.RegisterFromValFunction(__typeRefForStructWithRef, func(v types.Value) types.NomsValue {
|
||||
types.RegisterFromValFunction(__typeRefForStructWithRef, func(v types.Value) types.Value {
|
||||
return StructWithRefFromVal(v)
|
||||
})
|
||||
}
|
||||
|
||||
func StructWithRefFromVal(val types.Value) StructWithRef {
|
||||
// TODO: Do we still need FromVal?
|
||||
if val, ok := val.(StructWithRef); ok {
|
||||
return val
|
||||
}
|
||||
// TODO: Validate here
|
||||
return StructWithRef{val.(types.Map)}
|
||||
return StructWithRef{val.(types.Map), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s StructWithRef) NomsValue() types.Value {
|
||||
// TODO: Remove this
|
||||
return s
|
||||
}
|
||||
|
||||
func (s StructWithRef) InternalImplementation() types.Map {
|
||||
return s.m
|
||||
}
|
||||
|
||||
func (s StructWithRef) Equals(other types.Value) bool {
|
||||
if other, ok := other.(StructWithRef); ok {
|
||||
return s.m.Equals(other.m)
|
||||
return s.Ref() == other.Ref()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (s StructWithRef) Ref() ref.Ref {
|
||||
return s.m.Ref()
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s StructWithRef) Chunks() (futures []types.Future) {
|
||||
@@ -94,30 +104,31 @@ func (s StructWithRef) Chunks() (futures []types.Future) {
|
||||
}
|
||||
|
||||
func (s StructWithRef) R() RefOfSetOfFloat32 {
|
||||
return RefOfSetOfFloat32FromVal(s.m.Get(types.NewString("r")))
|
||||
return s.m.Get(types.NewString("r")).(RefOfSetOfFloat32)
|
||||
}
|
||||
|
||||
func (s StructWithRef) SetR(val RefOfSetOfFloat32) StructWithRef {
|
||||
return StructWithRef{s.m.Set(types.NewString("r"), val.NomsValue())}
|
||||
return StructWithRef{s.m.Set(types.NewString("r"), val), &ref.Ref{}}
|
||||
}
|
||||
|
||||
// RefOfListOfString
|
||||
|
||||
type RefOfListOfString struct {
|
||||
r ref.Ref
|
||||
r ref.Ref
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewRefOfListOfString(r ref.Ref) RefOfListOfString {
|
||||
return RefOfListOfString{r}
|
||||
return RefOfListOfString{r, &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (r RefOfListOfString) Ref() ref.Ref {
|
||||
return r.r
|
||||
return types.EnsureRef(r.ref, r)
|
||||
}
|
||||
|
||||
func (r RefOfListOfString) Equals(other types.Value) bool {
|
||||
if other, ok := other.(RefOfListOfString); ok {
|
||||
return r.r == other.r
|
||||
return r.Ref() == other.Ref()
|
||||
}
|
||||
return false
|
||||
}
|
||||
@@ -127,11 +138,20 @@ func (r RefOfListOfString) Chunks() []types.Future {
|
||||
}
|
||||
|
||||
func (r RefOfListOfString) NomsValue() types.Value {
|
||||
return types.Ref{R: r.r}
|
||||
// TODO: Remove this
|
||||
return r
|
||||
}
|
||||
|
||||
func RefOfListOfStringFromVal(p types.Value) RefOfListOfString {
|
||||
return RefOfListOfString{p.(types.Ref).Ref()}
|
||||
func (r RefOfListOfString) InternalImplementation() ref.Ref {
|
||||
return r.r
|
||||
}
|
||||
|
||||
func RefOfListOfStringFromVal(val types.Value) RefOfListOfString {
|
||||
// TODO: Do we still need FromVal?
|
||||
if val, ok := val.(RefOfListOfString); ok {
|
||||
return val
|
||||
}
|
||||
return RefOfListOfString{val.(types.Ref).Ref(), &ref.Ref{}}
|
||||
}
|
||||
|
||||
// A Noms Value that describes RefOfListOfString.
|
||||
@@ -143,28 +163,28 @@ func (m RefOfListOfString) TypeRef() types.TypeRef {
|
||||
|
||||
func init() {
|
||||
__typeRefForRefOfListOfString = types.MakeCompoundTypeRef("", types.RefKind, types.MakeCompoundTypeRef("", types.ListKind, types.MakePrimitiveTypeRef(types.StringKind)))
|
||||
types.RegisterFromValFunction(__typeRefForRefOfListOfString, func(v types.Value) types.NomsValue {
|
||||
types.RegisterFromValFunction(__typeRefForRefOfListOfString, func(v types.Value) types.Value {
|
||||
return RefOfListOfStringFromVal(v)
|
||||
})
|
||||
}
|
||||
|
||||
func (r RefOfListOfString) GetValue(cs chunks.ChunkSource) ListOfString {
|
||||
return ListOfStringFromVal(types.ReadValue(r.r, cs))
|
||||
return types.ReadValue(r.r, cs).(ListOfString)
|
||||
}
|
||||
|
||||
func (r RefOfListOfString) SetValue(val ListOfString, cs chunks.ChunkSink) RefOfListOfString {
|
||||
ref := types.WriteValue(val.NomsValue(), cs)
|
||||
return RefOfListOfString{ref}
|
||||
return RefOfListOfString{types.WriteValue(val, cs), &ref.Ref{}}
|
||||
}
|
||||
|
||||
// ListOfRefOfFloat32
|
||||
|
||||
type ListOfRefOfFloat32 struct {
|
||||
l types.List
|
||||
l types.List
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewListOfRefOfFloat32() ListOfRefOfFloat32 {
|
||||
return ListOfRefOfFloat32{types.NewList()}
|
||||
return ListOfRefOfFloat32{types.NewList(), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type ListOfRefOfFloat32Def []ref.Ref
|
||||
@@ -172,9 +192,9 @@ type ListOfRefOfFloat32Def []ref.Ref
|
||||
func (def ListOfRefOfFloat32Def) New() ListOfRefOfFloat32 {
|
||||
l := make([]types.Value, len(def))
|
||||
for i, d := range def {
|
||||
l[i] = types.Ref{R: d}
|
||||
l[i] = NewRefOfFloat32(d)
|
||||
}
|
||||
return ListOfRefOfFloat32{types.NewList(l...)}
|
||||
return ListOfRefOfFloat32{types.NewList(l...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfRefOfFloat32) Def() ListOfRefOfFloat32Def {
|
||||
@@ -186,23 +206,32 @@ func (l ListOfRefOfFloat32) Def() ListOfRefOfFloat32Def {
|
||||
}
|
||||
|
||||
func ListOfRefOfFloat32FromVal(val types.Value) ListOfRefOfFloat32 {
|
||||
// TODO: Do we still need FromVal?
|
||||
if val, ok := val.(ListOfRefOfFloat32); ok {
|
||||
return val
|
||||
}
|
||||
// TODO: Validate here
|
||||
return ListOfRefOfFloat32{val.(types.List)}
|
||||
return ListOfRefOfFloat32{val.(types.List), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfRefOfFloat32) NomsValue() types.Value {
|
||||
// TODO: Remove this
|
||||
return l
|
||||
}
|
||||
|
||||
func (l ListOfRefOfFloat32) InternalImplementation() types.List {
|
||||
return l.l
|
||||
}
|
||||
|
||||
func (l ListOfRefOfFloat32) Equals(other types.Value) bool {
|
||||
if other, ok := other.(ListOfRefOfFloat32); ok {
|
||||
return l.l.Equals(other.l)
|
||||
return l.Ref() == other.Ref()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (l ListOfRefOfFloat32) Ref() ref.Ref {
|
||||
return l.l.Ref()
|
||||
return types.EnsureRef(l.ref, l)
|
||||
}
|
||||
|
||||
func (l ListOfRefOfFloat32) Chunks() (futures []types.Future) {
|
||||
@@ -220,7 +249,7 @@ func (m ListOfRefOfFloat32) TypeRef() types.TypeRef {
|
||||
|
||||
func init() {
|
||||
__typeRefForListOfRefOfFloat32 = types.MakeCompoundTypeRef("", types.ListKind, types.MakeCompoundTypeRef("", types.RefKind, types.MakePrimitiveTypeRef(types.Float32Kind)))
|
||||
types.RegisterFromValFunction(__typeRefForListOfRefOfFloat32, func(v types.Value) types.NomsValue {
|
||||
types.RegisterFromValFunction(__typeRefForListOfRefOfFloat32, func(v types.Value) types.Value {
|
||||
return ListOfRefOfFloat32FromVal(v)
|
||||
})
|
||||
}
|
||||
@@ -234,37 +263,37 @@ func (l ListOfRefOfFloat32) Empty() bool {
|
||||
}
|
||||
|
||||
func (l ListOfRefOfFloat32) Get(i uint64) RefOfFloat32 {
|
||||
return RefOfFloat32FromVal(l.l.Get(i))
|
||||
return l.l.Get(i).(RefOfFloat32)
|
||||
}
|
||||
|
||||
func (l ListOfRefOfFloat32) Slice(idx uint64, end uint64) ListOfRefOfFloat32 {
|
||||
return ListOfRefOfFloat32{l.l.Slice(idx, end)}
|
||||
return ListOfRefOfFloat32{l.l.Slice(idx, end), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfRefOfFloat32) Set(i uint64, val RefOfFloat32) ListOfRefOfFloat32 {
|
||||
return ListOfRefOfFloat32{l.l.Set(i, val.NomsValue())}
|
||||
return ListOfRefOfFloat32{l.l.Set(i, val), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfRefOfFloat32) Append(v ...RefOfFloat32) ListOfRefOfFloat32 {
|
||||
return ListOfRefOfFloat32{l.l.Append(l.fromElemSlice(v)...)}
|
||||
return ListOfRefOfFloat32{l.l.Append(l.fromElemSlice(v)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfRefOfFloat32) Insert(idx uint64, v ...RefOfFloat32) ListOfRefOfFloat32 {
|
||||
return ListOfRefOfFloat32{l.l.Insert(idx, l.fromElemSlice(v)...)}
|
||||
return ListOfRefOfFloat32{l.l.Insert(idx, l.fromElemSlice(v)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfRefOfFloat32) Remove(idx uint64, end uint64) ListOfRefOfFloat32 {
|
||||
return ListOfRefOfFloat32{l.l.Remove(idx, end)}
|
||||
return ListOfRefOfFloat32{l.l.Remove(idx, end), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfRefOfFloat32) RemoveAt(idx uint64) ListOfRefOfFloat32 {
|
||||
return ListOfRefOfFloat32{(l.l.RemoveAt(idx))}
|
||||
return ListOfRefOfFloat32{(l.l.RemoveAt(idx)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfRefOfFloat32) fromElemSlice(p []RefOfFloat32) []types.Value {
|
||||
r := make([]types.Value, len(p))
|
||||
for i, v := range p {
|
||||
r[i] = v.NomsValue()
|
||||
r[i] = v
|
||||
}
|
||||
return r
|
||||
}
|
||||
@@ -273,7 +302,7 @@ type ListOfRefOfFloat32IterCallback func(v RefOfFloat32, i uint64) (stop bool)
|
||||
|
||||
func (l ListOfRefOfFloat32) Iter(cb ListOfRefOfFloat32IterCallback) {
|
||||
l.l.Iter(func(v types.Value, i uint64) bool {
|
||||
return cb(RefOfFloat32FromVal(v), i)
|
||||
return cb(v.(RefOfFloat32), i)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -281,7 +310,7 @@ type ListOfRefOfFloat32IterAllCallback func(v RefOfFloat32, i uint64)
|
||||
|
||||
func (l ListOfRefOfFloat32) IterAll(cb ListOfRefOfFloat32IterAllCallback) {
|
||||
l.l.IterAll(func(v types.Value, i uint64) {
|
||||
cb(RefOfFloat32FromVal(v), i)
|
||||
cb(v.(RefOfFloat32), i)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -300,20 +329,21 @@ func (l ListOfRefOfFloat32) Filter(cb ListOfRefOfFloat32FilterCallback) ListOfRe
|
||||
// RefOfSetOfFloat32
|
||||
|
||||
type RefOfSetOfFloat32 struct {
|
||||
r ref.Ref
|
||||
r ref.Ref
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewRefOfSetOfFloat32(r ref.Ref) RefOfSetOfFloat32 {
|
||||
return RefOfSetOfFloat32{r}
|
||||
return RefOfSetOfFloat32{r, &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (r RefOfSetOfFloat32) Ref() ref.Ref {
|
||||
return r.r
|
||||
return types.EnsureRef(r.ref, r)
|
||||
}
|
||||
|
||||
func (r RefOfSetOfFloat32) Equals(other types.Value) bool {
|
||||
if other, ok := other.(RefOfSetOfFloat32); ok {
|
||||
return r.r == other.r
|
||||
return r.Ref() == other.Ref()
|
||||
}
|
||||
return false
|
||||
}
|
||||
@@ -323,11 +353,20 @@ func (r RefOfSetOfFloat32) Chunks() []types.Future {
|
||||
}
|
||||
|
||||
func (r RefOfSetOfFloat32) NomsValue() types.Value {
|
||||
return types.Ref{R: r.r}
|
||||
// TODO: Remove this
|
||||
return r
|
||||
}
|
||||
|
||||
func RefOfSetOfFloat32FromVal(p types.Value) RefOfSetOfFloat32 {
|
||||
return RefOfSetOfFloat32{p.(types.Ref).Ref()}
|
||||
func (r RefOfSetOfFloat32) InternalImplementation() ref.Ref {
|
||||
return r.r
|
||||
}
|
||||
|
||||
func RefOfSetOfFloat32FromVal(val types.Value) RefOfSetOfFloat32 {
|
||||
// TODO: Do we still need FromVal?
|
||||
if val, ok := val.(RefOfSetOfFloat32); ok {
|
||||
return val
|
||||
}
|
||||
return RefOfSetOfFloat32{val.(types.Ref).Ref(), &ref.Ref{}}
|
||||
}
|
||||
|
||||
// A Noms Value that describes RefOfSetOfFloat32.
|
||||
@@ -339,28 +378,28 @@ func (m RefOfSetOfFloat32) TypeRef() types.TypeRef {
|
||||
|
||||
func init() {
|
||||
__typeRefForRefOfSetOfFloat32 = types.MakeCompoundTypeRef("", types.RefKind, types.MakeCompoundTypeRef("", types.SetKind, types.MakePrimitiveTypeRef(types.Float32Kind)))
|
||||
types.RegisterFromValFunction(__typeRefForRefOfSetOfFloat32, func(v types.Value) types.NomsValue {
|
||||
types.RegisterFromValFunction(__typeRefForRefOfSetOfFloat32, func(v types.Value) types.Value {
|
||||
return RefOfSetOfFloat32FromVal(v)
|
||||
})
|
||||
}
|
||||
|
||||
func (r RefOfSetOfFloat32) GetValue(cs chunks.ChunkSource) SetOfFloat32 {
|
||||
return SetOfFloat32FromVal(types.ReadValue(r.r, cs))
|
||||
return types.ReadValue(r.r, cs).(SetOfFloat32)
|
||||
}
|
||||
|
||||
func (r RefOfSetOfFloat32) SetValue(val SetOfFloat32, cs chunks.ChunkSink) RefOfSetOfFloat32 {
|
||||
ref := types.WriteValue(val.NomsValue(), cs)
|
||||
return RefOfSetOfFloat32{ref}
|
||||
return RefOfSetOfFloat32{types.WriteValue(val, cs), &ref.Ref{}}
|
||||
}
|
||||
|
||||
// ListOfString
|
||||
|
||||
type ListOfString struct {
|
||||
l types.List
|
||||
l types.List
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewListOfString() ListOfString {
|
||||
return ListOfString{types.NewList()}
|
||||
return ListOfString{types.NewList(), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type ListOfStringDef []string
|
||||
@@ -370,7 +409,7 @@ func (def ListOfStringDef) New() ListOfString {
|
||||
for i, d := range def {
|
||||
l[i] = types.NewString(d)
|
||||
}
|
||||
return ListOfString{types.NewList(l...)}
|
||||
return ListOfString{types.NewList(l...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfString) Def() ListOfStringDef {
|
||||
@@ -382,23 +421,32 @@ func (l ListOfString) Def() ListOfStringDef {
|
||||
}
|
||||
|
||||
func ListOfStringFromVal(val types.Value) ListOfString {
|
||||
// TODO: Do we still need FromVal?
|
||||
if val, ok := val.(ListOfString); ok {
|
||||
return val
|
||||
}
|
||||
// TODO: Validate here
|
||||
return ListOfString{val.(types.List)}
|
||||
return ListOfString{val.(types.List), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfString) NomsValue() types.Value {
|
||||
// TODO: Remove this
|
||||
return l
|
||||
}
|
||||
|
||||
func (l ListOfString) InternalImplementation() types.List {
|
||||
return l.l
|
||||
}
|
||||
|
||||
func (l ListOfString) Equals(other types.Value) bool {
|
||||
if other, ok := other.(ListOfString); ok {
|
||||
return l.l.Equals(other.l)
|
||||
return l.Ref() == other.Ref()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (l ListOfString) Ref() ref.Ref {
|
||||
return l.l.Ref()
|
||||
return types.EnsureRef(l.ref, l)
|
||||
}
|
||||
|
||||
func (l ListOfString) Chunks() (futures []types.Future) {
|
||||
@@ -416,7 +464,7 @@ func (m ListOfString) TypeRef() types.TypeRef {
|
||||
|
||||
func init() {
|
||||
__typeRefForListOfString = types.MakeCompoundTypeRef("", types.ListKind, types.MakePrimitiveTypeRef(types.StringKind))
|
||||
types.RegisterFromValFunction(__typeRefForListOfString, func(v types.Value) types.NomsValue {
|
||||
types.RegisterFromValFunction(__typeRefForListOfString, func(v types.Value) types.Value {
|
||||
return ListOfStringFromVal(v)
|
||||
})
|
||||
}
|
||||
@@ -434,27 +482,27 @@ func (l ListOfString) Get(i uint64) string {
|
||||
}
|
||||
|
||||
func (l ListOfString) Slice(idx uint64, end uint64) ListOfString {
|
||||
return ListOfString{l.l.Slice(idx, end)}
|
||||
return ListOfString{l.l.Slice(idx, end), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfString) Set(i uint64, val string) ListOfString {
|
||||
return ListOfString{l.l.Set(i, types.NewString(val))}
|
||||
return ListOfString{l.l.Set(i, types.NewString(val)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfString) Append(v ...string) ListOfString {
|
||||
return ListOfString{l.l.Append(l.fromElemSlice(v)...)}
|
||||
return ListOfString{l.l.Append(l.fromElemSlice(v)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfString) Insert(idx uint64, v ...string) ListOfString {
|
||||
return ListOfString{l.l.Insert(idx, l.fromElemSlice(v)...)}
|
||||
return ListOfString{l.l.Insert(idx, l.fromElemSlice(v)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfString) Remove(idx uint64, end uint64) ListOfString {
|
||||
return ListOfString{l.l.Remove(idx, end)}
|
||||
return ListOfString{l.l.Remove(idx, end), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfString) RemoveAt(idx uint64) ListOfString {
|
||||
return ListOfString{(l.l.RemoveAt(idx))}
|
||||
return ListOfString{(l.l.RemoveAt(idx)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfString) fromElemSlice(p []string) []types.Value {
|
||||
@@ -496,20 +544,21 @@ func (l ListOfString) Filter(cb ListOfStringFilterCallback) ListOfString {
|
||||
// RefOfFloat32
|
||||
|
||||
type RefOfFloat32 struct {
|
||||
r ref.Ref
|
||||
r ref.Ref
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewRefOfFloat32(r ref.Ref) RefOfFloat32 {
|
||||
return RefOfFloat32{r}
|
||||
return RefOfFloat32{r, &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (r RefOfFloat32) Ref() ref.Ref {
|
||||
return r.r
|
||||
return types.EnsureRef(r.ref, r)
|
||||
}
|
||||
|
||||
func (r RefOfFloat32) Equals(other types.Value) bool {
|
||||
if other, ok := other.(RefOfFloat32); ok {
|
||||
return r.r == other.r
|
||||
return r.Ref() == other.Ref()
|
||||
}
|
||||
return false
|
||||
}
|
||||
@@ -519,11 +568,20 @@ func (r RefOfFloat32) Chunks() []types.Future {
|
||||
}
|
||||
|
||||
func (r RefOfFloat32) NomsValue() types.Value {
|
||||
return types.Ref{R: r.r}
|
||||
// TODO: Remove this
|
||||
return r
|
||||
}
|
||||
|
||||
func RefOfFloat32FromVal(p types.Value) RefOfFloat32 {
|
||||
return RefOfFloat32{p.(types.Ref).Ref()}
|
||||
func (r RefOfFloat32) InternalImplementation() ref.Ref {
|
||||
return r.r
|
||||
}
|
||||
|
||||
func RefOfFloat32FromVal(val types.Value) RefOfFloat32 {
|
||||
// TODO: Do we still need FromVal?
|
||||
if val, ok := val.(RefOfFloat32); ok {
|
||||
return val
|
||||
}
|
||||
return RefOfFloat32{val.(types.Ref).Ref(), &ref.Ref{}}
|
||||
}
|
||||
|
||||
// A Noms Value that describes RefOfFloat32.
|
||||
@@ -535,7 +593,7 @@ func (m RefOfFloat32) TypeRef() types.TypeRef {
|
||||
|
||||
func init() {
|
||||
__typeRefForRefOfFloat32 = types.MakeCompoundTypeRef("", types.RefKind, types.MakePrimitiveTypeRef(types.Float32Kind))
|
||||
types.RegisterFromValFunction(__typeRefForRefOfFloat32, func(v types.Value) types.NomsValue {
|
||||
types.RegisterFromValFunction(__typeRefForRefOfFloat32, func(v types.Value) types.Value {
|
||||
return RefOfFloat32FromVal(v)
|
||||
})
|
||||
}
|
||||
@@ -545,18 +603,18 @@ func (r RefOfFloat32) GetValue(cs chunks.ChunkSource) float32 {
|
||||
}
|
||||
|
||||
func (r RefOfFloat32) SetValue(val float32, cs chunks.ChunkSink) RefOfFloat32 {
|
||||
ref := types.WriteValue(types.Float32(val), cs)
|
||||
return RefOfFloat32{ref}
|
||||
return RefOfFloat32{types.WriteValue(types.Float32(val), cs), &ref.Ref{}}
|
||||
}
|
||||
|
||||
// SetOfFloat32
|
||||
|
||||
type SetOfFloat32 struct {
|
||||
s types.Set
|
||||
s types.Set
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewSetOfFloat32() SetOfFloat32 {
|
||||
return SetOfFloat32{types.NewSet()}
|
||||
return SetOfFloat32{types.NewSet(), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type SetOfFloat32Def map[float32]bool
|
||||
@@ -568,7 +626,7 @@ func (def SetOfFloat32Def) New() SetOfFloat32 {
|
||||
l[i] = types.Float32(d)
|
||||
i++
|
||||
}
|
||||
return SetOfFloat32{types.NewSet(l...)}
|
||||
return SetOfFloat32{types.NewSet(l...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfFloat32) Def() SetOfFloat32Def {
|
||||
@@ -580,23 +638,32 @@ func (s SetOfFloat32) Def() SetOfFloat32Def {
|
||||
return def
|
||||
}
|
||||
|
||||
func SetOfFloat32FromVal(p types.Value) SetOfFloat32 {
|
||||
return SetOfFloat32{p.(types.Set)}
|
||||
func SetOfFloat32FromVal(val types.Value) SetOfFloat32 {
|
||||
// TODO: Do we still need FromVal?
|
||||
if val, ok := val.(SetOfFloat32); ok {
|
||||
return val
|
||||
}
|
||||
return SetOfFloat32{val.(types.Set), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfFloat32) NomsValue() types.Value {
|
||||
// TODO: Remove this
|
||||
return s
|
||||
}
|
||||
|
||||
func (s SetOfFloat32) InternalImplementation() types.Set {
|
||||
return s.s
|
||||
}
|
||||
|
||||
func (s SetOfFloat32) Equals(other types.Value) bool {
|
||||
if other, ok := other.(SetOfFloat32); ok {
|
||||
return s.s.Equals(other.s)
|
||||
return s.Ref() == other.Ref()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (s SetOfFloat32) Ref() ref.Ref {
|
||||
return s.s.Ref()
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s SetOfFloat32) Chunks() (futures []types.Future) {
|
||||
@@ -614,7 +681,7 @@ func (m SetOfFloat32) TypeRef() types.TypeRef {
|
||||
|
||||
func init() {
|
||||
__typeRefForSetOfFloat32 = types.MakeCompoundTypeRef("", types.SetKind, types.MakePrimitiveTypeRef(types.Float32Kind))
|
||||
types.RegisterFromValFunction(__typeRefForSetOfFloat32, func(v types.Value) types.NomsValue {
|
||||
types.RegisterFromValFunction(__typeRefForSetOfFloat32, func(v types.Value) types.Value {
|
||||
return SetOfFloat32FromVal(v)
|
||||
})
|
||||
}
|
||||
@@ -660,19 +727,19 @@ func (s SetOfFloat32) Filter(cb SetOfFloat32FilterCallback) SetOfFloat32 {
|
||||
}
|
||||
|
||||
func (s SetOfFloat32) Insert(p ...float32) SetOfFloat32 {
|
||||
return SetOfFloat32{s.s.Insert(s.fromElemSlice(p)...)}
|
||||
return SetOfFloat32{s.s.Insert(s.fromElemSlice(p)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfFloat32) Remove(p ...float32) SetOfFloat32 {
|
||||
return SetOfFloat32{s.s.Remove(s.fromElemSlice(p)...)}
|
||||
return SetOfFloat32{s.s.Remove(s.fromElemSlice(p)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfFloat32) Union(others ...SetOfFloat32) SetOfFloat32 {
|
||||
return SetOfFloat32{s.s.Union(s.fromStructSlice(others)...)}
|
||||
return SetOfFloat32{s.s.Union(s.fromStructSlice(others)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfFloat32) Subtract(others ...SetOfFloat32) SetOfFloat32 {
|
||||
return SetOfFloat32{s.s.Subtract(s.fromStructSlice(others)...)}
|
||||
return SetOfFloat32{s.s.Subtract(s.fromStructSlice(others)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfFloat32) Any() float32 {
|
||||
|
||||
@@ -41,7 +41,7 @@ func TestRefFromValAndNomsValue(t *testing.T) {
|
||||
r2 := NewRefOfListOfString(l.Ref())
|
||||
assert.True(r.Equals(r2))
|
||||
|
||||
rv2 := r.NomsValue()
|
||||
rv2 := types.Ref{R: r.InternalImplementation()}
|
||||
assert.True(rv.Equals(rv2))
|
||||
}
|
||||
|
||||
@@ -79,10 +79,10 @@ func TestStructWithRef(t *testing.T) {
|
||||
|
||||
assert.Panics(func() { r2.GetValue(cs) })
|
||||
|
||||
types.WriteValue(str.NomsValue(), cs)
|
||||
types.WriteValue(str, cs)
|
||||
assert.Panics(func() { r2.GetValue(cs) })
|
||||
|
||||
types.WriteValue(set.NomsValue(), cs)
|
||||
types.WriteValue(set, cs)
|
||||
set2 := r2.GetValue(cs)
|
||||
assert.True(set.Equals(set2))
|
||||
}
|
||||
|
||||
+22
-12
@@ -10,11 +10,12 @@ import (
|
||||
// SetOfBool
|
||||
|
||||
type SetOfBool struct {
|
||||
s types.Set
|
||||
s types.Set
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewSetOfBool() SetOfBool {
|
||||
return SetOfBool{types.NewSet()}
|
||||
return SetOfBool{types.NewSet(), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type SetOfBoolDef map[bool]bool
|
||||
@@ -26,7 +27,7 @@ func (def SetOfBoolDef) New() SetOfBool {
|
||||
l[i] = types.Bool(d)
|
||||
i++
|
||||
}
|
||||
return SetOfBool{types.NewSet(l...)}
|
||||
return SetOfBool{types.NewSet(l...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfBool) Def() SetOfBoolDef {
|
||||
@@ -38,23 +39,32 @@ func (s SetOfBool) Def() SetOfBoolDef {
|
||||
return def
|
||||
}
|
||||
|
||||
func SetOfBoolFromVal(p types.Value) SetOfBool {
|
||||
return SetOfBool{p.(types.Set)}
|
||||
func SetOfBoolFromVal(val types.Value) SetOfBool {
|
||||
// TODO: Do we still need FromVal?
|
||||
if val, ok := val.(SetOfBool); ok {
|
||||
return val
|
||||
}
|
||||
return SetOfBool{val.(types.Set), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfBool) NomsValue() types.Value {
|
||||
// TODO: Remove this
|
||||
return s
|
||||
}
|
||||
|
||||
func (s SetOfBool) InternalImplementation() types.Set {
|
||||
return s.s
|
||||
}
|
||||
|
||||
func (s SetOfBool) Equals(other types.Value) bool {
|
||||
if other, ok := other.(SetOfBool); ok {
|
||||
return s.s.Equals(other.s)
|
||||
return s.Ref() == other.Ref()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (s SetOfBool) Ref() ref.Ref {
|
||||
return s.s.Ref()
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s SetOfBool) Chunks() (futures []types.Future) {
|
||||
@@ -72,7 +82,7 @@ func (m SetOfBool) TypeRef() types.TypeRef {
|
||||
|
||||
func init() {
|
||||
__typeRefForSetOfBool = types.MakeCompoundTypeRef("", types.SetKind, types.MakePrimitiveTypeRef(types.BoolKind))
|
||||
types.RegisterFromValFunction(__typeRefForSetOfBool, func(v types.Value) types.NomsValue {
|
||||
types.RegisterFromValFunction(__typeRefForSetOfBool, func(v types.Value) types.Value {
|
||||
return SetOfBoolFromVal(v)
|
||||
})
|
||||
}
|
||||
@@ -118,19 +128,19 @@ func (s SetOfBool) Filter(cb SetOfBoolFilterCallback) SetOfBool {
|
||||
}
|
||||
|
||||
func (s SetOfBool) Insert(p ...bool) SetOfBool {
|
||||
return SetOfBool{s.s.Insert(s.fromElemSlice(p)...)}
|
||||
return SetOfBool{s.s.Insert(s.fromElemSlice(p)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfBool) Remove(p ...bool) SetOfBool {
|
||||
return SetOfBool{s.s.Remove(s.fromElemSlice(p)...)}
|
||||
return SetOfBool{s.s.Remove(s.fromElemSlice(p)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfBool) Union(others ...SetOfBool) SetOfBool {
|
||||
return SetOfBool{s.s.Union(s.fromStructSlice(others)...)}
|
||||
return SetOfBool{s.s.Union(s.fromStructSlice(others)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfBool) Subtract(others ...SetOfBool) SetOfBool {
|
||||
return SetOfBool{s.s.Subtract(s.fromStructSlice(others)...)}
|
||||
return SetOfBool{s.s.Subtract(s.fromStructSlice(others)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfBool) Any() bool {
|
||||
|
||||
@@ -28,7 +28,8 @@ func __testPackageInFile_struct_Ref() ref.Ref {
|
||||
// Struct
|
||||
|
||||
type Struct struct {
|
||||
m types.Map
|
||||
m types.Map
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewStruct() Struct {
|
||||
@@ -36,7 +37,7 @@ func NewStruct() Struct {
|
||||
types.NewString("$type"), types.MakeTypeRef(__testPackageInFile_struct_CachedRef, 0),
|
||||
types.NewString("s"), types.NewString(""),
|
||||
types.NewString("b"), types.Bool(false),
|
||||
)}
|
||||
), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type StructDef struct {
|
||||
@@ -50,7 +51,7 @@ func (def StructDef) New() Struct {
|
||||
types.NewString("$type"), types.MakeTypeRef(__testPackageInFile_struct_CachedRef, 0),
|
||||
types.NewString("s"), types.NewString(def.S),
|
||||
types.NewString("b"), types.Bool(def.B),
|
||||
)}
|
||||
), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s Struct) Def() (d StructDef) {
|
||||
@@ -66,29 +67,38 @@ func (m Struct) TypeRef() types.TypeRef {
|
||||
}
|
||||
|
||||
func init() {
|
||||
types.RegisterFromValFunction(__typeRefForStruct, func(v types.Value) types.NomsValue {
|
||||
types.RegisterFromValFunction(__typeRefForStruct, func(v types.Value) types.Value {
|
||||
return StructFromVal(v)
|
||||
})
|
||||
}
|
||||
|
||||
func StructFromVal(val types.Value) Struct {
|
||||
// TODO: Do we still need FromVal?
|
||||
if val, ok := val.(Struct); ok {
|
||||
return val
|
||||
}
|
||||
// TODO: Validate here
|
||||
return Struct{val.(types.Map)}
|
||||
return Struct{val.(types.Map), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s Struct) NomsValue() types.Value {
|
||||
// TODO: Remove this
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Struct) InternalImplementation() types.Map {
|
||||
return s.m
|
||||
}
|
||||
|
||||
func (s Struct) Equals(other types.Value) bool {
|
||||
if other, ok := other.(Struct); ok {
|
||||
return s.m.Equals(other.m)
|
||||
return s.Ref() == other.Ref()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (s Struct) Ref() ref.Ref {
|
||||
return s.m.Ref()
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s Struct) Chunks() (futures []types.Future) {
|
||||
@@ -102,7 +112,7 @@ func (s Struct) S() string {
|
||||
}
|
||||
|
||||
func (s Struct) SetS(val string) Struct {
|
||||
return Struct{s.m.Set(types.NewString("s"), types.NewString(val))}
|
||||
return Struct{s.m.Set(types.NewString("s"), types.NewString(val)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s Struct) B() bool {
|
||||
@@ -110,17 +120,18 @@ func (s Struct) B() bool {
|
||||
}
|
||||
|
||||
func (s Struct) SetB(val bool) Struct {
|
||||
return Struct{s.m.Set(types.NewString("b"), types.Bool(val))}
|
||||
return Struct{s.m.Set(types.NewString("b"), types.Bool(val)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
// ListOfStruct
|
||||
|
||||
type ListOfStruct struct {
|
||||
l types.List
|
||||
l types.List
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewListOfStruct() ListOfStruct {
|
||||
return ListOfStruct{types.NewList()}
|
||||
return ListOfStruct{types.NewList(), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type ListOfStructDef []StructDef
|
||||
@@ -128,37 +139,46 @@ type ListOfStructDef []StructDef
|
||||
func (def ListOfStructDef) New() ListOfStruct {
|
||||
l := make([]types.Value, len(def))
|
||||
for i, d := range def {
|
||||
l[i] = d.New().NomsValue()
|
||||
l[i] = d.New()
|
||||
}
|
||||
return ListOfStruct{types.NewList(l...)}
|
||||
return ListOfStruct{types.NewList(l...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfStruct) Def() ListOfStructDef {
|
||||
d := make([]StructDef, l.Len())
|
||||
for i := uint64(0); i < l.Len(); i++ {
|
||||
d[i] = StructFromVal(l.l.Get(i)).Def()
|
||||
d[i] = l.l.Get(i).(Struct).Def()
|
||||
}
|
||||
return d
|
||||
}
|
||||
|
||||
func ListOfStructFromVal(val types.Value) ListOfStruct {
|
||||
// TODO: Do we still need FromVal?
|
||||
if val, ok := val.(ListOfStruct); ok {
|
||||
return val
|
||||
}
|
||||
// TODO: Validate here
|
||||
return ListOfStruct{val.(types.List)}
|
||||
return ListOfStruct{val.(types.List), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfStruct) NomsValue() types.Value {
|
||||
// TODO: Remove this
|
||||
return l
|
||||
}
|
||||
|
||||
func (l ListOfStruct) InternalImplementation() types.List {
|
||||
return l.l
|
||||
}
|
||||
|
||||
func (l ListOfStruct) Equals(other types.Value) bool {
|
||||
if other, ok := other.(ListOfStruct); ok {
|
||||
return l.l.Equals(other.l)
|
||||
return l.Ref() == other.Ref()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (l ListOfStruct) Ref() ref.Ref {
|
||||
return l.l.Ref()
|
||||
return types.EnsureRef(l.ref, l)
|
||||
}
|
||||
|
||||
func (l ListOfStruct) Chunks() (futures []types.Future) {
|
||||
@@ -176,7 +196,7 @@ func (m ListOfStruct) TypeRef() types.TypeRef {
|
||||
|
||||
func init() {
|
||||
__typeRefForListOfStruct = types.MakeCompoundTypeRef("", types.ListKind, types.MakeTypeRef(__testPackageInFile_struct_CachedRef, 0))
|
||||
types.RegisterFromValFunction(__typeRefForListOfStruct, func(v types.Value) types.NomsValue {
|
||||
types.RegisterFromValFunction(__typeRefForListOfStruct, func(v types.Value) types.Value {
|
||||
return ListOfStructFromVal(v)
|
||||
})
|
||||
}
|
||||
@@ -190,37 +210,37 @@ func (l ListOfStruct) Empty() bool {
|
||||
}
|
||||
|
||||
func (l ListOfStruct) Get(i uint64) Struct {
|
||||
return StructFromVal(l.l.Get(i))
|
||||
return l.l.Get(i).(Struct)
|
||||
}
|
||||
|
||||
func (l ListOfStruct) Slice(idx uint64, end uint64) ListOfStruct {
|
||||
return ListOfStruct{l.l.Slice(idx, end)}
|
||||
return ListOfStruct{l.l.Slice(idx, end), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfStruct) Set(i uint64, val Struct) ListOfStruct {
|
||||
return ListOfStruct{l.l.Set(i, val.NomsValue())}
|
||||
return ListOfStruct{l.l.Set(i, val), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfStruct) Append(v ...Struct) ListOfStruct {
|
||||
return ListOfStruct{l.l.Append(l.fromElemSlice(v)...)}
|
||||
return ListOfStruct{l.l.Append(l.fromElemSlice(v)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfStruct) Insert(idx uint64, v ...Struct) ListOfStruct {
|
||||
return ListOfStruct{l.l.Insert(idx, l.fromElemSlice(v)...)}
|
||||
return ListOfStruct{l.l.Insert(idx, l.fromElemSlice(v)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfStruct) Remove(idx uint64, end uint64) ListOfStruct {
|
||||
return ListOfStruct{l.l.Remove(idx, end)}
|
||||
return ListOfStruct{l.l.Remove(idx, end), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfStruct) RemoveAt(idx uint64) ListOfStruct {
|
||||
return ListOfStruct{(l.l.RemoveAt(idx))}
|
||||
return ListOfStruct{(l.l.RemoveAt(idx)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfStruct) fromElemSlice(p []Struct) []types.Value {
|
||||
r := make([]types.Value, len(p))
|
||||
for i, v := range p {
|
||||
r[i] = v.NomsValue()
|
||||
r[i] = v
|
||||
}
|
||||
return r
|
||||
}
|
||||
@@ -229,7 +249,7 @@ type ListOfStructIterCallback func(v Struct, i uint64) (stop bool)
|
||||
|
||||
func (l ListOfStruct) Iter(cb ListOfStructIterCallback) {
|
||||
l.l.Iter(func(v types.Value, i uint64) bool {
|
||||
return cb(StructFromVal(v), i)
|
||||
return cb(v.(Struct), i)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -237,7 +257,7 @@ type ListOfStructIterAllCallback func(v Struct, i uint64)
|
||||
|
||||
func (l ListOfStruct) IterAll(cb ListOfStructIterAllCallback) {
|
||||
l.l.IterAll(func(v types.Value, i uint64) {
|
||||
cb(StructFromVal(v), i)
|
||||
cb(v.(Struct), i)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -28,13 +28,14 @@ func __testPackageInFile_struct_optional_Ref() ref.Ref {
|
||||
// OptionalStruct
|
||||
|
||||
type OptionalStruct struct {
|
||||
m types.Map
|
||||
m types.Map
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewOptionalStruct() OptionalStruct {
|
||||
return OptionalStruct{types.NewMap(
|
||||
types.NewString("$type"), types.MakeTypeRef(__testPackageInFile_struct_optional_CachedRef, 0),
|
||||
)}
|
||||
), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type OptionalStructDef struct {
|
||||
@@ -48,7 +49,7 @@ func (def OptionalStructDef) New() OptionalStruct {
|
||||
types.NewString("$type"), types.MakeTypeRef(__testPackageInFile_struct_optional_CachedRef, 0),
|
||||
types.NewString("s"), types.NewString(def.S),
|
||||
types.NewString("b"), types.Bool(def.B),
|
||||
)}
|
||||
), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s OptionalStruct) Def() (d OptionalStructDef) {
|
||||
@@ -68,29 +69,38 @@ func (m OptionalStruct) TypeRef() types.TypeRef {
|
||||
}
|
||||
|
||||
func init() {
|
||||
types.RegisterFromValFunction(__typeRefForOptionalStruct, func(v types.Value) types.NomsValue {
|
||||
types.RegisterFromValFunction(__typeRefForOptionalStruct, func(v types.Value) types.Value {
|
||||
return OptionalStructFromVal(v)
|
||||
})
|
||||
}
|
||||
|
||||
func OptionalStructFromVal(val types.Value) OptionalStruct {
|
||||
// TODO: Do we still need FromVal?
|
||||
if val, ok := val.(OptionalStruct); ok {
|
||||
return val
|
||||
}
|
||||
// TODO: Validate here
|
||||
return OptionalStruct{val.(types.Map)}
|
||||
return OptionalStruct{val.(types.Map), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s OptionalStruct) NomsValue() types.Value {
|
||||
// TODO: Remove this
|
||||
return s
|
||||
}
|
||||
|
||||
func (s OptionalStruct) InternalImplementation() types.Map {
|
||||
return s.m
|
||||
}
|
||||
|
||||
func (s OptionalStruct) Equals(other types.Value) bool {
|
||||
if other, ok := other.(OptionalStruct); ok {
|
||||
return s.m.Equals(other.m)
|
||||
return s.Ref() == other.Ref()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (s OptionalStruct) Ref() ref.Ref {
|
||||
return s.m.Ref()
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s OptionalStruct) Chunks() (futures []types.Future) {
|
||||
@@ -108,7 +118,7 @@ func (s OptionalStruct) S() (v string, ok bool) {
|
||||
}
|
||||
|
||||
func (s OptionalStruct) SetS(val string) OptionalStruct {
|
||||
return OptionalStruct{s.m.Set(types.NewString("s"), types.NewString(val))}
|
||||
return OptionalStruct{s.m.Set(types.NewString("s"), types.NewString(val)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s OptionalStruct) B() (v bool, ok bool) {
|
||||
@@ -120,5 +130,5 @@ func (s OptionalStruct) B() (v bool, ok bool) {
|
||||
}
|
||||
|
||||
func (s OptionalStruct) SetB(val bool) OptionalStruct {
|
||||
return OptionalStruct{s.m.Set(types.NewString("b"), types.Bool(val))}
|
||||
return OptionalStruct{s.m.Set(types.NewString("b"), types.Bool(val)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,8 @@ func __testPackageInFile_struct_primitives_Ref() ref.Ref {
|
||||
// StructPrimitives
|
||||
|
||||
type StructPrimitives struct {
|
||||
m types.Map
|
||||
m types.Map
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewStructPrimitives() StructPrimitives {
|
||||
@@ -60,7 +61,7 @@ func NewStructPrimitives() StructPrimitives {
|
||||
types.NewString("string"), types.NewString(""),
|
||||
types.NewString("blob"), types.NewEmptyBlob(),
|
||||
types.NewString("value"), types.Bool(false),
|
||||
)}
|
||||
), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type StructPrimitivesDef struct {
|
||||
@@ -98,7 +99,7 @@ func (def StructPrimitivesDef) New() StructPrimitives {
|
||||
types.NewString("string"), types.NewString(def.String),
|
||||
types.NewString("blob"), def.Blob,
|
||||
types.NewString("value"), def.Value,
|
||||
)}
|
||||
), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s StructPrimitives) Def() (d StructPrimitivesDef) {
|
||||
@@ -126,29 +127,38 @@ func (m StructPrimitives) TypeRef() types.TypeRef {
|
||||
}
|
||||
|
||||
func init() {
|
||||
types.RegisterFromValFunction(__typeRefForStructPrimitives, func(v types.Value) types.NomsValue {
|
||||
types.RegisterFromValFunction(__typeRefForStructPrimitives, func(v types.Value) types.Value {
|
||||
return StructPrimitivesFromVal(v)
|
||||
})
|
||||
}
|
||||
|
||||
func StructPrimitivesFromVal(val types.Value) StructPrimitives {
|
||||
// TODO: Do we still need FromVal?
|
||||
if val, ok := val.(StructPrimitives); ok {
|
||||
return val
|
||||
}
|
||||
// TODO: Validate here
|
||||
return StructPrimitives{val.(types.Map)}
|
||||
return StructPrimitives{val.(types.Map), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s StructPrimitives) NomsValue() types.Value {
|
||||
// TODO: Remove this
|
||||
return s
|
||||
}
|
||||
|
||||
func (s StructPrimitives) InternalImplementation() types.Map {
|
||||
return s.m
|
||||
}
|
||||
|
||||
func (s StructPrimitives) Equals(other types.Value) bool {
|
||||
if other, ok := other.(StructPrimitives); ok {
|
||||
return s.m.Equals(other.m)
|
||||
return s.Ref() == other.Ref()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (s StructPrimitives) Ref() ref.Ref {
|
||||
return s.m.Ref()
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s StructPrimitives) Chunks() (futures []types.Future) {
|
||||
@@ -162,7 +172,7 @@ func (s StructPrimitives) Uint64() uint64 {
|
||||
}
|
||||
|
||||
func (s StructPrimitives) SetUint64(val uint64) StructPrimitives {
|
||||
return StructPrimitives{s.m.Set(types.NewString("uint64"), types.UInt64(val))}
|
||||
return StructPrimitives{s.m.Set(types.NewString("uint64"), types.UInt64(val)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s StructPrimitives) Uint32() uint32 {
|
||||
@@ -170,7 +180,7 @@ func (s StructPrimitives) Uint32() uint32 {
|
||||
}
|
||||
|
||||
func (s StructPrimitives) SetUint32(val uint32) StructPrimitives {
|
||||
return StructPrimitives{s.m.Set(types.NewString("uint32"), types.UInt32(val))}
|
||||
return StructPrimitives{s.m.Set(types.NewString("uint32"), types.UInt32(val)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s StructPrimitives) Uint16() uint16 {
|
||||
@@ -178,7 +188,7 @@ func (s StructPrimitives) Uint16() uint16 {
|
||||
}
|
||||
|
||||
func (s StructPrimitives) SetUint16(val uint16) StructPrimitives {
|
||||
return StructPrimitives{s.m.Set(types.NewString("uint16"), types.UInt16(val))}
|
||||
return StructPrimitives{s.m.Set(types.NewString("uint16"), types.UInt16(val)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s StructPrimitives) Uint8() uint8 {
|
||||
@@ -186,7 +196,7 @@ func (s StructPrimitives) Uint8() uint8 {
|
||||
}
|
||||
|
||||
func (s StructPrimitives) SetUint8(val uint8) StructPrimitives {
|
||||
return StructPrimitives{s.m.Set(types.NewString("uint8"), types.UInt8(val))}
|
||||
return StructPrimitives{s.m.Set(types.NewString("uint8"), types.UInt8(val)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s StructPrimitives) Int64() int64 {
|
||||
@@ -194,7 +204,7 @@ func (s StructPrimitives) Int64() int64 {
|
||||
}
|
||||
|
||||
func (s StructPrimitives) SetInt64(val int64) StructPrimitives {
|
||||
return StructPrimitives{s.m.Set(types.NewString("int64"), types.Int64(val))}
|
||||
return StructPrimitives{s.m.Set(types.NewString("int64"), types.Int64(val)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s StructPrimitives) Int32() int32 {
|
||||
@@ -202,7 +212,7 @@ func (s StructPrimitives) Int32() int32 {
|
||||
}
|
||||
|
||||
func (s StructPrimitives) SetInt32(val int32) StructPrimitives {
|
||||
return StructPrimitives{s.m.Set(types.NewString("int32"), types.Int32(val))}
|
||||
return StructPrimitives{s.m.Set(types.NewString("int32"), types.Int32(val)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s StructPrimitives) Int16() int16 {
|
||||
@@ -210,7 +220,7 @@ func (s StructPrimitives) Int16() int16 {
|
||||
}
|
||||
|
||||
func (s StructPrimitives) SetInt16(val int16) StructPrimitives {
|
||||
return StructPrimitives{s.m.Set(types.NewString("int16"), types.Int16(val))}
|
||||
return StructPrimitives{s.m.Set(types.NewString("int16"), types.Int16(val)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s StructPrimitives) Int8() int8 {
|
||||
@@ -218,7 +228,7 @@ func (s StructPrimitives) Int8() int8 {
|
||||
}
|
||||
|
||||
func (s StructPrimitives) SetInt8(val int8) StructPrimitives {
|
||||
return StructPrimitives{s.m.Set(types.NewString("int8"), types.Int8(val))}
|
||||
return StructPrimitives{s.m.Set(types.NewString("int8"), types.Int8(val)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s StructPrimitives) Float64() float64 {
|
||||
@@ -226,7 +236,7 @@ func (s StructPrimitives) Float64() float64 {
|
||||
}
|
||||
|
||||
func (s StructPrimitives) SetFloat64(val float64) StructPrimitives {
|
||||
return StructPrimitives{s.m.Set(types.NewString("float64"), types.Float64(val))}
|
||||
return StructPrimitives{s.m.Set(types.NewString("float64"), types.Float64(val)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s StructPrimitives) Float32() float32 {
|
||||
@@ -234,7 +244,7 @@ func (s StructPrimitives) Float32() float32 {
|
||||
}
|
||||
|
||||
func (s StructPrimitives) SetFloat32(val float32) StructPrimitives {
|
||||
return StructPrimitives{s.m.Set(types.NewString("float32"), types.Float32(val))}
|
||||
return StructPrimitives{s.m.Set(types.NewString("float32"), types.Float32(val)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s StructPrimitives) Bool() bool {
|
||||
@@ -242,7 +252,7 @@ func (s StructPrimitives) Bool() bool {
|
||||
}
|
||||
|
||||
func (s StructPrimitives) SetBool(val bool) StructPrimitives {
|
||||
return StructPrimitives{s.m.Set(types.NewString("bool"), types.Bool(val))}
|
||||
return StructPrimitives{s.m.Set(types.NewString("bool"), types.Bool(val)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s StructPrimitives) String() string {
|
||||
@@ -250,7 +260,7 @@ func (s StructPrimitives) String() string {
|
||||
}
|
||||
|
||||
func (s StructPrimitives) SetString(val string) StructPrimitives {
|
||||
return StructPrimitives{s.m.Set(types.NewString("string"), types.NewString(val))}
|
||||
return StructPrimitives{s.m.Set(types.NewString("string"), types.NewString(val)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s StructPrimitives) Blob() types.Blob {
|
||||
@@ -258,7 +268,7 @@ func (s StructPrimitives) Blob() types.Blob {
|
||||
}
|
||||
|
||||
func (s StructPrimitives) SetBlob(val types.Blob) StructPrimitives {
|
||||
return StructPrimitives{s.m.Set(types.NewString("blob"), val)}
|
||||
return StructPrimitives{s.m.Set(types.NewString("blob"), val), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s StructPrimitives) Value() types.Value {
|
||||
@@ -266,5 +276,5 @@ func (s StructPrimitives) Value() types.Value {
|
||||
}
|
||||
|
||||
func (s StructPrimitives) SetValue(val types.Value) StructPrimitives {
|
||||
return StructPrimitives{s.m.Set(types.NewString("value"), val)}
|
||||
return StructPrimitives{s.m.Set(types.NewString("value"), val), &ref.Ref{}}
|
||||
}
|
||||
|
||||
@@ -121,5 +121,6 @@ func TestStructBackingMapKeyNames(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
s := NewStructPrimitives().SetBool(true)
|
||||
assert.True(bool(s.NomsValue().(types.Map).Get(types.NewString("bool")).(types.Bool)))
|
||||
|
||||
assert.True(bool(s.InternalImplementation().Get(types.NewString("bool")).(types.Bool)))
|
||||
}
|
||||
|
||||
@@ -27,14 +27,15 @@ func __testPackageInFile_struct_recursive_Ref() ref.Ref {
|
||||
// Tree
|
||||
|
||||
type Tree struct {
|
||||
m types.Map
|
||||
m types.Map
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewTree() Tree {
|
||||
return Tree{types.NewMap(
|
||||
types.NewString("$type"), types.MakeTypeRef(__testPackageInFile_struct_recursive_CachedRef, 0),
|
||||
types.NewString("children"), types.NewList(),
|
||||
)}
|
||||
types.NewString("children"), NewListOfTree(),
|
||||
), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type TreeDef struct {
|
||||
@@ -45,12 +46,12 @@ func (def TreeDef) New() Tree {
|
||||
return Tree{
|
||||
types.NewMap(
|
||||
types.NewString("$type"), types.MakeTypeRef(__testPackageInFile_struct_recursive_CachedRef, 0),
|
||||
types.NewString("children"), def.Children.New().NomsValue(),
|
||||
)}
|
||||
types.NewString("children"), def.Children.New(),
|
||||
), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s Tree) Def() (d TreeDef) {
|
||||
d.Children = ListOfTreeFromVal(s.m.Get(types.NewString("children"))).Def()
|
||||
d.Children = s.m.Get(types.NewString("children")).(ListOfTree).Def()
|
||||
return
|
||||
}
|
||||
|
||||
@@ -61,29 +62,38 @@ func (m Tree) TypeRef() types.TypeRef {
|
||||
}
|
||||
|
||||
func init() {
|
||||
types.RegisterFromValFunction(__typeRefForTree, func(v types.Value) types.NomsValue {
|
||||
types.RegisterFromValFunction(__typeRefForTree, func(v types.Value) types.Value {
|
||||
return TreeFromVal(v)
|
||||
})
|
||||
}
|
||||
|
||||
func TreeFromVal(val types.Value) Tree {
|
||||
// TODO: Do we still need FromVal?
|
||||
if val, ok := val.(Tree); ok {
|
||||
return val
|
||||
}
|
||||
// TODO: Validate here
|
||||
return Tree{val.(types.Map)}
|
||||
return Tree{val.(types.Map), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s Tree) NomsValue() types.Value {
|
||||
// TODO: Remove this
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Tree) InternalImplementation() types.Map {
|
||||
return s.m
|
||||
}
|
||||
|
||||
func (s Tree) Equals(other types.Value) bool {
|
||||
if other, ok := other.(Tree); ok {
|
||||
return s.m.Equals(other.m)
|
||||
return s.Ref() == other.Ref()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (s Tree) Ref() ref.Ref {
|
||||
return s.m.Ref()
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s Tree) Chunks() (futures []types.Future) {
|
||||
@@ -93,21 +103,22 @@ func (s Tree) Chunks() (futures []types.Future) {
|
||||
}
|
||||
|
||||
func (s Tree) Children() ListOfTree {
|
||||
return ListOfTreeFromVal(s.m.Get(types.NewString("children")))
|
||||
return s.m.Get(types.NewString("children")).(ListOfTree)
|
||||
}
|
||||
|
||||
func (s Tree) SetChildren(val ListOfTree) Tree {
|
||||
return Tree{s.m.Set(types.NewString("children"), val.NomsValue())}
|
||||
return Tree{s.m.Set(types.NewString("children"), val), &ref.Ref{}}
|
||||
}
|
||||
|
||||
// ListOfTree
|
||||
|
||||
type ListOfTree struct {
|
||||
l types.List
|
||||
l types.List
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewListOfTree() ListOfTree {
|
||||
return ListOfTree{types.NewList()}
|
||||
return ListOfTree{types.NewList(), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type ListOfTreeDef []TreeDef
|
||||
@@ -115,37 +126,46 @@ type ListOfTreeDef []TreeDef
|
||||
func (def ListOfTreeDef) New() ListOfTree {
|
||||
l := make([]types.Value, len(def))
|
||||
for i, d := range def {
|
||||
l[i] = d.New().NomsValue()
|
||||
l[i] = d.New()
|
||||
}
|
||||
return ListOfTree{types.NewList(l...)}
|
||||
return ListOfTree{types.NewList(l...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfTree) Def() ListOfTreeDef {
|
||||
d := make([]TreeDef, l.Len())
|
||||
for i := uint64(0); i < l.Len(); i++ {
|
||||
d[i] = TreeFromVal(l.l.Get(i)).Def()
|
||||
d[i] = l.l.Get(i).(Tree).Def()
|
||||
}
|
||||
return d
|
||||
}
|
||||
|
||||
func ListOfTreeFromVal(val types.Value) ListOfTree {
|
||||
// TODO: Do we still need FromVal?
|
||||
if val, ok := val.(ListOfTree); ok {
|
||||
return val
|
||||
}
|
||||
// TODO: Validate here
|
||||
return ListOfTree{val.(types.List)}
|
||||
return ListOfTree{val.(types.List), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfTree) NomsValue() types.Value {
|
||||
// TODO: Remove this
|
||||
return l
|
||||
}
|
||||
|
||||
func (l ListOfTree) InternalImplementation() types.List {
|
||||
return l.l
|
||||
}
|
||||
|
||||
func (l ListOfTree) Equals(other types.Value) bool {
|
||||
if other, ok := other.(ListOfTree); ok {
|
||||
return l.l.Equals(other.l)
|
||||
return l.Ref() == other.Ref()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (l ListOfTree) Ref() ref.Ref {
|
||||
return l.l.Ref()
|
||||
return types.EnsureRef(l.ref, l)
|
||||
}
|
||||
|
||||
func (l ListOfTree) Chunks() (futures []types.Future) {
|
||||
@@ -163,7 +183,7 @@ func (m ListOfTree) TypeRef() types.TypeRef {
|
||||
|
||||
func init() {
|
||||
__typeRefForListOfTree = types.MakeCompoundTypeRef("", types.ListKind, types.MakeTypeRef(__testPackageInFile_struct_recursive_CachedRef, 0))
|
||||
types.RegisterFromValFunction(__typeRefForListOfTree, func(v types.Value) types.NomsValue {
|
||||
types.RegisterFromValFunction(__typeRefForListOfTree, func(v types.Value) types.Value {
|
||||
return ListOfTreeFromVal(v)
|
||||
})
|
||||
}
|
||||
@@ -177,37 +197,37 @@ func (l ListOfTree) Empty() bool {
|
||||
}
|
||||
|
||||
func (l ListOfTree) Get(i uint64) Tree {
|
||||
return TreeFromVal(l.l.Get(i))
|
||||
return l.l.Get(i).(Tree)
|
||||
}
|
||||
|
||||
func (l ListOfTree) Slice(idx uint64, end uint64) ListOfTree {
|
||||
return ListOfTree{l.l.Slice(idx, end)}
|
||||
return ListOfTree{l.l.Slice(idx, end), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfTree) Set(i uint64, val Tree) ListOfTree {
|
||||
return ListOfTree{l.l.Set(i, val.NomsValue())}
|
||||
return ListOfTree{l.l.Set(i, val), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfTree) Append(v ...Tree) ListOfTree {
|
||||
return ListOfTree{l.l.Append(l.fromElemSlice(v)...)}
|
||||
return ListOfTree{l.l.Append(l.fromElemSlice(v)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfTree) Insert(idx uint64, v ...Tree) ListOfTree {
|
||||
return ListOfTree{l.l.Insert(idx, l.fromElemSlice(v)...)}
|
||||
return ListOfTree{l.l.Insert(idx, l.fromElemSlice(v)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfTree) Remove(idx uint64, end uint64) ListOfTree {
|
||||
return ListOfTree{l.l.Remove(idx, end)}
|
||||
return ListOfTree{l.l.Remove(idx, end), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfTree) RemoveAt(idx uint64) ListOfTree {
|
||||
return ListOfTree{(l.l.RemoveAt(idx))}
|
||||
return ListOfTree{(l.l.RemoveAt(idx)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfTree) fromElemSlice(p []Tree) []types.Value {
|
||||
r := make([]types.Value, len(p))
|
||||
for i, v := range p {
|
||||
r[i] = v.NomsValue()
|
||||
r[i] = v
|
||||
}
|
||||
return r
|
||||
}
|
||||
@@ -216,7 +236,7 @@ type ListOfTreeIterCallback func(v Tree, i uint64) (stop bool)
|
||||
|
||||
func (l ListOfTree) Iter(cb ListOfTreeIterCallback) {
|
||||
l.l.Iter(func(v types.Value, i uint64) bool {
|
||||
return cb(TreeFromVal(v), i)
|
||||
return cb(v.(Tree), i)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -224,7 +244,7 @@ type ListOfTreeIterAllCallback func(v Tree, i uint64)
|
||||
|
||||
func (l ListOfTree) IterAll(cb ListOfTreeIterAllCallback) {
|
||||
l.l.IterAll(func(v types.Value, i uint64) {
|
||||
cb(TreeFromVal(v), i)
|
||||
cb(v.(Tree), i)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
package test
|
||||
|
||||
import (
|
||||
"github.com/attic-labs/noms/nomdl/codegen/test/gen/sha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c"
|
||||
"github.com/attic-labs/noms/nomdl/codegen/test/gen/sha1_d31b592f480b7659b03b72a7d1271f31dde57b2d"
|
||||
|
||||
"github.com/attic-labs/noms/ref"
|
||||
"github.com/attic-labs/noms/types"
|
||||
)
|
||||
@@ -18,13 +19,13 @@ func __testPackageInFile_struct_with_imports_Ref() ref.Ref {
|
||||
types.MakeEnumTypeRef("E", "E1", "Ignored"),
|
||||
types.MakeStructTypeRef("ImportUser",
|
||||
[]types.Field{
|
||||
types.Field{"importedStruct", types.MakeTypeRef(ref.Parse("sha1-fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c"), 0), false},
|
||||
types.Field{"importedStruct", types.MakeTypeRef(ref.Parse("sha1-d31b592f480b7659b03b72a7d1271f31dde57b2d"), 0), false},
|
||||
types.Field{"enum", types.MakeTypeRef(ref.Ref{}, 0), false},
|
||||
},
|
||||
types.Choices{},
|
||||
),
|
||||
}, []ref.Ref{
|
||||
ref.Parse("sha1-fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c"),
|
||||
ref.Parse("sha1-d31b592f480b7659b03b72a7d1271f31dde57b2d"),
|
||||
})
|
||||
return types.RegisterPackage(&p)
|
||||
}
|
||||
@@ -41,19 +42,20 @@ const (
|
||||
// ImportUser
|
||||
|
||||
type ImportUser struct {
|
||||
m types.Map
|
||||
m types.Map
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewImportUser() ImportUser {
|
||||
return ImportUser{types.NewMap(
|
||||
types.NewString("$type"), types.MakeTypeRef(__testPackageInFile_struct_with_imports_CachedRef, 1),
|
||||
types.NewString("importedStruct"), sha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c.NewD().NomsValue(),
|
||||
types.NewString("importedStruct"), sha1_d31b592f480b7659b03b72a7d1271f31dde57b2d.NewD(),
|
||||
types.NewString("enum"), types.UInt32(0),
|
||||
)}
|
||||
), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type ImportUserDef struct {
|
||||
ImportedStruct sha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c.DDef
|
||||
ImportedStruct sha1_d31b592f480b7659b03b72a7d1271f31dde57b2d.DDef
|
||||
Enum E
|
||||
}
|
||||
|
||||
@@ -61,13 +63,13 @@ func (def ImportUserDef) New() ImportUser {
|
||||
return ImportUser{
|
||||
types.NewMap(
|
||||
types.NewString("$type"), types.MakeTypeRef(__testPackageInFile_struct_with_imports_CachedRef, 1),
|
||||
types.NewString("importedStruct"), def.ImportedStruct.New().NomsValue(),
|
||||
types.NewString("importedStruct"), def.ImportedStruct.New(),
|
||||
types.NewString("enum"), types.UInt32(def.Enum),
|
||||
)}
|
||||
), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s ImportUser) Def() (d ImportUserDef) {
|
||||
d.ImportedStruct = sha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c.DFromVal(s.m.Get(types.NewString("importedStruct"))).Def()
|
||||
d.ImportedStruct = s.m.Get(types.NewString("importedStruct")).(sha1_d31b592f480b7659b03b72a7d1271f31dde57b2d.D).Def()
|
||||
d.Enum = E(s.m.Get(types.NewString("enum")).(types.UInt32))
|
||||
return
|
||||
}
|
||||
@@ -79,29 +81,38 @@ func (m ImportUser) TypeRef() types.TypeRef {
|
||||
}
|
||||
|
||||
func init() {
|
||||
types.RegisterFromValFunction(__typeRefForImportUser, func(v types.Value) types.NomsValue {
|
||||
types.RegisterFromValFunction(__typeRefForImportUser, func(v types.Value) types.Value {
|
||||
return ImportUserFromVal(v)
|
||||
})
|
||||
}
|
||||
|
||||
func ImportUserFromVal(val types.Value) ImportUser {
|
||||
// TODO: Do we still need FromVal?
|
||||
if val, ok := val.(ImportUser); ok {
|
||||
return val
|
||||
}
|
||||
// TODO: Validate here
|
||||
return ImportUser{val.(types.Map)}
|
||||
return ImportUser{val.(types.Map), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s ImportUser) NomsValue() types.Value {
|
||||
// TODO: Remove this
|
||||
return s
|
||||
}
|
||||
|
||||
func (s ImportUser) InternalImplementation() types.Map {
|
||||
return s.m
|
||||
}
|
||||
|
||||
func (s ImportUser) Equals(other types.Value) bool {
|
||||
if other, ok := other.(ImportUser); ok {
|
||||
return s.m.Equals(other.m)
|
||||
return s.Ref() == other.Ref()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (s ImportUser) Ref() ref.Ref {
|
||||
return s.m.Ref()
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s ImportUser) Chunks() (futures []types.Future) {
|
||||
@@ -110,12 +121,12 @@ func (s ImportUser) Chunks() (futures []types.Future) {
|
||||
return
|
||||
}
|
||||
|
||||
func (s ImportUser) ImportedStruct() sha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c.D {
|
||||
return sha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c.DFromVal(s.m.Get(types.NewString("importedStruct")))
|
||||
func (s ImportUser) ImportedStruct() sha1_d31b592f480b7659b03b72a7d1271f31dde57b2d.D {
|
||||
return s.m.Get(types.NewString("importedStruct")).(sha1_d31b592f480b7659b03b72a7d1271f31dde57b2d.D)
|
||||
}
|
||||
|
||||
func (s ImportUser) SetImportedStruct(val sha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c.D) ImportUser {
|
||||
return ImportUser{s.m.Set(types.NewString("importedStruct"), val.NomsValue())}
|
||||
func (s ImportUser) SetImportedStruct(val sha1_d31b592f480b7659b03b72a7d1271f31dde57b2d.D) ImportUser {
|
||||
return ImportUser{s.m.Set(types.NewString("importedStruct"), val), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s ImportUser) Enum() E {
|
||||
@@ -123,142 +134,152 @@ func (s ImportUser) Enum() E {
|
||||
}
|
||||
|
||||
func (s ImportUser) SetEnum(val E) ImportUser {
|
||||
return ImportUser{s.m.Set(types.NewString("enum"), types.UInt32(val))}
|
||||
return ImportUser{s.m.Set(types.NewString("enum"), types.UInt32(val)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
// ListOfsha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c_D
|
||||
// ListOfsha1_d31b592f480b7659b03b72a7d1271f31dde57b2d_D
|
||||
|
||||
type ListOfsha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c_D struct {
|
||||
l types.List
|
||||
type ListOfsha1_d31b592f480b7659b03b72a7d1271f31dde57b2d_D struct {
|
||||
l types.List
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewListOfsha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c_D() ListOfsha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c_D {
|
||||
return ListOfsha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c_D{types.NewList()}
|
||||
func NewListOfsha1_d31b592f480b7659b03b72a7d1271f31dde57b2d_D() ListOfsha1_d31b592f480b7659b03b72a7d1271f31dde57b2d_D {
|
||||
return ListOfsha1_d31b592f480b7659b03b72a7d1271f31dde57b2d_D{types.NewList(), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type ListOfsha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c_DDef []sha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c.DDef
|
||||
type ListOfsha1_d31b592f480b7659b03b72a7d1271f31dde57b2d_DDef []sha1_d31b592f480b7659b03b72a7d1271f31dde57b2d.DDef
|
||||
|
||||
func (def ListOfsha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c_DDef) New() ListOfsha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c_D {
|
||||
func (def ListOfsha1_d31b592f480b7659b03b72a7d1271f31dde57b2d_DDef) New() ListOfsha1_d31b592f480b7659b03b72a7d1271f31dde57b2d_D {
|
||||
l := make([]types.Value, len(def))
|
||||
for i, d := range def {
|
||||
l[i] = d.New().NomsValue()
|
||||
l[i] = d.New()
|
||||
}
|
||||
return ListOfsha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c_D{types.NewList(l...)}
|
||||
return ListOfsha1_d31b592f480b7659b03b72a7d1271f31dde57b2d_D{types.NewList(l...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfsha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c_D) Def() ListOfsha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c_DDef {
|
||||
d := make([]sha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c.DDef, l.Len())
|
||||
func (l ListOfsha1_d31b592f480b7659b03b72a7d1271f31dde57b2d_D) Def() ListOfsha1_d31b592f480b7659b03b72a7d1271f31dde57b2d_DDef {
|
||||
d := make([]sha1_d31b592f480b7659b03b72a7d1271f31dde57b2d.DDef, l.Len())
|
||||
for i := uint64(0); i < l.Len(); i++ {
|
||||
d[i] = sha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c.DFromVal(l.l.Get(i)).Def()
|
||||
d[i] = l.l.Get(i).(sha1_d31b592f480b7659b03b72a7d1271f31dde57b2d.D).Def()
|
||||
}
|
||||
return d
|
||||
}
|
||||
|
||||
func ListOfsha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c_DFromVal(val types.Value) ListOfsha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c_D {
|
||||
func ListOfsha1_d31b592f480b7659b03b72a7d1271f31dde57b2d_DFromVal(val types.Value) ListOfsha1_d31b592f480b7659b03b72a7d1271f31dde57b2d_D {
|
||||
// TODO: Do we still need FromVal?
|
||||
if val, ok := val.(ListOfsha1_d31b592f480b7659b03b72a7d1271f31dde57b2d_D); ok {
|
||||
return val
|
||||
}
|
||||
// TODO: Validate here
|
||||
return ListOfsha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c_D{val.(types.List)}
|
||||
return ListOfsha1_d31b592f480b7659b03b72a7d1271f31dde57b2d_D{val.(types.List), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfsha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c_D) NomsValue() types.Value {
|
||||
func (l ListOfsha1_d31b592f480b7659b03b72a7d1271f31dde57b2d_D) NomsValue() types.Value {
|
||||
// TODO: Remove this
|
||||
return l
|
||||
}
|
||||
|
||||
func (l ListOfsha1_d31b592f480b7659b03b72a7d1271f31dde57b2d_D) InternalImplementation() types.List {
|
||||
return l.l
|
||||
}
|
||||
|
||||
func (l ListOfsha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c_D) Equals(other types.Value) bool {
|
||||
if other, ok := other.(ListOfsha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c_D); ok {
|
||||
return l.l.Equals(other.l)
|
||||
func (l ListOfsha1_d31b592f480b7659b03b72a7d1271f31dde57b2d_D) Equals(other types.Value) bool {
|
||||
if other, ok := other.(ListOfsha1_d31b592f480b7659b03b72a7d1271f31dde57b2d_D); ok {
|
||||
return l.Ref() == other.Ref()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (l ListOfsha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c_D) Ref() ref.Ref {
|
||||
return l.l.Ref()
|
||||
func (l ListOfsha1_d31b592f480b7659b03b72a7d1271f31dde57b2d_D) Ref() ref.Ref {
|
||||
return types.EnsureRef(l.ref, l)
|
||||
}
|
||||
|
||||
func (l ListOfsha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c_D) Chunks() (futures []types.Future) {
|
||||
func (l ListOfsha1_d31b592f480b7659b03b72a7d1271f31dde57b2d_D) Chunks() (futures []types.Future) {
|
||||
futures = append(futures, l.TypeRef().Chunks()...)
|
||||
futures = append(futures, l.l.Chunks()...)
|
||||
return
|
||||
}
|
||||
|
||||
// A Noms Value that describes ListOfsha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c_D.
|
||||
var __typeRefForListOfsha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c_D types.TypeRef
|
||||
// A Noms Value that describes ListOfsha1_d31b592f480b7659b03b72a7d1271f31dde57b2d_D.
|
||||
var __typeRefForListOfsha1_d31b592f480b7659b03b72a7d1271f31dde57b2d_D types.TypeRef
|
||||
|
||||
func (m ListOfsha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c_D) TypeRef() types.TypeRef {
|
||||
return __typeRefForListOfsha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c_D
|
||||
func (m ListOfsha1_d31b592f480b7659b03b72a7d1271f31dde57b2d_D) TypeRef() types.TypeRef {
|
||||
return __typeRefForListOfsha1_d31b592f480b7659b03b72a7d1271f31dde57b2d_D
|
||||
}
|
||||
|
||||
func init() {
|
||||
__typeRefForListOfsha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c_D = types.MakeCompoundTypeRef("", types.ListKind, types.MakeTypeRef(ref.Parse("sha1-fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c"), 0))
|
||||
types.RegisterFromValFunction(__typeRefForListOfsha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c_D, func(v types.Value) types.NomsValue {
|
||||
return ListOfsha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c_DFromVal(v)
|
||||
__typeRefForListOfsha1_d31b592f480b7659b03b72a7d1271f31dde57b2d_D = types.MakeCompoundTypeRef("", types.ListKind, types.MakeTypeRef(ref.Parse("sha1-d31b592f480b7659b03b72a7d1271f31dde57b2d"), 0))
|
||||
types.RegisterFromValFunction(__typeRefForListOfsha1_d31b592f480b7659b03b72a7d1271f31dde57b2d_D, func(v types.Value) types.Value {
|
||||
return ListOfsha1_d31b592f480b7659b03b72a7d1271f31dde57b2d_DFromVal(v)
|
||||
})
|
||||
}
|
||||
|
||||
func (l ListOfsha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c_D) Len() uint64 {
|
||||
func (l ListOfsha1_d31b592f480b7659b03b72a7d1271f31dde57b2d_D) Len() uint64 {
|
||||
return l.l.Len()
|
||||
}
|
||||
|
||||
func (l ListOfsha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c_D) Empty() bool {
|
||||
func (l ListOfsha1_d31b592f480b7659b03b72a7d1271f31dde57b2d_D) Empty() bool {
|
||||
return l.Len() == uint64(0)
|
||||
}
|
||||
|
||||
func (l ListOfsha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c_D) Get(i uint64) sha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c.D {
|
||||
return sha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c.DFromVal(l.l.Get(i))
|
||||
func (l ListOfsha1_d31b592f480b7659b03b72a7d1271f31dde57b2d_D) Get(i uint64) sha1_d31b592f480b7659b03b72a7d1271f31dde57b2d.D {
|
||||
return l.l.Get(i).(sha1_d31b592f480b7659b03b72a7d1271f31dde57b2d.D)
|
||||
}
|
||||
|
||||
func (l ListOfsha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c_D) Slice(idx uint64, end uint64) ListOfsha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c_D {
|
||||
return ListOfsha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c_D{l.l.Slice(idx, end)}
|
||||
func (l ListOfsha1_d31b592f480b7659b03b72a7d1271f31dde57b2d_D) Slice(idx uint64, end uint64) ListOfsha1_d31b592f480b7659b03b72a7d1271f31dde57b2d_D {
|
||||
return ListOfsha1_d31b592f480b7659b03b72a7d1271f31dde57b2d_D{l.l.Slice(idx, end), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfsha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c_D) Set(i uint64, val sha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c.D) ListOfsha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c_D {
|
||||
return ListOfsha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c_D{l.l.Set(i, val.NomsValue())}
|
||||
func (l ListOfsha1_d31b592f480b7659b03b72a7d1271f31dde57b2d_D) Set(i uint64, val sha1_d31b592f480b7659b03b72a7d1271f31dde57b2d.D) ListOfsha1_d31b592f480b7659b03b72a7d1271f31dde57b2d_D {
|
||||
return ListOfsha1_d31b592f480b7659b03b72a7d1271f31dde57b2d_D{l.l.Set(i, val), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfsha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c_D) Append(v ...sha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c.D) ListOfsha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c_D {
|
||||
return ListOfsha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c_D{l.l.Append(l.fromElemSlice(v)...)}
|
||||
func (l ListOfsha1_d31b592f480b7659b03b72a7d1271f31dde57b2d_D) Append(v ...sha1_d31b592f480b7659b03b72a7d1271f31dde57b2d.D) ListOfsha1_d31b592f480b7659b03b72a7d1271f31dde57b2d_D {
|
||||
return ListOfsha1_d31b592f480b7659b03b72a7d1271f31dde57b2d_D{l.l.Append(l.fromElemSlice(v)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfsha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c_D) Insert(idx uint64, v ...sha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c.D) ListOfsha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c_D {
|
||||
return ListOfsha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c_D{l.l.Insert(idx, l.fromElemSlice(v)...)}
|
||||
func (l ListOfsha1_d31b592f480b7659b03b72a7d1271f31dde57b2d_D) Insert(idx uint64, v ...sha1_d31b592f480b7659b03b72a7d1271f31dde57b2d.D) ListOfsha1_d31b592f480b7659b03b72a7d1271f31dde57b2d_D {
|
||||
return ListOfsha1_d31b592f480b7659b03b72a7d1271f31dde57b2d_D{l.l.Insert(idx, l.fromElemSlice(v)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfsha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c_D) Remove(idx uint64, end uint64) ListOfsha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c_D {
|
||||
return ListOfsha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c_D{l.l.Remove(idx, end)}
|
||||
func (l ListOfsha1_d31b592f480b7659b03b72a7d1271f31dde57b2d_D) Remove(idx uint64, end uint64) ListOfsha1_d31b592f480b7659b03b72a7d1271f31dde57b2d_D {
|
||||
return ListOfsha1_d31b592f480b7659b03b72a7d1271f31dde57b2d_D{l.l.Remove(idx, end), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfsha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c_D) RemoveAt(idx uint64) ListOfsha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c_D {
|
||||
return ListOfsha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c_D{(l.l.RemoveAt(idx))}
|
||||
func (l ListOfsha1_d31b592f480b7659b03b72a7d1271f31dde57b2d_D) RemoveAt(idx uint64) ListOfsha1_d31b592f480b7659b03b72a7d1271f31dde57b2d_D {
|
||||
return ListOfsha1_d31b592f480b7659b03b72a7d1271f31dde57b2d_D{(l.l.RemoveAt(idx)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfsha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c_D) fromElemSlice(p []sha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c.D) []types.Value {
|
||||
func (l ListOfsha1_d31b592f480b7659b03b72a7d1271f31dde57b2d_D) fromElemSlice(p []sha1_d31b592f480b7659b03b72a7d1271f31dde57b2d.D) []types.Value {
|
||||
r := make([]types.Value, len(p))
|
||||
for i, v := range p {
|
||||
r[i] = v.NomsValue()
|
||||
r[i] = v
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
type ListOfsha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c_DIterCallback func(v sha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c.D, i uint64) (stop bool)
|
||||
type ListOfsha1_d31b592f480b7659b03b72a7d1271f31dde57b2d_DIterCallback func(v sha1_d31b592f480b7659b03b72a7d1271f31dde57b2d.D, i uint64) (stop bool)
|
||||
|
||||
func (l ListOfsha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c_D) Iter(cb ListOfsha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c_DIterCallback) {
|
||||
func (l ListOfsha1_d31b592f480b7659b03b72a7d1271f31dde57b2d_D) Iter(cb ListOfsha1_d31b592f480b7659b03b72a7d1271f31dde57b2d_DIterCallback) {
|
||||
l.l.Iter(func(v types.Value, i uint64) bool {
|
||||
return cb(sha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c.DFromVal(v), i)
|
||||
return cb(v.(sha1_d31b592f480b7659b03b72a7d1271f31dde57b2d.D), i)
|
||||
})
|
||||
}
|
||||
|
||||
type ListOfsha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c_DIterAllCallback func(v sha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c.D, i uint64)
|
||||
type ListOfsha1_d31b592f480b7659b03b72a7d1271f31dde57b2d_DIterAllCallback func(v sha1_d31b592f480b7659b03b72a7d1271f31dde57b2d.D, i uint64)
|
||||
|
||||
func (l ListOfsha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c_D) IterAll(cb ListOfsha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c_DIterAllCallback) {
|
||||
func (l ListOfsha1_d31b592f480b7659b03b72a7d1271f31dde57b2d_D) IterAll(cb ListOfsha1_d31b592f480b7659b03b72a7d1271f31dde57b2d_DIterAllCallback) {
|
||||
l.l.IterAll(func(v types.Value, i uint64) {
|
||||
cb(sha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c.DFromVal(v), i)
|
||||
cb(v.(sha1_d31b592f480b7659b03b72a7d1271f31dde57b2d.D), i)
|
||||
})
|
||||
}
|
||||
|
||||
type ListOfsha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c_DFilterCallback func(v sha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c.D, i uint64) (keep bool)
|
||||
type ListOfsha1_d31b592f480b7659b03b72a7d1271f31dde57b2d_DFilterCallback func(v sha1_d31b592f480b7659b03b72a7d1271f31dde57b2d.D, i uint64) (keep bool)
|
||||
|
||||
func (l ListOfsha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c_D) Filter(cb ListOfsha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c_DFilterCallback) ListOfsha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c_D {
|
||||
nl := NewListOfsha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c_D()
|
||||
l.IterAll(func(v sha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c.D, i uint64) {
|
||||
func (l ListOfsha1_d31b592f480b7659b03b72a7d1271f31dde57b2d_D) Filter(cb ListOfsha1_d31b592f480b7659b03b72a7d1271f31dde57b2d_DFilterCallback) ListOfsha1_d31b592f480b7659b03b72a7d1271f31dde57b2d_D {
|
||||
nl := NewListOfsha1_d31b592f480b7659b03b72a7d1271f31dde57b2d_D()
|
||||
l.IterAll(func(v sha1_d31b592f480b7659b03b72a7d1271f31dde57b2d.D, i uint64) {
|
||||
if cb(v, i) {
|
||||
nl = nl.Append(v)
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/attic-labs/noms/Godeps/_workspace/src/github.com/stretchr/testify/assert"
|
||||
leaf "github.com/attic-labs/noms/nomdl/codegen/test/gen/sha1_8bbcfa69bdfc9953c4034f8591964e0387983910"
|
||||
dep "github.com/attic-labs/noms/nomdl/codegen/test/gen/sha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c"
|
||||
leaf "github.com/attic-labs/noms/nomdl/codegen/test/gen/sha1_bbf9c3d7eb6ed891f4b8490b5b81f21f89f7d288"
|
||||
dep "github.com/attic-labs/noms/nomdl/codegen/test/gen/sha1_d31b592f480b7659b03b72a7d1271f31dde57b2d"
|
||||
"github.com/attic-labs/noms/types"
|
||||
)
|
||||
|
||||
@@ -39,7 +39,7 @@ func TestWithImportsDef(t *testing.T) {
|
||||
|
||||
func TestListOfImportsDef(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
lDef := ListOfsha1_fa6ca544e2613ecf1ac0467b3d655d8305c6ae8c_DDef{
|
||||
lDef := ListOfsha1_d31b592f480b7659b03b72a7d1271f31dde57b2d_DDef{
|
||||
dep.DDef{EnumField: leaf.E3},
|
||||
dep.DDef{EnumField: leaf.E2},
|
||||
dep.DDef{EnumField: leaf.E1},
|
||||
|
||||
@@ -30,17 +30,18 @@ func __testPackageInFile_struct_with_list_Ref() ref.Ref {
|
||||
// StructWithList
|
||||
|
||||
type StructWithList struct {
|
||||
m types.Map
|
||||
m types.Map
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewStructWithList() StructWithList {
|
||||
return StructWithList{types.NewMap(
|
||||
types.NewString("$type"), types.MakeTypeRef(__testPackageInFile_struct_with_list_CachedRef, 0),
|
||||
types.NewString("l"), types.NewList(),
|
||||
types.NewString("l"), NewListOfUInt8(),
|
||||
types.NewString("b"), types.Bool(false),
|
||||
types.NewString("s"), types.NewString(""),
|
||||
types.NewString("i"), types.Int64(0),
|
||||
)}
|
||||
), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type StructWithListDef struct {
|
||||
@@ -54,15 +55,15 @@ func (def StructWithListDef) New() StructWithList {
|
||||
return StructWithList{
|
||||
types.NewMap(
|
||||
types.NewString("$type"), types.MakeTypeRef(__testPackageInFile_struct_with_list_CachedRef, 0),
|
||||
types.NewString("l"), def.L.New().NomsValue(),
|
||||
types.NewString("l"), def.L.New(),
|
||||
types.NewString("b"), types.Bool(def.B),
|
||||
types.NewString("s"), types.NewString(def.S),
|
||||
types.NewString("i"), types.Int64(def.I),
|
||||
)}
|
||||
), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s StructWithList) Def() (d StructWithListDef) {
|
||||
d.L = ListOfUInt8FromVal(s.m.Get(types.NewString("l"))).Def()
|
||||
d.L = s.m.Get(types.NewString("l")).(ListOfUInt8).Def()
|
||||
d.B = bool(s.m.Get(types.NewString("b")).(types.Bool))
|
||||
d.S = s.m.Get(types.NewString("s")).(types.String).String()
|
||||
d.I = int64(s.m.Get(types.NewString("i")).(types.Int64))
|
||||
@@ -76,29 +77,38 @@ func (m StructWithList) TypeRef() types.TypeRef {
|
||||
}
|
||||
|
||||
func init() {
|
||||
types.RegisterFromValFunction(__typeRefForStructWithList, func(v types.Value) types.NomsValue {
|
||||
types.RegisterFromValFunction(__typeRefForStructWithList, func(v types.Value) types.Value {
|
||||
return StructWithListFromVal(v)
|
||||
})
|
||||
}
|
||||
|
||||
func StructWithListFromVal(val types.Value) StructWithList {
|
||||
// TODO: Do we still need FromVal?
|
||||
if val, ok := val.(StructWithList); ok {
|
||||
return val
|
||||
}
|
||||
// TODO: Validate here
|
||||
return StructWithList{val.(types.Map)}
|
||||
return StructWithList{val.(types.Map), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s StructWithList) NomsValue() types.Value {
|
||||
// TODO: Remove this
|
||||
return s
|
||||
}
|
||||
|
||||
func (s StructWithList) InternalImplementation() types.Map {
|
||||
return s.m
|
||||
}
|
||||
|
||||
func (s StructWithList) Equals(other types.Value) bool {
|
||||
if other, ok := other.(StructWithList); ok {
|
||||
return s.m.Equals(other.m)
|
||||
return s.Ref() == other.Ref()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (s StructWithList) Ref() ref.Ref {
|
||||
return s.m.Ref()
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s StructWithList) Chunks() (futures []types.Future) {
|
||||
@@ -108,11 +118,11 @@ func (s StructWithList) Chunks() (futures []types.Future) {
|
||||
}
|
||||
|
||||
func (s StructWithList) L() ListOfUInt8 {
|
||||
return ListOfUInt8FromVal(s.m.Get(types.NewString("l")))
|
||||
return s.m.Get(types.NewString("l")).(ListOfUInt8)
|
||||
}
|
||||
|
||||
func (s StructWithList) SetL(val ListOfUInt8) StructWithList {
|
||||
return StructWithList{s.m.Set(types.NewString("l"), val.NomsValue())}
|
||||
return StructWithList{s.m.Set(types.NewString("l"), val), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s StructWithList) B() bool {
|
||||
@@ -120,7 +130,7 @@ func (s StructWithList) B() bool {
|
||||
}
|
||||
|
||||
func (s StructWithList) SetB(val bool) StructWithList {
|
||||
return StructWithList{s.m.Set(types.NewString("b"), types.Bool(val))}
|
||||
return StructWithList{s.m.Set(types.NewString("b"), types.Bool(val)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s StructWithList) S() string {
|
||||
@@ -128,7 +138,7 @@ func (s StructWithList) S() string {
|
||||
}
|
||||
|
||||
func (s StructWithList) SetS(val string) StructWithList {
|
||||
return StructWithList{s.m.Set(types.NewString("s"), types.NewString(val))}
|
||||
return StructWithList{s.m.Set(types.NewString("s"), types.NewString(val)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s StructWithList) I() int64 {
|
||||
@@ -136,17 +146,18 @@ func (s StructWithList) I() int64 {
|
||||
}
|
||||
|
||||
func (s StructWithList) SetI(val int64) StructWithList {
|
||||
return StructWithList{s.m.Set(types.NewString("i"), types.Int64(val))}
|
||||
return StructWithList{s.m.Set(types.NewString("i"), types.Int64(val)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
// ListOfUInt8
|
||||
|
||||
type ListOfUInt8 struct {
|
||||
l types.List
|
||||
l types.List
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewListOfUInt8() ListOfUInt8 {
|
||||
return ListOfUInt8{types.NewList()}
|
||||
return ListOfUInt8{types.NewList(), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type ListOfUInt8Def []uint8
|
||||
@@ -156,7 +167,7 @@ func (def ListOfUInt8Def) New() ListOfUInt8 {
|
||||
for i, d := range def {
|
||||
l[i] = types.UInt8(d)
|
||||
}
|
||||
return ListOfUInt8{types.NewList(l...)}
|
||||
return ListOfUInt8{types.NewList(l...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfUInt8) Def() ListOfUInt8Def {
|
||||
@@ -168,23 +179,32 @@ func (l ListOfUInt8) Def() ListOfUInt8Def {
|
||||
}
|
||||
|
||||
func ListOfUInt8FromVal(val types.Value) ListOfUInt8 {
|
||||
// TODO: Do we still need FromVal?
|
||||
if val, ok := val.(ListOfUInt8); ok {
|
||||
return val
|
||||
}
|
||||
// TODO: Validate here
|
||||
return ListOfUInt8{val.(types.List)}
|
||||
return ListOfUInt8{val.(types.List), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfUInt8) NomsValue() types.Value {
|
||||
// TODO: Remove this
|
||||
return l
|
||||
}
|
||||
|
||||
func (l ListOfUInt8) InternalImplementation() types.List {
|
||||
return l.l
|
||||
}
|
||||
|
||||
func (l ListOfUInt8) Equals(other types.Value) bool {
|
||||
if other, ok := other.(ListOfUInt8); ok {
|
||||
return l.l.Equals(other.l)
|
||||
return l.Ref() == other.Ref()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (l ListOfUInt8) Ref() ref.Ref {
|
||||
return l.l.Ref()
|
||||
return types.EnsureRef(l.ref, l)
|
||||
}
|
||||
|
||||
func (l ListOfUInt8) Chunks() (futures []types.Future) {
|
||||
@@ -202,7 +222,7 @@ func (m ListOfUInt8) TypeRef() types.TypeRef {
|
||||
|
||||
func init() {
|
||||
__typeRefForListOfUInt8 = types.MakeCompoundTypeRef("", types.ListKind, types.MakePrimitiveTypeRef(types.UInt8Kind))
|
||||
types.RegisterFromValFunction(__typeRefForListOfUInt8, func(v types.Value) types.NomsValue {
|
||||
types.RegisterFromValFunction(__typeRefForListOfUInt8, func(v types.Value) types.Value {
|
||||
return ListOfUInt8FromVal(v)
|
||||
})
|
||||
}
|
||||
@@ -220,27 +240,27 @@ func (l ListOfUInt8) Get(i uint64) uint8 {
|
||||
}
|
||||
|
||||
func (l ListOfUInt8) Slice(idx uint64, end uint64) ListOfUInt8 {
|
||||
return ListOfUInt8{l.l.Slice(idx, end)}
|
||||
return ListOfUInt8{l.l.Slice(idx, end), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfUInt8) Set(i uint64, val uint8) ListOfUInt8 {
|
||||
return ListOfUInt8{l.l.Set(i, types.UInt8(val))}
|
||||
return ListOfUInt8{l.l.Set(i, types.UInt8(val)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfUInt8) Append(v ...uint8) ListOfUInt8 {
|
||||
return ListOfUInt8{l.l.Append(l.fromElemSlice(v)...)}
|
||||
return ListOfUInt8{l.l.Append(l.fromElemSlice(v)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfUInt8) Insert(idx uint64, v ...uint8) ListOfUInt8 {
|
||||
return ListOfUInt8{l.l.Insert(idx, l.fromElemSlice(v)...)}
|
||||
return ListOfUInt8{l.l.Insert(idx, l.fromElemSlice(v)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfUInt8) Remove(idx uint64, end uint64) ListOfUInt8 {
|
||||
return ListOfUInt8{l.l.Remove(idx, end)}
|
||||
return ListOfUInt8{l.l.Remove(idx, end), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfUInt8) RemoveAt(idx uint64) ListOfUInt8 {
|
||||
return ListOfUInt8{(l.l.RemoveAt(idx))}
|
||||
return ListOfUInt8{(l.l.RemoveAt(idx)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (l ListOfUInt8) fromElemSlice(p []uint8) []types.Value {
|
||||
|
||||
@@ -33,7 +33,8 @@ func __testPackageInFile_struct_with_union_field_Ref() ref.Ref {
|
||||
// StructWithUnionField
|
||||
|
||||
type StructWithUnionField struct {
|
||||
m types.Map
|
||||
m types.Map
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewStructWithUnionField() StructWithUnionField {
|
||||
@@ -42,7 +43,7 @@ func NewStructWithUnionField() StructWithUnionField {
|
||||
types.NewString("a"), types.Float32(0),
|
||||
types.NewString("$unionIndex"), types.UInt32(0),
|
||||
types.NewString("$unionValue"), types.Float64(0),
|
||||
)}
|
||||
), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type StructWithUnionFieldDef struct {
|
||||
@@ -58,7 +59,7 @@ func (def StructWithUnionFieldDef) New() StructWithUnionField {
|
||||
types.NewString("a"), types.Float32(def.A),
|
||||
types.NewString("$unionIndex"), types.UInt32(def.__unionIndex),
|
||||
types.NewString("$unionValue"), def.__unionDefToValue(),
|
||||
)}
|
||||
), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s StructWithUnionField) Def() (d StructWithUnionFieldDef) {
|
||||
@@ -79,7 +80,7 @@ func (def StructWithUnionFieldDef) __unionDefToValue() types.Value {
|
||||
case 3:
|
||||
return def.__unionValue.(types.Value)
|
||||
case 4:
|
||||
return def.__unionValue.(SetOfUInt8Def).New().NomsValue()
|
||||
return def.__unionValue.(SetOfUInt8Def).New()
|
||||
}
|
||||
panic("unreachable")
|
||||
}
|
||||
@@ -95,7 +96,7 @@ func (s StructWithUnionField) __unionValueToDef() interface{} {
|
||||
case 3:
|
||||
return s.m.Get(types.NewString("$unionValue"))
|
||||
case 4:
|
||||
return SetOfUInt8FromVal(s.m.Get(types.NewString("$unionValue"))).Def()
|
||||
return s.m.Get(types.NewString("$unionValue")).(SetOfUInt8).Def()
|
||||
}
|
||||
panic("unreachable")
|
||||
}
|
||||
@@ -107,29 +108,38 @@ func (m StructWithUnionField) TypeRef() types.TypeRef {
|
||||
}
|
||||
|
||||
func init() {
|
||||
types.RegisterFromValFunction(__typeRefForStructWithUnionField, func(v types.Value) types.NomsValue {
|
||||
types.RegisterFromValFunction(__typeRefForStructWithUnionField, func(v types.Value) types.Value {
|
||||
return StructWithUnionFieldFromVal(v)
|
||||
})
|
||||
}
|
||||
|
||||
func StructWithUnionFieldFromVal(val types.Value) StructWithUnionField {
|
||||
// TODO: Do we still need FromVal?
|
||||
if val, ok := val.(StructWithUnionField); ok {
|
||||
return val
|
||||
}
|
||||
// TODO: Validate here
|
||||
return StructWithUnionField{val.(types.Map)}
|
||||
return StructWithUnionField{val.(types.Map), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s StructWithUnionField) NomsValue() types.Value {
|
||||
// TODO: Remove this
|
||||
return s
|
||||
}
|
||||
|
||||
func (s StructWithUnionField) InternalImplementation() types.Map {
|
||||
return s.m
|
||||
}
|
||||
|
||||
func (s StructWithUnionField) Equals(other types.Value) bool {
|
||||
if other, ok := other.(StructWithUnionField); ok {
|
||||
return s.m.Equals(other.m)
|
||||
return s.Ref() == other.Ref()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (s StructWithUnionField) Ref() ref.Ref {
|
||||
return s.m.Ref()
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s StructWithUnionField) Chunks() (futures []types.Future) {
|
||||
@@ -143,7 +153,7 @@ func (s StructWithUnionField) A() float32 {
|
||||
}
|
||||
|
||||
func (s StructWithUnionField) SetA(val float32) StructWithUnionField {
|
||||
return StructWithUnionField{s.m.Set(types.NewString("a"), types.Float32(val))}
|
||||
return StructWithUnionField{s.m.Set(types.NewString("a"), types.Float32(val)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s StructWithUnionField) B() (val float64, ok bool) {
|
||||
@@ -154,7 +164,7 @@ func (s StructWithUnionField) B() (val float64, ok bool) {
|
||||
}
|
||||
|
||||
func (s StructWithUnionField) SetB(val float64) StructWithUnionField {
|
||||
return StructWithUnionField{s.m.Set(types.NewString("$unionIndex"), types.UInt32(0)).Set(types.NewString("$unionValue"), types.Float64(val))}
|
||||
return StructWithUnionField{s.m.Set(types.NewString("$unionIndex"), types.UInt32(0)).Set(types.NewString("$unionValue"), types.Float64(val)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (def StructWithUnionFieldDef) B() (val float64, ok bool) {
|
||||
@@ -178,7 +188,7 @@ func (s StructWithUnionField) C() (val string, ok bool) {
|
||||
}
|
||||
|
||||
func (s StructWithUnionField) SetC(val string) StructWithUnionField {
|
||||
return StructWithUnionField{s.m.Set(types.NewString("$unionIndex"), types.UInt32(1)).Set(types.NewString("$unionValue"), types.NewString(val))}
|
||||
return StructWithUnionField{s.m.Set(types.NewString("$unionIndex"), types.UInt32(1)).Set(types.NewString("$unionValue"), types.NewString(val)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (def StructWithUnionFieldDef) C() (val string, ok bool) {
|
||||
@@ -202,7 +212,7 @@ func (s StructWithUnionField) D() (val types.Blob, ok bool) {
|
||||
}
|
||||
|
||||
func (s StructWithUnionField) SetD(val types.Blob) StructWithUnionField {
|
||||
return StructWithUnionField{s.m.Set(types.NewString("$unionIndex"), types.UInt32(2)).Set(types.NewString("$unionValue"), val)}
|
||||
return StructWithUnionField{s.m.Set(types.NewString("$unionIndex"), types.UInt32(2)).Set(types.NewString("$unionValue"), val), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (def StructWithUnionFieldDef) D() (val types.Blob, ok bool) {
|
||||
@@ -226,7 +236,7 @@ func (s StructWithUnionField) E() (val types.Value, ok bool) {
|
||||
}
|
||||
|
||||
func (s StructWithUnionField) SetE(val types.Value) StructWithUnionField {
|
||||
return StructWithUnionField{s.m.Set(types.NewString("$unionIndex"), types.UInt32(3)).Set(types.NewString("$unionValue"), val)}
|
||||
return StructWithUnionField{s.m.Set(types.NewString("$unionIndex"), types.UInt32(3)).Set(types.NewString("$unionValue"), val), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (def StructWithUnionFieldDef) E() (val types.Value, ok bool) {
|
||||
@@ -246,11 +256,11 @@ func (s StructWithUnionField) F() (val SetOfUInt8, ok bool) {
|
||||
if s.m.Get(types.NewString("$unionIndex")).(types.UInt32) != 4 {
|
||||
return
|
||||
}
|
||||
return SetOfUInt8FromVal(s.m.Get(types.NewString("$unionValue"))), true
|
||||
return s.m.Get(types.NewString("$unionValue")).(SetOfUInt8), true
|
||||
}
|
||||
|
||||
func (s StructWithUnionField) SetF(val SetOfUInt8) StructWithUnionField {
|
||||
return StructWithUnionField{s.m.Set(types.NewString("$unionIndex"), types.UInt32(4)).Set(types.NewString("$unionValue"), val.NomsValue())}
|
||||
return StructWithUnionField{s.m.Set(types.NewString("$unionIndex"), types.UInt32(4)).Set(types.NewString("$unionValue"), val), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (def StructWithUnionFieldDef) F() (val SetOfUInt8Def, ok bool) {
|
||||
@@ -269,11 +279,12 @@ func (def StructWithUnionFieldDef) SetF(val SetOfUInt8Def) StructWithUnionFieldD
|
||||
// SetOfUInt8
|
||||
|
||||
type SetOfUInt8 struct {
|
||||
s types.Set
|
||||
s types.Set
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewSetOfUInt8() SetOfUInt8 {
|
||||
return SetOfUInt8{types.NewSet()}
|
||||
return SetOfUInt8{types.NewSet(), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type SetOfUInt8Def map[uint8]bool
|
||||
@@ -285,7 +296,7 @@ func (def SetOfUInt8Def) New() SetOfUInt8 {
|
||||
l[i] = types.UInt8(d)
|
||||
i++
|
||||
}
|
||||
return SetOfUInt8{types.NewSet(l...)}
|
||||
return SetOfUInt8{types.NewSet(l...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfUInt8) Def() SetOfUInt8Def {
|
||||
@@ -297,23 +308,32 @@ func (s SetOfUInt8) Def() SetOfUInt8Def {
|
||||
return def
|
||||
}
|
||||
|
||||
func SetOfUInt8FromVal(p types.Value) SetOfUInt8 {
|
||||
return SetOfUInt8{p.(types.Set)}
|
||||
func SetOfUInt8FromVal(val types.Value) SetOfUInt8 {
|
||||
// TODO: Do we still need FromVal?
|
||||
if val, ok := val.(SetOfUInt8); ok {
|
||||
return val
|
||||
}
|
||||
return SetOfUInt8{val.(types.Set), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfUInt8) NomsValue() types.Value {
|
||||
// TODO: Remove this
|
||||
return s
|
||||
}
|
||||
|
||||
func (s SetOfUInt8) InternalImplementation() types.Set {
|
||||
return s.s
|
||||
}
|
||||
|
||||
func (s SetOfUInt8) Equals(other types.Value) bool {
|
||||
if other, ok := other.(SetOfUInt8); ok {
|
||||
return s.s.Equals(other.s)
|
||||
return s.Ref() == other.Ref()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (s SetOfUInt8) Ref() ref.Ref {
|
||||
return s.s.Ref()
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s SetOfUInt8) Chunks() (futures []types.Future) {
|
||||
@@ -331,7 +351,7 @@ func (m SetOfUInt8) TypeRef() types.TypeRef {
|
||||
|
||||
func init() {
|
||||
__typeRefForSetOfUInt8 = types.MakeCompoundTypeRef("", types.SetKind, types.MakePrimitiveTypeRef(types.UInt8Kind))
|
||||
types.RegisterFromValFunction(__typeRefForSetOfUInt8, func(v types.Value) types.NomsValue {
|
||||
types.RegisterFromValFunction(__typeRefForSetOfUInt8, func(v types.Value) types.Value {
|
||||
return SetOfUInt8FromVal(v)
|
||||
})
|
||||
}
|
||||
@@ -377,19 +397,19 @@ func (s SetOfUInt8) Filter(cb SetOfUInt8FilterCallback) SetOfUInt8 {
|
||||
}
|
||||
|
||||
func (s SetOfUInt8) Insert(p ...uint8) SetOfUInt8 {
|
||||
return SetOfUInt8{s.s.Insert(s.fromElemSlice(p)...)}
|
||||
return SetOfUInt8{s.s.Insert(s.fromElemSlice(p)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfUInt8) Remove(p ...uint8) SetOfUInt8 {
|
||||
return SetOfUInt8{s.s.Remove(s.fromElemSlice(p)...)}
|
||||
return SetOfUInt8{s.s.Remove(s.fromElemSlice(p)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfUInt8) Union(others ...SetOfUInt8) SetOfUInt8 {
|
||||
return SetOfUInt8{s.s.Union(s.fromStructSlice(others)...)}
|
||||
return SetOfUInt8{s.s.Union(s.fromStructSlice(others)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfUInt8) Subtract(others ...SetOfUInt8) SetOfUInt8 {
|
||||
return SetOfUInt8{s.s.Subtract(s.fromStructSlice(others)...)}
|
||||
return SetOfUInt8{s.s.Subtract(s.fromStructSlice(others)...), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s SetOfUInt8) Any() uint8 {
|
||||
|
||||
@@ -42,15 +42,16 @@ func __testPackageInFile_struct_with_unions_Ref() ref.Ref {
|
||||
// StructWithUnions
|
||||
|
||||
type StructWithUnions struct {
|
||||
m types.Map
|
||||
m types.Map
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewStructWithUnions() StructWithUnions {
|
||||
return StructWithUnions{types.NewMap(
|
||||
types.NewString("$type"), types.MakeTypeRef(__testPackageInFile_struct_with_unions_CachedRef, 0),
|
||||
types.NewString("a"), New__unionOfBOfFloat64AndCOfString().NomsValue(),
|
||||
types.NewString("d"), New__unionOfEOfFloat64AndFOfString().NomsValue(),
|
||||
)}
|
||||
types.NewString("a"), New__unionOfBOfFloat64AndCOfString(),
|
||||
types.NewString("d"), New__unionOfEOfFloat64AndFOfString(),
|
||||
), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type StructWithUnionsDef struct {
|
||||
@@ -62,14 +63,14 @@ func (def StructWithUnionsDef) New() StructWithUnions {
|
||||
return StructWithUnions{
|
||||
types.NewMap(
|
||||
types.NewString("$type"), types.MakeTypeRef(__testPackageInFile_struct_with_unions_CachedRef, 0),
|
||||
types.NewString("a"), def.A.New().NomsValue(),
|
||||
types.NewString("d"), def.D.New().NomsValue(),
|
||||
)}
|
||||
types.NewString("a"), def.A.New(),
|
||||
types.NewString("d"), def.D.New(),
|
||||
), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s StructWithUnions) Def() (d StructWithUnionsDef) {
|
||||
d.A = __unionOfBOfFloat64AndCOfStringFromVal(s.m.Get(types.NewString("a"))).Def()
|
||||
d.D = __unionOfEOfFloat64AndFOfStringFromVal(s.m.Get(types.NewString("d"))).Def()
|
||||
d.A = s.m.Get(types.NewString("a")).(__unionOfBOfFloat64AndCOfString).Def()
|
||||
d.D = s.m.Get(types.NewString("d")).(__unionOfEOfFloat64AndFOfString).Def()
|
||||
return
|
||||
}
|
||||
|
||||
@@ -80,29 +81,38 @@ func (m StructWithUnions) TypeRef() types.TypeRef {
|
||||
}
|
||||
|
||||
func init() {
|
||||
types.RegisterFromValFunction(__typeRefForStructWithUnions, func(v types.Value) types.NomsValue {
|
||||
types.RegisterFromValFunction(__typeRefForStructWithUnions, func(v types.Value) types.Value {
|
||||
return StructWithUnionsFromVal(v)
|
||||
})
|
||||
}
|
||||
|
||||
func StructWithUnionsFromVal(val types.Value) StructWithUnions {
|
||||
// TODO: Do we still need FromVal?
|
||||
if val, ok := val.(StructWithUnions); ok {
|
||||
return val
|
||||
}
|
||||
// TODO: Validate here
|
||||
return StructWithUnions{val.(types.Map)}
|
||||
return StructWithUnions{val.(types.Map), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s StructWithUnions) NomsValue() types.Value {
|
||||
// TODO: Remove this
|
||||
return s
|
||||
}
|
||||
|
||||
func (s StructWithUnions) InternalImplementation() types.Map {
|
||||
return s.m
|
||||
}
|
||||
|
||||
func (s StructWithUnions) Equals(other types.Value) bool {
|
||||
if other, ok := other.(StructWithUnions); ok {
|
||||
return s.m.Equals(other.m)
|
||||
return s.Ref() == other.Ref()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (s StructWithUnions) Ref() ref.Ref {
|
||||
return s.m.Ref()
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s StructWithUnions) Chunks() (futures []types.Future) {
|
||||
@@ -112,25 +122,26 @@ func (s StructWithUnions) Chunks() (futures []types.Future) {
|
||||
}
|
||||
|
||||
func (s StructWithUnions) A() __unionOfBOfFloat64AndCOfString {
|
||||
return __unionOfBOfFloat64AndCOfStringFromVal(s.m.Get(types.NewString("a")))
|
||||
return s.m.Get(types.NewString("a")).(__unionOfBOfFloat64AndCOfString)
|
||||
}
|
||||
|
||||
func (s StructWithUnions) SetA(val __unionOfBOfFloat64AndCOfString) StructWithUnions {
|
||||
return StructWithUnions{s.m.Set(types.NewString("a"), val.NomsValue())}
|
||||
return StructWithUnions{s.m.Set(types.NewString("a"), val), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s StructWithUnions) D() __unionOfEOfFloat64AndFOfString {
|
||||
return __unionOfEOfFloat64AndFOfStringFromVal(s.m.Get(types.NewString("d")))
|
||||
return s.m.Get(types.NewString("d")).(__unionOfEOfFloat64AndFOfString)
|
||||
}
|
||||
|
||||
func (s StructWithUnions) SetD(val __unionOfEOfFloat64AndFOfString) StructWithUnions {
|
||||
return StructWithUnions{s.m.Set(types.NewString("d"), val.NomsValue())}
|
||||
return StructWithUnions{s.m.Set(types.NewString("d"), val), &ref.Ref{}}
|
||||
}
|
||||
|
||||
// __unionOfBOfFloat64AndCOfString
|
||||
|
||||
type __unionOfBOfFloat64AndCOfString struct {
|
||||
m types.Map
|
||||
m types.Map
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func New__unionOfBOfFloat64AndCOfString() __unionOfBOfFloat64AndCOfString {
|
||||
@@ -138,7 +149,7 @@ func New__unionOfBOfFloat64AndCOfString() __unionOfBOfFloat64AndCOfString {
|
||||
types.NewString("$type"), types.MakeTypeRef(__testPackageInFile_struct_with_unions_CachedRef, 1),
|
||||
types.NewString("$unionIndex"), types.UInt32(0),
|
||||
types.NewString("$unionValue"), types.Float64(0),
|
||||
)}
|
||||
), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type __unionOfBOfFloat64AndCOfStringDef struct {
|
||||
@@ -152,7 +163,7 @@ func (def __unionOfBOfFloat64AndCOfStringDef) New() __unionOfBOfFloat64AndCOfStr
|
||||
types.NewString("$type"), types.MakeTypeRef(__testPackageInFile_struct_with_unions_CachedRef, 1),
|
||||
types.NewString("$unionIndex"), types.UInt32(def.__unionIndex),
|
||||
types.NewString("$unionValue"), def.__unionDefToValue(),
|
||||
)}
|
||||
), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s __unionOfBOfFloat64AndCOfString) Def() (d __unionOfBOfFloat64AndCOfStringDef) {
|
||||
@@ -188,29 +199,38 @@ func (m __unionOfBOfFloat64AndCOfString) TypeRef() types.TypeRef {
|
||||
}
|
||||
|
||||
func init() {
|
||||
types.RegisterFromValFunction(__typeRefFor__unionOfBOfFloat64AndCOfString, func(v types.Value) types.NomsValue {
|
||||
types.RegisterFromValFunction(__typeRefFor__unionOfBOfFloat64AndCOfString, func(v types.Value) types.Value {
|
||||
return __unionOfBOfFloat64AndCOfStringFromVal(v)
|
||||
})
|
||||
}
|
||||
|
||||
func __unionOfBOfFloat64AndCOfStringFromVal(val types.Value) __unionOfBOfFloat64AndCOfString {
|
||||
// TODO: Do we still need FromVal?
|
||||
if val, ok := val.(__unionOfBOfFloat64AndCOfString); ok {
|
||||
return val
|
||||
}
|
||||
// TODO: Validate here
|
||||
return __unionOfBOfFloat64AndCOfString{val.(types.Map)}
|
||||
return __unionOfBOfFloat64AndCOfString{val.(types.Map), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s __unionOfBOfFloat64AndCOfString) NomsValue() types.Value {
|
||||
// TODO: Remove this
|
||||
return s
|
||||
}
|
||||
|
||||
func (s __unionOfBOfFloat64AndCOfString) InternalImplementation() types.Map {
|
||||
return s.m
|
||||
}
|
||||
|
||||
func (s __unionOfBOfFloat64AndCOfString) Equals(other types.Value) bool {
|
||||
if other, ok := other.(__unionOfBOfFloat64AndCOfString); ok {
|
||||
return s.m.Equals(other.m)
|
||||
return s.Ref() == other.Ref()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (s __unionOfBOfFloat64AndCOfString) Ref() ref.Ref {
|
||||
return s.m.Ref()
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s __unionOfBOfFloat64AndCOfString) Chunks() (futures []types.Future) {
|
||||
@@ -227,7 +247,7 @@ func (s __unionOfBOfFloat64AndCOfString) B() (val float64, ok bool) {
|
||||
}
|
||||
|
||||
func (s __unionOfBOfFloat64AndCOfString) SetB(val float64) __unionOfBOfFloat64AndCOfString {
|
||||
return __unionOfBOfFloat64AndCOfString{s.m.Set(types.NewString("$unionIndex"), types.UInt32(0)).Set(types.NewString("$unionValue"), types.Float64(val))}
|
||||
return __unionOfBOfFloat64AndCOfString{s.m.Set(types.NewString("$unionIndex"), types.UInt32(0)).Set(types.NewString("$unionValue"), types.Float64(val)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (def __unionOfBOfFloat64AndCOfStringDef) B() (val float64, ok bool) {
|
||||
@@ -251,7 +271,7 @@ func (s __unionOfBOfFloat64AndCOfString) C() (val string, ok bool) {
|
||||
}
|
||||
|
||||
func (s __unionOfBOfFloat64AndCOfString) SetC(val string) __unionOfBOfFloat64AndCOfString {
|
||||
return __unionOfBOfFloat64AndCOfString{s.m.Set(types.NewString("$unionIndex"), types.UInt32(1)).Set(types.NewString("$unionValue"), types.NewString(val))}
|
||||
return __unionOfBOfFloat64AndCOfString{s.m.Set(types.NewString("$unionIndex"), types.UInt32(1)).Set(types.NewString("$unionValue"), types.NewString(val)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (def __unionOfBOfFloat64AndCOfStringDef) C() (val string, ok bool) {
|
||||
@@ -270,7 +290,8 @@ func (def __unionOfBOfFloat64AndCOfStringDef) SetC(val string) __unionOfBOfFloat
|
||||
// __unionOfEOfFloat64AndFOfString
|
||||
|
||||
type __unionOfEOfFloat64AndFOfString struct {
|
||||
m types.Map
|
||||
m types.Map
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func New__unionOfEOfFloat64AndFOfString() __unionOfEOfFloat64AndFOfString {
|
||||
@@ -278,7 +299,7 @@ func New__unionOfEOfFloat64AndFOfString() __unionOfEOfFloat64AndFOfString {
|
||||
types.NewString("$type"), types.MakeTypeRef(__testPackageInFile_struct_with_unions_CachedRef, 2),
|
||||
types.NewString("$unionIndex"), types.UInt32(0),
|
||||
types.NewString("$unionValue"), types.Float64(0),
|
||||
)}
|
||||
), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type __unionOfEOfFloat64AndFOfStringDef struct {
|
||||
@@ -292,7 +313,7 @@ func (def __unionOfEOfFloat64AndFOfStringDef) New() __unionOfEOfFloat64AndFOfStr
|
||||
types.NewString("$type"), types.MakeTypeRef(__testPackageInFile_struct_with_unions_CachedRef, 2),
|
||||
types.NewString("$unionIndex"), types.UInt32(def.__unionIndex),
|
||||
types.NewString("$unionValue"), def.__unionDefToValue(),
|
||||
)}
|
||||
), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s __unionOfEOfFloat64AndFOfString) Def() (d __unionOfEOfFloat64AndFOfStringDef) {
|
||||
@@ -328,29 +349,38 @@ func (m __unionOfEOfFloat64AndFOfString) TypeRef() types.TypeRef {
|
||||
}
|
||||
|
||||
func init() {
|
||||
types.RegisterFromValFunction(__typeRefFor__unionOfEOfFloat64AndFOfString, func(v types.Value) types.NomsValue {
|
||||
types.RegisterFromValFunction(__typeRefFor__unionOfEOfFloat64AndFOfString, func(v types.Value) types.Value {
|
||||
return __unionOfEOfFloat64AndFOfStringFromVal(v)
|
||||
})
|
||||
}
|
||||
|
||||
func __unionOfEOfFloat64AndFOfStringFromVal(val types.Value) __unionOfEOfFloat64AndFOfString {
|
||||
// TODO: Do we still need FromVal?
|
||||
if val, ok := val.(__unionOfEOfFloat64AndFOfString); ok {
|
||||
return val
|
||||
}
|
||||
// TODO: Validate here
|
||||
return __unionOfEOfFloat64AndFOfString{val.(types.Map)}
|
||||
return __unionOfEOfFloat64AndFOfString{val.(types.Map), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s __unionOfEOfFloat64AndFOfString) NomsValue() types.Value {
|
||||
// TODO: Remove this
|
||||
return s
|
||||
}
|
||||
|
||||
func (s __unionOfEOfFloat64AndFOfString) InternalImplementation() types.Map {
|
||||
return s.m
|
||||
}
|
||||
|
||||
func (s __unionOfEOfFloat64AndFOfString) Equals(other types.Value) bool {
|
||||
if other, ok := other.(__unionOfEOfFloat64AndFOfString); ok {
|
||||
return s.m.Equals(other.m)
|
||||
return s.Ref() == other.Ref()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (s __unionOfEOfFloat64AndFOfString) Ref() ref.Ref {
|
||||
return s.m.Ref()
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s __unionOfEOfFloat64AndFOfString) Chunks() (futures []types.Future) {
|
||||
@@ -367,7 +397,7 @@ func (s __unionOfEOfFloat64AndFOfString) E() (val float64, ok bool) {
|
||||
}
|
||||
|
||||
func (s __unionOfEOfFloat64AndFOfString) SetE(val float64) __unionOfEOfFloat64AndFOfString {
|
||||
return __unionOfEOfFloat64AndFOfString{s.m.Set(types.NewString("$unionIndex"), types.UInt32(0)).Set(types.NewString("$unionValue"), types.Float64(val))}
|
||||
return __unionOfEOfFloat64AndFOfString{s.m.Set(types.NewString("$unionIndex"), types.UInt32(0)).Set(types.NewString("$unionValue"), types.Float64(val)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (def __unionOfEOfFloat64AndFOfStringDef) E() (val float64, ok bool) {
|
||||
@@ -391,7 +421,7 @@ func (s __unionOfEOfFloat64AndFOfString) F() (val string, ok bool) {
|
||||
}
|
||||
|
||||
func (s __unionOfEOfFloat64AndFOfString) SetF(val string) __unionOfEOfFloat64AndFOfString {
|
||||
return __unionOfEOfFloat64AndFOfString{s.m.Set(types.NewString("$unionIndex"), types.UInt32(1)).Set(types.NewString("$unionValue"), types.NewString(val))}
|
||||
return __unionOfEOfFloat64AndFOfString{s.m.Set(types.NewString("$unionIndex"), types.UInt32(1)).Set(types.NewString("$unionValue"), types.NewString(val)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (def __unionOfEOfFloat64AndFOfStringDef) F() (val string, ok bool) {
|
||||
|
||||
@@ -1,198 +0,0 @@
|
||||
// This file was generated by nomdl/codegen.
|
||||
|
||||
package test
|
||||
|
||||
import (
|
||||
"github.com/attic-labs/noms/nomdl/codegen/test/gen/sha1_8bbcfa69bdfc9953c4034f8591964e0387983910"
|
||||
"github.com/attic-labs/noms/ref"
|
||||
"github.com/attic-labs/noms/types"
|
||||
)
|
||||
|
||||
var __testPackageInFile_dep_CachedRef = __testPackageInFile_dep_Ref()
|
||||
|
||||
// This function builds up a Noms value that describes the type
|
||||
// package implemented by this file and registers it with the global
|
||||
// type package definition cache.
|
||||
func __testPackageInFile_dep_Ref() ref.Ref {
|
||||
p := types.NewPackage([]types.TypeRef{
|
||||
|
||||
types.MakeStructTypeRef("D",
|
||||
[]types.Field{
|
||||
types.Field{"structField", types.MakeTypeRef(ref.Parse("sha1-8bbcfa69bdfc9953c4034f8591964e0387983910"), 0), false},
|
||||
types.Field{"enumField", types.MakeTypeRef(ref.Parse("sha1-8bbcfa69bdfc9953c4034f8591964e0387983910"), 1), false},
|
||||
},
|
||||
types.Choices{},
|
||||
),
|
||||
types.MakeStructTypeRef("DUser",
|
||||
[]types.Field{
|
||||
types.Field{"Dfield", types.MakeTypeRef(ref.Ref{}, 0), false},
|
||||
},
|
||||
types.Choices{},
|
||||
),
|
||||
}, []ref.Ref{})
|
||||
return types.RegisterPackage(&p)
|
||||
}
|
||||
|
||||
// D
|
||||
|
||||
type D struct {
|
||||
m types.Map
|
||||
}
|
||||
|
||||
func NewD() D {
|
||||
return D{types.NewMap(
|
||||
types.NewString("$type"), types.MakeTypeRef(__testPackageInFile_dep_CachedRef, 0),
|
||||
types.NewString("structField"), sha1_8bbcfa69bdfc9953c4034f8591964e0387983910.NewS().NomsValue(),
|
||||
types.NewString("enumField"), types.UInt32(0),
|
||||
)}
|
||||
}
|
||||
|
||||
type DDef struct {
|
||||
StructField sha1_8bbcfa69bdfc9953c4034f8591964e0387983910.SDef
|
||||
EnumField sha1_8bbcfa69bdfc9953c4034f8591964e0387983910.E
|
||||
}
|
||||
|
||||
func (def DDef) New() D {
|
||||
return D{
|
||||
types.NewMap(
|
||||
types.NewString("$type"), types.MakeTypeRef(__testPackageInFile_dep_CachedRef, 0),
|
||||
types.NewString("structField"), def.StructField.New().NomsValue(),
|
||||
types.NewString("enumField"), types.UInt32(def.EnumField),
|
||||
)}
|
||||
}
|
||||
|
||||
func (s D) Def() (d DDef) {
|
||||
d.StructField = sha1_8bbcfa69bdfc9953c4034f8591964e0387983910.SFromVal(s.m.Get(types.NewString("structField"))).Def()
|
||||
d.EnumField = sha1_8bbcfa69bdfc9953c4034f8591964e0387983910.E(s.m.Get(types.NewString("enumField")).(types.UInt32))
|
||||
return
|
||||
}
|
||||
|
||||
var __typeRefForD = types.MakeTypeRef(__testPackageInFile_dep_CachedRef, 0)
|
||||
|
||||
func (m D) TypeRef() types.TypeRef {
|
||||
return __typeRefForD
|
||||
}
|
||||
|
||||
func init() {
|
||||
types.RegisterFromValFunction(__typeRefForD, func(v types.Value) types.NomsValue {
|
||||
return DFromVal(v)
|
||||
})
|
||||
}
|
||||
|
||||
func DFromVal(val types.Value) D {
|
||||
// TODO: Validate here
|
||||
return D{val.(types.Map)}
|
||||
}
|
||||
|
||||
func (s D) NomsValue() types.Value {
|
||||
return s.m
|
||||
}
|
||||
|
||||
func (s D) Equals(other types.Value) bool {
|
||||
if other, ok := other.(D); ok {
|
||||
return s.m.Equals(other.m)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (s D) Ref() ref.Ref {
|
||||
return s.m.Ref()
|
||||
}
|
||||
|
||||
func (s D) Chunks() (futures []types.Future) {
|
||||
futures = append(futures, s.TypeRef().Chunks()...)
|
||||
futures = append(futures, s.m.Chunks()...)
|
||||
return
|
||||
}
|
||||
|
||||
func (s D) StructField() sha1_8bbcfa69bdfc9953c4034f8591964e0387983910.S {
|
||||
return sha1_8bbcfa69bdfc9953c4034f8591964e0387983910.SFromVal(s.m.Get(types.NewString("structField")))
|
||||
}
|
||||
|
||||
func (s D) SetStructField(val sha1_8bbcfa69bdfc9953c4034f8591964e0387983910.S) D {
|
||||
return D{s.m.Set(types.NewString("structField"), val.NomsValue())}
|
||||
}
|
||||
|
||||
func (s D) EnumField() sha1_8bbcfa69bdfc9953c4034f8591964e0387983910.E {
|
||||
return sha1_8bbcfa69bdfc9953c4034f8591964e0387983910.E(s.m.Get(types.NewString("enumField")).(types.UInt32))
|
||||
}
|
||||
|
||||
func (s D) SetEnumField(val sha1_8bbcfa69bdfc9953c4034f8591964e0387983910.E) D {
|
||||
return D{s.m.Set(types.NewString("enumField"), types.UInt32(val))}
|
||||
}
|
||||
|
||||
// DUser
|
||||
|
||||
type DUser struct {
|
||||
m types.Map
|
||||
}
|
||||
|
||||
func NewDUser() DUser {
|
||||
return DUser{types.NewMap(
|
||||
types.NewString("$type"), types.MakeTypeRef(__testPackageInFile_dep_CachedRef, 1),
|
||||
types.NewString("Dfield"), NewD().NomsValue(),
|
||||
)}
|
||||
}
|
||||
|
||||
type DUserDef struct {
|
||||
Dfield DDef
|
||||
}
|
||||
|
||||
func (def DUserDef) New() DUser {
|
||||
return DUser{
|
||||
types.NewMap(
|
||||
types.NewString("$type"), types.MakeTypeRef(__testPackageInFile_dep_CachedRef, 1),
|
||||
types.NewString("Dfield"), def.Dfield.New().NomsValue(),
|
||||
)}
|
||||
}
|
||||
|
||||
func (s DUser) Def() (d DUserDef) {
|
||||
d.Dfield = DFromVal(s.m.Get(types.NewString("Dfield"))).Def()
|
||||
return
|
||||
}
|
||||
|
||||
var __typeRefForDUser = types.MakeTypeRef(__testPackageInFile_dep_CachedRef, 1)
|
||||
|
||||
func (m DUser) TypeRef() types.TypeRef {
|
||||
return __typeRefForDUser
|
||||
}
|
||||
|
||||
func init() {
|
||||
types.RegisterFromValFunction(__typeRefForDUser, func(v types.Value) types.NomsValue {
|
||||
return DUserFromVal(v)
|
||||
})
|
||||
}
|
||||
|
||||
func DUserFromVal(val types.Value) DUser {
|
||||
// TODO: Validate here
|
||||
return DUser{val.(types.Map)}
|
||||
}
|
||||
|
||||
func (s DUser) NomsValue() types.Value {
|
||||
return s.m
|
||||
}
|
||||
|
||||
func (s DUser) Equals(other types.Value) bool {
|
||||
if other, ok := other.(DUser); ok {
|
||||
return s.m.Equals(other.m)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (s DUser) Ref() ref.Ref {
|
||||
return s.m.Ref()
|
||||
}
|
||||
|
||||
func (s DUser) Chunks() (futures []types.Future) {
|
||||
futures = append(futures, s.TypeRef().Chunks()...)
|
||||
futures = append(futures, s.m.Chunks()...)
|
||||
return
|
||||
}
|
||||
|
||||
func (s DUser) Dfield() D {
|
||||
return DFromVal(s.m.Get(types.NewString("Dfield")))
|
||||
}
|
||||
|
||||
func (s DUser) SetDfield(val D) DUser {
|
||||
return DUser{s.m.Set(types.NewString("Dfield"), val.NomsValue())}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
alias leaf = import "sha1-8bbcfa69bdfc9953c4034f8591964e0387983910"
|
||||
alias leaf = import "sha1-bbf9c3d7eb6ed891f4b8490b5b81f21f89f7d288"
|
||||
|
||||
struct D {
|
||||
structField: leaf.S
|
||||
|
||||
@@ -29,7 +29,8 @@ func __testPackageInFile_leafDep_Ref() ref.Ref {
|
||||
// S
|
||||
|
||||
type S struct {
|
||||
m types.Map
|
||||
m types.Map
|
||||
ref *ref.Ref
|
||||
}
|
||||
|
||||
func NewS() S {
|
||||
@@ -37,7 +38,7 @@ func NewS() S {
|
||||
types.NewString("$type"), types.MakeTypeRef(__testPackageInFile_leafDep_CachedRef, 0),
|
||||
types.NewString("s"), types.NewString(""),
|
||||
types.NewString("b"), types.Bool(false),
|
||||
)}
|
||||
), &ref.Ref{}}
|
||||
}
|
||||
|
||||
type SDef struct {
|
||||
@@ -51,7 +52,7 @@ func (def SDef) New() S {
|
||||
types.NewString("$type"), types.MakeTypeRef(__testPackageInFile_leafDep_CachedRef, 0),
|
||||
types.NewString("s"), types.NewString(def.S),
|
||||
types.NewString("b"), types.Bool(def.B),
|
||||
)}
|
||||
), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s S) Def() (d SDef) {
|
||||
@@ -67,29 +68,38 @@ func (m S) TypeRef() types.TypeRef {
|
||||
}
|
||||
|
||||
func init() {
|
||||
types.RegisterFromValFunction(__typeRefForS, func(v types.Value) types.NomsValue {
|
||||
types.RegisterFromValFunction(__typeRefForS, func(v types.Value) types.Value {
|
||||
return SFromVal(v)
|
||||
})
|
||||
}
|
||||
|
||||
func SFromVal(val types.Value) S {
|
||||
// TODO: Do we still need FromVal?
|
||||
if val, ok := val.(S); ok {
|
||||
return val
|
||||
}
|
||||
// TODO: Validate here
|
||||
return S{val.(types.Map)}
|
||||
return S{val.(types.Map), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s S) NomsValue() types.Value {
|
||||
// TODO: Remove this
|
||||
return s
|
||||
}
|
||||
|
||||
func (s S) InternalImplementation() types.Map {
|
||||
return s.m
|
||||
}
|
||||
|
||||
func (s S) Equals(other types.Value) bool {
|
||||
if other, ok := other.(S); ok {
|
||||
return s.m.Equals(other.m)
|
||||
return s.Ref() == other.Ref()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (s S) Ref() ref.Ref {
|
||||
return s.m.Ref()
|
||||
return types.EnsureRef(s.ref, s)
|
||||
}
|
||||
|
||||
func (s S) Chunks() (futures []types.Future) {
|
||||
@@ -103,7 +113,7 @@ func (s S) S() string {
|
||||
}
|
||||
|
||||
func (s S) SetS(val string) S {
|
||||
return S{s.m.Set(types.NewString("s"), types.NewString(val))}
|
||||
return S{s.m.Set(types.NewString("s"), types.NewString(val)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
func (s S) B() bool {
|
||||
@@ -111,7 +121,7 @@ func (s S) B() bool {
|
||||
}
|
||||
|
||||
func (s S) SetB(val bool) S {
|
||||
return S{s.m.Set(types.NewString("b"), types.Bool(val))}
|
||||
return S{s.m.Set(types.NewString("b"), types.Bool(val)), &ref.Ref{}}
|
||||
}
|
||||
|
||||
// E
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
// {{.Name}}
|
||||
|
||||
type {{.Name}} struct {
|
||||
l types.List
|
||||
}
|
||||
|
||||
func {{.Name}}FromVal(val types.Value) {{.Name}} {
|
||||
// TODO: Validate here
|
||||
return {{.Name}}{val.(types.List)}
|
||||
}
|
||||
|
||||
func (self {{.Name}}) NomsValue() types.Value {
|
||||
return self.l
|
||||
}
|
||||
|
||||
{{$name := .Name}}
|
||||
{{range $index, $field := .Choices}}
|
||||
func (self {{$name}}) {{.Name}}() ({{userType .T}}, bool) {
|
||||
if int32(self.l.Get(types.Int32(0)).(types.Int32) != {{$index}} {
|
||||
return {{userZero .T}}, false
|
||||
}
|
||||
return {{valueToUser "self.l.Get(types.Int32(1))" .T}}, true
|
||||
}
|
||||
|
||||
func (self {{$name}}) Set{{.Name}}(val {{userType .T}}) {{$name}} {
|
||||
return {{$name}}{types.NewList(types.Int32({{$index}}), {{userToValue "val" .T}})}
|
||||
}
|
||||
{{end}}
|
||||
Reference in New Issue
Block a user