diff --git a/internal/tlcodegen/test/gen/cases/internal/tl/tlBuiltinTuple2Int/int.go b/internal/tlcodegen/test/gen/cases/internal/tl/tlBuiltinTuple2Int/int.go new file mode 100644 index 00000000..eb2ce0f5 --- /dev/null +++ b/internal/tlcodegen/test/gen/cases/internal/tl/tlBuiltinTuple2Int/int.go @@ -0,0 +1,85 @@ +// Copyright 2022 V Kontakte LLC +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at https://mozilla.org/MPL/2.0/. + +// Code generated by vktl/cmd/tlgen2; DO NOT EDIT. +package tlBuiltinTuple2Int + +import ( + "github.com/vkcom/tl/internal/tlcodegen/test/gen/cases/internal" + "github.com/vkcom/tl/pkg/basictl" +) + +var _ = basictl.NatWrite +var _ = internal.ErrorInvalidEnumTag + +func BuiltinTuple2IntReset(vec *[2]int32) { + for i := range *vec { + (*vec)[i] = 0 + } +} + +func BuiltinTuple2IntFillRandom(rg *basictl.RandGenerator, vec *[2]int32) { + rg.IncreaseDepth() + for i := range *vec { + (*vec)[i] = basictl.RandomInt(rg) + } + rg.DecreaseDepth() +} + +func BuiltinTuple2IntRead(w []byte, vec *[2]int32) (_ []byte, err error) { + for i := range *vec { + if w, err = basictl.IntRead(w, &(*vec)[i]); err != nil { + return w, err + } + } + return w, nil +} + +func BuiltinTuple2IntWrite(w []byte, vec *[2]int32) []byte { + for _, elem := range *vec { + w = basictl.IntWrite(w, elem) + } + return w +} + +func BuiltinTuple2IntReadJSON(legacyTypeNames bool, in *basictl.JsonLexer, vec *[2]int32) error { + index := 0 + if in != nil { + in.Delim('[') + if !in.Ok() { + return internal.ErrorInvalidJSON("[2]int32", "expected json array") + } + for ; !in.IsDelim(']'); index++ { + if index == 2 { + return internal.ErrorWrongSequenceLength("[2]int32", index+1, 2) + } + if err := internal.Json2ReadInt32(in, &(*vec)[index]); err != nil { + return err + } + in.WantComma() + } + in.Delim(']') + if !in.Ok() { + return internal.ErrorInvalidJSON("[2]int32", "expected json array's end") + } + } + if index != 2 { + return internal.ErrorWrongSequenceLength("[2]int32", index+1, 2) + } + return nil +} + +func BuiltinTuple2IntWriteJSON(w []byte, vec *[2]int32) []byte { + return BuiltinTuple2IntWriteJSONOpt(true, false, w, vec) +} +func BuiltinTuple2IntWriteJSONOpt(newTypeNames bool, short bool, w []byte, vec *[2]int32) []byte { + w = append(w, '[') + for _, elem := range *vec { + w = basictl.JSONAddCommaIfNeeded(w) + w = basictl.JSONWriteInt32(w, elem) + } + return append(w, ']') +} diff --git a/internal/tlcodegen/test/gen/cases/internal/tl/tlBuiltinTuple2PairTupleIntTupleInt/pair.go b/internal/tlcodegen/test/gen/cases/internal/tl/tlBuiltinTuple2PairTupleIntTupleInt/pair.go new file mode 100644 index 00000000..4eed6119 --- /dev/null +++ b/internal/tlcodegen/test/gen/cases/internal/tl/tlBuiltinTuple2PairTupleIntTupleInt/pair.go @@ -0,0 +1,90 @@ +// Copyright 2022 V Kontakte LLC +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at https://mozilla.org/MPL/2.0/. + +// Code generated by vktl/cmd/tlgen2; DO NOT EDIT. +package tlBuiltinTuple2PairTupleIntTupleInt + +import ( + "github.com/vkcom/tl/internal/tlcodegen/test/gen/cases/internal" + "github.com/vkcom/tl/internal/tlcodegen/test/gen/cases/internal/tl/tlPairTupleIntTupleInt" + "github.com/vkcom/tl/pkg/basictl" +) + +var _ = basictl.NatWrite +var _ = internal.ErrorInvalidEnumTag + +func BuiltinTuple2PairTupleIntTupleIntReset(vec *[2]tlPairTupleIntTupleInt.PairTupleIntTupleInt) { + for i := range *vec { + (*vec)[i].Reset() + } +} + +func BuiltinTuple2PairTupleIntTupleIntFillRandom(rg *basictl.RandGenerator, vec *[2]tlPairTupleIntTupleInt.PairTupleIntTupleInt, nat_tXn uint32, nat_tYn uint32) { + rg.IncreaseDepth() + for i := range *vec { + (*vec)[i].FillRandom(rg, nat_tXn, nat_tYn) + } + rg.DecreaseDepth() +} + +func BuiltinTuple2PairTupleIntTupleIntRead(w []byte, vec *[2]tlPairTupleIntTupleInt.PairTupleIntTupleInt, nat_tXn uint32, nat_tYn uint32) (_ []byte, err error) { + for i := range *vec { + if w, err = (*vec)[i].Read(w, nat_tXn, nat_tYn); err != nil { + return w, err + } + } + return w, nil +} + +func BuiltinTuple2PairTupleIntTupleIntWrite(w []byte, vec *[2]tlPairTupleIntTupleInt.PairTupleIntTupleInt, nat_tXn uint32, nat_tYn uint32) (_ []byte, err error) { + for _, elem := range *vec { + if w, err = elem.Write(w, nat_tXn, nat_tYn); err != nil { + return w, err + } + } + return w, nil +} + +func BuiltinTuple2PairTupleIntTupleIntReadJSON(legacyTypeNames bool, in *basictl.JsonLexer, vec *[2]tlPairTupleIntTupleInt.PairTupleIntTupleInt, nat_tXn uint32, nat_tYn uint32) error { + index := 0 + if in != nil { + in.Delim('[') + if !in.Ok() { + return internal.ErrorInvalidJSON("[2]tlPairTupleIntTupleInt.PairTupleIntTupleInt", "expected json array") + } + for ; !in.IsDelim(']'); index++ { + if index == 2 { + return internal.ErrorWrongSequenceLength("[2]tlPairTupleIntTupleInt.PairTupleIntTupleInt", index+1, 2) + } + if err := (*vec)[index].ReadJSON(legacyTypeNames, in, nat_tXn, nat_tYn); err != nil { + return err + } + in.WantComma() + } + in.Delim(']') + if !in.Ok() { + return internal.ErrorInvalidJSON("[2]tlPairTupleIntTupleInt.PairTupleIntTupleInt", "expected json array's end") + } + } + if index != 2 { + return internal.ErrorWrongSequenceLength("[2]tlPairTupleIntTupleInt.PairTupleIntTupleInt", index+1, 2) + } + return nil +} + +func BuiltinTuple2PairTupleIntTupleIntWriteJSON(w []byte, vec *[2]tlPairTupleIntTupleInt.PairTupleIntTupleInt, nat_tXn uint32, nat_tYn uint32) (_ []byte, err error) { + return BuiltinTuple2PairTupleIntTupleIntWriteJSONOpt(true, false, w, vec, nat_tXn, nat_tYn) +} +func BuiltinTuple2PairTupleIntTupleIntWriteJSONOpt(newTypeNames bool, short bool, w []byte, vec *[2]tlPairTupleIntTupleInt.PairTupleIntTupleInt, nat_tXn uint32, nat_tYn uint32) (_ []byte, err error) { + w = append(w, '[') + for _, elem := range *vec { + w = basictl.JSONAddCommaIfNeeded(w) + if w, err = elem.WriteJSONOpt(newTypeNames, short, w, nat_tXn, nat_tYn); err != nil { + return w, err + } + } + return append(w, ']'), nil +} diff --git a/internal/tlcodegen/test/gen/cases/internal/tl/tlBuiltinTupleTupleInt2/tuple.go b/internal/tlcodegen/test/gen/cases/internal/tl/tlBuiltinTupleTupleInt2/tuple.go new file mode 100644 index 00000000..1d082d22 --- /dev/null +++ b/internal/tlcodegen/test/gen/cases/internal/tl/tlBuiltinTupleTupleInt2/tuple.go @@ -0,0 +1,100 @@ +// Copyright 2022 V Kontakte LLC +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at https://mozilla.org/MPL/2.0/. + +// Code generated by vktl/cmd/tlgen2; DO NOT EDIT. +package tlBuiltinTupleTupleInt2 + +import ( + "github.com/vkcom/tl/internal/tlcodegen/test/gen/cases/internal" + "github.com/vkcom/tl/internal/tlcodegen/test/gen/cases/internal/tl/tlBuiltinTuple2Int" + "github.com/vkcom/tl/pkg/basictl" +) + +var _ = basictl.NatWrite +var _ = internal.ErrorInvalidEnumTag + +func BuiltinTupleTupleInt2FillRandom(rg *basictl.RandGenerator, vec *[][2]int32, nat_n uint32) { + rg.IncreaseDepth() + *vec = make([][2]int32, nat_n) + for i := range *vec { + tlBuiltinTuple2Int.BuiltinTuple2IntFillRandom(rg, &(*vec)[i]) + } + rg.DecreaseDepth() +} + +func BuiltinTupleTupleInt2Read(w []byte, vec *[][2]int32, nat_n uint32) (_ []byte, err error) { + if err = basictl.CheckLengthSanity(w, nat_n, 4); err != nil { + return w, err + } + if uint32(cap(*vec)) < nat_n { + *vec = make([][2]int32, nat_n) + } else { + *vec = (*vec)[:nat_n] + } + for i := range *vec { + if w, err = tlBuiltinTuple2Int.BuiltinTuple2IntRead(w, &(*vec)[i]); err != nil { + return w, err + } + } + return w, nil +} + +func BuiltinTupleTupleInt2Write(w []byte, vec [][2]int32, nat_n uint32) (_ []byte, err error) { + if uint32(len(vec)) != nat_n { + return w, internal.ErrorWrongSequenceLength("[][2]int32", len(vec), nat_n) + } + for _, elem := range vec { + w = tlBuiltinTuple2Int.BuiltinTuple2IntWrite(w, &elem) + } + return w, nil +} + +func BuiltinTupleTupleInt2ReadJSON(legacyTypeNames bool, in *basictl.JsonLexer, vec *[][2]int32, nat_n uint32) error { + if uint32(cap(*vec)) < nat_n { + *vec = make([][2]int32, nat_n) + } else { + *vec = (*vec)[:nat_n] + } + index := 0 + if in != nil { + in.Delim('[') + if !in.Ok() { + return internal.ErrorInvalidJSON("[][2]int32", "expected json array") + } + for ; !in.IsDelim(']'); index++ { + if nat_n <= uint32(index) { + return internal.ErrorInvalidJSON("[][2]int32", "array is longer than expected") + } + if err := tlBuiltinTuple2Int.BuiltinTuple2IntReadJSON(legacyTypeNames, in, &(*vec)[index]); err != nil { + return err + } + in.WantComma() + } + in.Delim(']') + if !in.Ok() { + return internal.ErrorInvalidJSON("[][2]int32", "expected json array's end") + } + } + if uint32(index) != nat_n { + return internal.ErrorWrongSequenceLength("[][2]int32", index, nat_n) + } + return nil +} + +func BuiltinTupleTupleInt2WriteJSON(w []byte, vec [][2]int32, nat_n uint32) (_ []byte, err error) { + return BuiltinTupleTupleInt2WriteJSONOpt(true, false, w, vec, nat_n) +} +func BuiltinTupleTupleInt2WriteJSONOpt(newTypeNames bool, short bool, w []byte, vec [][2]int32, nat_n uint32) (_ []byte, err error) { + if uint32(len(vec)) != nat_n { + return w, internal.ErrorWrongSequenceLength("[][2]int32", len(vec), nat_n) + } + w = append(w, '[') + for _, elem := range vec { + w = basictl.JSONAddCommaIfNeeded(w) + w = tlBuiltinTuple2Int.BuiltinTuple2IntWriteJSONOpt(newTypeNames, short, w, &elem) + } + return append(w, ']'), nil +} diff --git a/internal/tlcodegen/test/gen/cases/internal/tl/tlBuiltinTupleTuplePairTupleIntTupleInt2/tuple.go b/internal/tlcodegen/test/gen/cases/internal/tl/tlBuiltinTupleTuplePairTupleIntTupleInt2/tuple.go new file mode 100644 index 00000000..6994cd67 --- /dev/null +++ b/internal/tlcodegen/test/gen/cases/internal/tl/tlBuiltinTupleTuplePairTupleIntTupleInt2/tuple.go @@ -0,0 +1,105 @@ +// Copyright 2022 V Kontakte LLC +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at https://mozilla.org/MPL/2.0/. + +// Code generated by vktl/cmd/tlgen2; DO NOT EDIT. +package tlBuiltinTupleTuplePairTupleIntTupleInt2 + +import ( + "github.com/vkcom/tl/internal/tlcodegen/test/gen/cases/internal" + "github.com/vkcom/tl/internal/tlcodegen/test/gen/cases/internal/tl/tlBuiltinTuple2PairTupleIntTupleInt" + "github.com/vkcom/tl/internal/tlcodegen/test/gen/cases/internal/tl/tlPairTupleIntTupleInt" + "github.com/vkcom/tl/pkg/basictl" +) + +var _ = basictl.NatWrite +var _ = internal.ErrorInvalidEnumTag + +func BuiltinTupleTuplePairTupleIntTupleInt2FillRandom(rg *basictl.RandGenerator, vec *[][2]tlPairTupleIntTupleInt.PairTupleIntTupleInt, nat_n uint32, nat_ttXn uint32, nat_ttYn uint32) { + rg.IncreaseDepth() + *vec = make([][2]tlPairTupleIntTupleInt.PairTupleIntTupleInt, nat_n) + for i := range *vec { + tlBuiltinTuple2PairTupleIntTupleInt.BuiltinTuple2PairTupleIntTupleIntFillRandom(rg, &(*vec)[i], nat_ttXn, nat_ttYn) + } + rg.DecreaseDepth() +} + +func BuiltinTupleTuplePairTupleIntTupleInt2Read(w []byte, vec *[][2]tlPairTupleIntTupleInt.PairTupleIntTupleInt, nat_n uint32, nat_ttXn uint32, nat_ttYn uint32) (_ []byte, err error) { + if err = basictl.CheckLengthSanity(w, nat_n, 4); err != nil { + return w, err + } + if uint32(cap(*vec)) < nat_n { + *vec = make([][2]tlPairTupleIntTupleInt.PairTupleIntTupleInt, nat_n) + } else { + *vec = (*vec)[:nat_n] + } + for i := range *vec { + if w, err = tlBuiltinTuple2PairTupleIntTupleInt.BuiltinTuple2PairTupleIntTupleIntRead(w, &(*vec)[i], nat_ttXn, nat_ttYn); err != nil { + return w, err + } + } + return w, nil +} + +func BuiltinTupleTuplePairTupleIntTupleInt2Write(w []byte, vec [][2]tlPairTupleIntTupleInt.PairTupleIntTupleInt, nat_n uint32, nat_ttXn uint32, nat_ttYn uint32) (_ []byte, err error) { + if uint32(len(vec)) != nat_n { + return w, internal.ErrorWrongSequenceLength("[][2]tlPairTupleIntTupleInt.PairTupleIntTupleInt", len(vec), nat_n) + } + for _, elem := range vec { + if w, err = tlBuiltinTuple2PairTupleIntTupleInt.BuiltinTuple2PairTupleIntTupleIntWrite(w, &elem, nat_ttXn, nat_ttYn); err != nil { + return w, err + } + } + return w, nil +} + +func BuiltinTupleTuplePairTupleIntTupleInt2ReadJSON(legacyTypeNames bool, in *basictl.JsonLexer, vec *[][2]tlPairTupleIntTupleInt.PairTupleIntTupleInt, nat_n uint32, nat_ttXn uint32, nat_ttYn uint32) error { + if uint32(cap(*vec)) < nat_n { + *vec = make([][2]tlPairTupleIntTupleInt.PairTupleIntTupleInt, nat_n) + } else { + *vec = (*vec)[:nat_n] + } + index := 0 + if in != nil { + in.Delim('[') + if !in.Ok() { + return internal.ErrorInvalidJSON("[][2]tlPairTupleIntTupleInt.PairTupleIntTupleInt", "expected json array") + } + for ; !in.IsDelim(']'); index++ { + if nat_n <= uint32(index) { + return internal.ErrorInvalidJSON("[][2]tlPairTupleIntTupleInt.PairTupleIntTupleInt", "array is longer than expected") + } + if err := tlBuiltinTuple2PairTupleIntTupleInt.BuiltinTuple2PairTupleIntTupleIntReadJSON(legacyTypeNames, in, &(*vec)[index], nat_ttXn, nat_ttYn); err != nil { + return err + } + in.WantComma() + } + in.Delim(']') + if !in.Ok() { + return internal.ErrorInvalidJSON("[][2]tlPairTupleIntTupleInt.PairTupleIntTupleInt", "expected json array's end") + } + } + if uint32(index) != nat_n { + return internal.ErrorWrongSequenceLength("[][2]tlPairTupleIntTupleInt.PairTupleIntTupleInt", index, nat_n) + } + return nil +} + +func BuiltinTupleTuplePairTupleIntTupleInt2WriteJSON(w []byte, vec [][2]tlPairTupleIntTupleInt.PairTupleIntTupleInt, nat_n uint32, nat_ttXn uint32, nat_ttYn uint32) (_ []byte, err error) { + return BuiltinTupleTuplePairTupleIntTupleInt2WriteJSONOpt(true, false, w, vec, nat_n, nat_ttXn, nat_ttYn) +} +func BuiltinTupleTuplePairTupleIntTupleInt2WriteJSONOpt(newTypeNames bool, short bool, w []byte, vec [][2]tlPairTupleIntTupleInt.PairTupleIntTupleInt, nat_n uint32, nat_ttXn uint32, nat_ttYn uint32) (_ []byte, err error) { + if uint32(len(vec)) != nat_n { + return w, internal.ErrorWrongSequenceLength("[][2]tlPairTupleIntTupleInt.PairTupleIntTupleInt", len(vec), nat_n) + } + w = append(w, '[') + for _, elem := range vec { + w = basictl.JSONAddCommaIfNeeded(w) + if w, err = tlBuiltinTuple2PairTupleIntTupleInt.BuiltinTuple2PairTupleIntTupleIntWriteJSONOpt(newTypeNames, short, w, &elem, nat_ttXn, nat_ttYn); err != nil { + return w, err + } + } + return append(w, ']'), nil +} diff --git a/internal/tlcodegen/test/gen/cases/internal/tl/tlPairTupleIntTupleInt/pair.go b/internal/tlcodegen/test/gen/cases/internal/tl/tlPairTupleIntTupleInt/pair.go new file mode 100644 index 00000000..0db4199a --- /dev/null +++ b/internal/tlcodegen/test/gen/cases/internal/tl/tlPairTupleIntTupleInt/pair.go @@ -0,0 +1,165 @@ +// Copyright 2022 V Kontakte LLC +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at https://mozilla.org/MPL/2.0/. + +// Code generated by vktl/cmd/tlgen2; DO NOT EDIT. +package tlPairTupleIntTupleInt + +import ( + "github.com/vkcom/tl/internal/tlcodegen/test/gen/cases/internal" + "github.com/vkcom/tl/internal/tlcodegen/test/gen/cases/internal/tl/tlBuiltinTupleInt" + "github.com/vkcom/tl/pkg/basictl" +) + +var _ = basictl.NatWrite +var _ = internal.ErrorInvalidEnumTag + +type PairTupleIntTupleInt struct { + X []int32 + Y []int32 +} + +func (PairTupleIntTupleInt) TLName() string { return "pair" } +func (PairTupleIntTupleInt) TLTag() uint32 { return 0xf01604df } + +func (item *PairTupleIntTupleInt) Reset() { + item.X = item.X[:0] + item.Y = item.Y[:0] +} + +func (item *PairTupleIntTupleInt) FillRandom(rg *basictl.RandGenerator, nat_X uint32, nat_Y uint32) { + tlBuiltinTupleInt.BuiltinTupleIntFillRandom(rg, &item.X, nat_X) + tlBuiltinTupleInt.BuiltinTupleIntFillRandom(rg, &item.Y, nat_Y) +} + +func (item *PairTupleIntTupleInt) Read(w []byte, nat_X uint32, nat_Y uint32) (_ []byte, err error) { + if w, err = tlBuiltinTupleInt.BuiltinTupleIntRead(w, &item.X, nat_X); err != nil { + return w, err + } + return tlBuiltinTupleInt.BuiltinTupleIntRead(w, &item.Y, nat_Y) +} + +// This method is general version of Write, use it instead! +func (item *PairTupleIntTupleInt) WriteGeneral(w []byte, nat_X uint32, nat_Y uint32) (_ []byte, err error) { + return item.Write(w, nat_X, nat_Y) +} + +func (item *PairTupleIntTupleInt) Write(w []byte, nat_X uint32, nat_Y uint32) (_ []byte, err error) { + if w, err = tlBuiltinTupleInt.BuiltinTupleIntWrite(w, item.X, nat_X); err != nil { + return w, err + } + if w, err = tlBuiltinTupleInt.BuiltinTupleIntWrite(w, item.Y, nat_Y); err != nil { + return w, err + } + return w, nil +} + +func (item *PairTupleIntTupleInt) ReadBoxed(w []byte, nat_X uint32, nat_Y uint32) (_ []byte, err error) { + if w, err = basictl.NatReadExactTag(w, 0xf01604df); err != nil { + return w, err + } + return item.Read(w, nat_X, nat_Y) +} + +// This method is general version of WriteBoxed, use it instead! +func (item *PairTupleIntTupleInt) WriteBoxedGeneral(w []byte, nat_X uint32, nat_Y uint32) (_ []byte, err error) { + return item.WriteBoxed(w, nat_X, nat_Y) +} + +func (item *PairTupleIntTupleInt) WriteBoxed(w []byte, nat_X uint32, nat_Y uint32) (_ []byte, err error) { + w = basictl.NatWrite(w, 0xf01604df) + return item.Write(w, nat_X, nat_Y) +} + +func (item *PairTupleIntTupleInt) ReadJSON(legacyTypeNames bool, in *basictl.JsonLexer, nat_X uint32, nat_Y uint32) error { + var rawX []byte + var rawY []byte + + if in != nil { + in.Delim('{') + if !in.Ok() { + return in.Error() + } + for !in.IsDelim('}') { + key := in.UnsafeFieldName(true) + in.WantColon() + switch key { + case "x": + if rawX != nil { + return internal.ErrorInvalidJSONWithDuplicatingKeys("pair", "x") + } + rawX = in.Raw() + if !in.Ok() { + return in.Error() + } + case "y": + if rawY != nil { + return internal.ErrorInvalidJSONWithDuplicatingKeys("pair", "y") + } + rawY = in.Raw() + if !in.Ok() { + return in.Error() + } + default: + return internal.ErrorInvalidJSONExcessElement("pair", key) + } + in.WantComma() + } + in.Delim('}') + if !in.Ok() { + return in.Error() + } + } + var inXPointer *basictl.JsonLexer + inX := basictl.JsonLexer{Data: rawX} + if rawX != nil { + inXPointer = &inX + } + if err := tlBuiltinTupleInt.BuiltinTupleIntReadJSON(legacyTypeNames, inXPointer, &item.X, nat_X); err != nil { + return err + } + + var inYPointer *basictl.JsonLexer + inY := basictl.JsonLexer{Data: rawY} + if rawY != nil { + inYPointer = &inY + } + if err := tlBuiltinTupleInt.BuiltinTupleIntReadJSON(legacyTypeNames, inYPointer, &item.Y, nat_Y); err != nil { + return err + } + + return nil +} + +// This method is general version of WriteJSON, use it instead! +func (item *PairTupleIntTupleInt) WriteJSONGeneral(w []byte, nat_X uint32, nat_Y uint32) (_ []byte, err error) { + return item.WriteJSONOpt(true, false, w, nat_X, nat_Y) +} + +func (item *PairTupleIntTupleInt) WriteJSON(w []byte, nat_X uint32, nat_Y uint32) (_ []byte, err error) { + return item.WriteJSONOpt(true, false, w, nat_X, nat_Y) +} +func (item *PairTupleIntTupleInt) WriteJSONOpt(newTypeNames bool, short bool, w []byte, nat_X uint32, nat_Y uint32) (_ []byte, err error) { + w = append(w, '{') + backupIndexX := len(w) + w = basictl.JSONAddCommaIfNeeded(w) + w = append(w, `"x":`...) + if w, err = tlBuiltinTupleInt.BuiltinTupleIntWriteJSONOpt(newTypeNames, short, w, item.X, nat_X); err != nil { + return w, err + } + if (len(item.X) != 0) == false { + w = w[:backupIndexX] + } + backupIndexY := len(w) + w = basictl.JSONAddCommaIfNeeded(w) + w = append(w, `"y":`...) + if w, err = tlBuiltinTupleInt.BuiltinTupleIntWriteJSONOpt(newTypeNames, short, w, item.Y, nat_Y); err != nil { + return w, err + } + if (len(item.Y) != 0) == false { + w = w[:backupIndexY] + } + return append(w, '}'), nil +} diff --git a/internal/tlcodegen/test/gen/cases/internal/tl/tlPairTupleTupleInt2TupleTupleInt2/pair.go b/internal/tlcodegen/test/gen/cases/internal/tl/tlPairTupleTupleInt2TupleTupleInt2/pair.go new file mode 100644 index 00000000..998b9132 --- /dev/null +++ b/internal/tlcodegen/test/gen/cases/internal/tl/tlPairTupleTupleInt2TupleTupleInt2/pair.go @@ -0,0 +1,165 @@ +// Copyright 2022 V Kontakte LLC +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at https://mozilla.org/MPL/2.0/. + +// Code generated by vktl/cmd/tlgen2; DO NOT EDIT. +package tlPairTupleTupleInt2TupleTupleInt2 + +import ( + "github.com/vkcom/tl/internal/tlcodegen/test/gen/cases/internal" + "github.com/vkcom/tl/internal/tlcodegen/test/gen/cases/internal/tl/tlBuiltinTupleTupleInt2" + "github.com/vkcom/tl/pkg/basictl" +) + +var _ = basictl.NatWrite +var _ = internal.ErrorInvalidEnumTag + +type PairTupleTupleInt2TupleTupleInt2 struct { + X [][2]int32 + Y [][2]int32 +} + +func (PairTupleTupleInt2TupleTupleInt2) TLName() string { return "pair" } +func (PairTupleTupleInt2TupleTupleInt2) TLTag() uint32 { return 0xf01604df } + +func (item *PairTupleTupleInt2TupleTupleInt2) Reset() { + item.X = item.X[:0] + item.Y = item.Y[:0] +} + +func (item *PairTupleTupleInt2TupleTupleInt2) FillRandom(rg *basictl.RandGenerator, nat_X uint32, nat_Y uint32) { + tlBuiltinTupleTupleInt2.BuiltinTupleTupleInt2FillRandom(rg, &item.X, nat_X) + tlBuiltinTupleTupleInt2.BuiltinTupleTupleInt2FillRandom(rg, &item.Y, nat_Y) +} + +func (item *PairTupleTupleInt2TupleTupleInt2) Read(w []byte, nat_X uint32, nat_Y uint32) (_ []byte, err error) { + if w, err = tlBuiltinTupleTupleInt2.BuiltinTupleTupleInt2Read(w, &item.X, nat_X); err != nil { + return w, err + } + return tlBuiltinTupleTupleInt2.BuiltinTupleTupleInt2Read(w, &item.Y, nat_Y) +} + +// This method is general version of Write, use it instead! +func (item *PairTupleTupleInt2TupleTupleInt2) WriteGeneral(w []byte, nat_X uint32, nat_Y uint32) (_ []byte, err error) { + return item.Write(w, nat_X, nat_Y) +} + +func (item *PairTupleTupleInt2TupleTupleInt2) Write(w []byte, nat_X uint32, nat_Y uint32) (_ []byte, err error) { + if w, err = tlBuiltinTupleTupleInt2.BuiltinTupleTupleInt2Write(w, item.X, nat_X); err != nil { + return w, err + } + if w, err = tlBuiltinTupleTupleInt2.BuiltinTupleTupleInt2Write(w, item.Y, nat_Y); err != nil { + return w, err + } + return w, nil +} + +func (item *PairTupleTupleInt2TupleTupleInt2) ReadBoxed(w []byte, nat_X uint32, nat_Y uint32) (_ []byte, err error) { + if w, err = basictl.NatReadExactTag(w, 0xf01604df); err != nil { + return w, err + } + return item.Read(w, nat_X, nat_Y) +} + +// This method is general version of WriteBoxed, use it instead! +func (item *PairTupleTupleInt2TupleTupleInt2) WriteBoxedGeneral(w []byte, nat_X uint32, nat_Y uint32) (_ []byte, err error) { + return item.WriteBoxed(w, nat_X, nat_Y) +} + +func (item *PairTupleTupleInt2TupleTupleInt2) WriteBoxed(w []byte, nat_X uint32, nat_Y uint32) (_ []byte, err error) { + w = basictl.NatWrite(w, 0xf01604df) + return item.Write(w, nat_X, nat_Y) +} + +func (item *PairTupleTupleInt2TupleTupleInt2) ReadJSON(legacyTypeNames bool, in *basictl.JsonLexer, nat_X uint32, nat_Y uint32) error { + var rawX []byte + var rawY []byte + + if in != nil { + in.Delim('{') + if !in.Ok() { + return in.Error() + } + for !in.IsDelim('}') { + key := in.UnsafeFieldName(true) + in.WantColon() + switch key { + case "x": + if rawX != nil { + return internal.ErrorInvalidJSONWithDuplicatingKeys("pair", "x") + } + rawX = in.Raw() + if !in.Ok() { + return in.Error() + } + case "y": + if rawY != nil { + return internal.ErrorInvalidJSONWithDuplicatingKeys("pair", "y") + } + rawY = in.Raw() + if !in.Ok() { + return in.Error() + } + default: + return internal.ErrorInvalidJSONExcessElement("pair", key) + } + in.WantComma() + } + in.Delim('}') + if !in.Ok() { + return in.Error() + } + } + var inXPointer *basictl.JsonLexer + inX := basictl.JsonLexer{Data: rawX} + if rawX != nil { + inXPointer = &inX + } + if err := tlBuiltinTupleTupleInt2.BuiltinTupleTupleInt2ReadJSON(legacyTypeNames, inXPointer, &item.X, nat_X); err != nil { + return err + } + + var inYPointer *basictl.JsonLexer + inY := basictl.JsonLexer{Data: rawY} + if rawY != nil { + inYPointer = &inY + } + if err := tlBuiltinTupleTupleInt2.BuiltinTupleTupleInt2ReadJSON(legacyTypeNames, inYPointer, &item.Y, nat_Y); err != nil { + return err + } + + return nil +} + +// This method is general version of WriteJSON, use it instead! +func (item *PairTupleTupleInt2TupleTupleInt2) WriteJSONGeneral(w []byte, nat_X uint32, nat_Y uint32) (_ []byte, err error) { + return item.WriteJSONOpt(true, false, w, nat_X, nat_Y) +} + +func (item *PairTupleTupleInt2TupleTupleInt2) WriteJSON(w []byte, nat_X uint32, nat_Y uint32) (_ []byte, err error) { + return item.WriteJSONOpt(true, false, w, nat_X, nat_Y) +} +func (item *PairTupleTupleInt2TupleTupleInt2) WriteJSONOpt(newTypeNames bool, short bool, w []byte, nat_X uint32, nat_Y uint32) (_ []byte, err error) { + w = append(w, '{') + backupIndexX := len(w) + w = basictl.JSONAddCommaIfNeeded(w) + w = append(w, `"x":`...) + if w, err = tlBuiltinTupleTupleInt2.BuiltinTupleTupleInt2WriteJSONOpt(newTypeNames, short, w, item.X, nat_X); err != nil { + return w, err + } + if (len(item.X) != 0) == false { + w = w[:backupIndexX] + } + backupIndexY := len(w) + w = basictl.JSONAddCommaIfNeeded(w) + w = append(w, `"y":`...) + if w, err = tlBuiltinTupleTupleInt2.BuiltinTupleTupleInt2WriteJSONOpt(newTypeNames, short, w, item.Y, nat_Y); err != nil { + return w, err + } + if (len(item.Y) != 0) == false { + w = w[:backupIndexY] + } + return append(w, '}'), nil +} diff --git a/internal/tlcodegen/test/gen/cases/internal/tl/tlPairTupleTuplePairTupleIntTupleInt2TupleTuplePairTupleIntTupleInt2/pair.go b/internal/tlcodegen/test/gen/cases/internal/tl/tlPairTupleTuplePairTupleIntTupleInt2TupleTuplePairTupleIntTupleInt2/pair.go new file mode 100644 index 00000000..62458cdc --- /dev/null +++ b/internal/tlcodegen/test/gen/cases/internal/tl/tlPairTupleTuplePairTupleIntTupleInt2TupleTuplePairTupleIntTupleInt2/pair.go @@ -0,0 +1,170 @@ +// Copyright 2022 V Kontakte LLC +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at https://mozilla.org/MPL/2.0/. + +// Code generated by vktl/cmd/tlgen2; DO NOT EDIT. +package tlPairTupleTuplePairTupleIntTupleInt2TupleTuplePairTupleIntTupleInt2 + +import ( + "github.com/vkcom/tl/internal/tlcodegen/test/gen/cases/internal" + "github.com/vkcom/tl/internal/tlcodegen/test/gen/cases/internal/tl/tlBuiltinTupleTuplePairTupleIntTupleInt2" + "github.com/vkcom/tl/internal/tlcodegen/test/gen/cases/internal/tl/tlPairTupleIntTupleInt" + "github.com/vkcom/tl/pkg/basictl" +) + +var _ = basictl.NatWrite +var _ = internal.ErrorInvalidEnumTag + +type PairTupleTuplePairTupleIntTupleInt2TupleTuplePairTupleIntTupleInt2 struct { + X [][2]tlPairTupleIntTupleInt.PairTupleIntTupleInt + Y [][2]tlPairTupleIntTupleInt.PairTupleIntTupleInt +} + +func (PairTupleTuplePairTupleIntTupleInt2TupleTuplePairTupleIntTupleInt2) TLName() string { + return "pair" +} +func (PairTupleTuplePairTupleIntTupleInt2TupleTuplePairTupleIntTupleInt2) TLTag() uint32 { + return 0xf01604df +} + +func (item *PairTupleTuplePairTupleIntTupleInt2TupleTuplePairTupleIntTupleInt2) Reset() { + item.X = item.X[:0] + item.Y = item.Y[:0] +} + +func (item *PairTupleTuplePairTupleIntTupleInt2TupleTuplePairTupleIntTupleInt2) FillRandom(rg *basictl.RandGenerator, nat_XttXn uint32, nat_XttYn uint32, nat_Xn uint32, nat_YttXn uint32, nat_YttYn uint32, nat_Yn uint32) { + tlBuiltinTupleTuplePairTupleIntTupleInt2.BuiltinTupleTuplePairTupleIntTupleInt2FillRandom(rg, &item.X, nat_Xn, nat_XttXn, nat_XttYn) + tlBuiltinTupleTuplePairTupleIntTupleInt2.BuiltinTupleTuplePairTupleIntTupleInt2FillRandom(rg, &item.Y, nat_Yn, nat_YttXn, nat_YttYn) +} + +func (item *PairTupleTuplePairTupleIntTupleInt2TupleTuplePairTupleIntTupleInt2) Read(w []byte, nat_XttXn uint32, nat_XttYn uint32, nat_Xn uint32, nat_YttXn uint32, nat_YttYn uint32, nat_Yn uint32) (_ []byte, err error) { + if w, err = tlBuiltinTupleTuplePairTupleIntTupleInt2.BuiltinTupleTuplePairTupleIntTupleInt2Read(w, &item.X, nat_Xn, nat_XttXn, nat_XttYn); err != nil { + return w, err + } + return tlBuiltinTupleTuplePairTupleIntTupleInt2.BuiltinTupleTuplePairTupleIntTupleInt2Read(w, &item.Y, nat_Yn, nat_YttXn, nat_YttYn) +} + +// This method is general version of Write, use it instead! +func (item *PairTupleTuplePairTupleIntTupleInt2TupleTuplePairTupleIntTupleInt2) WriteGeneral(w []byte, nat_XttXn uint32, nat_XttYn uint32, nat_Xn uint32, nat_YttXn uint32, nat_YttYn uint32, nat_Yn uint32) (_ []byte, err error) { + return item.Write(w, nat_XttXn, nat_XttYn, nat_Xn, nat_YttXn, nat_YttYn, nat_Yn) +} + +func (item *PairTupleTuplePairTupleIntTupleInt2TupleTuplePairTupleIntTupleInt2) Write(w []byte, nat_XttXn uint32, nat_XttYn uint32, nat_Xn uint32, nat_YttXn uint32, nat_YttYn uint32, nat_Yn uint32) (_ []byte, err error) { + if w, err = tlBuiltinTupleTuplePairTupleIntTupleInt2.BuiltinTupleTuplePairTupleIntTupleInt2Write(w, item.X, nat_Xn, nat_XttXn, nat_XttYn); err != nil { + return w, err + } + if w, err = tlBuiltinTupleTuplePairTupleIntTupleInt2.BuiltinTupleTuplePairTupleIntTupleInt2Write(w, item.Y, nat_Yn, nat_YttXn, nat_YttYn); err != nil { + return w, err + } + return w, nil +} + +func (item *PairTupleTuplePairTupleIntTupleInt2TupleTuplePairTupleIntTupleInt2) ReadBoxed(w []byte, nat_XttXn uint32, nat_XttYn uint32, nat_Xn uint32, nat_YttXn uint32, nat_YttYn uint32, nat_Yn uint32) (_ []byte, err error) { + if w, err = basictl.NatReadExactTag(w, 0xf01604df); err != nil { + return w, err + } + return item.Read(w, nat_XttXn, nat_XttYn, nat_Xn, nat_YttXn, nat_YttYn, nat_Yn) +} + +// This method is general version of WriteBoxed, use it instead! +func (item *PairTupleTuplePairTupleIntTupleInt2TupleTuplePairTupleIntTupleInt2) WriteBoxedGeneral(w []byte, nat_XttXn uint32, nat_XttYn uint32, nat_Xn uint32, nat_YttXn uint32, nat_YttYn uint32, nat_Yn uint32) (_ []byte, err error) { + return item.WriteBoxed(w, nat_XttXn, nat_XttYn, nat_Xn, nat_YttXn, nat_YttYn, nat_Yn) +} + +func (item *PairTupleTuplePairTupleIntTupleInt2TupleTuplePairTupleIntTupleInt2) WriteBoxed(w []byte, nat_XttXn uint32, nat_XttYn uint32, nat_Xn uint32, nat_YttXn uint32, nat_YttYn uint32, nat_Yn uint32) (_ []byte, err error) { + w = basictl.NatWrite(w, 0xf01604df) + return item.Write(w, nat_XttXn, nat_XttYn, nat_Xn, nat_YttXn, nat_YttYn, nat_Yn) +} + +func (item *PairTupleTuplePairTupleIntTupleInt2TupleTuplePairTupleIntTupleInt2) ReadJSON(legacyTypeNames bool, in *basictl.JsonLexer, nat_XttXn uint32, nat_XttYn uint32, nat_Xn uint32, nat_YttXn uint32, nat_YttYn uint32, nat_Yn uint32) error { + var rawX []byte + var rawY []byte + + if in != nil { + in.Delim('{') + if !in.Ok() { + return in.Error() + } + for !in.IsDelim('}') { + key := in.UnsafeFieldName(true) + in.WantColon() + switch key { + case "x": + if rawX != nil { + return internal.ErrorInvalidJSONWithDuplicatingKeys("pair", "x") + } + rawX = in.Raw() + if !in.Ok() { + return in.Error() + } + case "y": + if rawY != nil { + return internal.ErrorInvalidJSONWithDuplicatingKeys("pair", "y") + } + rawY = in.Raw() + if !in.Ok() { + return in.Error() + } + default: + return internal.ErrorInvalidJSONExcessElement("pair", key) + } + in.WantComma() + } + in.Delim('}') + if !in.Ok() { + return in.Error() + } + } + var inXPointer *basictl.JsonLexer + inX := basictl.JsonLexer{Data: rawX} + if rawX != nil { + inXPointer = &inX + } + if err := tlBuiltinTupleTuplePairTupleIntTupleInt2.BuiltinTupleTuplePairTupleIntTupleInt2ReadJSON(legacyTypeNames, inXPointer, &item.X, nat_Xn, nat_XttXn, nat_XttYn); err != nil { + return err + } + + var inYPointer *basictl.JsonLexer + inY := basictl.JsonLexer{Data: rawY} + if rawY != nil { + inYPointer = &inY + } + if err := tlBuiltinTupleTuplePairTupleIntTupleInt2.BuiltinTupleTuplePairTupleIntTupleInt2ReadJSON(legacyTypeNames, inYPointer, &item.Y, nat_Yn, nat_YttXn, nat_YttYn); err != nil { + return err + } + + return nil +} + +// This method is general version of WriteJSON, use it instead! +func (item *PairTupleTuplePairTupleIntTupleInt2TupleTuplePairTupleIntTupleInt2) WriteJSONGeneral(w []byte, nat_XttXn uint32, nat_XttYn uint32, nat_Xn uint32, nat_YttXn uint32, nat_YttYn uint32, nat_Yn uint32) (_ []byte, err error) { + return item.WriteJSONOpt(true, false, w, nat_XttXn, nat_XttYn, nat_Xn, nat_YttXn, nat_YttYn, nat_Yn) +} + +func (item *PairTupleTuplePairTupleIntTupleInt2TupleTuplePairTupleIntTupleInt2) WriteJSON(w []byte, nat_XttXn uint32, nat_XttYn uint32, nat_Xn uint32, nat_YttXn uint32, nat_YttYn uint32, nat_Yn uint32) (_ []byte, err error) { + return item.WriteJSONOpt(true, false, w, nat_XttXn, nat_XttYn, nat_Xn, nat_YttXn, nat_YttYn, nat_Yn) +} +func (item *PairTupleTuplePairTupleIntTupleInt2TupleTuplePairTupleIntTupleInt2) WriteJSONOpt(newTypeNames bool, short bool, w []byte, nat_XttXn uint32, nat_XttYn uint32, nat_Xn uint32, nat_YttXn uint32, nat_YttYn uint32, nat_Yn uint32) (_ []byte, err error) { + w = append(w, '{') + backupIndexX := len(w) + w = basictl.JSONAddCommaIfNeeded(w) + w = append(w, `"x":`...) + if w, err = tlBuiltinTupleTuplePairTupleIntTupleInt2.BuiltinTupleTuplePairTupleIntTupleInt2WriteJSONOpt(newTypeNames, short, w, item.X, nat_Xn, nat_XttXn, nat_XttYn); err != nil { + return w, err + } + if (len(item.X) != 0) == false { + w = w[:backupIndexX] + } + backupIndexY := len(w) + w = basictl.JSONAddCommaIfNeeded(w) + w = append(w, `"y":`...) + if w, err = tlBuiltinTupleTuplePairTupleIntTupleInt2.BuiltinTupleTuplePairTupleIntTupleInt2WriteJSONOpt(newTypeNames, short, w, item.Y, nat_Yn, nat_YttXn, nat_YttYn); err != nil { + return w, err + } + if (len(item.Y) != 0) == false { + w = w[:backupIndexY] + } + return append(w, '}'), nil +} diff --git a/internal/tlcodegen/test/gen/cases/internal/tl/tlTupleInt/tuple.go b/internal/tlcodegen/test/gen/cases/internal/tl/tlTupleInt/tuple.go new file mode 100644 index 00000000..1e316746 --- /dev/null +++ b/internal/tlcodegen/test/gen/cases/internal/tl/tlTupleInt/tuple.go @@ -0,0 +1,89 @@ +// Copyright 2022 V Kontakte LLC +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at https://mozilla.org/MPL/2.0/. + +// Code generated by vktl/cmd/tlgen2; DO NOT EDIT. +package tlTupleInt + +import ( + "github.com/vkcom/tl/internal/tlcodegen/test/gen/cases/internal" + "github.com/vkcom/tl/internal/tlcodegen/test/gen/cases/internal/tl/tlBuiltinTupleInt" + "github.com/vkcom/tl/pkg/basictl" +) + +var _ = basictl.NatWrite +var _ = internal.ErrorInvalidEnumTag + +type TupleInt []int32 + +func (TupleInt) TLName() string { return "tuple" } +func (TupleInt) TLTag() uint32 { return 0x9770768a } + +func (item *TupleInt) Reset() { + ptr := (*[]int32)(item) + *ptr = (*ptr)[:0] +} + +func (item *TupleInt) FillRandom(rg *basictl.RandGenerator, nat_n uint32) { + ptr := (*[]int32)(item) + tlBuiltinTupleInt.BuiltinTupleIntFillRandom(rg, ptr, nat_n) +} + +func (item *TupleInt) Read(w []byte, nat_n uint32) (_ []byte, err error) { + ptr := (*[]int32)(item) + return tlBuiltinTupleInt.BuiltinTupleIntRead(w, ptr, nat_n) +} + +// This method is general version of Write, use it instead! +func (item *TupleInt) WriteGeneral(w []byte, nat_n uint32) (_ []byte, err error) { + return item.Write(w, nat_n) +} + +func (item *TupleInt) Write(w []byte, nat_n uint32) (_ []byte, err error) { + ptr := (*[]int32)(item) + return tlBuiltinTupleInt.BuiltinTupleIntWrite(w, *ptr, nat_n) +} + +func (item *TupleInt) ReadBoxed(w []byte, nat_n uint32) (_ []byte, err error) { + if w, err = basictl.NatReadExactTag(w, 0x9770768a); err != nil { + return w, err + } + return item.Read(w, nat_n) +} + +// This method is general version of WriteBoxed, use it instead! +func (item *TupleInt) WriteBoxedGeneral(w []byte, nat_n uint32) (_ []byte, err error) { + return item.WriteBoxed(w, nat_n) +} + +func (item *TupleInt) WriteBoxed(w []byte, nat_n uint32) (_ []byte, err error) { + w = basictl.NatWrite(w, 0x9770768a) + return item.Write(w, nat_n) +} + +func (item *TupleInt) ReadJSON(legacyTypeNames bool, in *basictl.JsonLexer, nat_n uint32) error { + ptr := (*[]int32)(item) + if err := tlBuiltinTupleInt.BuiltinTupleIntReadJSON(legacyTypeNames, in, ptr, nat_n); err != nil { + return err + } + return nil +} + +// This method is general version of WriteJSON, use it instead! +func (item *TupleInt) WriteJSONGeneral(w []byte, nat_n uint32) (_ []byte, err error) { + return item.WriteJSON(w, nat_n) +} + +func (item *TupleInt) WriteJSON(w []byte, nat_n uint32) (_ []byte, err error) { + return item.WriteJSONOpt(true, false, w, nat_n) +} + +func (item *TupleInt) WriteJSONOpt(newTypeNames bool, short bool, w []byte, nat_n uint32) (_ []byte, err error) { + ptr := (*[]int32)(item) + if w, err = tlBuiltinTupleInt.BuiltinTupleIntWriteJSONOpt(newTypeNames, short, w, *ptr, nat_n); err != nil { + return w, err + } + return w, nil +} diff --git a/internal/tlcodegen/test/gen/cases/internal/tl/tlTupleInt2/tuple.go b/internal/tlcodegen/test/gen/cases/internal/tl/tlTupleInt2/tuple.go new file mode 100644 index 00000000..86d1099e --- /dev/null +++ b/internal/tlcodegen/test/gen/cases/internal/tl/tlTupleInt2/tuple.go @@ -0,0 +1,101 @@ +// Copyright 2022 V Kontakte LLC +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at https://mozilla.org/MPL/2.0/. + +// Code generated by vktl/cmd/tlgen2; DO NOT EDIT. +package tlTupleInt2 + +import ( + "github.com/vkcom/tl/internal/tlcodegen/test/gen/cases/internal" + "github.com/vkcom/tl/internal/tlcodegen/test/gen/cases/internal/tl/tlBuiltinTuple2Int" + "github.com/vkcom/tl/pkg/basictl" +) + +var _ = basictl.NatWrite +var _ = internal.ErrorInvalidEnumTag + +type TupleInt2 [2]int32 + +func (TupleInt2) TLName() string { return "tuple" } +func (TupleInt2) TLTag() uint32 { return 0x9770768a } + +func (item *TupleInt2) Reset() { + ptr := (*[2]int32)(item) + tlBuiltinTuple2Int.BuiltinTuple2IntReset(ptr) +} + +func (item *TupleInt2) FillRandom(rg *basictl.RandGenerator) { + ptr := (*[2]int32)(item) + tlBuiltinTuple2Int.BuiltinTuple2IntFillRandom(rg, ptr) +} + +func (item *TupleInt2) Read(w []byte) (_ []byte, err error) { + ptr := (*[2]int32)(item) + return tlBuiltinTuple2Int.BuiltinTuple2IntRead(w, ptr) +} + +// This method is general version of Write, use it instead! +func (item *TupleInt2) WriteGeneral(w []byte) (_ []byte, err error) { + return item.Write(w), nil +} + +func (item *TupleInt2) Write(w []byte) []byte { + ptr := (*[2]int32)(item) + return tlBuiltinTuple2Int.BuiltinTuple2IntWrite(w, ptr) +} + +func (item *TupleInt2) ReadBoxed(w []byte) (_ []byte, err error) { + if w, err = basictl.NatReadExactTag(w, 0x9770768a); err != nil { + return w, err + } + return item.Read(w) +} + +// This method is general version of WriteBoxed, use it instead! +func (item *TupleInt2) WriteBoxedGeneral(w []byte) (_ []byte, err error) { + return item.WriteBoxed(w), nil +} + +func (item *TupleInt2) WriteBoxed(w []byte) []byte { + w = basictl.NatWrite(w, 0x9770768a) + return item.Write(w) +} + +func (item TupleInt2) String() string { + return string(item.WriteJSON(nil)) +} + +func (item *TupleInt2) ReadJSON(legacyTypeNames bool, in *basictl.JsonLexer) error { + ptr := (*[2]int32)(item) + if err := tlBuiltinTuple2Int.BuiltinTuple2IntReadJSON(legacyTypeNames, in, ptr); err != nil { + return err + } + return nil +} + +// This method is general version of WriteJSON, use it instead! +func (item *TupleInt2) WriteJSONGeneral(w []byte) (_ []byte, err error) { + return item.WriteJSON(w), nil +} + +func (item *TupleInt2) WriteJSON(w []byte) []byte { + return item.WriteJSONOpt(true, false, w) +} + +func (item *TupleInt2) WriteJSONOpt(newTypeNames bool, short bool, w []byte) []byte { + ptr := (*[2]int32)(item) + w = tlBuiltinTuple2Int.BuiltinTuple2IntWriteJSONOpt(newTypeNames, short, w, ptr) + return w +} +func (item *TupleInt2) MarshalJSON() ([]byte, error) { + return item.WriteJSON(nil), nil +} + +func (item *TupleInt2) UnmarshalJSON(b []byte) error { + if err := item.ReadJSON(true, &basictl.JsonLexer{Data: b}); err != nil { + return internal.ErrorInvalidJSON("tuple", err.Error()) + } + return nil +} diff --git a/internal/tlcodegen/test/gen/cases/internal/tl/tlTuplePairTupleIntTupleInt2/tuple.go b/internal/tlcodegen/test/gen/cases/internal/tl/tlTuplePairTupleIntTupleInt2/tuple.go new file mode 100644 index 00000000..b35bb897 --- /dev/null +++ b/internal/tlcodegen/test/gen/cases/internal/tl/tlTuplePairTupleIntTupleInt2/tuple.go @@ -0,0 +1,90 @@ +// Copyright 2022 V Kontakte LLC +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at https://mozilla.org/MPL/2.0/. + +// Code generated by vktl/cmd/tlgen2; DO NOT EDIT. +package tlTuplePairTupleIntTupleInt2 + +import ( + "github.com/vkcom/tl/internal/tlcodegen/test/gen/cases/internal" + "github.com/vkcom/tl/internal/tlcodegen/test/gen/cases/internal/tl/tlBuiltinTuple2PairTupleIntTupleInt" + "github.com/vkcom/tl/internal/tlcodegen/test/gen/cases/internal/tl/tlPairTupleIntTupleInt" + "github.com/vkcom/tl/pkg/basictl" +) + +var _ = basictl.NatWrite +var _ = internal.ErrorInvalidEnumTag + +type TuplePairTupleIntTupleInt2 [2]tlPairTupleIntTupleInt.PairTupleIntTupleInt + +func (TuplePairTupleIntTupleInt2) TLName() string { return "tuple" } +func (TuplePairTupleIntTupleInt2) TLTag() uint32 { return 0x9770768a } + +func (item *TuplePairTupleIntTupleInt2) Reset() { + ptr := (*[2]tlPairTupleIntTupleInt.PairTupleIntTupleInt)(item) + tlBuiltinTuple2PairTupleIntTupleInt.BuiltinTuple2PairTupleIntTupleIntReset(ptr) +} + +func (item *TuplePairTupleIntTupleInt2) FillRandom(rg *basictl.RandGenerator, nat_tXn uint32, nat_tYn uint32) { + ptr := (*[2]tlPairTupleIntTupleInt.PairTupleIntTupleInt)(item) + tlBuiltinTuple2PairTupleIntTupleInt.BuiltinTuple2PairTupleIntTupleIntFillRandom(rg, ptr, nat_tXn, nat_tYn) +} + +func (item *TuplePairTupleIntTupleInt2) Read(w []byte, nat_tXn uint32, nat_tYn uint32) (_ []byte, err error) { + ptr := (*[2]tlPairTupleIntTupleInt.PairTupleIntTupleInt)(item) + return tlBuiltinTuple2PairTupleIntTupleInt.BuiltinTuple2PairTupleIntTupleIntRead(w, ptr, nat_tXn, nat_tYn) +} + +// This method is general version of Write, use it instead! +func (item *TuplePairTupleIntTupleInt2) WriteGeneral(w []byte, nat_tXn uint32, nat_tYn uint32) (_ []byte, err error) { + return item.Write(w, nat_tXn, nat_tYn) +} + +func (item *TuplePairTupleIntTupleInt2) Write(w []byte, nat_tXn uint32, nat_tYn uint32) (_ []byte, err error) { + ptr := (*[2]tlPairTupleIntTupleInt.PairTupleIntTupleInt)(item) + return tlBuiltinTuple2PairTupleIntTupleInt.BuiltinTuple2PairTupleIntTupleIntWrite(w, ptr, nat_tXn, nat_tYn) +} + +func (item *TuplePairTupleIntTupleInt2) ReadBoxed(w []byte, nat_tXn uint32, nat_tYn uint32) (_ []byte, err error) { + if w, err = basictl.NatReadExactTag(w, 0x9770768a); err != nil { + return w, err + } + return item.Read(w, nat_tXn, nat_tYn) +} + +// This method is general version of WriteBoxed, use it instead! +func (item *TuplePairTupleIntTupleInt2) WriteBoxedGeneral(w []byte, nat_tXn uint32, nat_tYn uint32) (_ []byte, err error) { + return item.WriteBoxed(w, nat_tXn, nat_tYn) +} + +func (item *TuplePairTupleIntTupleInt2) WriteBoxed(w []byte, nat_tXn uint32, nat_tYn uint32) (_ []byte, err error) { + w = basictl.NatWrite(w, 0x9770768a) + return item.Write(w, nat_tXn, nat_tYn) +} + +func (item *TuplePairTupleIntTupleInt2) ReadJSON(legacyTypeNames bool, in *basictl.JsonLexer, nat_tXn uint32, nat_tYn uint32) error { + ptr := (*[2]tlPairTupleIntTupleInt.PairTupleIntTupleInt)(item) + if err := tlBuiltinTuple2PairTupleIntTupleInt.BuiltinTuple2PairTupleIntTupleIntReadJSON(legacyTypeNames, in, ptr, nat_tXn, nat_tYn); err != nil { + return err + } + return nil +} + +// This method is general version of WriteJSON, use it instead! +func (item *TuplePairTupleIntTupleInt2) WriteJSONGeneral(w []byte, nat_tXn uint32, nat_tYn uint32) (_ []byte, err error) { + return item.WriteJSON(w, nat_tXn, nat_tYn) +} + +func (item *TuplePairTupleIntTupleInt2) WriteJSON(w []byte, nat_tXn uint32, nat_tYn uint32) (_ []byte, err error) { + return item.WriteJSONOpt(true, false, w, nat_tXn, nat_tYn) +} + +func (item *TuplePairTupleIntTupleInt2) WriteJSONOpt(newTypeNames bool, short bool, w []byte, nat_tXn uint32, nat_tYn uint32) (_ []byte, err error) { + ptr := (*[2]tlPairTupleIntTupleInt.PairTupleIntTupleInt)(item) + if w, err = tlBuiltinTuple2PairTupleIntTupleInt.BuiltinTuple2PairTupleIntTupleIntWriteJSONOpt(newTypeNames, short, w, ptr, nat_tXn, nat_tYn); err != nil { + return w, err + } + return w, nil +} diff --git a/internal/tlcodegen/test/gen/cases/internal/tl/tlTupleTupleInt2/tuple.go b/internal/tlcodegen/test/gen/cases/internal/tl/tlTupleTupleInt2/tuple.go new file mode 100644 index 00000000..db2f7f45 --- /dev/null +++ b/internal/tlcodegen/test/gen/cases/internal/tl/tlTupleTupleInt2/tuple.go @@ -0,0 +1,89 @@ +// Copyright 2022 V Kontakte LLC +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at https://mozilla.org/MPL/2.0/. + +// Code generated by vktl/cmd/tlgen2; DO NOT EDIT. +package tlTupleTupleInt2 + +import ( + "github.com/vkcom/tl/internal/tlcodegen/test/gen/cases/internal" + "github.com/vkcom/tl/internal/tlcodegen/test/gen/cases/internal/tl/tlBuiltinTupleTupleInt2" + "github.com/vkcom/tl/pkg/basictl" +) + +var _ = basictl.NatWrite +var _ = internal.ErrorInvalidEnumTag + +type TupleTupleInt2 [][2]int32 + +func (TupleTupleInt2) TLName() string { return "tuple" } +func (TupleTupleInt2) TLTag() uint32 { return 0x9770768a } + +func (item *TupleTupleInt2) Reset() { + ptr := (*[][2]int32)(item) + *ptr = (*ptr)[:0] +} + +func (item *TupleTupleInt2) FillRandom(rg *basictl.RandGenerator, nat_n uint32) { + ptr := (*[][2]int32)(item) + tlBuiltinTupleTupleInt2.BuiltinTupleTupleInt2FillRandom(rg, ptr, nat_n) +} + +func (item *TupleTupleInt2) Read(w []byte, nat_n uint32) (_ []byte, err error) { + ptr := (*[][2]int32)(item) + return tlBuiltinTupleTupleInt2.BuiltinTupleTupleInt2Read(w, ptr, nat_n) +} + +// This method is general version of Write, use it instead! +func (item *TupleTupleInt2) WriteGeneral(w []byte, nat_n uint32) (_ []byte, err error) { + return item.Write(w, nat_n) +} + +func (item *TupleTupleInt2) Write(w []byte, nat_n uint32) (_ []byte, err error) { + ptr := (*[][2]int32)(item) + return tlBuiltinTupleTupleInt2.BuiltinTupleTupleInt2Write(w, *ptr, nat_n) +} + +func (item *TupleTupleInt2) ReadBoxed(w []byte, nat_n uint32) (_ []byte, err error) { + if w, err = basictl.NatReadExactTag(w, 0x9770768a); err != nil { + return w, err + } + return item.Read(w, nat_n) +} + +// This method is general version of WriteBoxed, use it instead! +func (item *TupleTupleInt2) WriteBoxedGeneral(w []byte, nat_n uint32) (_ []byte, err error) { + return item.WriteBoxed(w, nat_n) +} + +func (item *TupleTupleInt2) WriteBoxed(w []byte, nat_n uint32) (_ []byte, err error) { + w = basictl.NatWrite(w, 0x9770768a) + return item.Write(w, nat_n) +} + +func (item *TupleTupleInt2) ReadJSON(legacyTypeNames bool, in *basictl.JsonLexer, nat_n uint32) error { + ptr := (*[][2]int32)(item) + if err := tlBuiltinTupleTupleInt2.BuiltinTupleTupleInt2ReadJSON(legacyTypeNames, in, ptr, nat_n); err != nil { + return err + } + return nil +} + +// This method is general version of WriteJSON, use it instead! +func (item *TupleTupleInt2) WriteJSONGeneral(w []byte, nat_n uint32) (_ []byte, err error) { + return item.WriteJSON(w, nat_n) +} + +func (item *TupleTupleInt2) WriteJSON(w []byte, nat_n uint32) (_ []byte, err error) { + return item.WriteJSONOpt(true, false, w, nat_n) +} + +func (item *TupleTupleInt2) WriteJSONOpt(newTypeNames bool, short bool, w []byte, nat_n uint32) (_ []byte, err error) { + ptr := (*[][2]int32)(item) + if w, err = tlBuiltinTupleTupleInt2.BuiltinTupleTupleInt2WriteJSONOpt(newTypeNames, short, w, *ptr, nat_n); err != nil { + return w, err + } + return w, nil +} diff --git a/internal/tlcodegen/test/gen/cases/internal/tl/tlTupleTuplePairTupleIntTupleInt2/tuple.go b/internal/tlcodegen/test/gen/cases/internal/tl/tlTupleTuplePairTupleIntTupleInt2/tuple.go new file mode 100644 index 00000000..53e0c783 --- /dev/null +++ b/internal/tlcodegen/test/gen/cases/internal/tl/tlTupleTuplePairTupleIntTupleInt2/tuple.go @@ -0,0 +1,90 @@ +// Copyright 2022 V Kontakte LLC +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at https://mozilla.org/MPL/2.0/. + +// Code generated by vktl/cmd/tlgen2; DO NOT EDIT. +package tlTupleTuplePairTupleIntTupleInt2 + +import ( + "github.com/vkcom/tl/internal/tlcodegen/test/gen/cases/internal" + "github.com/vkcom/tl/internal/tlcodegen/test/gen/cases/internal/tl/tlBuiltinTupleTuplePairTupleIntTupleInt2" + "github.com/vkcom/tl/internal/tlcodegen/test/gen/cases/internal/tl/tlPairTupleIntTupleInt" + "github.com/vkcom/tl/pkg/basictl" +) + +var _ = basictl.NatWrite +var _ = internal.ErrorInvalidEnumTag + +type TupleTuplePairTupleIntTupleInt2 [][2]tlPairTupleIntTupleInt.PairTupleIntTupleInt + +func (TupleTuplePairTupleIntTupleInt2) TLName() string { return "tuple" } +func (TupleTuplePairTupleIntTupleInt2) TLTag() uint32 { return 0x9770768a } + +func (item *TupleTuplePairTupleIntTupleInt2) Reset() { + ptr := (*[][2]tlPairTupleIntTupleInt.PairTupleIntTupleInt)(item) + *ptr = (*ptr)[:0] +} + +func (item *TupleTuplePairTupleIntTupleInt2) FillRandom(rg *basictl.RandGenerator, nat_ttXn uint32, nat_ttYn uint32, nat_n uint32) { + ptr := (*[][2]tlPairTupleIntTupleInt.PairTupleIntTupleInt)(item) + tlBuiltinTupleTuplePairTupleIntTupleInt2.BuiltinTupleTuplePairTupleIntTupleInt2FillRandom(rg, ptr, nat_n, nat_ttXn, nat_ttYn) +} + +func (item *TupleTuplePairTupleIntTupleInt2) Read(w []byte, nat_ttXn uint32, nat_ttYn uint32, nat_n uint32) (_ []byte, err error) { + ptr := (*[][2]tlPairTupleIntTupleInt.PairTupleIntTupleInt)(item) + return tlBuiltinTupleTuplePairTupleIntTupleInt2.BuiltinTupleTuplePairTupleIntTupleInt2Read(w, ptr, nat_n, nat_ttXn, nat_ttYn) +} + +// This method is general version of Write, use it instead! +func (item *TupleTuplePairTupleIntTupleInt2) WriteGeneral(w []byte, nat_ttXn uint32, nat_ttYn uint32, nat_n uint32) (_ []byte, err error) { + return item.Write(w, nat_ttXn, nat_ttYn, nat_n) +} + +func (item *TupleTuplePairTupleIntTupleInt2) Write(w []byte, nat_ttXn uint32, nat_ttYn uint32, nat_n uint32) (_ []byte, err error) { + ptr := (*[][2]tlPairTupleIntTupleInt.PairTupleIntTupleInt)(item) + return tlBuiltinTupleTuplePairTupleIntTupleInt2.BuiltinTupleTuplePairTupleIntTupleInt2Write(w, *ptr, nat_n, nat_ttXn, nat_ttYn) +} + +func (item *TupleTuplePairTupleIntTupleInt2) ReadBoxed(w []byte, nat_ttXn uint32, nat_ttYn uint32, nat_n uint32) (_ []byte, err error) { + if w, err = basictl.NatReadExactTag(w, 0x9770768a); err != nil { + return w, err + } + return item.Read(w, nat_ttXn, nat_ttYn, nat_n) +} + +// This method is general version of WriteBoxed, use it instead! +func (item *TupleTuplePairTupleIntTupleInt2) WriteBoxedGeneral(w []byte, nat_ttXn uint32, nat_ttYn uint32, nat_n uint32) (_ []byte, err error) { + return item.WriteBoxed(w, nat_ttXn, nat_ttYn, nat_n) +} + +func (item *TupleTuplePairTupleIntTupleInt2) WriteBoxed(w []byte, nat_ttXn uint32, nat_ttYn uint32, nat_n uint32) (_ []byte, err error) { + w = basictl.NatWrite(w, 0x9770768a) + return item.Write(w, nat_ttXn, nat_ttYn, nat_n) +} + +func (item *TupleTuplePairTupleIntTupleInt2) ReadJSON(legacyTypeNames bool, in *basictl.JsonLexer, nat_ttXn uint32, nat_ttYn uint32, nat_n uint32) error { + ptr := (*[][2]tlPairTupleIntTupleInt.PairTupleIntTupleInt)(item) + if err := tlBuiltinTupleTuplePairTupleIntTupleInt2.BuiltinTupleTuplePairTupleIntTupleInt2ReadJSON(legacyTypeNames, in, ptr, nat_n, nat_ttXn, nat_ttYn); err != nil { + return err + } + return nil +} + +// This method is general version of WriteJSON, use it instead! +func (item *TupleTuplePairTupleIntTupleInt2) WriteJSONGeneral(w []byte, nat_ttXn uint32, nat_ttYn uint32, nat_n uint32) (_ []byte, err error) { + return item.WriteJSON(w, nat_ttXn, nat_ttYn, nat_n) +} + +func (item *TupleTuplePairTupleIntTupleInt2) WriteJSON(w []byte, nat_ttXn uint32, nat_ttYn uint32, nat_n uint32) (_ []byte, err error) { + return item.WriteJSONOpt(true, false, w, nat_ttXn, nat_ttYn, nat_n) +} + +func (item *TupleTuplePairTupleIntTupleInt2) WriteJSONOpt(newTypeNames bool, short bool, w []byte, nat_ttXn uint32, nat_ttYn uint32, nat_n uint32) (_ []byte, err error) { + ptr := (*[][2]tlPairTupleIntTupleInt.PairTupleIntTupleInt)(item) + if w, err = tlBuiltinTupleTuplePairTupleIntTupleInt2.BuiltinTupleTuplePairTupleIntTupleInt2WriteJSONOpt(newTypeNames, short, w, *ptr, nat_n, nat_ttXn, nat_ttYn); err != nil { + return w, err + } + return w, nil +} diff --git a/internal/tlcodegen/test/gen/cases/internal/tlcases/tlCasesInplace1Int/cases.inplace1.go b/internal/tlcodegen/test/gen/cases/internal/tlcases/tlCasesInplace1Int/cases.inplace1.go new file mode 100644 index 00000000..f2dc7461 --- /dev/null +++ b/internal/tlcodegen/test/gen/cases/internal/tlcases/tlCasesInplace1Int/cases.inplace1.go @@ -0,0 +1,125 @@ +// Copyright 2022 V Kontakte LLC +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at https://mozilla.org/MPL/2.0/. + +// Code generated by vktl/cmd/tlgen2; DO NOT EDIT. +package tlCasesInplace1Int + +import ( + "github.com/vkcom/tl/internal/tlcodegen/test/gen/cases/internal" + "github.com/vkcom/tl/internal/tlcodegen/test/gen/cases/internal/tlcases/tlCasesInplace2Int" + "github.com/vkcom/tl/pkg/basictl" +) + +var _ = basictl.NatWrite +var _ = internal.ErrorInvalidEnumTag + +type CasesInplace1Int struct { + Value tlCasesInplace2Int.CasesInplace2Int +} + +func (CasesInplace1Int) TLName() string { return "cases.inplace1" } +func (CasesInplace1Int) TLTag() uint32 { return 0x5533e8e9 } + +func (item *CasesInplace1Int) Reset() { + item.Value.Reset() +} + +func (item *CasesInplace1Int) FillRandom(rg *basictl.RandGenerator, nat_a1 uint32, nat_a2 uint32, nat_a3 uint32) { + item.Value.FillRandom(rg, nat_a2, nat_a3, nat_a1) +} + +func (item *CasesInplace1Int) Read(w []byte, nat_a1 uint32, nat_a2 uint32, nat_a3 uint32) (_ []byte, err error) { + return item.Value.Read(w, nat_a2, nat_a3, nat_a1) +} + +// This method is general version of Write, use it instead! +func (item *CasesInplace1Int) WriteGeneral(w []byte, nat_a1 uint32, nat_a2 uint32, nat_a3 uint32) (_ []byte, err error) { + return item.Write(w, nat_a1, nat_a2, nat_a3) +} + +func (item *CasesInplace1Int) Write(w []byte, nat_a1 uint32, nat_a2 uint32, nat_a3 uint32) (_ []byte, err error) { + if w, err = item.Value.Write(w, nat_a2, nat_a3, nat_a1); err != nil { + return w, err + } + return w, nil +} + +func (item *CasesInplace1Int) ReadBoxed(w []byte, nat_a1 uint32, nat_a2 uint32, nat_a3 uint32) (_ []byte, err error) { + if w, err = basictl.NatReadExactTag(w, 0x5533e8e9); err != nil { + return w, err + } + return item.Read(w, nat_a1, nat_a2, nat_a3) +} + +// This method is general version of WriteBoxed, use it instead! +func (item *CasesInplace1Int) WriteBoxedGeneral(w []byte, nat_a1 uint32, nat_a2 uint32, nat_a3 uint32) (_ []byte, err error) { + return item.WriteBoxed(w, nat_a1, nat_a2, nat_a3) +} + +func (item *CasesInplace1Int) WriteBoxed(w []byte, nat_a1 uint32, nat_a2 uint32, nat_a3 uint32) (_ []byte, err error) { + w = basictl.NatWrite(w, 0x5533e8e9) + return item.Write(w, nat_a1, nat_a2, nat_a3) +} + +func (item *CasesInplace1Int) ReadJSON(legacyTypeNames bool, in *basictl.JsonLexer, nat_a1 uint32, nat_a2 uint32, nat_a3 uint32) error { + var rawValue []byte + + if in != nil { + in.Delim('{') + if !in.Ok() { + return in.Error() + } + for !in.IsDelim('}') { + key := in.UnsafeFieldName(true) + in.WantColon() + switch key { + case "value": + if rawValue != nil { + return internal.ErrorInvalidJSONWithDuplicatingKeys("cases.inplace1", "value") + } + rawValue = in.Raw() + if !in.Ok() { + return in.Error() + } + default: + return internal.ErrorInvalidJSONExcessElement("cases.inplace1", key) + } + in.WantComma() + } + in.Delim('}') + if !in.Ok() { + return in.Error() + } + } + var inValuePointer *basictl.JsonLexer + inValue := basictl.JsonLexer{Data: rawValue} + if rawValue != nil { + inValuePointer = &inValue + } + if err := item.Value.ReadJSON(legacyTypeNames, inValuePointer, nat_a2, nat_a3, nat_a1); err != nil { + return err + } + + return nil +} + +// This method is general version of WriteJSON, use it instead! +func (item *CasesInplace1Int) WriteJSONGeneral(w []byte, nat_a1 uint32, nat_a2 uint32, nat_a3 uint32) (_ []byte, err error) { + return item.WriteJSONOpt(true, false, w, nat_a1, nat_a2, nat_a3) +} + +func (item *CasesInplace1Int) WriteJSON(w []byte, nat_a1 uint32, nat_a2 uint32, nat_a3 uint32) (_ []byte, err error) { + return item.WriteJSONOpt(true, false, w, nat_a1, nat_a2, nat_a3) +} +func (item *CasesInplace1Int) WriteJSONOpt(newTypeNames bool, short bool, w []byte, nat_a1 uint32, nat_a2 uint32, nat_a3 uint32) (_ []byte, err error) { + w = append(w, '{') + w = basictl.JSONAddCommaIfNeeded(w) + w = append(w, `"value":`...) + if w, err = item.Value.WriteJSONOpt(newTypeNames, short, w, nat_a2, nat_a3, nat_a1); err != nil { + return w, err + } + return append(w, '}'), nil +} diff --git a/internal/tlcodegen/test/gen/cases/internal/tlcases/tlCasesInplace1PairTupleIntTupleInt/cases.inplace1.go b/internal/tlcodegen/test/gen/cases/internal/tlcases/tlCasesInplace1PairTupleIntTupleInt/cases.inplace1.go new file mode 100644 index 00000000..97658747 --- /dev/null +++ b/internal/tlcodegen/test/gen/cases/internal/tlcases/tlCasesInplace1PairTupleIntTupleInt/cases.inplace1.go @@ -0,0 +1,125 @@ +// Copyright 2022 V Kontakte LLC +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at https://mozilla.org/MPL/2.0/. + +// Code generated by vktl/cmd/tlgen2; DO NOT EDIT. +package tlCasesInplace1PairTupleIntTupleInt + +import ( + "github.com/vkcom/tl/internal/tlcodegen/test/gen/cases/internal" + "github.com/vkcom/tl/internal/tlcodegen/test/gen/cases/internal/tlcases/tlCasesInplace2PairTupleIntTupleInt" + "github.com/vkcom/tl/pkg/basictl" +) + +var _ = basictl.NatWrite +var _ = internal.ErrorInvalidEnumTag + +type CasesInplace1PairTupleIntTupleInt struct { + Value tlCasesInplace2PairTupleIntTupleInt.CasesInplace2PairTupleIntTupleInt +} + +func (CasesInplace1PairTupleIntTupleInt) TLName() string { return "cases.inplace1" } +func (CasesInplace1PairTupleIntTupleInt) TLTag() uint32 { return 0x5533e8e9 } + +func (item *CasesInplace1PairTupleIntTupleInt) Reset() { + item.Value.Reset() +} + +func (item *CasesInplace1PairTupleIntTupleInt) FillRandom(rg *basictl.RandGenerator, nat_a1 uint32, nat_a2 uint32, nat_a3 uint32, nat_XXn uint32, nat_XYn uint32) { + item.Value.FillRandom(rg, nat_a2, nat_a3, nat_a1, nat_XXn, nat_XYn) +} + +func (item *CasesInplace1PairTupleIntTupleInt) Read(w []byte, nat_a1 uint32, nat_a2 uint32, nat_a3 uint32, nat_XXn uint32, nat_XYn uint32) (_ []byte, err error) { + return item.Value.Read(w, nat_a2, nat_a3, nat_a1, nat_XXn, nat_XYn) +} + +// This method is general version of Write, use it instead! +func (item *CasesInplace1PairTupleIntTupleInt) WriteGeneral(w []byte, nat_a1 uint32, nat_a2 uint32, nat_a3 uint32, nat_XXn uint32, nat_XYn uint32) (_ []byte, err error) { + return item.Write(w, nat_a1, nat_a2, nat_a3, nat_XXn, nat_XYn) +} + +func (item *CasesInplace1PairTupleIntTupleInt) Write(w []byte, nat_a1 uint32, nat_a2 uint32, nat_a3 uint32, nat_XXn uint32, nat_XYn uint32) (_ []byte, err error) { + if w, err = item.Value.Write(w, nat_a2, nat_a3, nat_a1, nat_XXn, nat_XYn); err != nil { + return w, err + } + return w, nil +} + +func (item *CasesInplace1PairTupleIntTupleInt) ReadBoxed(w []byte, nat_a1 uint32, nat_a2 uint32, nat_a3 uint32, nat_XXn uint32, nat_XYn uint32) (_ []byte, err error) { + if w, err = basictl.NatReadExactTag(w, 0x5533e8e9); err != nil { + return w, err + } + return item.Read(w, nat_a1, nat_a2, nat_a3, nat_XXn, nat_XYn) +} + +// This method is general version of WriteBoxed, use it instead! +func (item *CasesInplace1PairTupleIntTupleInt) WriteBoxedGeneral(w []byte, nat_a1 uint32, nat_a2 uint32, nat_a3 uint32, nat_XXn uint32, nat_XYn uint32) (_ []byte, err error) { + return item.WriteBoxed(w, nat_a1, nat_a2, nat_a3, nat_XXn, nat_XYn) +} + +func (item *CasesInplace1PairTupleIntTupleInt) WriteBoxed(w []byte, nat_a1 uint32, nat_a2 uint32, nat_a3 uint32, nat_XXn uint32, nat_XYn uint32) (_ []byte, err error) { + w = basictl.NatWrite(w, 0x5533e8e9) + return item.Write(w, nat_a1, nat_a2, nat_a3, nat_XXn, nat_XYn) +} + +func (item *CasesInplace1PairTupleIntTupleInt) ReadJSON(legacyTypeNames bool, in *basictl.JsonLexer, nat_a1 uint32, nat_a2 uint32, nat_a3 uint32, nat_XXn uint32, nat_XYn uint32) error { + var rawValue []byte + + if in != nil { + in.Delim('{') + if !in.Ok() { + return in.Error() + } + for !in.IsDelim('}') { + key := in.UnsafeFieldName(true) + in.WantColon() + switch key { + case "value": + if rawValue != nil { + return internal.ErrorInvalidJSONWithDuplicatingKeys("cases.inplace1", "value") + } + rawValue = in.Raw() + if !in.Ok() { + return in.Error() + } + default: + return internal.ErrorInvalidJSONExcessElement("cases.inplace1", key) + } + in.WantComma() + } + in.Delim('}') + if !in.Ok() { + return in.Error() + } + } + var inValuePointer *basictl.JsonLexer + inValue := basictl.JsonLexer{Data: rawValue} + if rawValue != nil { + inValuePointer = &inValue + } + if err := item.Value.ReadJSON(legacyTypeNames, inValuePointer, nat_a2, nat_a3, nat_a1, nat_XXn, nat_XYn); err != nil { + return err + } + + return nil +} + +// This method is general version of WriteJSON, use it instead! +func (item *CasesInplace1PairTupleIntTupleInt) WriteJSONGeneral(w []byte, nat_a1 uint32, nat_a2 uint32, nat_a3 uint32, nat_XXn uint32, nat_XYn uint32) (_ []byte, err error) { + return item.WriteJSONOpt(true, false, w, nat_a1, nat_a2, nat_a3, nat_XXn, nat_XYn) +} + +func (item *CasesInplace1PairTupleIntTupleInt) WriteJSON(w []byte, nat_a1 uint32, nat_a2 uint32, nat_a3 uint32, nat_XXn uint32, nat_XYn uint32) (_ []byte, err error) { + return item.WriteJSONOpt(true, false, w, nat_a1, nat_a2, nat_a3, nat_XXn, nat_XYn) +} +func (item *CasesInplace1PairTupleIntTupleInt) WriteJSONOpt(newTypeNames bool, short bool, w []byte, nat_a1 uint32, nat_a2 uint32, nat_a3 uint32, nat_XXn uint32, nat_XYn uint32) (_ []byte, err error) { + w = append(w, '{') + w = basictl.JSONAddCommaIfNeeded(w) + w = append(w, `"value":`...) + if w, err = item.Value.WriteJSONOpt(newTypeNames, short, w, nat_a2, nat_a3, nat_a1, nat_XXn, nat_XYn); err != nil { + return w, err + } + return append(w, '}'), nil +} diff --git a/internal/tlcodegen/test/gen/cases/internal/tlcases/tlCasesInplace2Int/cases.inplace2.go b/internal/tlcodegen/test/gen/cases/internal/tlcases/tlCasesInplace2Int/cases.inplace2.go new file mode 100644 index 00000000..7ef9496e --- /dev/null +++ b/internal/tlcodegen/test/gen/cases/internal/tlcases/tlCasesInplace2Int/cases.inplace2.go @@ -0,0 +1,125 @@ +// Copyright 2022 V Kontakte LLC +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at https://mozilla.org/MPL/2.0/. + +// Code generated by vktl/cmd/tlgen2; DO NOT EDIT. +package tlCasesInplace2Int + +import ( + "github.com/vkcom/tl/internal/tlcodegen/test/gen/cases/internal" + "github.com/vkcom/tl/internal/tlcodegen/test/gen/cases/internal/tlcases/tlCasesInplace3TupleInt2" + "github.com/vkcom/tl/pkg/basictl" +) + +var _ = basictl.NatWrite +var _ = internal.ErrorInvalidEnumTag + +type CasesInplace2Int struct { + Value tlCasesInplace3TupleInt2.CasesInplace3TupleInt2 +} + +func (CasesInplace2Int) TLName() string { return "cases.inplace2" } +func (CasesInplace2Int) TLTag() uint32 { return 0x869fcff5 } + +func (item *CasesInplace2Int) Reset() { + item.Value.Reset() +} + +func (item *CasesInplace2Int) FillRandom(rg *basictl.RandGenerator, nat_a1 uint32, nat_a2 uint32, nat_a3 uint32) { + item.Value.FillRandom(rg, nat_a2, nat_a3, nat_a1) +} + +func (item *CasesInplace2Int) Read(w []byte, nat_a1 uint32, nat_a2 uint32, nat_a3 uint32) (_ []byte, err error) { + return item.Value.Read(w, nat_a2, nat_a3, nat_a1) +} + +// This method is general version of Write, use it instead! +func (item *CasesInplace2Int) WriteGeneral(w []byte, nat_a1 uint32, nat_a2 uint32, nat_a3 uint32) (_ []byte, err error) { + return item.Write(w, nat_a1, nat_a2, nat_a3) +} + +func (item *CasesInplace2Int) Write(w []byte, nat_a1 uint32, nat_a2 uint32, nat_a3 uint32) (_ []byte, err error) { + if w, err = item.Value.Write(w, nat_a2, nat_a3, nat_a1); err != nil { + return w, err + } + return w, nil +} + +func (item *CasesInplace2Int) ReadBoxed(w []byte, nat_a1 uint32, nat_a2 uint32, nat_a3 uint32) (_ []byte, err error) { + if w, err = basictl.NatReadExactTag(w, 0x869fcff5); err != nil { + return w, err + } + return item.Read(w, nat_a1, nat_a2, nat_a3) +} + +// This method is general version of WriteBoxed, use it instead! +func (item *CasesInplace2Int) WriteBoxedGeneral(w []byte, nat_a1 uint32, nat_a2 uint32, nat_a3 uint32) (_ []byte, err error) { + return item.WriteBoxed(w, nat_a1, nat_a2, nat_a3) +} + +func (item *CasesInplace2Int) WriteBoxed(w []byte, nat_a1 uint32, nat_a2 uint32, nat_a3 uint32) (_ []byte, err error) { + w = basictl.NatWrite(w, 0x869fcff5) + return item.Write(w, nat_a1, nat_a2, nat_a3) +} + +func (item *CasesInplace2Int) ReadJSON(legacyTypeNames bool, in *basictl.JsonLexer, nat_a1 uint32, nat_a2 uint32, nat_a3 uint32) error { + var rawValue []byte + + if in != nil { + in.Delim('{') + if !in.Ok() { + return in.Error() + } + for !in.IsDelim('}') { + key := in.UnsafeFieldName(true) + in.WantColon() + switch key { + case "value": + if rawValue != nil { + return internal.ErrorInvalidJSONWithDuplicatingKeys("cases.inplace2", "value") + } + rawValue = in.Raw() + if !in.Ok() { + return in.Error() + } + default: + return internal.ErrorInvalidJSONExcessElement("cases.inplace2", key) + } + in.WantComma() + } + in.Delim('}') + if !in.Ok() { + return in.Error() + } + } + var inValuePointer *basictl.JsonLexer + inValue := basictl.JsonLexer{Data: rawValue} + if rawValue != nil { + inValuePointer = &inValue + } + if err := item.Value.ReadJSON(legacyTypeNames, inValuePointer, nat_a2, nat_a3, nat_a1); err != nil { + return err + } + + return nil +} + +// This method is general version of WriteJSON, use it instead! +func (item *CasesInplace2Int) WriteJSONGeneral(w []byte, nat_a1 uint32, nat_a2 uint32, nat_a3 uint32) (_ []byte, err error) { + return item.WriteJSONOpt(true, false, w, nat_a1, nat_a2, nat_a3) +} + +func (item *CasesInplace2Int) WriteJSON(w []byte, nat_a1 uint32, nat_a2 uint32, nat_a3 uint32) (_ []byte, err error) { + return item.WriteJSONOpt(true, false, w, nat_a1, nat_a2, nat_a3) +} +func (item *CasesInplace2Int) WriteJSONOpt(newTypeNames bool, short bool, w []byte, nat_a1 uint32, nat_a2 uint32, nat_a3 uint32) (_ []byte, err error) { + w = append(w, '{') + w = basictl.JSONAddCommaIfNeeded(w) + w = append(w, `"value":`...) + if w, err = item.Value.WriteJSONOpt(newTypeNames, short, w, nat_a2, nat_a3, nat_a1); err != nil { + return w, err + } + return append(w, '}'), nil +} diff --git a/internal/tlcodegen/test/gen/cases/internal/tlcases/tlCasesInplace2PairTupleIntTupleInt/cases.inplace2.go b/internal/tlcodegen/test/gen/cases/internal/tlcases/tlCasesInplace2PairTupleIntTupleInt/cases.inplace2.go new file mode 100644 index 00000000..589a638a --- /dev/null +++ b/internal/tlcodegen/test/gen/cases/internal/tlcases/tlCasesInplace2PairTupleIntTupleInt/cases.inplace2.go @@ -0,0 +1,125 @@ +// Copyright 2022 V Kontakte LLC +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at https://mozilla.org/MPL/2.0/. + +// Code generated by vktl/cmd/tlgen2; DO NOT EDIT. +package tlCasesInplace2PairTupleIntTupleInt + +import ( + "github.com/vkcom/tl/internal/tlcodegen/test/gen/cases/internal" + "github.com/vkcom/tl/internal/tlcodegen/test/gen/cases/internal/tlcases/tlCasesInplace3TuplePairTupleIntTupleInt2" + "github.com/vkcom/tl/pkg/basictl" +) + +var _ = basictl.NatWrite +var _ = internal.ErrorInvalidEnumTag + +type CasesInplace2PairTupleIntTupleInt struct { + Value tlCasesInplace3TuplePairTupleIntTupleInt2.CasesInplace3TuplePairTupleIntTupleInt2 +} + +func (CasesInplace2PairTupleIntTupleInt) TLName() string { return "cases.inplace2" } +func (CasesInplace2PairTupleIntTupleInt) TLTag() uint32 { return 0x869fcff5 } + +func (item *CasesInplace2PairTupleIntTupleInt) Reset() { + item.Value.Reset() +} + +func (item *CasesInplace2PairTupleIntTupleInt) FillRandom(rg *basictl.RandGenerator, nat_a1 uint32, nat_a2 uint32, nat_a3 uint32, nat_XXn uint32, nat_XYn uint32) { + item.Value.FillRandom(rg, nat_a2, nat_a3, nat_a1, nat_XXn, nat_XYn) +} + +func (item *CasesInplace2PairTupleIntTupleInt) Read(w []byte, nat_a1 uint32, nat_a2 uint32, nat_a3 uint32, nat_XXn uint32, nat_XYn uint32) (_ []byte, err error) { + return item.Value.Read(w, nat_a2, nat_a3, nat_a1, nat_XXn, nat_XYn) +} + +// This method is general version of Write, use it instead! +func (item *CasesInplace2PairTupleIntTupleInt) WriteGeneral(w []byte, nat_a1 uint32, nat_a2 uint32, nat_a3 uint32, nat_XXn uint32, nat_XYn uint32) (_ []byte, err error) { + return item.Write(w, nat_a1, nat_a2, nat_a3, nat_XXn, nat_XYn) +} + +func (item *CasesInplace2PairTupleIntTupleInt) Write(w []byte, nat_a1 uint32, nat_a2 uint32, nat_a3 uint32, nat_XXn uint32, nat_XYn uint32) (_ []byte, err error) { + if w, err = item.Value.Write(w, nat_a2, nat_a3, nat_a1, nat_XXn, nat_XYn); err != nil { + return w, err + } + return w, nil +} + +func (item *CasesInplace2PairTupleIntTupleInt) ReadBoxed(w []byte, nat_a1 uint32, nat_a2 uint32, nat_a3 uint32, nat_XXn uint32, nat_XYn uint32) (_ []byte, err error) { + if w, err = basictl.NatReadExactTag(w, 0x869fcff5); err != nil { + return w, err + } + return item.Read(w, nat_a1, nat_a2, nat_a3, nat_XXn, nat_XYn) +} + +// This method is general version of WriteBoxed, use it instead! +func (item *CasesInplace2PairTupleIntTupleInt) WriteBoxedGeneral(w []byte, nat_a1 uint32, nat_a2 uint32, nat_a3 uint32, nat_XXn uint32, nat_XYn uint32) (_ []byte, err error) { + return item.WriteBoxed(w, nat_a1, nat_a2, nat_a3, nat_XXn, nat_XYn) +} + +func (item *CasesInplace2PairTupleIntTupleInt) WriteBoxed(w []byte, nat_a1 uint32, nat_a2 uint32, nat_a3 uint32, nat_XXn uint32, nat_XYn uint32) (_ []byte, err error) { + w = basictl.NatWrite(w, 0x869fcff5) + return item.Write(w, nat_a1, nat_a2, nat_a3, nat_XXn, nat_XYn) +} + +func (item *CasesInplace2PairTupleIntTupleInt) ReadJSON(legacyTypeNames bool, in *basictl.JsonLexer, nat_a1 uint32, nat_a2 uint32, nat_a3 uint32, nat_XXn uint32, nat_XYn uint32) error { + var rawValue []byte + + if in != nil { + in.Delim('{') + if !in.Ok() { + return in.Error() + } + for !in.IsDelim('}') { + key := in.UnsafeFieldName(true) + in.WantColon() + switch key { + case "value": + if rawValue != nil { + return internal.ErrorInvalidJSONWithDuplicatingKeys("cases.inplace2", "value") + } + rawValue = in.Raw() + if !in.Ok() { + return in.Error() + } + default: + return internal.ErrorInvalidJSONExcessElement("cases.inplace2", key) + } + in.WantComma() + } + in.Delim('}') + if !in.Ok() { + return in.Error() + } + } + var inValuePointer *basictl.JsonLexer + inValue := basictl.JsonLexer{Data: rawValue} + if rawValue != nil { + inValuePointer = &inValue + } + if err := item.Value.ReadJSON(legacyTypeNames, inValuePointer, nat_a2, nat_a3, nat_a1, nat_XXn, nat_XYn); err != nil { + return err + } + + return nil +} + +// This method is general version of WriteJSON, use it instead! +func (item *CasesInplace2PairTupleIntTupleInt) WriteJSONGeneral(w []byte, nat_a1 uint32, nat_a2 uint32, nat_a3 uint32, nat_XXn uint32, nat_XYn uint32) (_ []byte, err error) { + return item.WriteJSONOpt(true, false, w, nat_a1, nat_a2, nat_a3, nat_XXn, nat_XYn) +} + +func (item *CasesInplace2PairTupleIntTupleInt) WriteJSON(w []byte, nat_a1 uint32, nat_a2 uint32, nat_a3 uint32, nat_XXn uint32, nat_XYn uint32) (_ []byte, err error) { + return item.WriteJSONOpt(true, false, w, nat_a1, nat_a2, nat_a3, nat_XXn, nat_XYn) +} +func (item *CasesInplace2PairTupleIntTupleInt) WriteJSONOpt(newTypeNames bool, short bool, w []byte, nat_a1 uint32, nat_a2 uint32, nat_a3 uint32, nat_XXn uint32, nat_XYn uint32) (_ []byte, err error) { + w = append(w, '{') + w = basictl.JSONAddCommaIfNeeded(w) + w = append(w, `"value":`...) + if w, err = item.Value.WriteJSONOpt(newTypeNames, short, w, nat_a2, nat_a3, nat_a1, nat_XXn, nat_XYn); err != nil { + return w, err + } + return append(w, '}'), nil +} diff --git a/internal/tlcodegen/test/gen/cases/internal/tlcases/tlCasesInplace3TupleInt2/cases.inplace3.go b/internal/tlcodegen/test/gen/cases/internal/tlcases/tlCasesInplace3TupleInt2/cases.inplace3.go new file mode 100644 index 00000000..88c9889c --- /dev/null +++ b/internal/tlcodegen/test/gen/cases/internal/tlcases/tlCasesInplace3TupleInt2/cases.inplace3.go @@ -0,0 +1,125 @@ +// Copyright 2022 V Kontakte LLC +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at https://mozilla.org/MPL/2.0/. + +// Code generated by vktl/cmd/tlgen2; DO NOT EDIT. +package tlCasesInplace3TupleInt2 + +import ( + "github.com/vkcom/tl/internal/tlcodegen/test/gen/cases/internal" + "github.com/vkcom/tl/internal/tlcodegen/test/gen/cases/internal/tl/tlPairTupleTupleInt2TupleTupleInt2" + "github.com/vkcom/tl/pkg/basictl" +) + +var _ = basictl.NatWrite +var _ = internal.ErrorInvalidEnumTag + +type CasesInplace3TupleInt2 struct { + Value tlPairTupleTupleInt2TupleTupleInt2.PairTupleTupleInt2TupleTupleInt2 +} + +func (CasesInplace3TupleInt2) TLName() string { return "cases.inplace3" } +func (CasesInplace3TupleInt2) TLTag() uint32 { return 0x4ffb95cb } + +func (item *CasesInplace3TupleInt2) Reset() { + item.Value.Reset() +} + +func (item *CasesInplace3TupleInt2) FillRandom(rg *basictl.RandGenerator, nat_a1 uint32, nat_a2 uint32, nat_a3 uint32) { + item.Value.FillRandom(rg, nat_a2, nat_a3) +} + +func (item *CasesInplace3TupleInt2) Read(w []byte, nat_a1 uint32, nat_a2 uint32, nat_a3 uint32) (_ []byte, err error) { + return item.Value.Read(w, nat_a2, nat_a3) +} + +// This method is general version of Write, use it instead! +func (item *CasesInplace3TupleInt2) WriteGeneral(w []byte, nat_a1 uint32, nat_a2 uint32, nat_a3 uint32) (_ []byte, err error) { + return item.Write(w, nat_a1, nat_a2, nat_a3) +} + +func (item *CasesInplace3TupleInt2) Write(w []byte, nat_a1 uint32, nat_a2 uint32, nat_a3 uint32) (_ []byte, err error) { + if w, err = item.Value.Write(w, nat_a2, nat_a3); err != nil { + return w, err + } + return w, nil +} + +func (item *CasesInplace3TupleInt2) ReadBoxed(w []byte, nat_a1 uint32, nat_a2 uint32, nat_a3 uint32) (_ []byte, err error) { + if w, err = basictl.NatReadExactTag(w, 0x4ffb95cb); err != nil { + return w, err + } + return item.Read(w, nat_a1, nat_a2, nat_a3) +} + +// This method is general version of WriteBoxed, use it instead! +func (item *CasesInplace3TupleInt2) WriteBoxedGeneral(w []byte, nat_a1 uint32, nat_a2 uint32, nat_a3 uint32) (_ []byte, err error) { + return item.WriteBoxed(w, nat_a1, nat_a2, nat_a3) +} + +func (item *CasesInplace3TupleInt2) WriteBoxed(w []byte, nat_a1 uint32, nat_a2 uint32, nat_a3 uint32) (_ []byte, err error) { + w = basictl.NatWrite(w, 0x4ffb95cb) + return item.Write(w, nat_a1, nat_a2, nat_a3) +} + +func (item *CasesInplace3TupleInt2) ReadJSON(legacyTypeNames bool, in *basictl.JsonLexer, nat_a1 uint32, nat_a2 uint32, nat_a3 uint32) error { + var rawValue []byte + + if in != nil { + in.Delim('{') + if !in.Ok() { + return in.Error() + } + for !in.IsDelim('}') { + key := in.UnsafeFieldName(true) + in.WantColon() + switch key { + case "value": + if rawValue != nil { + return internal.ErrorInvalidJSONWithDuplicatingKeys("cases.inplace3", "value") + } + rawValue = in.Raw() + if !in.Ok() { + return in.Error() + } + default: + return internal.ErrorInvalidJSONExcessElement("cases.inplace3", key) + } + in.WantComma() + } + in.Delim('}') + if !in.Ok() { + return in.Error() + } + } + var inValuePointer *basictl.JsonLexer + inValue := basictl.JsonLexer{Data: rawValue} + if rawValue != nil { + inValuePointer = &inValue + } + if err := item.Value.ReadJSON(legacyTypeNames, inValuePointer, nat_a2, nat_a3); err != nil { + return err + } + + return nil +} + +// This method is general version of WriteJSON, use it instead! +func (item *CasesInplace3TupleInt2) WriteJSONGeneral(w []byte, nat_a1 uint32, nat_a2 uint32, nat_a3 uint32) (_ []byte, err error) { + return item.WriteJSONOpt(true, false, w, nat_a1, nat_a2, nat_a3) +} + +func (item *CasesInplace3TupleInt2) WriteJSON(w []byte, nat_a1 uint32, nat_a2 uint32, nat_a3 uint32) (_ []byte, err error) { + return item.WriteJSONOpt(true, false, w, nat_a1, nat_a2, nat_a3) +} +func (item *CasesInplace3TupleInt2) WriteJSONOpt(newTypeNames bool, short bool, w []byte, nat_a1 uint32, nat_a2 uint32, nat_a3 uint32) (_ []byte, err error) { + w = append(w, '{') + w = basictl.JSONAddCommaIfNeeded(w) + w = append(w, `"value":`...) + if w, err = item.Value.WriteJSONOpt(newTypeNames, short, w, nat_a2, nat_a3); err != nil { + return w, err + } + return append(w, '}'), nil +} diff --git a/internal/tlcodegen/test/gen/cases/internal/tlcases/tlCasesInplace3TuplePairTupleIntTupleInt2/cases.inplace3.go b/internal/tlcodegen/test/gen/cases/internal/tlcases/tlCasesInplace3TuplePairTupleIntTupleInt2/cases.inplace3.go new file mode 100644 index 00000000..b9d87b26 --- /dev/null +++ b/internal/tlcodegen/test/gen/cases/internal/tlcases/tlCasesInplace3TuplePairTupleIntTupleInt2/cases.inplace3.go @@ -0,0 +1,125 @@ +// Copyright 2022 V Kontakte LLC +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at https://mozilla.org/MPL/2.0/. + +// Code generated by vktl/cmd/tlgen2; DO NOT EDIT. +package tlCasesInplace3TuplePairTupleIntTupleInt2 + +import ( + "github.com/vkcom/tl/internal/tlcodegen/test/gen/cases/internal" + "github.com/vkcom/tl/internal/tlcodegen/test/gen/cases/internal/tl/tlPairTupleTuplePairTupleIntTupleInt2TupleTuplePairTupleIntTupleInt2" + "github.com/vkcom/tl/pkg/basictl" +) + +var _ = basictl.NatWrite +var _ = internal.ErrorInvalidEnumTag + +type CasesInplace3TuplePairTupleIntTupleInt2 struct { + Value tlPairTupleTuplePairTupleIntTupleInt2TupleTuplePairTupleIntTupleInt2.PairTupleTuplePairTupleIntTupleInt2TupleTuplePairTupleIntTupleInt2 +} + +func (CasesInplace3TuplePairTupleIntTupleInt2) TLName() string { return "cases.inplace3" } +func (CasesInplace3TuplePairTupleIntTupleInt2) TLTag() uint32 { return 0x4ffb95cb } + +func (item *CasesInplace3TuplePairTupleIntTupleInt2) Reset() { + item.Value.Reset() +} + +func (item *CasesInplace3TuplePairTupleIntTupleInt2) FillRandom(rg *basictl.RandGenerator, nat_a1 uint32, nat_a2 uint32, nat_a3 uint32, nat_XtXn uint32, nat_XtYn uint32) { + item.Value.FillRandom(rg, nat_XtXn, nat_XtYn, nat_a2, nat_XtXn, nat_XtYn, nat_a3) +} + +func (item *CasesInplace3TuplePairTupleIntTupleInt2) Read(w []byte, nat_a1 uint32, nat_a2 uint32, nat_a3 uint32, nat_XtXn uint32, nat_XtYn uint32) (_ []byte, err error) { + return item.Value.Read(w, nat_XtXn, nat_XtYn, nat_a2, nat_XtXn, nat_XtYn, nat_a3) +} + +// This method is general version of Write, use it instead! +func (item *CasesInplace3TuplePairTupleIntTupleInt2) WriteGeneral(w []byte, nat_a1 uint32, nat_a2 uint32, nat_a3 uint32, nat_XtXn uint32, nat_XtYn uint32) (_ []byte, err error) { + return item.Write(w, nat_a1, nat_a2, nat_a3, nat_XtXn, nat_XtYn) +} + +func (item *CasesInplace3TuplePairTupleIntTupleInt2) Write(w []byte, nat_a1 uint32, nat_a2 uint32, nat_a3 uint32, nat_XtXn uint32, nat_XtYn uint32) (_ []byte, err error) { + if w, err = item.Value.Write(w, nat_XtXn, nat_XtYn, nat_a2, nat_XtXn, nat_XtYn, nat_a3); err != nil { + return w, err + } + return w, nil +} + +func (item *CasesInplace3TuplePairTupleIntTupleInt2) ReadBoxed(w []byte, nat_a1 uint32, nat_a2 uint32, nat_a3 uint32, nat_XtXn uint32, nat_XtYn uint32) (_ []byte, err error) { + if w, err = basictl.NatReadExactTag(w, 0x4ffb95cb); err != nil { + return w, err + } + return item.Read(w, nat_a1, nat_a2, nat_a3, nat_XtXn, nat_XtYn) +} + +// This method is general version of WriteBoxed, use it instead! +func (item *CasesInplace3TuplePairTupleIntTupleInt2) WriteBoxedGeneral(w []byte, nat_a1 uint32, nat_a2 uint32, nat_a3 uint32, nat_XtXn uint32, nat_XtYn uint32) (_ []byte, err error) { + return item.WriteBoxed(w, nat_a1, nat_a2, nat_a3, nat_XtXn, nat_XtYn) +} + +func (item *CasesInplace3TuplePairTupleIntTupleInt2) WriteBoxed(w []byte, nat_a1 uint32, nat_a2 uint32, nat_a3 uint32, nat_XtXn uint32, nat_XtYn uint32) (_ []byte, err error) { + w = basictl.NatWrite(w, 0x4ffb95cb) + return item.Write(w, nat_a1, nat_a2, nat_a3, nat_XtXn, nat_XtYn) +} + +func (item *CasesInplace3TuplePairTupleIntTupleInt2) ReadJSON(legacyTypeNames bool, in *basictl.JsonLexer, nat_a1 uint32, nat_a2 uint32, nat_a3 uint32, nat_XtXn uint32, nat_XtYn uint32) error { + var rawValue []byte + + if in != nil { + in.Delim('{') + if !in.Ok() { + return in.Error() + } + for !in.IsDelim('}') { + key := in.UnsafeFieldName(true) + in.WantColon() + switch key { + case "value": + if rawValue != nil { + return internal.ErrorInvalidJSONWithDuplicatingKeys("cases.inplace3", "value") + } + rawValue = in.Raw() + if !in.Ok() { + return in.Error() + } + default: + return internal.ErrorInvalidJSONExcessElement("cases.inplace3", key) + } + in.WantComma() + } + in.Delim('}') + if !in.Ok() { + return in.Error() + } + } + var inValuePointer *basictl.JsonLexer + inValue := basictl.JsonLexer{Data: rawValue} + if rawValue != nil { + inValuePointer = &inValue + } + if err := item.Value.ReadJSON(legacyTypeNames, inValuePointer, nat_XtXn, nat_XtYn, nat_a2, nat_XtXn, nat_XtYn, nat_a3); err != nil { + return err + } + + return nil +} + +// This method is general version of WriteJSON, use it instead! +func (item *CasesInplace3TuplePairTupleIntTupleInt2) WriteJSONGeneral(w []byte, nat_a1 uint32, nat_a2 uint32, nat_a3 uint32, nat_XtXn uint32, nat_XtYn uint32) (_ []byte, err error) { + return item.WriteJSONOpt(true, false, w, nat_a1, nat_a2, nat_a3, nat_XtXn, nat_XtYn) +} + +func (item *CasesInplace3TuplePairTupleIntTupleInt2) WriteJSON(w []byte, nat_a1 uint32, nat_a2 uint32, nat_a3 uint32, nat_XtXn uint32, nat_XtYn uint32) (_ []byte, err error) { + return item.WriteJSONOpt(true, false, w, nat_a1, nat_a2, nat_a3, nat_XtXn, nat_XtYn) +} +func (item *CasesInplace3TuplePairTupleIntTupleInt2) WriteJSONOpt(newTypeNames bool, short bool, w []byte, nat_a1 uint32, nat_a2 uint32, nat_a3 uint32, nat_XtXn uint32, nat_XtYn uint32) (_ []byte, err error) { + w = append(w, '{') + w = basictl.JSONAddCommaIfNeeded(w) + w = append(w, `"value":`...) + if w, err = item.Value.WriteJSONOpt(newTypeNames, short, w, nat_XtXn, nat_XtYn, nat_a2, nat_XtXn, nat_XtYn, nat_a3); err != nil { + return w, err + } + return append(w, '}'), nil +} diff --git a/internal/tlcodegen/test/gen/cases/internal/tlcases/tlCasesTestInplaceStructArgs/cases.testInplaceStructArgs.go b/internal/tlcodegen/test/gen/cases/internal/tlcases/tlCasesTestInplaceStructArgs/cases.testInplaceStructArgs.go new file mode 100644 index 00000000..5d4c7454 --- /dev/null +++ b/internal/tlcodegen/test/gen/cases/internal/tlcases/tlCasesTestInplaceStructArgs/cases.testInplaceStructArgs.go @@ -0,0 +1,219 @@ +// Copyright 2022 V Kontakte LLC +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at https://mozilla.org/MPL/2.0/. + +// Code generated by vktl/cmd/tlgen2; DO NOT EDIT. +package tlCasesTestInplaceStructArgs + +import ( + "github.com/vkcom/tl/internal/tlcodegen/test/gen/cases/internal" + "github.com/vkcom/tl/internal/tlcodegen/test/gen/cases/internal/tlcases/tlCasesInplace1Int" + "github.com/vkcom/tl/pkg/basictl" +) + +var _ = basictl.NatWrite +var _ = internal.ErrorInvalidEnumTag + +type CasesTestInplaceStructArgs struct { + A1 uint32 + A2 uint32 + A3 uint32 + Arg tlCasesInplace1Int.CasesInplace1Int +} + +func (CasesTestInplaceStructArgs) TLName() string { return "cases.testInplaceStructArgs" } +func (CasesTestInplaceStructArgs) TLTag() uint32 { return 0xa9e4441e } + +func (item *CasesTestInplaceStructArgs) Reset() { + item.A1 = 0 + item.A2 = 0 + item.A3 = 0 + item.Arg.Reset() +} + +func (item *CasesTestInplaceStructArgs) FillRandom(rg *basictl.RandGenerator) { + item.Arg.FillRandom(rg, item.A1, item.A2, item.A3) +} + +func (item *CasesTestInplaceStructArgs) Read(w []byte) (_ []byte, err error) { + if w, err = basictl.NatRead(w, &item.A1); err != nil { + return w, err + } + if w, err = basictl.NatRead(w, &item.A2); err != nil { + return w, err + } + if w, err = basictl.NatRead(w, &item.A3); err != nil { + return w, err + } + return item.Arg.Read(w, item.A1, item.A2, item.A3) +} + +// This method is general version of Write, use it instead! +func (item *CasesTestInplaceStructArgs) WriteGeneral(w []byte) (_ []byte, err error) { + return item.Write(w) +} + +func (item *CasesTestInplaceStructArgs) Write(w []byte) (_ []byte, err error) { + w = basictl.NatWrite(w, item.A1) + w = basictl.NatWrite(w, item.A2) + w = basictl.NatWrite(w, item.A3) + if w, err = item.Arg.Write(w, item.A1, item.A2, item.A3); err != nil { + return w, err + } + return w, nil +} + +func (item *CasesTestInplaceStructArgs) ReadBoxed(w []byte) (_ []byte, err error) { + if w, err = basictl.NatReadExactTag(w, 0xa9e4441e); err != nil { + return w, err + } + return item.Read(w) +} + +// This method is general version of WriteBoxed, use it instead! +func (item *CasesTestInplaceStructArgs) WriteBoxedGeneral(w []byte) (_ []byte, err error) { + return item.WriteBoxed(w) +} + +func (item *CasesTestInplaceStructArgs) WriteBoxed(w []byte) (_ []byte, err error) { + w = basictl.NatWrite(w, 0xa9e4441e) + return item.Write(w) +} + +func (item CasesTestInplaceStructArgs) String() string { + w, err := item.WriteJSON(nil) + if err != nil { + return err.Error() + } + return string(w) +} + +func (item *CasesTestInplaceStructArgs) ReadJSON(legacyTypeNames bool, in *basictl.JsonLexer) error { + var propA1Presented bool + var propA2Presented bool + var propA3Presented bool + var rawArg []byte + + if in != nil { + in.Delim('{') + if !in.Ok() { + return in.Error() + } + for !in.IsDelim('}') { + key := in.UnsafeFieldName(true) + in.WantColon() + switch key { + case "a1": + if propA1Presented { + return internal.ErrorInvalidJSONWithDuplicatingKeys("cases.testInplaceStructArgs", "a1") + } + if err := internal.Json2ReadUint32(in, &item.A1); err != nil { + return err + } + propA1Presented = true + case "a2": + if propA2Presented { + return internal.ErrorInvalidJSONWithDuplicatingKeys("cases.testInplaceStructArgs", "a2") + } + if err := internal.Json2ReadUint32(in, &item.A2); err != nil { + return err + } + propA2Presented = true + case "a3": + if propA3Presented { + return internal.ErrorInvalidJSONWithDuplicatingKeys("cases.testInplaceStructArgs", "a3") + } + if err := internal.Json2ReadUint32(in, &item.A3); err != nil { + return err + } + propA3Presented = true + case "arg": + if rawArg != nil { + return internal.ErrorInvalidJSONWithDuplicatingKeys("cases.testInplaceStructArgs", "arg") + } + rawArg = in.Raw() + if !in.Ok() { + return in.Error() + } + default: + return internal.ErrorInvalidJSONExcessElement("cases.testInplaceStructArgs", key) + } + in.WantComma() + } + in.Delim('}') + if !in.Ok() { + return in.Error() + } + } + if !propA1Presented { + item.A1 = 0 + } + if !propA2Presented { + item.A2 = 0 + } + if !propA3Presented { + item.A3 = 0 + } + var inArgPointer *basictl.JsonLexer + inArg := basictl.JsonLexer{Data: rawArg} + if rawArg != nil { + inArgPointer = &inArg + } + if err := item.Arg.ReadJSON(legacyTypeNames, inArgPointer, item.A1, item.A2, item.A3); err != nil { + return err + } + + return nil +} + +// This method is general version of WriteJSON, use it instead! +func (item *CasesTestInplaceStructArgs) WriteJSONGeneral(w []byte) (_ []byte, err error) { + return item.WriteJSONOpt(true, false, w) +} + +func (item *CasesTestInplaceStructArgs) WriteJSON(w []byte) (_ []byte, err error) { + return item.WriteJSONOpt(true, false, w) +} +func (item *CasesTestInplaceStructArgs) WriteJSONOpt(newTypeNames bool, short bool, w []byte) (_ []byte, err error) { + w = append(w, '{') + backupIndexA1 := len(w) + w = basictl.JSONAddCommaIfNeeded(w) + w = append(w, `"a1":`...) + w = basictl.JSONWriteUint32(w, item.A1) + if (item.A1 != 0) == false { + w = w[:backupIndexA1] + } + backupIndexA2 := len(w) + w = basictl.JSONAddCommaIfNeeded(w) + w = append(w, `"a2":`...) + w = basictl.JSONWriteUint32(w, item.A2) + if (item.A2 != 0) == false { + w = w[:backupIndexA2] + } + backupIndexA3 := len(w) + w = basictl.JSONAddCommaIfNeeded(w) + w = append(w, `"a3":`...) + w = basictl.JSONWriteUint32(w, item.A3) + if (item.A3 != 0) == false { + w = w[:backupIndexA3] + } + w = basictl.JSONAddCommaIfNeeded(w) + w = append(w, `"arg":`...) + if w, err = item.Arg.WriteJSONOpt(newTypeNames, short, w, item.A1, item.A2, item.A3); err != nil { + return w, err + } + return append(w, '}'), nil +} + +func (item *CasesTestInplaceStructArgs) MarshalJSON() ([]byte, error) { + return item.WriteJSON(nil) +} + +func (item *CasesTestInplaceStructArgs) UnmarshalJSON(b []byte) error { + if err := item.ReadJSON(true, &basictl.JsonLexer{Data: b}); err != nil { + return internal.ErrorInvalidJSON("cases.testInplaceStructArgs", err.Error()) + } + return nil +} diff --git a/internal/tlcodegen/test/gen/cases/internal/tlcases/tlCasesTestInplaceStructArgs2/cases.testInplaceStructArgs2.go b/internal/tlcodegen/test/gen/cases/internal/tlcases/tlCasesTestInplaceStructArgs2/cases.testInplaceStructArgs2.go new file mode 100644 index 00000000..e66ec04d --- /dev/null +++ b/internal/tlcodegen/test/gen/cases/internal/tlcases/tlCasesTestInplaceStructArgs2/cases.testInplaceStructArgs2.go @@ -0,0 +1,219 @@ +// Copyright 2022 V Kontakte LLC +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at https://mozilla.org/MPL/2.0/. + +// Code generated by vktl/cmd/tlgen2; DO NOT EDIT. +package tlCasesTestInplaceStructArgs2 + +import ( + "github.com/vkcom/tl/internal/tlcodegen/test/gen/cases/internal" + "github.com/vkcom/tl/internal/tlcodegen/test/gen/cases/internal/tlcases/tlCasesInplace1PairTupleIntTupleInt" + "github.com/vkcom/tl/pkg/basictl" +) + +var _ = basictl.NatWrite +var _ = internal.ErrorInvalidEnumTag + +type CasesTestInplaceStructArgs2 struct { + A1 uint32 + A2 uint32 + A3 uint32 + Arg tlCasesInplace1PairTupleIntTupleInt.CasesInplace1PairTupleIntTupleInt +} + +func (CasesTestInplaceStructArgs2) TLName() string { return "cases.testInplaceStructArgs2" } +func (CasesTestInplaceStructArgs2) TLTag() uint32 { return 0xaa9f2480 } + +func (item *CasesTestInplaceStructArgs2) Reset() { + item.A1 = 0 + item.A2 = 0 + item.A3 = 0 + item.Arg.Reset() +} + +func (item *CasesTestInplaceStructArgs2) FillRandom(rg *basictl.RandGenerator) { + item.Arg.FillRandom(rg, item.A1, item.A2, item.A3, item.A3, item.A2) +} + +func (item *CasesTestInplaceStructArgs2) Read(w []byte) (_ []byte, err error) { + if w, err = basictl.NatRead(w, &item.A1); err != nil { + return w, err + } + if w, err = basictl.NatRead(w, &item.A2); err != nil { + return w, err + } + if w, err = basictl.NatRead(w, &item.A3); err != nil { + return w, err + } + return item.Arg.Read(w, item.A1, item.A2, item.A3, item.A3, item.A2) +} + +// This method is general version of Write, use it instead! +func (item *CasesTestInplaceStructArgs2) WriteGeneral(w []byte) (_ []byte, err error) { + return item.Write(w) +} + +func (item *CasesTestInplaceStructArgs2) Write(w []byte) (_ []byte, err error) { + w = basictl.NatWrite(w, item.A1) + w = basictl.NatWrite(w, item.A2) + w = basictl.NatWrite(w, item.A3) + if w, err = item.Arg.Write(w, item.A1, item.A2, item.A3, item.A3, item.A2); err != nil { + return w, err + } + return w, nil +} + +func (item *CasesTestInplaceStructArgs2) ReadBoxed(w []byte) (_ []byte, err error) { + if w, err = basictl.NatReadExactTag(w, 0xaa9f2480); err != nil { + return w, err + } + return item.Read(w) +} + +// This method is general version of WriteBoxed, use it instead! +func (item *CasesTestInplaceStructArgs2) WriteBoxedGeneral(w []byte) (_ []byte, err error) { + return item.WriteBoxed(w) +} + +func (item *CasesTestInplaceStructArgs2) WriteBoxed(w []byte) (_ []byte, err error) { + w = basictl.NatWrite(w, 0xaa9f2480) + return item.Write(w) +} + +func (item CasesTestInplaceStructArgs2) String() string { + w, err := item.WriteJSON(nil) + if err != nil { + return err.Error() + } + return string(w) +} + +func (item *CasesTestInplaceStructArgs2) ReadJSON(legacyTypeNames bool, in *basictl.JsonLexer) error { + var propA1Presented bool + var propA2Presented bool + var propA3Presented bool + var rawArg []byte + + if in != nil { + in.Delim('{') + if !in.Ok() { + return in.Error() + } + for !in.IsDelim('}') { + key := in.UnsafeFieldName(true) + in.WantColon() + switch key { + case "a1": + if propA1Presented { + return internal.ErrorInvalidJSONWithDuplicatingKeys("cases.testInplaceStructArgs2", "a1") + } + if err := internal.Json2ReadUint32(in, &item.A1); err != nil { + return err + } + propA1Presented = true + case "a2": + if propA2Presented { + return internal.ErrorInvalidJSONWithDuplicatingKeys("cases.testInplaceStructArgs2", "a2") + } + if err := internal.Json2ReadUint32(in, &item.A2); err != nil { + return err + } + propA2Presented = true + case "a3": + if propA3Presented { + return internal.ErrorInvalidJSONWithDuplicatingKeys("cases.testInplaceStructArgs2", "a3") + } + if err := internal.Json2ReadUint32(in, &item.A3); err != nil { + return err + } + propA3Presented = true + case "arg": + if rawArg != nil { + return internal.ErrorInvalidJSONWithDuplicatingKeys("cases.testInplaceStructArgs2", "arg") + } + rawArg = in.Raw() + if !in.Ok() { + return in.Error() + } + default: + return internal.ErrorInvalidJSONExcessElement("cases.testInplaceStructArgs2", key) + } + in.WantComma() + } + in.Delim('}') + if !in.Ok() { + return in.Error() + } + } + if !propA1Presented { + item.A1 = 0 + } + if !propA2Presented { + item.A2 = 0 + } + if !propA3Presented { + item.A3 = 0 + } + var inArgPointer *basictl.JsonLexer + inArg := basictl.JsonLexer{Data: rawArg} + if rawArg != nil { + inArgPointer = &inArg + } + if err := item.Arg.ReadJSON(legacyTypeNames, inArgPointer, item.A1, item.A2, item.A3, item.A3, item.A2); err != nil { + return err + } + + return nil +} + +// This method is general version of WriteJSON, use it instead! +func (item *CasesTestInplaceStructArgs2) WriteJSONGeneral(w []byte) (_ []byte, err error) { + return item.WriteJSONOpt(true, false, w) +} + +func (item *CasesTestInplaceStructArgs2) WriteJSON(w []byte) (_ []byte, err error) { + return item.WriteJSONOpt(true, false, w) +} +func (item *CasesTestInplaceStructArgs2) WriteJSONOpt(newTypeNames bool, short bool, w []byte) (_ []byte, err error) { + w = append(w, '{') + backupIndexA1 := len(w) + w = basictl.JSONAddCommaIfNeeded(w) + w = append(w, `"a1":`...) + w = basictl.JSONWriteUint32(w, item.A1) + if (item.A1 != 0) == false { + w = w[:backupIndexA1] + } + backupIndexA2 := len(w) + w = basictl.JSONAddCommaIfNeeded(w) + w = append(w, `"a2":`...) + w = basictl.JSONWriteUint32(w, item.A2) + if (item.A2 != 0) == false { + w = w[:backupIndexA2] + } + backupIndexA3 := len(w) + w = basictl.JSONAddCommaIfNeeded(w) + w = append(w, `"a3":`...) + w = basictl.JSONWriteUint32(w, item.A3) + if (item.A3 != 0) == false { + w = w[:backupIndexA3] + } + w = basictl.JSONAddCommaIfNeeded(w) + w = append(w, `"arg":`...) + if w, err = item.Arg.WriteJSONOpt(newTypeNames, short, w, item.A1, item.A2, item.A3, item.A3, item.A2); err != nil { + return w, err + } + return append(w, '}'), nil +} + +func (item *CasesTestInplaceStructArgs2) MarshalJSON() ([]byte, error) { + return item.WriteJSON(nil) +} + +func (item *CasesTestInplaceStructArgs2) UnmarshalJSON(b []byte) error { + if err := item.ReadJSON(true, &basictl.JsonLexer{Data: b}); err != nil { + return internal.ErrorInvalidJSON("cases.testInplaceStructArgs2", err.Error()) + } + return nil +}