From 2e290f6d9d53f70d6992ada9b195a6872713ad68 Mon Sep 17 00:00:00 2001 From: Patrick Stephen Date: Fri, 10 Nov 2023 10:22:05 -0600 Subject: [PATCH 1/5] Bump to go 1.21 --- .github/workflows/go.yml | 2 +- go.mod | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index be56e04..c61646a 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -16,7 +16,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v2 with: - go-version: "1.20" + go-version: "1.21" - name: Build run: go build -v ./... diff --git a/go.mod b/go.mod index 6136433..fafef5e 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,3 @@ module github.com/200sc/bebop -go 1.20 +go 1.21 From cbdd7e8787bffcc3c5c9a5d684826f4012b2a99f Mon Sep 17 00:00:00 2001 From: Patrick Stephen Date: Thu, 21 Mar 2024 13:41:55 -0500 Subject: [PATCH 2/5] block around tmp in size calculations An alternate implementation, using incrementing tmp variable names, was reverted in 09ebd16fcf18d305ce02d44e7604334f3d782846. Restoring that logic would re-introduce nondeterministic tmp variable name generation when executing file generation in parallel. Block wrapping is preferred to keep our tests parallel and keep the generation of files less stateful and more concurrent-safe for use as a library. --- gen_templates.go | 4 +- testdata/generated-always-pointers/foo.go | 28 +- testdata/generated-always-pointers/fruit.go | 259 ++++++++++++++++++ testdata/generated-always-pointers/jazz.go | 56 ++-- testdata/generated-always-pointers/lab.go | 84 ++++-- .../generated-always-pointers/map_types.go | 56 ++-- testdata/generated-always-pointers/request.go | 28 +- testdata/generated-always-pointers/server.go | 56 ++-- testdata/generated-always-pointers/tags.go | 28 +- testdata/generated-always-pointers/union.go | 168 ++++++++---- .../generated-always-pointers/union_field.go | 84 ++++-- testdata/generated-private/foo.go | 28 +- testdata/generated-private/fruit.go | 259 ++++++++++++++++++ testdata/generated-private/jazz.go | 56 ++-- testdata/generated-private/lab.go | 84 ++++-- testdata/generated-private/map_types.go | 56 ++-- testdata/generated-private/request.go | 28 +- testdata/generated-private/server.go | 56 ++-- testdata/generated-private/tags.go | 28 +- testdata/generated-private/union.go | 168 ++++++++---- testdata/generated-private/union_field.go | 84 ++++-- testdata/generated/foo.go | 28 +- testdata/generated/import_b/import_b.go | 140 +++++++--- testdata/generated/jazz.go | 56 ++-- testdata/generated/lab.go | 84 ++++-- testdata/generated/map_types.go | 56 ++-- testdata/generated/request.go | 28 +- testdata/generated/server.go | 56 ++-- testdata/generated/tags.go | 28 +- testdata/generated/union.go | 168 ++++++++---- testdata/generated/union_field.go | 84 ++++-- .../generated/import_separate_a.go | 112 +++++--- .../generatedtwo/import_separate_b.go | 112 +++++--- 33 files changed, 2040 insertions(+), 610 deletions(-) create mode 100644 testdata/generated-always-pointers/fruit.go create mode 100644 testdata/generated-private/fruit.go diff --git a/gen_templates.go b/gen_templates.go index 2e530f2..ac499a2 100644 --- a/gen_templates.go +++ b/gen_templates.go @@ -64,9 +64,9 @@ const ( hintSafeKey = "&safe" fmtErrReturn = "if err != nil {\n\treturn err\n}" - fmtAddSizeToAt = "tmp := (%ASGN)\nat += tmp.Size()" + fmtAddSizeToAt = "{\n\ttmp := (%ASGN)\n\tat += tmp.Size()\n}\n" fmtAdd4PlusLenToAt = "at += 4 + len(%ASGN)" - fmtAddSizeToBodyLen = "tmp := (%ASGN)\nbodyLen += tmp.Size()" + fmtAddSizeToBodyLen = "{\n\ttmp := (%ASGN)\n\tbodyLen += tmp.Size()\n}\n" fmtAdd4PlusLenToBodyLen = "bodyLen += 4 + len(%ASGN)" fmtMakeType = "(%RECV), err = Make%TYPE(r)\n" + fmtErrReturn diff --git a/testdata/generated-always-pointers/foo.go b/testdata/generated-always-pointers/foo.go index 10a35df..52a468c 100644 --- a/testdata/generated-always-pointers/foo.go +++ b/testdata/generated-always-pointers/foo.go @@ -17,8 +17,11 @@ type Foo struct { func (bbp *Foo) MarshalBebopTo(buf []byte) int { at := 0 (bbp.Bar).MarshalBebopTo(buf[at:]) - tmp := (bbp.Bar) - at += tmp.Size() + { + tmp := (bbp.Bar) + at += tmp.Size() + } + return at } @@ -28,16 +31,22 @@ func (bbp *Foo) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := (bbp.Bar) - at += tmp.Size() + { + tmp := (bbp.Bar) + at += tmp.Size() + } + return nil } func (bbp *Foo) MustUnmarshalBebop(buf []byte) { at := 0 bbp.Bar = MustMakeBarFromBytes(buf[at:]) - tmp := (bbp.Bar) - at += tmp.Size() + { + tmp := (bbp.Bar) + at += tmp.Size() + } + } func (bbp *Foo) EncodeBebop(iow io.Writer) (err error) { @@ -60,8 +69,11 @@ func (bbp *Foo) DecodeBebop(ior io.Reader) (err error) { func (bbp *Foo) Size() int { bodyLen := 0 - tmp := (bbp.Bar) - bodyLen += tmp.Size() + { + tmp := (bbp.Bar) + bodyLen += tmp.Size() + } + return bodyLen } diff --git a/testdata/generated-always-pointers/fruit.go b/testdata/generated-always-pointers/fruit.go new file mode 100644 index 0000000..fe9c1c9 --- /dev/null +++ b/testdata/generated-always-pointers/fruit.go @@ -0,0 +1,259 @@ +// Code generated by bebopc-go; DO NOT EDIT. + +package generated + +import ( + "github.com/200sc/bebop" + "github.com/200sc/bebop/iohelp" + "io" +) + +var _ bebop.Record = &Fruit{} + +type Fruit struct { + ID uint64 + Name string +} + +func (bbp *Fruit) MarshalBebopTo(buf []byte) int { + at := 0 + iohelp.WriteUint64Bytes(buf[at:], bbp.ID) + at += 8 + iohelp.WriteUint32Bytes(buf[at:], uint32(len(bbp.Name))) + copy(buf[at+4:at+4+len(bbp.Name)], []byte(bbp.Name)) + at += 4 + len(bbp.Name) + return at +} + +func (bbp *Fruit) UnmarshalBebop(buf []byte) (err error) { + at := 0 + if len(buf[at:]) < 8 { + return io.ErrUnexpectedEOF + } + bbp.ID = iohelp.ReadUint64Bytes(buf[at:]) + at += 8 + bbp.Name, err = iohelp.ReadStringBytes(buf[at:]) + if err != nil { + return err + } + at += 4 + len(bbp.Name) + return nil +} + +func (bbp *Fruit) MustUnmarshalBebop(buf []byte) { + at := 0 + bbp.ID = iohelp.ReadUint64Bytes(buf[at:]) + at += 8 + bbp.Name = iohelp.MustReadStringBytes(buf[at:]) + at += 4 + len(bbp.Name) +} + +func (bbp *Fruit) EncodeBebop(iow io.Writer) (err error) { + w := iohelp.NewErrorWriter(iow) + iohelp.WriteUint64(w, bbp.ID) + iohelp.WriteUint32(w, uint32(len(bbp.Name))) + w.Write([]byte(bbp.Name)) + return w.Err +} + +func (bbp *Fruit) DecodeBebop(ior io.Reader) (err error) { + r := iohelp.NewErrorReader(ior) + bbp.ID = iohelp.ReadUint64(r) + bbp.Name = iohelp.ReadString(r) + return r.Err +} + +func (bbp *Fruit) Size() int { + bodyLen := 0 + bodyLen += 8 + bodyLen += 4 + len(bbp.Name) + return bodyLen +} + +func (bbp *Fruit) MarshalBebop() []byte { + buf := make([]byte, bbp.Size()) + bbp.MarshalBebopTo(buf) + return buf +} + +func MakeFruit(r *iohelp.ErrorReader) (Fruit, error) { + v := Fruit{} + err := v.DecodeBebop(r) + return v, err +} + +func MakeFruitFromBytes(buf []byte) (Fruit, error) { + v := Fruit{} + err := v.UnmarshalBebop(buf) + return v, err +} + +func MustMakeFruitFromBytes(buf []byte) Fruit { + v := Fruit{} + v.MustUnmarshalBebop(buf) + return v +} + +var _ bebop.Record = &Basket{} + +type Basket struct { + Apples Fruit + Oranges Fruit + Mangos Fruit +} + +func (bbp *Basket) MarshalBebopTo(buf []byte) int { + at := 0 + (bbp.Apples).MarshalBebopTo(buf[at:]) + { + tmp := (bbp.Apples) + at += tmp.Size() + } + + (bbp.Oranges).MarshalBebopTo(buf[at:]) + { + tmp := (bbp.Oranges) + at += tmp.Size() + } + + (bbp.Mangos).MarshalBebopTo(buf[at:]) + { + tmp := (bbp.Mangos) + at += tmp.Size() + } + + return at +} + +func (bbp *Basket) UnmarshalBebop(buf []byte) (err error) { + at := 0 + bbp.Apples, err = MakeFruitFromBytes(buf[at:]) + if err != nil { + return err + } + { + tmp := (bbp.Apples) + at += tmp.Size() + } + + bbp.Oranges, err = MakeFruitFromBytes(buf[at:]) + if err != nil { + return err + } + { + tmp := (bbp.Oranges) + at += tmp.Size() + } + + bbp.Mangos, err = MakeFruitFromBytes(buf[at:]) + if err != nil { + return err + } + { + tmp := (bbp.Mangos) + at += tmp.Size() + } + + return nil +} + +func (bbp *Basket) MustUnmarshalBebop(buf []byte) { + at := 0 + bbp.Apples = MustMakeFruitFromBytes(buf[at:]) + { + tmp := (bbp.Apples) + at += tmp.Size() + } + + bbp.Oranges = MustMakeFruitFromBytes(buf[at:]) + { + tmp := (bbp.Oranges) + at += tmp.Size() + } + + bbp.Mangos = MustMakeFruitFromBytes(buf[at:]) + { + tmp := (bbp.Mangos) + at += tmp.Size() + } + +} + +func (bbp *Basket) EncodeBebop(iow io.Writer) (err error) { + w := iohelp.NewErrorWriter(iow) + err = (bbp.Apples).EncodeBebop(w) + if err != nil { + return err + } + err = (bbp.Oranges).EncodeBebop(w) + if err != nil { + return err + } + err = (bbp.Mangos).EncodeBebop(w) + if err != nil { + return err + } + return w.Err +} + +func (bbp *Basket) DecodeBebop(ior io.Reader) (err error) { + r := iohelp.NewErrorReader(ior) + (bbp.Apples), err = MakeFruit(r) + if err != nil { + return err + } + (bbp.Oranges), err = MakeFruit(r) + if err != nil { + return err + } + (bbp.Mangos), err = MakeFruit(r) + if err != nil { + return err + } + return r.Err +} + +func (bbp *Basket) Size() int { + bodyLen := 0 + { + tmp := (bbp.Apples) + bodyLen += tmp.Size() + } + + { + tmp := (bbp.Oranges) + bodyLen += tmp.Size() + } + + { + tmp := (bbp.Mangos) + bodyLen += tmp.Size() + } + + return bodyLen +} + +func (bbp *Basket) MarshalBebop() []byte { + buf := make([]byte, bbp.Size()) + bbp.MarshalBebopTo(buf) + return buf +} + +func MakeBasket(r *iohelp.ErrorReader) (Basket, error) { + v := Basket{} + err := v.DecodeBebop(r) + return v, err +} + +func MakeBasketFromBytes(buf []byte) (Basket, error) { + v := Basket{} + err := v.UnmarshalBebop(buf) + return v, err +} + +func MustMakeBasketFromBytes(buf []byte) Basket { + v := Basket{} + v.MustUnmarshalBebop(buf) + return v +} + diff --git a/testdata/generated-always-pointers/jazz.go b/testdata/generated-always-pointers/jazz.go index e297110..4728c36 100644 --- a/testdata/generated-always-pointers/jazz.go +++ b/testdata/generated-always-pointers/jazz.go @@ -131,8 +131,11 @@ func (bbp *Library) MarshalBebopTo(buf []byte) int { iohelp.WriteGUIDBytes(buf[at:], k1) at += 16 (v1).MarshalBebopTo(buf[at:]) - tmp := (v1) - at += tmp.Size() + { + tmp := (v1) + at += tmp.Size() + } + } return at } @@ -152,8 +155,11 @@ func (bbp *Library) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := ((bbp.Songs)[k1]) - at += tmp.Size() + { + tmp := ((bbp.Songs)[k1]) + at += tmp.Size() + } + } return nil } @@ -167,8 +173,11 @@ func (bbp *Library) MustUnmarshalBebop(buf []byte) { k1 := iohelp.ReadGUIDBytes(buf[at:]) at += 16 (bbp.Songs)[k1] = MustMakeSongFromBytes(buf[at:]) - tmp := ((bbp.Songs)[k1]) - at += tmp.Size() + { + tmp := ((bbp.Songs)[k1]) + at += tmp.Size() + } + } } @@ -204,8 +213,11 @@ func (bbp *Library) Size() int { bodyLen += 4 for _, v1 := range bbp.Songs { bodyLen += 16 - tmp := (v1) - bodyLen += tmp.Size() + { + tmp := (v1) + bodyLen += tmp.Size() + } + } return bodyLen } @@ -266,8 +278,11 @@ func (bbp *Song) MarshalBebopTo(buf []byte) int { at += 4 for _, v2 := range *bbp.Performers { (v2).MarshalBebopTo(buf[at:]) - tmp := (v2) - at += tmp.Size() + { + tmp := (v2) + at += tmp.Size() + } + } } return at @@ -308,8 +323,11 @@ func (bbp *Song) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := (((*bbp.Performers))[i3]) - at += tmp.Size() + { + tmp := (((*bbp.Performers))[i3]) + at += tmp.Size() + } + } default: return nil @@ -340,8 +358,11 @@ func (bbp *Song) MustUnmarshalBebop(buf []byte) { at += 4 for i3 := range (*bbp.Performers) { ((*bbp.Performers))[i3] = MustMakeMusicianFromBytes(buf[at:]) - tmp := (((*bbp.Performers))[i3]) - at += tmp.Size() + { + tmp := (((*bbp.Performers))[i3]) + at += tmp.Size() + } + } default: return @@ -417,8 +438,11 @@ func (bbp *Song) Size() int { bodyLen += 1 bodyLen += 4 for _, elem := range *bbp.Performers { - tmp := (elem) - bodyLen += tmp.Size() + { + tmp := (elem) + bodyLen += tmp.Size() + } + } } return bodyLen diff --git a/testdata/generated-always-pointers/lab.go b/testdata/generated-always-pointers/lab.go index 94cf220..2f091c3 100644 --- a/testdata/generated-always-pointers/lab.go +++ b/testdata/generated-always-pointers/lab.go @@ -716,8 +716,11 @@ func (bbp *MediaMessage) MarshalBebopTo(buf []byte) int { buf[at] = 2 at++ (*bbp.Data).MarshalBebopTo(buf[at:]) - tmp := (*bbp.Data) - at += tmp.Size() + { + tmp := (*bbp.Data) + at += tmp.Size() + } + } return at } @@ -740,8 +743,11 @@ func (bbp *MediaMessage) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := ((*bbp.Data)) - at += tmp.Size() + { + tmp := ((*bbp.Data)) + at += tmp.Size() + } + default: return nil } @@ -763,8 +769,11 @@ func (bbp *MediaMessage) MustUnmarshalBebop(buf []byte) { at += 1 bbp.Data = new(VideoData) (*bbp.Data) = MustMakeVideoDataFromBytes(buf[at:]) - tmp := ((*bbp.Data)) - at += tmp.Size() + { + tmp := ((*bbp.Data)) + at += tmp.Size() + } + default: return } @@ -819,8 +828,11 @@ func (bbp *MediaMessage) Size() int { } if bbp.Data != nil { bodyLen += 1 - tmp := (*bbp.Data) - bodyLen += tmp.Size() + { + tmp := (*bbp.Data) + bodyLen += tmp.Size() + } + } return bodyLen } @@ -1190,8 +1202,11 @@ func (bbp *SkipTestOldContainer) MarshalBebopTo(buf []byte) int { buf[at] = 1 at++ (*bbp.S).MarshalBebopTo(buf[at:]) - tmp := (*bbp.S) - at += tmp.Size() + { + tmp := (*bbp.S) + at += tmp.Size() + } + } if bbp.After != nil { buf[at] = 2 @@ -1215,8 +1230,11 @@ func (bbp *SkipTestOldContainer) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := ((*bbp.S)) - at += tmp.Size() + { + tmp := ((*bbp.S)) + at += tmp.Size() + } + case 2: at += 1 bbp.After = new(int32) @@ -1241,8 +1259,11 @@ func (bbp *SkipTestOldContainer) MustUnmarshalBebop(buf []byte) { at += 1 bbp.S = new(SkipTestOld) (*bbp.S) = MustMakeSkipTestOldFromBytes(buf[at:]) - tmp := ((*bbp.S)) - at += tmp.Size() + { + tmp := ((*bbp.S)) + at += tmp.Size() + } + case 2: at += 1 bbp.After = new(int32) @@ -1298,8 +1319,11 @@ func (bbp *SkipTestOldContainer) Size() int { bodyLen := 5 if bbp.S != nil { bodyLen += 1 - tmp := (*bbp.S) - bodyLen += tmp.Size() + { + tmp := (*bbp.S) + bodyLen += tmp.Size() + } + } if bbp.After != nil { bodyLen += 1 @@ -1347,8 +1371,11 @@ func (bbp *SkipTestNewContainer) MarshalBebopTo(buf []byte) int { buf[at] = 1 at++ (*bbp.S).MarshalBebopTo(buf[at:]) - tmp := (*bbp.S) - at += tmp.Size() + { + tmp := (*bbp.S) + at += tmp.Size() + } + } if bbp.After != nil { buf[at] = 2 @@ -1372,8 +1399,11 @@ func (bbp *SkipTestNewContainer) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := ((*bbp.S)) - at += tmp.Size() + { + tmp := ((*bbp.S)) + at += tmp.Size() + } + case 2: at += 1 bbp.After = new(int32) @@ -1398,8 +1428,11 @@ func (bbp *SkipTestNewContainer) MustUnmarshalBebop(buf []byte) { at += 1 bbp.S = new(SkipTestNew) (*bbp.S) = MustMakeSkipTestNewFromBytes(buf[at:]) - tmp := ((*bbp.S)) - at += tmp.Size() + { + tmp := ((*bbp.S)) + at += tmp.Size() + } + case 2: at += 1 bbp.After = new(int32) @@ -1455,8 +1488,11 @@ func (bbp *SkipTestNewContainer) Size() int { bodyLen := 5 if bbp.S != nil { bodyLen += 1 - tmp := (*bbp.S) - bodyLen += tmp.Size() + { + tmp := (*bbp.S) + bodyLen += tmp.Size() + } + } if bbp.After != nil { bodyLen += 1 diff --git a/testdata/generated-always-pointers/map_types.go b/testdata/generated-always-pointers/map_types.go index c8a4cd9..57d4b92 100644 --- a/testdata/generated-always-pointers/map_types.go +++ b/testdata/generated-always-pointers/map_types.go @@ -164,8 +164,11 @@ func (bbp *SomeMaps) MarshalBebopTo(buf []byte) int { iohelp.WriteBoolBytes(buf[at:], k4) at += 1 (v4).MarshalBebopTo(buf[at:]) - tmp := (v4) - at += tmp.Size() + { + tmp := (v4) + at += tmp.Size() + } + } } } @@ -193,8 +196,11 @@ func (bbp *SomeMaps) MarshalBebopTo(buf []byte) int { iohelp.WriteGUIDBytes(buf[at:], k1) at += 16 (v1).MarshalBebopTo(buf[at:]) - tmp := (v1) - at += tmp.Size() + { + tmp := (v1) + at += tmp.Size() + } + } return at } @@ -275,8 +281,11 @@ func (bbp *SomeMaps) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := (((((bbp.M3)[i1])[k2])[i3])[k4]) - at += tmp.Size() + { + tmp := (((((bbp.M3)[i1])[k2])[i3])[k4]) + at += tmp.Size() + } + } } } @@ -323,8 +332,11 @@ func (bbp *SomeMaps) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := ((bbp.M5)[k1]) - at += tmp.Size() + { + tmp := ((bbp.M5)[k1]) + at += tmp.Size() + } + } return nil } @@ -375,8 +387,11 @@ func (bbp *SomeMaps) MustUnmarshalBebop(buf []byte) { k4 := iohelp.ReadBoolBytes(buf[at:]) at += 1 ((((bbp.M3)[i1])[k2])[i3])[k4] = MustMakeSFromBytes(buf[at:]) - tmp := (((((bbp.M3)[i1])[k2])[i3])[k4]) - at += tmp.Size() + { + tmp := (((((bbp.M3)[i1])[k2])[i3])[k4]) + at += tmp.Size() + } + } } } @@ -405,8 +420,11 @@ func (bbp *SomeMaps) MustUnmarshalBebop(buf []byte) { k1 := iohelp.ReadGUIDBytes(buf[at:]) at += 16 (bbp.M5)[k1] = MustMakeMFromBytes(buf[at:]) - tmp := ((bbp.M5)[k1]) - at += tmp.Size() + { + tmp := ((bbp.M5)[k1]) + at += tmp.Size() + } + } } @@ -559,8 +577,11 @@ func (bbp *SomeMaps) Size() int { bodyLen += 4 for _, v4 := range elem { bodyLen += 1 - tmp := (v4) - bodyLen += tmp.Size() + { + tmp := (v4) + bodyLen += tmp.Size() + } + } } } @@ -577,8 +598,11 @@ func (bbp *SomeMaps) Size() int { bodyLen += 4 for _, v1 := range bbp.M5 { bodyLen += 16 - tmp := (v1) - bodyLen += tmp.Size() + { + tmp := (v1) + bodyLen += tmp.Size() + } + } return bodyLen } diff --git a/testdata/generated-always-pointers/request.go b/testdata/generated-always-pointers/request.go index 6a1d5dc..de69561 100644 --- a/testdata/generated-always-pointers/request.go +++ b/testdata/generated-always-pointers/request.go @@ -150,8 +150,11 @@ func (bbp *RequestResponse) MarshalBebopTo(buf []byte) int { at += 4 for _, v1 := range bbp.availableFurniture { (v1).MarshalBebopTo(buf[at:]) - tmp := (v1) - at += tmp.Size() + { + tmp := (v1) + at += tmp.Size() + } + } return at } @@ -168,8 +171,11 @@ func (bbp *RequestResponse) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := ((bbp.availableFurniture)[i1]) - at += tmp.Size() + { + tmp := ((bbp.availableFurniture)[i1]) + at += tmp.Size() + } + } return nil } @@ -180,8 +186,11 @@ func (bbp *RequestResponse) MustUnmarshalBebop(buf []byte) { at += 4 for i1 := range bbp.availableFurniture { (bbp.availableFurniture)[i1] = MustMakeFurnitureFromBytes(buf[at:]) - tmp := ((bbp.availableFurniture)[i1]) - at += tmp.Size() + { + tmp := ((bbp.availableFurniture)[i1]) + at += tmp.Size() + } + } } @@ -213,8 +222,11 @@ func (bbp *RequestResponse) Size() int { bodyLen := 0 bodyLen += 4 for _, elem := range bbp.availableFurniture { - tmp := (elem) - bodyLen += tmp.Size() + { + tmp := (elem) + bodyLen += tmp.Size() + } + } return bodyLen } diff --git a/testdata/generated-always-pointers/server.go b/testdata/generated-always-pointers/server.go index 387c5bf..0964127 100644 --- a/testdata/generated-always-pointers/server.go +++ b/testdata/generated-always-pointers/server.go @@ -252,8 +252,11 @@ func (bbp *PrintRequest) MarshalBebopTo(buf []byte) int { buf[at] = 1 at++ (*bbp.Print).MarshalBebopTo(buf[at:]) - tmp := (*bbp.Print) - at += tmp.Size() + { + tmp := (*bbp.Print) + at += tmp.Size() + } + } return at } @@ -271,8 +274,11 @@ func (bbp *PrintRequest) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := ((*bbp.Print)) - at += tmp.Size() + { + tmp := ((*bbp.Print)) + at += tmp.Size() + } + default: return nil } @@ -289,8 +295,11 @@ func (bbp *PrintRequest) MustUnmarshalBebop(buf []byte) { at += 1 bbp.Print = new(Print) (*bbp.Print) = MustMakePrintFromBytes(buf[at:]) - tmp := ((*bbp.Print)) - at += tmp.Size() + { + tmp := ((*bbp.Print)) + at += tmp.Size() + } + default: return } @@ -334,8 +343,11 @@ func (bbp *PrintRequest) Size() int { bodyLen := 5 if bbp.Print != nil { bodyLen += 1 - tmp := (*bbp.Print) - bodyLen += tmp.Size() + { + tmp := (*bbp.Print) + bodyLen += tmp.Size() + } + } return bodyLen } @@ -380,8 +392,11 @@ func (bbp *AddRequest) MarshalBebopTo(buf []byte) int { buf[at] = 1 at++ (*bbp.Add).MarshalBebopTo(buf[at:]) - tmp := (*bbp.Add) - at += tmp.Size() + { + tmp := (*bbp.Add) + at += tmp.Size() + } + } return at } @@ -399,8 +414,11 @@ func (bbp *AddRequest) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := ((*bbp.Add)) - at += tmp.Size() + { + tmp := ((*bbp.Add)) + at += tmp.Size() + } + default: return nil } @@ -417,8 +435,11 @@ func (bbp *AddRequest) MustUnmarshalBebop(buf []byte) { at += 1 bbp.Add = new(Add) (*bbp.Add) = MustMakeAddFromBytes(buf[at:]) - tmp := ((*bbp.Add)) - at += tmp.Size() + { + tmp := ((*bbp.Add)) + at += tmp.Size() + } + default: return } @@ -462,8 +483,11 @@ func (bbp *AddRequest) Size() int { bodyLen := 5 if bbp.Add != nil { bodyLen += 1 - tmp := (*bbp.Add) - bodyLen += tmp.Size() + { + tmp := (*bbp.Add) + bodyLen += tmp.Size() + } + } return bodyLen } diff --git a/testdata/generated-always-pointers/tags.go b/testdata/generated-always-pointers/tags.go index 60cf7cd..9f648bb 100644 --- a/testdata/generated-always-pointers/tags.go +++ b/testdata/generated-always-pointers/tags.go @@ -282,8 +282,11 @@ func (bbp *TaggedUnion) MarshalBebopTo(buf []byte) int { buf[at] = 1 at++ (*bbp.TaggedSubStruct).MarshalBebopTo(buf[at:]) - tmp := (*bbp.TaggedSubStruct) - at += tmp.Size() + { + tmp := (*bbp.TaggedSubStruct) + at += tmp.Size() + } + return at } return at @@ -305,8 +308,11 @@ func (bbp *TaggedUnion) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := ((*bbp.TaggedSubStruct)) - at += tmp.Size() + { + tmp := ((*bbp.TaggedSubStruct)) + at += tmp.Size() + } + return nil default: return nil @@ -324,8 +330,11 @@ func (bbp *TaggedUnion) MustUnmarshalBebop(buf []byte) { at += 1 bbp.TaggedSubStruct = new(TaggedSubStruct) (*bbp.TaggedSubStruct) = MustMakeTaggedSubStructFromBytes(buf[at:]) - tmp := ((*bbp.TaggedSubStruct)) - at += tmp.Size() + { + tmp := ((*bbp.TaggedSubStruct)) + at += tmp.Size() + } + return default: return @@ -372,8 +381,11 @@ func (bbp *TaggedUnion) Size() int { bodyLen := 4 if bbp.TaggedSubStruct != nil { bodyLen += 1 - tmp := (*bbp.TaggedSubStruct) - bodyLen += tmp.Size() + { + tmp := (*bbp.TaggedSubStruct) + bodyLen += tmp.Size() + } + return bodyLen } return bodyLen diff --git a/testdata/generated-always-pointers/union.go b/testdata/generated-always-pointers/union.go index 2c35909..38e54e0 100644 --- a/testdata/generated-always-pointers/union.go +++ b/testdata/generated-always-pointers/union.go @@ -263,24 +263,33 @@ func (bbp *U) MarshalBebopTo(buf []byte) int { buf[at] = 1 at++ (*bbp.A).MarshalBebopTo(buf[at:]) - tmp := (*bbp.A) - at += tmp.Size() + { + tmp := (*bbp.A) + at += tmp.Size() + } + return at } if bbp.B != nil { buf[at] = 2 at++ (*bbp.B).MarshalBebopTo(buf[at:]) - tmp := (*bbp.B) - at += tmp.Size() + { + tmp := (*bbp.B) + at += tmp.Size() + } + return at } if bbp.C != nil { buf[at] = 3 at++ (*bbp.C).MarshalBebopTo(buf[at:]) - tmp := (*bbp.C) - at += tmp.Size() + { + tmp := (*bbp.C) + at += tmp.Size() + } + return at } return at @@ -302,8 +311,11 @@ func (bbp *U) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := ((*bbp.A)) - at += tmp.Size() + { + tmp := ((*bbp.A)) + at += tmp.Size() + } + return nil case 2: at += 1 @@ -312,8 +324,11 @@ func (bbp *U) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := ((*bbp.B)) - at += tmp.Size() + { + tmp := ((*bbp.B)) + at += tmp.Size() + } + return nil case 3: at += 1 @@ -322,8 +337,11 @@ func (bbp *U) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := ((*bbp.C)) - at += tmp.Size() + { + tmp := ((*bbp.C)) + at += tmp.Size() + } + return nil default: return nil @@ -341,22 +359,31 @@ func (bbp *U) MustUnmarshalBebop(buf []byte) { at += 1 bbp.A = new(A) (*bbp.A) = MustMakeAFromBytes(buf[at:]) - tmp := ((*bbp.A)) - at += tmp.Size() + { + tmp := ((*bbp.A)) + at += tmp.Size() + } + return case 2: at += 1 bbp.B = new(B) (*bbp.B) = MustMakeBFromBytes(buf[at:]) - tmp := ((*bbp.B)) - at += tmp.Size() + { + tmp := ((*bbp.B)) + at += tmp.Size() + } + return case 3: at += 1 bbp.C = new(C) (*bbp.C) = MustMakeCFromBytes(buf[at:]) - tmp := ((*bbp.C)) - at += tmp.Size() + { + tmp := ((*bbp.C)) + at += tmp.Size() + } + return default: return @@ -435,20 +462,29 @@ func (bbp *U) Size() int { bodyLen := 4 if bbp.A != nil { bodyLen += 1 - tmp := (*bbp.A) - bodyLen += tmp.Size() + { + tmp := (*bbp.A) + bodyLen += tmp.Size() + } + return bodyLen } if bbp.B != nil { bodyLen += 1 - tmp := (*bbp.B) - bodyLen += tmp.Size() + { + tmp := (*bbp.B) + bodyLen += tmp.Size() + } + return bodyLen } if bbp.C != nil { bodyLen += 1 - tmp := (*bbp.C) - bodyLen += tmp.Size() + { + tmp := (*bbp.C) + bodyLen += tmp.Size() + } + return bodyLen } return bodyLen @@ -490,8 +526,11 @@ func (bbp *Cons) MarshalBebopTo(buf []byte) int { iohelp.WriteUint32Bytes(buf[at:], bbp.Head) at += 4 (bbp.Tail).MarshalBebopTo(buf[at:]) - tmp := (bbp.Tail) - at += tmp.Size() + { + tmp := (bbp.Tail) + at += tmp.Size() + } + return at } @@ -506,8 +545,11 @@ func (bbp *Cons) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := (bbp.Tail) - at += tmp.Size() + { + tmp := (bbp.Tail) + at += tmp.Size() + } + return nil } @@ -516,8 +558,11 @@ func (bbp *Cons) MustUnmarshalBebop(buf []byte) { bbp.Head = iohelp.ReadUint32Bytes(buf[at:]) at += 4 bbp.Tail = MustMakeListFromBytes(buf[at:]) - tmp := (bbp.Tail) - at += tmp.Size() + { + tmp := (bbp.Tail) + at += tmp.Size() + } + } func (bbp *Cons) EncodeBebop(iow io.Writer) (err error) { @@ -543,8 +588,11 @@ func (bbp *Cons) DecodeBebop(ior io.Reader) (err error) { func (bbp *Cons) Size() int { bodyLen := 0 bodyLen += 4 - tmp := (bbp.Tail) - bodyLen += tmp.Size() + { + tmp := (bbp.Tail) + bodyLen += tmp.Size() + } + return bodyLen } @@ -632,16 +680,22 @@ func (bbp *List) MarshalBebopTo(buf []byte) int { buf[at] = 1 at++ (*bbp.Cons).MarshalBebopTo(buf[at:]) - tmp := (*bbp.Cons) - at += tmp.Size() + { + tmp := (*bbp.Cons) + at += tmp.Size() + } + return at } if bbp.Null != nil { buf[at] = 2 at++ (*bbp.Null).MarshalBebopTo(buf[at:]) - tmp := (*bbp.Null) - at += tmp.Size() + { + tmp := (*bbp.Null) + at += tmp.Size() + } + return at } return at @@ -663,8 +717,11 @@ func (bbp *List) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := ((*bbp.Cons)) - at += tmp.Size() + { + tmp := ((*bbp.Cons)) + at += tmp.Size() + } + return nil case 2: at += 1 @@ -673,8 +730,11 @@ func (bbp *List) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := ((*bbp.Null)) - at += tmp.Size() + { + tmp := ((*bbp.Null)) + at += tmp.Size() + } + return nil default: return nil @@ -692,15 +752,21 @@ func (bbp *List) MustUnmarshalBebop(buf []byte) { at += 1 bbp.Cons = new(Cons) (*bbp.Cons) = MustMakeConsFromBytes(buf[at:]) - tmp := ((*bbp.Cons)) - at += tmp.Size() + { + tmp := ((*bbp.Cons)) + at += tmp.Size() + } + return case 2: at += 1 bbp.Null = new(Null) (*bbp.Null) = MustMakeNullFromBytes(buf[at:]) - tmp := ((*bbp.Null)) - at += tmp.Size() + { + tmp := ((*bbp.Null)) + at += tmp.Size() + } + return default: return @@ -763,14 +829,20 @@ func (bbp *List) Size() int { bodyLen := 4 if bbp.Cons != nil { bodyLen += 1 - tmp := (*bbp.Cons) - bodyLen += tmp.Size() + { + tmp := (*bbp.Cons) + bodyLen += tmp.Size() + } + return bodyLen } if bbp.Null != nil { bodyLen += 1 - tmp := (*bbp.Null) - bodyLen += tmp.Size() + { + tmp := (*bbp.Null) + bodyLen += tmp.Size() + } + return bodyLen } return bodyLen diff --git a/testdata/generated-always-pointers/union_field.go b/testdata/generated-always-pointers/union_field.go index aa0cf64..63a80c3 100644 --- a/testdata/generated-always-pointers/union_field.go +++ b/testdata/generated-always-pointers/union_field.go @@ -22,8 +22,11 @@ func (bbp *WithUnionField) MarshalBebopTo(buf []byte) int { buf[at] = 1 at++ (*bbp.Test).MarshalBebopTo(buf[at:]) - tmp := (*bbp.Test) - at += tmp.Size() + { + tmp := (*bbp.Test) + at += tmp.Size() + } + } return at } @@ -41,8 +44,11 @@ func (bbp *WithUnionField) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := ((*bbp.Test)) - at += tmp.Size() + { + tmp := ((*bbp.Test)) + at += tmp.Size() + } + default: return nil } @@ -59,8 +65,11 @@ func (bbp *WithUnionField) MustUnmarshalBebop(buf []byte) { at += 1 bbp.Test = new(List2) (*bbp.Test) = MustMakeList2FromBytes(buf[at:]) - tmp := ((*bbp.Test)) - at += tmp.Size() + { + tmp := ((*bbp.Test)) + at += tmp.Size() + } + default: return } @@ -104,8 +113,11 @@ func (bbp *WithUnionField) Size() int { bodyLen := 5 if bbp.Test != nil { bodyLen += 1 - tmp := (*bbp.Test) - bodyLen += tmp.Size() + { + tmp := (*bbp.Test) + bodyLen += tmp.Size() + } + } return bodyLen } @@ -272,16 +284,22 @@ func (bbp *List2) MarshalBebopTo(buf []byte) int { buf[at] = 1 at++ (*bbp.Cons2).MarshalBebopTo(buf[at:]) - tmp := (*bbp.Cons2) - at += tmp.Size() + { + tmp := (*bbp.Cons2) + at += tmp.Size() + } + return at } if bbp.Nil2 != nil { buf[at] = 2 at++ (*bbp.Nil2).MarshalBebopTo(buf[at:]) - tmp := (*bbp.Nil2) - at += tmp.Size() + { + tmp := (*bbp.Nil2) + at += tmp.Size() + } + return at } return at @@ -303,8 +321,11 @@ func (bbp *List2) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := ((*bbp.Cons2)) - at += tmp.Size() + { + tmp := ((*bbp.Cons2)) + at += tmp.Size() + } + return nil case 2: at += 1 @@ -313,8 +334,11 @@ func (bbp *List2) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := ((*bbp.Nil2)) - at += tmp.Size() + { + tmp := ((*bbp.Nil2)) + at += tmp.Size() + } + return nil default: return nil @@ -332,15 +356,21 @@ func (bbp *List2) MustUnmarshalBebop(buf []byte) { at += 1 bbp.Cons2 = new(Cons2) (*bbp.Cons2) = MustMakeCons2FromBytes(buf[at:]) - tmp := ((*bbp.Cons2)) - at += tmp.Size() + { + tmp := ((*bbp.Cons2)) + at += tmp.Size() + } + return case 2: at += 1 bbp.Nil2 = new(Nil2) (*bbp.Nil2) = MustMakeNil2FromBytes(buf[at:]) - tmp := ((*bbp.Nil2)) - at += tmp.Size() + { + tmp := ((*bbp.Nil2)) + at += tmp.Size() + } + return default: return @@ -403,14 +433,20 @@ func (bbp *List2) Size() int { bodyLen := 4 if bbp.Cons2 != nil { bodyLen += 1 - tmp := (*bbp.Cons2) - bodyLen += tmp.Size() + { + tmp := (*bbp.Cons2) + bodyLen += tmp.Size() + } + return bodyLen } if bbp.Nil2 != nil { bodyLen += 1 - tmp := (*bbp.Nil2) - bodyLen += tmp.Size() + { + tmp := (*bbp.Nil2) + bodyLen += tmp.Size() + } + return bodyLen } return bodyLen diff --git a/testdata/generated-private/foo.go b/testdata/generated-private/foo.go index 2f3cff7..759b838 100644 --- a/testdata/generated-private/foo.go +++ b/testdata/generated-private/foo.go @@ -17,8 +17,11 @@ type foo struct { func (bbp foo) MarshalBebopTo(buf []byte) int { at := 0 (bbp.bar).MarshalBebopTo(buf[at:]) - tmp := (bbp.bar) - at += tmp.Size() + { + tmp := (bbp.bar) + at += tmp.Size() + } + return at } @@ -28,16 +31,22 @@ func (bbp *foo) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := (bbp.bar) - at += tmp.Size() + { + tmp := (bbp.bar) + at += tmp.Size() + } + return nil } func (bbp *foo) MustUnmarshalBebop(buf []byte) { at := 0 bbp.bar = mustMakebarFromBytes(buf[at:]) - tmp := (bbp.bar) - at += tmp.Size() + { + tmp := (bbp.bar) + at += tmp.Size() + } + } func (bbp foo) EncodeBebop(iow io.Writer) (err error) { @@ -60,8 +69,11 @@ func (bbp *foo) DecodeBebop(ior io.Reader) (err error) { func (bbp foo) Size() int { bodyLen := 0 - tmp := (bbp.bar) - bodyLen += tmp.Size() + { + tmp := (bbp.bar) + bodyLen += tmp.Size() + } + return bodyLen } diff --git a/testdata/generated-private/fruit.go b/testdata/generated-private/fruit.go new file mode 100644 index 0000000..64dc1b4 --- /dev/null +++ b/testdata/generated-private/fruit.go @@ -0,0 +1,259 @@ +// Code generated by bebopc-go; DO NOT EDIT. + +package generated + +import ( + "github.com/200sc/bebop" + "github.com/200sc/bebop/iohelp" + "io" +) + +var _ bebop.Record = &fruit{} + +type fruit struct { + iD uint64 + name string +} + +func (bbp fruit) MarshalBebopTo(buf []byte) int { + at := 0 + iohelp.WriteUint64Bytes(buf[at:], bbp.iD) + at += 8 + iohelp.WriteUint32Bytes(buf[at:], uint32(len(bbp.name))) + copy(buf[at+4:at+4+len(bbp.name)], []byte(bbp.name)) + at += 4 + len(bbp.name) + return at +} + +func (bbp *fruit) UnmarshalBebop(buf []byte) (err error) { + at := 0 + if len(buf[at:]) < 8 { + return io.ErrUnexpectedEOF + } + bbp.iD = iohelp.ReadUint64Bytes(buf[at:]) + at += 8 + bbp.name, err = iohelp.ReadStringBytes(buf[at:]) + if err != nil { + return err + } + at += 4 + len(bbp.name) + return nil +} + +func (bbp *fruit) MustUnmarshalBebop(buf []byte) { + at := 0 + bbp.iD = iohelp.ReadUint64Bytes(buf[at:]) + at += 8 + bbp.name = iohelp.MustReadStringBytes(buf[at:]) + at += 4 + len(bbp.name) +} + +func (bbp fruit) EncodeBebop(iow io.Writer) (err error) { + w := iohelp.NewErrorWriter(iow) + iohelp.WriteUint64(w, bbp.iD) + iohelp.WriteUint32(w, uint32(len(bbp.name))) + w.Write([]byte(bbp.name)) + return w.Err +} + +func (bbp *fruit) DecodeBebop(ior io.Reader) (err error) { + r := iohelp.NewErrorReader(ior) + bbp.iD = iohelp.ReadUint64(r) + bbp.name = iohelp.ReadString(r) + return r.Err +} + +func (bbp fruit) Size() int { + bodyLen := 0 + bodyLen += 8 + bodyLen += 4 + len(bbp.name) + return bodyLen +} + +func (bbp fruit) MarshalBebop() []byte { + buf := make([]byte, bbp.Size()) + bbp.MarshalBebopTo(buf) + return buf +} + +func makefruit(r *iohelp.ErrorReader) (fruit, error) { + v := fruit{} + err := v.DecodeBebop(r) + return v, err +} + +func makefruitFromBytes(buf []byte) (fruit, error) { + v := fruit{} + err := v.UnmarshalBebop(buf) + return v, err +} + +func mustMakefruitFromBytes(buf []byte) fruit { + v := fruit{} + v.MustUnmarshalBebop(buf) + return v +} + +var _ bebop.Record = &basket{} + +type basket struct { + apples fruit + oranges fruit + mangos fruit +} + +func (bbp basket) MarshalBebopTo(buf []byte) int { + at := 0 + (bbp.apples).MarshalBebopTo(buf[at:]) + { + tmp := (bbp.apples) + at += tmp.Size() + } + + (bbp.oranges).MarshalBebopTo(buf[at:]) + { + tmp := (bbp.oranges) + at += tmp.Size() + } + + (bbp.mangos).MarshalBebopTo(buf[at:]) + { + tmp := (bbp.mangos) + at += tmp.Size() + } + + return at +} + +func (bbp *basket) UnmarshalBebop(buf []byte) (err error) { + at := 0 + bbp.apples, err = makefruitFromBytes(buf[at:]) + if err != nil { + return err + } + { + tmp := (bbp.apples) + at += tmp.Size() + } + + bbp.oranges, err = makefruitFromBytes(buf[at:]) + if err != nil { + return err + } + { + tmp := (bbp.oranges) + at += tmp.Size() + } + + bbp.mangos, err = makefruitFromBytes(buf[at:]) + if err != nil { + return err + } + { + tmp := (bbp.mangos) + at += tmp.Size() + } + + return nil +} + +func (bbp *basket) MustUnmarshalBebop(buf []byte) { + at := 0 + bbp.apples = mustMakefruitFromBytes(buf[at:]) + { + tmp := (bbp.apples) + at += tmp.Size() + } + + bbp.oranges = mustMakefruitFromBytes(buf[at:]) + { + tmp := (bbp.oranges) + at += tmp.Size() + } + + bbp.mangos = mustMakefruitFromBytes(buf[at:]) + { + tmp := (bbp.mangos) + at += tmp.Size() + } + +} + +func (bbp basket) EncodeBebop(iow io.Writer) (err error) { + w := iohelp.NewErrorWriter(iow) + err = (bbp.apples).EncodeBebop(w) + if err != nil { + return err + } + err = (bbp.oranges).EncodeBebop(w) + if err != nil { + return err + } + err = (bbp.mangos).EncodeBebop(w) + if err != nil { + return err + } + return w.Err +} + +func (bbp *basket) DecodeBebop(ior io.Reader) (err error) { + r := iohelp.NewErrorReader(ior) + (bbp.apples), err = makefruit(r) + if err != nil { + return err + } + (bbp.oranges), err = makefruit(r) + if err != nil { + return err + } + (bbp.mangos), err = makefruit(r) + if err != nil { + return err + } + return r.Err +} + +func (bbp basket) Size() int { + bodyLen := 0 + { + tmp := (bbp.apples) + bodyLen += tmp.Size() + } + + { + tmp := (bbp.oranges) + bodyLen += tmp.Size() + } + + { + tmp := (bbp.mangos) + bodyLen += tmp.Size() + } + + return bodyLen +} + +func (bbp basket) MarshalBebop() []byte { + buf := make([]byte, bbp.Size()) + bbp.MarshalBebopTo(buf) + return buf +} + +func makebasket(r *iohelp.ErrorReader) (basket, error) { + v := basket{} + err := v.DecodeBebop(r) + return v, err +} + +func makebasketFromBytes(buf []byte) (basket, error) { + v := basket{} + err := v.UnmarshalBebop(buf) + return v, err +} + +func mustMakebasketFromBytes(buf []byte) basket { + v := basket{} + v.MustUnmarshalBebop(buf) + return v +} + diff --git a/testdata/generated-private/jazz.go b/testdata/generated-private/jazz.go index ada75db..ee52e07 100644 --- a/testdata/generated-private/jazz.go +++ b/testdata/generated-private/jazz.go @@ -131,8 +131,11 @@ func (bbp library) MarshalBebopTo(buf []byte) int { iohelp.WriteGUIDBytes(buf[at:], k1) at += 16 (v1).MarshalBebopTo(buf[at:]) - tmp := (v1) - at += tmp.Size() + { + tmp := (v1) + at += tmp.Size() + } + } return at } @@ -152,8 +155,11 @@ func (bbp *library) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := ((bbp.songs)[k1]) - at += tmp.Size() + { + tmp := ((bbp.songs)[k1]) + at += tmp.Size() + } + } return nil } @@ -167,8 +173,11 @@ func (bbp *library) MustUnmarshalBebop(buf []byte) { k1 := iohelp.ReadGUIDBytes(buf[at:]) at += 16 (bbp.songs)[k1] = mustMakesongFromBytes(buf[at:]) - tmp := ((bbp.songs)[k1]) - at += tmp.Size() + { + tmp := ((bbp.songs)[k1]) + at += tmp.Size() + } + } } @@ -204,8 +213,11 @@ func (bbp library) Size() int { bodyLen += 4 for _, v1 := range bbp.songs { bodyLen += 16 - tmp := (v1) - bodyLen += tmp.Size() + { + tmp := (v1) + bodyLen += tmp.Size() + } + } return bodyLen } @@ -266,8 +278,11 @@ func (bbp song) MarshalBebopTo(buf []byte) int { at += 4 for _, v2 := range *bbp.performers { (v2).MarshalBebopTo(buf[at:]) - tmp := (v2) - at += tmp.Size() + { + tmp := (v2) + at += tmp.Size() + } + } } return at @@ -308,8 +323,11 @@ func (bbp *song) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := (((*bbp.performers))[i3]) - at += tmp.Size() + { + tmp := (((*bbp.performers))[i3]) + at += tmp.Size() + } + } default: return nil @@ -340,8 +358,11 @@ func (bbp *song) MustUnmarshalBebop(buf []byte) { at += 4 for i3 := range (*bbp.performers) { ((*bbp.performers))[i3] = mustMakemusicianFromBytes(buf[at:]) - tmp := (((*bbp.performers))[i3]) - at += tmp.Size() + { + tmp := (((*bbp.performers))[i3]) + at += tmp.Size() + } + } default: return @@ -417,8 +438,11 @@ func (bbp song) Size() int { bodyLen += 1 bodyLen += 4 for _, elem := range *bbp.performers { - tmp := (elem) - bodyLen += tmp.Size() + { + tmp := (elem) + bodyLen += tmp.Size() + } + } } return bodyLen diff --git a/testdata/generated-private/lab.go b/testdata/generated-private/lab.go index ae9a13d..75bb42a 100644 --- a/testdata/generated-private/lab.go +++ b/testdata/generated-private/lab.go @@ -716,8 +716,11 @@ func (bbp mediaMessage) MarshalBebopTo(buf []byte) int { buf[at] = 2 at++ (*bbp.data).MarshalBebopTo(buf[at:]) - tmp := (*bbp.data) - at += tmp.Size() + { + tmp := (*bbp.data) + at += tmp.Size() + } + } return at } @@ -740,8 +743,11 @@ func (bbp *mediaMessage) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := ((*bbp.data)) - at += tmp.Size() + { + tmp := ((*bbp.data)) + at += tmp.Size() + } + default: return nil } @@ -763,8 +769,11 @@ func (bbp *mediaMessage) MustUnmarshalBebop(buf []byte) { at += 1 bbp.data = new(videoData) (*bbp.data) = mustMakevideoDataFromBytes(buf[at:]) - tmp := ((*bbp.data)) - at += tmp.Size() + { + tmp := ((*bbp.data)) + at += tmp.Size() + } + default: return } @@ -819,8 +828,11 @@ func (bbp mediaMessage) Size() int { } if bbp.data != nil { bodyLen += 1 - tmp := (*bbp.data) - bodyLen += tmp.Size() + { + tmp := (*bbp.data) + bodyLen += tmp.Size() + } + } return bodyLen } @@ -1190,8 +1202,11 @@ func (bbp skipTestOldContainer) MarshalBebopTo(buf []byte) int { buf[at] = 1 at++ (*bbp.s).MarshalBebopTo(buf[at:]) - tmp := (*bbp.s) - at += tmp.Size() + { + tmp := (*bbp.s) + at += tmp.Size() + } + } if bbp.after != nil { buf[at] = 2 @@ -1215,8 +1230,11 @@ func (bbp *skipTestOldContainer) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := ((*bbp.s)) - at += tmp.Size() + { + tmp := ((*bbp.s)) + at += tmp.Size() + } + case 2: at += 1 bbp.after = new(int32) @@ -1241,8 +1259,11 @@ func (bbp *skipTestOldContainer) MustUnmarshalBebop(buf []byte) { at += 1 bbp.s = new(skipTestOld) (*bbp.s) = mustMakeskipTestOldFromBytes(buf[at:]) - tmp := ((*bbp.s)) - at += tmp.Size() + { + tmp := ((*bbp.s)) + at += tmp.Size() + } + case 2: at += 1 bbp.after = new(int32) @@ -1298,8 +1319,11 @@ func (bbp skipTestOldContainer) Size() int { bodyLen := 5 if bbp.s != nil { bodyLen += 1 - tmp := (*bbp.s) - bodyLen += tmp.Size() + { + tmp := (*bbp.s) + bodyLen += tmp.Size() + } + } if bbp.after != nil { bodyLen += 1 @@ -1347,8 +1371,11 @@ func (bbp skipTestNewContainer) MarshalBebopTo(buf []byte) int { buf[at] = 1 at++ (*bbp.s).MarshalBebopTo(buf[at:]) - tmp := (*bbp.s) - at += tmp.Size() + { + tmp := (*bbp.s) + at += tmp.Size() + } + } if bbp.after != nil { buf[at] = 2 @@ -1372,8 +1399,11 @@ func (bbp *skipTestNewContainer) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := ((*bbp.s)) - at += tmp.Size() + { + tmp := ((*bbp.s)) + at += tmp.Size() + } + case 2: at += 1 bbp.after = new(int32) @@ -1398,8 +1428,11 @@ func (bbp *skipTestNewContainer) MustUnmarshalBebop(buf []byte) { at += 1 bbp.s = new(skipTestNew) (*bbp.s) = mustMakeskipTestNewFromBytes(buf[at:]) - tmp := ((*bbp.s)) - at += tmp.Size() + { + tmp := ((*bbp.s)) + at += tmp.Size() + } + case 2: at += 1 bbp.after = new(int32) @@ -1455,8 +1488,11 @@ func (bbp skipTestNewContainer) Size() int { bodyLen := 5 if bbp.s != nil { bodyLen += 1 - tmp := (*bbp.s) - bodyLen += tmp.Size() + { + tmp := (*bbp.s) + bodyLen += tmp.Size() + } + } if bbp.after != nil { bodyLen += 1 diff --git a/testdata/generated-private/map_types.go b/testdata/generated-private/map_types.go index d3c5800..731bc06 100644 --- a/testdata/generated-private/map_types.go +++ b/testdata/generated-private/map_types.go @@ -164,8 +164,11 @@ func (bbp someMaps) MarshalBebopTo(buf []byte) int { iohelp.WriteBoolBytes(buf[at:], k4) at += 1 (v4).MarshalBebopTo(buf[at:]) - tmp := (v4) - at += tmp.Size() + { + tmp := (v4) + at += tmp.Size() + } + } } } @@ -193,8 +196,11 @@ func (bbp someMaps) MarshalBebopTo(buf []byte) int { iohelp.WriteGUIDBytes(buf[at:], k1) at += 16 (v1).MarshalBebopTo(buf[at:]) - tmp := (v1) - at += tmp.Size() + { + tmp := (v1) + at += tmp.Size() + } + } return at } @@ -275,8 +281,11 @@ func (bbp *someMaps) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := (((((bbp.m3)[i1])[k2])[i3])[k4]) - at += tmp.Size() + { + tmp := (((((bbp.m3)[i1])[k2])[i3])[k4]) + at += tmp.Size() + } + } } } @@ -323,8 +332,11 @@ func (bbp *someMaps) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := ((bbp.m5)[k1]) - at += tmp.Size() + { + tmp := ((bbp.m5)[k1]) + at += tmp.Size() + } + } return nil } @@ -375,8 +387,11 @@ func (bbp *someMaps) MustUnmarshalBebop(buf []byte) { k4 := iohelp.ReadBoolBytes(buf[at:]) at += 1 ((((bbp.m3)[i1])[k2])[i3])[k4] = mustMakesFromBytes(buf[at:]) - tmp := (((((bbp.m3)[i1])[k2])[i3])[k4]) - at += tmp.Size() + { + tmp := (((((bbp.m3)[i1])[k2])[i3])[k4]) + at += tmp.Size() + } + } } } @@ -405,8 +420,11 @@ func (bbp *someMaps) MustUnmarshalBebop(buf []byte) { k1 := iohelp.ReadGUIDBytes(buf[at:]) at += 16 (bbp.m5)[k1] = mustMakemFromBytes(buf[at:]) - tmp := ((bbp.m5)[k1]) - at += tmp.Size() + { + tmp := ((bbp.m5)[k1]) + at += tmp.Size() + } + } } @@ -559,8 +577,11 @@ func (bbp someMaps) Size() int { bodyLen += 4 for _, v4 := range elem { bodyLen += 1 - tmp := (v4) - bodyLen += tmp.Size() + { + tmp := (v4) + bodyLen += tmp.Size() + } + } } } @@ -577,8 +598,11 @@ func (bbp someMaps) Size() int { bodyLen += 4 for _, v1 := range bbp.m5 { bodyLen += 16 - tmp := (v1) - bodyLen += tmp.Size() + { + tmp := (v1) + bodyLen += tmp.Size() + } + } return bodyLen } diff --git a/testdata/generated-private/request.go b/testdata/generated-private/request.go index a5ed846..77995f9 100644 --- a/testdata/generated-private/request.go +++ b/testdata/generated-private/request.go @@ -150,8 +150,11 @@ func (bbp requestResponse) MarshalBebopTo(buf []byte) int { at += 4 for _, v1 := range bbp.availableFurniture { (v1).MarshalBebopTo(buf[at:]) - tmp := (v1) - at += tmp.Size() + { + tmp := (v1) + at += tmp.Size() + } + } return at } @@ -168,8 +171,11 @@ func (bbp *requestResponse) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := ((bbp.availableFurniture)[i1]) - at += tmp.Size() + { + tmp := ((bbp.availableFurniture)[i1]) + at += tmp.Size() + } + } return nil } @@ -180,8 +186,11 @@ func (bbp *requestResponse) MustUnmarshalBebop(buf []byte) { at += 4 for i1 := range bbp.availableFurniture { (bbp.availableFurniture)[i1] = mustMakefurnitureFromBytes(buf[at:]) - tmp := ((bbp.availableFurniture)[i1]) - at += tmp.Size() + { + tmp := ((bbp.availableFurniture)[i1]) + at += tmp.Size() + } + } } @@ -213,8 +222,11 @@ func (bbp requestResponse) Size() int { bodyLen := 0 bodyLen += 4 for _, elem := range bbp.availableFurniture { - tmp := (elem) - bodyLen += tmp.Size() + { + tmp := (elem) + bodyLen += tmp.Size() + } + } return bodyLen } diff --git a/testdata/generated-private/server.go b/testdata/generated-private/server.go index a8c26f4..6958bca 100644 --- a/testdata/generated-private/server.go +++ b/testdata/generated-private/server.go @@ -252,8 +252,11 @@ func (bbp printRequest) MarshalBebopTo(buf []byte) int { buf[at] = 1 at++ (*bbp.print).MarshalBebopTo(buf[at:]) - tmp := (*bbp.print) - at += tmp.Size() + { + tmp := (*bbp.print) + at += tmp.Size() + } + } return at } @@ -271,8 +274,11 @@ func (bbp *printRequest) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := ((*bbp.print)) - at += tmp.Size() + { + tmp := ((*bbp.print)) + at += tmp.Size() + } + default: return nil } @@ -289,8 +295,11 @@ func (bbp *printRequest) MustUnmarshalBebop(buf []byte) { at += 1 bbp.print = new(print) (*bbp.print) = mustMakeprintFromBytes(buf[at:]) - tmp := ((*bbp.print)) - at += tmp.Size() + { + tmp := ((*bbp.print)) + at += tmp.Size() + } + default: return } @@ -334,8 +343,11 @@ func (bbp printRequest) Size() int { bodyLen := 5 if bbp.print != nil { bodyLen += 1 - tmp := (*bbp.print) - bodyLen += tmp.Size() + { + tmp := (*bbp.print) + bodyLen += tmp.Size() + } + } return bodyLen } @@ -380,8 +392,11 @@ func (bbp addRequest) MarshalBebopTo(buf []byte) int { buf[at] = 1 at++ (*bbp.add).MarshalBebopTo(buf[at:]) - tmp := (*bbp.add) - at += tmp.Size() + { + tmp := (*bbp.add) + at += tmp.Size() + } + } return at } @@ -399,8 +414,11 @@ func (bbp *addRequest) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := ((*bbp.add)) - at += tmp.Size() + { + tmp := ((*bbp.add)) + at += tmp.Size() + } + default: return nil } @@ -417,8 +435,11 @@ func (bbp *addRequest) MustUnmarshalBebop(buf []byte) { at += 1 bbp.add = new(add) (*bbp.add) = mustMakeaddFromBytes(buf[at:]) - tmp := ((*bbp.add)) - at += tmp.Size() + { + tmp := ((*bbp.add)) + at += tmp.Size() + } + default: return } @@ -462,8 +483,11 @@ func (bbp addRequest) Size() int { bodyLen := 5 if bbp.add != nil { bodyLen += 1 - tmp := (*bbp.add) - bodyLen += tmp.Size() + { + tmp := (*bbp.add) + bodyLen += tmp.Size() + } + } return bodyLen } diff --git a/testdata/generated-private/tags.go b/testdata/generated-private/tags.go index 97db3d7..19cc109 100644 --- a/testdata/generated-private/tags.go +++ b/testdata/generated-private/tags.go @@ -282,8 +282,11 @@ func (bbp taggedUnion) MarshalBebopTo(buf []byte) int { buf[at] = 1 at++ (*bbp.taggedSubStruct).MarshalBebopTo(buf[at:]) - tmp := (*bbp.taggedSubStruct) - at += tmp.Size() + { + tmp := (*bbp.taggedSubStruct) + at += tmp.Size() + } + return at } return at @@ -305,8 +308,11 @@ func (bbp *taggedUnion) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := ((*bbp.taggedSubStruct)) - at += tmp.Size() + { + tmp := ((*bbp.taggedSubStruct)) + at += tmp.Size() + } + return nil default: return nil @@ -324,8 +330,11 @@ func (bbp *taggedUnion) MustUnmarshalBebop(buf []byte) { at += 1 bbp.taggedSubStruct = new(taggedSubStruct) (*bbp.taggedSubStruct) = mustMaketaggedSubStructFromBytes(buf[at:]) - tmp := ((*bbp.taggedSubStruct)) - at += tmp.Size() + { + tmp := ((*bbp.taggedSubStruct)) + at += tmp.Size() + } + return default: return @@ -372,8 +381,11 @@ func (bbp taggedUnion) Size() int { bodyLen := 4 if bbp.taggedSubStruct != nil { bodyLen += 1 - tmp := (*bbp.taggedSubStruct) - bodyLen += tmp.Size() + { + tmp := (*bbp.taggedSubStruct) + bodyLen += tmp.Size() + } + return bodyLen } return bodyLen diff --git a/testdata/generated-private/union.go b/testdata/generated-private/union.go index 88fe897..a8e7512 100644 --- a/testdata/generated-private/union.go +++ b/testdata/generated-private/union.go @@ -263,24 +263,33 @@ func (bbp u) MarshalBebopTo(buf []byte) int { buf[at] = 1 at++ (*bbp.a).MarshalBebopTo(buf[at:]) - tmp := (*bbp.a) - at += tmp.Size() + { + tmp := (*bbp.a) + at += tmp.Size() + } + return at } if bbp.b != nil { buf[at] = 2 at++ (*bbp.b).MarshalBebopTo(buf[at:]) - tmp := (*bbp.b) - at += tmp.Size() + { + tmp := (*bbp.b) + at += tmp.Size() + } + return at } if bbp.c != nil { buf[at] = 3 at++ (*bbp.c).MarshalBebopTo(buf[at:]) - tmp := (*bbp.c) - at += tmp.Size() + { + tmp := (*bbp.c) + at += tmp.Size() + } + return at } return at @@ -302,8 +311,11 @@ func (bbp *u) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := ((*bbp.a)) - at += tmp.Size() + { + tmp := ((*bbp.a)) + at += tmp.Size() + } + return nil case 2: at += 1 @@ -312,8 +324,11 @@ func (bbp *u) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := ((*bbp.b)) - at += tmp.Size() + { + tmp := ((*bbp.b)) + at += tmp.Size() + } + return nil case 3: at += 1 @@ -322,8 +337,11 @@ func (bbp *u) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := ((*bbp.c)) - at += tmp.Size() + { + tmp := ((*bbp.c)) + at += tmp.Size() + } + return nil default: return nil @@ -341,22 +359,31 @@ func (bbp *u) MustUnmarshalBebop(buf []byte) { at += 1 bbp.a = new(a) (*bbp.a) = mustMakeaFromBytes(buf[at:]) - tmp := ((*bbp.a)) - at += tmp.Size() + { + tmp := ((*bbp.a)) + at += tmp.Size() + } + return case 2: at += 1 bbp.b = new(b) (*bbp.b) = mustMakebFromBytes(buf[at:]) - tmp := ((*bbp.b)) - at += tmp.Size() + { + tmp := ((*bbp.b)) + at += tmp.Size() + } + return case 3: at += 1 bbp.c = new(c) (*bbp.c) = mustMakecFromBytes(buf[at:]) - tmp := ((*bbp.c)) - at += tmp.Size() + { + tmp := ((*bbp.c)) + at += tmp.Size() + } + return default: return @@ -435,20 +462,29 @@ func (bbp u) Size() int { bodyLen := 4 if bbp.a != nil { bodyLen += 1 - tmp := (*bbp.a) - bodyLen += tmp.Size() + { + tmp := (*bbp.a) + bodyLen += tmp.Size() + } + return bodyLen } if bbp.b != nil { bodyLen += 1 - tmp := (*bbp.b) - bodyLen += tmp.Size() + { + tmp := (*bbp.b) + bodyLen += tmp.Size() + } + return bodyLen } if bbp.c != nil { bodyLen += 1 - tmp := (*bbp.c) - bodyLen += tmp.Size() + { + tmp := (*bbp.c) + bodyLen += tmp.Size() + } + return bodyLen } return bodyLen @@ -490,8 +526,11 @@ func (bbp cons) MarshalBebopTo(buf []byte) int { iohelp.WriteUint32Bytes(buf[at:], bbp.head) at += 4 (bbp.tail).MarshalBebopTo(buf[at:]) - tmp := (bbp.tail) - at += tmp.Size() + { + tmp := (bbp.tail) + at += tmp.Size() + } + return at } @@ -506,8 +545,11 @@ func (bbp *cons) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := (bbp.tail) - at += tmp.Size() + { + tmp := (bbp.tail) + at += tmp.Size() + } + return nil } @@ -516,8 +558,11 @@ func (bbp *cons) MustUnmarshalBebop(buf []byte) { bbp.head = iohelp.ReadUint32Bytes(buf[at:]) at += 4 bbp.tail = mustMakelistFromBytes(buf[at:]) - tmp := (bbp.tail) - at += tmp.Size() + { + tmp := (bbp.tail) + at += tmp.Size() + } + } func (bbp cons) EncodeBebop(iow io.Writer) (err error) { @@ -543,8 +588,11 @@ func (bbp *cons) DecodeBebop(ior io.Reader) (err error) { func (bbp cons) Size() int { bodyLen := 0 bodyLen += 4 - tmp := (bbp.tail) - bodyLen += tmp.Size() + { + tmp := (bbp.tail) + bodyLen += tmp.Size() + } + return bodyLen } @@ -632,16 +680,22 @@ func (bbp list) MarshalBebopTo(buf []byte) int { buf[at] = 1 at++ (*bbp.cons).MarshalBebopTo(buf[at:]) - tmp := (*bbp.cons) - at += tmp.Size() + { + tmp := (*bbp.cons) + at += tmp.Size() + } + return at } if bbp.null != nil { buf[at] = 2 at++ (*bbp.null).MarshalBebopTo(buf[at:]) - tmp := (*bbp.null) - at += tmp.Size() + { + tmp := (*bbp.null) + at += tmp.Size() + } + return at } return at @@ -663,8 +717,11 @@ func (bbp *list) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := ((*bbp.cons)) - at += tmp.Size() + { + tmp := ((*bbp.cons)) + at += tmp.Size() + } + return nil case 2: at += 1 @@ -673,8 +730,11 @@ func (bbp *list) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := ((*bbp.null)) - at += tmp.Size() + { + tmp := ((*bbp.null)) + at += tmp.Size() + } + return nil default: return nil @@ -692,15 +752,21 @@ func (bbp *list) MustUnmarshalBebop(buf []byte) { at += 1 bbp.cons = new(cons) (*bbp.cons) = mustMakeconsFromBytes(buf[at:]) - tmp := ((*bbp.cons)) - at += tmp.Size() + { + tmp := ((*bbp.cons)) + at += tmp.Size() + } + return case 2: at += 1 bbp.null = new(null) (*bbp.null) = mustMakenullFromBytes(buf[at:]) - tmp := ((*bbp.null)) - at += tmp.Size() + { + tmp := ((*bbp.null)) + at += tmp.Size() + } + return default: return @@ -763,14 +829,20 @@ func (bbp list) Size() int { bodyLen := 4 if bbp.cons != nil { bodyLen += 1 - tmp := (*bbp.cons) - bodyLen += tmp.Size() + { + tmp := (*bbp.cons) + bodyLen += tmp.Size() + } + return bodyLen } if bbp.null != nil { bodyLen += 1 - tmp := (*bbp.null) - bodyLen += tmp.Size() + { + tmp := (*bbp.null) + bodyLen += tmp.Size() + } + return bodyLen } return bodyLen diff --git a/testdata/generated-private/union_field.go b/testdata/generated-private/union_field.go index 457c376..209e73c 100644 --- a/testdata/generated-private/union_field.go +++ b/testdata/generated-private/union_field.go @@ -22,8 +22,11 @@ func (bbp withUnionField) MarshalBebopTo(buf []byte) int { buf[at] = 1 at++ (*bbp.test).MarshalBebopTo(buf[at:]) - tmp := (*bbp.test) - at += tmp.Size() + { + tmp := (*bbp.test) + at += tmp.Size() + } + } return at } @@ -41,8 +44,11 @@ func (bbp *withUnionField) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := ((*bbp.test)) - at += tmp.Size() + { + tmp := ((*bbp.test)) + at += tmp.Size() + } + default: return nil } @@ -59,8 +65,11 @@ func (bbp *withUnionField) MustUnmarshalBebop(buf []byte) { at += 1 bbp.test = new(list2) (*bbp.test) = mustMakelist2FromBytes(buf[at:]) - tmp := ((*bbp.test)) - at += tmp.Size() + { + tmp := ((*bbp.test)) + at += tmp.Size() + } + default: return } @@ -104,8 +113,11 @@ func (bbp withUnionField) Size() int { bodyLen := 5 if bbp.test != nil { bodyLen += 1 - tmp := (*bbp.test) - bodyLen += tmp.Size() + { + tmp := (*bbp.test) + bodyLen += tmp.Size() + } + } return bodyLen } @@ -272,16 +284,22 @@ func (bbp list2) MarshalBebopTo(buf []byte) int { buf[at] = 1 at++ (*bbp.cons2).MarshalBebopTo(buf[at:]) - tmp := (*bbp.cons2) - at += tmp.Size() + { + tmp := (*bbp.cons2) + at += tmp.Size() + } + return at } if bbp.nil2 != nil { buf[at] = 2 at++ (*bbp.nil2).MarshalBebopTo(buf[at:]) - tmp := (*bbp.nil2) - at += tmp.Size() + { + tmp := (*bbp.nil2) + at += tmp.Size() + } + return at } return at @@ -303,8 +321,11 @@ func (bbp *list2) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := ((*bbp.cons2)) - at += tmp.Size() + { + tmp := ((*bbp.cons2)) + at += tmp.Size() + } + return nil case 2: at += 1 @@ -313,8 +334,11 @@ func (bbp *list2) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := ((*bbp.nil2)) - at += tmp.Size() + { + tmp := ((*bbp.nil2)) + at += tmp.Size() + } + return nil default: return nil @@ -332,15 +356,21 @@ func (bbp *list2) MustUnmarshalBebop(buf []byte) { at += 1 bbp.cons2 = new(cons2) (*bbp.cons2) = mustMakecons2FromBytes(buf[at:]) - tmp := ((*bbp.cons2)) - at += tmp.Size() + { + tmp := ((*bbp.cons2)) + at += tmp.Size() + } + return case 2: at += 1 bbp.nil2 = new(nil2) (*bbp.nil2) = mustMakenil2FromBytes(buf[at:]) - tmp := ((*bbp.nil2)) - at += tmp.Size() + { + tmp := ((*bbp.nil2)) + at += tmp.Size() + } + return default: return @@ -403,14 +433,20 @@ func (bbp list2) Size() int { bodyLen := 4 if bbp.cons2 != nil { bodyLen += 1 - tmp := (*bbp.cons2) - bodyLen += tmp.Size() + { + tmp := (*bbp.cons2) + bodyLen += tmp.Size() + } + return bodyLen } if bbp.nil2 != nil { bodyLen += 1 - tmp := (*bbp.nil2) - bodyLen += tmp.Size() + { + tmp := (*bbp.nil2) + bodyLen += tmp.Size() + } + return bodyLen } return bodyLen diff --git a/testdata/generated/foo.go b/testdata/generated/foo.go index 4d19789..ca33367 100644 --- a/testdata/generated/foo.go +++ b/testdata/generated/foo.go @@ -17,8 +17,11 @@ type Foo struct { func (bbp Foo) MarshalBebopTo(buf []byte) int { at := 0 (bbp.Bar).MarshalBebopTo(buf[at:]) - tmp := (bbp.Bar) - at += tmp.Size() + { + tmp := (bbp.Bar) + at += tmp.Size() + } + return at } @@ -28,16 +31,22 @@ func (bbp *Foo) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := (bbp.Bar) - at += tmp.Size() + { + tmp := (bbp.Bar) + at += tmp.Size() + } + return nil } func (bbp *Foo) MustUnmarshalBebop(buf []byte) { at := 0 bbp.Bar = MustMakeBarFromBytes(buf[at:]) - tmp := (bbp.Bar) - at += tmp.Size() + { + tmp := (bbp.Bar) + at += tmp.Size() + } + } func (bbp Foo) EncodeBebop(iow io.Writer) (err error) { @@ -60,8 +69,11 @@ func (bbp *Foo) DecodeBebop(ior io.Reader) (err error) { func (bbp Foo) Size() int { bodyLen := 0 - tmp := (bbp.Bar) - bodyLen += tmp.Size() + { + tmp := (bbp.Bar) + bodyLen += tmp.Size() + } + return bodyLen } diff --git a/testdata/generated/import_b/import_b.go b/testdata/generated/import_b/import_b.go index 42b8eb5..9f1d85b 100644 --- a/testdata/generated/import_b/import_b.go +++ b/testdata/generated/import_b/import_b.go @@ -292,8 +292,11 @@ func (bbp Library) MarshalBebopTo(buf []byte) int { iohelp.WriteGUIDBytes(buf[at:], k1) at += 16 (v1).MarshalBebopTo(buf[at:]) - tmp := (v1) - at += tmp.Size() + { + tmp := (v1) + at += tmp.Size() + } + } return at } @@ -313,8 +316,11 @@ func (bbp *Library) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := ((bbp.Songs)[k1]) - at += tmp.Size() + { + tmp := ((bbp.Songs)[k1]) + at += tmp.Size() + } + } return nil } @@ -328,8 +334,11 @@ func (bbp *Library) MustUnmarshalBebop(buf []byte) { k1 := iohelp.ReadGUIDBytes(buf[at:]) at += 16 (bbp.Songs)[k1] = MustMakeSongFromBytes(buf[at:]) - tmp := ((bbp.Songs)[k1]) - at += tmp.Size() + { + tmp := ((bbp.Songs)[k1]) + at += tmp.Size() + } + } } @@ -365,8 +374,11 @@ func (bbp Library) Size() int { bodyLen += 4 for _, v1 := range bbp.Songs { bodyLen += 16 - tmp := (v1) - bodyLen += tmp.Size() + { + tmp := (v1) + bodyLen += tmp.Size() + } + } return bodyLen } @@ -1107,8 +1119,11 @@ func (bbp Song) MarshalBebopTo(buf []byte) int { at += 4 for _, v2 := range *bbp.Performers { (v2).MarshalBebopTo(buf[at:]) - tmp := (v2) - at += tmp.Size() + { + tmp := (v2) + at += tmp.Size() + } + } } return at @@ -1149,8 +1164,11 @@ func (bbp *Song) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := (((*bbp.Performers))[i3]) - at += tmp.Size() + { + tmp := (((*bbp.Performers))[i3]) + at += tmp.Size() + } + } default: return nil @@ -1181,8 +1199,11 @@ func (bbp *Song) MustUnmarshalBebop(buf []byte) { at += 4 for i3 := range (*bbp.Performers) { ((*bbp.Performers))[i3] = MustMakeMusicianFromBytes(buf[at:]) - tmp := (((*bbp.Performers))[i3]) - at += tmp.Size() + { + tmp := (((*bbp.Performers))[i3]) + at += tmp.Size() + } + } default: return @@ -1258,8 +1279,11 @@ func (bbp Song) Size() int { bodyLen += 1 bodyLen += 4 for _, elem := range *bbp.Performers { - tmp := (elem) - bodyLen += tmp.Size() + { + tmp := (elem) + bodyLen += tmp.Size() + } + } } return bodyLen @@ -1310,8 +1334,11 @@ func (bbp MediaMessage) MarshalBebopTo(buf []byte) int { buf[at] = 2 at++ (*bbp.Data).MarshalBebopTo(buf[at:]) - tmp := (*bbp.Data) - at += tmp.Size() + { + tmp := (*bbp.Data) + at += tmp.Size() + } + } return at } @@ -1334,8 +1361,11 @@ func (bbp *MediaMessage) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := ((*bbp.Data)) - at += tmp.Size() + { + tmp := ((*bbp.Data)) + at += tmp.Size() + } + default: return nil } @@ -1357,8 +1387,11 @@ func (bbp *MediaMessage) MustUnmarshalBebop(buf []byte) { at += 1 bbp.Data = new(VideoData) (*bbp.Data) = MustMakeVideoDataFromBytes(buf[at:]) - tmp := ((*bbp.Data)) - at += tmp.Size() + { + tmp := ((*bbp.Data)) + at += tmp.Size() + } + default: return } @@ -1413,8 +1446,11 @@ func (bbp MediaMessage) Size() int { } if bbp.Data != nil { bodyLen += 1 - tmp := (*bbp.Data) - bodyLen += tmp.Size() + { + tmp := (*bbp.Data) + bodyLen += tmp.Size() + } + } return bodyLen } @@ -1784,8 +1820,11 @@ func (bbp SkipTestOldContainer) MarshalBebopTo(buf []byte) int { buf[at] = 1 at++ (*bbp.S).MarshalBebopTo(buf[at:]) - tmp := (*bbp.S) - at += tmp.Size() + { + tmp := (*bbp.S) + at += tmp.Size() + } + } if bbp.After != nil { buf[at] = 2 @@ -1809,8 +1848,11 @@ func (bbp *SkipTestOldContainer) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := ((*bbp.S)) - at += tmp.Size() + { + tmp := ((*bbp.S)) + at += tmp.Size() + } + case 2: at += 1 bbp.After = new(int32) @@ -1835,8 +1877,11 @@ func (bbp *SkipTestOldContainer) MustUnmarshalBebop(buf []byte) { at += 1 bbp.S = new(SkipTestOld) (*bbp.S) = MustMakeSkipTestOldFromBytes(buf[at:]) - tmp := ((*bbp.S)) - at += tmp.Size() + { + tmp := ((*bbp.S)) + at += tmp.Size() + } + case 2: at += 1 bbp.After = new(int32) @@ -1892,8 +1937,11 @@ func (bbp SkipTestOldContainer) Size() int { bodyLen := 5 if bbp.S != nil { bodyLen += 1 - tmp := (*bbp.S) - bodyLen += tmp.Size() + { + tmp := (*bbp.S) + bodyLen += tmp.Size() + } + } if bbp.After != nil { bodyLen += 1 @@ -1941,8 +1989,11 @@ func (bbp SkipTestNewContainer) MarshalBebopTo(buf []byte) int { buf[at] = 1 at++ (*bbp.S).MarshalBebopTo(buf[at:]) - tmp := (*bbp.S) - at += tmp.Size() + { + tmp := (*bbp.S) + at += tmp.Size() + } + } if bbp.After != nil { buf[at] = 2 @@ -1966,8 +2017,11 @@ func (bbp *SkipTestNewContainer) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := ((*bbp.S)) - at += tmp.Size() + { + tmp := ((*bbp.S)) + at += tmp.Size() + } + case 2: at += 1 bbp.After = new(int32) @@ -1992,8 +2046,11 @@ func (bbp *SkipTestNewContainer) MustUnmarshalBebop(buf []byte) { at += 1 bbp.S = new(SkipTestNew) (*bbp.S) = MustMakeSkipTestNewFromBytes(buf[at:]) - tmp := ((*bbp.S)) - at += tmp.Size() + { + tmp := ((*bbp.S)) + at += tmp.Size() + } + case 2: at += 1 bbp.After = new(int32) @@ -2049,8 +2106,11 @@ func (bbp SkipTestNewContainer) Size() int { bodyLen := 5 if bbp.S != nil { bodyLen += 1 - tmp := (*bbp.S) - bodyLen += tmp.Size() + { + tmp := (*bbp.S) + bodyLen += tmp.Size() + } + } if bbp.After != nil { bodyLen += 1 diff --git a/testdata/generated/jazz.go b/testdata/generated/jazz.go index e381e9b..647559b 100644 --- a/testdata/generated/jazz.go +++ b/testdata/generated/jazz.go @@ -131,8 +131,11 @@ func (bbp Library) MarshalBebopTo(buf []byte) int { iohelp.WriteGUIDBytes(buf[at:], k1) at += 16 (v1).MarshalBebopTo(buf[at:]) - tmp := (v1) - at += tmp.Size() + { + tmp := (v1) + at += tmp.Size() + } + } return at } @@ -152,8 +155,11 @@ func (bbp *Library) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := ((bbp.Songs)[k1]) - at += tmp.Size() + { + tmp := ((bbp.Songs)[k1]) + at += tmp.Size() + } + } return nil } @@ -167,8 +173,11 @@ func (bbp *Library) MustUnmarshalBebop(buf []byte) { k1 := iohelp.ReadGUIDBytes(buf[at:]) at += 16 (bbp.Songs)[k1] = MustMakeSongFromBytes(buf[at:]) - tmp := ((bbp.Songs)[k1]) - at += tmp.Size() + { + tmp := ((bbp.Songs)[k1]) + at += tmp.Size() + } + } } @@ -204,8 +213,11 @@ func (bbp Library) Size() int { bodyLen += 4 for _, v1 := range bbp.Songs { bodyLen += 16 - tmp := (v1) - bodyLen += tmp.Size() + { + tmp := (v1) + bodyLen += tmp.Size() + } + } return bodyLen } @@ -266,8 +278,11 @@ func (bbp Song) MarshalBebopTo(buf []byte) int { at += 4 for _, v2 := range *bbp.Performers { (v2).MarshalBebopTo(buf[at:]) - tmp := (v2) - at += tmp.Size() + { + tmp := (v2) + at += tmp.Size() + } + } } return at @@ -308,8 +323,11 @@ func (bbp *Song) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := (((*bbp.Performers))[i3]) - at += tmp.Size() + { + tmp := (((*bbp.Performers))[i3]) + at += tmp.Size() + } + } default: return nil @@ -340,8 +358,11 @@ func (bbp *Song) MustUnmarshalBebop(buf []byte) { at += 4 for i3 := range (*bbp.Performers) { ((*bbp.Performers))[i3] = MustMakeMusicianFromBytes(buf[at:]) - tmp := (((*bbp.Performers))[i3]) - at += tmp.Size() + { + tmp := (((*bbp.Performers))[i3]) + at += tmp.Size() + } + } default: return @@ -417,8 +438,11 @@ func (bbp Song) Size() int { bodyLen += 1 bodyLen += 4 for _, elem := range *bbp.Performers { - tmp := (elem) - bodyLen += tmp.Size() + { + tmp := (elem) + bodyLen += tmp.Size() + } + } } return bodyLen diff --git a/testdata/generated/lab.go b/testdata/generated/lab.go index 0c3af56..091d481 100644 --- a/testdata/generated/lab.go +++ b/testdata/generated/lab.go @@ -716,8 +716,11 @@ func (bbp MediaMessage) MarshalBebopTo(buf []byte) int { buf[at] = 2 at++ (*bbp.Data).MarshalBebopTo(buf[at:]) - tmp := (*bbp.Data) - at += tmp.Size() + { + tmp := (*bbp.Data) + at += tmp.Size() + } + } return at } @@ -740,8 +743,11 @@ func (bbp *MediaMessage) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := ((*bbp.Data)) - at += tmp.Size() + { + tmp := ((*bbp.Data)) + at += tmp.Size() + } + default: return nil } @@ -763,8 +769,11 @@ func (bbp *MediaMessage) MustUnmarshalBebop(buf []byte) { at += 1 bbp.Data = new(VideoData) (*bbp.Data) = MustMakeVideoDataFromBytes(buf[at:]) - tmp := ((*bbp.Data)) - at += tmp.Size() + { + tmp := ((*bbp.Data)) + at += tmp.Size() + } + default: return } @@ -819,8 +828,11 @@ func (bbp MediaMessage) Size() int { } if bbp.Data != nil { bodyLen += 1 - tmp := (*bbp.Data) - bodyLen += tmp.Size() + { + tmp := (*bbp.Data) + bodyLen += tmp.Size() + } + } return bodyLen } @@ -1190,8 +1202,11 @@ func (bbp SkipTestOldContainer) MarshalBebopTo(buf []byte) int { buf[at] = 1 at++ (*bbp.S).MarshalBebopTo(buf[at:]) - tmp := (*bbp.S) - at += tmp.Size() + { + tmp := (*bbp.S) + at += tmp.Size() + } + } if bbp.After != nil { buf[at] = 2 @@ -1215,8 +1230,11 @@ func (bbp *SkipTestOldContainer) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := ((*bbp.S)) - at += tmp.Size() + { + tmp := ((*bbp.S)) + at += tmp.Size() + } + case 2: at += 1 bbp.After = new(int32) @@ -1241,8 +1259,11 @@ func (bbp *SkipTestOldContainer) MustUnmarshalBebop(buf []byte) { at += 1 bbp.S = new(SkipTestOld) (*bbp.S) = MustMakeSkipTestOldFromBytes(buf[at:]) - tmp := ((*bbp.S)) - at += tmp.Size() + { + tmp := ((*bbp.S)) + at += tmp.Size() + } + case 2: at += 1 bbp.After = new(int32) @@ -1298,8 +1319,11 @@ func (bbp SkipTestOldContainer) Size() int { bodyLen := 5 if bbp.S != nil { bodyLen += 1 - tmp := (*bbp.S) - bodyLen += tmp.Size() + { + tmp := (*bbp.S) + bodyLen += tmp.Size() + } + } if bbp.After != nil { bodyLen += 1 @@ -1347,8 +1371,11 @@ func (bbp SkipTestNewContainer) MarshalBebopTo(buf []byte) int { buf[at] = 1 at++ (*bbp.S).MarshalBebopTo(buf[at:]) - tmp := (*bbp.S) - at += tmp.Size() + { + tmp := (*bbp.S) + at += tmp.Size() + } + } if bbp.After != nil { buf[at] = 2 @@ -1372,8 +1399,11 @@ func (bbp *SkipTestNewContainer) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := ((*bbp.S)) - at += tmp.Size() + { + tmp := ((*bbp.S)) + at += tmp.Size() + } + case 2: at += 1 bbp.After = new(int32) @@ -1398,8 +1428,11 @@ func (bbp *SkipTestNewContainer) MustUnmarshalBebop(buf []byte) { at += 1 bbp.S = new(SkipTestNew) (*bbp.S) = MustMakeSkipTestNewFromBytes(buf[at:]) - tmp := ((*bbp.S)) - at += tmp.Size() + { + tmp := ((*bbp.S)) + at += tmp.Size() + } + case 2: at += 1 bbp.After = new(int32) @@ -1455,8 +1488,11 @@ func (bbp SkipTestNewContainer) Size() int { bodyLen := 5 if bbp.S != nil { bodyLen += 1 - tmp := (*bbp.S) - bodyLen += tmp.Size() + { + tmp := (*bbp.S) + bodyLen += tmp.Size() + } + } if bbp.After != nil { bodyLen += 1 diff --git a/testdata/generated/map_types.go b/testdata/generated/map_types.go index c9884c3..1cad87c 100644 --- a/testdata/generated/map_types.go +++ b/testdata/generated/map_types.go @@ -164,8 +164,11 @@ func (bbp SomeMaps) MarshalBebopTo(buf []byte) int { iohelp.WriteBoolBytes(buf[at:], k4) at += 1 (v4).MarshalBebopTo(buf[at:]) - tmp := (v4) - at += tmp.Size() + { + tmp := (v4) + at += tmp.Size() + } + } } } @@ -193,8 +196,11 @@ func (bbp SomeMaps) MarshalBebopTo(buf []byte) int { iohelp.WriteGUIDBytes(buf[at:], k1) at += 16 (v1).MarshalBebopTo(buf[at:]) - tmp := (v1) - at += tmp.Size() + { + tmp := (v1) + at += tmp.Size() + } + } return at } @@ -275,8 +281,11 @@ func (bbp *SomeMaps) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := (((((bbp.M3)[i1])[k2])[i3])[k4]) - at += tmp.Size() + { + tmp := (((((bbp.M3)[i1])[k2])[i3])[k4]) + at += tmp.Size() + } + } } } @@ -323,8 +332,11 @@ func (bbp *SomeMaps) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := ((bbp.M5)[k1]) - at += tmp.Size() + { + tmp := ((bbp.M5)[k1]) + at += tmp.Size() + } + } return nil } @@ -375,8 +387,11 @@ func (bbp *SomeMaps) MustUnmarshalBebop(buf []byte) { k4 := iohelp.ReadBoolBytes(buf[at:]) at += 1 ((((bbp.M3)[i1])[k2])[i3])[k4] = MustMakeSFromBytes(buf[at:]) - tmp := (((((bbp.M3)[i1])[k2])[i3])[k4]) - at += tmp.Size() + { + tmp := (((((bbp.M3)[i1])[k2])[i3])[k4]) + at += tmp.Size() + } + } } } @@ -405,8 +420,11 @@ func (bbp *SomeMaps) MustUnmarshalBebop(buf []byte) { k1 := iohelp.ReadGUIDBytes(buf[at:]) at += 16 (bbp.M5)[k1] = MustMakeMFromBytes(buf[at:]) - tmp := ((bbp.M5)[k1]) - at += tmp.Size() + { + tmp := ((bbp.M5)[k1]) + at += tmp.Size() + } + } } @@ -559,8 +577,11 @@ func (bbp SomeMaps) Size() int { bodyLen += 4 for _, v4 := range elem { bodyLen += 1 - tmp := (v4) - bodyLen += tmp.Size() + { + tmp := (v4) + bodyLen += tmp.Size() + } + } } } @@ -577,8 +598,11 @@ func (bbp SomeMaps) Size() int { bodyLen += 4 for _, v1 := range bbp.M5 { bodyLen += 16 - tmp := (v1) - bodyLen += tmp.Size() + { + tmp := (v1) + bodyLen += tmp.Size() + } + } return bodyLen } diff --git a/testdata/generated/request.go b/testdata/generated/request.go index 91294c3..1f5cbb1 100644 --- a/testdata/generated/request.go +++ b/testdata/generated/request.go @@ -150,8 +150,11 @@ func (bbp RequestResponse) MarshalBebopTo(buf []byte) int { at += 4 for _, v1 := range bbp.availableFurniture { (v1).MarshalBebopTo(buf[at:]) - tmp := (v1) - at += tmp.Size() + { + tmp := (v1) + at += tmp.Size() + } + } return at } @@ -168,8 +171,11 @@ func (bbp *RequestResponse) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := ((bbp.availableFurniture)[i1]) - at += tmp.Size() + { + tmp := ((bbp.availableFurniture)[i1]) + at += tmp.Size() + } + } return nil } @@ -180,8 +186,11 @@ func (bbp *RequestResponse) MustUnmarshalBebop(buf []byte) { at += 4 for i1 := range bbp.availableFurniture { (bbp.availableFurniture)[i1] = MustMakeFurnitureFromBytes(buf[at:]) - tmp := ((bbp.availableFurniture)[i1]) - at += tmp.Size() + { + tmp := ((bbp.availableFurniture)[i1]) + at += tmp.Size() + } + } } @@ -213,8 +222,11 @@ func (bbp RequestResponse) Size() int { bodyLen := 0 bodyLen += 4 for _, elem := range bbp.availableFurniture { - tmp := (elem) - bodyLen += tmp.Size() + { + tmp := (elem) + bodyLen += tmp.Size() + } + } return bodyLen } diff --git a/testdata/generated/server.go b/testdata/generated/server.go index 0757b59..52b3881 100644 --- a/testdata/generated/server.go +++ b/testdata/generated/server.go @@ -252,8 +252,11 @@ func (bbp PrintRequest) MarshalBebopTo(buf []byte) int { buf[at] = 1 at++ (*bbp.Print).MarshalBebopTo(buf[at:]) - tmp := (*bbp.Print) - at += tmp.Size() + { + tmp := (*bbp.Print) + at += tmp.Size() + } + } return at } @@ -271,8 +274,11 @@ func (bbp *PrintRequest) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := ((*bbp.Print)) - at += tmp.Size() + { + tmp := ((*bbp.Print)) + at += tmp.Size() + } + default: return nil } @@ -289,8 +295,11 @@ func (bbp *PrintRequest) MustUnmarshalBebop(buf []byte) { at += 1 bbp.Print = new(Print) (*bbp.Print) = MustMakePrintFromBytes(buf[at:]) - tmp := ((*bbp.Print)) - at += tmp.Size() + { + tmp := ((*bbp.Print)) + at += tmp.Size() + } + default: return } @@ -334,8 +343,11 @@ func (bbp PrintRequest) Size() int { bodyLen := 5 if bbp.Print != nil { bodyLen += 1 - tmp := (*bbp.Print) - bodyLen += tmp.Size() + { + tmp := (*bbp.Print) + bodyLen += tmp.Size() + } + } return bodyLen } @@ -380,8 +392,11 @@ func (bbp AddRequest) MarshalBebopTo(buf []byte) int { buf[at] = 1 at++ (*bbp.Add).MarshalBebopTo(buf[at:]) - tmp := (*bbp.Add) - at += tmp.Size() + { + tmp := (*bbp.Add) + at += tmp.Size() + } + } return at } @@ -399,8 +414,11 @@ func (bbp *AddRequest) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := ((*bbp.Add)) - at += tmp.Size() + { + tmp := ((*bbp.Add)) + at += tmp.Size() + } + default: return nil } @@ -417,8 +435,11 @@ func (bbp *AddRequest) MustUnmarshalBebop(buf []byte) { at += 1 bbp.Add = new(Add) (*bbp.Add) = MustMakeAddFromBytes(buf[at:]) - tmp := ((*bbp.Add)) - at += tmp.Size() + { + tmp := ((*bbp.Add)) + at += tmp.Size() + } + default: return } @@ -462,8 +483,11 @@ func (bbp AddRequest) Size() int { bodyLen := 5 if bbp.Add != nil { bodyLen += 1 - tmp := (*bbp.Add) - bodyLen += tmp.Size() + { + tmp := (*bbp.Add) + bodyLen += tmp.Size() + } + } return bodyLen } diff --git a/testdata/generated/tags.go b/testdata/generated/tags.go index 9bee6f9..21f3453 100644 --- a/testdata/generated/tags.go +++ b/testdata/generated/tags.go @@ -282,8 +282,11 @@ func (bbp TaggedUnion) MarshalBebopTo(buf []byte) int { buf[at] = 1 at++ (*bbp.TaggedSubStruct).MarshalBebopTo(buf[at:]) - tmp := (*bbp.TaggedSubStruct) - at += tmp.Size() + { + tmp := (*bbp.TaggedSubStruct) + at += tmp.Size() + } + return at } return at @@ -305,8 +308,11 @@ func (bbp *TaggedUnion) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := ((*bbp.TaggedSubStruct)) - at += tmp.Size() + { + tmp := ((*bbp.TaggedSubStruct)) + at += tmp.Size() + } + return nil default: return nil @@ -324,8 +330,11 @@ func (bbp *TaggedUnion) MustUnmarshalBebop(buf []byte) { at += 1 bbp.TaggedSubStruct = new(TaggedSubStruct) (*bbp.TaggedSubStruct) = MustMakeTaggedSubStructFromBytes(buf[at:]) - tmp := ((*bbp.TaggedSubStruct)) - at += tmp.Size() + { + tmp := ((*bbp.TaggedSubStruct)) + at += tmp.Size() + } + return default: return @@ -372,8 +381,11 @@ func (bbp TaggedUnion) Size() int { bodyLen := 4 if bbp.TaggedSubStruct != nil { bodyLen += 1 - tmp := (*bbp.TaggedSubStruct) - bodyLen += tmp.Size() + { + tmp := (*bbp.TaggedSubStruct) + bodyLen += tmp.Size() + } + return bodyLen } return bodyLen diff --git a/testdata/generated/union.go b/testdata/generated/union.go index 3160b3b..cf90e95 100644 --- a/testdata/generated/union.go +++ b/testdata/generated/union.go @@ -263,24 +263,33 @@ func (bbp U) MarshalBebopTo(buf []byte) int { buf[at] = 1 at++ (*bbp.A).MarshalBebopTo(buf[at:]) - tmp := (*bbp.A) - at += tmp.Size() + { + tmp := (*bbp.A) + at += tmp.Size() + } + return at } if bbp.B != nil { buf[at] = 2 at++ (*bbp.B).MarshalBebopTo(buf[at:]) - tmp := (*bbp.B) - at += tmp.Size() + { + tmp := (*bbp.B) + at += tmp.Size() + } + return at } if bbp.C != nil { buf[at] = 3 at++ (*bbp.C).MarshalBebopTo(buf[at:]) - tmp := (*bbp.C) - at += tmp.Size() + { + tmp := (*bbp.C) + at += tmp.Size() + } + return at } return at @@ -302,8 +311,11 @@ func (bbp *U) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := ((*bbp.A)) - at += tmp.Size() + { + tmp := ((*bbp.A)) + at += tmp.Size() + } + return nil case 2: at += 1 @@ -312,8 +324,11 @@ func (bbp *U) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := ((*bbp.B)) - at += tmp.Size() + { + tmp := ((*bbp.B)) + at += tmp.Size() + } + return nil case 3: at += 1 @@ -322,8 +337,11 @@ func (bbp *U) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := ((*bbp.C)) - at += tmp.Size() + { + tmp := ((*bbp.C)) + at += tmp.Size() + } + return nil default: return nil @@ -341,22 +359,31 @@ func (bbp *U) MustUnmarshalBebop(buf []byte) { at += 1 bbp.A = new(A) (*bbp.A) = MustMakeAFromBytes(buf[at:]) - tmp := ((*bbp.A)) - at += tmp.Size() + { + tmp := ((*bbp.A)) + at += tmp.Size() + } + return case 2: at += 1 bbp.B = new(B) (*bbp.B) = MustMakeBFromBytes(buf[at:]) - tmp := ((*bbp.B)) - at += tmp.Size() + { + tmp := ((*bbp.B)) + at += tmp.Size() + } + return case 3: at += 1 bbp.C = new(C) (*bbp.C) = MustMakeCFromBytes(buf[at:]) - tmp := ((*bbp.C)) - at += tmp.Size() + { + tmp := ((*bbp.C)) + at += tmp.Size() + } + return default: return @@ -435,20 +462,29 @@ func (bbp U) Size() int { bodyLen := 4 if bbp.A != nil { bodyLen += 1 - tmp := (*bbp.A) - bodyLen += tmp.Size() + { + tmp := (*bbp.A) + bodyLen += tmp.Size() + } + return bodyLen } if bbp.B != nil { bodyLen += 1 - tmp := (*bbp.B) - bodyLen += tmp.Size() + { + tmp := (*bbp.B) + bodyLen += tmp.Size() + } + return bodyLen } if bbp.C != nil { bodyLen += 1 - tmp := (*bbp.C) - bodyLen += tmp.Size() + { + tmp := (*bbp.C) + bodyLen += tmp.Size() + } + return bodyLen } return bodyLen @@ -490,8 +526,11 @@ func (bbp Cons) MarshalBebopTo(buf []byte) int { iohelp.WriteUint32Bytes(buf[at:], bbp.Head) at += 4 (bbp.Tail).MarshalBebopTo(buf[at:]) - tmp := (bbp.Tail) - at += tmp.Size() + { + tmp := (bbp.Tail) + at += tmp.Size() + } + return at } @@ -506,8 +545,11 @@ func (bbp *Cons) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := (bbp.Tail) - at += tmp.Size() + { + tmp := (bbp.Tail) + at += tmp.Size() + } + return nil } @@ -516,8 +558,11 @@ func (bbp *Cons) MustUnmarshalBebop(buf []byte) { bbp.Head = iohelp.ReadUint32Bytes(buf[at:]) at += 4 bbp.Tail = MustMakeListFromBytes(buf[at:]) - tmp := (bbp.Tail) - at += tmp.Size() + { + tmp := (bbp.Tail) + at += tmp.Size() + } + } func (bbp Cons) EncodeBebop(iow io.Writer) (err error) { @@ -543,8 +588,11 @@ func (bbp *Cons) DecodeBebop(ior io.Reader) (err error) { func (bbp Cons) Size() int { bodyLen := 0 bodyLen += 4 - tmp := (bbp.Tail) - bodyLen += tmp.Size() + { + tmp := (bbp.Tail) + bodyLen += tmp.Size() + } + return bodyLen } @@ -632,16 +680,22 @@ func (bbp List) MarshalBebopTo(buf []byte) int { buf[at] = 1 at++ (*bbp.Cons).MarshalBebopTo(buf[at:]) - tmp := (*bbp.Cons) - at += tmp.Size() + { + tmp := (*bbp.Cons) + at += tmp.Size() + } + return at } if bbp.Null != nil { buf[at] = 2 at++ (*bbp.Null).MarshalBebopTo(buf[at:]) - tmp := (*bbp.Null) - at += tmp.Size() + { + tmp := (*bbp.Null) + at += tmp.Size() + } + return at } return at @@ -663,8 +717,11 @@ func (bbp *List) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := ((*bbp.Cons)) - at += tmp.Size() + { + tmp := ((*bbp.Cons)) + at += tmp.Size() + } + return nil case 2: at += 1 @@ -673,8 +730,11 @@ func (bbp *List) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := ((*bbp.Null)) - at += tmp.Size() + { + tmp := ((*bbp.Null)) + at += tmp.Size() + } + return nil default: return nil @@ -692,15 +752,21 @@ func (bbp *List) MustUnmarshalBebop(buf []byte) { at += 1 bbp.Cons = new(Cons) (*bbp.Cons) = MustMakeConsFromBytes(buf[at:]) - tmp := ((*bbp.Cons)) - at += tmp.Size() + { + tmp := ((*bbp.Cons)) + at += tmp.Size() + } + return case 2: at += 1 bbp.Null = new(Null) (*bbp.Null) = MustMakeNullFromBytes(buf[at:]) - tmp := ((*bbp.Null)) - at += tmp.Size() + { + tmp := ((*bbp.Null)) + at += tmp.Size() + } + return default: return @@ -763,14 +829,20 @@ func (bbp List) Size() int { bodyLen := 4 if bbp.Cons != nil { bodyLen += 1 - tmp := (*bbp.Cons) - bodyLen += tmp.Size() + { + tmp := (*bbp.Cons) + bodyLen += tmp.Size() + } + return bodyLen } if bbp.Null != nil { bodyLen += 1 - tmp := (*bbp.Null) - bodyLen += tmp.Size() + { + tmp := (*bbp.Null) + bodyLen += tmp.Size() + } + return bodyLen } return bodyLen diff --git a/testdata/generated/union_field.go b/testdata/generated/union_field.go index 7235808..0b62b49 100644 --- a/testdata/generated/union_field.go +++ b/testdata/generated/union_field.go @@ -22,8 +22,11 @@ func (bbp WithUnionField) MarshalBebopTo(buf []byte) int { buf[at] = 1 at++ (*bbp.Test).MarshalBebopTo(buf[at:]) - tmp := (*bbp.Test) - at += tmp.Size() + { + tmp := (*bbp.Test) + at += tmp.Size() + } + } return at } @@ -41,8 +44,11 @@ func (bbp *WithUnionField) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := ((*bbp.Test)) - at += tmp.Size() + { + tmp := ((*bbp.Test)) + at += tmp.Size() + } + default: return nil } @@ -59,8 +65,11 @@ func (bbp *WithUnionField) MustUnmarshalBebop(buf []byte) { at += 1 bbp.Test = new(List2) (*bbp.Test) = MustMakeList2FromBytes(buf[at:]) - tmp := ((*bbp.Test)) - at += tmp.Size() + { + tmp := ((*bbp.Test)) + at += tmp.Size() + } + default: return } @@ -104,8 +113,11 @@ func (bbp WithUnionField) Size() int { bodyLen := 5 if bbp.Test != nil { bodyLen += 1 - tmp := (*bbp.Test) - bodyLen += tmp.Size() + { + tmp := (*bbp.Test) + bodyLen += tmp.Size() + } + } return bodyLen } @@ -272,16 +284,22 @@ func (bbp List2) MarshalBebopTo(buf []byte) int { buf[at] = 1 at++ (*bbp.Cons2).MarshalBebopTo(buf[at:]) - tmp := (*bbp.Cons2) - at += tmp.Size() + { + tmp := (*bbp.Cons2) + at += tmp.Size() + } + return at } if bbp.Nil2 != nil { buf[at] = 2 at++ (*bbp.Nil2).MarshalBebopTo(buf[at:]) - tmp := (*bbp.Nil2) - at += tmp.Size() + { + tmp := (*bbp.Nil2) + at += tmp.Size() + } + return at } return at @@ -303,8 +321,11 @@ func (bbp *List2) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := ((*bbp.Cons2)) - at += tmp.Size() + { + tmp := ((*bbp.Cons2)) + at += tmp.Size() + } + return nil case 2: at += 1 @@ -313,8 +334,11 @@ func (bbp *List2) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := ((*bbp.Nil2)) - at += tmp.Size() + { + tmp := ((*bbp.Nil2)) + at += tmp.Size() + } + return nil default: return nil @@ -332,15 +356,21 @@ func (bbp *List2) MustUnmarshalBebop(buf []byte) { at += 1 bbp.Cons2 = new(Cons2) (*bbp.Cons2) = MustMakeCons2FromBytes(buf[at:]) - tmp := ((*bbp.Cons2)) - at += tmp.Size() + { + tmp := ((*bbp.Cons2)) + at += tmp.Size() + } + return case 2: at += 1 bbp.Nil2 = new(Nil2) (*bbp.Nil2) = MustMakeNil2FromBytes(buf[at:]) - tmp := ((*bbp.Nil2)) - at += tmp.Size() + { + tmp := ((*bbp.Nil2)) + at += tmp.Size() + } + return default: return @@ -403,14 +433,20 @@ func (bbp List2) Size() int { bodyLen := 4 if bbp.Cons2 != nil { bodyLen += 1 - tmp := (*bbp.Cons2) - bodyLen += tmp.Size() + { + tmp := (*bbp.Cons2) + bodyLen += tmp.Size() + } + return bodyLen } if bbp.Nil2 != nil { bodyLen += 1 - tmp := (*bbp.Nil2) - bodyLen += tmp.Size() + { + tmp := (*bbp.Nil2) + bodyLen += tmp.Size() + } + return bodyLen } return bodyLen diff --git a/testdata/incompatible/generated/import_separate_a.go b/testdata/incompatible/generated/import_separate_a.go index 9c4865c..7fcbac4 100644 --- a/testdata/incompatible/generated/import_separate_a.go +++ b/testdata/incompatible/generated/import_separate_a.go @@ -22,8 +22,11 @@ type UsesImport struct { func (bbp UsesImport) MarshalBebopTo(buf []byte) int { at := 0 (bbp.Imported).MarshalBebopTo(buf[at:]) - tmp := (bbp.Imported) - at += tmp.Size() + { + tmp := (bbp.Imported) + at += tmp.Size() + } + return at } @@ -33,16 +36,22 @@ func (bbp *UsesImport) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := (bbp.Imported) - at += tmp.Size() + { + tmp := (bbp.Imported) + at += tmp.Size() + } + return nil } func (bbp *UsesImport) MustUnmarshalBebop(buf []byte) { at := 0 bbp.Imported = generatedtwo.MustMakeImportedTypeFromBytes(buf[at:]) - tmp := (bbp.Imported) - at += tmp.Size() + { + tmp := (bbp.Imported) + at += tmp.Size() + } + } func (bbp UsesImport) EncodeBebop(iow io.Writer) (err error) { @@ -65,8 +74,11 @@ func (bbp *UsesImport) DecodeBebop(ior io.Reader) (err error) { func (bbp UsesImport) Size() int { bodyLen := 0 - tmp := (bbp.Imported) - bodyLen += tmp.Size() + { + tmp := (bbp.Imported) + bodyLen += tmp.Size() + } + return bodyLen } @@ -108,8 +120,11 @@ func (bbp UsesImportMsg) MarshalBebopTo(buf []byte) int { buf[at] = 1 at++ (*bbp.Imported).MarshalBebopTo(buf[at:]) - tmp := (*bbp.Imported) - at += tmp.Size() + { + tmp := (*bbp.Imported) + at += tmp.Size() + } + } return at } @@ -127,8 +142,11 @@ func (bbp *UsesImportMsg) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := ((*bbp.Imported)) - at += tmp.Size() + { + tmp := ((*bbp.Imported)) + at += tmp.Size() + } + default: return nil } @@ -145,8 +163,11 @@ func (bbp *UsesImportMsg) MustUnmarshalBebop(buf []byte) { at += 1 bbp.Imported = new(generatedtwo.ImportedType) (*bbp.Imported) = generatedtwo.MustMakeImportedTypeFromBytes(buf[at:]) - tmp := ((*bbp.Imported)) - at += tmp.Size() + { + tmp := ((*bbp.Imported)) + at += tmp.Size() + } + default: return } @@ -190,8 +211,11 @@ func (bbp UsesImportMsg) Size() int { bodyLen := 5 if bbp.Imported != nil { bodyLen += 1 - tmp := (*bbp.Imported) - bodyLen += tmp.Size() + { + tmp := (*bbp.Imported) + bodyLen += tmp.Size() + } + } return bodyLen } @@ -416,16 +440,22 @@ func (bbp UsesImportUnion) MarshalBebopTo(buf []byte) int { buf[at] = 1 at++ (*bbp.UnionStruct).MarshalBebopTo(buf[at:]) - tmp := (*bbp.UnionStruct) - at += tmp.Size() + { + tmp := (*bbp.UnionStruct) + at += tmp.Size() + } + return at } if bbp.UnionMessage != nil { buf[at] = 2 at++ (*bbp.UnionMessage).MarshalBebopTo(buf[at:]) - tmp := (*bbp.UnionMessage) - at += tmp.Size() + { + tmp := (*bbp.UnionMessage) + at += tmp.Size() + } + return at } return at @@ -447,8 +477,11 @@ func (bbp *UsesImportUnion) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := ((*bbp.UnionStruct)) - at += tmp.Size() + { + tmp := ((*bbp.UnionStruct)) + at += tmp.Size() + } + return nil case 2: at += 1 @@ -457,8 +490,11 @@ func (bbp *UsesImportUnion) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := ((*bbp.UnionMessage)) - at += tmp.Size() + { + tmp := ((*bbp.UnionMessage)) + at += tmp.Size() + } + return nil default: return nil @@ -476,15 +512,21 @@ func (bbp *UsesImportUnion) MustUnmarshalBebop(buf []byte) { at += 1 bbp.UnionStruct = new(UnionStruct) (*bbp.UnionStruct) = MustMakeUnionStructFromBytes(buf[at:]) - tmp := ((*bbp.UnionStruct)) - at += tmp.Size() + { + tmp := ((*bbp.UnionStruct)) + at += tmp.Size() + } + return case 2: at += 1 bbp.UnionMessage = new(UnionMessage) (*bbp.UnionMessage) = MustMakeUnionMessageFromBytes(buf[at:]) - tmp := ((*bbp.UnionMessage)) - at += tmp.Size() + { + tmp := ((*bbp.UnionMessage)) + at += tmp.Size() + } + return default: return @@ -547,14 +589,20 @@ func (bbp UsesImportUnion) Size() int { bodyLen := 4 if bbp.UnionStruct != nil { bodyLen += 1 - tmp := (*bbp.UnionStruct) - bodyLen += tmp.Size() + { + tmp := (*bbp.UnionStruct) + bodyLen += tmp.Size() + } + return bodyLen } if bbp.UnionMessage != nil { bodyLen += 1 - tmp := (*bbp.UnionMessage) - bodyLen += tmp.Size() + { + tmp := (*bbp.UnionMessage) + bodyLen += tmp.Size() + } + return bodyLen } return bodyLen diff --git a/testdata/incompatible/generatedtwo/import_separate_b.go b/testdata/incompatible/generatedtwo/import_separate_b.go index 58d9f7a..397cd94 100644 --- a/testdata/incompatible/generatedtwo/import_separate_b.go +++ b/testdata/incompatible/generatedtwo/import_separate_b.go @@ -113,15 +113,21 @@ func (bbp ImportedMessage) MarshalBebopTo(buf []byte) int { buf[at] = 2 at++ (*bbp.Bar).MarshalBebopTo(buf[at:]) - tmp := (*bbp.Bar) - at += tmp.Size() + { + tmp := (*bbp.Bar) + at += tmp.Size() + } + } if bbp.Unin != nil { buf[at] = 3 at++ (*bbp.Unin).MarshalBebopTo(buf[at:]) - tmp := (*bbp.Unin) - at += tmp.Size() + { + tmp := (*bbp.Unin) + at += tmp.Size() + } + } return at } @@ -144,8 +150,11 @@ func (bbp *ImportedMessage) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := ((*bbp.Bar)) - at += tmp.Size() + { + tmp := ((*bbp.Bar)) + at += tmp.Size() + } + case 3: at += 1 bbp.Unin = new(ImportedUnion) @@ -153,8 +162,11 @@ func (bbp *ImportedMessage) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := ((*bbp.Unin)) - at += tmp.Size() + { + tmp := ((*bbp.Unin)) + at += tmp.Size() + } + default: return nil } @@ -176,14 +188,20 @@ func (bbp *ImportedMessage) MustUnmarshalBebop(buf []byte) { at += 1 bbp.Bar = new(ImportedType) (*bbp.Bar) = MustMakeImportedTypeFromBytes(buf[at:]) - tmp := ((*bbp.Bar)) - at += tmp.Size() + { + tmp := ((*bbp.Bar)) + at += tmp.Size() + } + case 3: at += 1 bbp.Unin = new(ImportedUnion) (*bbp.Unin) = MustMakeImportedUnionFromBytes(buf[at:]) - tmp := ((*bbp.Unin)) - at += tmp.Size() + { + tmp := ((*bbp.Unin)) + at += tmp.Size() + } + default: return } @@ -251,13 +269,19 @@ func (bbp ImportedMessage) Size() int { } if bbp.Bar != nil { bodyLen += 1 - tmp := (*bbp.Bar) - bodyLen += tmp.Size() + { + tmp := (*bbp.Bar) + bodyLen += tmp.Size() + } + } if bbp.Unin != nil { bodyLen += 1 - tmp := (*bbp.Unin) - bodyLen += tmp.Size() + { + tmp := (*bbp.Unin) + bodyLen += tmp.Size() + } + } return bodyLen } @@ -422,16 +446,22 @@ func (bbp ImportedUnion) MarshalBebopTo(buf []byte) int { buf[at] = 1 at++ (*bbp.WhyAreTheseInline).MarshalBebopTo(buf[at:]) - tmp := (*bbp.WhyAreTheseInline) - at += tmp.Size() + { + tmp := (*bbp.WhyAreTheseInline) + at += tmp.Size() + } + return at } if bbp.Really != nil { buf[at] = 2 at++ (*bbp.Really).MarshalBebopTo(buf[at:]) - tmp := (*bbp.Really) - at += tmp.Size() + { + tmp := (*bbp.Really) + at += tmp.Size() + } + return at } return at @@ -453,8 +483,11 @@ func (bbp *ImportedUnion) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := ((*bbp.WhyAreTheseInline)) - at += tmp.Size() + { + tmp := ((*bbp.WhyAreTheseInline)) + at += tmp.Size() + } + return nil case 2: at += 1 @@ -463,8 +496,11 @@ func (bbp *ImportedUnion) UnmarshalBebop(buf []byte) (err error) { if err != nil { return err } - tmp := ((*bbp.Really)) - at += tmp.Size() + { + tmp := ((*bbp.Really)) + at += tmp.Size() + } + return nil default: return nil @@ -482,15 +518,21 @@ func (bbp *ImportedUnion) MustUnmarshalBebop(buf []byte) { at += 1 bbp.WhyAreTheseInline = new(WhyAreTheseInline) (*bbp.WhyAreTheseInline) = MustMakeWhyAreTheseInlineFromBytes(buf[at:]) - tmp := ((*bbp.WhyAreTheseInline)) - at += tmp.Size() + { + tmp := ((*bbp.WhyAreTheseInline)) + at += tmp.Size() + } + return case 2: at += 1 bbp.Really = new(Really) (*bbp.Really) = MustMakeReallyFromBytes(buf[at:]) - tmp := ((*bbp.Really)) - at += tmp.Size() + { + tmp := ((*bbp.Really)) + at += tmp.Size() + } + return default: return @@ -553,14 +595,20 @@ func (bbp ImportedUnion) Size() int { bodyLen := 4 if bbp.WhyAreTheseInline != nil { bodyLen += 1 - tmp := (*bbp.WhyAreTheseInline) - bodyLen += tmp.Size() + { + tmp := (*bbp.WhyAreTheseInline) + bodyLen += tmp.Size() + } + return bodyLen } if bbp.Really != nil { bodyLen += 1 - tmp := (*bbp.Really) - bodyLen += tmp.Size() + { + tmp := (*bbp.Really) + bodyLen += tmp.Size() + } + return bodyLen } return bodyLen From 0b508e2727e5cdb27e0c4a1690e8b2571aa2a7da Mon Sep 17 00:00:00 2001 From: Patrick Stephen Date: Thu, 21 Mar 2024 13:42:22 -0500 Subject: [PATCH 3/5] Add fruit test case demonstrating need for tmp variable blocks --- gen_test.go | 1 + testdata/base/fruit.bop | 10 ++ testdata/generated/fruit.go | 259 ++++++++++++++++++++++++++++++++++++ 3 files changed, 270 insertions(+) create mode 100644 testdata/base/fruit.bop create mode 100644 testdata/generated/fruit.go diff --git a/gen_test.go b/gen_test.go index d3c5ed9..0feeceb 100644 --- a/gen_test.go +++ b/gen_test.go @@ -404,6 +404,7 @@ var genTestFiles = []string{ "documentation", "enums", "foo", + "fruit", "jazz", "lab", "map_types", diff --git a/testdata/base/fruit.bop b/testdata/base/fruit.bop new file mode 100644 index 0000000..2e2dc76 --- /dev/null +++ b/testdata/base/fruit.bop @@ -0,0 +1,10 @@ +struct Fruit { + uint64 ID; + string Name; +} + +struct Basket { + Fruit Apples; + Fruit Oranges; + Fruit Mangos; +} \ No newline at end of file diff --git a/testdata/generated/fruit.go b/testdata/generated/fruit.go new file mode 100644 index 0000000..607b59d --- /dev/null +++ b/testdata/generated/fruit.go @@ -0,0 +1,259 @@ +// Code generated by bebopc-go; DO NOT EDIT. + +package generated + +import ( + "github.com/200sc/bebop" + "github.com/200sc/bebop/iohelp" + "io" +) + +var _ bebop.Record = &Fruit{} + +type Fruit struct { + ID uint64 + Name string +} + +func (bbp Fruit) MarshalBebopTo(buf []byte) int { + at := 0 + iohelp.WriteUint64Bytes(buf[at:], bbp.ID) + at += 8 + iohelp.WriteUint32Bytes(buf[at:], uint32(len(bbp.Name))) + copy(buf[at+4:at+4+len(bbp.Name)], []byte(bbp.Name)) + at += 4 + len(bbp.Name) + return at +} + +func (bbp *Fruit) UnmarshalBebop(buf []byte) (err error) { + at := 0 + if len(buf[at:]) < 8 { + return io.ErrUnexpectedEOF + } + bbp.ID = iohelp.ReadUint64Bytes(buf[at:]) + at += 8 + bbp.Name, err = iohelp.ReadStringBytes(buf[at:]) + if err != nil { + return err + } + at += 4 + len(bbp.Name) + return nil +} + +func (bbp *Fruit) MustUnmarshalBebop(buf []byte) { + at := 0 + bbp.ID = iohelp.ReadUint64Bytes(buf[at:]) + at += 8 + bbp.Name = iohelp.MustReadStringBytes(buf[at:]) + at += 4 + len(bbp.Name) +} + +func (bbp Fruit) EncodeBebop(iow io.Writer) (err error) { + w := iohelp.NewErrorWriter(iow) + iohelp.WriteUint64(w, bbp.ID) + iohelp.WriteUint32(w, uint32(len(bbp.Name))) + w.Write([]byte(bbp.Name)) + return w.Err +} + +func (bbp *Fruit) DecodeBebop(ior io.Reader) (err error) { + r := iohelp.NewErrorReader(ior) + bbp.ID = iohelp.ReadUint64(r) + bbp.Name = iohelp.ReadString(r) + return r.Err +} + +func (bbp Fruit) Size() int { + bodyLen := 0 + bodyLen += 8 + bodyLen += 4 + len(bbp.Name) + return bodyLen +} + +func (bbp Fruit) MarshalBebop() []byte { + buf := make([]byte, bbp.Size()) + bbp.MarshalBebopTo(buf) + return buf +} + +func MakeFruit(r *iohelp.ErrorReader) (Fruit, error) { + v := Fruit{} + err := v.DecodeBebop(r) + return v, err +} + +func MakeFruitFromBytes(buf []byte) (Fruit, error) { + v := Fruit{} + err := v.UnmarshalBebop(buf) + return v, err +} + +func MustMakeFruitFromBytes(buf []byte) Fruit { + v := Fruit{} + v.MustUnmarshalBebop(buf) + return v +} + +var _ bebop.Record = &Basket{} + +type Basket struct { + Apples Fruit + Oranges Fruit + Mangos Fruit +} + +func (bbp Basket) MarshalBebopTo(buf []byte) int { + at := 0 + (bbp.Apples).MarshalBebopTo(buf[at:]) + { + tmp := (bbp.Apples) + at += tmp.Size() + } + + (bbp.Oranges).MarshalBebopTo(buf[at:]) + { + tmp := (bbp.Oranges) + at += tmp.Size() + } + + (bbp.Mangos).MarshalBebopTo(buf[at:]) + { + tmp := (bbp.Mangos) + at += tmp.Size() + } + + return at +} + +func (bbp *Basket) UnmarshalBebop(buf []byte) (err error) { + at := 0 + bbp.Apples, err = MakeFruitFromBytes(buf[at:]) + if err != nil { + return err + } + { + tmp := (bbp.Apples) + at += tmp.Size() + } + + bbp.Oranges, err = MakeFruitFromBytes(buf[at:]) + if err != nil { + return err + } + { + tmp := (bbp.Oranges) + at += tmp.Size() + } + + bbp.Mangos, err = MakeFruitFromBytes(buf[at:]) + if err != nil { + return err + } + { + tmp := (bbp.Mangos) + at += tmp.Size() + } + + return nil +} + +func (bbp *Basket) MustUnmarshalBebop(buf []byte) { + at := 0 + bbp.Apples = MustMakeFruitFromBytes(buf[at:]) + { + tmp := (bbp.Apples) + at += tmp.Size() + } + + bbp.Oranges = MustMakeFruitFromBytes(buf[at:]) + { + tmp := (bbp.Oranges) + at += tmp.Size() + } + + bbp.Mangos = MustMakeFruitFromBytes(buf[at:]) + { + tmp := (bbp.Mangos) + at += tmp.Size() + } + +} + +func (bbp Basket) EncodeBebop(iow io.Writer) (err error) { + w := iohelp.NewErrorWriter(iow) + err = (bbp.Apples).EncodeBebop(w) + if err != nil { + return err + } + err = (bbp.Oranges).EncodeBebop(w) + if err != nil { + return err + } + err = (bbp.Mangos).EncodeBebop(w) + if err != nil { + return err + } + return w.Err +} + +func (bbp *Basket) DecodeBebop(ior io.Reader) (err error) { + r := iohelp.NewErrorReader(ior) + (bbp.Apples), err = MakeFruit(r) + if err != nil { + return err + } + (bbp.Oranges), err = MakeFruit(r) + if err != nil { + return err + } + (bbp.Mangos), err = MakeFruit(r) + if err != nil { + return err + } + return r.Err +} + +func (bbp Basket) Size() int { + bodyLen := 0 + { + tmp := (bbp.Apples) + bodyLen += tmp.Size() + } + + { + tmp := (bbp.Oranges) + bodyLen += tmp.Size() + } + + { + tmp := (bbp.Mangos) + bodyLen += tmp.Size() + } + + return bodyLen +} + +func (bbp Basket) MarshalBebop() []byte { + buf := make([]byte, bbp.Size()) + bbp.MarshalBebopTo(buf) + return buf +} + +func MakeBasket(r *iohelp.ErrorReader) (Basket, error) { + v := Basket{} + err := v.DecodeBebop(r) + return v, err +} + +func MakeBasketFromBytes(buf []byte) (Basket, error) { + v := Basket{} + err := v.UnmarshalBebop(buf) + return v, err +} + +func MustMakeBasketFromBytes(buf []byte) Basket { + v := Basket{} + v.MustUnmarshalBebop(buf) + return v +} + From 942c291ed2c9d590da03f6c3ba33fd57af6388ba Mon Sep 17 00:00:00 2001 From: Patrick Stephen Date: Thu, 21 Mar 2024 13:44:50 -0500 Subject: [PATCH 4/5] Bump to 0.6.0 --- bebop.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bebop.go b/bebop.go index 629cd93..8770df8 100644 --- a/bebop.go +++ b/bebop.go @@ -2,7 +2,7 @@ package bebop // Version is the library version. Should be used by CLI tools when passed a '--version' flag. -const Version = "v0.5.0" +const Version = "v0.6.0" // A File is a structured representation of a .bop file. type File struct { From a0b9faa65007e0903d231e53aa674aa8ed918d2f Mon Sep 17 00:00:00 2001 From: Patrick Stephen Date: Thu, 21 Mar 2024 13:54:07 -0500 Subject: [PATCH 5/5] Add notes on adding failure test cases to CONTRIBUTING --- CONTRIBUTING.md | 8 ++++++++ tokenize_test.go | 6 +++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index dc83047..d20a950 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -4,3 +4,11 @@ Please raise issues for discussion before opening PRs (or ideally before startin just to save time if its not the direction we want to take the project. For small changes (anywhere from typos to non-breaking bug fixes) going straight to a PR is fine, but not required. + +## Testing + +This library is organized so `go test -v` will test tokenization, parsing, code generation, and the validity of the output generated code. Output code is validated via some integrated tests, and by relying on `go test` itself checking that output can be compiled. + +If an example file fails tokenization, it can be added to `testTokenizeFiles` to track that failure and prevent regressions. Likewise for parsing, `TestReadFile` notes expected parsing output. Adding a variant that just ensures a file -can- be parsed, not ensuring a particular AST, is a welcome augmentation. + +For generated code, add the example file to `generated/base` and add it's name, minus `.bop`, to `genTestFiles`. diff --git a/tokenize_test.go b/tokenize_test.go index 45aac25..e67a3e0 100644 --- a/tokenize_test.go +++ b/tokenize_test.go @@ -8,7 +8,7 @@ import ( "testing" ) -var testFiles = []string{ +var testTokenizeFiles = []string{ "array_of_strings", "all_consts", "basic_arrays", @@ -31,7 +31,7 @@ var testFiles = []string{ func TestTokenize(t *testing.T) { t.Parallel() - for _, filename := range testFiles { + for _, filename := range testTokenizeFiles { filename := filename t.Run(filename, func(t *testing.T) { t.Parallel() @@ -111,7 +111,7 @@ func TestTokenizeNoSemis(t *testing.T) { "import": "import semis cannot be added", "msgpack_comparison": "we are naively removing semis from within comments", } - for _, filename := range testFiles { + for _, filename := range testTokenizeFiles { filename := filename t.Run(filename, func(t *testing.T) { t.Parallel()