From 5bda67180de043201f998ce6728b20498fbd4b5a Mon Sep 17 00:00:00 2001 From: Chris Masone Date: Thu, 5 Nov 2015 12:15:23 -0800 Subject: [PATCH] Run go generate ./... at top level to pick up codegen changes from rebase --- clients/pitchmap/index/types.noms.go | 8 +- clients/util/types.noms.go | 46 +++--- .../test/gen/struct_with_dup_list.noms.go | 141 ------------------ .../codegen/test/gen/struct_with_list.noms.go | 141 ++++++++++++++++++ 4 files changed, 175 insertions(+), 161 deletions(-) diff --git a/clients/pitchmap/index/types.noms.go b/clients/pitchmap/index/types.noms.go index a5f44e698c..7e6a6cbe72 100644 --- a/clients/pitchmap/index/types.noms.go +++ b/clients/pitchmap/index/types.noms.go @@ -433,9 +433,11 @@ func (m RefOfMapOfStringToValue) TypeRef() types.TypeRef { func init() { __typeRefForRefOfMapOfStringToValue = types.MakeCompoundTypeRef(types.RefKind, types.MakeCompoundTypeRef(types.MapKind, types.MakePrimitiveTypeRef(types.StringKind), types.MakePrimitiveTypeRef(types.ValueKind))) - types.RegisterFromValFunction(__typeRefForRefOfMapOfStringToValue, func(v types.Value) types.Value { - return NewRefOfMapOfStringToValue(v.(types.Ref).TargetRef()) - }) + types.RegisterRef(__typeRefForRefOfMapOfStringToValue, builderForRefOfMapOfStringToValue) +} + +func builderForRefOfMapOfStringToValue(r ref.Ref) types.Value { + return NewRefOfMapOfStringToValue(r) } func (r RefOfMapOfStringToValue) TargetValue(cs chunks.ChunkSource) MapOfStringToValue { diff --git a/clients/util/types.noms.go b/clients/util/types.noms.go index 7d5b5828d1..11d06e751a 100644 --- a/clients/util/types.noms.go +++ b/clients/util/types.noms.go @@ -37,10 +37,6 @@ func (l ListOfRefOfMapOfStringToValue) Def() ListOfRefOfMapOfStringToValueDef { return d } -func (l ListOfRefOfMapOfStringToValue) InternalImplementation() types.List { - return l.l -} - func (l ListOfRefOfMapOfStringToValue) Equals(other types.Value) bool { return other != nil && __typeRefForListOfRefOfMapOfStringToValue.Equals(other.TypeRef()) && l.Ref() == other.Ref() } @@ -64,9 +60,15 @@ func (m ListOfRefOfMapOfStringToValue) TypeRef() types.TypeRef { func init() { __typeRefForListOfRefOfMapOfStringToValue = types.MakeCompoundTypeRef(types.ListKind, types.MakeCompoundTypeRef(types.RefKind, types.MakeCompoundTypeRef(types.MapKind, types.MakePrimitiveTypeRef(types.StringKind), types.MakePrimitiveTypeRef(types.ValueKind)))) - types.RegisterFromValFunction(__typeRefForListOfRefOfMapOfStringToValue, func(v types.Value) types.Value { - return ListOfRefOfMapOfStringToValue{v.(types.List), &ref.Ref{}} - }) + types.RegisterValue(__typeRefForListOfRefOfMapOfStringToValue, builderForListOfRefOfMapOfStringToValue, readerForListOfRefOfMapOfStringToValue) +} + +func builderForListOfRefOfMapOfStringToValue(v types.Value) types.Value { + return ListOfRefOfMapOfStringToValue{v.(types.List), &ref.Ref{}} +} + +func readerForListOfRefOfMapOfStringToValue(v types.Value) types.Value { + return v.(ListOfRefOfMapOfStringToValue).l } func (l ListOfRefOfMapOfStringToValue) Len() uint64 { @@ -129,6 +131,12 @@ func (l ListOfRefOfMapOfStringToValue) IterAll(cb ListOfRefOfMapOfStringToValueI }) } +func (l ListOfRefOfMapOfStringToValue) IterAllP(concurrency int, cb ListOfRefOfMapOfStringToValueIterAllCallback) { + l.l.IterAllP(concurrency, func(v types.Value, i uint64) { + cb(v.(RefOfMapOfStringToValue), i) + }) +} + type ListOfRefOfMapOfStringToValueFilterCallback func(v RefOfMapOfStringToValue, i uint64) (keep bool) func (l ListOfRefOfMapOfStringToValue) Filter(cb ListOfRefOfMapOfStringToValueFilterCallback) ListOfRefOfMapOfStringToValue { @@ -179,9 +187,11 @@ func (m RefOfMapOfStringToValue) TypeRef() types.TypeRef { func init() { __typeRefForRefOfMapOfStringToValue = types.MakeCompoundTypeRef(types.RefKind, types.MakeCompoundTypeRef(types.MapKind, types.MakePrimitiveTypeRef(types.StringKind), types.MakePrimitiveTypeRef(types.ValueKind))) - types.RegisterFromValFunction(__typeRefForRefOfMapOfStringToValue, func(v types.Value) types.Value { - return NewRefOfMapOfStringToValue(v.(types.Ref).TargetRef()) - }) + types.RegisterRef(__typeRefForRefOfMapOfStringToValue, builderForRefOfMapOfStringToValue) +} + +func builderForRefOfMapOfStringToValue(r ref.Ref) types.Value { + return NewRefOfMapOfStringToValue(r) } func (r RefOfMapOfStringToValue) TargetValue(cs chunks.ChunkSource) MapOfStringToValue { @@ -222,10 +232,6 @@ func (m MapOfStringToValue) Def() MapOfStringToValueDef { return def } -func (m MapOfStringToValue) InternalImplementation() types.Map { - return m.m -} - func (m MapOfStringToValue) Equals(other types.Value) bool { return other != nil && __typeRefForMapOfStringToValue.Equals(other.TypeRef()) && m.Ref() == other.Ref() } @@ -249,9 +255,15 @@ 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.Value { - return MapOfStringToValue{v.(types.Map), &ref.Ref{}} - }) + types.RegisterValue(__typeRefForMapOfStringToValue, builderForMapOfStringToValue, readerForMapOfStringToValue) +} + +func builderForMapOfStringToValue(v types.Value) types.Value { + return MapOfStringToValue{v.(types.Map), &ref.Ref{}} +} + +func readerForMapOfStringToValue(v types.Value) types.Value { + return v.(MapOfStringToValue).m } func (m MapOfStringToValue) Empty() bool { diff --git a/nomdl/codegen/test/gen/struct_with_dup_list.noms.go b/nomdl/codegen/test/gen/struct_with_dup_list.noms.go index 28ee80462d..64b3082773 100644 --- a/nomdl/codegen/test/gen/struct_with_dup_list.noms.go +++ b/nomdl/codegen/test/gen/struct_with_dup_list.noms.go @@ -109,144 +109,3 @@ func (s StructWithDupList) SetL(val ListOfUInt8) StructWithDupList { s.ref = &ref.Ref{} return s } - -// ListOfUInt8 - -type ListOfUInt8 struct { - l types.List - ref *ref.Ref -} - -func NewListOfUInt8() ListOfUInt8 { - return ListOfUInt8{types.NewList(), &ref.Ref{}} -} - -type ListOfUInt8Def []uint8 - -func (def ListOfUInt8Def) New() ListOfUInt8 { - l := make([]types.Value, len(def)) - for i, d := range def { - l[i] = types.UInt8(d) - } - return ListOfUInt8{types.NewList(l...), &ref.Ref{}} -} - -func (l ListOfUInt8) Def() ListOfUInt8Def { - d := make([]uint8, l.Len()) - for i := uint64(0); i < l.Len(); i++ { - d[i] = uint8(l.l.Get(i).(types.UInt8)) - } - return d -} - -func (l ListOfUInt8) Equals(other types.Value) bool { - return other != nil && __typeRefForListOfUInt8.Equals(other.TypeRef()) && l.Ref() == other.Ref() -} - -func (l ListOfUInt8) Ref() ref.Ref { - return types.EnsureRef(l.ref, l) -} - -func (l ListOfUInt8) Chunks() (chunks []ref.Ref) { - chunks = append(chunks, l.TypeRef().Chunks()...) - chunks = append(chunks, l.l.Chunks()...) - return -} - -// A Noms Value that describes ListOfUInt8. -var __typeRefForListOfUInt8 types.TypeRef - -func (m ListOfUInt8) TypeRef() types.TypeRef { - return __typeRefForListOfUInt8 -} - -func init() { - __typeRefForListOfUInt8 = types.MakeCompoundTypeRef(types.ListKind, types.MakePrimitiveTypeRef(types.UInt8Kind)) - types.RegisterValue(__typeRefForListOfUInt8, builderForListOfUInt8, readerForListOfUInt8) -} - -func builderForListOfUInt8(v types.Value) types.Value { - return ListOfUInt8{v.(types.List), &ref.Ref{}} -} - -func readerForListOfUInt8(v types.Value) types.Value { - return v.(ListOfUInt8).l -} - -func (l ListOfUInt8) Len() uint64 { - return l.l.Len() -} - -func (l ListOfUInt8) Empty() bool { - return l.Len() == uint64(0) -} - -func (l ListOfUInt8) Get(i uint64) uint8 { - return uint8(l.l.Get(i).(types.UInt8)) -} - -func (l ListOfUInt8) Slice(idx uint64, end uint64) ListOfUInt8 { - 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)), &ref.Ref{}} -} - -func (l ListOfUInt8) Append(v ...uint8) ListOfUInt8 { - 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)...), &ref.Ref{}} -} - -func (l ListOfUInt8) Remove(idx uint64, end uint64) ListOfUInt8 { - return ListOfUInt8{l.l.Remove(idx, end), &ref.Ref{}} -} - -func (l ListOfUInt8) RemoveAt(idx uint64) ListOfUInt8 { - return ListOfUInt8{(l.l.RemoveAt(idx)), &ref.Ref{}} -} - -func (l ListOfUInt8) fromElemSlice(p []uint8) []types.Value { - r := make([]types.Value, len(p)) - for i, v := range p { - r[i] = types.UInt8(v) - } - return r -} - -type ListOfUInt8IterCallback func(v uint8, i uint64) (stop bool) - -func (l ListOfUInt8) Iter(cb ListOfUInt8IterCallback) { - l.l.Iter(func(v types.Value, i uint64) bool { - return cb(uint8(v.(types.UInt8)), i) - }) -} - -type ListOfUInt8IterAllCallback func(v uint8, i uint64) - -func (l ListOfUInt8) IterAll(cb ListOfUInt8IterAllCallback) { - l.l.IterAll(func(v types.Value, i uint64) { - cb(uint8(v.(types.UInt8)), i) - }) -} - -func (l ListOfUInt8) IterAllP(concurrency int, cb ListOfUInt8IterAllCallback) { - l.l.IterAllP(concurrency, func(v types.Value, i uint64) { - cb(uint8(v.(types.UInt8)), i) - }) -} - -type ListOfUInt8FilterCallback func(v uint8, i uint64) (keep bool) - -func (l ListOfUInt8) Filter(cb ListOfUInt8FilterCallback) ListOfUInt8 { - nl := NewListOfUInt8() - l.IterAll(func(v uint8, i uint64) { - if cb(v, i) { - nl = nl.Append(v) - } - }) - return nl -} diff --git a/nomdl/codegen/test/gen/struct_with_list.noms.go b/nomdl/codegen/test/gen/struct_with_list.noms.go index f1a708ddb6..5079ff0929 100644 --- a/nomdl/codegen/test/gen/struct_with_list.noms.go +++ b/nomdl/codegen/test/gen/struct_with_list.noms.go @@ -163,3 +163,144 @@ func (s StructWithList) SetI(val int64) StructWithList { s.ref = &ref.Ref{} return s } + +// ListOfUInt8 + +type ListOfUInt8 struct { + l types.List + ref *ref.Ref +} + +func NewListOfUInt8() ListOfUInt8 { + return ListOfUInt8{types.NewList(), &ref.Ref{}} +} + +type ListOfUInt8Def []uint8 + +func (def ListOfUInt8Def) New() ListOfUInt8 { + l := make([]types.Value, len(def)) + for i, d := range def { + l[i] = types.UInt8(d) + } + return ListOfUInt8{types.NewList(l...), &ref.Ref{}} +} + +func (l ListOfUInt8) Def() ListOfUInt8Def { + d := make([]uint8, l.Len()) + for i := uint64(0); i < l.Len(); i++ { + d[i] = uint8(l.l.Get(i).(types.UInt8)) + } + return d +} + +func (l ListOfUInt8) Equals(other types.Value) bool { + return other != nil && __typeRefForListOfUInt8.Equals(other.TypeRef()) && l.Ref() == other.Ref() +} + +func (l ListOfUInt8) Ref() ref.Ref { + return types.EnsureRef(l.ref, l) +} + +func (l ListOfUInt8) Chunks() (chunks []ref.Ref) { + chunks = append(chunks, l.TypeRef().Chunks()...) + chunks = append(chunks, l.l.Chunks()...) + return +} + +// A Noms Value that describes ListOfUInt8. +var __typeRefForListOfUInt8 types.TypeRef + +func (m ListOfUInt8) TypeRef() types.TypeRef { + return __typeRefForListOfUInt8 +} + +func init() { + __typeRefForListOfUInt8 = types.MakeCompoundTypeRef(types.ListKind, types.MakePrimitiveTypeRef(types.UInt8Kind)) + types.RegisterValue(__typeRefForListOfUInt8, builderForListOfUInt8, readerForListOfUInt8) +} + +func builderForListOfUInt8(v types.Value) types.Value { + return ListOfUInt8{v.(types.List), &ref.Ref{}} +} + +func readerForListOfUInt8(v types.Value) types.Value { + return v.(ListOfUInt8).l +} + +func (l ListOfUInt8) Len() uint64 { + return l.l.Len() +} + +func (l ListOfUInt8) Empty() bool { + return l.Len() == uint64(0) +} + +func (l ListOfUInt8) Get(i uint64) uint8 { + return uint8(l.l.Get(i).(types.UInt8)) +} + +func (l ListOfUInt8) Slice(idx uint64, end uint64) ListOfUInt8 { + 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)), &ref.Ref{}} +} + +func (l ListOfUInt8) Append(v ...uint8) ListOfUInt8 { + 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)...), &ref.Ref{}} +} + +func (l ListOfUInt8) Remove(idx uint64, end uint64) ListOfUInt8 { + return ListOfUInt8{l.l.Remove(idx, end), &ref.Ref{}} +} + +func (l ListOfUInt8) RemoveAt(idx uint64) ListOfUInt8 { + return ListOfUInt8{(l.l.RemoveAt(idx)), &ref.Ref{}} +} + +func (l ListOfUInt8) fromElemSlice(p []uint8) []types.Value { + r := make([]types.Value, len(p)) + for i, v := range p { + r[i] = types.UInt8(v) + } + return r +} + +type ListOfUInt8IterCallback func(v uint8, i uint64) (stop bool) + +func (l ListOfUInt8) Iter(cb ListOfUInt8IterCallback) { + l.l.Iter(func(v types.Value, i uint64) bool { + return cb(uint8(v.(types.UInt8)), i) + }) +} + +type ListOfUInt8IterAllCallback func(v uint8, i uint64) + +func (l ListOfUInt8) IterAll(cb ListOfUInt8IterAllCallback) { + l.l.IterAll(func(v types.Value, i uint64) { + cb(uint8(v.(types.UInt8)), i) + }) +} + +func (l ListOfUInt8) IterAllP(concurrency int, cb ListOfUInt8IterAllCallback) { + l.l.IterAllP(concurrency, func(v types.Value, i uint64) { + cb(uint8(v.(types.UInt8)), i) + }) +} + +type ListOfUInt8FilterCallback func(v uint8, i uint64) (keep bool) + +func (l ListOfUInt8) Filter(cb ListOfUInt8FilterCallback) ListOfUInt8 { + nl := NewListOfUInt8() + l.IterAll(func(v uint8, i uint64) { + if cb(v, i) { + nl = nl.Append(v) + } + }) + return nl +}