diff --git a/thrift/compiler/test/fixtures/adapter/gen-go/module/adapterservice.go b/thrift/compiler/test/fixtures/adapter/gen-go/module/adapterservice.go deleted file mode 100644 index 3ddfe8de670..00000000000 --- a/thrift/compiler/test/fixtures/adapter/gen-go/module/adapterservice.go +++ /dev/null @@ -1,836 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package module - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -type AdapterService interface { - Count() (_r *CountingStruct, err error) - // Parameters: - // - Arg - AdaptedTypes(arg *HeapAllocated) (_r *HeapAllocated, err error) -} - -type AdapterServiceClientInterface interface { - thrift.ClientInterface - Count() (_r *CountingStruct, err error) - // Parameters: - // - Arg - AdaptedTypes(arg *HeapAllocated) (_r *HeapAllocated, err error) -} - -type AdapterServiceClient struct { - AdapterServiceClientInterface - CC thrift.ClientConn -} - -func(client *AdapterServiceClient) Open() error { - return client.CC.Open() -} - -func(client *AdapterServiceClient) Close() error { - return client.CC.Close() -} - -func(client *AdapterServiceClient) IsOpen() bool { - return client.CC.IsOpen() -} - -func NewAdapterServiceClientFactory(t thrift.Transport, f thrift.ProtocolFactory) *AdapterServiceClient { - return &AdapterServiceClient{ CC: thrift.NewClientConn(t, f) } -} - -func NewAdapterServiceClient(t thrift.Transport, iprot thrift.Protocol, oprot thrift.Protocol) *AdapterServiceClient { - return &AdapterServiceClient{ CC: thrift.NewClientConnWithProtocols(t, iprot, oprot) } -} - -func NewAdapterServiceClientProtocol(prot thrift.Protocol) *AdapterServiceClient { - return NewAdapterServiceClient(prot.Transport(), prot, prot) -} - -func (p *AdapterServiceClient) Count() (_r *CountingStruct, err error) { - var args AdapterServiceCountArgs - err = p.CC.SendMsg("count", &args, thrift.CALL) - if err != nil { return } - return p.recvCount() -} - - -func (p *AdapterServiceClient) recvCount() (value *CountingStruct, err error) { - var __result AdapterServiceCountResult - err = p.CC.RecvMsg("count", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -// Parameters: -// - Arg -func (p *AdapterServiceClient) AdaptedTypes(arg *HeapAllocated) (_r *HeapAllocated, err error) { - args := AdapterServiceAdaptedTypesArgs{ - Arg : arg, - } - err = p.CC.SendMsg("adaptedTypes", &args, thrift.CALL) - if err != nil { return } - return p.recvAdaptedTypes() -} - - -func (p *AdapterServiceClient) recvAdaptedTypes() (value *HeapAllocated, err error) { - var __result AdapterServiceAdaptedTypesResult - err = p.CC.RecvMsg("adaptedTypes", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - - -type AdapterServiceThreadsafeClient struct { - AdapterServiceClientInterface - CC thrift.ClientConn - Mu sync.Mutex -} - -func(client *AdapterServiceThreadsafeClient) Open() error { - client.Mu.Lock() - defer client.Mu.Unlock() - return client.CC.Open() -} - -func(client *AdapterServiceThreadsafeClient) Close() error { - client.Mu.Lock() - defer client.Mu.Unlock() - return client.CC.Close() -} - -func(client *AdapterServiceThreadsafeClient) IsOpen() bool { - client.Mu.Lock() - defer client.Mu.Unlock() - return client.CC.IsOpen() -} - -func NewAdapterServiceThreadsafeClientFactory(t thrift.Transport, f thrift.ProtocolFactory) *AdapterServiceThreadsafeClient { - return &AdapterServiceThreadsafeClient{ CC: thrift.NewClientConn(t, f) } -} - -func NewAdapterServiceThreadsafeClient(t thrift.Transport, iprot thrift.Protocol, oprot thrift.Protocol) *AdapterServiceThreadsafeClient { - return &AdapterServiceThreadsafeClient{ CC: thrift.NewClientConnWithProtocols(t, iprot, oprot) } -} - -func NewAdapterServiceThreadsafeClientProtocol(prot thrift.Protocol) *AdapterServiceThreadsafeClient { - return NewAdapterServiceThreadsafeClient(prot.Transport(), prot, prot) -} - -func (p *AdapterServiceThreadsafeClient) Count() (_r *CountingStruct, err error) { - p.Mu.Lock() - defer p.Mu.Unlock() - var args AdapterServiceCountArgs - err = p.CC.SendMsg("count", &args, thrift.CALL) - if err != nil { return } - return p.recvCount() -} - - -func (p *AdapterServiceThreadsafeClient) recvCount() (value *CountingStruct, err error) { - var __result AdapterServiceCountResult - err = p.CC.RecvMsg("count", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -// Parameters: -// - Arg -func (p *AdapterServiceThreadsafeClient) AdaptedTypes(arg *HeapAllocated) (_r *HeapAllocated, err error) { - p.Mu.Lock() - defer p.Mu.Unlock() - args := AdapterServiceAdaptedTypesArgs{ - Arg : arg, - } - err = p.CC.SendMsg("adaptedTypes", &args, thrift.CALL) - if err != nil { return } - return p.recvAdaptedTypes() -} - - -func (p *AdapterServiceThreadsafeClient) recvAdaptedTypes() (value *HeapAllocated, err error) { - var __result AdapterServiceAdaptedTypesResult - err = p.CC.RecvMsg("adaptedTypes", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - - -type AdapterServiceChannelClient struct { - RequestChannel thrift.RequestChannel -} - -func (c *AdapterServiceChannelClient) Close() error { - return c.RequestChannel.Close() -} - -func (c *AdapterServiceChannelClient) IsOpen() bool { - return c.RequestChannel.IsOpen() -} - -func (c *AdapterServiceChannelClient) Open() error { - return c.RequestChannel.Open() -} - -func NewAdapterServiceChannelClient(channel thrift.RequestChannel) *AdapterServiceChannelClient { - return &AdapterServiceChannelClient{RequestChannel: channel} -} - -func (p *AdapterServiceChannelClient) Count(ctx context.Context) (_r *CountingStruct, err error) { - args := AdapterServiceCountArgs{ - } - var __result AdapterServiceCountResult - err = p.RequestChannel.Call(ctx, "count", &args, &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -// Parameters: -// - Arg -func (p *AdapterServiceChannelClient) AdaptedTypes(ctx context.Context, arg *HeapAllocated) (_r *HeapAllocated, err error) { - args := AdapterServiceAdaptedTypesArgs{ - Arg : arg, - } - var __result AdapterServiceAdaptedTypesResult - err = p.RequestChannel.Call(ctx, "adaptedTypes", &args, &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - - -type AdapterServiceProcessor struct { - processorMap map[string]thrift.ProcessorFunction - functionServiceMap map[string]string - handler AdapterService -} - -func (p *AdapterServiceProcessor) AddToProcessorMap(key string, processor thrift.ProcessorFunction) { - p.processorMap[key] = processor -} - -func (p *AdapterServiceProcessor) AddToFunctionServiceMap(key, service string) { - p.functionServiceMap[key] = service -} - -func (p *AdapterServiceProcessor) GetProcessorFunction(key string) (processor thrift.ProcessorFunction, err error) { - if processor, ok := p.processorMap[key]; ok { - return processor, nil - } - return nil, nil // generic error message will be sent -} - -func (p *AdapterServiceProcessor) ProcessorMap() map[string]thrift.ProcessorFunction { - return p.processorMap -} - -func (p *AdapterServiceProcessor) FunctionServiceMap() map[string]string { - return p.functionServiceMap -} - -func NewAdapterServiceProcessor(handler AdapterService) *AdapterServiceProcessor { - self26 := &AdapterServiceProcessor{handler:handler, processorMap:make(map[string]thrift.ProcessorFunction), functionServiceMap:make(map[string]string)} - self26.processorMap["count"] = &adapterServiceProcessorCount{handler:handler} - self26.processorMap["adaptedTypes"] = &adapterServiceProcessorAdaptedTypes{handler:handler} - self26.functionServiceMap["count"] = "AdapterService" - self26.functionServiceMap["adaptedTypes"] = "AdapterService" - return self26 -} - -type adapterServiceProcessorCount struct { - handler AdapterService -} - -func (p *AdapterServiceCountResult) Exception() thrift.WritableException { - if p == nil { return nil } - return nil -} - -func (p *adapterServiceProcessorCount) Read(iprot thrift.Protocol) (thrift.Struct, thrift.Exception) { - args := AdapterServiceCountArgs{} - if err := args.Read(iprot); err != nil { - return nil, err - } - iprot.ReadMessageEnd() - return &args, nil -} - -func (p *adapterServiceProcessorCount) Write(seqId int32, result thrift.WritableStruct, oprot thrift.Protocol) (err thrift.Exception) { - var err2 error - messageType := thrift.REPLY - switch result.(type) { - case thrift.ApplicationException: - messageType = thrift.EXCEPTION - } - if err2 = oprot.WriteMessageBegin("count", messageType, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - return err -} - -func (p *adapterServiceProcessorCount) Run(argStruct thrift.Struct) (thrift.WritableStruct, thrift.ApplicationException) { - var __result AdapterServiceCountResult - if retval, err := p.handler.Count(); err != nil { - switch err.(type) { - default: - x := thrift.NewApplicationExceptionCause(thrift.INTERNAL_ERROR, "Internal error processing count: " + err.Error(), err) - return x, x - } - } else { - __result.Success = retval - } - return &__result, nil -} - -type adapterServiceProcessorAdaptedTypes struct { - handler AdapterService -} - -func (p *AdapterServiceAdaptedTypesResult) Exception() thrift.WritableException { - if p == nil { return nil } - return nil -} - -func (p *adapterServiceProcessorAdaptedTypes) Read(iprot thrift.Protocol) (thrift.Struct, thrift.Exception) { - args := AdapterServiceAdaptedTypesArgs{} - if err := args.Read(iprot); err != nil { - return nil, err - } - iprot.ReadMessageEnd() - return &args, nil -} - -func (p *adapterServiceProcessorAdaptedTypes) Write(seqId int32, result thrift.WritableStruct, oprot thrift.Protocol) (err thrift.Exception) { - var err2 error - messageType := thrift.REPLY - switch result.(type) { - case thrift.ApplicationException: - messageType = thrift.EXCEPTION - } - if err2 = oprot.WriteMessageBegin("adaptedTypes", messageType, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - return err -} - -func (p *adapterServiceProcessorAdaptedTypes) Run(argStruct thrift.Struct) (thrift.WritableStruct, thrift.ApplicationException) { - args := argStruct.(*AdapterServiceAdaptedTypesArgs) - var __result AdapterServiceAdaptedTypesResult - if retval, err := p.handler.AdaptedTypes(args.Arg); err != nil { - switch err.(type) { - default: - x := thrift.NewApplicationExceptionCause(thrift.INTERNAL_ERROR, "Internal error processing adaptedTypes: " + err.Error(), err) - return x, x - } - } else { - __result.Success = retval - } - return &__result, nil -} - - -// HELPER FUNCTIONS AND STRUCTURES - -type AdapterServiceCountArgs struct { - thrift.IRequest -} - -func NewAdapterServiceCountArgs() *AdapterServiceCountArgs { - return &AdapterServiceCountArgs{} -} - -type AdapterServiceCountArgsBuilder struct { - obj *AdapterServiceCountArgs -} - -func NewAdapterServiceCountArgsBuilder() *AdapterServiceCountArgsBuilder{ - return &AdapterServiceCountArgsBuilder{ - obj: NewAdapterServiceCountArgs(), - } -} - -func (p AdapterServiceCountArgsBuilder) Emit() *AdapterServiceCountArgs{ - return &AdapterServiceCountArgs{ - } -} - -func (p *AdapterServiceCountArgs) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AdapterServiceCountArgs) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("count_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *AdapterServiceCountArgs) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("AdapterServiceCountArgs({})") -} - -// Attributes: -// - Success -type AdapterServiceCountResult struct { - thrift.IResponse - Success *CountingStruct `thrift:"success,0,optional" db:"success" json:"success,omitempty"` -} - -func NewAdapterServiceCountResult() *AdapterServiceCountResult { - return &AdapterServiceCountResult{} -} - -var AdapterServiceCountResult_Success_DEFAULT *CountingStruct -func (p *AdapterServiceCountResult) GetSuccess() *CountingStruct { - if !p.IsSetSuccess() { - return AdapterServiceCountResult_Success_DEFAULT - } - return p.Success -} -func (p *AdapterServiceCountResult) DefaultGetSuccess() *CountingStruct { - if !p.IsSetSuccess() { - return NewCountingStruct() - } - return p.Success -} -func (p *AdapterServiceCountResult) IsSetSuccess() bool { - return p != nil && p.Success != nil -} - -type AdapterServiceCountResultBuilder struct { - obj *AdapterServiceCountResult -} - -func NewAdapterServiceCountResultBuilder() *AdapterServiceCountResultBuilder{ - return &AdapterServiceCountResultBuilder{ - obj: NewAdapterServiceCountResult(), - } -} - -func (p AdapterServiceCountResultBuilder) Emit() *AdapterServiceCountResult{ - return &AdapterServiceCountResult{ - Success: p.obj.Success, - } -} - -func (a *AdapterServiceCountResultBuilder) Success(success *CountingStruct) *AdapterServiceCountResultBuilder { - a.obj.Success = success - return a -} - -func (a *AdapterServiceCountResult) SetSuccess(success *CountingStruct) *AdapterServiceCountResult { - a.Success = success - return a -} - -func (p *AdapterServiceCountResult) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 0: - if err := p.ReadField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AdapterServiceCountResult) ReadField0(iprot thrift.Protocol) error { - p.Success = NewCountingStruct() - if err := p.Success.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) - } - return nil -} - -func (p *AdapterServiceCountResult) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("count_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField0(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *AdapterServiceCountResult) writeField0(oprot thrift.Protocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := p.Success.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } - } - return err -} - -func (p *AdapterServiceCountResult) String() string { - if p == nil { - return "" - } - - var successVal string - if p.Success == nil { - successVal = "" - } else { - successVal = fmt.Sprintf("%v", p.Success) - } - return fmt.Sprintf("AdapterServiceCountResult({Success:%s})", successVal) -} - -// Attributes: -// - Arg -type AdapterServiceAdaptedTypesArgs struct { - thrift.IRequest - Arg *HeapAllocated `thrift:"arg,1" db:"arg" json:"arg"` -} - -func NewAdapterServiceAdaptedTypesArgs() *AdapterServiceAdaptedTypesArgs { - return &AdapterServiceAdaptedTypesArgs{ - Arg: NewHeapAllocated(), - } -} - -var AdapterServiceAdaptedTypesArgs_Arg_DEFAULT *HeapAllocated -func (p *AdapterServiceAdaptedTypesArgs) GetArg() *HeapAllocated { - if !p.IsSetArg() { - return AdapterServiceAdaptedTypesArgs_Arg_DEFAULT - } - return p.Arg -} -func (p *AdapterServiceAdaptedTypesArgs) DefaultGetArg() *HeapAllocated { - if !p.IsSetArg() { - return NewHeapAllocated() - } - return p.Arg -} -func (p *AdapterServiceAdaptedTypesArgs) IsSetArg() bool { - return p != nil && p.Arg != nil -} - -type AdapterServiceAdaptedTypesArgsBuilder struct { - obj *AdapterServiceAdaptedTypesArgs -} - -func NewAdapterServiceAdaptedTypesArgsBuilder() *AdapterServiceAdaptedTypesArgsBuilder{ - return &AdapterServiceAdaptedTypesArgsBuilder{ - obj: NewAdapterServiceAdaptedTypesArgs(), - } -} - -func (p AdapterServiceAdaptedTypesArgsBuilder) Emit() *AdapterServiceAdaptedTypesArgs{ - return &AdapterServiceAdaptedTypesArgs{ - Arg: p.obj.Arg, - } -} - -func (a *AdapterServiceAdaptedTypesArgsBuilder) Arg(arg *HeapAllocated) *AdapterServiceAdaptedTypesArgsBuilder { - a.obj.Arg = arg - return a -} - -func (a *AdapterServiceAdaptedTypesArgs) SetArg(arg *HeapAllocated) *AdapterServiceAdaptedTypesArgs { - a.Arg = arg - return a -} - -func (p *AdapterServiceAdaptedTypesArgs) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AdapterServiceAdaptedTypesArgs) ReadField1(iprot thrift.Protocol) error { - p.Arg = NewHeapAllocated() - if err := p.Arg.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Arg), err) - } - return nil -} - -func (p *AdapterServiceAdaptedTypesArgs) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("adaptedTypes_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *AdapterServiceAdaptedTypesArgs) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("arg", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:arg: ", p), err) } - if err := p.Arg.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Arg), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:arg: ", p), err) } - return err -} - -func (p *AdapterServiceAdaptedTypesArgs) String() string { - if p == nil { - return "" - } - - var argVal string - if p.Arg == nil { - argVal = "" - } else { - argVal = fmt.Sprintf("%v", p.Arg) - } - return fmt.Sprintf("AdapterServiceAdaptedTypesArgs({Arg:%s})", argVal) -} - -// Attributes: -// - Success -type AdapterServiceAdaptedTypesResult struct { - thrift.IResponse - Success *HeapAllocated `thrift:"success,0,optional" db:"success" json:"success,omitempty"` -} - -func NewAdapterServiceAdaptedTypesResult() *AdapterServiceAdaptedTypesResult { - return &AdapterServiceAdaptedTypesResult{} -} - -var AdapterServiceAdaptedTypesResult_Success_DEFAULT *HeapAllocated -func (p *AdapterServiceAdaptedTypesResult) GetSuccess() *HeapAllocated { - if !p.IsSetSuccess() { - return AdapterServiceAdaptedTypesResult_Success_DEFAULT - } - return p.Success -} -func (p *AdapterServiceAdaptedTypesResult) DefaultGetSuccess() *HeapAllocated { - if !p.IsSetSuccess() { - return NewHeapAllocated() - } - return p.Success -} -func (p *AdapterServiceAdaptedTypesResult) IsSetSuccess() bool { - return p != nil && p.Success != nil -} - -type AdapterServiceAdaptedTypesResultBuilder struct { - obj *AdapterServiceAdaptedTypesResult -} - -func NewAdapterServiceAdaptedTypesResultBuilder() *AdapterServiceAdaptedTypesResultBuilder{ - return &AdapterServiceAdaptedTypesResultBuilder{ - obj: NewAdapterServiceAdaptedTypesResult(), - } -} - -func (p AdapterServiceAdaptedTypesResultBuilder) Emit() *AdapterServiceAdaptedTypesResult{ - return &AdapterServiceAdaptedTypesResult{ - Success: p.obj.Success, - } -} - -func (a *AdapterServiceAdaptedTypesResultBuilder) Success(success *HeapAllocated) *AdapterServiceAdaptedTypesResultBuilder { - a.obj.Success = success - return a -} - -func (a *AdapterServiceAdaptedTypesResult) SetSuccess(success *HeapAllocated) *AdapterServiceAdaptedTypesResult { - a.Success = success - return a -} - -func (p *AdapterServiceAdaptedTypesResult) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 0: - if err := p.ReadField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AdapterServiceAdaptedTypesResult) ReadField0(iprot thrift.Protocol) error { - p.Success = NewHeapAllocated() - if err := p.Success.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) - } - return nil -} - -func (p *AdapterServiceAdaptedTypesResult) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("adaptedTypes_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField0(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *AdapterServiceAdaptedTypesResult) writeField0(oprot thrift.Protocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := p.Success.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } - } - return err -} - -func (p *AdapterServiceAdaptedTypesResult) String() string { - if p == nil { - return "" - } - - var successVal string - if p.Success == nil { - successVal = "" - } else { - successVal = fmt.Sprintf("%v", p.Success) - } - return fmt.Sprintf("AdapterServiceAdaptedTypesResult({Success:%s})", successVal) -} - - diff --git a/thrift/compiler/test/fixtures/adapter/gen-go/module/constants.go b/thrift/compiler/test/fixtures/adapter/gen-go/module/constants.go deleted file mode 100644 index 5f08f0c9348..00000000000 --- a/thrift/compiler/test/fixtures/adapter/gen-go/module/constants.go +++ /dev/null @@ -1,73 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package module - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -const Var1 = 10 -const Var2 = "20" -var Var3 *MyStruct -const Var4 = 40 -const Var5 = "50" -var Var6 *MyStruct -const Timeout = 42 -const Msg = "hello, world" -var Person *Person2 -const TimeoutNoTransitive = 420 -const MsgNoTransitive = "hello, world 2" -var PersonNoTransitive *Person2 -var TypeAdapted AdaptedBool -var NestedAdapted *MoveOnly -var ContainerOfAdapted []AdaptedByte - -func init() { -Var3 = &MyStruct{ - Field: 30, - SetString: []string{ - "10", "20", }, -} - -Var6 = &MyStruct{ - Field: 60, - SetString: []string{ - "30", "40", }, -} - -Person = &Person2{ - Name: "DefaultName", -} - -PersonNoTransitive = &Person2{ - Name: "DefaultName 2", -} - -TypeAdapted = true - -NestedAdapted = &MoveOnly{ - Ptr: &HeapAllocated{ - }, -} - -ContainerOfAdapted = []AdaptedByte{ - 1, - 2, - 3, -} - -} - diff --git a/thrift/compiler/test/fixtures/adapter/gen-go/module/service.go b/thrift/compiler/test/fixtures/adapter/gen-go/module/service.go deleted file mode 100644 index fc2c6d389d2..00000000000 --- a/thrift/compiler/test/fixtures/adapter/gen-go/module/service.go +++ /dev/null @@ -1,632 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package module - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -type Service interface { - // Parameters: - // - Arg1 - // - Arg2 - // - Arg3 - Func(arg1 string, arg2 string, arg3 *Foo) (_r int32, err error) -} - -type ServiceClientInterface interface { - thrift.ClientInterface - // Parameters: - // - Arg1 - // - Arg2 - // - Arg3 - Func(arg1 string, arg2 string, arg3 *Foo) (_r int32, err error) -} - -type ServiceClient struct { - ServiceClientInterface - CC thrift.ClientConn -} - -func(client *ServiceClient) Open() error { - return client.CC.Open() -} - -func(client *ServiceClient) Close() error { - return client.CC.Close() -} - -func(client *ServiceClient) IsOpen() bool { - return client.CC.IsOpen() -} - -func NewServiceClientFactory(t thrift.Transport, f thrift.ProtocolFactory) *ServiceClient { - return &ServiceClient{ CC: thrift.NewClientConn(t, f) } -} - -func NewServiceClient(t thrift.Transport, iprot thrift.Protocol, oprot thrift.Protocol) *ServiceClient { - return &ServiceClient{ CC: thrift.NewClientConnWithProtocols(t, iprot, oprot) } -} - -func NewServiceClientProtocol(prot thrift.Protocol) *ServiceClient { - return NewServiceClient(prot.Transport(), prot, prot) -} - -// Parameters: -// - Arg1 -// - Arg2 -// - Arg3 -func (p *ServiceClient) Func(arg1 string, arg2 string, arg3 *Foo) (_r int32, err error) { - args := ServiceFuncArgs{ - Arg1 : arg1, - Arg2 : arg2, - Arg3 : arg3, - } - err = p.CC.SendMsg("func", &args, thrift.CALL) - if err != nil { return } - return p.recvFunc() -} - - -func (p *ServiceClient) recvFunc() (value int32, err error) { - var __result ServiceFuncResult - err = p.CC.RecvMsg("func", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - - -type ServiceThreadsafeClient struct { - ServiceClientInterface - CC thrift.ClientConn - Mu sync.Mutex -} - -func(client *ServiceThreadsafeClient) Open() error { - client.Mu.Lock() - defer client.Mu.Unlock() - return client.CC.Open() -} - -func(client *ServiceThreadsafeClient) Close() error { - client.Mu.Lock() - defer client.Mu.Unlock() - return client.CC.Close() -} - -func(client *ServiceThreadsafeClient) IsOpen() bool { - client.Mu.Lock() - defer client.Mu.Unlock() - return client.CC.IsOpen() -} - -func NewServiceThreadsafeClientFactory(t thrift.Transport, f thrift.ProtocolFactory) *ServiceThreadsafeClient { - return &ServiceThreadsafeClient{ CC: thrift.NewClientConn(t, f) } -} - -func NewServiceThreadsafeClient(t thrift.Transport, iprot thrift.Protocol, oprot thrift.Protocol) *ServiceThreadsafeClient { - return &ServiceThreadsafeClient{ CC: thrift.NewClientConnWithProtocols(t, iprot, oprot) } -} - -func NewServiceThreadsafeClientProtocol(prot thrift.Protocol) *ServiceThreadsafeClient { - return NewServiceThreadsafeClient(prot.Transport(), prot, prot) -} - -// Parameters: -// - Arg1 -// - Arg2 -// - Arg3 -func (p *ServiceThreadsafeClient) Func(arg1 string, arg2 string, arg3 *Foo) (_r int32, err error) { - p.Mu.Lock() - defer p.Mu.Unlock() - args := ServiceFuncArgs{ - Arg1 : arg1, - Arg2 : arg2, - Arg3 : arg3, - } - err = p.CC.SendMsg("func", &args, thrift.CALL) - if err != nil { return } - return p.recvFunc() -} - - -func (p *ServiceThreadsafeClient) recvFunc() (value int32, err error) { - var __result ServiceFuncResult - err = p.CC.RecvMsg("func", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - - -type ServiceChannelClient struct { - RequestChannel thrift.RequestChannel -} - -func (c *ServiceChannelClient) Close() error { - return c.RequestChannel.Close() -} - -func (c *ServiceChannelClient) IsOpen() bool { - return c.RequestChannel.IsOpen() -} - -func (c *ServiceChannelClient) Open() error { - return c.RequestChannel.Open() -} - -func NewServiceChannelClient(channel thrift.RequestChannel) *ServiceChannelClient { - return &ServiceChannelClient{RequestChannel: channel} -} - -// Parameters: -// - Arg1 -// - Arg2 -// - Arg3 -func (p *ServiceChannelClient) Func(ctx context.Context, arg1 string, arg2 string, arg3 *Foo) (_r int32, err error) { - args := ServiceFuncArgs{ - Arg1 : arg1, - Arg2 : arg2, - Arg3 : arg3, - } - var __result ServiceFuncResult - err = p.RequestChannel.Call(ctx, "func", &args, &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - - -type ServiceProcessor struct { - processorMap map[string]thrift.ProcessorFunction - functionServiceMap map[string]string - handler Service -} - -func (p *ServiceProcessor) AddToProcessorMap(key string, processor thrift.ProcessorFunction) { - p.processorMap[key] = processor -} - -func (p *ServiceProcessor) AddToFunctionServiceMap(key, service string) { - p.functionServiceMap[key] = service -} - -func (p *ServiceProcessor) GetProcessorFunction(key string) (processor thrift.ProcessorFunction, err error) { - if processor, ok := p.processorMap[key]; ok { - return processor, nil - } - return nil, nil // generic error message will be sent -} - -func (p *ServiceProcessor) ProcessorMap() map[string]thrift.ProcessorFunction { - return p.processorMap -} - -func (p *ServiceProcessor) FunctionServiceMap() map[string]string { - return p.functionServiceMap -} - -func NewServiceProcessor(handler Service) *ServiceProcessor { - self24 := &ServiceProcessor{handler:handler, processorMap:make(map[string]thrift.ProcessorFunction), functionServiceMap:make(map[string]string)} - self24.processorMap["func"] = &serviceProcessorFunc{handler:handler} - self24.functionServiceMap["func"] = "Service" - return self24 -} - -type serviceProcessorFunc struct { - handler Service -} - -func (p *ServiceFuncResult) Exception() thrift.WritableException { - if p == nil { return nil } - return nil -} - -func (p *serviceProcessorFunc) Read(iprot thrift.Protocol) (thrift.Struct, thrift.Exception) { - args := ServiceFuncArgs{} - if err := args.Read(iprot); err != nil { - return nil, err - } - iprot.ReadMessageEnd() - return &args, nil -} - -func (p *serviceProcessorFunc) Write(seqId int32, result thrift.WritableStruct, oprot thrift.Protocol) (err thrift.Exception) { - var err2 error - messageType := thrift.REPLY - switch result.(type) { - case thrift.ApplicationException: - messageType = thrift.EXCEPTION - } - if err2 = oprot.WriteMessageBegin("func", messageType, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - return err -} - -func (p *serviceProcessorFunc) Run(argStruct thrift.Struct) (thrift.WritableStruct, thrift.ApplicationException) { - args := argStruct.(*ServiceFuncArgs) - var __result ServiceFuncResult - if retval, err := p.handler.Func(args.Arg1, args.Arg2, args.Arg3); err != nil { - switch err.(type) { - default: - x := thrift.NewApplicationExceptionCause(thrift.INTERNAL_ERROR, "Internal error processing func: " + err.Error(), err) - return x, x - } - } else { - __result.Success = &retval - } - return &__result, nil -} - - -// HELPER FUNCTIONS AND STRUCTURES - -// Attributes: -// - Arg1 -// - Arg2 -// - Arg3 -type ServiceFuncArgs struct { - thrift.IRequest - Arg1 string `thrift:"arg1,1" db:"arg1" json:"arg1"` - Arg2 string `thrift:"arg2,2" db:"arg2" json:"arg2"` - Arg3 *Foo `thrift:"arg3,3" db:"arg3" json:"arg3"` -} - -func NewServiceFuncArgs() *ServiceFuncArgs { - return &ServiceFuncArgs{ - Arg3: NewFoo(), - } -} - - -func (p *ServiceFuncArgs) GetArg1() string { - return p.Arg1 -} - -func (p *ServiceFuncArgs) GetArg2() string { - return p.Arg2 -} -var ServiceFuncArgs_Arg3_DEFAULT *Foo -func (p *ServiceFuncArgs) GetArg3() *Foo { - if !p.IsSetArg3() { - return ServiceFuncArgs_Arg3_DEFAULT - } - return p.Arg3 -} -func (p *ServiceFuncArgs) DefaultGetArg3() *Foo { - if !p.IsSetArg3() { - return NewFoo() - } - return p.Arg3 -} -func (p *ServiceFuncArgs) IsSetArg3() bool { - return p != nil && p.Arg3 != nil -} - -type ServiceFuncArgsBuilder struct { - obj *ServiceFuncArgs -} - -func NewServiceFuncArgsBuilder() *ServiceFuncArgsBuilder{ - return &ServiceFuncArgsBuilder{ - obj: NewServiceFuncArgs(), - } -} - -func (p ServiceFuncArgsBuilder) Emit() *ServiceFuncArgs{ - return &ServiceFuncArgs{ - Arg1: p.obj.Arg1, - Arg2: p.obj.Arg2, - Arg3: p.obj.Arg3, - } -} - -func (s *ServiceFuncArgsBuilder) Arg1(arg1 string) *ServiceFuncArgsBuilder { - s.obj.Arg1 = arg1 - return s -} - -func (s *ServiceFuncArgsBuilder) Arg2(arg2 string) *ServiceFuncArgsBuilder { - s.obj.Arg2 = arg2 - return s -} - -func (s *ServiceFuncArgsBuilder) Arg3(arg3 *Foo) *ServiceFuncArgsBuilder { - s.obj.Arg3 = arg3 - return s -} - -func (s *ServiceFuncArgs) SetArg1(arg1 string) *ServiceFuncArgs { - s.Arg1 = arg1 - return s -} - -func (s *ServiceFuncArgs) SetArg2(arg2 string) *ServiceFuncArgs { - s.Arg2 = arg2 - return s -} - -func (s *ServiceFuncArgs) SetArg3(arg3 *Foo) *ServiceFuncArgs { - s.Arg3 = arg3 - return s -} - -func (p *ServiceFuncArgs) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 3: - if err := p.ReadField3(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ServiceFuncArgs) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - temp := StringWithAdapter_7208(v) - p.Arg1 = temp - } - return nil -} - -func (p *ServiceFuncArgs) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Arg2 = v - } - return nil -} - -func (p *ServiceFuncArgs) ReadField3(iprot thrift.Protocol) error { - p.Arg3 = NewFoo() - if err := p.Arg3.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Arg3), err) - } - return nil -} - -func (p *ServiceFuncArgs) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("func_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *ServiceFuncArgs) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("arg1", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:arg1: ", p), err) } - if err := oprot.WriteString(string(p.Arg1)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.arg1 (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:arg1: ", p), err) } - return err -} - -func (p *ServiceFuncArgs) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("arg2", thrift.STRING, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:arg2: ", p), err) } - if err := oprot.WriteString(string(p.Arg2)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.arg2 (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:arg2: ", p), err) } - return err -} - -func (p *ServiceFuncArgs) writeField3(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("arg3", thrift.STRUCT, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:arg3: ", p), err) } - if err := p.Arg3.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Arg3), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:arg3: ", p), err) } - return err -} - -func (p *ServiceFuncArgs) String() string { - if p == nil { - return "" - } - - arg1Val := fmt.Sprintf("%v", p.Arg1) - arg2Val := fmt.Sprintf("%v", p.Arg2) - var arg3Val string - if p.Arg3 == nil { - arg3Val = "" - } else { - arg3Val = fmt.Sprintf("%v", p.Arg3) - } - return fmt.Sprintf("ServiceFuncArgs({Arg1:%s Arg2:%s Arg3:%s})", arg1Val, arg2Val, arg3Val) -} - -// Attributes: -// - Success -type ServiceFuncResult struct { - thrift.IResponse - Success *int32 `thrift:"success,0,optional" db:"success" json:"success,omitempty"` -} - -func NewServiceFuncResult() *ServiceFuncResult { - return &ServiceFuncResult{} -} - -var ServiceFuncResult_Success_DEFAULT int32 -func (p *ServiceFuncResult) GetSuccess() int32 { - if !p.IsSetSuccess() { - return ServiceFuncResult_Success_DEFAULT - } - return *p.Success -} -func (p *ServiceFuncResult) IsSetSuccess() bool { - return p != nil && p.Success != nil -} - -type ServiceFuncResultBuilder struct { - obj *ServiceFuncResult -} - -func NewServiceFuncResultBuilder() *ServiceFuncResultBuilder{ - return &ServiceFuncResultBuilder{ - obj: NewServiceFuncResult(), - } -} - -func (p ServiceFuncResultBuilder) Emit() *ServiceFuncResult{ - return &ServiceFuncResult{ - Success: p.obj.Success, - } -} - -func (s *ServiceFuncResultBuilder) Success(success *int32) *ServiceFuncResultBuilder { - s.obj.Success = success - return s -} - -func (s *ServiceFuncResult) SetSuccess(success *int32) *ServiceFuncResult { - s.Success = success - return s -} - -func (p *ServiceFuncResult) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 0: - if err := p.ReadField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ServiceFuncResult) ReadField0(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - temp := MyI32_4873(v) - p.Success = &temp - } - return nil -} - -func (p *ServiceFuncResult) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("func_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField0(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *ServiceFuncResult) writeField0(oprot thrift.Protocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.I32, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := oprot.WriteI32(int32(*p.Success)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.success (0) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } - } - return err -} - -func (p *ServiceFuncResult) String() string { - if p == nil { - return "" - } - - var successVal string - if p.Success == nil { - successVal = "" - } else { - successVal = fmt.Sprintf("%v", *p.Success) - } - return fmt.Sprintf("ServiceFuncResult({Success:%s})", successVal) -} - - diff --git a/thrift/compiler/test/fixtures/adapter/gen-go/module/ttypes.go b/thrift/compiler/test/fixtures/adapter/gen-go/module/ttypes.go deleted file mode 100644 index 01a1041222b..00000000000 --- a/thrift/compiler/test/fixtures/adapter/gen-go/module/ttypes.go +++ /dev/null @@ -1,7369 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package module - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var GoUnusedProtection__ int; - -type Color int64 -const ( - Color_UNKNOWN Color = 0 - Color_RED Color = 1 - Color_GREEN Color = 2 - Color_BLUE Color = 3 -) - -var ColorToName = map[Color]string { - Color_UNKNOWN: "UNKNOWN", - Color_RED: "RED", - Color_GREEN: "GREEN", - Color_BLUE: "BLUE", -} - -var ColorToValue = map[string]Color { - "UNKNOWN": Color_UNKNOWN, - "RED": Color_RED, - "GREEN": Color_GREEN, - "BLUE": Color_BLUE, -} - -var ColorNames = []string { - "UNKNOWN", - "RED", - "GREEN", - "BLUE", -} - -var ColorValues = []Color { - Color_UNKNOWN, - Color_RED, - Color_GREEN, - Color_BLUE, -} - -func (p Color) String() string { - if v, ok := ColorToName[p]; ok { - return v - } - return "" -} - -func ColorFromString(s string) (Color, error) { - if v, ok := ColorToValue[s]; ok { - return v, nil - } - return Color(0), fmt.Errorf("not a valid Color string") -} - -func ColorPtr(v Color) *Color { return &v } - -type ThriftAdaptedEnum int64 -const ( - ThriftAdaptedEnum_Zero ThriftAdaptedEnum = 0 - ThriftAdaptedEnum_One ThriftAdaptedEnum = 1 -) - -var ThriftAdaptedEnumToName = map[ThriftAdaptedEnum]string { - ThriftAdaptedEnum_Zero: "Zero", - ThriftAdaptedEnum_One: "One", -} - -var ThriftAdaptedEnumToValue = map[string]ThriftAdaptedEnum { - "Zero": ThriftAdaptedEnum_Zero, - "One": ThriftAdaptedEnum_One, -} - -var ThriftAdaptedEnumNames = []string { - "Zero", - "One", -} - -var ThriftAdaptedEnumValues = []ThriftAdaptedEnum { - ThriftAdaptedEnum_Zero, - ThriftAdaptedEnum_One, -} - -func (p ThriftAdaptedEnum) String() string { - if v, ok := ThriftAdaptedEnumToName[p]; ok { - return v - } - return "" -} - -func ThriftAdaptedEnumFromString(s string) (ThriftAdaptedEnum, error) { - if v, ok := ThriftAdaptedEnumToValue[s]; ok { - return v, nil - } - return ThriftAdaptedEnum(0), fmt.Errorf("not a valid ThriftAdaptedEnum string") -} - -func ThriftAdaptedEnumPtr(v ThriftAdaptedEnum) *ThriftAdaptedEnum { return &v } - -type SetWithAdapter = []string - -func SetWithAdapterPtr(v SetWithAdapter) *SetWithAdapter { return &v } - -type StringWithAdapter = string - -func StringWithAdapterPtr(v StringWithAdapter) *StringWithAdapter { return &v } - -type ListWithElemAdapter = []StringWithAdapter - -func ListWithElemAdapterPtr(v ListWithElemAdapter) *ListWithElemAdapter { return &v } - -type ListWithElemAdapterWithAdapter = ListWithElemAdapter - -func ListWithElemAdapterWithAdapterPtr(v ListWithElemAdapterWithAdapter) *ListWithElemAdapterWithAdapter { return &v } - -type MyI64 = int64 - -func MyI64Ptr(v MyI64) *MyI64 { return &v } - -type DoubleTypedefI64 = MyI64 - -func DoubleTypedefI64Ptr(v DoubleTypedefI64) *DoubleTypedefI64 { return &v } - -type MyI32 = int32 - -func MyI32Ptr(v MyI32) *MyI32 { return &v } - -type FooWithAdapter = Foo - -func FooWithAdapterPtr(v FooWithAdapter) *FooWithAdapter { return &v } - -func NewFooWithAdapter() *FooWithAdapter { return NewFoo() } - -type StructWithAdapter = *Bar - -func StructWithAdapterPtr(v StructWithAdapter) *StructWithAdapter { return &v } - -func NewStructWithAdapter() StructWithAdapter { return NewBar() } - -type UnionWithAdapter = *Baz - -func UnionWithAdapterPtr(v UnionWithAdapter) *UnionWithAdapter { return &v } - -func NewUnionWithAdapter() UnionWithAdapter { return NewBaz() } - -type AdaptedA = A - -func AdaptedAPtr(v AdaptedA) *AdaptedA { return &v } - -func NewAdaptedA() *AdaptedA { return NewA() } - -type DurationMs = int64 - -func DurationMsPtr(v DurationMs) *DurationMs { return &v } - -type AdaptedBool = bool - -func AdaptedBoolPtr(v AdaptedBool) *AdaptedBool { return &v } - -type AdaptedByte = int8 - -func AdaptedBytePtr(v AdaptedByte) *AdaptedByte { return &v } - -type AdaptedShort = int16 - -func AdaptedShortPtr(v AdaptedShort) *AdaptedShort { return &v } - -type AdaptedInteger = int32 - -func AdaptedIntegerPtr(v AdaptedInteger) *AdaptedInteger { return &v } - -type AdaptedLong = int64 - -func AdaptedLongPtr(v AdaptedLong) *AdaptedLong { return &v } - -type AdaptedDouble = float64 - -func AdaptedDoublePtr(v AdaptedDouble) *AdaptedDouble { return &v } - -type AdaptedString = string - -func AdaptedStringPtr(v AdaptedString) *AdaptedString { return &v } - -type DoubleTypedefBool = AdaptedBool - -func DoubleTypedefBoolPtr(v DoubleTypedefBool) *DoubleTypedefBool { return &v } - -type IOBuf = []byte - -func IOBufPtr(v IOBuf) *IOBuf { return &v } - -type CustomProtocolType = IOBuf - -func CustomProtocolTypePtr(v CustomProtocolType) *CustomProtocolType { return &v } - -type IndirectionString = string - -func IndirectionStringPtr(v IndirectionString) *IndirectionString { return &v } - -type AdaptedEnum = ThriftAdaptedEnum - -func AdaptedEnumPtr(v AdaptedEnum) *AdaptedEnum { return &v } - -type AdaptedTypedef = AdaptedStruct - -func AdaptedTypedefPtr(v AdaptedTypedef) *AdaptedTypedef { return &v } - -func NewAdaptedTypedef() *AdaptedTypedef { return NewAdaptedStruct() } - -type TypedefOfDirect = DirectlyAdaptedStruct - -func TypedefOfDirectPtr(v TypedefOfDirect) *TypedefOfDirect { return &v } - -func NewTypedefOfDirect() *TypedefOfDirect { return NewDirectlyAdaptedStruct() } - -type AdaptedCircularAdaptee = CircularAdaptee - -func AdaptedCircularAdapteePtr(v AdaptedCircularAdaptee) *AdaptedCircularAdaptee { return &v } - -func NewAdaptedCircularAdaptee() *AdaptedCircularAdaptee { return NewCircularAdaptee() } - -type CountingInt = int64 - -func CountingIntPtr(v CountingInt) *CountingInt { return &v } - -type FooWithAdapter_9317 = *FooWithAdapter - -func FooWithAdapter_9317Ptr(v FooWithAdapter_9317) *FooWithAdapter_9317 { return &v } - -func NewFooWithAdapter_9317() FooWithAdapter_9317 { return NewFooWithAdapter() } - -type ListWithElemAdapterWithAdapter_2312 = ListWithElemAdapterWithAdapter - -func ListWithElemAdapterWithAdapter_2312Ptr(v ListWithElemAdapterWithAdapter_2312) *ListWithElemAdapterWithAdapter_2312 { return &v } - -type MyI32_4873 = MyI32 - -func MyI32_4873Ptr(v MyI32_4873) *MyI32_4873 { return &v } - -type StringWithAdapter_7208 = StringWithAdapter - -func StringWithAdapter_7208Ptr(v StringWithAdapter_7208) *StringWithAdapter_7208 { return &v } - -type Baz_7352 = *Baz - -func Baz_7352Ptr(v Baz_7352) *Baz_7352 { return &v } - -func NewBaz_7352() Baz_7352 { return NewBaz() } - -type Foo_3943 = *Foo - -func Foo_3943Ptr(v Foo_3943) *Foo_3943 { return &v } - -func NewFoo_3943() Foo_3943 { return NewFoo() } - -type Foo_6868 = *Foo - -func Foo_6868Ptr(v Foo_6868) *Foo_6868 { return &v } - -func NewFoo_6868() Foo_6868 { return NewFoo() } - -type Binary_5673 = []byte - -func Binary_5673Ptr(v Binary_5673) *Binary_5673 { return &v } - -type I32_5137 = int32 - -func I32_5137Ptr(v I32_5137) *I32_5137 { return &v } - -type MapString_ListWithElemAdapterWithAdapter_8454 = map[string]ListWithElemAdapterWithAdapter_2312 - -func MapString_ListWithElemAdapterWithAdapter_8454Ptr(v MapString_ListWithElemAdapterWithAdapter_8454) *MapString_ListWithElemAdapterWithAdapter_8454 { return &v } - -// Attributes: -// - Signature -// - Color -type MyAnnotation struct { - Signature string `thrift:"signature,1" db:"signature" json:"signature"` - Color Color `thrift:"color,2" db:"color" json:"color"` -} - -func NewMyAnnotation() *MyAnnotation { - return &MyAnnotation{ - Color: 1, - } -} - - -func (p *MyAnnotation) GetSignature() string { - return p.Signature -} - -func (p *MyAnnotation) GetColor() Color { - return p.Color -} -type MyAnnotationBuilder struct { - obj *MyAnnotation -} - -func NewMyAnnotationBuilder() *MyAnnotationBuilder{ - return &MyAnnotationBuilder{ - obj: NewMyAnnotation(), - } -} - -func (p MyAnnotationBuilder) Emit() *MyAnnotation{ - return &MyAnnotation{ - Signature: p.obj.Signature, - Color: p.obj.Color, - } -} - -func (m *MyAnnotationBuilder) Signature(signature string) *MyAnnotationBuilder { - m.obj.Signature = signature - return m -} - -func (m *MyAnnotationBuilder) Color(color Color) *MyAnnotationBuilder { - m.obj.Color = color - return m -} - -func (m *MyAnnotation) SetSignature(signature string) *MyAnnotation { - m.Signature = signature - return m -} - -func (m *MyAnnotation) SetColor(color Color) *MyAnnotation { - m.Color = color - return m -} - -func (p *MyAnnotation) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyAnnotation) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Signature = v - } - return nil -} - -func (p *MyAnnotation) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - temp := Color(v) - p.Color = temp - } - return nil -} - -func (p *MyAnnotation) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("MyAnnotation"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyAnnotation) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("signature", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:signature: ", p), err) } - if err := oprot.WriteString(string(p.Signature)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.signature (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:signature: ", p), err) } - return err -} - -func (p *MyAnnotation) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("color", thrift.I32, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:color: ", p), err) } - if err := oprot.WriteI32(int32(p.Color)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.color (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:color: ", p), err) } - return err -} - -func (p *MyAnnotation) String() string { - if p == nil { - return "" - } - - signatureVal := fmt.Sprintf("%v", p.Signature) - colorVal := fmt.Sprintf("%v", p.Color) - return fmt.Sprintf("MyAnnotation({Signature:%s Color:%s})", signatureVal, colorVal) -} - -// Attributes: -// - IntField -// - OptionalIntField -// - IntFieldWithDefault -// - SetField -// - OptionalSetField -// - MapField -// - OptionalMapField -// - BinaryField -// - LongField -// - AdaptedLongField -// - DoubleAdaptedField -type Foo struct { - IntField int32 `thrift:"intField,1" db:"intField" json:"intField"` - OptionalIntField *int32 `thrift:"optionalIntField,2,optional" db:"optionalIntField" json:"optionalIntField,omitempty"` - IntFieldWithDefault int32 `thrift:"intFieldWithDefault,3" db:"intFieldWithDefault" json:"intFieldWithDefault"` - SetField SetWithAdapter `thrift:"setField,4" db:"setField" json:"setField"` - OptionalSetField SetWithAdapter `thrift:"optionalSetField,5,optional" db:"optionalSetField" json:"optionalSetField,omitempty"` - MapField map[string]ListWithElemAdapterWithAdapter_2312 `thrift:"mapField,6" db:"mapField" json:"mapField"` - OptionalMapField map[string]ListWithElemAdapterWithAdapter_2312 `thrift:"optionalMapField,7,optional" db:"optionalMapField" json:"optionalMapField,omitempty"` - BinaryField []byte `thrift:"binaryField,8" db:"binaryField" json:"binaryField"` - LongField MyI64 `thrift:"longField,9" db:"longField" json:"longField"` - AdaptedLongField MyI64 `thrift:"adaptedLongField,10" db:"adaptedLongField" json:"adaptedLongField"` - DoubleAdaptedField DoubleTypedefI64 `thrift:"doubleAdaptedField,11" db:"doubleAdaptedField" json:"doubleAdaptedField"` -} - -func NewFoo() *Foo { - return &Foo{ - IntFieldWithDefault: 13, - } -} - - -func (p *Foo) GetIntField() int32 { - return p.IntField -} -var Foo_OptionalIntField_DEFAULT int32 -func (p *Foo) GetOptionalIntField() int32 { - if !p.IsSetOptionalIntField() { - return Foo_OptionalIntField_DEFAULT - } - return *p.OptionalIntField -} - -func (p *Foo) GetIntFieldWithDefault() int32 { - return p.IntFieldWithDefault -} - -func (p *Foo) GetSetField() SetWithAdapter { - return p.SetField -} -var Foo_OptionalSetField_DEFAULT SetWithAdapter - -func (p *Foo) GetOptionalSetField() SetWithAdapter { - return p.OptionalSetField -} - -func (p *Foo) GetMapField() map[string]ListWithElemAdapterWithAdapter_2312 { - return p.MapField -} -var Foo_OptionalMapField_DEFAULT map[string]ListWithElemAdapterWithAdapter_2312 - -func (p *Foo) GetOptionalMapField() map[string]ListWithElemAdapterWithAdapter_2312 { - return p.OptionalMapField -} - -func (p *Foo) GetBinaryField() []byte { - return p.BinaryField -} - -func (p *Foo) GetLongField() MyI64 { - return p.LongField -} - -func (p *Foo) GetAdaptedLongField() MyI64 { - return p.AdaptedLongField -} - -func (p *Foo) GetDoubleAdaptedField() DoubleTypedefI64 { - return p.DoubleAdaptedField -} -func (p *Foo) IsSetOptionalIntField() bool { - return p != nil && p.OptionalIntField != nil -} - -func (p *Foo) IsSetOptionalSetField() bool { - return p != nil && p.OptionalSetField != nil -} - -func (p *Foo) IsSetOptionalMapField() bool { - return p != nil && p.OptionalMapField != nil -} - -type FooBuilder struct { - obj *Foo -} - -func NewFooBuilder() *FooBuilder{ - return &FooBuilder{ - obj: NewFoo(), - } -} - -func (p FooBuilder) Emit() *Foo{ - return &Foo{ - IntField: p.obj.IntField, - OptionalIntField: p.obj.OptionalIntField, - IntFieldWithDefault: p.obj.IntFieldWithDefault, - SetField: p.obj.SetField, - OptionalSetField: p.obj.OptionalSetField, - MapField: p.obj.MapField, - OptionalMapField: p.obj.OptionalMapField, - BinaryField: p.obj.BinaryField, - LongField: p.obj.LongField, - AdaptedLongField: p.obj.AdaptedLongField, - DoubleAdaptedField: p.obj.DoubleAdaptedField, - } -} - -func (f *FooBuilder) IntField(intField int32) *FooBuilder { - f.obj.IntField = intField - return f -} - -func (f *FooBuilder) OptionalIntField(optionalIntField *int32) *FooBuilder { - f.obj.OptionalIntField = optionalIntField - return f -} - -func (f *FooBuilder) IntFieldWithDefault(intFieldWithDefault int32) *FooBuilder { - f.obj.IntFieldWithDefault = intFieldWithDefault - return f -} - -func (f *FooBuilder) SetField(setField SetWithAdapter) *FooBuilder { - f.obj.SetField = setField - return f -} - -func (f *FooBuilder) OptionalSetField(optionalSetField SetWithAdapter) *FooBuilder { - f.obj.OptionalSetField = optionalSetField - return f -} - -func (f *FooBuilder) MapField(mapField map[string]ListWithElemAdapterWithAdapter_2312) *FooBuilder { - f.obj.MapField = mapField - return f -} - -func (f *FooBuilder) OptionalMapField(optionalMapField map[string]ListWithElemAdapterWithAdapter_2312) *FooBuilder { - f.obj.OptionalMapField = optionalMapField - return f -} - -func (f *FooBuilder) BinaryField(binaryField []byte) *FooBuilder { - f.obj.BinaryField = binaryField - return f -} - -func (f *FooBuilder) LongField(longField MyI64) *FooBuilder { - f.obj.LongField = longField - return f -} - -func (f *FooBuilder) AdaptedLongField(adaptedLongField MyI64) *FooBuilder { - f.obj.AdaptedLongField = adaptedLongField - return f -} - -func (f *FooBuilder) DoubleAdaptedField(doubleAdaptedField DoubleTypedefI64) *FooBuilder { - f.obj.DoubleAdaptedField = doubleAdaptedField - return f -} - -func (f *Foo) SetIntField(intField int32) *Foo { - f.IntField = intField - return f -} - -func (f *Foo) SetOptionalIntField(optionalIntField *int32) *Foo { - f.OptionalIntField = optionalIntField - return f -} - -func (f *Foo) SetIntFieldWithDefault(intFieldWithDefault int32) *Foo { - f.IntFieldWithDefault = intFieldWithDefault - return f -} - -func (f *Foo) SetSetField(setField SetWithAdapter) *Foo { - f.SetField = setField - return f -} - -func (f *Foo) SetOptionalSetField(optionalSetField SetWithAdapter) *Foo { - f.OptionalSetField = optionalSetField - return f -} - -func (f *Foo) SetMapField(mapField map[string]ListWithElemAdapterWithAdapter_2312) *Foo { - f.MapField = mapField - return f -} - -func (f *Foo) SetOptionalMapField(optionalMapField map[string]ListWithElemAdapterWithAdapter_2312) *Foo { - f.OptionalMapField = optionalMapField - return f -} - -func (f *Foo) SetBinaryField(binaryField []byte) *Foo { - f.BinaryField = binaryField - return f -} - -func (f *Foo) SetLongField(longField MyI64) *Foo { - f.LongField = longField - return f -} - -func (f *Foo) SetAdaptedLongField(adaptedLongField MyI64) *Foo { - f.AdaptedLongField = adaptedLongField - return f -} - -func (f *Foo) SetDoubleAdaptedField(doubleAdaptedField DoubleTypedefI64) *Foo { - f.DoubleAdaptedField = doubleAdaptedField - return f -} - -func (p *Foo) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 3: - if err := p.ReadField3(iprot); err != nil { - return err - } - case 4: - if err := p.ReadField4(iprot); err != nil { - return err - } - case 5: - if err := p.ReadField5(iprot); err != nil { - return err - } - case 6: - if err := p.ReadField6(iprot); err != nil { - return err - } - case 7: - if err := p.ReadField7(iprot); err != nil { - return err - } - case 8: - if err := p.ReadField8(iprot); err != nil { - return err - } - case 9: - if err := p.ReadField9(iprot); err != nil { - return err - } - case 10: - if err := p.ReadField10(iprot); err != nil { - return err - } - case 11: - if err := p.ReadField11(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Foo) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - temp := I32_5137(v) - p.IntField = temp - } - return nil -} - -func (p *Foo) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - temp := I32_5137(v) - p.OptionalIntField = &temp - } - return nil -} - -func (p *Foo) ReadField3(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 3: ", err) - } else { - temp := I32_5137(v) - p.IntFieldWithDefault = temp - } - return nil -} - -func (p *Foo) ReadField4(iprot thrift.Protocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return thrift.PrependError("error reading set begin: ", err) - } - tSet := make(SetWithAdapter, 0, size) - p.SetField = tSet - for i := 0; i < size; i ++ { - var _elem0 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem0 = v - } - p.SetField = append(p.SetField, _elem0) - } - if err := iprot.ReadSetEnd(); err != nil { - return thrift.PrependError("error reading set end: ", err) - } - return nil -} - -func (p *Foo) ReadField5(iprot thrift.Protocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return thrift.PrependError("error reading set begin: ", err) - } - tSet := make(SetWithAdapter, 0, size) - p.OptionalSetField = tSet - for i := 0; i < size; i ++ { - var _elem1 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem1 = v - } - p.OptionalSetField = append(p.OptionalSetField, _elem1) - } - if err := iprot.ReadSetEnd(); err != nil { - return thrift.PrependError("error reading set end: ", err) - } - return nil -} - -func (p *Foo) ReadField6(iprot thrift.Protocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[string]ListWithElemAdapterWithAdapter_2312, size) - p.MapField = tMap - for i := 0; i < size; i ++ { - var _key2 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key2 = v - } - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make(ListWithElemAdapterWithAdapter_2312, 0, size) - _val3 := tSlice - for i := 0; i < size; i ++ { - var _elem4 StringWithAdapter - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - temp := StringWithAdapter(v) - _elem4 = temp - } - _val3 = append(_val3, _elem4) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - p.MapField[_key2] = _val3 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *Foo) ReadField7(iprot thrift.Protocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[string]ListWithElemAdapterWithAdapter_2312, size) - p.OptionalMapField = tMap - for i := 0; i < size; i ++ { - var _key5 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key5 = v - } - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make(ListWithElemAdapterWithAdapter_2312, 0, size) - _val6 := tSlice - for i := 0; i < size; i ++ { - var _elem7 StringWithAdapter - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - temp := StringWithAdapter(v) - _elem7 = temp - } - _val6 = append(_val6, _elem7) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - p.OptionalMapField[_key5] = _val6 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *Foo) ReadField8(iprot thrift.Protocol) error { - if v, err := iprot.ReadBinary(); err != nil { - return thrift.PrependError("error reading field 8: ", err) - } else { - temp := Binary_5673(v) - p.BinaryField = temp - } - return nil -} - -func (p *Foo) ReadField9(iprot thrift.Protocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 9: ", err) - } else { - temp := MyI64(v) - p.LongField = temp - } - return nil -} - -func (p *Foo) ReadField10(iprot thrift.Protocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 10: ", err) - } else { - temp := MyI64(v) - p.AdaptedLongField = temp - } - return nil -} - -func (p *Foo) ReadField11(iprot thrift.Protocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 11: ", err) - } else { - temp := DoubleTypedefI64(v) - p.DoubleAdaptedField = temp - } - return nil -} - -func (p *Foo) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Foo"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := p.writeField4(oprot); err != nil { return err } - if err := p.writeField5(oprot); err != nil { return err } - if err := p.writeField6(oprot); err != nil { return err } - if err := p.writeField7(oprot); err != nil { return err } - if err := p.writeField8(oprot); err != nil { return err } - if err := p.writeField9(oprot); err != nil { return err } - if err := p.writeField10(oprot); err != nil { return err } - if err := p.writeField11(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Foo) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("intField", thrift.I32, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:intField: ", p), err) } - if err := oprot.WriteI32(int32(p.IntField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.intField (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:intField: ", p), err) } - return err -} - -func (p *Foo) writeField2(oprot thrift.Protocol) (err error) { - if p.IsSetOptionalIntField() { - if err := oprot.WriteFieldBegin("optionalIntField", thrift.I32, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:optionalIntField: ", p), err) } - if err := oprot.WriteI32(int32(*p.OptionalIntField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.optionalIntField (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:optionalIntField: ", p), err) } - } - return err -} - -func (p *Foo) writeField3(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("intFieldWithDefault", thrift.I32, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:intFieldWithDefault: ", p), err) } - if err := oprot.WriteI32(int32(p.IntFieldWithDefault)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.intFieldWithDefault (3) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:intFieldWithDefault: ", p), err) } - return err -} - -func (p *Foo) writeField4(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("setField", thrift.SET, 4); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:setField: ", p), err) } - if err := oprot.WriteSetBegin(thrift.STRING, len(p.SetField)); err != nil { - return thrift.PrependError("error writing set begin: ", err) - } - set := make(map[string]bool, len(p.SetField)) - for _, v := range p.SetField { - if ok := set[v]; ok { - return thrift.PrependError("", fmt.Errorf("%T error writing set field: slice is not unique", v)) - } - set[v] = true - } - for _, v := range p.SetField { - if err := oprot.WriteString(string(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteSetEnd(); err != nil { - return thrift.PrependError("error writing set end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 4:setField: ", p), err) } - return err -} - -func (p *Foo) writeField5(oprot thrift.Protocol) (err error) { - if p.IsSetOptionalSetField() { - if err := oprot.WriteFieldBegin("optionalSetField", thrift.SET, 5); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:optionalSetField: ", p), err) } - if err := oprot.WriteSetBegin(thrift.STRING, len(p.OptionalSetField)); err != nil { - return thrift.PrependError("error writing set begin: ", err) - } - set := make(map[string]bool, len(p.OptionalSetField)) - for _, v := range p.OptionalSetField { - if ok := set[v]; ok { - return thrift.PrependError("", fmt.Errorf("%T error writing set field: slice is not unique", v)) - } - set[v] = true - } - for _, v := range p.OptionalSetField { - if err := oprot.WriteString(string(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteSetEnd(); err != nil { - return thrift.PrependError("error writing set end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 5:optionalSetField: ", p), err) } - } - return err -} - -func (p *Foo) writeField6(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("mapField", thrift.MAP, 6); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 6:mapField: ", p), err) } - if err := oprot.WriteMapBegin(thrift.STRING, thrift.LIST, len(p.MapField)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.MapField { - if err := oprot.WriteString(string(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := oprot.WriteListBegin(thrift.STRING, len(v)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range v { - if err := oprot.WriteString(string(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 6:mapField: ", p), err) } - return err -} - -func (p *Foo) writeField7(oprot thrift.Protocol) (err error) { - if p.IsSetOptionalMapField() { - if err := oprot.WriteFieldBegin("optionalMapField", thrift.MAP, 7); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 7:optionalMapField: ", p), err) } - if err := oprot.WriteMapBegin(thrift.STRING, thrift.LIST, len(p.OptionalMapField)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.OptionalMapField { - if err := oprot.WriteString(string(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := oprot.WriteListBegin(thrift.STRING, len(v)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range v { - if err := oprot.WriteString(string(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 7:optionalMapField: ", p), err) } - } - return err -} - -func (p *Foo) writeField8(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("binaryField", thrift.STRING, 8); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 8:binaryField: ", p), err) } - if err := oprot.WriteBinary(p.BinaryField); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.binaryField (8) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 8:binaryField: ", p), err) } - return err -} - -func (p *Foo) writeField9(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("longField", thrift.I64, 9); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 9:longField: ", p), err) } - if err := oprot.WriteI64(int64(p.LongField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.longField (9) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 9:longField: ", p), err) } - return err -} - -func (p *Foo) writeField10(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("adaptedLongField", thrift.I64, 10); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 10:adaptedLongField: ", p), err) } - if err := oprot.WriteI64(int64(p.AdaptedLongField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.adaptedLongField (10) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 10:adaptedLongField: ", p), err) } - return err -} - -func (p *Foo) writeField11(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("doubleAdaptedField", thrift.I64, 11); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 11:doubleAdaptedField: ", p), err) } - if err := oprot.WriteI64(int64(p.DoubleAdaptedField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.doubleAdaptedField (11) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 11:doubleAdaptedField: ", p), err) } - return err -} - -func (p *Foo) String() string { - if p == nil { - return "" - } - - intFieldVal := fmt.Sprintf("%v", p.IntField) - var optionalIntFieldVal string - if p.OptionalIntField == nil { - optionalIntFieldVal = "" - } else { - optionalIntFieldVal = fmt.Sprintf("%v", *p.OptionalIntField) - } - intFieldWithDefaultVal := fmt.Sprintf("%v", p.IntFieldWithDefault) - setFieldVal := fmt.Sprintf("%v", p.SetField) - optionalSetFieldVal := fmt.Sprintf("%v", p.OptionalSetField) - mapFieldVal := fmt.Sprintf("%v", p.MapField) - optionalMapFieldVal := fmt.Sprintf("%v", p.OptionalMapField) - binaryFieldVal := fmt.Sprintf("%v", p.BinaryField) - longFieldVal := fmt.Sprintf("%v", p.LongField) - adaptedLongFieldVal := fmt.Sprintf("%v", p.AdaptedLongField) - doubleAdaptedFieldVal := fmt.Sprintf("%v", p.DoubleAdaptedField) - return fmt.Sprintf("Foo({IntField:%s OptionalIntField:%s IntFieldWithDefault:%s SetField:%s OptionalSetField:%s MapField:%s OptionalMapField:%s BinaryField:%s LongField:%s AdaptedLongField:%s DoubleAdaptedField:%s})", intFieldVal, optionalIntFieldVal, intFieldWithDefaultVal, setFieldVal, optionalSetFieldVal, mapFieldVal, optionalMapFieldVal, binaryFieldVal, longFieldVal, adaptedLongFieldVal, doubleAdaptedFieldVal) -} - -// Attributes: -// - IntField -// - SetField -// - MapField -// - BinaryField -// - LongField -type Baz struct { - IntField *int32 `thrift:"intField,1,optional" db:"intField" json:"intField,omitempty"` - // unused fields # 2 to 3 - SetField SetWithAdapter `thrift:"setField,4,optional" db:"setField" json:"setField,omitempty"` - // unused field # 5 - MapField map[string]ListWithElemAdapterWithAdapter_2312 `thrift:"mapField,6,optional" db:"mapField" json:"mapField,omitempty"` - // unused field # 7 - BinaryField []byte `thrift:"binaryField,8,optional" db:"binaryField" json:"binaryField,omitempty"` - LongField *MyI64 `thrift:"longField,9,optional" db:"longField" json:"longField,omitempty"` -} - -func NewBaz() *Baz { - return &Baz{} -} - -var Baz_IntField_DEFAULT int32 -func (p *Baz) GetIntField() int32 { - if !p.IsSetIntField() { - return Baz_IntField_DEFAULT - } - return *p.IntField -} -var Baz_SetField_DEFAULT SetWithAdapter - -func (p *Baz) GetSetField() SetWithAdapter { - return p.SetField -} -var Baz_MapField_DEFAULT map[string]ListWithElemAdapterWithAdapter_2312 - -func (p *Baz) GetMapField() map[string]ListWithElemAdapterWithAdapter_2312 { - return p.MapField -} -var Baz_BinaryField_DEFAULT []byte - -func (p *Baz) GetBinaryField() []byte { - return p.BinaryField -} -var Baz_LongField_DEFAULT MyI64 -func (p *Baz) GetLongField() MyI64 { - if !p.IsSetLongField() { - return Baz_LongField_DEFAULT - } - return *p.LongField -} -func (p *Baz) CountSetFieldsBaz() int { - count := 0 - if (p.IsSetIntField()) { - count++ - } - if (p.IsSetSetField()) { - count++ - } - if (p.IsSetMapField()) { - count++ - } - if (p.IsSetBinaryField()) { - count++ - } - if (p.IsSetLongField()) { - count++ - } - return count - -} - -func (p *Baz) IsSetIntField() bool { - return p != nil && p.IntField != nil -} - -func (p *Baz) IsSetSetField() bool { - return p != nil && p.SetField != nil -} - -func (p *Baz) IsSetMapField() bool { - return p != nil && p.MapField != nil -} - -func (p *Baz) IsSetBinaryField() bool { - return p != nil && p.BinaryField != nil -} - -func (p *Baz) IsSetLongField() bool { - return p != nil && p.LongField != nil -} - -type BazBuilder struct { - obj *Baz -} - -func NewBazBuilder() *BazBuilder{ - return &BazBuilder{ - obj: NewBaz(), - } -} - -func (p BazBuilder) Emit() *Baz{ - return &Baz{ - IntField: p.obj.IntField, - SetField: p.obj.SetField, - MapField: p.obj.MapField, - BinaryField: p.obj.BinaryField, - LongField: p.obj.LongField, - } -} - -func (b *BazBuilder) IntField(intField *int32) *BazBuilder { - b.obj.IntField = intField - return b -} - -func (b *BazBuilder) SetField(setField SetWithAdapter) *BazBuilder { - b.obj.SetField = setField - return b -} - -func (b *BazBuilder) MapField(mapField map[string]ListWithElemAdapterWithAdapter_2312) *BazBuilder { - b.obj.MapField = mapField - return b -} - -func (b *BazBuilder) BinaryField(binaryField []byte) *BazBuilder { - b.obj.BinaryField = binaryField - return b -} - -func (b *BazBuilder) LongField(longField *MyI64) *BazBuilder { - b.obj.LongField = longField - return b -} - -func (b *Baz) SetIntField(intField *int32) *Baz { - b.IntField = intField - return b -} - -func (b *Baz) SetSetField(setField SetWithAdapter) *Baz { - b.SetField = setField - return b -} - -func (b *Baz) SetMapField(mapField map[string]ListWithElemAdapterWithAdapter_2312) *Baz { - b.MapField = mapField - return b -} - -func (b *Baz) SetBinaryField(binaryField []byte) *Baz { - b.BinaryField = binaryField - return b -} - -func (b *Baz) SetLongField(longField *MyI64) *Baz { - b.LongField = longField - return b -} - -func (p *Baz) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 4: - if err := p.ReadField4(iprot); err != nil { - return err - } - case 6: - if err := p.ReadField6(iprot); err != nil { - return err - } - case 8: - if err := p.ReadField8(iprot); err != nil { - return err - } - case 9: - if err := p.ReadField9(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Baz) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - temp := I32_5137(v) - p.IntField = &temp - } - return nil -} - -func (p *Baz) ReadField4(iprot thrift.Protocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return thrift.PrependError("error reading set begin: ", err) - } - tSet := make(SetWithAdapter, 0, size) - p.SetField = tSet - for i := 0; i < size; i ++ { - var _elem8 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem8 = v - } - p.SetField = append(p.SetField, _elem8) - } - if err := iprot.ReadSetEnd(); err != nil { - return thrift.PrependError("error reading set end: ", err) - } - return nil -} - -func (p *Baz) ReadField6(iprot thrift.Protocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[string]ListWithElemAdapterWithAdapter_2312, size) - p.MapField = tMap - for i := 0; i < size; i ++ { - var _key9 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key9 = v - } - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make(ListWithElemAdapterWithAdapter_2312, 0, size) - _val10 := tSlice - for i := 0; i < size; i ++ { - var _elem11 StringWithAdapter - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - temp := StringWithAdapter(v) - _elem11 = temp - } - _val10 = append(_val10, _elem11) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - p.MapField[_key9] = _val10 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *Baz) ReadField8(iprot thrift.Protocol) error { - if v, err := iprot.ReadBinary(); err != nil { - return thrift.PrependError("error reading field 8: ", err) - } else { - temp := Binary_5673(v) - p.BinaryField = temp - } - return nil -} - -func (p *Baz) ReadField9(iprot thrift.Protocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 9: ", err) - } else { - temp := MyI64(v) - p.LongField = &temp - } - return nil -} - -func (p *Baz) Write(oprot thrift.Protocol) error { - if c := p.CountSetFieldsBaz(); c > 1 { - return fmt.Errorf("%T write union: no more than one field must be set (%d set).", p, c) - } - if err := oprot.WriteStructBegin("Baz"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField4(oprot); err != nil { return err } - if err := p.writeField6(oprot); err != nil { return err } - if err := p.writeField8(oprot); err != nil { return err } - if err := p.writeField9(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Baz) writeField1(oprot thrift.Protocol) (err error) { - if p.IsSetIntField() { - if err := oprot.WriteFieldBegin("intField", thrift.I32, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:intField: ", p), err) } - if err := oprot.WriteI32(int32(*p.IntField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.intField (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:intField: ", p), err) } - } - return err -} - -func (p *Baz) writeField4(oprot thrift.Protocol) (err error) { - if p.IsSetSetField() { - if err := oprot.WriteFieldBegin("setField", thrift.SET, 4); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:setField: ", p), err) } - if err := oprot.WriteSetBegin(thrift.STRING, len(p.SetField)); err != nil { - return thrift.PrependError("error writing set begin: ", err) - } - set := make(map[string]bool, len(p.SetField)) - for _, v := range p.SetField { - if ok := set[v]; ok { - return thrift.PrependError("", fmt.Errorf("%T error writing set field: slice is not unique", v)) - } - set[v] = true - } - for _, v := range p.SetField { - if err := oprot.WriteString(string(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteSetEnd(); err != nil { - return thrift.PrependError("error writing set end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 4:setField: ", p), err) } - } - return err -} - -func (p *Baz) writeField6(oprot thrift.Protocol) (err error) { - if p.IsSetMapField() { - if err := oprot.WriteFieldBegin("mapField", thrift.MAP, 6); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 6:mapField: ", p), err) } - if err := oprot.WriteMapBegin(thrift.STRING, thrift.LIST, len(p.MapField)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.MapField { - if err := oprot.WriteString(string(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := oprot.WriteListBegin(thrift.STRING, len(v)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range v { - if err := oprot.WriteString(string(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 6:mapField: ", p), err) } - } - return err -} - -func (p *Baz) writeField8(oprot thrift.Protocol) (err error) { - if p.IsSetBinaryField() { - if err := oprot.WriteFieldBegin("binaryField", thrift.STRING, 8); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 8:binaryField: ", p), err) } - if err := oprot.WriteBinary(p.BinaryField); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.binaryField (8) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 8:binaryField: ", p), err) } - } - return err -} - -func (p *Baz) writeField9(oprot thrift.Protocol) (err error) { - if p.IsSetLongField() { - if err := oprot.WriteFieldBegin("longField", thrift.I64, 9); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 9:longField: ", p), err) } - if err := oprot.WriteI64(int64(*p.LongField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.longField (9) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 9:longField: ", p), err) } - } - return err -} - -func (p *Baz) String() string { - if p == nil { - return "" - } - - var intFieldVal string - if p.IntField == nil { - intFieldVal = "" - } else { - intFieldVal = fmt.Sprintf("%v", *p.IntField) - } - setFieldVal := fmt.Sprintf("%v", p.SetField) - mapFieldVal := fmt.Sprintf("%v", p.MapField) - binaryFieldVal := fmt.Sprintf("%v", p.BinaryField) - var longFieldVal string - if p.LongField == nil { - longFieldVal = "" - } else { - longFieldVal = fmt.Sprintf("%v", *p.LongField) - } - return fmt.Sprintf("Baz({IntField:%s SetField:%s MapField:%s BinaryField:%s LongField:%s})", intFieldVal, setFieldVal, mapFieldVal, binaryFieldVal, longFieldVal) -} - -// Attributes: -// - StructField -// - OptionalStructField -// - StructListField -// - OptionalStructListField -// - UnionField -// - OptionalUnionField -// - AdaptedStructField -type Bar struct { - StructField *Foo `thrift:"structField,1" db:"structField" json:"structField"` - OptionalStructField *Foo `thrift:"optionalStructField,2,optional" db:"optionalStructField" json:"optionalStructField,omitempty"` - StructListField []*Foo `thrift:"structListField,3" db:"structListField" json:"structListField"` - OptionalStructListField []*Foo `thrift:"optionalStructListField,4,optional" db:"optionalStructListField" json:"optionalStructListField,omitempty"` - UnionField *Baz `thrift:"unionField,5" db:"unionField" json:"unionField"` - OptionalUnionField *Baz `thrift:"optionalUnionField,6,optional" db:"optionalUnionField" json:"optionalUnionField,omitempty"` - AdaptedStructField *DirectlyAdapted `thrift:"adaptedStructField,7" db:"adaptedStructField" json:"adaptedStructField"` -} - -func NewBar() *Bar { - return &Bar{ - StructField: NewFoo_6868(), - AdaptedStructField: NewDirectlyAdapted(), - } -} - -var Bar_StructField_DEFAULT *Foo -func (p *Bar) GetStructField() *Foo { - if !p.IsSetStructField() { - return Bar_StructField_DEFAULT - } - return p.StructField -} -var Bar_OptionalStructField_DEFAULT *Foo -func (p *Bar) GetOptionalStructField() *Foo { - if !p.IsSetOptionalStructField() { - return Bar_OptionalStructField_DEFAULT - } - return p.OptionalStructField -} - -func (p *Bar) GetStructListField() []*Foo { - return p.StructListField -} -var Bar_OptionalStructListField_DEFAULT []*Foo - -func (p *Bar) GetOptionalStructListField() []*Foo { - return p.OptionalStructListField -} -var Bar_UnionField_DEFAULT *Baz -func (p *Bar) GetUnionField() *Baz { - if !p.IsSetUnionField() { - return Bar_UnionField_DEFAULT - } - return p.UnionField -} -var Bar_OptionalUnionField_DEFAULT *Baz -func (p *Bar) GetOptionalUnionField() *Baz { - if !p.IsSetOptionalUnionField() { - return Bar_OptionalUnionField_DEFAULT - } - return p.OptionalUnionField -} -var Bar_AdaptedStructField_DEFAULT *DirectlyAdapted -func (p *Bar) GetAdaptedStructField() *DirectlyAdapted { - if !p.IsSetAdaptedStructField() { - return Bar_AdaptedStructField_DEFAULT - } - return p.AdaptedStructField -} -func (p *Bar) IsSetStructField() bool { - return p != nil && p.StructField != nil -} - -func (p *Bar) IsSetOptionalStructField() bool { - return p != nil && p.OptionalStructField != nil -} - -func (p *Bar) IsSetOptionalStructListField() bool { - return p != nil && p.OptionalStructListField != nil -} - -func (p *Bar) IsSetUnionField() bool { - return p != nil && p.UnionField != nil -} - -func (p *Bar) IsSetOptionalUnionField() bool { - return p != nil && p.OptionalUnionField != nil -} - -func (p *Bar) IsSetAdaptedStructField() bool { - return p != nil && p.AdaptedStructField != nil -} - -type BarBuilder struct { - obj *Bar -} - -func NewBarBuilder() *BarBuilder{ - return &BarBuilder{ - obj: NewBar(), - } -} - -func (p BarBuilder) Emit() *Bar{ - return &Bar{ - StructField: p.obj.StructField, - OptionalStructField: p.obj.OptionalStructField, - StructListField: p.obj.StructListField, - OptionalStructListField: p.obj.OptionalStructListField, - UnionField: p.obj.UnionField, - OptionalUnionField: p.obj.OptionalUnionField, - AdaptedStructField: p.obj.AdaptedStructField, - } -} - -func (b *BarBuilder) StructField(structField *Foo) *BarBuilder { - b.obj.StructField = structField - return b -} - -func (b *BarBuilder) OptionalStructField(optionalStructField *Foo) *BarBuilder { - b.obj.OptionalStructField = optionalStructField - return b -} - -func (b *BarBuilder) StructListField(structListField []*Foo) *BarBuilder { - b.obj.StructListField = structListField - return b -} - -func (b *BarBuilder) OptionalStructListField(optionalStructListField []*Foo) *BarBuilder { - b.obj.OptionalStructListField = optionalStructListField - return b -} - -func (b *BarBuilder) UnionField(unionField *Baz) *BarBuilder { - b.obj.UnionField = unionField - return b -} - -func (b *BarBuilder) OptionalUnionField(optionalUnionField *Baz) *BarBuilder { - b.obj.OptionalUnionField = optionalUnionField - return b -} - -func (b *BarBuilder) AdaptedStructField(adaptedStructField *DirectlyAdapted) *BarBuilder { - b.obj.AdaptedStructField = adaptedStructField - return b -} - -func (b *Bar) SetStructField(structField *Foo) *Bar { - b.StructField = structField - return b -} - -func (b *Bar) SetOptionalStructField(optionalStructField *Foo) *Bar { - b.OptionalStructField = optionalStructField - return b -} - -func (b *Bar) SetStructListField(structListField []*Foo) *Bar { - b.StructListField = structListField - return b -} - -func (b *Bar) SetOptionalStructListField(optionalStructListField []*Foo) *Bar { - b.OptionalStructListField = optionalStructListField - return b -} - -func (b *Bar) SetUnionField(unionField *Baz) *Bar { - b.UnionField = unionField - return b -} - -func (b *Bar) SetOptionalUnionField(optionalUnionField *Baz) *Bar { - b.OptionalUnionField = optionalUnionField - return b -} - -func (b *Bar) SetAdaptedStructField(adaptedStructField *DirectlyAdapted) *Bar { - b.AdaptedStructField = adaptedStructField - return b -} - -func (p *Bar) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 3: - if err := p.ReadField3(iprot); err != nil { - return err - } - case 4: - if err := p.ReadField4(iprot); err != nil { - return err - } - case 5: - if err := p.ReadField5(iprot); err != nil { - return err - } - case 6: - if err := p.ReadField6(iprot); err != nil { - return err - } - case 7: - if err := p.ReadField7(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Bar) ReadField1(iprot thrift.Protocol) error { - p.StructField = NewFoo_6868() - if err := p.StructField.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.StructField), err) - } - return nil -} - -func (p *Bar) ReadField2(iprot thrift.Protocol) error { - p.OptionalStructField = NewFoo_3943() - if err := p.OptionalStructField.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.OptionalStructField), err) - } - return nil -} - -func (p *Bar) ReadField3(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]*Foo, 0, size) - p.StructListField = tSlice - for i := 0; i < size; i ++ { - _elem12 := NewFooWithAdapter_9317() - if err := _elem12.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem12), err) - } - p.StructListField = append(p.StructListField, _elem12) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *Bar) ReadField4(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]*Foo, 0, size) - p.OptionalStructListField = tSlice - for i := 0; i < size; i ++ { - _elem13 := NewFooWithAdapter_9317() - if err := _elem13.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem13), err) - } - p.OptionalStructListField = append(p.OptionalStructListField, _elem13) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *Bar) ReadField5(iprot thrift.Protocol) error { - p.UnionField = NewBaz_7352() - if err := p.UnionField.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.UnionField), err) - } - return nil -} - -func (p *Bar) ReadField6(iprot thrift.Protocol) error { - p.OptionalUnionField = NewBaz_7352() - if err := p.OptionalUnionField.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.OptionalUnionField), err) - } - return nil -} - -func (p *Bar) ReadField7(iprot thrift.Protocol) error { - p.AdaptedStructField = NewDirectlyAdapted() - if err := p.AdaptedStructField.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.AdaptedStructField), err) - } - return nil -} - -func (p *Bar) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Bar"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := p.writeField4(oprot); err != nil { return err } - if err := p.writeField5(oprot); err != nil { return err } - if err := p.writeField6(oprot); err != nil { return err } - if err := p.writeField7(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Bar) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("structField", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:structField: ", p), err) } - if err := p.StructField.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.StructField), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:structField: ", p), err) } - return err -} - -func (p *Bar) writeField2(oprot thrift.Protocol) (err error) { - if p.IsSetOptionalStructField() { - if err := oprot.WriteFieldBegin("optionalStructField", thrift.STRUCT, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:optionalStructField: ", p), err) } - if err := p.OptionalStructField.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.OptionalStructField), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:optionalStructField: ", p), err) } - } - return err -} - -func (p *Bar) writeField3(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("structListField", thrift.LIST, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:structListField: ", p), err) } - if err := oprot.WriteListBegin(thrift.STRUCT, len(p.StructListField)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.StructListField { - if err := v.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) - } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:structListField: ", p), err) } - return err -} - -func (p *Bar) writeField4(oprot thrift.Protocol) (err error) { - if p.IsSetOptionalStructListField() { - if err := oprot.WriteFieldBegin("optionalStructListField", thrift.LIST, 4); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:optionalStructListField: ", p), err) } - if err := oprot.WriteListBegin(thrift.STRUCT, len(p.OptionalStructListField)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.OptionalStructListField { - if err := v.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) - } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 4:optionalStructListField: ", p), err) } - } - return err -} - -func (p *Bar) writeField5(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("unionField", thrift.STRUCT, 5); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:unionField: ", p), err) } - if err := p.UnionField.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.UnionField), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 5:unionField: ", p), err) } - return err -} - -func (p *Bar) writeField6(oprot thrift.Protocol) (err error) { - if p.IsSetOptionalUnionField() { - if err := oprot.WriteFieldBegin("optionalUnionField", thrift.STRUCT, 6); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 6:optionalUnionField: ", p), err) } - if err := p.OptionalUnionField.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.OptionalUnionField), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 6:optionalUnionField: ", p), err) } - } - return err -} - -func (p *Bar) writeField7(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("adaptedStructField", thrift.STRUCT, 7); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 7:adaptedStructField: ", p), err) } - if err := p.AdaptedStructField.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.AdaptedStructField), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 7:adaptedStructField: ", p), err) } - return err -} - -func (p *Bar) String() string { - if p == nil { - return "" - } - - var structFieldVal string - if p.StructField == nil { - structFieldVal = "" - } else { - structFieldVal = fmt.Sprintf("%v", p.StructField) - } - var optionalStructFieldVal string - if p.OptionalStructField == nil { - optionalStructFieldVal = "" - } else { - optionalStructFieldVal = fmt.Sprintf("%v", p.OptionalStructField) - } - structListFieldVal := fmt.Sprintf("%v", p.StructListField) - optionalStructListFieldVal := fmt.Sprintf("%v", p.OptionalStructListField) - var unionFieldVal string - if p.UnionField == nil { - unionFieldVal = "" - } else { - unionFieldVal = fmt.Sprintf("%v", p.UnionField) - } - var optionalUnionFieldVal string - if p.OptionalUnionField == nil { - optionalUnionFieldVal = "" - } else { - optionalUnionFieldVal = fmt.Sprintf("%v", p.OptionalUnionField) - } - var adaptedStructFieldVal string - if p.AdaptedStructField == nil { - adaptedStructFieldVal = "" - } else { - adaptedStructFieldVal = fmt.Sprintf("%v", p.AdaptedStructField) - } - return fmt.Sprintf("Bar({StructField:%s OptionalStructField:%s StructListField:%s OptionalStructListField:%s UnionField:%s OptionalUnionField:%s AdaptedStructField:%s})", structFieldVal, optionalStructFieldVal, structListFieldVal, optionalStructListFieldVal, unionFieldVal, optionalUnionFieldVal, adaptedStructFieldVal) -} - -// Attributes: -// - Field -type DirectlyAdapted struct { - Field int32 `thrift:"field,1" db:"field" json:"field"` -} - -func NewDirectlyAdapted() *DirectlyAdapted { - return &DirectlyAdapted{} -} - - -func (p *DirectlyAdapted) GetField() int32 { - return p.Field -} -type DirectlyAdaptedBuilder struct { - obj *DirectlyAdapted -} - -func NewDirectlyAdaptedBuilder() *DirectlyAdaptedBuilder{ - return &DirectlyAdaptedBuilder{ - obj: NewDirectlyAdapted(), - } -} - -func (p DirectlyAdaptedBuilder) Emit() *DirectlyAdapted{ - return &DirectlyAdapted{ - Field: p.obj.Field, - } -} - -func (d *DirectlyAdaptedBuilder) Field(field int32) *DirectlyAdaptedBuilder { - d.obj.Field = field - return d -} - -func (d *DirectlyAdapted) SetField(field int32) *DirectlyAdapted { - d.Field = field - return d -} - -func (p *DirectlyAdapted) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *DirectlyAdapted) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Field = v - } - return nil -} - -func (p *DirectlyAdapted) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("DirectlyAdapted"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *DirectlyAdapted) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("field", thrift.I32, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:field: ", p), err) } - if err := oprot.WriteI32(int32(p.Field)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.field (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:field: ", p), err) } - return err -} - -func (p *DirectlyAdapted) String() string { - if p == nil { - return "" - } - - fieldVal := fmt.Sprintf("%v", p.Field) - return fmt.Sprintf("DirectlyAdapted({Field:%s})", fieldVal) -} - -// Attributes: -// - Field -type IndependentDirectlyAdapted struct { - Field int32 `thrift:"field,1" db:"field" json:"field"` -} - -func NewIndependentDirectlyAdapted() *IndependentDirectlyAdapted { - return &IndependentDirectlyAdapted{} -} - - -func (p *IndependentDirectlyAdapted) GetField() int32 { - return p.Field -} -type IndependentDirectlyAdaptedBuilder struct { - obj *IndependentDirectlyAdapted -} - -func NewIndependentDirectlyAdaptedBuilder() *IndependentDirectlyAdaptedBuilder{ - return &IndependentDirectlyAdaptedBuilder{ - obj: NewIndependentDirectlyAdapted(), - } -} - -func (p IndependentDirectlyAdaptedBuilder) Emit() *IndependentDirectlyAdapted{ - return &IndependentDirectlyAdapted{ - Field: p.obj.Field, - } -} - -func (i *IndependentDirectlyAdaptedBuilder) Field(field int32) *IndependentDirectlyAdaptedBuilder { - i.obj.Field = field - return i -} - -func (i *IndependentDirectlyAdapted) SetField(field int32) *IndependentDirectlyAdapted { - i.Field = field - return i -} - -func (p *IndependentDirectlyAdapted) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *IndependentDirectlyAdapted) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Field = v - } - return nil -} - -func (p *IndependentDirectlyAdapted) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("IndependentDirectlyAdapted"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *IndependentDirectlyAdapted) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("field", thrift.I32, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:field: ", p), err) } - if err := oprot.WriteI32(int32(p.Field)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.field (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:field: ", p), err) } - return err -} - -func (p *IndependentDirectlyAdapted) String() string { - if p == nil { - return "" - } - - fieldVal := fmt.Sprintf("%v", p.Field) - return fmt.Sprintf("IndependentDirectlyAdapted({Field:%s})", fieldVal) -} - -// Attributes: -// - Field -// - SharedField -// - OptSharedField -// - OptBoxedField -type StructWithFieldAdapter struct { - Field int32 `thrift:"field,1" db:"field" json:"field"` - SharedField *int32 `thrift:"shared_field,2" db:"shared_field" json:"shared_field"` - OptSharedField *int32 `thrift:"opt_shared_field,3,optional" db:"opt_shared_field" json:"opt_shared_field,omitempty"` - OptBoxedField *int32 `thrift:"opt_boxed_field,4,optional" db:"opt_boxed_field" json:"opt_boxed_field,omitempty"` -} - -func NewStructWithFieldAdapter() *StructWithFieldAdapter { - return &StructWithFieldAdapter{} -} - - -func (p *StructWithFieldAdapter) GetField() int32 { - return p.Field -} -var StructWithFieldAdapter_SharedField_DEFAULT int32 -func (p *StructWithFieldAdapter) GetSharedField() int32 { - if !p.IsSetSharedField() { - return StructWithFieldAdapter_SharedField_DEFAULT - } - return *p.SharedField -} -var StructWithFieldAdapter_OptSharedField_DEFAULT int32 -func (p *StructWithFieldAdapter) GetOptSharedField() int32 { - if !p.IsSetOptSharedField() { - return StructWithFieldAdapter_OptSharedField_DEFAULT - } - return *p.OptSharedField -} -var StructWithFieldAdapter_OptBoxedField_DEFAULT int32 -func (p *StructWithFieldAdapter) GetOptBoxedField() int32 { - if !p.IsSetOptBoxedField() { - return StructWithFieldAdapter_OptBoxedField_DEFAULT - } - return *p.OptBoxedField -} -func (p *StructWithFieldAdapter) IsSetSharedField() bool { - return p != nil && p.SharedField != nil -} - -func (p *StructWithFieldAdapter) IsSetOptSharedField() bool { - return p != nil && p.OptSharedField != nil -} - -func (p *StructWithFieldAdapter) IsSetOptBoxedField() bool { - return p != nil && p.OptBoxedField != nil -} - -type StructWithFieldAdapterBuilder struct { - obj *StructWithFieldAdapter -} - -func NewStructWithFieldAdapterBuilder() *StructWithFieldAdapterBuilder{ - return &StructWithFieldAdapterBuilder{ - obj: NewStructWithFieldAdapter(), - } -} - -func (p StructWithFieldAdapterBuilder) Emit() *StructWithFieldAdapter{ - return &StructWithFieldAdapter{ - Field: p.obj.Field, - SharedField: p.obj.SharedField, - OptSharedField: p.obj.OptSharedField, - OptBoxedField: p.obj.OptBoxedField, - } -} - -func (s *StructWithFieldAdapterBuilder) Field(field int32) *StructWithFieldAdapterBuilder { - s.obj.Field = field - return s -} - -func (s *StructWithFieldAdapterBuilder) SharedField(sharedField *int32) *StructWithFieldAdapterBuilder { - s.obj.SharedField = sharedField - return s -} - -func (s *StructWithFieldAdapterBuilder) OptSharedField(optSharedField *int32) *StructWithFieldAdapterBuilder { - s.obj.OptSharedField = optSharedField - return s -} - -func (s *StructWithFieldAdapterBuilder) OptBoxedField(optBoxedField *int32) *StructWithFieldAdapterBuilder { - s.obj.OptBoxedField = optBoxedField - return s -} - -func (s *StructWithFieldAdapter) SetField(field int32) *StructWithFieldAdapter { - s.Field = field - return s -} - -func (s *StructWithFieldAdapter) SetSharedField(sharedField *int32) *StructWithFieldAdapter { - s.SharedField = sharedField - return s -} - -func (s *StructWithFieldAdapter) SetOptSharedField(optSharedField *int32) *StructWithFieldAdapter { - s.OptSharedField = optSharedField - return s -} - -func (s *StructWithFieldAdapter) SetOptBoxedField(optBoxedField *int32) *StructWithFieldAdapter { - s.OptBoxedField = optBoxedField - return s -} - -func (p *StructWithFieldAdapter) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 3: - if err := p.ReadField3(iprot); err != nil { - return err - } - case 4: - if err := p.ReadField4(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *StructWithFieldAdapter) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Field = v - } - return nil -} - -func (p *StructWithFieldAdapter) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.SharedField = &v - } - return nil -} - -func (p *StructWithFieldAdapter) ReadField3(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 3: ", err) - } else { - p.OptSharedField = &v - } - return nil -} - -func (p *StructWithFieldAdapter) ReadField4(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 4: ", err) - } else { - p.OptBoxedField = &v - } - return nil -} - -func (p *StructWithFieldAdapter) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("StructWithFieldAdapter"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := p.writeField4(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *StructWithFieldAdapter) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("field", thrift.I32, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:field: ", p), err) } - if err := oprot.WriteI32(int32(p.Field)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.field (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:field: ", p), err) } - return err -} - -func (p *StructWithFieldAdapter) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("shared_field", thrift.I32, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:shared_field: ", p), err) } - if err := oprot.WriteI32(int32(*p.SharedField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.shared_field (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:shared_field: ", p), err) } - return err -} - -func (p *StructWithFieldAdapter) writeField3(oprot thrift.Protocol) (err error) { - if p.IsSetOptSharedField() { - if err := oprot.WriteFieldBegin("opt_shared_field", thrift.I32, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:opt_shared_field: ", p), err) } - if err := oprot.WriteI32(int32(*p.OptSharedField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.opt_shared_field (3) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:opt_shared_field: ", p), err) } - } - return err -} - -func (p *StructWithFieldAdapter) writeField4(oprot thrift.Protocol) (err error) { - if p.IsSetOptBoxedField() { - if err := oprot.WriteFieldBegin("opt_boxed_field", thrift.I32, 4); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:opt_boxed_field: ", p), err) } - if err := oprot.WriteI32(int32(*p.OptBoxedField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.opt_boxed_field (4) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 4:opt_boxed_field: ", p), err) } - } - return err -} - -func (p *StructWithFieldAdapter) String() string { - if p == nil { - return "" - } - - fieldVal := fmt.Sprintf("%v", p.Field) - var sharedFieldVal string - if p.SharedField == nil { - sharedFieldVal = "" - } else { - sharedFieldVal = fmt.Sprintf("%v", *p.SharedField) - } - var optSharedFieldVal string - if p.OptSharedField == nil { - optSharedFieldVal = "" - } else { - optSharedFieldVal = fmt.Sprintf("%v", *p.OptSharedField) - } - var optBoxedFieldVal string - if p.OptBoxedField == nil { - optBoxedFieldVal = "" - } else { - optBoxedFieldVal = fmt.Sprintf("%v", *p.OptBoxedField) - } - return fmt.Sprintf("StructWithFieldAdapter({Field:%s SharedField:%s OptSharedField:%s OptBoxedField:%s})", fieldVal, sharedFieldVal, optSharedFieldVal, optBoxedFieldVal) -} - -// Attributes: -// - IntField -// - StringField -// - SetField -type TerseAdaptedFields struct { - IntField int32 `thrift:"int_field,1" db:"int_field" json:"int_field"` - StringField string `thrift:"string_field,2" db:"string_field" json:"string_field"` - SetField []int32 `thrift:"set_field,3" db:"set_field" json:"set_field"` -} - -func NewTerseAdaptedFields() *TerseAdaptedFields { - return &TerseAdaptedFields{} -} - - -func (p *TerseAdaptedFields) GetIntField() int32 { - return p.IntField -} - -func (p *TerseAdaptedFields) GetStringField() string { - return p.StringField -} - -func (p *TerseAdaptedFields) GetSetField() []int32 { - return p.SetField -} -type TerseAdaptedFieldsBuilder struct { - obj *TerseAdaptedFields -} - -func NewTerseAdaptedFieldsBuilder() *TerseAdaptedFieldsBuilder{ - return &TerseAdaptedFieldsBuilder{ - obj: NewTerseAdaptedFields(), - } -} - -func (p TerseAdaptedFieldsBuilder) Emit() *TerseAdaptedFields{ - return &TerseAdaptedFields{ - IntField: p.obj.IntField, - StringField: p.obj.StringField, - SetField: p.obj.SetField, - } -} - -func (t *TerseAdaptedFieldsBuilder) IntField(intField int32) *TerseAdaptedFieldsBuilder { - t.obj.IntField = intField - return t -} - -func (t *TerseAdaptedFieldsBuilder) StringField(stringField string) *TerseAdaptedFieldsBuilder { - t.obj.StringField = stringField - return t -} - -func (t *TerseAdaptedFieldsBuilder) SetField(setField []int32) *TerseAdaptedFieldsBuilder { - t.obj.SetField = setField - return t -} - -func (t *TerseAdaptedFields) SetIntField(intField int32) *TerseAdaptedFields { - t.IntField = intField - return t -} - -func (t *TerseAdaptedFields) SetStringField(stringField string) *TerseAdaptedFields { - t.StringField = stringField - return t -} - -func (t *TerseAdaptedFields) SetSetField(setField []int32) *TerseAdaptedFields { - t.SetField = setField - return t -} - -func (p *TerseAdaptedFields) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 3: - if err := p.ReadField3(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *TerseAdaptedFields) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.IntField = v - } - return nil -} - -func (p *TerseAdaptedFields) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.StringField = v - } - return nil -} - -func (p *TerseAdaptedFields) ReadField3(iprot thrift.Protocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return thrift.PrependError("error reading set begin: ", err) - } - tSet := make([]int32, 0, size) - p.SetField = tSet - for i := 0; i < size; i ++ { - var _elem14 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem14 = v - } - p.SetField = append(p.SetField, _elem14) - } - if err := iprot.ReadSetEnd(); err != nil { - return thrift.PrependError("error reading set end: ", err) - } - return nil -} - -func (p *TerseAdaptedFields) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("TerseAdaptedFields"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *TerseAdaptedFields) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("int_field", thrift.I32, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:int_field: ", p), err) } - if err := oprot.WriteI32(int32(p.IntField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.int_field (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:int_field: ", p), err) } - return err -} - -func (p *TerseAdaptedFields) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("string_field", thrift.STRING, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:string_field: ", p), err) } - if err := oprot.WriteString(string(p.StringField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.string_field (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:string_field: ", p), err) } - return err -} - -func (p *TerseAdaptedFields) writeField3(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("set_field", thrift.SET, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:set_field: ", p), err) } - if err := oprot.WriteSetBegin(thrift.I32, len(p.SetField)); err != nil { - return thrift.PrependError("error writing set begin: ", err) - } - set := make(map[int32]bool, len(p.SetField)) - for _, v := range p.SetField { - if ok := set[v]; ok { - return thrift.PrependError("", fmt.Errorf("%T error writing set field: slice is not unique", v)) - } - set[v] = true - } - for _, v := range p.SetField { - if err := oprot.WriteI32(int32(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteSetEnd(); err != nil { - return thrift.PrependError("error writing set end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:set_field: ", p), err) } - return err -} - -func (p *TerseAdaptedFields) String() string { - if p == nil { - return "" - } - - intFieldVal := fmt.Sprintf("%v", p.IntField) - stringFieldVal := fmt.Sprintf("%v", p.StringField) - setFieldVal := fmt.Sprintf("%v", p.SetField) - return fmt.Sprintf("TerseAdaptedFields({IntField:%s StringField:%s SetField:%s})", intFieldVal, stringFieldVal, setFieldVal) -} - -// Attributes: -// - A -type B struct { - A *A `thrift:"a,1" db:"a" json:"a"` -} - -func NewB() *B { - return &B{ - A: NewAdaptedA(), - } -} - -var B_A_DEFAULT *A -func (p *B) GetA() *A { - if !p.IsSetA() { - return B_A_DEFAULT - } - return p.A -} -func (p *B) IsSetA() bool { - return p != nil && p.A != nil -} - -type BBuilder struct { - obj *B -} - -func NewBBuilder() *BBuilder{ - return &BBuilder{ - obj: NewB(), - } -} - -func (p BBuilder) Emit() *B{ - return &B{ - A: p.obj.A, - } -} - -func (b *BBuilder) A(a *A) *BBuilder { - b.obj.A = a - return b -} - -func (b *B) SetA(a *A) *B { - b.A = a - return b -} - -func (p *B) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *B) ReadField1(iprot thrift.Protocol) error { - p.A = NewAdaptedA() - if err := p.A.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.A), err) - } - return nil -} - -func (p *B) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("B"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *B) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("a", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:a: ", p), err) } - if err := p.A.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.A), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:a: ", p), err) } - return err -} - -func (p *B) String() string { - if p == nil { - return "" - } - - var aVal string - if p.A == nil { - aVal = "" - } else { - aVal = fmt.Sprintf("%v", p.A) - } - return fmt.Sprintf("B({A:%s})", aVal) -} - -type A struct { -} - -func NewA() *A { - return &A{} -} - -type ABuilder struct { - obj *A -} - -func NewABuilder() *ABuilder{ - return &ABuilder{ - obj: NewA(), - } -} - -func (p ABuilder) Emit() *A{ - return &A{ - } -} - -func (p *A) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *A) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("A"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *A) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("A({})") -} - -// Attributes: -// - Path -type Config struct { - Path string `thrift:"path,1" db:"path" json:"path"` -} - -func NewConfig() *Config { - return &Config{} -} - - -func (p *Config) GetPath() string { - return p.Path -} -type ConfigBuilder struct { - obj *Config -} - -func NewConfigBuilder() *ConfigBuilder{ - return &ConfigBuilder{ - obj: NewConfig(), - } -} - -func (p ConfigBuilder) Emit() *Config{ - return &Config{ - Path: p.obj.Path, - } -} - -func (c *ConfigBuilder) Path(path string) *ConfigBuilder { - c.obj.Path = path - return c -} - -func (c *Config) SetPath(path string) *Config { - c.Path = path - return c -} - -func (p *Config) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Config) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Path = v - } - return nil -} - -func (p *Config) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Config"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Config) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("path", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:path: ", p), err) } - if err := oprot.WriteString(string(p.Path)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.path (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:path: ", p), err) } - return err -} - -func (p *Config) String() string { - if p == nil { - return "" - } - - pathVal := fmt.Sprintf("%v", p.Path) - return fmt.Sprintf("Config({Path:%s})", pathVal) -} - -// Attributes: -// - Field -// - SetString -type MyStruct struct { - Field int32 `thrift:"field,1" db:"field" json:"field"` - SetString SetWithAdapter `thrift:"set_string,2" db:"set_string" json:"set_string"` -} - -func NewMyStruct() *MyStruct { - return &MyStruct{} -} - - -func (p *MyStruct) GetField() int32 { - return p.Field -} - -func (p *MyStruct) GetSetString() SetWithAdapter { - return p.SetString -} -type MyStructBuilder struct { - obj *MyStruct -} - -func NewMyStructBuilder() *MyStructBuilder{ - return &MyStructBuilder{ - obj: NewMyStruct(), - } -} - -func (p MyStructBuilder) Emit() *MyStruct{ - return &MyStruct{ - Field: p.obj.Field, - SetString: p.obj.SetString, - } -} - -func (m *MyStructBuilder) Field(field int32) *MyStructBuilder { - m.obj.Field = field - return m -} - -func (m *MyStructBuilder) SetString(setString SetWithAdapter) *MyStructBuilder { - m.obj.SetString = setString - return m -} - -func (m *MyStruct) SetField(field int32) *MyStruct { - m.Field = field - return m -} - -func (m *MyStruct) SetSetString(setString SetWithAdapter) *MyStruct { - m.SetString = setString - return m -} - -func (p *MyStruct) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyStruct) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Field = v - } - return nil -} - -func (p *MyStruct) ReadField2(iprot thrift.Protocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return thrift.PrependError("error reading set begin: ", err) - } - tSet := make(SetWithAdapter, 0, size) - p.SetString = tSet - for i := 0; i < size; i ++ { - var _elem15 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem15 = v - } - p.SetString = append(p.SetString, _elem15) - } - if err := iprot.ReadSetEnd(); err != nil { - return thrift.PrependError("error reading set end: ", err) - } - return nil -} - -func (p *MyStruct) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("MyStruct"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyStruct) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("field", thrift.I32, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:field: ", p), err) } - if err := oprot.WriteI32(int32(p.Field)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.field (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:field: ", p), err) } - return err -} - -func (p *MyStruct) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("set_string", thrift.SET, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:set_string: ", p), err) } - if err := oprot.WriteSetBegin(thrift.STRING, len(p.SetString)); err != nil { - return thrift.PrependError("error writing set begin: ", err) - } - set := make(map[string]bool, len(p.SetString)) - for _, v := range p.SetString { - if ok := set[v]; ok { - return thrift.PrependError("", fmt.Errorf("%T error writing set field: slice is not unique", v)) - } - set[v] = true - } - for _, v := range p.SetString { - if err := oprot.WriteString(string(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteSetEnd(); err != nil { - return thrift.PrependError("error writing set end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:set_string: ", p), err) } - return err -} - -func (p *MyStruct) String() string { - if p == nil { - return "" - } - - fieldVal := fmt.Sprintf("%v", p.Field) - setStringVal := fmt.Sprintf("%v", p.SetString) - return fmt.Sprintf("MyStruct({Field:%s SetString:%s})", fieldVal, setStringVal) -} - -// Attributes: -// - Delay -// - Custom -// - Timeout -// - Data -// - Meta -// - IndirectionString -// - StringData -// - DoubleWrappedBool -// - DoubleWrappedInteger -// - BinaryData -type AdaptTestStruct struct { - Delay DurationMs `thrift:"delay,1" db:"delay" json:"delay"` - Custom CustomProtocolType `thrift:"custom,2" db:"custom" json:"custom"` - Timeout int64 `thrift:"timeout,3" db:"timeout" json:"timeout"` - Data int64 `thrift:"data,4" db:"data" json:"data"` - Meta string `thrift:"meta,5" db:"meta" json:"meta"` - IndirectionString IndirectionString `thrift:"indirectionString,6" db:"indirectionString" json:"indirectionString"` - StringData string `thrift:"string_data,7" db:"string_data" json:"string_data"` - DoubleWrappedBool AdaptedBool `thrift:"double_wrapped_bool,8" db:"double_wrapped_bool" json:"double_wrapped_bool"` - DoubleWrappedInteger AdaptedInteger `thrift:"double_wrapped_integer,9" db:"double_wrapped_integer" json:"double_wrapped_integer"` - BinaryData []byte `thrift:"binary_data,10" db:"binary_data" json:"binary_data"` -} - -func NewAdaptTestStruct() *AdaptTestStruct { - return &AdaptTestStruct{} -} - - -func (p *AdaptTestStruct) GetDelay() DurationMs { - return p.Delay -} - -func (p *AdaptTestStruct) GetCustom() CustomProtocolType { - return p.Custom -} - -func (p *AdaptTestStruct) GetTimeout() int64 { - return p.Timeout -} - -func (p *AdaptTestStruct) GetData() int64 { - return p.Data -} - -func (p *AdaptTestStruct) GetMeta() string { - return p.Meta -} - -func (p *AdaptTestStruct) GetIndirectionString() IndirectionString { - return p.IndirectionString -} - -func (p *AdaptTestStruct) GetStringData() string { - return p.StringData -} - -func (p *AdaptTestStruct) GetDoubleWrappedBool() AdaptedBool { - return p.DoubleWrappedBool -} - -func (p *AdaptTestStruct) GetDoubleWrappedInteger() AdaptedInteger { - return p.DoubleWrappedInteger -} - -func (p *AdaptTestStruct) GetBinaryData() []byte { - return p.BinaryData -} -type AdaptTestStructBuilder struct { - obj *AdaptTestStruct -} - -func NewAdaptTestStructBuilder() *AdaptTestStructBuilder{ - return &AdaptTestStructBuilder{ - obj: NewAdaptTestStruct(), - } -} - -func (p AdaptTestStructBuilder) Emit() *AdaptTestStruct{ - return &AdaptTestStruct{ - Delay: p.obj.Delay, - Custom: p.obj.Custom, - Timeout: p.obj.Timeout, - Data: p.obj.Data, - Meta: p.obj.Meta, - IndirectionString: p.obj.IndirectionString, - StringData: p.obj.StringData, - DoubleWrappedBool: p.obj.DoubleWrappedBool, - DoubleWrappedInteger: p.obj.DoubleWrappedInteger, - BinaryData: p.obj.BinaryData, - } -} - -func (a *AdaptTestStructBuilder) Delay(delay DurationMs) *AdaptTestStructBuilder { - a.obj.Delay = delay - return a -} - -func (a *AdaptTestStructBuilder) Custom(custom CustomProtocolType) *AdaptTestStructBuilder { - a.obj.Custom = custom - return a -} - -func (a *AdaptTestStructBuilder) Timeout(timeout int64) *AdaptTestStructBuilder { - a.obj.Timeout = timeout - return a -} - -func (a *AdaptTestStructBuilder) Data(data int64) *AdaptTestStructBuilder { - a.obj.Data = data - return a -} - -func (a *AdaptTestStructBuilder) Meta(meta string) *AdaptTestStructBuilder { - a.obj.Meta = meta - return a -} - -func (a *AdaptTestStructBuilder) IndirectionString(indirectionString IndirectionString) *AdaptTestStructBuilder { - a.obj.IndirectionString = indirectionString - return a -} - -func (a *AdaptTestStructBuilder) StringData(stringData string) *AdaptTestStructBuilder { - a.obj.StringData = stringData - return a -} - -func (a *AdaptTestStructBuilder) DoubleWrappedBool(doubleWrappedBool AdaptedBool) *AdaptTestStructBuilder { - a.obj.DoubleWrappedBool = doubleWrappedBool - return a -} - -func (a *AdaptTestStructBuilder) DoubleWrappedInteger(doubleWrappedInteger AdaptedInteger) *AdaptTestStructBuilder { - a.obj.DoubleWrappedInteger = doubleWrappedInteger - return a -} - -func (a *AdaptTestStructBuilder) BinaryData(binaryData []byte) *AdaptTestStructBuilder { - a.obj.BinaryData = binaryData - return a -} - -func (a *AdaptTestStruct) SetDelay(delay DurationMs) *AdaptTestStruct { - a.Delay = delay - return a -} - -func (a *AdaptTestStruct) SetCustom(custom CustomProtocolType) *AdaptTestStruct { - a.Custom = custom - return a -} - -func (a *AdaptTestStruct) SetTimeout(timeout int64) *AdaptTestStruct { - a.Timeout = timeout - return a -} - -func (a *AdaptTestStruct) SetData(data int64) *AdaptTestStruct { - a.Data = data - return a -} - -func (a *AdaptTestStruct) SetMeta(meta string) *AdaptTestStruct { - a.Meta = meta - return a -} - -func (a *AdaptTestStruct) SetIndirectionString(indirectionString IndirectionString) *AdaptTestStruct { - a.IndirectionString = indirectionString - return a -} - -func (a *AdaptTestStruct) SetStringData(stringData string) *AdaptTestStruct { - a.StringData = stringData - return a -} - -func (a *AdaptTestStruct) SetDoubleWrappedBool(doubleWrappedBool AdaptedBool) *AdaptTestStruct { - a.DoubleWrappedBool = doubleWrappedBool - return a -} - -func (a *AdaptTestStruct) SetDoubleWrappedInteger(doubleWrappedInteger AdaptedInteger) *AdaptTestStruct { - a.DoubleWrappedInteger = doubleWrappedInteger - return a -} - -func (a *AdaptTestStruct) SetBinaryData(binaryData []byte) *AdaptTestStruct { - a.BinaryData = binaryData - return a -} - -func (p *AdaptTestStruct) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 3: - if err := p.ReadField3(iprot); err != nil { - return err - } - case 4: - if err := p.ReadField4(iprot); err != nil { - return err - } - case 5: - if err := p.ReadField5(iprot); err != nil { - return err - } - case 6: - if err := p.ReadField6(iprot); err != nil { - return err - } - case 7: - if err := p.ReadField7(iprot); err != nil { - return err - } - case 8: - if err := p.ReadField8(iprot); err != nil { - return err - } - case 9: - if err := p.ReadField9(iprot); err != nil { - return err - } - case 10: - if err := p.ReadField10(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AdaptTestStruct) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - temp := DurationMs(v) - p.Delay = temp - } - return nil -} - -func (p *AdaptTestStruct) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadBinary(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - temp := CustomProtocolType(v) - p.Custom = temp - } - return nil -} - -func (p *AdaptTestStruct) ReadField3(iprot thrift.Protocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 3: ", err) - } else { - p.Timeout = v - } - return nil -} - -func (p *AdaptTestStruct) ReadField4(iprot thrift.Protocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 4: ", err) - } else { - p.Data = v - } - return nil -} - -func (p *AdaptTestStruct) ReadField5(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 5: ", err) - } else { - p.Meta = v - } - return nil -} - -func (p *AdaptTestStruct) ReadField6(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 6: ", err) - } else { - temp := IndirectionString(v) - p.IndirectionString = temp - } - return nil -} - -func (p *AdaptTestStruct) ReadField7(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 7: ", err) - } else { - p.StringData = v - } - return nil -} - -func (p *AdaptTestStruct) ReadField8(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 8: ", err) - } else { - temp := AdaptedBool(v) - p.DoubleWrappedBool = temp - } - return nil -} - -func (p *AdaptTestStruct) ReadField9(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 9: ", err) - } else { - temp := AdaptedInteger(v) - p.DoubleWrappedInteger = temp - } - return nil -} - -func (p *AdaptTestStruct) ReadField10(iprot thrift.Protocol) error { - if v, err := iprot.ReadBinary(); err != nil { - return thrift.PrependError("error reading field 10: ", err) - } else { - p.BinaryData = v - } - return nil -} - -func (p *AdaptTestStruct) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("AdaptTestStruct"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := p.writeField4(oprot); err != nil { return err } - if err := p.writeField5(oprot); err != nil { return err } - if err := p.writeField6(oprot); err != nil { return err } - if err := p.writeField7(oprot); err != nil { return err } - if err := p.writeField8(oprot); err != nil { return err } - if err := p.writeField9(oprot); err != nil { return err } - if err := p.writeField10(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *AdaptTestStruct) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("delay", thrift.I64, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:delay: ", p), err) } - if err := oprot.WriteI64(int64(p.Delay)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.delay (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:delay: ", p), err) } - return err -} - -func (p *AdaptTestStruct) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("custom", thrift.STRING, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:custom: ", p), err) } - if err := oprot.WriteBinary(p.Custom); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.custom (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:custom: ", p), err) } - return err -} - -func (p *AdaptTestStruct) writeField3(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("timeout", thrift.I64, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:timeout: ", p), err) } - if err := oprot.WriteI64(int64(p.Timeout)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.timeout (3) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:timeout: ", p), err) } - return err -} - -func (p *AdaptTestStruct) writeField4(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("data", thrift.I64, 4); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:data: ", p), err) } - if err := oprot.WriteI64(int64(p.Data)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.data (4) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 4:data: ", p), err) } - return err -} - -func (p *AdaptTestStruct) writeField5(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("meta", thrift.STRING, 5); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:meta: ", p), err) } - if err := oprot.WriteString(string(p.Meta)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.meta (5) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 5:meta: ", p), err) } - return err -} - -func (p *AdaptTestStruct) writeField6(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("indirectionString", thrift.STRING, 6); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 6:indirectionString: ", p), err) } - if err := oprot.WriteString(string(p.IndirectionString)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.indirectionString (6) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 6:indirectionString: ", p), err) } - return err -} - -func (p *AdaptTestStruct) writeField7(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("string_data", thrift.STRING, 7); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 7:string_data: ", p), err) } - if err := oprot.WriteString(string(p.StringData)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.string_data (7) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 7:string_data: ", p), err) } - return err -} - -func (p *AdaptTestStruct) writeField8(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("double_wrapped_bool", thrift.BOOL, 8); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 8:double_wrapped_bool: ", p), err) } - if err := oprot.WriteBool(bool(p.DoubleWrappedBool)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.double_wrapped_bool (8) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 8:double_wrapped_bool: ", p), err) } - return err -} - -func (p *AdaptTestStruct) writeField9(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("double_wrapped_integer", thrift.I32, 9); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 9:double_wrapped_integer: ", p), err) } - if err := oprot.WriteI32(int32(p.DoubleWrappedInteger)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.double_wrapped_integer (9) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 9:double_wrapped_integer: ", p), err) } - return err -} - -func (p *AdaptTestStruct) writeField10(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("binary_data", thrift.STRING, 10); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 10:binary_data: ", p), err) } - if err := oprot.WriteBinary(p.BinaryData); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.binary_data (10) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 10:binary_data: ", p), err) } - return err -} - -func (p *AdaptTestStruct) String() string { - if p == nil { - return "" - } - - delayVal := fmt.Sprintf("%v", p.Delay) - customVal := fmt.Sprintf("%v", p.Custom) - timeoutVal := fmt.Sprintf("%v", p.Timeout) - dataVal := fmt.Sprintf("%v", p.Data) - metaVal := fmt.Sprintf("%v", p.Meta) - indirectionStringVal := fmt.Sprintf("%v", p.IndirectionString) - stringDataVal := fmt.Sprintf("%v", p.StringData) - doubleWrappedBoolVal := fmt.Sprintf("%v", p.DoubleWrappedBool) - doubleWrappedIntegerVal := fmt.Sprintf("%v", p.DoubleWrappedInteger) - binaryDataVal := fmt.Sprintf("%v", p.BinaryData) - return fmt.Sprintf("AdaptTestStruct({Delay:%s Custom:%s Timeout:%s Data:%s Meta:%s IndirectionString:%s StringData:%s DoubleWrappedBool:%s DoubleWrappedInteger:%s BinaryData:%s})", delayVal, customVal, timeoutVal, dataVal, metaVal, indirectionStringVal, stringDataVal, doubleWrappedBoolVal, doubleWrappedIntegerVal, binaryDataVal) -} - -// Attributes: -// - AdaptedBool -// - AdaptedByte -// - AdaptedShort -// - AdaptedInteger -// - AdaptedLong -// - AdaptedDouble -// - AdaptedString -// - AdaptedList -// - AdaptedSet -// - AdaptedMap -// - AdaptedBoolDefault -// - AdaptedByteDefault -// - AdaptedShortDefault -// - AdaptedIntegerDefault -// - AdaptedLongDefault -// - AdaptedDoubleDefault -// - AdaptedStringDefault -// - AdaptedEnum -// - AdaptedListDefault -// - AdaptedSetDefault -// - AdaptedMapDefault -// - DoubleTypedefBool -type AdaptTemplatedTestStruct struct { - AdaptedBool AdaptedBool `thrift:"adaptedBool,1" db:"adaptedBool" json:"adaptedBool"` - AdaptedByte AdaptedByte `thrift:"adaptedByte,2" db:"adaptedByte" json:"adaptedByte"` - AdaptedShort AdaptedShort `thrift:"adaptedShort,3" db:"adaptedShort" json:"adaptedShort"` - AdaptedInteger AdaptedInteger `thrift:"adaptedInteger,4" db:"adaptedInteger" json:"adaptedInteger"` - AdaptedLong AdaptedLong `thrift:"adaptedLong,5" db:"adaptedLong" json:"adaptedLong"` - AdaptedDouble AdaptedDouble `thrift:"adaptedDouble,6" db:"adaptedDouble" json:"adaptedDouble"` - AdaptedString AdaptedString `thrift:"adaptedString,7" db:"adaptedString" json:"adaptedString"` - AdaptedList []int64 `thrift:"adaptedList,8" db:"adaptedList" json:"adaptedList"` - AdaptedSet []int64 `thrift:"adaptedSet,9" db:"adaptedSet" json:"adaptedSet"` - AdaptedMap map[int64]int64 `thrift:"adaptedMap,10" db:"adaptedMap" json:"adaptedMap"` - AdaptedBoolDefault AdaptedBool `thrift:"adaptedBoolDefault,11" db:"adaptedBoolDefault" json:"adaptedBoolDefault"` - AdaptedByteDefault AdaptedByte `thrift:"adaptedByteDefault,12" db:"adaptedByteDefault" json:"adaptedByteDefault"` - AdaptedShortDefault AdaptedShort `thrift:"adaptedShortDefault,13" db:"adaptedShortDefault" json:"adaptedShortDefault"` - AdaptedIntegerDefault AdaptedInteger `thrift:"adaptedIntegerDefault,14" db:"adaptedIntegerDefault" json:"adaptedIntegerDefault"` - AdaptedLongDefault AdaptedLong `thrift:"adaptedLongDefault,15" db:"adaptedLongDefault" json:"adaptedLongDefault"` - AdaptedDoubleDefault AdaptedDouble `thrift:"adaptedDoubleDefault,16" db:"adaptedDoubleDefault" json:"adaptedDoubleDefault"` - AdaptedStringDefault AdaptedString `thrift:"adaptedStringDefault,17" db:"adaptedStringDefault" json:"adaptedStringDefault"` - AdaptedEnum AdaptedEnum `thrift:"adaptedEnum,18" db:"adaptedEnum" json:"adaptedEnum"` - AdaptedListDefault []int64 `thrift:"adaptedListDefault,19" db:"adaptedListDefault" json:"adaptedListDefault"` - AdaptedSetDefault []int64 `thrift:"adaptedSetDefault,20" db:"adaptedSetDefault" json:"adaptedSetDefault"` - AdaptedMapDefault map[int64]int64 `thrift:"adaptedMapDefault,21" db:"adaptedMapDefault" json:"adaptedMapDefault"` - DoubleTypedefBool DoubleTypedefBool `thrift:"doubleTypedefBool,22" db:"doubleTypedefBool" json:"doubleTypedefBool"` -} - -func NewAdaptTemplatedTestStruct() *AdaptTemplatedTestStruct { - return &AdaptTemplatedTestStruct{ - AdaptedBoolDefault: true, - AdaptedByteDefault: 1, - AdaptedShortDefault: 2, - AdaptedIntegerDefault: 3, - AdaptedLongDefault: 4, - AdaptedDoubleDefault: 5, - AdaptedStringDefault: "6", - AdaptedEnum: 1, - AdaptedListDefault: []int64{ - 1, - }, - AdaptedSetDefault: []int64{ - 1, }, - AdaptedMapDefault: map[int64]int64{ - 1: 1, - }, - } -} - - -func (p *AdaptTemplatedTestStruct) GetAdaptedBool() AdaptedBool { - return p.AdaptedBool -} - -func (p *AdaptTemplatedTestStruct) GetAdaptedByte() AdaptedByte { - return p.AdaptedByte -} - -func (p *AdaptTemplatedTestStruct) GetAdaptedShort() AdaptedShort { - return p.AdaptedShort -} - -func (p *AdaptTemplatedTestStruct) GetAdaptedInteger() AdaptedInteger { - return p.AdaptedInteger -} - -func (p *AdaptTemplatedTestStruct) GetAdaptedLong() AdaptedLong { - return p.AdaptedLong -} - -func (p *AdaptTemplatedTestStruct) GetAdaptedDouble() AdaptedDouble { - return p.AdaptedDouble -} - -func (p *AdaptTemplatedTestStruct) GetAdaptedString() AdaptedString { - return p.AdaptedString -} - -func (p *AdaptTemplatedTestStruct) GetAdaptedList() []int64 { - return p.AdaptedList -} - -func (p *AdaptTemplatedTestStruct) GetAdaptedSet() []int64 { - return p.AdaptedSet -} - -func (p *AdaptTemplatedTestStruct) GetAdaptedMap() map[int64]int64 { - return p.AdaptedMap -} - -func (p *AdaptTemplatedTestStruct) GetAdaptedBoolDefault() AdaptedBool { - return p.AdaptedBoolDefault -} - -func (p *AdaptTemplatedTestStruct) GetAdaptedByteDefault() AdaptedByte { - return p.AdaptedByteDefault -} - -func (p *AdaptTemplatedTestStruct) GetAdaptedShortDefault() AdaptedShort { - return p.AdaptedShortDefault -} - -func (p *AdaptTemplatedTestStruct) GetAdaptedIntegerDefault() AdaptedInteger { - return p.AdaptedIntegerDefault -} - -func (p *AdaptTemplatedTestStruct) GetAdaptedLongDefault() AdaptedLong { - return p.AdaptedLongDefault -} - -func (p *AdaptTemplatedTestStruct) GetAdaptedDoubleDefault() AdaptedDouble { - return p.AdaptedDoubleDefault -} - -func (p *AdaptTemplatedTestStruct) GetAdaptedStringDefault() AdaptedString { - return p.AdaptedStringDefault -} - -func (p *AdaptTemplatedTestStruct) GetAdaptedEnum() AdaptedEnum { - return p.AdaptedEnum -} - -func (p *AdaptTemplatedTestStruct) GetAdaptedListDefault() []int64 { - return p.AdaptedListDefault -} - -func (p *AdaptTemplatedTestStruct) GetAdaptedSetDefault() []int64 { - return p.AdaptedSetDefault -} - -func (p *AdaptTemplatedTestStruct) GetAdaptedMapDefault() map[int64]int64 { - return p.AdaptedMapDefault -} - -func (p *AdaptTemplatedTestStruct) GetDoubleTypedefBool() DoubleTypedefBool { - return p.DoubleTypedefBool -} -type AdaptTemplatedTestStructBuilder struct { - obj *AdaptTemplatedTestStruct -} - -func NewAdaptTemplatedTestStructBuilder() *AdaptTemplatedTestStructBuilder{ - return &AdaptTemplatedTestStructBuilder{ - obj: NewAdaptTemplatedTestStruct(), - } -} - -func (p AdaptTemplatedTestStructBuilder) Emit() *AdaptTemplatedTestStruct{ - return &AdaptTemplatedTestStruct{ - AdaptedBool: p.obj.AdaptedBool, - AdaptedByte: p.obj.AdaptedByte, - AdaptedShort: p.obj.AdaptedShort, - AdaptedInteger: p.obj.AdaptedInteger, - AdaptedLong: p.obj.AdaptedLong, - AdaptedDouble: p.obj.AdaptedDouble, - AdaptedString: p.obj.AdaptedString, - AdaptedList: p.obj.AdaptedList, - AdaptedSet: p.obj.AdaptedSet, - AdaptedMap: p.obj.AdaptedMap, - AdaptedBoolDefault: p.obj.AdaptedBoolDefault, - AdaptedByteDefault: p.obj.AdaptedByteDefault, - AdaptedShortDefault: p.obj.AdaptedShortDefault, - AdaptedIntegerDefault: p.obj.AdaptedIntegerDefault, - AdaptedLongDefault: p.obj.AdaptedLongDefault, - AdaptedDoubleDefault: p.obj.AdaptedDoubleDefault, - AdaptedStringDefault: p.obj.AdaptedStringDefault, - AdaptedEnum: p.obj.AdaptedEnum, - AdaptedListDefault: p.obj.AdaptedListDefault, - AdaptedSetDefault: p.obj.AdaptedSetDefault, - AdaptedMapDefault: p.obj.AdaptedMapDefault, - DoubleTypedefBool: p.obj.DoubleTypedefBool, - } -} - -func (a *AdaptTemplatedTestStructBuilder) AdaptedBool(adaptedBool AdaptedBool) *AdaptTemplatedTestStructBuilder { - a.obj.AdaptedBool = adaptedBool - return a -} - -func (a *AdaptTemplatedTestStructBuilder) AdaptedByte(adaptedByte AdaptedByte) *AdaptTemplatedTestStructBuilder { - a.obj.AdaptedByte = adaptedByte - return a -} - -func (a *AdaptTemplatedTestStructBuilder) AdaptedShort(adaptedShort AdaptedShort) *AdaptTemplatedTestStructBuilder { - a.obj.AdaptedShort = adaptedShort - return a -} - -func (a *AdaptTemplatedTestStructBuilder) AdaptedInteger(adaptedInteger AdaptedInteger) *AdaptTemplatedTestStructBuilder { - a.obj.AdaptedInteger = adaptedInteger - return a -} - -func (a *AdaptTemplatedTestStructBuilder) AdaptedLong(adaptedLong AdaptedLong) *AdaptTemplatedTestStructBuilder { - a.obj.AdaptedLong = adaptedLong - return a -} - -func (a *AdaptTemplatedTestStructBuilder) AdaptedDouble(adaptedDouble AdaptedDouble) *AdaptTemplatedTestStructBuilder { - a.obj.AdaptedDouble = adaptedDouble - return a -} - -func (a *AdaptTemplatedTestStructBuilder) AdaptedString(adaptedString AdaptedString) *AdaptTemplatedTestStructBuilder { - a.obj.AdaptedString = adaptedString - return a -} - -func (a *AdaptTemplatedTestStructBuilder) AdaptedList(adaptedList []int64) *AdaptTemplatedTestStructBuilder { - a.obj.AdaptedList = adaptedList - return a -} - -func (a *AdaptTemplatedTestStructBuilder) AdaptedSet(adaptedSet []int64) *AdaptTemplatedTestStructBuilder { - a.obj.AdaptedSet = adaptedSet - return a -} - -func (a *AdaptTemplatedTestStructBuilder) AdaptedMap(adaptedMap map[int64]int64) *AdaptTemplatedTestStructBuilder { - a.obj.AdaptedMap = adaptedMap - return a -} - -func (a *AdaptTemplatedTestStructBuilder) AdaptedBoolDefault(adaptedBoolDefault AdaptedBool) *AdaptTemplatedTestStructBuilder { - a.obj.AdaptedBoolDefault = adaptedBoolDefault - return a -} - -func (a *AdaptTemplatedTestStructBuilder) AdaptedByteDefault(adaptedByteDefault AdaptedByte) *AdaptTemplatedTestStructBuilder { - a.obj.AdaptedByteDefault = adaptedByteDefault - return a -} - -func (a *AdaptTemplatedTestStructBuilder) AdaptedShortDefault(adaptedShortDefault AdaptedShort) *AdaptTemplatedTestStructBuilder { - a.obj.AdaptedShortDefault = adaptedShortDefault - return a -} - -func (a *AdaptTemplatedTestStructBuilder) AdaptedIntegerDefault(adaptedIntegerDefault AdaptedInteger) *AdaptTemplatedTestStructBuilder { - a.obj.AdaptedIntegerDefault = adaptedIntegerDefault - return a -} - -func (a *AdaptTemplatedTestStructBuilder) AdaptedLongDefault(adaptedLongDefault AdaptedLong) *AdaptTemplatedTestStructBuilder { - a.obj.AdaptedLongDefault = adaptedLongDefault - return a -} - -func (a *AdaptTemplatedTestStructBuilder) AdaptedDoubleDefault(adaptedDoubleDefault AdaptedDouble) *AdaptTemplatedTestStructBuilder { - a.obj.AdaptedDoubleDefault = adaptedDoubleDefault - return a -} - -func (a *AdaptTemplatedTestStructBuilder) AdaptedStringDefault(adaptedStringDefault AdaptedString) *AdaptTemplatedTestStructBuilder { - a.obj.AdaptedStringDefault = adaptedStringDefault - return a -} - -func (a *AdaptTemplatedTestStructBuilder) AdaptedEnum(adaptedEnum AdaptedEnum) *AdaptTemplatedTestStructBuilder { - a.obj.AdaptedEnum = adaptedEnum - return a -} - -func (a *AdaptTemplatedTestStructBuilder) AdaptedListDefault(adaptedListDefault []int64) *AdaptTemplatedTestStructBuilder { - a.obj.AdaptedListDefault = adaptedListDefault - return a -} - -func (a *AdaptTemplatedTestStructBuilder) AdaptedSetDefault(adaptedSetDefault []int64) *AdaptTemplatedTestStructBuilder { - a.obj.AdaptedSetDefault = adaptedSetDefault - return a -} - -func (a *AdaptTemplatedTestStructBuilder) AdaptedMapDefault(adaptedMapDefault map[int64]int64) *AdaptTemplatedTestStructBuilder { - a.obj.AdaptedMapDefault = adaptedMapDefault - return a -} - -func (a *AdaptTemplatedTestStructBuilder) DoubleTypedefBool(doubleTypedefBool DoubleTypedefBool) *AdaptTemplatedTestStructBuilder { - a.obj.DoubleTypedefBool = doubleTypedefBool - return a -} - -func (a *AdaptTemplatedTestStruct) SetAdaptedBool(adaptedBool AdaptedBool) *AdaptTemplatedTestStruct { - a.AdaptedBool = adaptedBool - return a -} - -func (a *AdaptTemplatedTestStruct) SetAdaptedByte(adaptedByte AdaptedByte) *AdaptTemplatedTestStruct { - a.AdaptedByte = adaptedByte - return a -} - -func (a *AdaptTemplatedTestStruct) SetAdaptedShort(adaptedShort AdaptedShort) *AdaptTemplatedTestStruct { - a.AdaptedShort = adaptedShort - return a -} - -func (a *AdaptTemplatedTestStruct) SetAdaptedInteger(adaptedInteger AdaptedInteger) *AdaptTemplatedTestStruct { - a.AdaptedInteger = adaptedInteger - return a -} - -func (a *AdaptTemplatedTestStruct) SetAdaptedLong(adaptedLong AdaptedLong) *AdaptTemplatedTestStruct { - a.AdaptedLong = adaptedLong - return a -} - -func (a *AdaptTemplatedTestStruct) SetAdaptedDouble(adaptedDouble AdaptedDouble) *AdaptTemplatedTestStruct { - a.AdaptedDouble = adaptedDouble - return a -} - -func (a *AdaptTemplatedTestStruct) SetAdaptedString(adaptedString AdaptedString) *AdaptTemplatedTestStruct { - a.AdaptedString = adaptedString - return a -} - -func (a *AdaptTemplatedTestStruct) SetAdaptedList(adaptedList []int64) *AdaptTemplatedTestStruct { - a.AdaptedList = adaptedList - return a -} - -func (a *AdaptTemplatedTestStruct) SetAdaptedSet(adaptedSet []int64) *AdaptTemplatedTestStruct { - a.AdaptedSet = adaptedSet - return a -} - -func (a *AdaptTemplatedTestStruct) SetAdaptedMap(adaptedMap map[int64]int64) *AdaptTemplatedTestStruct { - a.AdaptedMap = adaptedMap - return a -} - -func (a *AdaptTemplatedTestStruct) SetAdaptedBoolDefault(adaptedBoolDefault AdaptedBool) *AdaptTemplatedTestStruct { - a.AdaptedBoolDefault = adaptedBoolDefault - return a -} - -func (a *AdaptTemplatedTestStruct) SetAdaptedByteDefault(adaptedByteDefault AdaptedByte) *AdaptTemplatedTestStruct { - a.AdaptedByteDefault = adaptedByteDefault - return a -} - -func (a *AdaptTemplatedTestStruct) SetAdaptedShortDefault(adaptedShortDefault AdaptedShort) *AdaptTemplatedTestStruct { - a.AdaptedShortDefault = adaptedShortDefault - return a -} - -func (a *AdaptTemplatedTestStruct) SetAdaptedIntegerDefault(adaptedIntegerDefault AdaptedInteger) *AdaptTemplatedTestStruct { - a.AdaptedIntegerDefault = adaptedIntegerDefault - return a -} - -func (a *AdaptTemplatedTestStruct) SetAdaptedLongDefault(adaptedLongDefault AdaptedLong) *AdaptTemplatedTestStruct { - a.AdaptedLongDefault = adaptedLongDefault - return a -} - -func (a *AdaptTemplatedTestStruct) SetAdaptedDoubleDefault(adaptedDoubleDefault AdaptedDouble) *AdaptTemplatedTestStruct { - a.AdaptedDoubleDefault = adaptedDoubleDefault - return a -} - -func (a *AdaptTemplatedTestStruct) SetAdaptedStringDefault(adaptedStringDefault AdaptedString) *AdaptTemplatedTestStruct { - a.AdaptedStringDefault = adaptedStringDefault - return a -} - -func (a *AdaptTemplatedTestStruct) SetAdaptedEnum(adaptedEnum AdaptedEnum) *AdaptTemplatedTestStruct { - a.AdaptedEnum = adaptedEnum - return a -} - -func (a *AdaptTemplatedTestStruct) SetAdaptedListDefault(adaptedListDefault []int64) *AdaptTemplatedTestStruct { - a.AdaptedListDefault = adaptedListDefault - return a -} - -func (a *AdaptTemplatedTestStruct) SetAdaptedSetDefault(adaptedSetDefault []int64) *AdaptTemplatedTestStruct { - a.AdaptedSetDefault = adaptedSetDefault - return a -} - -func (a *AdaptTemplatedTestStruct) SetAdaptedMapDefault(adaptedMapDefault map[int64]int64) *AdaptTemplatedTestStruct { - a.AdaptedMapDefault = adaptedMapDefault - return a -} - -func (a *AdaptTemplatedTestStruct) SetDoubleTypedefBool(doubleTypedefBool DoubleTypedefBool) *AdaptTemplatedTestStruct { - a.DoubleTypedefBool = doubleTypedefBool - return a -} - -func (p *AdaptTemplatedTestStruct) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 3: - if err := p.ReadField3(iprot); err != nil { - return err - } - case 4: - if err := p.ReadField4(iprot); err != nil { - return err - } - case 5: - if err := p.ReadField5(iprot); err != nil { - return err - } - case 6: - if err := p.ReadField6(iprot); err != nil { - return err - } - case 7: - if err := p.ReadField7(iprot); err != nil { - return err - } - case 8: - if err := p.ReadField8(iprot); err != nil { - return err - } - case 9: - if err := p.ReadField9(iprot); err != nil { - return err - } - case 10: - if err := p.ReadField10(iprot); err != nil { - return err - } - case 11: - if err := p.ReadField11(iprot); err != nil { - return err - } - case 12: - if err := p.ReadField12(iprot); err != nil { - return err - } - case 13: - if err := p.ReadField13(iprot); err != nil { - return err - } - case 14: - if err := p.ReadField14(iprot); err != nil { - return err - } - case 15: - if err := p.ReadField15(iprot); err != nil { - return err - } - case 16: - if err := p.ReadField16(iprot); err != nil { - return err - } - case 17: - if err := p.ReadField17(iprot); err != nil { - return err - } - case 18: - if err := p.ReadField18(iprot); err != nil { - return err - } - case 19: - if err := p.ReadField19(iprot); err != nil { - return err - } - case 20: - if err := p.ReadField20(iprot); err != nil { - return err - } - case 21: - if err := p.ReadField21(iprot); err != nil { - return err - } - case 22: - if err := p.ReadField22(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AdaptTemplatedTestStruct) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - temp := AdaptedBool(v) - p.AdaptedBool = temp - } - return nil -} - -func (p *AdaptTemplatedTestStruct) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadByte(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - temp := AdaptedByte(v) - p.AdaptedByte = temp - } - return nil -} - -func (p *AdaptTemplatedTestStruct) ReadField3(iprot thrift.Protocol) error { - if v, err := iprot.ReadI16(); err != nil { - return thrift.PrependError("error reading field 3: ", err) - } else { - temp := AdaptedShort(v) - p.AdaptedShort = temp - } - return nil -} - -func (p *AdaptTemplatedTestStruct) ReadField4(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 4: ", err) - } else { - temp := AdaptedInteger(v) - p.AdaptedInteger = temp - } - return nil -} - -func (p *AdaptTemplatedTestStruct) ReadField5(iprot thrift.Protocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 5: ", err) - } else { - temp := AdaptedLong(v) - p.AdaptedLong = temp - } - return nil -} - -func (p *AdaptTemplatedTestStruct) ReadField6(iprot thrift.Protocol) error { - if v, err := iprot.ReadDouble(); err != nil { - return thrift.PrependError("error reading field 6: ", err) - } else { - temp := AdaptedDouble(v) - p.AdaptedDouble = temp - } - return nil -} - -func (p *AdaptTemplatedTestStruct) ReadField7(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 7: ", err) - } else { - temp := AdaptedString(v) - p.AdaptedString = temp - } - return nil -} - -func (p *AdaptTemplatedTestStruct) ReadField8(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]int64, 0, size) - p.AdaptedList = tSlice - for i := 0; i < size; i ++ { - var _elem16 int64 - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem16 = v - } - p.AdaptedList = append(p.AdaptedList, _elem16) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *AdaptTemplatedTestStruct) ReadField9(iprot thrift.Protocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return thrift.PrependError("error reading set begin: ", err) - } - tSet := make([]int64, 0, size) - p.AdaptedSet = tSet - for i := 0; i < size; i ++ { - var _elem17 int64 - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem17 = v - } - p.AdaptedSet = append(p.AdaptedSet, _elem17) - } - if err := iprot.ReadSetEnd(); err != nil { - return thrift.PrependError("error reading set end: ", err) - } - return nil -} - -func (p *AdaptTemplatedTestStruct) ReadField10(iprot thrift.Protocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[int64]int64, size) - p.AdaptedMap = tMap - for i := 0; i < size; i ++ { - var _key18 int64 - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key18 = v - } - var _val19 int64 - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _val19 = v - } - p.AdaptedMap[_key18] = _val19 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *AdaptTemplatedTestStruct) ReadField11(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 11: ", err) - } else { - temp := AdaptedBool(v) - p.AdaptedBoolDefault = temp - } - return nil -} - -func (p *AdaptTemplatedTestStruct) ReadField12(iprot thrift.Protocol) error { - if v, err := iprot.ReadByte(); err != nil { - return thrift.PrependError("error reading field 12: ", err) - } else { - temp := AdaptedByte(v) - p.AdaptedByteDefault = temp - } - return nil -} - -func (p *AdaptTemplatedTestStruct) ReadField13(iprot thrift.Protocol) error { - if v, err := iprot.ReadI16(); err != nil { - return thrift.PrependError("error reading field 13: ", err) - } else { - temp := AdaptedShort(v) - p.AdaptedShortDefault = temp - } - return nil -} - -func (p *AdaptTemplatedTestStruct) ReadField14(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 14: ", err) - } else { - temp := AdaptedInteger(v) - p.AdaptedIntegerDefault = temp - } - return nil -} - -func (p *AdaptTemplatedTestStruct) ReadField15(iprot thrift.Protocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 15: ", err) - } else { - temp := AdaptedLong(v) - p.AdaptedLongDefault = temp - } - return nil -} - -func (p *AdaptTemplatedTestStruct) ReadField16(iprot thrift.Protocol) error { - if v, err := iprot.ReadDouble(); err != nil { - return thrift.PrependError("error reading field 16: ", err) - } else { - temp := AdaptedDouble(v) - p.AdaptedDoubleDefault = temp - } - return nil -} - -func (p *AdaptTemplatedTestStruct) ReadField17(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 17: ", err) - } else { - temp := AdaptedString(v) - p.AdaptedStringDefault = temp - } - return nil -} - -func (p *AdaptTemplatedTestStruct) ReadField18(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 18: ", err) - } else { - temp := AdaptedEnum(v) - p.AdaptedEnum = temp - } - return nil -} - -func (p *AdaptTemplatedTestStruct) ReadField19(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]int64, 0, size) - p.AdaptedListDefault = tSlice - for i := 0; i < size; i ++ { - var _elem20 int64 - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem20 = v - } - p.AdaptedListDefault = append(p.AdaptedListDefault, _elem20) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *AdaptTemplatedTestStruct) ReadField20(iprot thrift.Protocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return thrift.PrependError("error reading set begin: ", err) - } - tSet := make([]int64, 0, size) - p.AdaptedSetDefault = tSet - for i := 0; i < size; i ++ { - var _elem21 int64 - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem21 = v - } - p.AdaptedSetDefault = append(p.AdaptedSetDefault, _elem21) - } - if err := iprot.ReadSetEnd(); err != nil { - return thrift.PrependError("error reading set end: ", err) - } - return nil -} - -func (p *AdaptTemplatedTestStruct) ReadField21(iprot thrift.Protocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[int64]int64, size) - p.AdaptedMapDefault = tMap - for i := 0; i < size; i ++ { - var _key22 int64 - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key22 = v - } - var _val23 int64 - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _val23 = v - } - p.AdaptedMapDefault[_key22] = _val23 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *AdaptTemplatedTestStruct) ReadField22(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 22: ", err) - } else { - temp := DoubleTypedefBool(v) - p.DoubleTypedefBool = temp - } - return nil -} - -func (p *AdaptTemplatedTestStruct) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("AdaptTemplatedTestStruct"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := p.writeField4(oprot); err != nil { return err } - if err := p.writeField5(oprot); err != nil { return err } - if err := p.writeField6(oprot); err != nil { return err } - if err := p.writeField7(oprot); err != nil { return err } - if err := p.writeField8(oprot); err != nil { return err } - if err := p.writeField9(oprot); err != nil { return err } - if err := p.writeField10(oprot); err != nil { return err } - if err := p.writeField11(oprot); err != nil { return err } - if err := p.writeField12(oprot); err != nil { return err } - if err := p.writeField13(oprot); err != nil { return err } - if err := p.writeField14(oprot); err != nil { return err } - if err := p.writeField15(oprot); err != nil { return err } - if err := p.writeField16(oprot); err != nil { return err } - if err := p.writeField17(oprot); err != nil { return err } - if err := p.writeField18(oprot); err != nil { return err } - if err := p.writeField19(oprot); err != nil { return err } - if err := p.writeField20(oprot); err != nil { return err } - if err := p.writeField21(oprot); err != nil { return err } - if err := p.writeField22(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *AdaptTemplatedTestStruct) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("adaptedBool", thrift.BOOL, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:adaptedBool: ", p), err) } - if err := oprot.WriteBool(bool(p.AdaptedBool)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.adaptedBool (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:adaptedBool: ", p), err) } - return err -} - -func (p *AdaptTemplatedTestStruct) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("adaptedByte", thrift.BYTE, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:adaptedByte: ", p), err) } - if err := oprot.WriteByte(byte(p.AdaptedByte)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.adaptedByte (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:adaptedByte: ", p), err) } - return err -} - -func (p *AdaptTemplatedTestStruct) writeField3(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("adaptedShort", thrift.I16, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:adaptedShort: ", p), err) } - if err := oprot.WriteI16(int16(p.AdaptedShort)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.adaptedShort (3) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:adaptedShort: ", p), err) } - return err -} - -func (p *AdaptTemplatedTestStruct) writeField4(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("adaptedInteger", thrift.I32, 4); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:adaptedInteger: ", p), err) } - if err := oprot.WriteI32(int32(p.AdaptedInteger)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.adaptedInteger (4) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 4:adaptedInteger: ", p), err) } - return err -} - -func (p *AdaptTemplatedTestStruct) writeField5(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("adaptedLong", thrift.I64, 5); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:adaptedLong: ", p), err) } - if err := oprot.WriteI64(int64(p.AdaptedLong)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.adaptedLong (5) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 5:adaptedLong: ", p), err) } - return err -} - -func (p *AdaptTemplatedTestStruct) writeField6(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("adaptedDouble", thrift.DOUBLE, 6); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 6:adaptedDouble: ", p), err) } - if err := oprot.WriteDouble(float64(p.AdaptedDouble)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.adaptedDouble (6) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 6:adaptedDouble: ", p), err) } - return err -} - -func (p *AdaptTemplatedTestStruct) writeField7(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("adaptedString", thrift.STRING, 7); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 7:adaptedString: ", p), err) } - if err := oprot.WriteString(string(p.AdaptedString)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.adaptedString (7) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 7:adaptedString: ", p), err) } - return err -} - -func (p *AdaptTemplatedTestStruct) writeField8(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("adaptedList", thrift.LIST, 8); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 8:adaptedList: ", p), err) } - if err := oprot.WriteListBegin(thrift.I64, len(p.AdaptedList)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.AdaptedList { - if err := oprot.WriteI64(int64(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 8:adaptedList: ", p), err) } - return err -} - -func (p *AdaptTemplatedTestStruct) writeField9(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("adaptedSet", thrift.SET, 9); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 9:adaptedSet: ", p), err) } - if err := oprot.WriteSetBegin(thrift.I64, len(p.AdaptedSet)); err != nil { - return thrift.PrependError("error writing set begin: ", err) - } - set := make(map[int64]bool, len(p.AdaptedSet)) - for _, v := range p.AdaptedSet { - if ok := set[v]; ok { - return thrift.PrependError("", fmt.Errorf("%T error writing set field: slice is not unique", v)) - } - set[v] = true - } - for _, v := range p.AdaptedSet { - if err := oprot.WriteI64(int64(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteSetEnd(); err != nil { - return thrift.PrependError("error writing set end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 9:adaptedSet: ", p), err) } - return err -} - -func (p *AdaptTemplatedTestStruct) writeField10(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("adaptedMap", thrift.MAP, 10); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 10:adaptedMap: ", p), err) } - if err := oprot.WriteMapBegin(thrift.I64, thrift.I64, len(p.AdaptedMap)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.AdaptedMap { - if err := oprot.WriteI64(int64(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := oprot.WriteI64(int64(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 10:adaptedMap: ", p), err) } - return err -} - -func (p *AdaptTemplatedTestStruct) writeField11(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("adaptedBoolDefault", thrift.BOOL, 11); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 11:adaptedBoolDefault: ", p), err) } - if err := oprot.WriteBool(bool(p.AdaptedBoolDefault)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.adaptedBoolDefault (11) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 11:adaptedBoolDefault: ", p), err) } - return err -} - -func (p *AdaptTemplatedTestStruct) writeField12(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("adaptedByteDefault", thrift.BYTE, 12); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 12:adaptedByteDefault: ", p), err) } - if err := oprot.WriteByte(byte(p.AdaptedByteDefault)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.adaptedByteDefault (12) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 12:adaptedByteDefault: ", p), err) } - return err -} - -func (p *AdaptTemplatedTestStruct) writeField13(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("adaptedShortDefault", thrift.I16, 13); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 13:adaptedShortDefault: ", p), err) } - if err := oprot.WriteI16(int16(p.AdaptedShortDefault)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.adaptedShortDefault (13) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 13:adaptedShortDefault: ", p), err) } - return err -} - -func (p *AdaptTemplatedTestStruct) writeField14(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("adaptedIntegerDefault", thrift.I32, 14); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 14:adaptedIntegerDefault: ", p), err) } - if err := oprot.WriteI32(int32(p.AdaptedIntegerDefault)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.adaptedIntegerDefault (14) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 14:adaptedIntegerDefault: ", p), err) } - return err -} - -func (p *AdaptTemplatedTestStruct) writeField15(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("adaptedLongDefault", thrift.I64, 15); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 15:adaptedLongDefault: ", p), err) } - if err := oprot.WriteI64(int64(p.AdaptedLongDefault)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.adaptedLongDefault (15) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 15:adaptedLongDefault: ", p), err) } - return err -} - -func (p *AdaptTemplatedTestStruct) writeField16(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("adaptedDoubleDefault", thrift.DOUBLE, 16); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 16:adaptedDoubleDefault: ", p), err) } - if err := oprot.WriteDouble(float64(p.AdaptedDoubleDefault)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.adaptedDoubleDefault (16) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 16:adaptedDoubleDefault: ", p), err) } - return err -} - -func (p *AdaptTemplatedTestStruct) writeField17(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("adaptedStringDefault", thrift.STRING, 17); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 17:adaptedStringDefault: ", p), err) } - if err := oprot.WriteString(string(p.AdaptedStringDefault)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.adaptedStringDefault (17) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 17:adaptedStringDefault: ", p), err) } - return err -} - -func (p *AdaptTemplatedTestStruct) writeField18(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("adaptedEnum", thrift.I32, 18); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 18:adaptedEnum: ", p), err) } - if err := oprot.WriteI32(int32(p.AdaptedEnum)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.adaptedEnum (18) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 18:adaptedEnum: ", p), err) } - return err -} - -func (p *AdaptTemplatedTestStruct) writeField19(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("adaptedListDefault", thrift.LIST, 19); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 19:adaptedListDefault: ", p), err) } - if err := oprot.WriteListBegin(thrift.I64, len(p.AdaptedListDefault)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.AdaptedListDefault { - if err := oprot.WriteI64(int64(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 19:adaptedListDefault: ", p), err) } - return err -} - -func (p *AdaptTemplatedTestStruct) writeField20(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("adaptedSetDefault", thrift.SET, 20); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 20:adaptedSetDefault: ", p), err) } - if err := oprot.WriteSetBegin(thrift.I64, len(p.AdaptedSetDefault)); err != nil { - return thrift.PrependError("error writing set begin: ", err) - } - set := make(map[int64]bool, len(p.AdaptedSetDefault)) - for _, v := range p.AdaptedSetDefault { - if ok := set[v]; ok { - return thrift.PrependError("", fmt.Errorf("%T error writing set field: slice is not unique", v)) - } - set[v] = true - } - for _, v := range p.AdaptedSetDefault { - if err := oprot.WriteI64(int64(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteSetEnd(); err != nil { - return thrift.PrependError("error writing set end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 20:adaptedSetDefault: ", p), err) } - return err -} - -func (p *AdaptTemplatedTestStruct) writeField21(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("adaptedMapDefault", thrift.MAP, 21); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 21:adaptedMapDefault: ", p), err) } - if err := oprot.WriteMapBegin(thrift.I64, thrift.I64, len(p.AdaptedMapDefault)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.AdaptedMapDefault { - if err := oprot.WriteI64(int64(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := oprot.WriteI64(int64(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 21:adaptedMapDefault: ", p), err) } - return err -} - -func (p *AdaptTemplatedTestStruct) writeField22(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("doubleTypedefBool", thrift.BOOL, 22); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 22:doubleTypedefBool: ", p), err) } - if err := oprot.WriteBool(bool(p.DoubleTypedefBool)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.doubleTypedefBool (22) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 22:doubleTypedefBool: ", p), err) } - return err -} - -func (p *AdaptTemplatedTestStruct) String() string { - if p == nil { - return "" - } - - adaptedBoolVal := fmt.Sprintf("%v", p.AdaptedBool) - adaptedByteVal := fmt.Sprintf("%v", p.AdaptedByte) - adaptedShortVal := fmt.Sprintf("%v", p.AdaptedShort) - adaptedIntegerVal := fmt.Sprintf("%v", p.AdaptedInteger) - adaptedLongVal := fmt.Sprintf("%v", p.AdaptedLong) - adaptedDoubleVal := fmt.Sprintf("%v", p.AdaptedDouble) - adaptedStringVal := fmt.Sprintf("%v", p.AdaptedString) - adaptedListVal := fmt.Sprintf("%v", p.AdaptedList) - adaptedSetVal := fmt.Sprintf("%v", p.AdaptedSet) - adaptedMapVal := fmt.Sprintf("%v", p.AdaptedMap) - adaptedBoolDefaultVal := fmt.Sprintf("%v", p.AdaptedBoolDefault) - adaptedByteDefaultVal := fmt.Sprintf("%v", p.AdaptedByteDefault) - adaptedShortDefaultVal := fmt.Sprintf("%v", p.AdaptedShortDefault) - adaptedIntegerDefaultVal := fmt.Sprintf("%v", p.AdaptedIntegerDefault) - adaptedLongDefaultVal := fmt.Sprintf("%v", p.AdaptedLongDefault) - adaptedDoubleDefaultVal := fmt.Sprintf("%v", p.AdaptedDoubleDefault) - adaptedStringDefaultVal := fmt.Sprintf("%v", p.AdaptedStringDefault) - adaptedEnumVal := fmt.Sprintf("%v", p.AdaptedEnum) - adaptedListDefaultVal := fmt.Sprintf("%v", p.AdaptedListDefault) - adaptedSetDefaultVal := fmt.Sprintf("%v", p.AdaptedSetDefault) - adaptedMapDefaultVal := fmt.Sprintf("%v", p.AdaptedMapDefault) - doubleTypedefBoolVal := fmt.Sprintf("%v", p.DoubleTypedefBool) - return fmt.Sprintf("AdaptTemplatedTestStruct({AdaptedBool:%s AdaptedByte:%s AdaptedShort:%s AdaptedInteger:%s AdaptedLong:%s AdaptedDouble:%s AdaptedString:%s AdaptedList:%s AdaptedSet:%s AdaptedMap:%s AdaptedBoolDefault:%s AdaptedByteDefault:%s AdaptedShortDefault:%s AdaptedIntegerDefault:%s AdaptedLongDefault:%s AdaptedDoubleDefault:%s AdaptedStringDefault:%s AdaptedEnum:%s AdaptedListDefault:%s AdaptedSetDefault:%s AdaptedMapDefault:%s DoubleTypedefBool:%s})", adaptedBoolVal, adaptedByteVal, adaptedShortVal, adaptedIntegerVal, adaptedLongVal, adaptedDoubleVal, adaptedStringVal, adaptedListVal, adaptedSetVal, adaptedMapVal, adaptedBoolDefaultVal, adaptedByteDefaultVal, adaptedShortDefaultVal, adaptedIntegerDefaultVal, adaptedLongDefaultVal, adaptedDoubleDefaultVal, adaptedStringDefaultVal, adaptedEnumVal, adaptedListDefaultVal, adaptedSetDefaultVal, adaptedMapDefaultVal, doubleTypedefBoolVal) -} - -// Attributes: -// - AdaptedStruct -type AdaptTemplatedNestedTestStruct struct { - AdaptedStruct *AdaptTemplatedTestStruct `thrift:"adaptedStruct,1" db:"adaptedStruct" json:"adaptedStruct"` -} - -func NewAdaptTemplatedNestedTestStruct() *AdaptTemplatedNestedTestStruct { - return &AdaptTemplatedNestedTestStruct{ - AdaptedStruct: NewAdaptTemplatedTestStruct(), - } -} - -var AdaptTemplatedNestedTestStruct_AdaptedStruct_DEFAULT *AdaptTemplatedTestStruct -func (p *AdaptTemplatedNestedTestStruct) GetAdaptedStruct() *AdaptTemplatedTestStruct { - if !p.IsSetAdaptedStruct() { - return AdaptTemplatedNestedTestStruct_AdaptedStruct_DEFAULT - } - return p.AdaptedStruct -} -func (p *AdaptTemplatedNestedTestStruct) DefaultGetAdaptedStruct() *AdaptTemplatedTestStruct { - if !p.IsSetAdaptedStruct() { - return NewAdaptTemplatedTestStruct() - } - return p.AdaptedStruct -} -func (p *AdaptTemplatedNestedTestStruct) IsSetAdaptedStruct() bool { - return p != nil && p.AdaptedStruct != nil -} - -type AdaptTemplatedNestedTestStructBuilder struct { - obj *AdaptTemplatedNestedTestStruct -} - -func NewAdaptTemplatedNestedTestStructBuilder() *AdaptTemplatedNestedTestStructBuilder{ - return &AdaptTemplatedNestedTestStructBuilder{ - obj: NewAdaptTemplatedNestedTestStruct(), - } -} - -func (p AdaptTemplatedNestedTestStructBuilder) Emit() *AdaptTemplatedNestedTestStruct{ - return &AdaptTemplatedNestedTestStruct{ - AdaptedStruct: p.obj.AdaptedStruct, - } -} - -func (a *AdaptTemplatedNestedTestStructBuilder) AdaptedStruct(adaptedStruct *AdaptTemplatedTestStruct) *AdaptTemplatedNestedTestStructBuilder { - a.obj.AdaptedStruct = adaptedStruct - return a -} - -func (a *AdaptTemplatedNestedTestStruct) SetAdaptedStruct(adaptedStruct *AdaptTemplatedTestStruct) *AdaptTemplatedNestedTestStruct { - a.AdaptedStruct = adaptedStruct - return a -} - -func (p *AdaptTemplatedNestedTestStruct) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AdaptTemplatedNestedTestStruct) ReadField1(iprot thrift.Protocol) error { - p.AdaptedStruct = NewAdaptTemplatedTestStruct() - if err := p.AdaptedStruct.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.AdaptedStruct), err) - } - return nil -} - -func (p *AdaptTemplatedNestedTestStruct) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("AdaptTemplatedNestedTestStruct"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *AdaptTemplatedNestedTestStruct) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("adaptedStruct", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:adaptedStruct: ", p), err) } - if err := p.AdaptedStruct.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.AdaptedStruct), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:adaptedStruct: ", p), err) } - return err -} - -func (p *AdaptTemplatedNestedTestStruct) String() string { - if p == nil { - return "" - } - - var adaptedStructVal string - if p.AdaptedStruct == nil { - adaptedStructVal = "" - } else { - adaptedStructVal = fmt.Sprintf("%v", p.AdaptedStruct) - } - return fmt.Sprintf("AdaptTemplatedNestedTestStruct({AdaptedStruct:%s})", adaptedStructVal) -} - -// Attributes: -// - Delay -// - Custom -type AdaptTestUnion struct { - Delay *DurationMs `thrift:"delay,1,optional" db:"delay" json:"delay,omitempty"` - Custom CustomProtocolType `thrift:"custom,2,optional" db:"custom" json:"custom,omitempty"` -} - -func NewAdaptTestUnion() *AdaptTestUnion { - return &AdaptTestUnion{} -} - -var AdaptTestUnion_Delay_DEFAULT DurationMs -func (p *AdaptTestUnion) GetDelay() DurationMs { - if !p.IsSetDelay() { - return AdaptTestUnion_Delay_DEFAULT - } - return *p.Delay -} -var AdaptTestUnion_Custom_DEFAULT CustomProtocolType - -func (p *AdaptTestUnion) GetCustom() CustomProtocolType { - return p.Custom -} -func (p *AdaptTestUnion) CountSetFieldsAdaptTestUnion() int { - count := 0 - if (p.IsSetDelay()) { - count++ - } - if (p.IsSetCustom()) { - count++ - } - return count - -} - -func (p *AdaptTestUnion) IsSetDelay() bool { - return p != nil && p.Delay != nil -} - -func (p *AdaptTestUnion) IsSetCustom() bool { - return p != nil && p.Custom != nil -} - -type AdaptTestUnionBuilder struct { - obj *AdaptTestUnion -} - -func NewAdaptTestUnionBuilder() *AdaptTestUnionBuilder{ - return &AdaptTestUnionBuilder{ - obj: NewAdaptTestUnion(), - } -} - -func (p AdaptTestUnionBuilder) Emit() *AdaptTestUnion{ - return &AdaptTestUnion{ - Delay: p.obj.Delay, - Custom: p.obj.Custom, - } -} - -func (a *AdaptTestUnionBuilder) Delay(delay *DurationMs) *AdaptTestUnionBuilder { - a.obj.Delay = delay - return a -} - -func (a *AdaptTestUnionBuilder) Custom(custom CustomProtocolType) *AdaptTestUnionBuilder { - a.obj.Custom = custom - return a -} - -func (a *AdaptTestUnion) SetDelay(delay *DurationMs) *AdaptTestUnion { - a.Delay = delay - return a -} - -func (a *AdaptTestUnion) SetCustom(custom CustomProtocolType) *AdaptTestUnion { - a.Custom = custom - return a -} - -func (p *AdaptTestUnion) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AdaptTestUnion) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - temp := DurationMs(v) - p.Delay = &temp - } - return nil -} - -func (p *AdaptTestUnion) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadBinary(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - temp := CustomProtocolType(v) - p.Custom = temp - } - return nil -} - -func (p *AdaptTestUnion) Write(oprot thrift.Protocol) error { - if c := p.CountSetFieldsAdaptTestUnion(); c > 1 { - return fmt.Errorf("%T write union: no more than one field must be set (%d set).", p, c) - } - if err := oprot.WriteStructBegin("AdaptTestUnion"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *AdaptTestUnion) writeField1(oprot thrift.Protocol) (err error) { - if p.IsSetDelay() { - if err := oprot.WriteFieldBegin("delay", thrift.I64, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:delay: ", p), err) } - if err := oprot.WriteI64(int64(*p.Delay)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.delay (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:delay: ", p), err) } - } - return err -} - -func (p *AdaptTestUnion) writeField2(oprot thrift.Protocol) (err error) { - if p.IsSetCustom() { - if err := oprot.WriteFieldBegin("custom", thrift.STRING, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:custom: ", p), err) } - if err := oprot.WriteBinary(p.Custom); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.custom (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:custom: ", p), err) } - } - return err -} - -func (p *AdaptTestUnion) String() string { - if p == nil { - return "" - } - - var delayVal string - if p.Delay == nil { - delayVal = "" - } else { - delayVal = fmt.Sprintf("%v", *p.Delay) - } - customVal := fmt.Sprintf("%v", p.Custom) - return fmt.Sprintf("AdaptTestUnion({Delay:%s Custom:%s})", delayVal, customVal) -} - -// Attributes: -// - Data -type AdaptedStruct struct { - Data int64 `thrift:"data,1" db:"data" json:"data"` -} - -func NewAdaptedStruct() *AdaptedStruct { - return &AdaptedStruct{} -} - - -func (p *AdaptedStruct) GetData() int64 { - return p.Data -} -type AdaptedStructBuilder struct { - obj *AdaptedStruct -} - -func NewAdaptedStructBuilder() *AdaptedStructBuilder{ - return &AdaptedStructBuilder{ - obj: NewAdaptedStruct(), - } -} - -func (p AdaptedStructBuilder) Emit() *AdaptedStruct{ - return &AdaptedStruct{ - Data: p.obj.Data, - } -} - -func (a *AdaptedStructBuilder) Data(data int64) *AdaptedStructBuilder { - a.obj.Data = data - return a -} - -func (a *AdaptedStruct) SetData(data int64) *AdaptedStruct { - a.Data = data - return a -} - -func (p *AdaptedStruct) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AdaptedStruct) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Data = v - } - return nil -} - -func (p *AdaptedStruct) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("AdaptedStruct"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *AdaptedStruct) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("data", thrift.I64, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:data: ", p), err) } - if err := oprot.WriteI64(int64(p.Data)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.data (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:data: ", p), err) } - return err -} - -func (p *AdaptedStruct) String() string { - if p == nil { - return "" - } - - dataVal := fmt.Sprintf("%v", p.Data) - return fmt.Sprintf("AdaptedStruct({Data:%s})", dataVal) -} - -// Attributes: -// - Data -type DirectlyAdaptedStruct struct { - Data int64 `thrift:"data,1" db:"data" json:"data"` -} - -func NewDirectlyAdaptedStruct() *DirectlyAdaptedStruct { - return &DirectlyAdaptedStruct{} -} - - -func (p *DirectlyAdaptedStruct) GetData() int64 { - return p.Data -} -type DirectlyAdaptedStructBuilder struct { - obj *DirectlyAdaptedStruct -} - -func NewDirectlyAdaptedStructBuilder() *DirectlyAdaptedStructBuilder{ - return &DirectlyAdaptedStructBuilder{ - obj: NewDirectlyAdaptedStruct(), - } -} - -func (p DirectlyAdaptedStructBuilder) Emit() *DirectlyAdaptedStruct{ - return &DirectlyAdaptedStruct{ - Data: p.obj.Data, - } -} - -func (d *DirectlyAdaptedStructBuilder) Data(data int64) *DirectlyAdaptedStructBuilder { - d.obj.Data = data - return d -} - -func (d *DirectlyAdaptedStruct) SetData(data int64) *DirectlyAdaptedStruct { - d.Data = data - return d -} - -func (p *DirectlyAdaptedStruct) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *DirectlyAdaptedStruct) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Data = v - } - return nil -} - -func (p *DirectlyAdaptedStruct) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("DirectlyAdaptedStruct"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *DirectlyAdaptedStruct) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("data", thrift.I64, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:data: ", p), err) } - if err := oprot.WriteI64(int64(p.Data)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.data (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:data: ", p), err) } - return err -} - -func (p *DirectlyAdaptedStruct) String() string { - if p == nil { - return "" - } - - dataVal := fmt.Sprintf("%v", p.Data) - return fmt.Sprintf("DirectlyAdaptedStruct({Data:%s})", dataVal) -} - -// Attributes: -// - AdaptedStruct -// - AdaptedTypedef -// - DirectlyAdapted -// - TypedefOfAdapted -type StructFieldAdaptedStruct struct { - AdaptedStruct *AdaptedStruct `thrift:"adaptedStruct,1" db:"adaptedStruct" json:"adaptedStruct"` - AdaptedTypedef *AdaptedTypedef `thrift:"adaptedTypedef,2" db:"adaptedTypedef" json:"adaptedTypedef"` - DirectlyAdapted *DirectlyAdaptedStruct `thrift:"directlyAdapted,3" db:"directlyAdapted" json:"directlyAdapted"` - TypedefOfAdapted *TypedefOfDirect `thrift:"typedefOfAdapted,4" db:"typedefOfAdapted" json:"typedefOfAdapted"` -} - -func NewStructFieldAdaptedStruct() *StructFieldAdaptedStruct { - return &StructFieldAdaptedStruct{ - AdaptedStruct: NewAdaptedStruct(), - AdaptedTypedef: NewAdaptedTypedef(), - DirectlyAdapted: NewDirectlyAdaptedStruct(), - TypedefOfAdapted: NewTypedefOfDirect(), - } -} - -var StructFieldAdaptedStruct_AdaptedStruct_DEFAULT *AdaptedStruct -func (p *StructFieldAdaptedStruct) GetAdaptedStruct() *AdaptedStruct { - if !p.IsSetAdaptedStruct() { - return StructFieldAdaptedStruct_AdaptedStruct_DEFAULT - } - return p.AdaptedStruct -} -func (p *StructFieldAdaptedStruct) DefaultGetAdaptedStruct() *AdaptedStruct { - if !p.IsSetAdaptedStruct() { - return NewAdaptedStruct() - } - return p.AdaptedStruct -} -var StructFieldAdaptedStruct_AdaptedTypedef_DEFAULT *AdaptedTypedef -func (p *StructFieldAdaptedStruct) GetAdaptedTypedef() *AdaptedTypedef { - if !p.IsSetAdaptedTypedef() { - return StructFieldAdaptedStruct_AdaptedTypedef_DEFAULT - } - return p.AdaptedTypedef -} -var StructFieldAdaptedStruct_DirectlyAdapted_DEFAULT *DirectlyAdaptedStruct -func (p *StructFieldAdaptedStruct) GetDirectlyAdapted() *DirectlyAdaptedStruct { - if !p.IsSetDirectlyAdapted() { - return StructFieldAdaptedStruct_DirectlyAdapted_DEFAULT - } - return p.DirectlyAdapted -} -func (p *StructFieldAdaptedStruct) DefaultGetDirectlyAdapted() *DirectlyAdaptedStruct { - if !p.IsSetDirectlyAdapted() { - return NewDirectlyAdaptedStruct() - } - return p.DirectlyAdapted -} -var StructFieldAdaptedStruct_TypedefOfAdapted_DEFAULT *TypedefOfDirect -func (p *StructFieldAdaptedStruct) GetTypedefOfAdapted() *TypedefOfDirect { - if !p.IsSetTypedefOfAdapted() { - return StructFieldAdaptedStruct_TypedefOfAdapted_DEFAULT - } - return p.TypedefOfAdapted -} -func (p *StructFieldAdaptedStruct) IsSetAdaptedStruct() bool { - return p != nil && p.AdaptedStruct != nil -} - -func (p *StructFieldAdaptedStruct) IsSetAdaptedTypedef() bool { - return p != nil && p.AdaptedTypedef != nil -} - -func (p *StructFieldAdaptedStruct) IsSetDirectlyAdapted() bool { - return p != nil && p.DirectlyAdapted != nil -} - -func (p *StructFieldAdaptedStruct) IsSetTypedefOfAdapted() bool { - return p != nil && p.TypedefOfAdapted != nil -} - -type StructFieldAdaptedStructBuilder struct { - obj *StructFieldAdaptedStruct -} - -func NewStructFieldAdaptedStructBuilder() *StructFieldAdaptedStructBuilder{ - return &StructFieldAdaptedStructBuilder{ - obj: NewStructFieldAdaptedStruct(), - } -} - -func (p StructFieldAdaptedStructBuilder) Emit() *StructFieldAdaptedStruct{ - return &StructFieldAdaptedStruct{ - AdaptedStruct: p.obj.AdaptedStruct, - AdaptedTypedef: p.obj.AdaptedTypedef, - DirectlyAdapted: p.obj.DirectlyAdapted, - TypedefOfAdapted: p.obj.TypedefOfAdapted, - } -} - -func (s *StructFieldAdaptedStructBuilder) AdaptedStruct(adaptedStruct *AdaptedStruct) *StructFieldAdaptedStructBuilder { - s.obj.AdaptedStruct = adaptedStruct - return s -} - -func (s *StructFieldAdaptedStructBuilder) AdaptedTypedef(adaptedTypedef *AdaptedTypedef) *StructFieldAdaptedStructBuilder { - s.obj.AdaptedTypedef = adaptedTypedef - return s -} - -func (s *StructFieldAdaptedStructBuilder) DirectlyAdapted(directlyAdapted *DirectlyAdaptedStruct) *StructFieldAdaptedStructBuilder { - s.obj.DirectlyAdapted = directlyAdapted - return s -} - -func (s *StructFieldAdaptedStructBuilder) TypedefOfAdapted(typedefOfAdapted *TypedefOfDirect) *StructFieldAdaptedStructBuilder { - s.obj.TypedefOfAdapted = typedefOfAdapted - return s -} - -func (s *StructFieldAdaptedStruct) SetAdaptedStruct(adaptedStruct *AdaptedStruct) *StructFieldAdaptedStruct { - s.AdaptedStruct = adaptedStruct - return s -} - -func (s *StructFieldAdaptedStruct) SetAdaptedTypedef(adaptedTypedef *AdaptedTypedef) *StructFieldAdaptedStruct { - s.AdaptedTypedef = adaptedTypedef - return s -} - -func (s *StructFieldAdaptedStruct) SetDirectlyAdapted(directlyAdapted *DirectlyAdaptedStruct) *StructFieldAdaptedStruct { - s.DirectlyAdapted = directlyAdapted - return s -} - -func (s *StructFieldAdaptedStruct) SetTypedefOfAdapted(typedefOfAdapted *TypedefOfDirect) *StructFieldAdaptedStruct { - s.TypedefOfAdapted = typedefOfAdapted - return s -} - -func (p *StructFieldAdaptedStruct) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 3: - if err := p.ReadField3(iprot); err != nil { - return err - } - case 4: - if err := p.ReadField4(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *StructFieldAdaptedStruct) ReadField1(iprot thrift.Protocol) error { - p.AdaptedStruct = NewAdaptedStruct() - if err := p.AdaptedStruct.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.AdaptedStruct), err) - } - return nil -} - -func (p *StructFieldAdaptedStruct) ReadField2(iprot thrift.Protocol) error { - p.AdaptedTypedef = NewAdaptedTypedef() - if err := p.AdaptedTypedef.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.AdaptedTypedef), err) - } - return nil -} - -func (p *StructFieldAdaptedStruct) ReadField3(iprot thrift.Protocol) error { - p.DirectlyAdapted = NewDirectlyAdaptedStruct() - if err := p.DirectlyAdapted.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.DirectlyAdapted), err) - } - return nil -} - -func (p *StructFieldAdaptedStruct) ReadField4(iprot thrift.Protocol) error { - p.TypedefOfAdapted = NewTypedefOfDirect() - if err := p.TypedefOfAdapted.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.TypedefOfAdapted), err) - } - return nil -} - -func (p *StructFieldAdaptedStruct) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("StructFieldAdaptedStruct"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := p.writeField4(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *StructFieldAdaptedStruct) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("adaptedStruct", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:adaptedStruct: ", p), err) } - if err := p.AdaptedStruct.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.AdaptedStruct), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:adaptedStruct: ", p), err) } - return err -} - -func (p *StructFieldAdaptedStruct) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("adaptedTypedef", thrift.STRUCT, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:adaptedTypedef: ", p), err) } - if err := p.AdaptedTypedef.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.AdaptedTypedef), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:adaptedTypedef: ", p), err) } - return err -} - -func (p *StructFieldAdaptedStruct) writeField3(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("directlyAdapted", thrift.STRUCT, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:directlyAdapted: ", p), err) } - if err := p.DirectlyAdapted.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.DirectlyAdapted), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:directlyAdapted: ", p), err) } - return err -} - -func (p *StructFieldAdaptedStruct) writeField4(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("typedefOfAdapted", thrift.STRUCT, 4); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:typedefOfAdapted: ", p), err) } - if err := p.TypedefOfAdapted.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.TypedefOfAdapted), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 4:typedefOfAdapted: ", p), err) } - return err -} - -func (p *StructFieldAdaptedStruct) String() string { - if p == nil { - return "" - } - - var adaptedStructVal string - if p.AdaptedStruct == nil { - adaptedStructVal = "" - } else { - adaptedStructVal = fmt.Sprintf("%v", p.AdaptedStruct) - } - var adaptedTypedefVal string - if p.AdaptedTypedef == nil { - adaptedTypedefVal = "" - } else { - adaptedTypedefVal = fmt.Sprintf("%v", p.AdaptedTypedef) - } - var directlyAdaptedVal string - if p.DirectlyAdapted == nil { - directlyAdaptedVal = "" - } else { - directlyAdaptedVal = fmt.Sprintf("%v", p.DirectlyAdapted) - } - var typedefOfAdaptedVal string - if p.TypedefOfAdapted == nil { - typedefOfAdaptedVal = "" - } else { - typedefOfAdaptedVal = fmt.Sprintf("%v", p.TypedefOfAdapted) - } - return fmt.Sprintf("StructFieldAdaptedStruct({AdaptedStruct:%s AdaptedTypedef:%s DirectlyAdapted:%s TypedefOfAdapted:%s})", adaptedStructVal, adaptedTypedefVal, directlyAdaptedVal, typedefOfAdaptedVal) -} - -// Attributes: -// - Field -type CircularAdaptee struct { - Field *CircularStruct `thrift:"field,1" db:"field" json:"field"` -} - -func NewCircularAdaptee() *CircularAdaptee { - return &CircularAdaptee{ - Field: NewCircularStruct(), - } -} - -var CircularAdaptee_Field_DEFAULT *CircularStruct -func (p *CircularAdaptee) GetField() *CircularStruct { - if !p.IsSetField() { - return CircularAdaptee_Field_DEFAULT - } - return p.Field -} -func (p *CircularAdaptee) IsSetField() bool { - return p != nil && p.Field != nil -} - -type CircularAdapteeBuilder struct { - obj *CircularAdaptee -} - -func NewCircularAdapteeBuilder() *CircularAdapteeBuilder{ - return &CircularAdapteeBuilder{ - obj: NewCircularAdaptee(), - } -} - -func (p CircularAdapteeBuilder) Emit() *CircularAdaptee{ - return &CircularAdaptee{ - Field: p.obj.Field, - } -} - -func (c *CircularAdapteeBuilder) Field(field *CircularStruct) *CircularAdapteeBuilder { - c.obj.Field = field - return c -} - -func (c *CircularAdaptee) SetField(field *CircularStruct) *CircularAdaptee { - c.Field = field - return c -} - -func (p *CircularAdaptee) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *CircularAdaptee) ReadField1(iprot thrift.Protocol) error { - p.Field = NewCircularStruct() - if err := p.Field.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Field), err) - } - return nil -} - -func (p *CircularAdaptee) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("CircularAdaptee"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *CircularAdaptee) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("field", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:field: ", p), err) } - if err := p.Field.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Field), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:field: ", p), err) } - return err -} - -func (p *CircularAdaptee) String() string { - if p == nil { - return "" - } - - var fieldVal string - if p.Field == nil { - fieldVal = "" - } else { - fieldVal = fmt.Sprintf("%v", p.Field) - } - return fmt.Sprintf("CircularAdaptee({Field:%s})", fieldVal) -} - -// Attributes: -// - Field -type CircularStruct struct { - Field *CircularAdaptee `thrift:"field,1,optional" db:"field" json:"field,omitempty"` -} - -func NewCircularStruct() *CircularStruct { - return &CircularStruct{} -} - -var CircularStruct_Field_DEFAULT *CircularAdaptee -func (p *CircularStruct) GetField() *CircularAdaptee { - if !p.IsSetField() { - return CircularStruct_Field_DEFAULT - } - return p.Field -} -func (p *CircularStruct) IsSetField() bool { - return p != nil && p.Field != nil -} - -type CircularStructBuilder struct { - obj *CircularStruct -} - -func NewCircularStructBuilder() *CircularStructBuilder{ - return &CircularStructBuilder{ - obj: NewCircularStruct(), - } -} - -func (p CircularStructBuilder) Emit() *CircularStruct{ - return &CircularStruct{ - Field: p.obj.Field, - } -} - -func (c *CircularStructBuilder) Field(field *CircularAdaptee) *CircularStructBuilder { - c.obj.Field = field - return c -} - -func (c *CircularStruct) SetField(field *CircularAdaptee) *CircularStruct { - c.Field = field - return c -} - -func (p *CircularStruct) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *CircularStruct) ReadField1(iprot thrift.Protocol) error { - p.Field = NewAdaptedCircularAdaptee() - if err := p.Field.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Field), err) - } - return nil -} - -func (p *CircularStruct) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("CircularStruct"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *CircularStruct) writeField1(oprot thrift.Protocol) (err error) { - if p.IsSetField() { - if err := oprot.WriteFieldBegin("field", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:field: ", p), err) } - if err := p.Field.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Field), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:field: ", p), err) } - } - return err -} - -func (p *CircularStruct) String() string { - if p == nil { - return "" - } - - var fieldVal string - if p.Field == nil { - fieldVal = "" - } else { - fieldVal = fmt.Sprintf("%v", p.Field) - } - return fmt.Sprintf("CircularStruct({Field:%s})", fieldVal) -} - -// Attributes: -// - ReorderedDependentAdapted -type ReorderedStruct struct { - ReorderedDependentAdapted *DeclaredAfterStruct `thrift:"reordered_dependent_adapted,1" db:"reordered_dependent_adapted" json:"reordered_dependent_adapted"` -} - -func NewReorderedStruct() *ReorderedStruct { - return &ReorderedStruct{ - ReorderedDependentAdapted: NewDeclaredAfterStruct(), - } -} - -var ReorderedStruct_ReorderedDependentAdapted_DEFAULT *DeclaredAfterStruct -func (p *ReorderedStruct) GetReorderedDependentAdapted() *DeclaredAfterStruct { - if !p.IsSetReorderedDependentAdapted() { - return ReorderedStruct_ReorderedDependentAdapted_DEFAULT - } - return p.ReorderedDependentAdapted -} -func (p *ReorderedStruct) IsSetReorderedDependentAdapted() bool { - return p != nil && p.ReorderedDependentAdapted != nil -} - -type ReorderedStructBuilder struct { - obj *ReorderedStruct -} - -func NewReorderedStructBuilder() *ReorderedStructBuilder{ - return &ReorderedStructBuilder{ - obj: NewReorderedStruct(), - } -} - -func (p ReorderedStructBuilder) Emit() *ReorderedStruct{ - return &ReorderedStruct{ - ReorderedDependentAdapted: p.obj.ReorderedDependentAdapted, - } -} - -func (r *ReorderedStructBuilder) ReorderedDependentAdapted(reorderedDependentAdapted *DeclaredAfterStruct) *ReorderedStructBuilder { - r.obj.ReorderedDependentAdapted = reorderedDependentAdapted - return r -} - -func (r *ReorderedStruct) SetReorderedDependentAdapted(reorderedDependentAdapted *DeclaredAfterStruct) *ReorderedStruct { - r.ReorderedDependentAdapted = reorderedDependentAdapted - return r -} - -func (p *ReorderedStruct) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ReorderedStruct) ReadField1(iprot thrift.Protocol) error { - p.ReorderedDependentAdapted = NewDeclaredAfterStruct() - if err := p.ReorderedDependentAdapted.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.ReorderedDependentAdapted), err) - } - return nil -} - -func (p *ReorderedStruct) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("ReorderedStruct"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *ReorderedStruct) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("reordered_dependent_adapted", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:reordered_dependent_adapted: ", p), err) } - if err := p.ReorderedDependentAdapted.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.ReorderedDependentAdapted), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:reordered_dependent_adapted: ", p), err) } - return err -} - -func (p *ReorderedStruct) String() string { - if p == nil { - return "" - } - - var reorderedDependentAdaptedVal string - if p.ReorderedDependentAdapted == nil { - reorderedDependentAdaptedVal = "" - } else { - reorderedDependentAdaptedVal = fmt.Sprintf("%v", p.ReorderedDependentAdapted) - } - return fmt.Sprintf("ReorderedStruct({ReorderedDependentAdapted:%s})", reorderedDependentAdaptedVal) -} - -type DeclaredAfterStruct struct { -} - -func NewDeclaredAfterStruct() *DeclaredAfterStruct { - return &DeclaredAfterStruct{} -} - -type DeclaredAfterStructBuilder struct { - obj *DeclaredAfterStruct -} - -func NewDeclaredAfterStructBuilder() *DeclaredAfterStructBuilder{ - return &DeclaredAfterStructBuilder{ - obj: NewDeclaredAfterStruct(), - } -} - -func (p DeclaredAfterStructBuilder) Emit() *DeclaredAfterStruct{ - return &DeclaredAfterStruct{ - } -} - -func (p *DeclaredAfterStruct) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *DeclaredAfterStruct) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("DeclaredAfterStruct"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *DeclaredAfterStruct) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("DeclaredAfterStruct({})") -} - -// Attributes: -// - Data -type RenamedStruct struct { - Data int64 `thrift:"data,1" db:"data" json:"data"` -} - -func NewRenamedStruct() *RenamedStruct { - return &RenamedStruct{} -} - - -func (p *RenamedStruct) GetData() int64 { - return p.Data -} -type RenamedStructBuilder struct { - obj *RenamedStruct -} - -func NewRenamedStructBuilder() *RenamedStructBuilder{ - return &RenamedStructBuilder{ - obj: NewRenamedStruct(), - } -} - -func (p RenamedStructBuilder) Emit() *RenamedStruct{ - return &RenamedStruct{ - Data: p.obj.Data, - } -} - -func (r *RenamedStructBuilder) Data(data int64) *RenamedStructBuilder { - r.obj.Data = data - return r -} - -func (r *RenamedStruct) SetData(data int64) *RenamedStruct { - r.Data = data - return r -} - -func (p *RenamedStruct) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *RenamedStruct) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Data = v - } - return nil -} - -func (p *RenamedStruct) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("RenamedStruct"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *RenamedStruct) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("data", thrift.I64, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:data: ", p), err) } - if err := oprot.WriteI64(int64(p.Data)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.data (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:data: ", p), err) } - return err -} - -func (p *RenamedStruct) String() string { - if p == nil { - return "" - } - - dataVal := fmt.Sprintf("%v", p.Data) - return fmt.Sprintf("RenamedStruct({Data:%s})", dataVal) -} - -// Attributes: -// - Data -type SameNamespaceStruct struct { - Data int64 `thrift:"data,1" db:"data" json:"data"` -} - -func NewSameNamespaceStruct() *SameNamespaceStruct { - return &SameNamespaceStruct{} -} - - -func (p *SameNamespaceStruct) GetData() int64 { - return p.Data -} -type SameNamespaceStructBuilder struct { - obj *SameNamespaceStruct -} - -func NewSameNamespaceStructBuilder() *SameNamespaceStructBuilder{ - return &SameNamespaceStructBuilder{ - obj: NewSameNamespaceStruct(), - } -} - -func (p SameNamespaceStructBuilder) Emit() *SameNamespaceStruct{ - return &SameNamespaceStruct{ - Data: p.obj.Data, - } -} - -func (s *SameNamespaceStructBuilder) Data(data int64) *SameNamespaceStructBuilder { - s.obj.Data = data - return s -} - -func (s *SameNamespaceStruct) SetData(data int64) *SameNamespaceStruct { - s.Data = data - return s -} - -func (p *SameNamespaceStruct) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *SameNamespaceStruct) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Data = v - } - return nil -} - -func (p *SameNamespaceStruct) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("SameNamespaceStruct"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *SameNamespaceStruct) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("data", thrift.I64, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:data: ", p), err) } - if err := oprot.WriteI64(int64(p.Data)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.data (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:data: ", p), err) } - return err -} - -func (p *SameNamespaceStruct) String() string { - if p == nil { - return "" - } - - dataVal := fmt.Sprintf("%v", p.Data) - return fmt.Sprintf("SameNamespaceStruct({Data:%s})", dataVal) -} - -type HeapAllocated struct { -} - -func NewHeapAllocated() *HeapAllocated { - return &HeapAllocated{} -} - -type HeapAllocatedBuilder struct { - obj *HeapAllocated -} - -func NewHeapAllocatedBuilder() *HeapAllocatedBuilder{ - return &HeapAllocatedBuilder{ - obj: NewHeapAllocated(), - } -} - -func (p HeapAllocatedBuilder) Emit() *HeapAllocated{ - return &HeapAllocated{ - } -} - -func (p *HeapAllocated) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *HeapAllocated) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("HeapAllocated"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *HeapAllocated) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("HeapAllocated({})") -} - -// Attributes: -// - Ptr -type MoveOnly struct { - Ptr *HeapAllocated `thrift:"ptr,1" db:"ptr" json:"ptr"` -} - -func NewMoveOnly() *MoveOnly { - return &MoveOnly{ - Ptr: NewHeapAllocated(), - } -} - -var MoveOnly_Ptr_DEFAULT *HeapAllocated -func (p *MoveOnly) GetPtr() *HeapAllocated { - if !p.IsSetPtr() { - return MoveOnly_Ptr_DEFAULT - } - return p.Ptr -} -func (p *MoveOnly) DefaultGetPtr() *HeapAllocated { - if !p.IsSetPtr() { - return NewHeapAllocated() - } - return p.Ptr -} -func (p *MoveOnly) IsSetPtr() bool { - return p != nil && p.Ptr != nil -} - -type MoveOnlyBuilder struct { - obj *MoveOnly -} - -func NewMoveOnlyBuilder() *MoveOnlyBuilder{ - return &MoveOnlyBuilder{ - obj: NewMoveOnly(), - } -} - -func (p MoveOnlyBuilder) Emit() *MoveOnly{ - return &MoveOnly{ - Ptr: p.obj.Ptr, - } -} - -func (m *MoveOnlyBuilder) Ptr(ptr *HeapAllocated) *MoveOnlyBuilder { - m.obj.Ptr = ptr - return m -} - -func (m *MoveOnly) SetPtr(ptr *HeapAllocated) *MoveOnly { - m.Ptr = ptr - return m -} - -func (p *MoveOnly) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MoveOnly) ReadField1(iprot thrift.Protocol) error { - p.Ptr = NewHeapAllocated() - if err := p.Ptr.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Ptr), err) - } - return nil -} - -func (p *MoveOnly) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("MoveOnly"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MoveOnly) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("ptr", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:ptr: ", p), err) } - if err := p.Ptr.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Ptr), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:ptr: ", p), err) } - return err -} - -func (p *MoveOnly) String() string { - if p == nil { - return "" - } - - var ptrVal string - if p.Ptr == nil { - ptrVal = "" - } else { - ptrVal = fmt.Sprintf("%v", p.Ptr) - } - return fmt.Sprintf("MoveOnly({Ptr:%s})", ptrVal) -} - -// Attributes: -// - Ptr -type AlsoMoveOnly struct { - Ptr int64 `thrift:"ptr,1" db:"ptr" json:"ptr"` -} - -func NewAlsoMoveOnly() *AlsoMoveOnly { - return &AlsoMoveOnly{} -} - - -func (p *AlsoMoveOnly) GetPtr() int64 { - return p.Ptr -} -type AlsoMoveOnlyBuilder struct { - obj *AlsoMoveOnly -} - -func NewAlsoMoveOnlyBuilder() *AlsoMoveOnlyBuilder{ - return &AlsoMoveOnlyBuilder{ - obj: NewAlsoMoveOnly(), - } -} - -func (p AlsoMoveOnlyBuilder) Emit() *AlsoMoveOnly{ - return &AlsoMoveOnly{ - Ptr: p.obj.Ptr, - } -} - -func (a *AlsoMoveOnlyBuilder) Ptr(ptr int64) *AlsoMoveOnlyBuilder { - a.obj.Ptr = ptr - return a -} - -func (a *AlsoMoveOnly) SetPtr(ptr int64) *AlsoMoveOnly { - a.Ptr = ptr - return a -} - -func (p *AlsoMoveOnly) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AlsoMoveOnly) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Ptr = v - } - return nil -} - -func (p *AlsoMoveOnly) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("AlsoMoveOnly"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *AlsoMoveOnly) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("ptr", thrift.I64, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:ptr: ", p), err) } - if err := oprot.WriteI64(int64(p.Ptr)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.ptr (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:ptr: ", p), err) } - return err -} - -func (p *AlsoMoveOnly) String() string { - if p == nil { - return "" - } - - ptrVal := fmt.Sprintf("%v", p.Ptr) - return fmt.Sprintf("AlsoMoveOnly({Ptr:%s})", ptrVal) -} - -type ApplyAdapter struct { -} - -func NewApplyAdapter() *ApplyAdapter { - return &ApplyAdapter{} -} - -type ApplyAdapterBuilder struct { - obj *ApplyAdapter -} - -func NewApplyAdapterBuilder() *ApplyAdapterBuilder{ - return &ApplyAdapterBuilder{ - obj: NewApplyAdapter(), - } -} - -func (p ApplyAdapterBuilder) Emit() *ApplyAdapter{ - return &ApplyAdapter{ - } -} - -func (p *ApplyAdapter) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ApplyAdapter) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("ApplyAdapter"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *ApplyAdapter) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("ApplyAdapter({})") -} - -type TransitiveAdapted struct { -} - -func NewTransitiveAdapted() *TransitiveAdapted { - return &TransitiveAdapted{} -} - -type TransitiveAdaptedBuilder struct { - obj *TransitiveAdapted -} - -func NewTransitiveAdaptedBuilder() *TransitiveAdaptedBuilder{ - return &TransitiveAdaptedBuilder{ - obj: NewTransitiveAdapted(), - } -} - -func (p TransitiveAdaptedBuilder) Emit() *TransitiveAdapted{ - return &TransitiveAdapted{ - } -} - -func (p *TransitiveAdapted) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *TransitiveAdapted) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("TransitiveAdapted"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *TransitiveAdapted) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("TransitiveAdapted({})") -} - -// Attributes: -// - RegularInt -// - CountingInt -// - RegularString -type CountingStruct struct { - RegularInt *int64 `thrift:"regularInt,1,optional" db:"regularInt" json:"regularInt,omitempty"` - CountingInt *CountingInt `thrift:"countingInt,2,optional" db:"countingInt" json:"countingInt,omitempty"` - RegularString *string `thrift:"regularString,3,optional" db:"regularString" json:"regularString,omitempty"` -} - -func NewCountingStruct() *CountingStruct { - return &CountingStruct{} -} - -var CountingStruct_RegularInt_DEFAULT int64 -func (p *CountingStruct) GetRegularInt() int64 { - if !p.IsSetRegularInt() { - return CountingStruct_RegularInt_DEFAULT - } - return *p.RegularInt -} -var CountingStruct_CountingInt_DEFAULT CountingInt -func (p *CountingStruct) GetCountingInt() CountingInt { - if !p.IsSetCountingInt() { - return CountingStruct_CountingInt_DEFAULT - } - return *p.CountingInt -} -var CountingStruct_RegularString_DEFAULT string -func (p *CountingStruct) GetRegularString() string { - if !p.IsSetRegularString() { - return CountingStruct_RegularString_DEFAULT - } - return *p.RegularString -} -func (p *CountingStruct) IsSetRegularInt() bool { - return p != nil && p.RegularInt != nil -} - -func (p *CountingStruct) IsSetCountingInt() bool { - return p != nil && p.CountingInt != nil -} - -func (p *CountingStruct) IsSetRegularString() bool { - return p != nil && p.RegularString != nil -} - -type CountingStructBuilder struct { - obj *CountingStruct -} - -func NewCountingStructBuilder() *CountingStructBuilder{ - return &CountingStructBuilder{ - obj: NewCountingStruct(), - } -} - -func (p CountingStructBuilder) Emit() *CountingStruct{ - return &CountingStruct{ - RegularInt: p.obj.RegularInt, - CountingInt: p.obj.CountingInt, - RegularString: p.obj.RegularString, - } -} - -func (c *CountingStructBuilder) RegularInt(regularInt *int64) *CountingStructBuilder { - c.obj.RegularInt = regularInt - return c -} - -func (c *CountingStructBuilder) CountingInt(countingInt *CountingInt) *CountingStructBuilder { - c.obj.CountingInt = countingInt - return c -} - -func (c *CountingStructBuilder) RegularString(regularString *string) *CountingStructBuilder { - c.obj.RegularString = regularString - return c -} - -func (c *CountingStruct) SetRegularInt(regularInt *int64) *CountingStruct { - c.RegularInt = regularInt - return c -} - -func (c *CountingStruct) SetCountingInt(countingInt *CountingInt) *CountingStruct { - c.CountingInt = countingInt - return c -} - -func (c *CountingStruct) SetRegularString(regularString *string) *CountingStruct { - c.RegularString = regularString - return c -} - -func (p *CountingStruct) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 3: - if err := p.ReadField3(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *CountingStruct) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.RegularInt = &v - } - return nil -} - -func (p *CountingStruct) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - temp := CountingInt(v) - p.CountingInt = &temp - } - return nil -} - -func (p *CountingStruct) ReadField3(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 3: ", err) - } else { - p.RegularString = &v - } - return nil -} - -func (p *CountingStruct) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("CountingStruct"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *CountingStruct) writeField1(oprot thrift.Protocol) (err error) { - if p.IsSetRegularInt() { - if err := oprot.WriteFieldBegin("regularInt", thrift.I64, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:regularInt: ", p), err) } - if err := oprot.WriteI64(int64(*p.RegularInt)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.regularInt (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:regularInt: ", p), err) } - } - return err -} - -func (p *CountingStruct) writeField2(oprot thrift.Protocol) (err error) { - if p.IsSetCountingInt() { - if err := oprot.WriteFieldBegin("countingInt", thrift.I64, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:countingInt: ", p), err) } - if err := oprot.WriteI64(int64(*p.CountingInt)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.countingInt (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:countingInt: ", p), err) } - } - return err -} - -func (p *CountingStruct) writeField3(oprot thrift.Protocol) (err error) { - if p.IsSetRegularString() { - if err := oprot.WriteFieldBegin("regularString", thrift.STRING, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:regularString: ", p), err) } - if err := oprot.WriteString(string(*p.RegularString)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.regularString (3) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:regularString: ", p), err) } - } - return err -} - -func (p *CountingStruct) String() string { - if p == nil { - return "" - } - - var regularIntVal string - if p.RegularInt == nil { - regularIntVal = "" - } else { - regularIntVal = fmt.Sprintf("%v", *p.RegularInt) - } - var countingIntVal string - if p.CountingInt == nil { - countingIntVal = "" - } else { - countingIntVal = fmt.Sprintf("%v", *p.CountingInt) - } - var regularStringVal string - if p.RegularString == nil { - regularStringVal = "" - } else { - regularStringVal = fmt.Sprintf("%v", *p.RegularString) - } - return fmt.Sprintf("CountingStruct({RegularInt:%s CountingInt:%s RegularString:%s})", regularIntVal, countingIntVal, regularStringVal) -} - -// Attributes: -// - Name -type Person struct { - Name string `thrift:"name,1" db:"name" json:"name"` -} - -func NewPerson() *Person { - return &Person{} -} - - -func (p *Person) GetName() string { - return p.Name -} -type PersonBuilder struct { - obj *Person -} - -func NewPersonBuilder() *PersonBuilder{ - return &PersonBuilder{ - obj: NewPerson(), - } -} - -func (p PersonBuilder) Emit() *Person{ - return &Person{ - Name: p.obj.Name, - } -} - -func (p *PersonBuilder) Name(name string) *PersonBuilder { - p.obj.Name = name - return p -} - -func (p *Person) SetName(name string) *Person { - p.Name = name - return p -} - -func (p *Person) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Person) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Name = v - } - return nil -} - -func (p *Person) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Person"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Person) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) } - if err := oprot.WriteString(string(p.Name)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) } - return err -} - -func (p *Person) String() string { - if p == nil { - return "" - } - - nameVal := fmt.Sprintf("%v", p.Name) - return fmt.Sprintf("Person({Name:%s})", nameVal) -} - -// Attributes: -// - Name -type Person2 struct { - Name string `thrift:"name,1" db:"name" json:"name"` -} - -func NewPerson2() *Person2 { - return &Person2{} -} - - -func (p *Person2) GetName() string { - return p.Name -} -type Person2Builder struct { - obj *Person2 -} - -func NewPerson2Builder() *Person2Builder{ - return &Person2Builder{ - obj: NewPerson2(), - } -} - -func (p Person2Builder) Emit() *Person2{ - return &Person2{ - Name: p.obj.Name, - } -} - -func (p *Person2Builder) Name(name string) *Person2Builder { - p.obj.Name = name - return p -} - -func (p *Person2) SetName(name string) *Person2 { - p.Name = name - return p -} - -func (p *Person2) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Person2) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Name = v - } - return nil -} - -func (p *Person2) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Person2"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Person2) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) } - if err := oprot.WriteString(string(p.Name)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) } - return err -} - -func (p *Person2) String() string { - if p == nil { - return "" - } - - nameVal := fmt.Sprintf("%v", p.Name) - return fmt.Sprintf("Person2({Name:%s})", nameVal) -} - diff --git a/thrift/compiler/test/fixtures/adapter/gen-go/thrift/annotation/cpp/constants.go b/thrift/compiler/test/fixtures/adapter/gen-go/thrift/annotation/cpp/constants.go deleted file mode 100644 index 966e368e2dd..00000000000 --- a/thrift/compiler/test/fixtures/adapter/gen-go/thrift/annotation/cpp/constants.go +++ /dev/null @@ -1,25 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package cpp - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - - -func init() { -} - diff --git a/thrift/compiler/test/fixtures/adapter/gen-go/thrift/annotation/cpp/ttypes.go b/thrift/compiler/test/fixtures/adapter/gen-go/thrift/annotation/cpp/ttypes.go deleted file mode 100644 index 209f29e21fd..00000000000 --- a/thrift/compiler/test/fixtures/adapter/gen-go/thrift/annotation/cpp/ttypes.go +++ /dev/null @@ -1,2188 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package cpp - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var GoUnusedProtection__ int; - -//Optional, defaults to Unique -type RefType int64 -const ( - RefType_Unique RefType = 0 - RefType_Shared RefType = 1 - RefType_SharedMutable RefType = 2 -) - -var RefTypeToName = map[RefType]string { - RefType_Unique: "Unique", - RefType_Shared: "Shared", - RefType_SharedMutable: "SharedMutable", -} - -var RefTypeToValue = map[string]RefType { - "Unique": RefType_Unique, - "Shared": RefType_Shared, - "SharedMutable": RefType_SharedMutable, -} - -var RefTypeNames = []string { - "Unique", - "Shared", - "SharedMutable", -} - -var RefTypeValues = []RefType { - RefType_Unique, - RefType_Shared, - RefType_SharedMutable, -} - -func (p RefType) String() string { - if v, ok := RefTypeToName[p]; ok { - return v - } - return "" -} - -func RefTypeFromString(s string) (RefType, error) { - if v, ok := RefTypeToValue[s]; ok { - return v, nil - } - return RefType(0), fmt.Errorf("not a valid RefType string") -} - -func RefTypePtr(v RefType) *RefType { return &v } - -//Enum in C++ by default uses signed 32 bit integer. There is no need to specify -//underlying type for signed 32 bit integer. -//64-bit is not supported to avoid truncation since enums are sent as 32-bit integers over the wire. -type EnumUnderlyingType int64 -const ( - EnumUnderlyingType_I8 EnumUnderlyingType = 0 - EnumUnderlyingType_U8 EnumUnderlyingType = 1 - EnumUnderlyingType_I16 EnumUnderlyingType = 2 - EnumUnderlyingType_U16 EnumUnderlyingType = 3 - EnumUnderlyingType_U32 EnumUnderlyingType = 4 -) - -var EnumUnderlyingTypeToName = map[EnumUnderlyingType]string { - EnumUnderlyingType_I8: "I8", - EnumUnderlyingType_U8: "U8", - EnumUnderlyingType_I16: "I16", - EnumUnderlyingType_U16: "U16", - EnumUnderlyingType_U32: "U32", -} - -var EnumUnderlyingTypeToValue = map[string]EnumUnderlyingType { - "I8": EnumUnderlyingType_I8, - "U8": EnumUnderlyingType_U8, - "I16": EnumUnderlyingType_I16, - "U16": EnumUnderlyingType_U16, - "U32": EnumUnderlyingType_U32, -} - -var EnumUnderlyingTypeNames = []string { - "I8", - "U8", - "I16", - "U16", - "U32", -} - -var EnumUnderlyingTypeValues = []EnumUnderlyingType { - EnumUnderlyingType_I8, - EnumUnderlyingType_U8, - EnumUnderlyingType_I16, - EnumUnderlyingType_U16, - EnumUnderlyingType_U32, -} - -func (p EnumUnderlyingType) String() string { - if v, ok := EnumUnderlyingTypeToName[p]; ok { - return v - } - return "" -} - -func EnumUnderlyingTypeFromString(s string) (EnumUnderlyingType, error) { - if v, ok := EnumUnderlyingTypeToValue[s]; ok { - return v, nil - } - return EnumUnderlyingType(0), fmt.Errorf("not a valid EnumUnderlyingType string") -} - -func EnumUnderlyingTypePtr(v EnumUnderlyingType) *EnumUnderlyingType { return &v } - -// Changes the native type of a Thrift object (the C++ type used in codegen) to the value of the `name` field. -// Container types may instead provide the `template` field, in which case template parameters will be filled in by thrift. -// (e.g. `template = "folly::sorted_vector_set"` is equivalent to `type = "folly::sorted_vector_set"` on `set`) -// -// It is also possible to add `cpp_include` to bring in additional data structures and use them here. -// It is required that the custom type matches the specified Thrift type even for internal container types. -// Prefer types that can leverage `reserve(size_t)` as Thrift makes uses these optimizations. -// *Special Case*: This annotation can be used to define a string/binary type as `IOBuf` or `unique_ptr` so that you can leverage Thrift's support for zero-copy buffer manipulation through `IOBuf`. -// During deserialization, thrift receives a buffer that is used to allocate the appropriate fields in the struct. When using smart pointers, instead of making a copy of the data, it only modifies the pointer to point to the address that is used by the buffer. -// -// The custom type must provide the following methods -// * `list`: `push_back(T)` -// * `map`: `insert(std::pair)` -// * `set`: `insert(T)` -// -// Attributes: -// - Name -// - Template -type Type struct { - Name string `thrift:"name,1" db:"name" json:"name"` - Template string `thrift:"template,2" db:"template" json:"template"` -} - -func NewType() *Type { - return &Type{} -} - - -func (p *Type) GetName() string { - return p.Name -} - -func (p *Type) GetTemplate() string { - return p.Template -} -type TypeBuilder struct { - obj *Type -} - -func NewTypeBuilder() *TypeBuilder{ - return &TypeBuilder{ - obj: NewType(), - } -} - -func (p TypeBuilder) Emit() *Type{ - return &Type{ - Name: p.obj.Name, - Template: p.obj.Template, - } -} - -func (t *TypeBuilder) Name(name string) *TypeBuilder { - t.obj.Name = name - return t -} - -func (t *TypeBuilder) Template(template string) *TypeBuilder { - t.obj.Template = template - return t -} - -func (t *Type) SetName(name string) *Type { - t.Name = name - return t -} - -func (t *Type) SetTemplate(template string) *Type { - t.Template = template - return t -} - -func (p *Type) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Type) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Name = v - } - return nil -} - -func (p *Type) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Template = v - } - return nil -} - -func (p *Type) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Type"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Type) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) } - if err := oprot.WriteString(string(p.Name)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) } - return err -} - -func (p *Type) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("template", thrift.STRING, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:template: ", p), err) } - if err := oprot.WriteString(string(p.Template)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.template (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:template: ", p), err) } - return err -} - -func (p *Type) String() string { - if p == nil { - return "" - } - - nameVal := fmt.Sprintf("%v", p.Name) - templateVal := fmt.Sprintf("%v", p.Template) - return fmt.Sprintf("Type({Name:%s Template:%s})", nameVal, templateVal) -} - -// Allocates a field on the heap instead of inline. -// This annotation is added to support recursive types. However, you can also use it to turn a field from a value to a smart pointer. -// `@cpp.Ref` is equivalent having type`@cpp.RefType.Unique`. -// -// NOTE: A struct may transitively contain itself as a field only if at least one of the fields in the inclusion chain is either an optional Ref field or a container. Otherwise the struct would have infinite size. -// -// Attributes: -// - Type -type Ref struct { - Type RefType `thrift:"type,1" db:"type" json:"type"` -} - -func NewRef() *Ref { - return &Ref{} -} - - -func (p *Ref) GetType() RefType { - return p.Type -} -type RefBuilder struct { - obj *Ref -} - -func NewRefBuilder() *RefBuilder{ - return &RefBuilder{ - obj: NewRef(), - } -} - -func (p RefBuilder) Emit() *Ref{ - return &Ref{ - Type: p.obj.Type, - } -} - -func (r *RefBuilder) Type(type_a1 RefType) *RefBuilder { - r.obj.Type = type_a1 - return r -} - -func (r *Ref) SetType(type_a1 RefType) *Ref { - r.Type = type_a1 - return r -} - -func (p *Ref) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Ref) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - temp := RefType(v) - p.Type = temp - } - return nil -} - -func (p *Ref) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Ref"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Ref) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("type", thrift.I32, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:type: ", p), err) } - if err := oprot.WriteI32(int32(p.Type)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.type (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:type: ", p), err) } - return err -} - -func (p *Ref) String() string { - if p == nil { - return "" - } - - typeVal := fmt.Sprintf("%v", p.Type) - return fmt.Sprintf("Ref({Type:%s})", typeVal) -} - -// Changes the name of the definition in generated C++ code. -// In most cases a much better solution is to rename the problematic Thrift field itself. Only use the `cpp.name` annotation if such renaming is problematic, -// e.g. when the field name appears in code as a string, particularly when using JSON serialization, and it is hard to change all usage sites. -// -// Attributes: -// - Value -type Name struct { - Value string `thrift:"value,1" db:"value" json:"value"` -} - -func NewName() *Name { - return &Name{} -} - - -func (p *Name) GetValue() string { - return p.Value -} -type NameBuilder struct { - obj *Name -} - -func NewNameBuilder() *NameBuilder{ - return &NameBuilder{ - obj: NewName(), - } -} - -func (p NameBuilder) Emit() *Name{ - return &Name{ - Value: p.obj.Value, - } -} - -func (n *NameBuilder) Value(value string) *NameBuilder { - n.obj.Value = value - return n -} - -func (n *Name) SetValue(value string) *Name { - n.Value = value - return n -} - -func (p *Name) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Name) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Value = v - } - return nil -} - -func (p *Name) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Name"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Name) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("value", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:value: ", p), err) } - if err := oprot.WriteString(string(p.Value)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.value (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:value: ", p), err) } - return err -} - -func (p *Name) String() string { - if p == nil { - return "" - } - - valueVal := fmt.Sprintf("%v", p.Value) - return fmt.Sprintf("Name({Value:%s})", valueVal) -} - -// Lazily deserialize large field on first access. -// -// ``` -// FooWithLazyField foo; -// apache::thrift::CompactSerializer::deserialize(serializedData, foo); -// -// // large_field is lazy field, it will be deserialized on first access -// // The data will be deserialized in method call large_field_ref() -// LOG(INFO) << foo.large_field_ref()->size(); -// -// // Result will be cached, we won't deserialize again -// LOG(INFO) << foo.large_field_ref()->size(); -// ``` -// -// Read more: /doc/fb/languages/cpp/lazy.md -// -// Attributes: -// - Ref -type Lazy struct { - Ref bool `thrift:"ref,1" db:"ref" json:"ref"` -} - -func NewLazy() *Lazy { - return &Lazy{} -} - - -func (p *Lazy) GetRef() bool { - return p.Ref -} -type LazyBuilder struct { - obj *Lazy -} - -func NewLazyBuilder() *LazyBuilder{ - return &LazyBuilder{ - obj: NewLazy(), - } -} - -func (p LazyBuilder) Emit() *Lazy{ - return &Lazy{ - Ref: p.obj.Ref, - } -} - -func (l *LazyBuilder) Ref(ref bool) *LazyBuilder { - l.obj.Ref = ref - return l -} - -func (l *Lazy) SetRef(ref bool) *Lazy { - l.Ref = ref - return l -} - -func (p *Lazy) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Lazy) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Ref = v - } - return nil -} - -func (p *Lazy) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Lazy"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Lazy) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("ref", thrift.BOOL, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:ref: ", p), err) } - if err := oprot.WriteBool(bool(p.Ref)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.ref (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:ref: ", p), err) } - return err -} - -func (p *Lazy) String() string { - if p == nil { - return "" - } - - refVal := fmt.Sprintf("%v", p.Ref) - return fmt.Sprintf("Lazy({Ref:%s})", refVal) -} - -type DisableLazyChecksum struct { -} - -func NewDisableLazyChecksum() *DisableLazyChecksum { - return &DisableLazyChecksum{} -} - -type DisableLazyChecksumBuilder struct { - obj *DisableLazyChecksum -} - -func NewDisableLazyChecksumBuilder() *DisableLazyChecksumBuilder{ - return &DisableLazyChecksumBuilder{ - obj: NewDisableLazyChecksum(), - } -} - -func (p DisableLazyChecksumBuilder) Emit() *DisableLazyChecksum{ - return &DisableLazyChecksum{ - } -} - -func (p *DisableLazyChecksum) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *DisableLazyChecksum) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("DisableLazyChecksum"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *DisableLazyChecksum) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("DisableLazyChecksum({})") -} - -// An annotation that applies a C++ adapter to typedef, field, or struct. -// -// For example: -// -// @cpp.Adapter{name = "::ns::IdAdapter"} -// typedef i64 MyI64; -// -// Here the type `MyI64` has the C++ adapter `IdAdapter`. -// -// struct User { -// @cpp.Adapter{name = "::ns::IdAdapter"} -// 1: i64 id; -// } -// -// Here the field `id` has the C++ adapter `IdAdapter`. -// -// Attributes: -// - Name: The name of a C++ adapter type used to convert between Thrift and native -// C++ representation. -// -// The adapter can be either a Type or Field adapter, providing either of the following APIs: -// -// struct ThriftTypeAdapter { -// static AdaptedType fromThrift(ThriftType thrift); -// static {const ThriftType& | ThriftType} toThrift(const AdaptedType& native); -// }; -// -// struct ThriftFieldAdapter { -// // Context is an instantiation of apache::thrift::FieldContext -// template -// static void construct(AdaptedType& field, Context ctx); -// -// template -// static AdaptedType fromThriftField(ThriftType value, Context ctx); -// -// template -// static {const ThriftType& | ThriftType} toThrift(const AdaptedType& adapted, Context ctx); -// }; -// - AdaptedType: It is sometimes necessary to specify AdaptedType here (in case the codegen would -// have a circular depdenceny, which will cause the C++ build to fail). -// - UnderlyingName: The name and/or extra namespace to use when directly adapting a type -// (as opposed a typedef). -// -// In this case, the IDL name of the type will refer to the adapted type in -// C++ and the underlying thrift type will be generated in a nested -// namespace and/or with a different name. -// -// If neither `underlyingName` or `extraNamespace` is provided, the -// underlying type will be generated in a nested 'detail' namespace with -// the same name. -// - ExtraNamespace -// - MoveOnly: Must set to true when adapted type is not copyable. -type Adapter struct { - Name string `thrift:"name,1" db:"name" json:"name"` - AdaptedType string `thrift:"adaptedType,2" db:"adaptedType" json:"adaptedType"` - UnderlyingName string `thrift:"underlyingName,3" db:"underlyingName" json:"underlyingName"` - ExtraNamespace string `thrift:"extraNamespace,4" db:"extraNamespace" json:"extraNamespace"` - MoveOnly bool `thrift:"moveOnly,5" db:"moveOnly" json:"moveOnly"` -} - -func NewAdapter() *Adapter { - return &Adapter{} -} - - -func (p *Adapter) GetName() string { - return p.Name -} - -func (p *Adapter) GetAdaptedType() string { - return p.AdaptedType -} - -func (p *Adapter) GetUnderlyingName() string { - return p.UnderlyingName -} - -func (p *Adapter) GetExtraNamespace() string { - return p.ExtraNamespace -} - -func (p *Adapter) GetMoveOnly() bool { - return p.MoveOnly -} -type AdapterBuilder struct { - obj *Adapter -} - -func NewAdapterBuilder() *AdapterBuilder{ - return &AdapterBuilder{ - obj: NewAdapter(), - } -} - -func (p AdapterBuilder) Emit() *Adapter{ - return &Adapter{ - Name: p.obj.Name, - AdaptedType: p.obj.AdaptedType, - UnderlyingName: p.obj.UnderlyingName, - ExtraNamespace: p.obj.ExtraNamespace, - MoveOnly: p.obj.MoveOnly, - } -} - -func (a *AdapterBuilder) Name(name string) *AdapterBuilder { - a.obj.Name = name - return a -} - -func (a *AdapterBuilder) AdaptedType(adaptedType string) *AdapterBuilder { - a.obj.AdaptedType = adaptedType - return a -} - -func (a *AdapterBuilder) UnderlyingName(underlyingName string) *AdapterBuilder { - a.obj.UnderlyingName = underlyingName - return a -} - -func (a *AdapterBuilder) ExtraNamespace(extraNamespace string) *AdapterBuilder { - a.obj.ExtraNamespace = extraNamespace - return a -} - -func (a *AdapterBuilder) MoveOnly(moveOnly bool) *AdapterBuilder { - a.obj.MoveOnly = moveOnly - return a -} - -func (a *Adapter) SetName(name string) *Adapter { - a.Name = name - return a -} - -func (a *Adapter) SetAdaptedType(adaptedType string) *Adapter { - a.AdaptedType = adaptedType - return a -} - -func (a *Adapter) SetUnderlyingName(underlyingName string) *Adapter { - a.UnderlyingName = underlyingName - return a -} - -func (a *Adapter) SetExtraNamespace(extraNamespace string) *Adapter { - a.ExtraNamespace = extraNamespace - return a -} - -func (a *Adapter) SetMoveOnly(moveOnly bool) *Adapter { - a.MoveOnly = moveOnly - return a -} - -func (p *Adapter) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 3: - if err := p.ReadField3(iprot); err != nil { - return err - } - case 4: - if err := p.ReadField4(iprot); err != nil { - return err - } - case 5: - if err := p.ReadField5(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Adapter) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Name = v - } - return nil -} - -func (p *Adapter) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.AdaptedType = v - } - return nil -} - -func (p *Adapter) ReadField3(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 3: ", err) - } else { - p.UnderlyingName = v - } - return nil -} - -func (p *Adapter) ReadField4(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 4: ", err) - } else { - p.ExtraNamespace = v - } - return nil -} - -func (p *Adapter) ReadField5(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 5: ", err) - } else { - p.MoveOnly = v - } - return nil -} - -func (p *Adapter) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Adapter"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := p.writeField4(oprot); err != nil { return err } - if err := p.writeField5(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Adapter) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) } - if err := oprot.WriteString(string(p.Name)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) } - return err -} - -func (p *Adapter) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("adaptedType", thrift.STRING, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:adaptedType: ", p), err) } - if err := oprot.WriteString(string(p.AdaptedType)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.adaptedType (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:adaptedType: ", p), err) } - return err -} - -func (p *Adapter) writeField3(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("underlyingName", thrift.STRING, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:underlyingName: ", p), err) } - if err := oprot.WriteString(string(p.UnderlyingName)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.underlyingName (3) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:underlyingName: ", p), err) } - return err -} - -func (p *Adapter) writeField4(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("extraNamespace", thrift.STRING, 4); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:extraNamespace: ", p), err) } - if err := oprot.WriteString(string(p.ExtraNamespace)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.extraNamespace (4) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 4:extraNamespace: ", p), err) } - return err -} - -func (p *Adapter) writeField5(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("moveOnly", thrift.BOOL, 5); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:moveOnly: ", p), err) } - if err := oprot.WriteBool(bool(p.MoveOnly)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.moveOnly (5) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 5:moveOnly: ", p), err) } - return err -} - -func (p *Adapter) String() string { - if p == nil { - return "" - } - - nameVal := fmt.Sprintf("%v", p.Name) - adaptedTypeVal := fmt.Sprintf("%v", p.AdaptedType) - underlyingNameVal := fmt.Sprintf("%v", p.UnderlyingName) - extraNamespaceVal := fmt.Sprintf("%v", p.ExtraNamespace) - moveOnlyVal := fmt.Sprintf("%v", p.MoveOnly) - return fmt.Sprintf("Adapter({Name:%s AdaptedType:%s UnderlyingName:%s ExtraNamespace:%s MoveOnly:%s})", nameVal, adaptedTypeVal, underlyingNameVal, extraNamespaceVal, moveOnlyVal) -} - -// Packs isset bits into fewer bytes to save space at the cost of making access more expensive. -// Passing `atomic = false` reduces the access cost while making concurrent writes UB. -// Read more: /doc/fb/languages/cpp/isset-bitpacking.md -// -// Attributes: -// - Atomic -type PackIsset struct { - Atomic bool `thrift:"atomic,1" db:"atomic" json:"atomic"` -} - -func NewPackIsset() *PackIsset { - return &PackIsset{ - Atomic: true, - } -} - - -func (p *PackIsset) GetAtomic() bool { - return p.Atomic -} -type PackIssetBuilder struct { - obj *PackIsset -} - -func NewPackIssetBuilder() *PackIssetBuilder{ - return &PackIssetBuilder{ - obj: NewPackIsset(), - } -} - -func (p PackIssetBuilder) Emit() *PackIsset{ - return &PackIsset{ - Atomic: p.obj.Atomic, - } -} - -func (p *PackIssetBuilder) Atomic(atomic bool) *PackIssetBuilder { - p.obj.Atomic = atomic - return p -} - -func (p *PackIsset) SetAtomic(atomic bool) *PackIsset { - p.Atomic = atomic - return p -} - -func (p *PackIsset) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *PackIsset) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Atomic = v - } - return nil -} - -func (p *PackIsset) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("PackIsset"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *PackIsset) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("atomic", thrift.BOOL, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:atomic: ", p), err) } - if err := oprot.WriteBool(bool(p.Atomic)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.atomic (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:atomic: ", p), err) } - return err -} - -func (p *PackIsset) String() string { - if p == nil { - return "" - } - - atomicVal := fmt.Sprintf("%v", p.Atomic) - return fmt.Sprintf("PackIsset({Atomic:%s})", atomicVal) -} - -// This annotation enables reordering of fields in the generated C++ struct to minimize padding. -// This is achieved by placing the fields in the order of decreasing alignments. The order of fields with the same alignment is preserved. -// -// ``` -// @cpp.MinimizePadding -// struct Padded { -// 1: byte small -// 2: i64 big -// 3: i16 medium -// 4: i32 biggish -// 5: byte tiny -// } -// ``` -// -// For example, the C++ fields for the `Padded` Thrift struct above will be generated in the following order: -// -// ``` -// int64_t big; -// int32_t biggish; -// int16_t medium; -// int8_t small; -// int8_t tiny; -// ``` -// -// which gives the size of 16 bytes compared to 32 bytes if `cpp.MinimizePadding` was not specified. -type MinimizePadding struct { -} - -func NewMinimizePadding() *MinimizePadding { - return &MinimizePadding{} -} - -type MinimizePaddingBuilder struct { - obj *MinimizePadding -} - -func NewMinimizePaddingBuilder() *MinimizePaddingBuilder{ - return &MinimizePaddingBuilder{ - obj: NewMinimizePadding(), - } -} - -func (p MinimizePaddingBuilder) Emit() *MinimizePadding{ - return &MinimizePadding{ - } -} - -func (p *MinimizePadding) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MinimizePadding) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("MinimizePadding"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MinimizePadding) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("MinimizePadding({})") -} - -type TriviallyRelocatable struct { -} - -func NewTriviallyRelocatable() *TriviallyRelocatable { - return &TriviallyRelocatable{} -} - -type TriviallyRelocatableBuilder struct { - obj *TriviallyRelocatable -} - -func NewTriviallyRelocatableBuilder() *TriviallyRelocatableBuilder{ - return &TriviallyRelocatableBuilder{ - obj: NewTriviallyRelocatable(), - } -} - -func (p TriviallyRelocatableBuilder) Emit() *TriviallyRelocatable{ - return &TriviallyRelocatable{ - } -} - -func (p *TriviallyRelocatable) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *TriviallyRelocatable) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("TriviallyRelocatable"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *TriviallyRelocatable) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("TriviallyRelocatable({})") -} - -type ScopedEnumAsUnionType struct { -} - -func NewScopedEnumAsUnionType() *ScopedEnumAsUnionType { - return &ScopedEnumAsUnionType{} -} - -type ScopedEnumAsUnionTypeBuilder struct { - obj *ScopedEnumAsUnionType -} - -func NewScopedEnumAsUnionTypeBuilder() *ScopedEnumAsUnionTypeBuilder{ - return &ScopedEnumAsUnionTypeBuilder{ - obj: NewScopedEnumAsUnionType(), - } -} - -func (p ScopedEnumAsUnionTypeBuilder) Emit() *ScopedEnumAsUnionType{ - return &ScopedEnumAsUnionType{ - } -} - -func (p *ScopedEnumAsUnionType) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ScopedEnumAsUnionType) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("ScopedEnumAsUnionType"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *ScopedEnumAsUnionType) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("ScopedEnumAsUnionType({})") -} - -// Indicates a typedef should be 'strong', and require an explicit cast to -// the underlying type. -// -// Currently only works for integer typedefs, for example: -// -// @cpp.StrongType -// typedef i32 MyId; -// -// Will cause an enum class to be used instead of a typedef in the genearte code, for example: -// -// enum class MyId : ::std::int32_t {}; -// -type StrongType struct { -} - -func NewStrongType() *StrongType { - return &StrongType{} -} - -type StrongTypeBuilder struct { - obj *StrongType -} - -func NewStrongTypeBuilder() *StrongTypeBuilder{ - return &StrongTypeBuilder{ - obj: NewStrongType(), - } -} - -func (p StrongTypeBuilder) Emit() *StrongType{ - return &StrongType{ - } -} - -func (p *StrongType) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *StrongType) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("StrongType"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *StrongType) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("StrongType({})") -} - -// An annotation that intercepts field access with C++ field interceptor. -// Use with *caution* since this may introduce substantial performance overhead on each field access. -// -// For example: -// -// struct Foo { -// @cpp.FieldInterceptor{name = "MyFieldInterceptor"} -// 1: i64 id; -// } -// -// The field interceptor `MyFieldInterceptor` will intercept with `interceptThriftFieldAccess` -// when the field `id` is accessed. -// -// Attributes: -// - Name: The name of a field interceptor. -// -// The field interceptor provides the following API: -// -// struct ThriftFieldInterceptor { -// template -// static void interceptThriftFieldAccess(T&& field, -// apache::thrift::FieldContext&& ctx); -// }; -// -// The field interceptor intercepts with the field value and the field context. -// It enforces an easily searchable function name `interceptThriftFieldAccess`. -// - Noinline: Setting to true makes compiler not inline and erase function signature for -// the intercepting field accessor. -type FieldInterceptor struct { - Name string `thrift:"name,1" db:"name" json:"name"` - Noinline bool `thrift:"noinline,2" db:"noinline" json:"noinline"` -} - -func NewFieldInterceptor() *FieldInterceptor { - return &FieldInterceptor{} -} - - -func (p *FieldInterceptor) GetName() string { - return p.Name -} - -func (p *FieldInterceptor) GetNoinline() bool { - return p.Noinline -} -type FieldInterceptorBuilder struct { - obj *FieldInterceptor -} - -func NewFieldInterceptorBuilder() *FieldInterceptorBuilder{ - return &FieldInterceptorBuilder{ - obj: NewFieldInterceptor(), - } -} - -func (p FieldInterceptorBuilder) Emit() *FieldInterceptor{ - return &FieldInterceptor{ - Name: p.obj.Name, - Noinline: p.obj.Noinline, - } -} - -func (f *FieldInterceptorBuilder) Name(name string) *FieldInterceptorBuilder { - f.obj.Name = name - return f -} - -func (f *FieldInterceptorBuilder) Noinline(noinline bool) *FieldInterceptorBuilder { - f.obj.Noinline = noinline - return f -} - -func (f *FieldInterceptor) SetName(name string) *FieldInterceptor { - f.Name = name - return f -} - -func (f *FieldInterceptor) SetNoinline(noinline bool) *FieldInterceptor { - f.Noinline = noinline - return f -} - -func (p *FieldInterceptor) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *FieldInterceptor) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Name = v - } - return nil -} - -func (p *FieldInterceptor) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Noinline = v - } - return nil -} - -func (p *FieldInterceptor) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("FieldInterceptor"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *FieldInterceptor) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) } - if err := oprot.WriteString(string(p.Name)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) } - return err -} - -func (p *FieldInterceptor) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("noinline", thrift.BOOL, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:noinline: ", p), err) } - if err := oprot.WriteBool(bool(p.Noinline)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.noinline (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:noinline: ", p), err) } - return err -} - -func (p *FieldInterceptor) String() string { - if p == nil { - return "" - } - - nameVal := fmt.Sprintf("%v", p.Name) - noinlineVal := fmt.Sprintf("%v", p.Noinline) - return fmt.Sprintf("FieldInterceptor({Name:%s Noinline:%s})", nameVal, noinlineVal) -} - -type UseOpEncode struct { -} - -func NewUseOpEncode() *UseOpEncode { - return &UseOpEncode{} -} - -type UseOpEncodeBuilder struct { - obj *UseOpEncode -} - -func NewUseOpEncodeBuilder() *UseOpEncodeBuilder{ - return &UseOpEncodeBuilder{ - obj: NewUseOpEncode(), - } -} - -func (p UseOpEncodeBuilder) Emit() *UseOpEncode{ - return &UseOpEncode{ - } -} - -func (p *UseOpEncode) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *UseOpEncode) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("UseOpEncode"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *UseOpEncode) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("UseOpEncode({})") -} - -// Indicates an integer type for C++ to use as the underlying type of enum, for example: -// -// @cpp.EnumType{type = cpp.EnumUnderlyingType.I8} -// enum Fruit { -// Apple = 0, -// Banana = 1, -// } -// -// will be generated into the following: -// -// enum class Fruit : ::std::int8_t { -// Apple = 0, -// Banana = 1, -// }; -// -// -// Attributes: -// - Type -type EnumType struct { - Type EnumUnderlyingType `thrift:"type,1" db:"type" json:"type"` -} - -func NewEnumType() *EnumType { - return &EnumType{} -} - - -func (p *EnumType) GetType() EnumUnderlyingType { - return p.Type -} -type EnumTypeBuilder struct { - obj *EnumType -} - -func NewEnumTypeBuilder() *EnumTypeBuilder{ - return &EnumTypeBuilder{ - obj: NewEnumType(), - } -} - -func (p EnumTypeBuilder) Emit() *EnumType{ - return &EnumType{ - Type: p.obj.Type, - } -} - -func (e *EnumTypeBuilder) Type(type_a1 EnumUnderlyingType) *EnumTypeBuilder { - e.obj.Type = type_a1 - return e -} - -func (e *EnumType) SetType(type_a1 EnumUnderlyingType) *EnumType { - e.Type = type_a1 - return e -} - -func (p *EnumType) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *EnumType) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - temp := EnumUnderlyingType(v) - p.Type = temp - } - return nil -} - -func (p *EnumType) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("EnumType"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *EnumType) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("type", thrift.I32, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:type: ", p), err) } - if err := oprot.WriteI32(int32(p.Type)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.type (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:type: ", p), err) } - return err -} - -func (p *EnumType) String() string { - if p == nil { - return "" - } - - typeVal := fmt.Sprintf("%v", p.Type) - return fmt.Sprintf("EnumType({Type:%s})", typeVal) -} - -// Indicates that frozen types should not be generated for a given struct. -type Frozen2Exclude struct { -} - -func NewFrozen2Exclude() *Frozen2Exclude { - return &Frozen2Exclude{} -} - -type Frozen2ExcludeBuilder struct { - obj *Frozen2Exclude -} - -func NewFrozen2ExcludeBuilder() *Frozen2ExcludeBuilder{ - return &Frozen2ExcludeBuilder{ - obj: NewFrozen2Exclude(), - } -} - -func (p Frozen2ExcludeBuilder) Emit() *Frozen2Exclude{ - return &Frozen2Exclude{ - } -} - -func (p *Frozen2Exclude) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Frozen2Exclude) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Frozen2Exclude"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Frozen2Exclude) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Frozen2Exclude({})") -} - -// Indicates that the container params must be complete at the time this type is instantiated. -// Only required in rare cases where the build fails with a frozen-related assert failure. -type Frozen2RequiresCompleteContainerParams struct { -} - -func NewFrozen2RequiresCompleteContainerParams() *Frozen2RequiresCompleteContainerParams { - return &Frozen2RequiresCompleteContainerParams{} -} - -type Frozen2RequiresCompleteContainerParamsBuilder struct { - obj *Frozen2RequiresCompleteContainerParams -} - -func NewFrozen2RequiresCompleteContainerParamsBuilder() *Frozen2RequiresCompleteContainerParamsBuilder{ - return &Frozen2RequiresCompleteContainerParamsBuilder{ - obj: NewFrozen2RequiresCompleteContainerParams(), - } -} - -func (p Frozen2RequiresCompleteContainerParamsBuilder) Emit() *Frozen2RequiresCompleteContainerParams{ - return &Frozen2RequiresCompleteContainerParams{ - } -} - -func (p *Frozen2RequiresCompleteContainerParams) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Frozen2RequiresCompleteContainerParams) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Frozen2RequiresCompleteContainerParams"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Frozen2RequiresCompleteContainerParams) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Frozen2RequiresCompleteContainerParams({})") -} - -// Generates typed interceptor stubs that can be overriden by user, -// and adorn the handler methods. This can be used on individual functions -// or on services (equivalent to adding it to all functions). -// -// service MyService { -// @cpp.GenerateTypedInterceptor -// void ping(); -// } -// -// This will generate the following interface: -// -// class TypedInterceptor { -// TypeErasedStorage before_ping(); -// TypeErasedStorage after_ping(); -// } -// -type GenerateTypedInterceptor struct { -} - -func NewGenerateTypedInterceptor() *GenerateTypedInterceptor { - return &GenerateTypedInterceptor{} -} - -type GenerateTypedInterceptorBuilder struct { - obj *GenerateTypedInterceptor -} - -func NewGenerateTypedInterceptorBuilder() *GenerateTypedInterceptorBuilder{ - return &GenerateTypedInterceptorBuilder{ - obj: NewGenerateTypedInterceptor(), - } -} - -func (p GenerateTypedInterceptorBuilder) Emit() *GenerateTypedInterceptor{ - return &GenerateTypedInterceptor{ - } -} - -func (p *GenerateTypedInterceptor) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *GenerateTypedInterceptor) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("GenerateTypedInterceptor"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *GenerateTypedInterceptor) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("GenerateTypedInterceptor({})") -} - -// Causes C++ handler code to run inline on the EventBase thread. -// Disables overload protection, use with caution. -// Cannot be applied to individual functions in interactions. -// -// Causes the request to be executed on the event base thread directly instead of rescheduling onto a thread manager thread, provided the async_eb_ handler method is implemented. -// You should only execute the request on the event base thread if it is very fast and you have measured that rescheduling is a substantial chunk of your service's CPU usage. -// If a request executing on the event base thread blocks or takes a long time, all other requests sharing the same event base are affected and latency will increase significantly. -// We strongly discourage the use of this annotation unless strictly necessary. You will have to implement the harder-to-use async_eb_ handler method. -// This also disables queue timeouts, an important form of overload protection. -type ProcessInEbThreadUnsafe struct { -} - -func NewProcessInEbThreadUnsafe() *ProcessInEbThreadUnsafe { - return &ProcessInEbThreadUnsafe{} -} - -type ProcessInEbThreadUnsafeBuilder struct { - obj *ProcessInEbThreadUnsafe -} - -func NewProcessInEbThreadUnsafeBuilder() *ProcessInEbThreadUnsafeBuilder{ - return &ProcessInEbThreadUnsafeBuilder{ - obj: NewProcessInEbThreadUnsafe(), - } -} - -func (p ProcessInEbThreadUnsafeBuilder) Emit() *ProcessInEbThreadUnsafe{ - return &ProcessInEbThreadUnsafe{ - } -} - -func (p *ProcessInEbThreadUnsafe) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ProcessInEbThreadUnsafe) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("ProcessInEbThreadUnsafe"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *ProcessInEbThreadUnsafe) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("ProcessInEbThreadUnsafe({})") -} - -// Applies to structured annotation that need to be accessed in Runtime. -type RuntimeAnnotation struct { -} - -func NewRuntimeAnnotation() *RuntimeAnnotation { - return &RuntimeAnnotation{} -} - -type RuntimeAnnotationBuilder struct { - obj *RuntimeAnnotation -} - -func NewRuntimeAnnotationBuilder() *RuntimeAnnotationBuilder{ - return &RuntimeAnnotationBuilder{ - obj: NewRuntimeAnnotation(), - } -} - -func (p RuntimeAnnotationBuilder) Emit() *RuntimeAnnotation{ - return &RuntimeAnnotation{ - } -} - -func (p *RuntimeAnnotation) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *RuntimeAnnotation) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("RuntimeAnnotation"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *RuntimeAnnotation) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("RuntimeAnnotation({})") -} - diff --git a/thrift/compiler/test/fixtures/adapter/gen-go/thrift/annotation/hack/constants.go b/thrift/compiler/test/fixtures/adapter/gen-go/thrift/annotation/hack/constants.go deleted file mode 100644 index 4054b104418..00000000000 --- a/thrift/compiler/test/fixtures/adapter/gen-go/thrift/annotation/hack/constants.go +++ /dev/null @@ -1,25 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package hack - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - - -func init() { -} - diff --git a/thrift/compiler/test/fixtures/adapter/gen-go/thrift/annotation/hack/ttypes.go b/thrift/compiler/test/fixtures/adapter/gen-go/thrift/annotation/hack/ttypes.go deleted file mode 100644 index 4d27cf73b43..00000000000 --- a/thrift/compiler/test/fixtures/adapter/gen-go/thrift/annotation/hack/ttypes.go +++ /dev/null @@ -1,1315 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package hack - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var GoUnusedProtection__ int; - -// An experimental annotation that applies a Hack wrapper to fields. -// For example: -// -// struct User { -// @hack.FieldWrapper{name="MyWrapper"} -// 1: i64 id; -// } -// -// Attributes: -// - Name: The name of a Hack wrapper class used to wrap the field -type FieldWrapper struct { - Name string `thrift:"name,1" db:"name" json:"name"` -} - -func NewFieldWrapper() *FieldWrapper { - return &FieldWrapper{} -} - - -func (p *FieldWrapper) GetName() string { - return p.Name -} -type FieldWrapperBuilder struct { - obj *FieldWrapper -} - -func NewFieldWrapperBuilder() *FieldWrapperBuilder{ - return &FieldWrapperBuilder{ - obj: NewFieldWrapper(), - } -} - -func (p FieldWrapperBuilder) Emit() *FieldWrapper{ - return &FieldWrapper{ - Name: p.obj.Name, - } -} - -func (f *FieldWrapperBuilder) Name(name string) *FieldWrapperBuilder { - f.obj.Name = name - return f -} - -func (f *FieldWrapper) SetName(name string) *FieldWrapper { - f.Name = name - return f -} - -func (p *FieldWrapper) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *FieldWrapper) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Name = v - } - return nil -} - -func (p *FieldWrapper) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("FieldWrapper"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *FieldWrapper) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) } - if err := oprot.WriteString(string(p.Name)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) } - return err -} - -func (p *FieldWrapper) String() string { - if p == nil { - return "" - } - - nameVal := fmt.Sprintf("%v", p.Name) - return fmt.Sprintf("FieldWrapper({Name:%s})", nameVal) -} - -// An annotation that applies a Hack wrapper to fields, typedef or structs. -// For example: -// -// struct User { -// @hack.FieldWrapper{name="MyWrapper"} -// 1: i64 id; -// } -// -// Attributes: -// - Name: The name of a Hack wrapper class used to wrap the field -// - UnderlyingName: When applied directly to a typedef or struct, the IDL name of the -// type will refer to the adapted type in Hack and the underlying thrift struct will be -// generated in a nested namespace and/or with a different name. By default the type/struct -// will be generated in a nested 'thrift_adapted_types' namespace with the same name, -// but both of these can be changed by setting these fields. -// Empty string enables the nested namespace and uses the IDL name for the struct. -// - ExtraNamespace -type Wrapper struct { - Name string `thrift:"name,1" db:"name" json:"name"` - UnderlyingName string `thrift:"underlyingName,2" db:"underlyingName" json:"underlyingName"` - ExtraNamespace string `thrift:"extraNamespace,3" db:"extraNamespace" json:"extraNamespace"` -} - -func NewWrapper() *Wrapper { - return &Wrapper{ - ExtraNamespace: "thrift_adapted_types", - } -} - - -func (p *Wrapper) GetName() string { - return p.Name -} - -func (p *Wrapper) GetUnderlyingName() string { - return p.UnderlyingName -} - -func (p *Wrapper) GetExtraNamespace() string { - return p.ExtraNamespace -} -type WrapperBuilder struct { - obj *Wrapper -} - -func NewWrapperBuilder() *WrapperBuilder{ - return &WrapperBuilder{ - obj: NewWrapper(), - } -} - -func (p WrapperBuilder) Emit() *Wrapper{ - return &Wrapper{ - Name: p.obj.Name, - UnderlyingName: p.obj.UnderlyingName, - ExtraNamespace: p.obj.ExtraNamespace, - } -} - -func (w *WrapperBuilder) Name(name string) *WrapperBuilder { - w.obj.Name = name - return w -} - -func (w *WrapperBuilder) UnderlyingName(underlyingName string) *WrapperBuilder { - w.obj.UnderlyingName = underlyingName - return w -} - -func (w *WrapperBuilder) ExtraNamespace(extraNamespace string) *WrapperBuilder { - w.obj.ExtraNamespace = extraNamespace - return w -} - -func (w *Wrapper) SetName(name string) *Wrapper { - w.Name = name - return w -} - -func (w *Wrapper) SetUnderlyingName(underlyingName string) *Wrapper { - w.UnderlyingName = underlyingName - return w -} - -func (w *Wrapper) SetExtraNamespace(extraNamespace string) *Wrapper { - w.ExtraNamespace = extraNamespace - return w -} - -func (p *Wrapper) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 3: - if err := p.ReadField3(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Wrapper) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Name = v - } - return nil -} - -func (p *Wrapper) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.UnderlyingName = v - } - return nil -} - -func (p *Wrapper) ReadField3(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 3: ", err) - } else { - p.ExtraNamespace = v - } - return nil -} - -func (p *Wrapper) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Wrapper"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Wrapper) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) } - if err := oprot.WriteString(string(p.Name)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) } - return err -} - -func (p *Wrapper) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("underlyingName", thrift.STRING, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:underlyingName: ", p), err) } - if err := oprot.WriteString(string(p.UnderlyingName)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.underlyingName (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:underlyingName: ", p), err) } - return err -} - -func (p *Wrapper) writeField3(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("extraNamespace", thrift.STRING, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:extraNamespace: ", p), err) } - if err := oprot.WriteString(string(p.ExtraNamespace)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.extraNamespace (3) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:extraNamespace: ", p), err) } - return err -} - -func (p *Wrapper) String() string { - if p == nil { - return "" - } - - nameVal := fmt.Sprintf("%v", p.Name) - underlyingNameVal := fmt.Sprintf("%v", p.UnderlyingName) - extraNamespaceVal := fmt.Sprintf("%v", p.ExtraNamespace) - return fmt.Sprintf("Wrapper({Name:%s UnderlyingName:%s ExtraNamespace:%s})", nameVal, underlyingNameVal, extraNamespaceVal) -} - -// An annotation that applies a Hack adapter to types. For example: -// @hack.Adapter{name="\\TimestampAdapter"} -// typedef i64 Timestamp; -// -// struct User { -// 1: Timestamp account_creation_time; -// } -// -// Here the field `account_creation_time` will have type TimestampAdapter::THackType instead of i64. -// -// in hack: -// ``` -// final class TimestampAdapter implements IThriftAdapter { -// const type TThriftType = int; -// const type THackType = Time; -// public static function fromThrift(int $seconds)[]: Time { -// return Time::fromEpochSeconds($seconds); -// } -// public static function toThrift(Time $time): int { -// return $hack_value->asFullSecondsSinceEpoch(); -// } -// } -// ``` -// elsewhere in hack: -// ``` -// function timeSinceCreated(Document $doc): Duration { -// // $doc->created_time is of type Time -// return Duration::between(Time::now(), $doc->created_time); -// } -// ``` -// This completely replaces the underlying type of a thrift for a custom implementation and uses -// the specified adapter to convert to and from the underlying Thrift type during (de)serialization. -// -// Attributes: -// - Name: The name of a Hack adapter class that implements IThriftAdapter -type Adapter struct { - Name string `thrift:"name,1" db:"name" json:"name"` -} - -func NewAdapter() *Adapter { - return &Adapter{} -} - - -func (p *Adapter) GetName() string { - return p.Name -} -type AdapterBuilder struct { - obj *Adapter -} - -func NewAdapterBuilder() *AdapterBuilder{ - return &AdapterBuilder{ - obj: NewAdapter(), - } -} - -func (p AdapterBuilder) Emit() *Adapter{ - return &Adapter{ - Name: p.obj.Name, - } -} - -func (a *AdapterBuilder) Name(name string) *AdapterBuilder { - a.obj.Name = name - return a -} - -func (a *Adapter) SetName(name string) *Adapter { - a.Name = name - return a -} - -func (p *Adapter) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Adapter) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Name = v - } - return nil -} - -func (p *Adapter) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Adapter"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Adapter) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) } - if err := oprot.WriteString(string(p.Name)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) } - return err -} - -func (p *Adapter) String() string { - if p == nil { - return "" - } - - nameVal := fmt.Sprintf("%v", p.Name) - return fmt.Sprintf("Adapter({Name:%s})", nameVal) -} - -// Attributes: -// - Reason -type SkipCodegen struct { - Reason string `thrift:"reason,1" db:"reason" json:"reason"` -} - -func NewSkipCodegen() *SkipCodegen { - return &SkipCodegen{} -} - - -func (p *SkipCodegen) GetReason() string { - return p.Reason -} -type SkipCodegenBuilder struct { - obj *SkipCodegen -} - -func NewSkipCodegenBuilder() *SkipCodegenBuilder{ - return &SkipCodegenBuilder{ - obj: NewSkipCodegen(), - } -} - -func (p SkipCodegenBuilder) Emit() *SkipCodegen{ - return &SkipCodegen{ - Reason: p.obj.Reason, - } -} - -func (s *SkipCodegenBuilder) Reason(reason string) *SkipCodegenBuilder { - s.obj.Reason = reason - return s -} - -func (s *SkipCodegen) SetReason(reason string) *SkipCodegen { - s.Reason = reason - return s -} - -func (p *SkipCodegen) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *SkipCodegen) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Reason = v - } - return nil -} - -func (p *SkipCodegen) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("SkipCodegen"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *SkipCodegen) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("reason", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:reason: ", p), err) } - if err := oprot.WriteString(string(p.Reason)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.reason (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:reason: ", p), err) } - return err -} - -func (p *SkipCodegen) String() string { - if p == nil { - return "" - } - - reasonVal := fmt.Sprintf("%v", p.Reason) - return fmt.Sprintf("SkipCodegen({Reason:%s})", reasonVal) -} - -// This annotation is mainly used to rename symbols which can result in symbol -// conflict errors in Hack codegen. -// For ex: reserved keywords in Hack language, symbols with similar names from -// other files in Hack -// -// Attributes: -// - Name -// - Reason -type Name struct { - Name string `thrift:"name,1" db:"name" json:"name"` - Reason string `thrift:"reason,2" db:"reason" json:"reason"` -} - -func NewName() *Name { - return &Name{} -} - - -func (p *Name) GetName() string { - return p.Name -} - -func (p *Name) GetReason() string { - return p.Reason -} -type NameBuilder struct { - obj *Name -} - -func NewNameBuilder() *NameBuilder{ - return &NameBuilder{ - obj: NewName(), - } -} - -func (p NameBuilder) Emit() *Name{ - return &Name{ - Name: p.obj.Name, - Reason: p.obj.Reason, - } -} - -func (n *NameBuilder) Name(name string) *NameBuilder { - n.obj.Name = name - return n -} - -func (n *NameBuilder) Reason(reason string) *NameBuilder { - n.obj.Reason = reason - return n -} - -func (n *Name) SetName(name string) *Name { - n.Name = name - return n -} - -func (n *Name) SetReason(reason string) *Name { - n.Reason = reason - return n -} - -func (p *Name) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Name) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Name = v - } - return nil -} - -func (p *Name) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Reason = v - } - return nil -} - -func (p *Name) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Name"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Name) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) } - if err := oprot.WriteString(string(p.Name)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) } - return err -} - -func (p *Name) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("reason", thrift.STRING, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:reason: ", p), err) } - if err := oprot.WriteString(string(p.Reason)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.reason (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:reason: ", p), err) } - return err -} - -func (p *Name) String() string { - if p == nil { - return "" - } - - nameVal := fmt.Sprintf("%v", p.Name) - reasonVal := fmt.Sprintf("%v", p.Reason) - return fmt.Sprintf("Name({Name:%s Reason:%s})", nameVal, reasonVal) -} - -// This annotation is for adding Hack attributes to union enums. -// -// Attributes: -// - Attributes -type UnionEnumAttributes struct { - Attributes []string `thrift:"attributes,1" db:"attributes" json:"attributes"` -} - -func NewUnionEnumAttributes() *UnionEnumAttributes { - return &UnionEnumAttributes{} -} - - -func (p *UnionEnumAttributes) GetAttributes() []string { - return p.Attributes -} -type UnionEnumAttributesBuilder struct { - obj *UnionEnumAttributes -} - -func NewUnionEnumAttributesBuilder() *UnionEnumAttributesBuilder{ - return &UnionEnumAttributesBuilder{ - obj: NewUnionEnumAttributes(), - } -} - -func (p UnionEnumAttributesBuilder) Emit() *UnionEnumAttributes{ - return &UnionEnumAttributes{ - Attributes: p.obj.Attributes, - } -} - -func (u *UnionEnumAttributesBuilder) Attributes(attributes []string) *UnionEnumAttributesBuilder { - u.obj.Attributes = attributes - return u -} - -func (u *UnionEnumAttributes) SetAttributes(attributes []string) *UnionEnumAttributes { - u.Attributes = attributes - return u -} - -func (p *UnionEnumAttributes) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *UnionEnumAttributes) ReadField1(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]string, 0, size) - p.Attributes = tSlice - for i := 0; i < size; i ++ { - var _elem0 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem0 = v - } - p.Attributes = append(p.Attributes, _elem0) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *UnionEnumAttributes) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("UnionEnumAttributes"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *UnionEnumAttributes) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("attributes", thrift.LIST, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:attributes: ", p), err) } - if err := oprot.WriteListBegin(thrift.STRING, len(p.Attributes)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.Attributes { - if err := oprot.WriteString(string(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:attributes: ", p), err) } - return err -} - -func (p *UnionEnumAttributes) String() string { - if p == nil { - return "" - } - - attributesVal := fmt.Sprintf("%v", p.Attributes) - return fmt.Sprintf("UnionEnumAttributes({Attributes:%s})", attributesVal) -} - -// This annotation is for using a custom trait for structs. -// -// Attributes: -// - Name -type StructTrait struct { - Name string `thrift:"name,1" db:"name" json:"name"` -} - -func NewStructTrait() *StructTrait { - return &StructTrait{} -} - - -func (p *StructTrait) GetName() string { - return p.Name -} -type StructTraitBuilder struct { - obj *StructTrait -} - -func NewStructTraitBuilder() *StructTraitBuilder{ - return &StructTraitBuilder{ - obj: NewStructTrait(), - } -} - -func (p StructTraitBuilder) Emit() *StructTrait{ - return &StructTrait{ - Name: p.obj.Name, - } -} - -func (s *StructTraitBuilder) Name(name string) *StructTraitBuilder { - s.obj.Name = name - return s -} - -func (s *StructTrait) SetName(name string) *StructTrait { - s.Name = name - return s -} - -func (p *StructTrait) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *StructTrait) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Name = v - } - return nil -} - -func (p *StructTrait) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("StructTrait"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *StructTrait) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) } - if err := oprot.WriteString(string(p.Name)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) } - return err -} - -func (p *StructTrait) String() string { - if p == nil { - return "" - } - - nameVal := fmt.Sprintf("%v", p.Name) - return fmt.Sprintf("StructTrait({Name:%s})", nameVal) -} - -// This annotation is for adding Hack attributes. -// * Where to use: field or struct type -// * Value: add attributes like `JSEnum` to structs or fields -// * Example: -// -// ``` -// // In thrift -// enum MyEnum { -// ALLOWED = 1, -// THIS_IS_ALLOWED = 2, -// THIS_IS_ALLOWED_2 = 3, -// }( -// hack.attributes= -// "\JSEnum(shape('name' => 'MyEnum')), -// \GraphQLEnum('MyEnum', 'Description for my enum',)" -// ) -// struct MyThriftStruct { -// 1: string foo (hack.attributes = "FieldAttribute"); -// 2: string bar; -// 3: string baz; -// } (hack.attributes = "ClassAttribute") -// ``` -// ``` -// //thrift compiler will generate this for you -// <<\JSEnum(shape('name' => 'MyEnum')), -// \GraphQLEnum('MyEnum', 'Description for my enum',)>> -// enum MyEnum: int { -// ALLOWED = 1; -// THIS_IS_ALLOWED = 2; -// THIS_IS_ALLOWED_2 = 3; -// } -// <> -// class MyThriftStruct implements \IThriftStruct { -// .... -// <> -// public string $foo; -// .... -// } -// ``` -// -// Attributes: -// - Attributes -type Attributes struct { - Attributes []string `thrift:"attributes,1" db:"attributes" json:"attributes"` -} - -func NewAttributes() *Attributes { - return &Attributes{} -} - - -func (p *Attributes) GetAttributes() []string { - return p.Attributes -} -type AttributesBuilder struct { - obj *Attributes -} - -func NewAttributesBuilder() *AttributesBuilder{ - return &AttributesBuilder{ - obj: NewAttributes(), - } -} - -func (p AttributesBuilder) Emit() *Attributes{ - return &Attributes{ - Attributes: p.obj.Attributes, - } -} - -func (a *AttributesBuilder) Attributes(attributes []string) *AttributesBuilder { - a.obj.Attributes = attributes - return a -} - -func (a *Attributes) SetAttributes(attributes []string) *Attributes { - a.Attributes = attributes - return a -} - -func (p *Attributes) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Attributes) ReadField1(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]string, 0, size) - p.Attributes = tSlice - for i := 0; i < size; i ++ { - var _elem1 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem1 = v - } - p.Attributes = append(p.Attributes, _elem1) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *Attributes) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Attributes"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Attributes) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("attributes", thrift.LIST, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:attributes: ", p), err) } - if err := oprot.WriteListBegin(thrift.STRING, len(p.Attributes)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.Attributes { - if err := oprot.WriteString(string(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:attributes: ", p), err) } - return err -} - -func (p *Attributes) String() string { - if p == nil { - return "" - } - - attributesVal := fmt.Sprintf("%v", p.Attributes) - return fmt.Sprintf("Attributes({Attributes:%s})", attributesVal) -} - -type StructAsTrait struct { -} - -func NewStructAsTrait() *StructAsTrait { - return &StructAsTrait{} -} - -type StructAsTraitBuilder struct { - obj *StructAsTrait -} - -func NewStructAsTraitBuilder() *StructAsTraitBuilder{ - return &StructAsTraitBuilder{ - obj: NewStructAsTrait(), - } -} - -func (p StructAsTraitBuilder) Emit() *StructAsTrait{ - return &StructAsTrait{ - } -} - -func (p *StructAsTrait) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *StructAsTrait) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("StructAsTrait"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *StructAsTrait) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("StructAsTrait({})") -} - -// This annotation is to generate an entity as internal -type ModuleInternal struct { -} - -func NewModuleInternal() *ModuleInternal { - return &ModuleInternal{} -} - -type ModuleInternalBuilder struct { - obj *ModuleInternal -} - -func NewModuleInternalBuilder() *ModuleInternalBuilder{ - return &ModuleInternalBuilder{ - obj: NewModuleInternal(), - } -} - -func (p ModuleInternalBuilder) Emit() *ModuleInternal{ - return &ModuleInternal{ - } -} - -func (p *ModuleInternal) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ModuleInternal) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("ModuleInternal"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *ModuleInternal) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("ModuleInternal({})") -} - diff --git a/thrift/compiler/test/fixtures/adapter/gen-go/thrift/annotation/python/constants.go b/thrift/compiler/test/fixtures/adapter/gen-go/thrift/annotation/python/constants.go deleted file mode 100644 index ed5940409e3..00000000000 --- a/thrift/compiler/test/fixtures/adapter/gen-go/thrift/annotation/python/constants.go +++ /dev/null @@ -1,25 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package python - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - - -func init() { -} - diff --git a/thrift/compiler/test/fixtures/adapter/gen-go/thrift/annotation/python/ttypes.go b/thrift/compiler/test/fixtures/adapter/gen-go/thrift/annotation/python/ttypes.go deleted file mode 100644 index 66b625efb10..00000000000 --- a/thrift/compiler/test/fixtures/adapter/gen-go/thrift/annotation/python/ttypes.go +++ /dev/null @@ -1,568 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package python - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var GoUnusedProtection__ int; - -// Hides in thrift-py3 only, not in thrift-python -type Py3Hidden struct { -} - -func NewPy3Hidden() *Py3Hidden { - return &Py3Hidden{} -} - -type Py3HiddenBuilder struct { - obj *Py3Hidden -} - -func NewPy3HiddenBuilder() *Py3HiddenBuilder{ - return &Py3HiddenBuilder{ - obj: NewPy3Hidden(), - } -} - -func (p Py3HiddenBuilder) Emit() *Py3Hidden{ - return &Py3Hidden{ - } -} - -func (p *Py3Hidden) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Py3Hidden) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Py3Hidden"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Py3Hidden) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Py3Hidden({})") -} - -type Flags struct { -} - -func NewFlags() *Flags { - return &Flags{} -} - -type FlagsBuilder struct { - obj *Flags -} - -func NewFlagsBuilder() *FlagsBuilder{ - return &FlagsBuilder{ - obj: NewFlags(), - } -} - -func (p FlagsBuilder) Emit() *Flags{ - return &Flags{ - } -} - -func (p *Flags) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Flags) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Flags"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Flags) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Flags({})") -} - -// Attributes: -// - Name -type Name struct { - Name string `thrift:"name,1" db:"name" json:"name"` -} - -func NewName() *Name { - return &Name{} -} - - -func (p *Name) GetName() string { - return p.Name -} -type NameBuilder struct { - obj *Name -} - -func NewNameBuilder() *NameBuilder{ - return &NameBuilder{ - obj: NewName(), - } -} - -func (p NameBuilder) Emit() *Name{ - return &Name{ - Name: p.obj.Name, - } -} - -func (n *NameBuilder) Name(name string) *NameBuilder { - n.obj.Name = name - return n -} - -func (n *Name) SetName(name string) *Name { - n.Name = name - return n -} - -func (p *Name) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Name) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Name = v - } - return nil -} - -func (p *Name) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Name"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Name) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) } - if err := oprot.WriteString(string(p.Name)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) } - return err -} - -func (p *Name) String() string { - if p == nil { - return "" - } - - nameVal := fmt.Sprintf("%v", p.Name) - return fmt.Sprintf("Name({Name:%s})", nameVal) -} - -// An annotation that applies a Python adapter to typedef or field, or directly on struct. -// This completely replaces the underlying type of a thrift for a custom implementation and -// uses the specified adapter to convert to and from the underlying Thrift type during (de)serialization. -// -// Example 1: -// -// @python.Adapter{name = "my.module.DatetimeAdapter", typeHint = "datetime.datetime"} -// typedef i64 Datetime -// -// Here the type 'Datetime' has the Python adapter `DatetimeAdapter`. -// -// -// Example 2: -// -// struct User { -// @python.Adapter{name = "my.module.DatetimeAdapter", typeHint = "datetime.datetime"} -// 1: i64 created_at; -// } -// Here the field `created_at` has the Python adapter `DatetimeAdapter`. -// -// -// Example 3: -// -// -// @python.Adapter{name = "my.module.AnotherAdapter", typeHint = "my.module.AdaptedFoo"} -// struct Foo { -// 1: string bar; -// } -// -// Here the struct `Foo` has the Python adapter `AnotherAdapter`. -// -// -// Attributes: -// - Name: Fully qualified name of a Python adapter class, which should inherit from thrift.python.adapter.Adapter -// - TypeHint: Fully qualified type hint the above implementation adapts to. -// If ending with "[]", it becomes a generic, and the unadapted type will be filled between the brackets. -type Adapter struct { - Name string `thrift:"name,1" db:"name" json:"name"` - TypeHint string `thrift:"typeHint,2" db:"typeHint" json:"typeHint"` -} - -func NewAdapter() *Adapter { - return &Adapter{} -} - - -func (p *Adapter) GetName() string { - return p.Name -} - -func (p *Adapter) GetTypeHint() string { - return p.TypeHint -} -type AdapterBuilder struct { - obj *Adapter -} - -func NewAdapterBuilder() *AdapterBuilder{ - return &AdapterBuilder{ - obj: NewAdapter(), - } -} - -func (p AdapterBuilder) Emit() *Adapter{ - return &Adapter{ - Name: p.obj.Name, - TypeHint: p.obj.TypeHint, - } -} - -func (a *AdapterBuilder) Name(name string) *AdapterBuilder { - a.obj.Name = name - return a -} - -func (a *AdapterBuilder) TypeHint(typeHint string) *AdapterBuilder { - a.obj.TypeHint = typeHint - return a -} - -func (a *Adapter) SetName(name string) *Adapter { - a.Name = name - return a -} - -func (a *Adapter) SetTypeHint(typeHint string) *Adapter { - a.TypeHint = typeHint - return a -} - -func (p *Adapter) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Adapter) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Name = v - } - return nil -} - -func (p *Adapter) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.TypeHint = v - } - return nil -} - -func (p *Adapter) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Adapter"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Adapter) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) } - if err := oprot.WriteString(string(p.Name)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) } - return err -} - -func (p *Adapter) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("typeHint", thrift.STRING, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:typeHint: ", p), err) } - if err := oprot.WriteString(string(p.TypeHint)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.typeHint (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:typeHint: ", p), err) } - return err -} - -func (p *Adapter) String() string { - if p == nil { - return "" - } - - nameVal := fmt.Sprintf("%v", p.Name) - typeHintVal := fmt.Sprintf("%v", p.TypeHint) - return fmt.Sprintf("Adapter({Name:%s TypeHint:%s})", nameVal, typeHintVal) -} - -// Controls cpp <-> python FFI for a struct or union -// By default, struct uses marshal C API unless cpp.Type or cpp.Adapter is present -// on a field or a type -// Use this annotation to opt-in struct to marshal in spite of cpp.Type or cpp.Adapter -// Alternatively, use this struct with serialize = false to use serialization for FFI. -// -// Attributes: -// - Serialize -type UseCAPI struct { - Serialize bool `thrift:"serialize,1" db:"serialize" json:"serialize"` -} - -func NewUseCAPI() *UseCAPI { - return &UseCAPI{} -} - - -func (p *UseCAPI) GetSerialize() bool { - return p.Serialize -} -type UseCAPIBuilder struct { - obj *UseCAPI -} - -func NewUseCAPIBuilder() *UseCAPIBuilder{ - return &UseCAPIBuilder{ - obj: NewUseCAPI(), - } -} - -func (p UseCAPIBuilder) Emit() *UseCAPI{ - return &UseCAPI{ - Serialize: p.obj.Serialize, - } -} - -func (u *UseCAPIBuilder) Serialize(serialize bool) *UseCAPIBuilder { - u.obj.Serialize = serialize - return u -} - -func (u *UseCAPI) SetSerialize(serialize bool) *UseCAPI { - u.Serialize = serialize - return u -} - -func (p *UseCAPI) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *UseCAPI) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Serialize = v - } - return nil -} - -func (p *UseCAPI) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("UseCAPI"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *UseCAPI) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("serialize", thrift.BOOL, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:serialize: ", p), err) } - if err := oprot.WriteBool(bool(p.Serialize)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.serialize (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:serialize: ", p), err) } - return err -} - -func (p *UseCAPI) String() string { - if p == nil { - return "" - } - - serializeVal := fmt.Sprintf("%v", p.Serialize) - return fmt.Sprintf("UseCAPI({Serialize:%s})", serializeVal) -} - diff --git a/thrift/compiler/test/fixtures/adapter/gen-go/thrift/annotation/rust/constants.go b/thrift/compiler/test/fixtures/adapter/gen-go/thrift/annotation/rust/constants.go deleted file mode 100644 index 9c2568e77ab..00000000000 --- a/thrift/compiler/test/fixtures/adapter/gen-go/thrift/annotation/rust/constants.go +++ /dev/null @@ -1,25 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package rust - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - - -func init() { -} - diff --git a/thrift/compiler/test/fixtures/adapter/gen-go/thrift/annotation/rust/ttypes.go b/thrift/compiler/test/fixtures/adapter/gen-go/thrift/annotation/rust/ttypes.go deleted file mode 100644 index 078587ea1c8..00000000000 --- a/thrift/compiler/test/fixtures/adapter/gen-go/thrift/annotation/rust/ttypes.go +++ /dev/null @@ -1,377 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package rust - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var GoUnusedProtection__ int; - -// Attributes: -// - Name -type Adapter struct { - Name string `thrift:"name,1" db:"name" json:"name"` -} - -func NewAdapter() *Adapter { - return &Adapter{} -} - - -func (p *Adapter) GetName() string { - return p.Name -} -type AdapterBuilder struct { - obj *Adapter -} - -func NewAdapterBuilder() *AdapterBuilder{ - return &AdapterBuilder{ - obj: NewAdapter(), - } -} - -func (p AdapterBuilder) Emit() *Adapter{ - return &Adapter{ - Name: p.obj.Name, - } -} - -func (a *AdapterBuilder) Name(name string) *AdapterBuilder { - a.obj.Name = name - return a -} - -func (a *Adapter) SetName(name string) *Adapter { - a.Name = name - return a -} - -func (p *Adapter) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Adapter) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Name = v - } - return nil -} - -func (p *Adapter) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Adapter"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Adapter) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) } - if err := oprot.WriteString(string(p.Name)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) } - return err -} - -func (p *Adapter) String() string { - if p == nil { - return "" - } - - nameVal := fmt.Sprintf("%v", p.Name) - return fmt.Sprintf("Adapter({Name:%s})", nameVal) -} - -// Attributes: -// - Derives -type Derive struct { - Derives []string `thrift:"derives,1" db:"derives" json:"derives"` -} - -func NewDerive() *Derive { - return &Derive{} -} - - -func (p *Derive) GetDerives() []string { - return p.Derives -} -type DeriveBuilder struct { - obj *Derive -} - -func NewDeriveBuilder() *DeriveBuilder{ - return &DeriveBuilder{ - obj: NewDerive(), - } -} - -func (p DeriveBuilder) Emit() *Derive{ - return &Derive{ - Derives: p.obj.Derives, - } -} - -func (d *DeriveBuilder) Derives(derives []string) *DeriveBuilder { - d.obj.Derives = derives - return d -} - -func (d *Derive) SetDerives(derives []string) *Derive { - d.Derives = derives - return d -} - -func (p *Derive) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Derive) ReadField1(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]string, 0, size) - p.Derives = tSlice - for i := 0; i < size; i ++ { - var _elem0 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem0 = v - } - p.Derives = append(p.Derives, _elem0) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *Derive) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Derive"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Derive) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("derives", thrift.LIST, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:derives: ", p), err) } - if err := oprot.WriteListBegin(thrift.STRING, len(p.Derives)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.Derives { - if err := oprot.WriteString(string(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:derives: ", p), err) } - return err -} - -func (p *Derive) String() string { - if p == nil { - return "" - } - - derivesVal := fmt.Sprintf("%v", p.Derives) - return fmt.Sprintf("Derive({Derives:%s})", derivesVal) -} - -// Attributes: -// - AnyhowToApplicationExn -type ServiceExn struct { - AnyhowToApplicationExn bool `thrift:"anyhow_to_application_exn,1" db:"anyhow_to_application_exn" json:"anyhow_to_application_exn"` -} - -func NewServiceExn() *ServiceExn { - return &ServiceExn{} -} - - -func (p *ServiceExn) GetAnyhowToApplicationExn() bool { - return p.AnyhowToApplicationExn -} -type ServiceExnBuilder struct { - obj *ServiceExn -} - -func NewServiceExnBuilder() *ServiceExnBuilder{ - return &ServiceExnBuilder{ - obj: NewServiceExn(), - } -} - -func (p ServiceExnBuilder) Emit() *ServiceExn{ - return &ServiceExn{ - AnyhowToApplicationExn: p.obj.AnyhowToApplicationExn, - } -} - -func (s *ServiceExnBuilder) AnyhowToApplicationExn(anyhowToApplicationExn bool) *ServiceExnBuilder { - s.obj.AnyhowToApplicationExn = anyhowToApplicationExn - return s -} - -func (s *ServiceExn) SetAnyhowToApplicationExn(anyhowToApplicationExn bool) *ServiceExn { - s.AnyhowToApplicationExn = anyhowToApplicationExn - return s -} - -func (p *ServiceExn) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ServiceExn) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.AnyhowToApplicationExn = v - } - return nil -} - -func (p *ServiceExn) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("ServiceExn"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *ServiceExn) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("anyhow_to_application_exn", thrift.BOOL, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:anyhow_to_application_exn: ", p), err) } - if err := oprot.WriteBool(bool(p.AnyhowToApplicationExn)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.anyhow_to_application_exn (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:anyhow_to_application_exn: ", p), err) } - return err -} - -func (p *ServiceExn) String() string { - if p == nil { - return "" - } - - anyhowToApplicationExnVal := fmt.Sprintf("%v", p.AnyhowToApplicationExn) - return fmt.Sprintf("ServiceExn({AnyhowToApplicationExn:%s})", anyhowToApplicationExnVal) -} - diff --git a/thrift/compiler/test/fixtures/adapter/gen-go/thrift/annotation/scope/constants.go b/thrift/compiler/test/fixtures/adapter/gen-go/thrift/annotation/scope/constants.go deleted file mode 100644 index 0c3448a7126..00000000000 --- a/thrift/compiler/test/fixtures/adapter/gen-go/thrift/annotation/scope/constants.go +++ /dev/null @@ -1,25 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package scope - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - - -func init() { -} - diff --git a/thrift/compiler/test/fixtures/adapter/gen-go/thrift/annotation/scope/ttypes.go b/thrift/compiler/test/fixtures/adapter/gen-go/thrift/annotation/scope/ttypes.go deleted file mode 100644 index 580c39e775c..00000000000 --- a/thrift/compiler/test/fixtures/adapter/gen-go/thrift/annotation/scope/ttypes.go +++ /dev/null @@ -1,1169 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package scope - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var GoUnusedProtection__ int; - -// Indicates that the scope of sibling annotations is transitive. -// -// For example: -// -// @scope.Struct -// @scope.Union -// @scope.Exception -// @scope.Transitive -// struct Structured {} -// -// Annotating a Thrift struct with @Structured automatically applies -// @scope.Struct, @scope.Union and @scope.Exception annotations, i.e. -// -// @Structured -// struct MyAnnotation {} -// -// is equivalent to -// -// @scope.Struct -// @scope.Union -// @scope.Exception -// struct MyAnnotation {} -// -type Transitive struct { -} - -func NewTransitive() *Transitive { - return &Transitive{} -} - -type TransitiveBuilder struct { - obj *Transitive -} - -func NewTransitiveBuilder() *TransitiveBuilder{ - return &TransitiveBuilder{ - obj: NewTransitive(), - } -} - -func (p TransitiveBuilder) Emit() *Transitive{ - return &Transitive{ - } -} - -func (p *Transitive) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Transitive) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Transitive"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Transitive) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Transitive({})") -} - -// The Program scope. -// -// This allows annotations on the `package` definition, which implies the -// annotaiton applies to the entire program. -type Program struct { -} - -func NewProgram() *Program { - return &Program{} -} - -type ProgramBuilder struct { - obj *Program -} - -func NewProgramBuilder() *ProgramBuilder{ - return &ProgramBuilder{ - obj: NewProgram(), - } -} - -func (p ProgramBuilder) Emit() *Program{ - return &Program{ - } -} - -func (p *Program) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Program) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Program"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Program) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Program({})") -} - -// The `struct` definition scope. -type Struct struct { -} - -func NewStruct() *Struct { - return &Struct{} -} - -type StructBuilder struct { - obj *Struct -} - -func NewStructBuilder() *StructBuilder{ - return &StructBuilder{ - obj: NewStruct(), - } -} - -func (p StructBuilder) Emit() *Struct{ - return &Struct{ - } -} - -func (p *Struct) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Struct) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Struct"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Struct) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Struct({})") -} - -// The `union` definition scope. -type Union struct { -} - -func NewUnion() *Union { - return &Union{} -} - -type UnionBuilder struct { - obj *Union -} - -func NewUnionBuilder() *UnionBuilder{ - return &UnionBuilder{ - obj: NewUnion(), - } -} - -func (p UnionBuilder) Emit() *Union{ - return &Union{ - } -} - -func (p *Union) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Union) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Union"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Union) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Union({})") -} - -// The `exception` definition scope. -type Exception struct { -} - -func NewException() *Exception { - return &Exception{} -} - -type ExceptionBuilder struct { - obj *Exception -} - -func NewExceptionBuilder() *ExceptionBuilder{ - return &ExceptionBuilder{ - obj: NewException(), - } -} - -func (p ExceptionBuilder) Emit() *Exception{ - return &Exception{ - } -} - -func (p *Exception) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Exception) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Exception"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Exception) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Exception({})") -} - -// Field declartaions, for example in `struct` or `function` declartions. -type Field struct { -} - -func NewField() *Field { - return &Field{} -} - -type FieldBuilder struct { - obj *Field -} - -func NewFieldBuilder() *FieldBuilder{ - return &FieldBuilder{ - obj: NewField(), - } -} - -func (p FieldBuilder) Emit() *Field{ - return &Field{ - } -} - -func (p *Field) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Field) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Field"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Field) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Field({})") -} - -// The `typedef` definition scope. -type Typedef struct { -} - -func NewTypedef() *Typedef { - return &Typedef{} -} - -type TypedefBuilder struct { - obj *Typedef -} - -func NewTypedefBuilder() *TypedefBuilder{ - return &TypedefBuilder{ - obj: NewTypedef(), - } -} - -func (p TypedefBuilder) Emit() *Typedef{ - return &Typedef{ - } -} - -func (p *Typedef) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Typedef) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Typedef"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Typedef) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Typedef({})") -} - -// The `service` definition scope. -type Service struct { -} - -func NewService() *Service { - return &Service{} -} - -type ServiceBuilder struct { - obj *Service -} - -func NewServiceBuilder() *ServiceBuilder{ - return &ServiceBuilder{ - obj: NewService(), - } -} - -func (p ServiceBuilder) Emit() *Service{ - return &Service{ - } -} - -func (p *Service) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Service) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Service"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Service) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Service({})") -} - -// The `interaction` definition scope. -type Interaction struct { -} - -func NewInteraction() *Interaction { - return &Interaction{} -} - -type InteractionBuilder struct { - obj *Interaction -} - -func NewInteractionBuilder() *InteractionBuilder{ - return &InteractionBuilder{ - obj: NewInteraction(), - } -} - -func (p InteractionBuilder) Emit() *Interaction{ - return &Interaction{ - } -} - -func (p *Interaction) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Interaction) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Interaction"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Interaction) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Interaction({})") -} - -// The `function` definition scope. -type Function struct { -} - -func NewFunction() *Function { - return &Function{} -} - -type FunctionBuilder struct { - obj *Function -} - -func NewFunctionBuilder() *FunctionBuilder{ - return &FunctionBuilder{ - obj: NewFunction(), - } -} - -func (p FunctionBuilder) Emit() *Function{ - return &Function{ - } -} - -func (p *Function) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Function) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Function"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Function) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Function({})") -} - -// The Enum value definition scope. -type EnumValue struct { -} - -func NewEnumValue() *EnumValue { - return &EnumValue{} -} - -type EnumValueBuilder struct { - obj *EnumValue -} - -func NewEnumValueBuilder() *EnumValueBuilder{ - return &EnumValueBuilder{ - obj: NewEnumValue(), - } -} - -func (p EnumValueBuilder) Emit() *EnumValue{ - return &EnumValue{ - } -} - -func (p *EnumValue) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *EnumValue) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("EnumValue"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *EnumValue) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("EnumValue({})") -} - -// The `const` definition scope. -type Const struct { -} - -func NewConst() *Const { - return &Const{} -} - -type ConstBuilder struct { - obj *Const -} - -func NewConstBuilder() *ConstBuilder{ - return &ConstBuilder{ - obj: NewConst(), - } -} - -func (p ConstBuilder) Emit() *Const{ - return &Const{ - } -} - -func (p *Const) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Const) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Const"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Const) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Const({})") -} - -type Enum struct { -} - -func NewEnum() *Enum { - return &Enum{} -} - -type EnumBuilder struct { - obj *Enum -} - -func NewEnumBuilder() *EnumBuilder{ - return &EnumBuilder{ - obj: NewEnum(), - } -} - -func (p EnumBuilder) Emit() *Enum{ - return &Enum{ - } -} - -func (p *Enum) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Enum) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Enum"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Enum) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Enum({})") -} - -// A scope that includes all 'structured' definitions. -type Structured struct { -} - -func NewStructured() *Structured { - return &Structured{} -} - -type StructuredBuilder struct { - obj *Structured -} - -func NewStructuredBuilder() *StructuredBuilder{ - return &StructuredBuilder{ - obj: NewStructured(), - } -} - -func (p StructuredBuilder) Emit() *Structured{ - return &Structured{ - } -} - -func (p *Structured) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Structured) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Structured"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Structured) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Structured({})") -} - -// A scope that includes all 'interface' definitions. -type Interface struct { -} - -func NewInterface() *Interface { - return &Interface{} -} - -type InterfaceBuilder struct { - obj *Interface -} - -func NewInterfaceBuilder() *InterfaceBuilder{ - return &InterfaceBuilder{ - obj: NewInterface(), - } -} - -func (p InterfaceBuilder) Emit() *Interface{ - return &Interface{ - } -} - -func (p *Interface) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Interface) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Interface"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Interface) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Interface({})") -} - -// A scope that includes all program-scoped definition. -type RootDefinition struct { -} - -func NewRootDefinition() *RootDefinition { - return &RootDefinition{} -} - -type RootDefinitionBuilder struct { - obj *RootDefinition -} - -func NewRootDefinitionBuilder() *RootDefinitionBuilder{ - return &RootDefinitionBuilder{ - obj: NewRootDefinition(), - } -} - -func (p RootDefinitionBuilder) Emit() *RootDefinition{ - return &RootDefinition{ - } -} - -func (p *RootDefinition) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *RootDefinition) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("RootDefinition"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *RootDefinition) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("RootDefinition({})") -} - -// A scope that includes all definitions. -type Definition struct { -} - -func NewDefinition() *Definition { - return &Definition{} -} - -type DefinitionBuilder struct { - obj *Definition -} - -func NewDefinitionBuilder() *DefinitionBuilder{ - return &DefinitionBuilder{ - obj: NewDefinition(), - } -} - -func (p DefinitionBuilder) Emit() *Definition{ - return &Definition{ - } -} - -func (p *Definition) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Definition) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Definition"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Definition) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Definition({})") -} - diff --git a/thrift/compiler/test/fixtures/adapter/gen-go/thrift/annotation/thrift/constants.go b/thrift/compiler/test/fixtures/adapter/gen-go/thrift/annotation/thrift/constants.go deleted file mode 100644 index 50d9b0fe3ee..00000000000 --- a/thrift/compiler/test/fixtures/adapter/gen-go/thrift/annotation/thrift/constants.go +++ /dev/null @@ -1,25 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package thrift - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - - -func init() { -} - diff --git a/thrift/compiler/test/fixtures/adapter/gen-go/thrift/annotation/thrift/ttypes.go b/thrift/compiler/test/fixtures/adapter/gen-go/thrift/annotation/thrift/ttypes.go deleted file mode 100644 index 35ea75e3dd0..00000000000 --- a/thrift/compiler/test/fixtures/adapter/gen-go/thrift/annotation/thrift/ttypes.go +++ /dev/null @@ -1,1545 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package thrift - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var GoUnusedProtection__ int; - -type RpcPriority int64 -const ( - RpcPriority_HIGH_IMPORTANT RpcPriority = 0 - RpcPriority_HIGH RpcPriority = 1 - RpcPriority_IMPORTANT RpcPriority = 2 - RpcPriority_NORMAL RpcPriority = 3 - RpcPriority_BEST_EFFORT RpcPriority = 4 -) - -var RpcPriorityToName = map[RpcPriority]string { - RpcPriority_HIGH_IMPORTANT: "HIGH_IMPORTANT", - RpcPriority_HIGH: "HIGH", - RpcPriority_IMPORTANT: "IMPORTANT", - RpcPriority_NORMAL: "NORMAL", - RpcPriority_BEST_EFFORT: "BEST_EFFORT", -} - -var RpcPriorityToValue = map[string]RpcPriority { - "HIGH_IMPORTANT": RpcPriority_HIGH_IMPORTANT, - "HIGH": RpcPriority_HIGH, - "IMPORTANT": RpcPriority_IMPORTANT, - "NORMAL": RpcPriority_NORMAL, - "BEST_EFFORT": RpcPriority_BEST_EFFORT, -} - -var RpcPriorityNames = []string { - "HIGH_IMPORTANT", - "HIGH", - "IMPORTANT", - "NORMAL", - "BEST_EFFORT", -} - -var RpcPriorityValues = []RpcPriority { - RpcPriority_HIGH_IMPORTANT, - RpcPriority_HIGH, - RpcPriority_IMPORTANT, - RpcPriority_NORMAL, - RpcPriority_BEST_EFFORT, -} - -func (p RpcPriority) String() string { - if v, ok := RpcPriorityToName[p]; ok { - return v - } - return "" -} - -func RpcPriorityFromString(s string) (RpcPriority, error) { - if v, ok := RpcPriorityToValue[s]; ok { - return v, nil - } - return RpcPriority(0), fmt.Errorf("not a valid RpcPriority string") -} - -func RpcPriorityPtr(v RpcPriority) *RpcPriority { return &v } - -// Indicates a definition/feature should only be used with permission, may -// only work in specific contexts, and may change in incompatible ways without -// notice. Note that this is primarily intended to annotate features by the Thrift Team -// and isn't recommended for general use. -type Experimental struct { -} - -func NewExperimental() *Experimental { - return &Experimental{} -} - -type ExperimentalBuilder struct { - obj *Experimental -} - -func NewExperimentalBuilder() *ExperimentalBuilder{ - return &ExperimentalBuilder{ - obj: NewExperimental(), - } -} - -func (p ExperimentalBuilder) Emit() *Experimental{ - return &Experimental{ - } -} - -func (p *Experimental) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Experimental) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Experimental"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Experimental) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Experimental({})") -} - -// Annotate a thrift structured or enum to indicate if ids or values should not -// be used. -// -// For example, you may want to mark ids as deprecated, or these ids -// might be reserved for other use cases or annotations. -// -// The resolved set of disallowed ids is the union of the values in `ids` and -// the range of values represented in `id_ranges`. Example: -// -// // These ids are not allowed: 3, 8, half-open ranges [10, 15), [20, 30) -// @thrift.ReserveIds{ids = [3, 8], id_ranges = {10: 15, 20: 30}} -// struct Foo { -// ... -// 3: i64 f; // Build failure: 3 cannot be used -// } -// -// Attributes: -// - Ids: Individual ids that cannot be used. -// - IdRanges: Represents ranges of ids that cannot be used. -// -// Each (key: value) pair represents the half-open range `[key, value)`, -// where `key` is included and `value` is not. For example, the map -// `{10: 15, 20: 30}` represents the union of id/value ranges `[10, 15)` and -// `[20, 30)`. -type ReserveIds struct { - Ids []int32 `thrift:"ids,1" db:"ids" json:"ids"` - IdRanges map[int32]int32 `thrift:"id_ranges,2" db:"id_ranges" json:"id_ranges"` -} - -func NewReserveIds() *ReserveIds { - return &ReserveIds{} -} - - -func (p *ReserveIds) GetIds() []int32 { - return p.Ids -} - -func (p *ReserveIds) GetIdRanges() map[int32]int32 { - return p.IdRanges -} -type ReserveIdsBuilder struct { - obj *ReserveIds -} - -func NewReserveIdsBuilder() *ReserveIdsBuilder{ - return &ReserveIdsBuilder{ - obj: NewReserveIds(), - } -} - -func (p ReserveIdsBuilder) Emit() *ReserveIds{ - return &ReserveIds{ - Ids: p.obj.Ids, - IdRanges: p.obj.IdRanges, - } -} - -func (r *ReserveIdsBuilder) Ids(ids []int32) *ReserveIdsBuilder { - r.obj.Ids = ids - return r -} - -func (r *ReserveIdsBuilder) IdRanges(idRanges map[int32]int32) *ReserveIdsBuilder { - r.obj.IdRanges = idRanges - return r -} - -func (r *ReserveIds) SetIds(ids []int32) *ReserveIds { - r.Ids = ids - return r -} - -func (r *ReserveIds) SetIdRanges(idRanges map[int32]int32) *ReserveIds { - r.IdRanges = idRanges - return r -} - -func (p *ReserveIds) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ReserveIds) ReadField1(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]int32, 0, size) - p.Ids = tSlice - for i := 0; i < size; i ++ { - var _elem0 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem0 = v - } - p.Ids = append(p.Ids, _elem0) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *ReserveIds) ReadField2(iprot thrift.Protocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[int32]int32, size) - p.IdRanges = tMap - for i := 0; i < size; i ++ { - var _key1 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key1 = v - } - var _val2 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _val2 = v - } - p.IdRanges[_key1] = _val2 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *ReserveIds) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("ReserveIds"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *ReserveIds) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("ids", thrift.LIST, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:ids: ", p), err) } - if err := oprot.WriteListBegin(thrift.I32, len(p.Ids)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.Ids { - if err := oprot.WriteI32(int32(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:ids: ", p), err) } - return err -} - -func (p *ReserveIds) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("id_ranges", thrift.MAP, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:id_ranges: ", p), err) } - if err := oprot.WriteMapBegin(thrift.I32, thrift.I32, len(p.IdRanges)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.IdRanges { - if err := oprot.WriteI32(int32(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := oprot.WriteI32(int32(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:id_ranges: ", p), err) } - return err -} - -func (p *ReserveIds) String() string { - if p == nil { - return "" - } - - idsVal := fmt.Sprintf("%v", p.Ids) - idRangesVal := fmt.Sprintf("%v", p.IdRanges) - return fmt.Sprintf("ReserveIds({Ids:%s IdRanges:%s})", idsVal, idRangesVal) -} - -// Indicates additional backward compatibility restrictions, beyond the -// standard Thrift required 'wire' compatibility. -// -// Attributes: -// - FieldName -type RequiresBackwardCompatibility struct { - FieldName bool `thrift:"field_name,1" db:"field_name" json:"field_name"` -} - -func NewRequiresBackwardCompatibility() *RequiresBackwardCompatibility { - return &RequiresBackwardCompatibility{} -} - - -func (p *RequiresBackwardCompatibility) GetFieldName() bool { - return p.FieldName -} -type RequiresBackwardCompatibilityBuilder struct { - obj *RequiresBackwardCompatibility -} - -func NewRequiresBackwardCompatibilityBuilder() *RequiresBackwardCompatibilityBuilder{ - return &RequiresBackwardCompatibilityBuilder{ - obj: NewRequiresBackwardCompatibility(), - } -} - -func (p RequiresBackwardCompatibilityBuilder) Emit() *RequiresBackwardCompatibility{ - return &RequiresBackwardCompatibility{ - FieldName: p.obj.FieldName, - } -} - -func (r *RequiresBackwardCompatibilityBuilder) FieldName(fieldName bool) *RequiresBackwardCompatibilityBuilder { - r.obj.FieldName = fieldName - return r -} - -func (r *RequiresBackwardCompatibility) SetFieldName(fieldName bool) *RequiresBackwardCompatibility { - r.FieldName = fieldName - return r -} - -func (p *RequiresBackwardCompatibility) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *RequiresBackwardCompatibility) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.FieldName = v - } - return nil -} - -func (p *RequiresBackwardCompatibility) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("RequiresBackwardCompatibility"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *RequiresBackwardCompatibility) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("field_name", thrift.BOOL, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:field_name: ", p), err) } - if err := oprot.WriteBool(bool(p.FieldName)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.field_name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:field_name: ", p), err) } - return err -} - -func (p *RequiresBackwardCompatibility) String() string { - if p == nil { - return "" - } - - fieldNameVal := fmt.Sprintf("%v", p.FieldName) - return fmt.Sprintf("RequiresBackwardCompatibility({FieldName:%s})", fieldNameVal) -} - -// An annotation that changes the field qualifier from 'none' to 'terse'. -// A terse field is eligible to skip serialization, when it equals to the -// intrinsic default value. It also clears to the intrinsic default value -// before deserialization to distinguish between if a terse field was skipped -// or missing during serialization. This is different from an unqualified -// field, as an unqualified field is always serialized regardless of its value, -// and it is not cleared before deserialization. -// -// The annotation can be only used to annotate an unqualified field, and when -// it is annotating a struct or exception, it changes all unqualified fields to -// terse fields. Note, the annotation can not be used for union. -type TerseWrite struct { -} - -func NewTerseWrite() *TerseWrite { - return &TerseWrite{} -} - -type TerseWriteBuilder struct { - obj *TerseWrite -} - -func NewTerseWriteBuilder() *TerseWriteBuilder{ - return &TerseWriteBuilder{ - obj: NewTerseWrite(), - } -} - -func (p TerseWriteBuilder) Emit() *TerseWrite{ - return &TerseWrite{ - } -} - -func (p *TerseWrite) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *TerseWrite) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("TerseWrite"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *TerseWrite) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("TerseWrite({})") -} - -// Indicates that an optional field's value should never be stored on the stack, -// i.e. the subobject should be allocated separately (e.g. because it is large and infrequently set). -// -// NOTE: The APIs and initialization behavior are same as normal field, but different from `@cpp.Ref`. e.g. -// -// ``` -// struct Foo { -// 1: optional i32 normal; -// @thrift.Box -// 2: optional i32 boxed; -// @cpp.Ref -// 3: optional i32 referred; -// } -// ``` -// in C++ -// -// ``` -// Foo foo; -// EXPECT_FALSE(foo.normal().has_value()); // okay -// EXPECT_FALSE(foo.boxed().has_value()); // okay -// EXPECT_FALSE(foo.referred().has_value()); // build failure: std::unique_ptr doesn't have has_value method -// -// EXPECT_EQ(*foo.normal(), 0); // throw bad_field_access exception -// EXPECT_EQ(*foo.boxed(), 0); // throw bad_field_access exception -// EXPECT_EQ(*foo.referred(), 0); // okay, field has value by default -// ``` -// -// Affects C++ and Rust. -// TODO: replace with @cpp.Box + @rust.Box -type Box struct { -} - -func NewBox() *Box { - return &Box{} -} - -type BoxBuilder struct { - obj *Box -} - -func NewBoxBuilder() *BoxBuilder{ - return &BoxBuilder{ - obj: NewBox(), - } -} - -func (p BoxBuilder) Emit() *Box{ - return &Box{ - } -} - -func (p *Box) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Box) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Box"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Box) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Box({})") -} - -// Indicates whether the nested fields are accessible directly. -// https://github.com/facebook/fbthrift/blob/v2023.11.20.00/thrift/doc/idl/mixins.md -type Mixin struct { -} - -func NewMixin() *Mixin { - return &Mixin{} -} - -type MixinBuilder struct { - obj *Mixin -} - -func NewMixinBuilder() *MixinBuilder{ - return &MixinBuilder{ - obj: NewMixin(), - } -} - -func (p MixinBuilder) Emit() *Mixin{ - return &Mixin{ - } -} - -func (p *Mixin) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Mixin) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Mixin"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Mixin) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Mixin({})") -} - -// Option to serialize thrift struct in ascending field id order instead of field declaration order. -// -// This can potentially make serialized data size smaller in compact protocol, -// since compact protocol can write deltas between subsequent field ids instead of full ids. -// -// NOTE: This annotation won't reduce payload size for other protocols. -type SerializeInFieldIdOrder struct { -} - -func NewSerializeInFieldIdOrder() *SerializeInFieldIdOrder { - return &SerializeInFieldIdOrder{} -} - -type SerializeInFieldIdOrderBuilder struct { - obj *SerializeInFieldIdOrder -} - -func NewSerializeInFieldIdOrderBuilder() *SerializeInFieldIdOrderBuilder{ - return &SerializeInFieldIdOrderBuilder{ - obj: NewSerializeInFieldIdOrder(), - } -} - -func (p SerializeInFieldIdOrderBuilder) Emit() *SerializeInFieldIdOrder{ - return &SerializeInFieldIdOrder{ - } -} - -func (p *SerializeInFieldIdOrder) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *SerializeInFieldIdOrder) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("SerializeInFieldIdOrder"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *SerializeInFieldIdOrder) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("SerializeInFieldIdOrder({})") -} - -// Indicates an enum is a bitmask and should support bit-wise operators. -// Currently generates additional code in C++ and Hack. -type BitmaskEnum struct { -} - -func NewBitmaskEnum() *BitmaskEnum { - return &BitmaskEnum{} -} - -type BitmaskEnumBuilder struct { - obj *BitmaskEnum -} - -func NewBitmaskEnumBuilder() *BitmaskEnumBuilder{ - return &BitmaskEnumBuilder{ - obj: NewBitmaskEnum(), - } -} - -func (p BitmaskEnumBuilder) Emit() *BitmaskEnum{ - return &BitmaskEnum{ - } -} - -func (p *BitmaskEnum) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *BitmaskEnum) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("BitmaskEnum"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *BitmaskEnum) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("BitmaskEnum({})") -} - -// Specifies the field where the exception message is stored. -type ExceptionMessage struct { -} - -func NewExceptionMessage() *ExceptionMessage { - return &ExceptionMessage{} -} - -type ExceptionMessageBuilder struct { - obj *ExceptionMessage -} - -func NewExceptionMessageBuilder() *ExceptionMessageBuilder{ - return &ExceptionMessageBuilder{ - obj: NewExceptionMessage(), - } -} - -func (p ExceptionMessageBuilder) Emit() *ExceptionMessage{ - return &ExceptionMessage{ - } -} - -func (p *ExceptionMessage) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ExceptionMessage) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("ExceptionMessage"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *ExceptionMessage) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("ExceptionMessage({})") -} - -// Generates a const of type schema. Struct containing the schema of the -// annotated type. Optionally specify name to override default -// schema. -// -// Attributes: -// - Name -type GenerateRuntimeSchema struct { - Name string `thrift:"name,1" db:"name" json:"name"` -} - -func NewGenerateRuntimeSchema() *GenerateRuntimeSchema { - return &GenerateRuntimeSchema{} -} - - -func (p *GenerateRuntimeSchema) GetName() string { - return p.Name -} -type GenerateRuntimeSchemaBuilder struct { - obj *GenerateRuntimeSchema -} - -func NewGenerateRuntimeSchemaBuilder() *GenerateRuntimeSchemaBuilder{ - return &GenerateRuntimeSchemaBuilder{ - obj: NewGenerateRuntimeSchema(), - } -} - -func (p GenerateRuntimeSchemaBuilder) Emit() *GenerateRuntimeSchema{ - return &GenerateRuntimeSchema{ - Name: p.obj.Name, - } -} - -func (g *GenerateRuntimeSchemaBuilder) Name(name string) *GenerateRuntimeSchemaBuilder { - g.obj.Name = name - return g -} - -func (g *GenerateRuntimeSchema) SetName(name string) *GenerateRuntimeSchema { - g.Name = name - return g -} - -func (p *GenerateRuntimeSchema) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *GenerateRuntimeSchema) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Name = v - } - return nil -} - -func (p *GenerateRuntimeSchema) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("GenerateRuntimeSchema"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *GenerateRuntimeSchema) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) } - if err := oprot.WriteString(string(p.Name)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) } - return err -} - -func (p *GenerateRuntimeSchema) String() string { - if p == nil { - return "" - } - - nameVal := fmt.Sprintf("%v", p.Name) - return fmt.Sprintf("GenerateRuntimeSchema({Name:%s})", nameVal) -} - -// Indicates that a field's value should never be stored on the stack, and that -// identical values can be shared in immutable contexts. -type InternBox struct { -} - -func NewInternBox() *InternBox { - return &InternBox{} -} - -type InternBoxBuilder struct { - obj *InternBox -} - -func NewInternBoxBuilder() *InternBoxBuilder{ - return &InternBoxBuilder{ - obj: NewInternBox(), - } -} - -func (p InternBoxBuilder) Emit() *InternBox{ - return &InternBox{ - } -} - -func (p *InternBox) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *InternBox) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("InternBox"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *InternBox) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("InternBox({})") -} - -// Indicates that an interaction's methods should be processed sequentially. -type Serial struct { -} - -func NewSerial() *Serial { - return &Serial{} -} - -type SerialBuilder struct { - obj *Serial -} - -func NewSerialBuilder() *SerialBuilder{ - return &SerialBuilder{ - obj: NewSerial(), - } -} - -func (p SerialBuilder) Emit() *Serial{ - return &Serial{ - } -} - -func (p *Serial) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Serial) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Serial"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Serial) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Serial({})") -} - -// Changes the URI of this definition away from the default-generated one. -// -// Attributes: -// - Value -type Uri struct { - Value string `thrift:"value,1" db:"value" json:"value"` -} - -func NewUri() *Uri { - return &Uri{} -} - - -func (p *Uri) GetValue() string { - return p.Value -} -type UriBuilder struct { - obj *Uri -} - -func NewUriBuilder() *UriBuilder{ - return &UriBuilder{ - obj: NewUri(), - } -} - -func (p UriBuilder) Emit() *Uri{ - return &Uri{ - Value: p.obj.Value, - } -} - -func (u *UriBuilder) Value(value string) *UriBuilder { - u.obj.Value = value - return u -} - -func (u *Uri) SetValue(value string) *Uri { - u.Value = value - return u -} - -func (p *Uri) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Uri) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Value = v - } - return nil -} - -func (p *Uri) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Uri"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Uri) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("value", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:value: ", p), err) } - if err := oprot.WriteString(string(p.Value)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.value (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:value: ", p), err) } - return err -} - -func (p *Uri) String() string { - if p == nil { - return "" - } - - valueVal := fmt.Sprintf("%v", p.Value) - return fmt.Sprintf("Uri({Value:%s})", valueVal) -} - -// Changes the priority of this function (default NORMAL). -// -// Attributes: -// - Level -type Priority struct { - Level RpcPriority `thrift:"level,1" db:"level" json:"level"` -} - -func NewPriority() *Priority { - return &Priority{} -} - - -func (p *Priority) GetLevel() RpcPriority { - return p.Level -} -type PriorityBuilder struct { - obj *Priority -} - -func NewPriorityBuilder() *PriorityBuilder{ - return &PriorityBuilder{ - obj: NewPriority(), - } -} - -func (p PriorityBuilder) Emit() *Priority{ - return &Priority{ - Level: p.obj.Level, - } -} - -func (p *PriorityBuilder) Level(level RpcPriority) *PriorityBuilder { - p.obj.Level = level - return p -} - -func (p *Priority) SetLevel(level RpcPriority) *Priority { - p.Level = level - return p -} - -func (p *Priority) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Priority) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - temp := RpcPriority(v) - p.Level = temp - } - return nil -} - -func (p *Priority) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Priority"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Priority) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("level", thrift.I32, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:level: ", p), err) } - if err := oprot.WriteI32(int32(p.Level)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.level (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:level: ", p), err) } - return err -} - -func (p *Priority) String() string { - if p == nil { - return "" - } - - levelVal := fmt.Sprintf("%v", p.Level) - return fmt.Sprintf("Priority({Level:%s})", levelVal) -} - -// Applies unstructured annotations to a definition. -// -// Attributes: -// - Items -type DeprecatedUnvalidatedAnnotations struct { - Items map[string]string `thrift:"items,1" db:"items" json:"items"` -} - -func NewDeprecatedUnvalidatedAnnotations() *DeprecatedUnvalidatedAnnotations { - return &DeprecatedUnvalidatedAnnotations{} -} - - -func (p *DeprecatedUnvalidatedAnnotations) GetItems() map[string]string { - return p.Items -} -type DeprecatedUnvalidatedAnnotationsBuilder struct { - obj *DeprecatedUnvalidatedAnnotations -} - -func NewDeprecatedUnvalidatedAnnotationsBuilder() *DeprecatedUnvalidatedAnnotationsBuilder{ - return &DeprecatedUnvalidatedAnnotationsBuilder{ - obj: NewDeprecatedUnvalidatedAnnotations(), - } -} - -func (p DeprecatedUnvalidatedAnnotationsBuilder) Emit() *DeprecatedUnvalidatedAnnotations{ - return &DeprecatedUnvalidatedAnnotations{ - Items: p.obj.Items, - } -} - -func (d *DeprecatedUnvalidatedAnnotationsBuilder) Items(items map[string]string) *DeprecatedUnvalidatedAnnotationsBuilder { - d.obj.Items = items - return d -} - -func (d *DeprecatedUnvalidatedAnnotations) SetItems(items map[string]string) *DeprecatedUnvalidatedAnnotations { - d.Items = items - return d -} - -func (p *DeprecatedUnvalidatedAnnotations) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *DeprecatedUnvalidatedAnnotations) ReadField1(iprot thrift.Protocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[string]string, size) - p.Items = tMap - for i := 0; i < size; i ++ { - var _key3 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key3 = v - } - var _val4 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _val4 = v - } - p.Items[_key3] = _val4 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *DeprecatedUnvalidatedAnnotations) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("DeprecatedUnvalidatedAnnotations"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *DeprecatedUnvalidatedAnnotations) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("items", thrift.MAP, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:items: ", p), err) } - if err := oprot.WriteMapBegin(thrift.STRING, thrift.STRING, len(p.Items)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.Items { - if err := oprot.WriteString(string(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := oprot.WriteString(string(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:items: ", p), err) } - return err -} - -func (p *DeprecatedUnvalidatedAnnotations) String() string { - if p == nil { - return "" - } - - itemsVal := fmt.Sprintf("%v", p.Items) - return fmt.Sprintf("DeprecatedUnvalidatedAnnotations({Items:%s})", itemsVal) -} - diff --git a/thrift/compiler/test/fixtures/basic-annotations/gen-go/module/badservice.go b/thrift/compiler/test/fixtures/basic-annotations/gen-go/module/badservice.go deleted file mode 100644 index f369afb8630..00000000000 --- a/thrift/compiler/test/fixtures/basic-annotations/gen-go/module/badservice.go +++ /dev/null @@ -1,448 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package module - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -type BadService interface { - Bar() (_r int32, err error) -} - -type BadServiceClientInterface interface { - thrift.ClientInterface - Bar() (_r int32, err error) -} - -type BadServiceClient struct { - BadServiceClientInterface - CC thrift.ClientConn -} - -func(client *BadServiceClient) Open() error { - return client.CC.Open() -} - -func(client *BadServiceClient) Close() error { - return client.CC.Close() -} - -func(client *BadServiceClient) IsOpen() bool { - return client.CC.IsOpen() -} - -func NewBadServiceClientFactory(t thrift.Transport, f thrift.ProtocolFactory) *BadServiceClient { - return &BadServiceClient{ CC: thrift.NewClientConn(t, f) } -} - -func NewBadServiceClient(t thrift.Transport, iprot thrift.Protocol, oprot thrift.Protocol) *BadServiceClient { - return &BadServiceClient{ CC: thrift.NewClientConnWithProtocols(t, iprot, oprot) } -} - -func NewBadServiceClientProtocol(prot thrift.Protocol) *BadServiceClient { - return NewBadServiceClient(prot.Transport(), prot, prot) -} - -func (p *BadServiceClient) Bar() (_r int32, err error) { - var args BadServiceBarArgs - err = p.CC.SendMsg("bar", &args, thrift.CALL) - if err != nil { return } - return p.recvBar() -} - - -func (p *BadServiceClient) recvBar() (value int32, err error) { - var __result BadServiceBarResult - err = p.CC.RecvMsg("bar", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - - -type BadServiceThreadsafeClient struct { - BadServiceClientInterface - CC thrift.ClientConn - Mu sync.Mutex -} - -func(client *BadServiceThreadsafeClient) Open() error { - client.Mu.Lock() - defer client.Mu.Unlock() - return client.CC.Open() -} - -func(client *BadServiceThreadsafeClient) Close() error { - client.Mu.Lock() - defer client.Mu.Unlock() - return client.CC.Close() -} - -func(client *BadServiceThreadsafeClient) IsOpen() bool { - client.Mu.Lock() - defer client.Mu.Unlock() - return client.CC.IsOpen() -} - -func NewBadServiceThreadsafeClientFactory(t thrift.Transport, f thrift.ProtocolFactory) *BadServiceThreadsafeClient { - return &BadServiceThreadsafeClient{ CC: thrift.NewClientConn(t, f) } -} - -func NewBadServiceThreadsafeClient(t thrift.Transport, iprot thrift.Protocol, oprot thrift.Protocol) *BadServiceThreadsafeClient { - return &BadServiceThreadsafeClient{ CC: thrift.NewClientConnWithProtocols(t, iprot, oprot) } -} - -func NewBadServiceThreadsafeClientProtocol(prot thrift.Protocol) *BadServiceThreadsafeClient { - return NewBadServiceThreadsafeClient(prot.Transport(), prot, prot) -} - -func (p *BadServiceThreadsafeClient) Bar() (_r int32, err error) { - p.Mu.Lock() - defer p.Mu.Unlock() - var args BadServiceBarArgs - err = p.CC.SendMsg("bar", &args, thrift.CALL) - if err != nil { return } - return p.recvBar() -} - - -func (p *BadServiceThreadsafeClient) recvBar() (value int32, err error) { - var __result BadServiceBarResult - err = p.CC.RecvMsg("bar", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - - -type BadServiceChannelClient struct { - RequestChannel thrift.RequestChannel -} - -func (c *BadServiceChannelClient) Close() error { - return c.RequestChannel.Close() -} - -func (c *BadServiceChannelClient) IsOpen() bool { - return c.RequestChannel.IsOpen() -} - -func (c *BadServiceChannelClient) Open() error { - return c.RequestChannel.Open() -} - -func NewBadServiceChannelClient(channel thrift.RequestChannel) *BadServiceChannelClient { - return &BadServiceChannelClient{RequestChannel: channel} -} - -func (p *BadServiceChannelClient) Bar(ctx context.Context) (_r int32, err error) { - args := BadServiceBarArgs{ - } - var __result BadServiceBarResult - err = p.RequestChannel.Call(ctx, "bar", &args, &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - - -type BadServiceProcessor struct { - processorMap map[string]thrift.ProcessorFunction - functionServiceMap map[string]string - handler BadService -} - -func (p *BadServiceProcessor) AddToProcessorMap(key string, processor thrift.ProcessorFunction) { - p.processorMap[key] = processor -} - -func (p *BadServiceProcessor) AddToFunctionServiceMap(key, service string) { - p.functionServiceMap[key] = service -} - -func (p *BadServiceProcessor) GetProcessorFunction(key string) (processor thrift.ProcessorFunction, err error) { - if processor, ok := p.processorMap[key]; ok { - return processor, nil - } - return nil, nil // generic error message will be sent -} - -func (p *BadServiceProcessor) ProcessorMap() map[string]thrift.ProcessorFunction { - return p.processorMap -} - -func (p *BadServiceProcessor) FunctionServiceMap() map[string]string { - return p.functionServiceMap -} - -func NewBadServiceProcessor(handler BadService) *BadServiceProcessor { - self6 := &BadServiceProcessor{handler:handler, processorMap:make(map[string]thrift.ProcessorFunction), functionServiceMap:make(map[string]string)} - self6.processorMap["bar"] = &badServiceProcessorBar{handler:handler} - self6.functionServiceMap["bar"] = "BadService" - return self6 -} - -type badServiceProcessorBar struct { - handler BadService -} - -func (p *BadServiceBarResult) Exception() thrift.WritableException { - if p == nil { return nil } - return nil -} - -func (p *badServiceProcessorBar) Read(iprot thrift.Protocol) (thrift.Struct, thrift.Exception) { - args := BadServiceBarArgs{} - if err := args.Read(iprot); err != nil { - return nil, err - } - iprot.ReadMessageEnd() - return &args, nil -} - -func (p *badServiceProcessorBar) Write(seqId int32, result thrift.WritableStruct, oprot thrift.Protocol) (err thrift.Exception) { - var err2 error - messageType := thrift.REPLY - switch result.(type) { - case thrift.ApplicationException: - messageType = thrift.EXCEPTION - } - if err2 = oprot.WriteMessageBegin("bar", messageType, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - return err -} - -func (p *badServiceProcessorBar) Run(argStruct thrift.Struct) (thrift.WritableStruct, thrift.ApplicationException) { - var __result BadServiceBarResult - if retval, err := p.handler.Bar(); err != nil { - switch err.(type) { - default: - x := thrift.NewApplicationExceptionCause(thrift.INTERNAL_ERROR, "Internal error processing bar: " + err.Error(), err) - return x, x - } - } else { - __result.Success = &retval - } - return &__result, nil -} - - -// HELPER FUNCTIONS AND STRUCTURES - -type BadServiceBarArgs struct { - thrift.IRequest -} - -func NewBadServiceBarArgs() *BadServiceBarArgs { - return &BadServiceBarArgs{} -} - -type BadServiceBarArgsBuilder struct { - obj *BadServiceBarArgs -} - -func NewBadServiceBarArgsBuilder() *BadServiceBarArgsBuilder{ - return &BadServiceBarArgsBuilder{ - obj: NewBadServiceBarArgs(), - } -} - -func (p BadServiceBarArgsBuilder) Emit() *BadServiceBarArgs{ - return &BadServiceBarArgs{ - } -} - -func (p *BadServiceBarArgs) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *BadServiceBarArgs) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("bar_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *BadServiceBarArgs) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("BadServiceBarArgs({})") -} - -// Attributes: -// - Success -type BadServiceBarResult struct { - thrift.IResponse - Success *int32 `thrift:"success,0,optional" db:"success" json:"success,omitempty"` -} - -func NewBadServiceBarResult() *BadServiceBarResult { - return &BadServiceBarResult{} -} - -var BadServiceBarResult_Success_DEFAULT int32 -func (p *BadServiceBarResult) GetSuccess() int32 { - if !p.IsSetSuccess() { - return BadServiceBarResult_Success_DEFAULT - } - return *p.Success -} -func (p *BadServiceBarResult) IsSetSuccess() bool { - return p != nil && p.Success != nil -} - -type BadServiceBarResultBuilder struct { - obj *BadServiceBarResult -} - -func NewBadServiceBarResultBuilder() *BadServiceBarResultBuilder{ - return &BadServiceBarResultBuilder{ - obj: NewBadServiceBarResult(), - } -} - -func (p BadServiceBarResultBuilder) Emit() *BadServiceBarResult{ - return &BadServiceBarResult{ - Success: p.obj.Success, - } -} - -func (b *BadServiceBarResultBuilder) Success(success *int32) *BadServiceBarResultBuilder { - b.obj.Success = success - return b -} - -func (b *BadServiceBarResult) SetSuccess(success *int32) *BadServiceBarResult { - b.Success = success - return b -} - -func (p *BadServiceBarResult) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 0: - if err := p.ReadField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *BadServiceBarResult) ReadField0(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - p.Success = &v - } - return nil -} - -func (p *BadServiceBarResult) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("bar_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField0(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *BadServiceBarResult) writeField0(oprot thrift.Protocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.I32, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := oprot.WriteI32(int32(*p.Success)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.success (0) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } - } - return err -} - -func (p *BadServiceBarResult) String() string { - if p == nil { - return "" - } - - var successVal string - if p.Success == nil { - successVal = "" - } else { - successVal = fmt.Sprintf("%v", *p.Success) - } - return fmt.Sprintf("BadServiceBarResult({Success:%s})", successVal) -} - - diff --git a/thrift/compiler/test/fixtures/basic-annotations/gen-go/module/constants.go b/thrift/compiler/test/fixtures/basic-annotations/gen-go/module/constants.go deleted file mode 100644 index 4ed68ac2375..00000000000 --- a/thrift/compiler/test/fixtures/basic-annotations/gen-go/module/constants.go +++ /dev/null @@ -1,32 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package module - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var MyStruct *MyStruct - -func init() { -MyStruct = &MyStruct{ - Major: 42, - Abstract: "abstract", - MyEnum: 2, -} - -} - diff --git a/thrift/compiler/test/fixtures/basic-annotations/gen-go/module/foobarbazservice.go b/thrift/compiler/test/fixtures/basic-annotations/gen-go/module/foobarbazservice.go deleted file mode 100644 index 2231bd61760..00000000000 --- a/thrift/compiler/test/fixtures/basic-annotations/gen-go/module/foobarbazservice.go +++ /dev/null @@ -1,832 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package module - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -type FooBarBazService interface { - FooStructured() (err error) - BarNonStructured() (err error) - Baz() (err error) -} - -type FooBarBazServiceClientInterface interface { - thrift.ClientInterface - FooStructured() (err error) - BarNonStructured() (err error) - Baz() (err error) -} - -type FooBarBazServiceClient struct { - FooBarBazServiceClientInterface - CC thrift.ClientConn -} - -func(client *FooBarBazServiceClient) Open() error { - return client.CC.Open() -} - -func(client *FooBarBazServiceClient) Close() error { - return client.CC.Close() -} - -func(client *FooBarBazServiceClient) IsOpen() bool { - return client.CC.IsOpen() -} - -func NewFooBarBazServiceClientFactory(t thrift.Transport, f thrift.ProtocolFactory) *FooBarBazServiceClient { - return &FooBarBazServiceClient{ CC: thrift.NewClientConn(t, f) } -} - -func NewFooBarBazServiceClient(t thrift.Transport, iprot thrift.Protocol, oprot thrift.Protocol) *FooBarBazServiceClient { - return &FooBarBazServiceClient{ CC: thrift.NewClientConnWithProtocols(t, iprot, oprot) } -} - -func NewFooBarBazServiceClientProtocol(prot thrift.Protocol) *FooBarBazServiceClient { - return NewFooBarBazServiceClient(prot.Transport(), prot, prot) -} - -func (p *FooBarBazServiceClient) FooStructured() (err error) { - var args FooBarBazServiceFooArgs - err = p.CC.SendMsg("foo", &args, thrift.CALL) - if err != nil { return } - return p.recvFoo() -} - - -func (p *FooBarBazServiceClient) recvFoo() (err error) { - var __result FooBarBazServiceFooResult - return p.CC.RecvMsg("foo", &__result) -} - -func (p *FooBarBazServiceClient) BarNonStructured() (err error) { - var args FooBarBazServiceBarArgs - err = p.CC.SendMsg("bar", &args, thrift.CALL) - if err != nil { return } - return p.recvBar() -} - - -func (p *FooBarBazServiceClient) recvBar() (err error) { - var __result FooBarBazServiceBarResult - return p.CC.RecvMsg("bar", &__result) -} - -func (p *FooBarBazServiceClient) Baz() (err error) { - var args FooBarBazServiceBazArgs - err = p.CC.SendMsg("baz", &args, thrift.CALL) - if err != nil { return } - return p.recvBaz() -} - - -func (p *FooBarBazServiceClient) recvBaz() (err error) { - var __result FooBarBazServiceBazResult - return p.CC.RecvMsg("baz", &__result) -} - - -type FooBarBazServiceThreadsafeClient struct { - FooBarBazServiceClientInterface - CC thrift.ClientConn - Mu sync.Mutex -} - -func(client *FooBarBazServiceThreadsafeClient) Open() error { - client.Mu.Lock() - defer client.Mu.Unlock() - return client.CC.Open() -} - -func(client *FooBarBazServiceThreadsafeClient) Close() error { - client.Mu.Lock() - defer client.Mu.Unlock() - return client.CC.Close() -} - -func(client *FooBarBazServiceThreadsafeClient) IsOpen() bool { - client.Mu.Lock() - defer client.Mu.Unlock() - return client.CC.IsOpen() -} - -func NewFooBarBazServiceThreadsafeClientFactory(t thrift.Transport, f thrift.ProtocolFactory) *FooBarBazServiceThreadsafeClient { - return &FooBarBazServiceThreadsafeClient{ CC: thrift.NewClientConn(t, f) } -} - -func NewFooBarBazServiceThreadsafeClient(t thrift.Transport, iprot thrift.Protocol, oprot thrift.Protocol) *FooBarBazServiceThreadsafeClient { - return &FooBarBazServiceThreadsafeClient{ CC: thrift.NewClientConnWithProtocols(t, iprot, oprot) } -} - -func NewFooBarBazServiceThreadsafeClientProtocol(prot thrift.Protocol) *FooBarBazServiceThreadsafeClient { - return NewFooBarBazServiceThreadsafeClient(prot.Transport(), prot, prot) -} - -func (p *FooBarBazServiceThreadsafeClient) FooStructured() (err error) { - p.Mu.Lock() - defer p.Mu.Unlock() - var args FooBarBazServiceFooArgs - err = p.CC.SendMsg("foo", &args, thrift.CALL) - if err != nil { return } - return p.recvFoo() -} - - -func (p *FooBarBazServiceThreadsafeClient) recvFoo() (err error) { - var __result FooBarBazServiceFooResult - return p.CC.RecvMsg("foo", &__result) -} - -func (p *FooBarBazServiceThreadsafeClient) BarNonStructured() (err error) { - p.Mu.Lock() - defer p.Mu.Unlock() - var args FooBarBazServiceBarArgs - err = p.CC.SendMsg("bar", &args, thrift.CALL) - if err != nil { return } - return p.recvBar() -} - - -func (p *FooBarBazServiceThreadsafeClient) recvBar() (err error) { - var __result FooBarBazServiceBarResult - return p.CC.RecvMsg("bar", &__result) -} - -func (p *FooBarBazServiceThreadsafeClient) Baz() (err error) { - p.Mu.Lock() - defer p.Mu.Unlock() - var args FooBarBazServiceBazArgs - err = p.CC.SendMsg("baz", &args, thrift.CALL) - if err != nil { return } - return p.recvBaz() -} - - -func (p *FooBarBazServiceThreadsafeClient) recvBaz() (err error) { - var __result FooBarBazServiceBazResult - return p.CC.RecvMsg("baz", &__result) -} - - -type FooBarBazServiceChannelClient struct { - RequestChannel thrift.RequestChannel -} - -func (c *FooBarBazServiceChannelClient) Close() error { - return c.RequestChannel.Close() -} - -func (c *FooBarBazServiceChannelClient) IsOpen() bool { - return c.RequestChannel.IsOpen() -} - -func (c *FooBarBazServiceChannelClient) Open() error { - return c.RequestChannel.Open() -} - -func NewFooBarBazServiceChannelClient(channel thrift.RequestChannel) *FooBarBazServiceChannelClient { - return &FooBarBazServiceChannelClient{RequestChannel: channel} -} - -func (p *FooBarBazServiceChannelClient) FooStructured(ctx context.Context) (err error) { - args := FooBarBazServiceFooArgs{ - } - var __result FooBarBazServiceFooResult - err = p.RequestChannel.Call(ctx, "foo", &args, &__result) - if err != nil { return } - - return nil -} - -func (p *FooBarBazServiceChannelClient) BarNonStructured(ctx context.Context) (err error) { - args := FooBarBazServiceBarArgs{ - } - var __result FooBarBazServiceBarResult - err = p.RequestChannel.Call(ctx, "bar", &args, &__result) - if err != nil { return } - - return nil -} - -func (p *FooBarBazServiceChannelClient) Baz(ctx context.Context) (err error) { - args := FooBarBazServiceBazArgs{ - } - var __result FooBarBazServiceBazResult - err = p.RequestChannel.Call(ctx, "baz", &args, &__result) - if err != nil { return } - - return nil -} - - -type FooBarBazServiceProcessor struct { - processorMap map[string]thrift.ProcessorFunction - functionServiceMap map[string]string - handler FooBarBazService -} - -func (p *FooBarBazServiceProcessor) AddToProcessorMap(key string, processor thrift.ProcessorFunction) { - p.processorMap[key] = processor -} - -func (p *FooBarBazServiceProcessor) AddToFunctionServiceMap(key, service string) { - p.functionServiceMap[key] = service -} - -func (p *FooBarBazServiceProcessor) GetProcessorFunction(key string) (processor thrift.ProcessorFunction, err error) { - if processor, ok := p.processorMap[key]; ok { - return processor, nil - } - return nil, nil // generic error message will be sent -} - -func (p *FooBarBazServiceProcessor) ProcessorMap() map[string]thrift.ProcessorFunction { - return p.processorMap -} - -func (p *FooBarBazServiceProcessor) FunctionServiceMap() map[string]string { - return p.functionServiceMap -} - -func NewFooBarBazServiceProcessor(handler FooBarBazService) *FooBarBazServiceProcessor { - self8 := &FooBarBazServiceProcessor{handler:handler, processorMap:make(map[string]thrift.ProcessorFunction), functionServiceMap:make(map[string]string)} - self8.processorMap["foo"] = &fooBarBazServiceProcessorFoo{handler:handler} - self8.processorMap["bar"] = &fooBarBazServiceProcessorBar{handler:handler} - self8.processorMap["baz"] = &fooBarBazServiceProcessorBaz{handler:handler} - self8.functionServiceMap["foo"] = "FooBarBazService" - self8.functionServiceMap["bar"] = "FooBarBazService" - self8.functionServiceMap["baz"] = "FooBarBazService" - return self8 -} - -type fooBarBazServiceProcessorFoo struct { - handler FooBarBazService -} - -func (p *FooBarBazServiceFooResult) Exception() thrift.WritableException { - if p == nil { return nil } - return nil -} - -func (p *fooBarBazServiceProcessorFoo) Read(iprot thrift.Protocol) (thrift.Struct, thrift.Exception) { - args := FooBarBazServiceFooArgs{} - if err := args.Read(iprot); err != nil { - return nil, err - } - iprot.ReadMessageEnd() - return &args, nil -} - -func (p *fooBarBazServiceProcessorFoo) Write(seqId int32, result thrift.WritableStruct, oprot thrift.Protocol) (err thrift.Exception) { - var err2 error - messageType := thrift.REPLY - switch result.(type) { - case thrift.ApplicationException: - messageType = thrift.EXCEPTION - } - if err2 = oprot.WriteMessageBegin("foo", messageType, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - return err -} - -func (p *fooBarBazServiceProcessorFoo) Run(argStruct thrift.Struct) (thrift.WritableStruct, thrift.ApplicationException) { - var __result FooBarBazServiceFooResult - if err := p.handler.FooStructured(); err != nil { - switch err.(type) { - default: - x := thrift.NewApplicationExceptionCause(thrift.INTERNAL_ERROR, "Internal error processing foo: " + err.Error(), err) - return x, x - } - } - return &__result, nil -} - -type fooBarBazServiceProcessorBar struct { - handler FooBarBazService -} - -func (p *FooBarBazServiceBarResult) Exception() thrift.WritableException { - if p == nil { return nil } - return nil -} - -func (p *fooBarBazServiceProcessorBar) Read(iprot thrift.Protocol) (thrift.Struct, thrift.Exception) { - args := FooBarBazServiceBarArgs{} - if err := args.Read(iprot); err != nil { - return nil, err - } - iprot.ReadMessageEnd() - return &args, nil -} - -func (p *fooBarBazServiceProcessorBar) Write(seqId int32, result thrift.WritableStruct, oprot thrift.Protocol) (err thrift.Exception) { - var err2 error - messageType := thrift.REPLY - switch result.(type) { - case thrift.ApplicationException: - messageType = thrift.EXCEPTION - } - if err2 = oprot.WriteMessageBegin("bar", messageType, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - return err -} - -func (p *fooBarBazServiceProcessorBar) Run(argStruct thrift.Struct) (thrift.WritableStruct, thrift.ApplicationException) { - var __result FooBarBazServiceBarResult - if err := p.handler.BarNonStructured(); err != nil { - switch err.(type) { - default: - x := thrift.NewApplicationExceptionCause(thrift.INTERNAL_ERROR, "Internal error processing bar: " + err.Error(), err) - return x, x - } - } - return &__result, nil -} - -type fooBarBazServiceProcessorBaz struct { - handler FooBarBazService -} - -func (p *FooBarBazServiceBazResult) Exception() thrift.WritableException { - if p == nil { return nil } - return nil -} - -func (p *fooBarBazServiceProcessorBaz) Read(iprot thrift.Protocol) (thrift.Struct, thrift.Exception) { - args := FooBarBazServiceBazArgs{} - if err := args.Read(iprot); err != nil { - return nil, err - } - iprot.ReadMessageEnd() - return &args, nil -} - -func (p *fooBarBazServiceProcessorBaz) Write(seqId int32, result thrift.WritableStruct, oprot thrift.Protocol) (err thrift.Exception) { - var err2 error - messageType := thrift.REPLY - switch result.(type) { - case thrift.ApplicationException: - messageType = thrift.EXCEPTION - } - if err2 = oprot.WriteMessageBegin("baz", messageType, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - return err -} - -func (p *fooBarBazServiceProcessorBaz) Run(argStruct thrift.Struct) (thrift.WritableStruct, thrift.ApplicationException) { - var __result FooBarBazServiceBazResult - if err := p.handler.Baz(); err != nil { - switch err.(type) { - default: - x := thrift.NewApplicationExceptionCause(thrift.INTERNAL_ERROR, "Internal error processing baz: " + err.Error(), err) - return x, x - } - } - return &__result, nil -} - - -// HELPER FUNCTIONS AND STRUCTURES - -type FooBarBazServiceFooArgs struct { - thrift.IRequest -} - -func NewFooBarBazServiceFooArgs() *FooBarBazServiceFooArgs { - return &FooBarBazServiceFooArgs{} -} - -type FooBarBazServiceFooArgsBuilder struct { - obj *FooBarBazServiceFooArgs -} - -func NewFooBarBazServiceFooArgsBuilder() *FooBarBazServiceFooArgsBuilder{ - return &FooBarBazServiceFooArgsBuilder{ - obj: NewFooBarBazServiceFooArgs(), - } -} - -func (p FooBarBazServiceFooArgsBuilder) Emit() *FooBarBazServiceFooArgs{ - return &FooBarBazServiceFooArgs{ - } -} - -func (p *FooBarBazServiceFooArgs) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *FooBarBazServiceFooArgs) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("foo_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *FooBarBazServiceFooArgs) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("FooBarBazServiceFooArgs({})") -} - -type FooBarBazServiceFooResult struct { - thrift.IResponse -} - -func NewFooBarBazServiceFooResult() *FooBarBazServiceFooResult { - return &FooBarBazServiceFooResult{} -} - -type FooBarBazServiceFooResultBuilder struct { - obj *FooBarBazServiceFooResult -} - -func NewFooBarBazServiceFooResultBuilder() *FooBarBazServiceFooResultBuilder{ - return &FooBarBazServiceFooResultBuilder{ - obj: NewFooBarBazServiceFooResult(), - } -} - -func (p FooBarBazServiceFooResultBuilder) Emit() *FooBarBazServiceFooResult{ - return &FooBarBazServiceFooResult{ - } -} - -func (p *FooBarBazServiceFooResult) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *FooBarBazServiceFooResult) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("foo_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *FooBarBazServiceFooResult) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("FooBarBazServiceFooResult({})") -} - -type FooBarBazServiceBarArgs struct { - thrift.IRequest -} - -func NewFooBarBazServiceBarArgs() *FooBarBazServiceBarArgs { - return &FooBarBazServiceBarArgs{} -} - -type FooBarBazServiceBarArgsBuilder struct { - obj *FooBarBazServiceBarArgs -} - -func NewFooBarBazServiceBarArgsBuilder() *FooBarBazServiceBarArgsBuilder{ - return &FooBarBazServiceBarArgsBuilder{ - obj: NewFooBarBazServiceBarArgs(), - } -} - -func (p FooBarBazServiceBarArgsBuilder) Emit() *FooBarBazServiceBarArgs{ - return &FooBarBazServiceBarArgs{ - } -} - -func (p *FooBarBazServiceBarArgs) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *FooBarBazServiceBarArgs) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("bar_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *FooBarBazServiceBarArgs) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("FooBarBazServiceBarArgs({})") -} - -type FooBarBazServiceBarResult struct { - thrift.IResponse -} - -func NewFooBarBazServiceBarResult() *FooBarBazServiceBarResult { - return &FooBarBazServiceBarResult{} -} - -type FooBarBazServiceBarResultBuilder struct { - obj *FooBarBazServiceBarResult -} - -func NewFooBarBazServiceBarResultBuilder() *FooBarBazServiceBarResultBuilder{ - return &FooBarBazServiceBarResultBuilder{ - obj: NewFooBarBazServiceBarResult(), - } -} - -func (p FooBarBazServiceBarResultBuilder) Emit() *FooBarBazServiceBarResult{ - return &FooBarBazServiceBarResult{ - } -} - -func (p *FooBarBazServiceBarResult) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *FooBarBazServiceBarResult) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("bar_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *FooBarBazServiceBarResult) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("FooBarBazServiceBarResult({})") -} - -type FooBarBazServiceBazArgs struct { - thrift.IRequest -} - -func NewFooBarBazServiceBazArgs() *FooBarBazServiceBazArgs { - return &FooBarBazServiceBazArgs{} -} - -type FooBarBazServiceBazArgsBuilder struct { - obj *FooBarBazServiceBazArgs -} - -func NewFooBarBazServiceBazArgsBuilder() *FooBarBazServiceBazArgsBuilder{ - return &FooBarBazServiceBazArgsBuilder{ - obj: NewFooBarBazServiceBazArgs(), - } -} - -func (p FooBarBazServiceBazArgsBuilder) Emit() *FooBarBazServiceBazArgs{ - return &FooBarBazServiceBazArgs{ - } -} - -func (p *FooBarBazServiceBazArgs) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *FooBarBazServiceBazArgs) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("baz_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *FooBarBazServiceBazArgs) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("FooBarBazServiceBazArgs({})") -} - -type FooBarBazServiceBazResult struct { - thrift.IResponse -} - -func NewFooBarBazServiceBazResult() *FooBarBazServiceBazResult { - return &FooBarBazServiceBazResult{} -} - -type FooBarBazServiceBazResultBuilder struct { - obj *FooBarBazServiceBazResult -} - -func NewFooBarBazServiceBazResultBuilder() *FooBarBazServiceBazResultBuilder{ - return &FooBarBazServiceBazResultBuilder{ - obj: NewFooBarBazServiceBazResult(), - } -} - -func (p FooBarBazServiceBazResultBuilder) Emit() *FooBarBazServiceBazResult{ - return &FooBarBazServiceBazResult{ - } -} - -func (p *FooBarBazServiceBazResult) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *FooBarBazServiceBazResult) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("baz_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *FooBarBazServiceBazResult) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("FooBarBazServiceBazResult({})") -} - - diff --git a/thrift/compiler/test/fixtures/basic-annotations/gen-go/module/myservice.go b/thrift/compiler/test/fixtures/basic-annotations/gen-go/module/myservice.go deleted file mode 100644 index ab31248fde8..00000000000 --- a/thrift/compiler/test/fixtures/basic-annotations/gen-go/module/myservice.go +++ /dev/null @@ -1,2286 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package module - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -type MyService interface { - Ping() (err error) - GetRandomData() (_r string, err error) - // Parameters: - // - Id - HasDataById(id int64) (_r bool, err error) - // Parameters: - // - Id - GoGetDataById(id int64) (_r string, err error) - // Parameters: - // - Id - // - Data - PutDataById(id int64, data string) (err error) - // Parameters: - // - Id - // - Data - LobDataById(id int64, data string) (err error) - GoDoNothing() (err error) -} - -type MyServiceClientInterface interface { - thrift.ClientInterface - Ping() (err error) - GetRandomData() (_r string, err error) - // Parameters: - // - Id - HasDataById(id int64) (_r bool, err error) - // Parameters: - // - Id - GoGetDataById(id int64) (_r string, err error) - // Parameters: - // - Id - // - Data - PutDataById(id int64, data string) (err error) - // Parameters: - // - Id - // - Data - LobDataById(id int64, data string) (err error) - GoDoNothing() (err error) -} - -type MyServiceClient struct { - MyServiceClientInterface - CC thrift.ClientConn -} - -func(client *MyServiceClient) Open() error { - return client.CC.Open() -} - -func(client *MyServiceClient) Close() error { - return client.CC.Close() -} - -func(client *MyServiceClient) IsOpen() bool { - return client.CC.IsOpen() -} - -func NewMyServiceClientFactory(t thrift.Transport, f thrift.ProtocolFactory) *MyServiceClient { - return &MyServiceClient{ CC: thrift.NewClientConn(t, f) } -} - -func NewMyServiceClient(t thrift.Transport, iprot thrift.Protocol, oprot thrift.Protocol) *MyServiceClient { - return &MyServiceClient{ CC: thrift.NewClientConnWithProtocols(t, iprot, oprot) } -} - -func NewMyServiceClientProtocol(prot thrift.Protocol) *MyServiceClient { - return NewMyServiceClient(prot.Transport(), prot, prot) -} - -func (p *MyServiceClient) Ping() (err error) { - var args MyServicePingArgs - err = p.CC.SendMsg("ping", &args, thrift.CALL) - if err != nil { return } - return p.recvPing() -} - - -func (p *MyServiceClient) recvPing() (err error) { - var __result MyServicePingResult - err = p.CC.RecvMsg("ping", &__result) - if err != nil { return } - if __result.MyExcept != nil { - err = __result.MyExcept - return - } - return nil -} - -func (p *MyServiceClient) GetRandomData() (_r string, err error) { - var args MyServiceGetRandomDataArgs - err = p.CC.SendMsg("getRandomData", &args, thrift.CALL) - if err != nil { return } - return p.recvGetRandomData() -} - - -func (p *MyServiceClient) recvGetRandomData() (value string, err error) { - var __result MyServiceGetRandomDataResult - err = p.CC.RecvMsg("getRandomData", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -// Parameters: -// - Id -func (p *MyServiceClient) HasDataById(id int64) (_r bool, err error) { - args := MyServiceHasDataByIdArgs{ - Id : id, - } - err = p.CC.SendMsg("hasDataById", &args, thrift.CALL) - if err != nil { return } - return p.recvHasDataById() -} - - -func (p *MyServiceClient) recvHasDataById() (value bool, err error) { - var __result MyServiceHasDataByIdResult - err = p.CC.RecvMsg("hasDataById", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -// Parameters: -// - Id -func (p *MyServiceClient) GoGetDataById(id int64) (_r string, err error) { - args := MyServiceGetDataByIdArgs{ - Id : id, - } - err = p.CC.SendMsg("getDataById", &args, thrift.CALL) - if err != nil { return } - return p.recvGetDataById() -} - - -func (p *MyServiceClient) recvGetDataById() (value string, err error) { - var __result MyServiceGetDataByIdResult - err = p.CC.RecvMsg("getDataById", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -// Parameters: -// - Id -// - Data -func (p *MyServiceClient) PutDataById(id int64, data string) (err error) { - args := MyServicePutDataByIdArgs{ - Id : id, - Data : data, - } - err = p.CC.SendMsg("putDataById", &args, thrift.CALL) - if err != nil { return } - return p.recvPutDataById() -} - - -func (p *MyServiceClient) recvPutDataById() (err error) { - var __result MyServicePutDataByIdResult - return p.CC.RecvMsg("putDataById", &__result) -} - -// Parameters: -// - Id -// - Data -func (p *MyServiceClient) LobDataById(id int64, data string) (err error) { - args := MyServiceLobDataByIdArgs{ - Id : id, - Data : data, - } - err = p.CC.SendMsg("lobDataById", &args, thrift.ONEWAY) - if err != nil { return } - return -} - -func (p *MyServiceClient) GoDoNothing() (err error) { - var args MyServiceDoNothingArgs - err = p.CC.SendMsg("doNothing", &args, thrift.CALL) - if err != nil { return } - return p.recvDoNothing() -} - - -func (p *MyServiceClient) recvDoNothing() (err error) { - var __result MyServiceDoNothingResult - return p.CC.RecvMsg("doNothing", &__result) -} - - -type MyServiceThreadsafeClient struct { - MyServiceClientInterface - CC thrift.ClientConn - Mu sync.Mutex -} - -func(client *MyServiceThreadsafeClient) Open() error { - client.Mu.Lock() - defer client.Mu.Unlock() - return client.CC.Open() -} - -func(client *MyServiceThreadsafeClient) Close() error { - client.Mu.Lock() - defer client.Mu.Unlock() - return client.CC.Close() -} - -func(client *MyServiceThreadsafeClient) IsOpen() bool { - client.Mu.Lock() - defer client.Mu.Unlock() - return client.CC.IsOpen() -} - -func NewMyServiceThreadsafeClientFactory(t thrift.Transport, f thrift.ProtocolFactory) *MyServiceThreadsafeClient { - return &MyServiceThreadsafeClient{ CC: thrift.NewClientConn(t, f) } -} - -func NewMyServiceThreadsafeClient(t thrift.Transport, iprot thrift.Protocol, oprot thrift.Protocol) *MyServiceThreadsafeClient { - return &MyServiceThreadsafeClient{ CC: thrift.NewClientConnWithProtocols(t, iprot, oprot) } -} - -func NewMyServiceThreadsafeClientProtocol(prot thrift.Protocol) *MyServiceThreadsafeClient { - return NewMyServiceThreadsafeClient(prot.Transport(), prot, prot) -} - -func (p *MyServiceThreadsafeClient) Ping() (err error) { - p.Mu.Lock() - defer p.Mu.Unlock() - var args MyServicePingArgs - err = p.CC.SendMsg("ping", &args, thrift.CALL) - if err != nil { return } - return p.recvPing() -} - - -func (p *MyServiceThreadsafeClient) recvPing() (err error) { - var __result MyServicePingResult - err = p.CC.RecvMsg("ping", &__result) - if err != nil { return } - if __result.MyExcept != nil { - err = __result.MyExcept - return - } - return nil -} - -func (p *MyServiceThreadsafeClient) GetRandomData() (_r string, err error) { - p.Mu.Lock() - defer p.Mu.Unlock() - var args MyServiceGetRandomDataArgs - err = p.CC.SendMsg("getRandomData", &args, thrift.CALL) - if err != nil { return } - return p.recvGetRandomData() -} - - -func (p *MyServiceThreadsafeClient) recvGetRandomData() (value string, err error) { - var __result MyServiceGetRandomDataResult - err = p.CC.RecvMsg("getRandomData", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -// Parameters: -// - Id -func (p *MyServiceThreadsafeClient) HasDataById(id int64) (_r bool, err error) { - p.Mu.Lock() - defer p.Mu.Unlock() - args := MyServiceHasDataByIdArgs{ - Id : id, - } - err = p.CC.SendMsg("hasDataById", &args, thrift.CALL) - if err != nil { return } - return p.recvHasDataById() -} - - -func (p *MyServiceThreadsafeClient) recvHasDataById() (value bool, err error) { - var __result MyServiceHasDataByIdResult - err = p.CC.RecvMsg("hasDataById", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -// Parameters: -// - Id -func (p *MyServiceThreadsafeClient) GoGetDataById(id int64) (_r string, err error) { - p.Mu.Lock() - defer p.Mu.Unlock() - args := MyServiceGetDataByIdArgs{ - Id : id, - } - err = p.CC.SendMsg("getDataById", &args, thrift.CALL) - if err != nil { return } - return p.recvGetDataById() -} - - -func (p *MyServiceThreadsafeClient) recvGetDataById() (value string, err error) { - var __result MyServiceGetDataByIdResult - err = p.CC.RecvMsg("getDataById", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -// Parameters: -// - Id -// - Data -func (p *MyServiceThreadsafeClient) PutDataById(id int64, data string) (err error) { - p.Mu.Lock() - defer p.Mu.Unlock() - args := MyServicePutDataByIdArgs{ - Id : id, - Data : data, - } - err = p.CC.SendMsg("putDataById", &args, thrift.CALL) - if err != nil { return } - return p.recvPutDataById() -} - - -func (p *MyServiceThreadsafeClient) recvPutDataById() (err error) { - var __result MyServicePutDataByIdResult - return p.CC.RecvMsg("putDataById", &__result) -} - -// Parameters: -// - Id -// - Data -func (p *MyServiceThreadsafeClient) LobDataById(id int64, data string) (err error) { - p.Mu.Lock() - defer p.Mu.Unlock() - args := MyServiceLobDataByIdArgs{ - Id : id, - Data : data, - } - err = p.CC.SendMsg("lobDataById", &args, thrift.ONEWAY) - if err != nil { return } - return -} - -func (p *MyServiceThreadsafeClient) GoDoNothing() (err error) { - p.Mu.Lock() - defer p.Mu.Unlock() - var args MyServiceDoNothingArgs - err = p.CC.SendMsg("doNothing", &args, thrift.CALL) - if err != nil { return } - return p.recvDoNothing() -} - - -func (p *MyServiceThreadsafeClient) recvDoNothing() (err error) { - var __result MyServiceDoNothingResult - return p.CC.RecvMsg("doNothing", &__result) -} - - -type MyServiceChannelClient struct { - RequestChannel thrift.RequestChannel -} - -func (c *MyServiceChannelClient) Close() error { - return c.RequestChannel.Close() -} - -func (c *MyServiceChannelClient) IsOpen() bool { - return c.RequestChannel.IsOpen() -} - -func (c *MyServiceChannelClient) Open() error { - return c.RequestChannel.Open() -} - -func NewMyServiceChannelClient(channel thrift.RequestChannel) *MyServiceChannelClient { - return &MyServiceChannelClient{RequestChannel: channel} -} - -func (p *MyServiceChannelClient) Ping(ctx context.Context) (err error) { - args := MyServicePingArgs{ - } - var __result MyServicePingResult - err = p.RequestChannel.Call(ctx, "ping", &args, &__result) - if err != nil { return } - if __result.MyExcept != nil { - err = __result.MyExcept - return - } - return nil -} - -func (p *MyServiceChannelClient) GetRandomData(ctx context.Context) (_r string, err error) { - args := MyServiceGetRandomDataArgs{ - } - var __result MyServiceGetRandomDataResult - err = p.RequestChannel.Call(ctx, "getRandomData", &args, &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -// Parameters: -// - Id -func (p *MyServiceChannelClient) HasDataById(ctx context.Context, id int64) (_r bool, err error) { - args := MyServiceHasDataByIdArgs{ - Id : id, - } - var __result MyServiceHasDataByIdResult - err = p.RequestChannel.Call(ctx, "hasDataById", &args, &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -// Parameters: -// - Id -func (p *MyServiceChannelClient) GoGetDataById(ctx context.Context, id int64) (_r string, err error) { - args := MyServiceGetDataByIdArgs{ - Id : id, - } - var __result MyServiceGetDataByIdResult - err = p.RequestChannel.Call(ctx, "getDataById", &args, &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -// Parameters: -// - Id -// - Data -func (p *MyServiceChannelClient) PutDataById(ctx context.Context, id int64, data string) (err error) { - args := MyServicePutDataByIdArgs{ - Id : id, - Data : data, - } - var __result MyServicePutDataByIdResult - err = p.RequestChannel.Call(ctx, "putDataById", &args, &__result) - if err != nil { return } - - return nil -} - -// Parameters: -// - Id -// - Data -func (p *MyServiceChannelClient) LobDataById(ctx context.Context, id int64, data string) (err error) { - args := MyServiceLobDataByIdArgs{ - Id : id, - Data : data, - } - err = p.RequestChannel.Oneway(ctx, "lobDataById", &args) - if err != nil { return } - - return nil -} - -func (p *MyServiceChannelClient) GoDoNothing(ctx context.Context) (err error) { - args := MyServiceDoNothingArgs{ - } - var __result MyServiceDoNothingResult - err = p.RequestChannel.Call(ctx, "doNothing", &args, &__result) - if err != nil { return } - - return nil -} - - -type MyServiceProcessor struct { - processorMap map[string]thrift.ProcessorFunction - functionServiceMap map[string]string - handler MyService -} - -func (p *MyServiceProcessor) AddToProcessorMap(key string, processor thrift.ProcessorFunction) { - p.processorMap[key] = processor -} - -func (p *MyServiceProcessor) AddToFunctionServiceMap(key, service string) { - p.functionServiceMap[key] = service -} - -func (p *MyServiceProcessor) GetProcessorFunction(key string) (processor thrift.ProcessorFunction, err error) { - if processor, ok := p.processorMap[key]; ok { - return processor, nil - } - return nil, nil // generic error message will be sent -} - -func (p *MyServiceProcessor) ProcessorMap() map[string]thrift.ProcessorFunction { - return p.processorMap -} - -func (p *MyServiceProcessor) FunctionServiceMap() map[string]string { - return p.functionServiceMap -} - -func NewMyServiceProcessor(handler MyService) *MyServiceProcessor { - self1 := &MyServiceProcessor{handler:handler, processorMap:make(map[string]thrift.ProcessorFunction), functionServiceMap:make(map[string]string)} - self1.processorMap["ping"] = &myServiceProcessorPing{handler:handler} - self1.processorMap["getRandomData"] = &myServiceProcessorGetRandomData{handler:handler} - self1.processorMap["hasDataById"] = &myServiceProcessorHasDataById{handler:handler} - self1.processorMap["getDataById"] = &myServiceProcessorGetDataById{handler:handler} - self1.processorMap["putDataById"] = &myServiceProcessorPutDataById{handler:handler} - self1.processorMap["lobDataById"] = &myServiceProcessorLobDataById{handler:handler} - self1.processorMap["doNothing"] = &myServiceProcessorDoNothing{handler:handler} - self1.functionServiceMap["ping"] = "MyService" - self1.functionServiceMap["getRandomData"] = "MyService" - self1.functionServiceMap["hasDataById"] = "MyService" - self1.functionServiceMap["getDataById"] = "MyService" - self1.functionServiceMap["putDataById"] = "MyService" - self1.functionServiceMap["lobDataById"] = "MyService" - self1.functionServiceMap["doNothing"] = "MyService" - return self1 -} - -type myServiceProcessorPing struct { - handler MyService -} - -func (p *MyServicePingResult) Exception() thrift.WritableException { - if p == nil { return nil } - if p.MyExcept != nil { - return p.MyExcept - } - return nil -} - -func (p *myServiceProcessorPing) Read(iprot thrift.Protocol) (thrift.Struct, thrift.Exception) { - args := MyServicePingArgs{} - if err := args.Read(iprot); err != nil { - return nil, err - } - iprot.ReadMessageEnd() - return &args, nil -} - -func (p *myServiceProcessorPing) Write(seqId int32, result thrift.WritableStruct, oprot thrift.Protocol) (err thrift.Exception) { - var err2 error - messageType := thrift.REPLY - switch v := result.(type) { - case *MyException: - msg := MyServicePingResult{MyExcept: v} - result = &msg - case thrift.ApplicationException: - messageType = thrift.EXCEPTION - } - if err2 = oprot.WriteMessageBegin("ping", messageType, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - return err -} - -func (p *myServiceProcessorPing) Run(argStruct thrift.Struct) (thrift.WritableStruct, thrift.ApplicationException) { - var __result MyServicePingResult - if err := p.handler.Ping(); err != nil { - switch v := err.(type) { - case *MyException: - __result.MyExcept = v - default: - x := thrift.NewApplicationExceptionCause(thrift.INTERNAL_ERROR, "Internal error processing ping: " + err.Error(), err) - return x, x - } - } - return &__result, nil -} - -type myServiceProcessorGetRandomData struct { - handler MyService -} - -func (p *MyServiceGetRandomDataResult) Exception() thrift.WritableException { - if p == nil { return nil } - return nil -} - -func (p *myServiceProcessorGetRandomData) Read(iprot thrift.Protocol) (thrift.Struct, thrift.Exception) { - args := MyServiceGetRandomDataArgs{} - if err := args.Read(iprot); err != nil { - return nil, err - } - iprot.ReadMessageEnd() - return &args, nil -} - -func (p *myServiceProcessorGetRandomData) Write(seqId int32, result thrift.WritableStruct, oprot thrift.Protocol) (err thrift.Exception) { - var err2 error - messageType := thrift.REPLY - switch result.(type) { - case thrift.ApplicationException: - messageType = thrift.EXCEPTION - } - if err2 = oprot.WriteMessageBegin("getRandomData", messageType, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - return err -} - -func (p *myServiceProcessorGetRandomData) Run(argStruct thrift.Struct) (thrift.WritableStruct, thrift.ApplicationException) { - var __result MyServiceGetRandomDataResult - if retval, err := p.handler.GetRandomData(); err != nil { - switch err.(type) { - default: - x := thrift.NewApplicationExceptionCause(thrift.INTERNAL_ERROR, "Internal error processing getRandomData: " + err.Error(), err) - return x, x - } - } else { - __result.Success = &retval - } - return &__result, nil -} - -type myServiceProcessorHasDataById struct { - handler MyService -} - -func (p *MyServiceHasDataByIdResult) Exception() thrift.WritableException { - if p == nil { return nil } - return nil -} - -func (p *myServiceProcessorHasDataById) Read(iprot thrift.Protocol) (thrift.Struct, thrift.Exception) { - args := MyServiceHasDataByIdArgs{} - if err := args.Read(iprot); err != nil { - return nil, err - } - iprot.ReadMessageEnd() - return &args, nil -} - -func (p *myServiceProcessorHasDataById) Write(seqId int32, result thrift.WritableStruct, oprot thrift.Protocol) (err thrift.Exception) { - var err2 error - messageType := thrift.REPLY - switch result.(type) { - case thrift.ApplicationException: - messageType = thrift.EXCEPTION - } - if err2 = oprot.WriteMessageBegin("hasDataById", messageType, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - return err -} - -func (p *myServiceProcessorHasDataById) Run(argStruct thrift.Struct) (thrift.WritableStruct, thrift.ApplicationException) { - args := argStruct.(*MyServiceHasDataByIdArgs) - var __result MyServiceHasDataByIdResult - if retval, err := p.handler.HasDataById(args.Id); err != nil { - switch err.(type) { - default: - x := thrift.NewApplicationExceptionCause(thrift.INTERNAL_ERROR, "Internal error processing hasDataById: " + err.Error(), err) - return x, x - } - } else { - __result.Success = &retval - } - return &__result, nil -} - -type myServiceProcessorGetDataById struct { - handler MyService -} - -func (p *MyServiceGetDataByIdResult) Exception() thrift.WritableException { - if p == nil { return nil } - return nil -} - -func (p *myServiceProcessorGetDataById) Read(iprot thrift.Protocol) (thrift.Struct, thrift.Exception) { - args := MyServiceGetDataByIdArgs{} - if err := args.Read(iprot); err != nil { - return nil, err - } - iprot.ReadMessageEnd() - return &args, nil -} - -func (p *myServiceProcessorGetDataById) Write(seqId int32, result thrift.WritableStruct, oprot thrift.Protocol) (err thrift.Exception) { - var err2 error - messageType := thrift.REPLY - switch result.(type) { - case thrift.ApplicationException: - messageType = thrift.EXCEPTION - } - if err2 = oprot.WriteMessageBegin("getDataById", messageType, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - return err -} - -func (p *myServiceProcessorGetDataById) Run(argStruct thrift.Struct) (thrift.WritableStruct, thrift.ApplicationException) { - args := argStruct.(*MyServiceGetDataByIdArgs) - var __result MyServiceGetDataByIdResult - if retval, err := p.handler.GoGetDataById(args.Id); err != nil { - switch err.(type) { - default: - x := thrift.NewApplicationExceptionCause(thrift.INTERNAL_ERROR, "Internal error processing getDataById: " + err.Error(), err) - return x, x - } - } else { - __result.Success = &retval - } - return &__result, nil -} - -type myServiceProcessorPutDataById struct { - handler MyService -} - -func (p *MyServicePutDataByIdResult) Exception() thrift.WritableException { - if p == nil { return nil } - return nil -} - -func (p *myServiceProcessorPutDataById) Read(iprot thrift.Protocol) (thrift.Struct, thrift.Exception) { - args := MyServicePutDataByIdArgs{} - if err := args.Read(iprot); err != nil { - return nil, err - } - iprot.ReadMessageEnd() - return &args, nil -} - -func (p *myServiceProcessorPutDataById) Write(seqId int32, result thrift.WritableStruct, oprot thrift.Protocol) (err thrift.Exception) { - var err2 error - messageType := thrift.REPLY - switch result.(type) { - case thrift.ApplicationException: - messageType = thrift.EXCEPTION - } - if err2 = oprot.WriteMessageBegin("putDataById", messageType, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - return err -} - -func (p *myServiceProcessorPutDataById) Run(argStruct thrift.Struct) (thrift.WritableStruct, thrift.ApplicationException) { - args := argStruct.(*MyServicePutDataByIdArgs) - var __result MyServicePutDataByIdResult - if err := p.handler.PutDataById(args.Id, args.Data); err != nil { - switch err.(type) { - default: - x := thrift.NewApplicationExceptionCause(thrift.INTERNAL_ERROR, "Internal error processing putDataById: " + err.Error(), err) - return x, x - } - } - return &__result, nil -} - -type myServiceProcessorLobDataById struct { - handler MyService -} - -func (p *myServiceProcessorLobDataById) Read(iprot thrift.Protocol) (thrift.Struct, thrift.Exception) { - args := MyServiceLobDataByIdArgs{} - if err := args.Read(iprot); err != nil { - return nil, err - } - iprot.ReadMessageEnd() - return &args, nil -} - -func (p *myServiceProcessorLobDataById) Write(seqId int32, result thrift.WritableStruct, oprot thrift.Protocol) (err thrift.Exception) { - var err2 error - messageType := thrift.REPLY - switch result.(type) { - case thrift.ApplicationException: - messageType = thrift.EXCEPTION - } - if err2 = oprot.WriteMessageBegin("lobDataById", messageType, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - return err -} - -func (p *myServiceProcessorLobDataById) Run(argStruct thrift.Struct) (thrift.WritableStruct, thrift.ApplicationException) { - args := argStruct.(*MyServiceLobDataByIdArgs) - if err := p.handler.LobDataById(args.Id, args.Data); err != nil { - switch err.(type) { - default: - x := thrift.NewApplicationExceptionCause(thrift.INTERNAL_ERROR, "Internal error processing lobDataById: " + err.Error(), err) - return x, x - } - } - return nil, nil -} - -type myServiceProcessorDoNothing struct { - handler MyService -} - -func (p *MyServiceDoNothingResult) Exception() thrift.WritableException { - if p == nil { return nil } - return nil -} - -func (p *myServiceProcessorDoNothing) Read(iprot thrift.Protocol) (thrift.Struct, thrift.Exception) { - args := MyServiceDoNothingArgs{} - if err := args.Read(iprot); err != nil { - return nil, err - } - iprot.ReadMessageEnd() - return &args, nil -} - -func (p *myServiceProcessorDoNothing) Write(seqId int32, result thrift.WritableStruct, oprot thrift.Protocol) (err thrift.Exception) { - var err2 error - messageType := thrift.REPLY - switch result.(type) { - case thrift.ApplicationException: - messageType = thrift.EXCEPTION - } - if err2 = oprot.WriteMessageBegin("doNothing", messageType, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - return err -} - -func (p *myServiceProcessorDoNothing) Run(argStruct thrift.Struct) (thrift.WritableStruct, thrift.ApplicationException) { - var __result MyServiceDoNothingResult - if err := p.handler.GoDoNothing(); err != nil { - switch err.(type) { - default: - x := thrift.NewApplicationExceptionCause(thrift.INTERNAL_ERROR, "Internal error processing doNothing: " + err.Error(), err) - return x, x - } - } - return &__result, nil -} - - -// HELPER FUNCTIONS AND STRUCTURES - -type MyServicePingArgs struct { - thrift.IRequest -} - -func NewMyServicePingArgs() *MyServicePingArgs { - return &MyServicePingArgs{} -} - -type MyServicePingArgsBuilder struct { - obj *MyServicePingArgs -} - -func NewMyServicePingArgsBuilder() *MyServicePingArgsBuilder{ - return &MyServicePingArgsBuilder{ - obj: NewMyServicePingArgs(), - } -} - -func (p MyServicePingArgsBuilder) Emit() *MyServicePingArgs{ - return &MyServicePingArgs{ - } -} - -func (p *MyServicePingArgs) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyServicePingArgs) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("ping_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyServicePingArgs) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("MyServicePingArgs({})") -} - -// Attributes: -// - MyExcept -type MyServicePingResult struct { - thrift.IResponse - MyExcept *MyException `thrift:"myExcept,1,optional" db:"myExcept" json:"myExcept,omitempty"` -} - -func NewMyServicePingResult() *MyServicePingResult { - return &MyServicePingResult{} -} - -var MyServicePingResult_MyExcept_DEFAULT *MyException -func (p *MyServicePingResult) GetMyExcept() *MyException { - if !p.IsSetMyExcept() { - return MyServicePingResult_MyExcept_DEFAULT - } - return p.MyExcept -} -func (p *MyServicePingResult) IsSetMyExcept() bool { - return p != nil && p.MyExcept != nil -} - -type MyServicePingResultBuilder struct { - obj *MyServicePingResult -} - -func NewMyServicePingResultBuilder() *MyServicePingResultBuilder{ - return &MyServicePingResultBuilder{ - obj: NewMyServicePingResult(), - } -} - -func (p MyServicePingResultBuilder) Emit() *MyServicePingResult{ - return &MyServicePingResult{ - MyExcept: p.obj.MyExcept, - } -} - -func (m *MyServicePingResultBuilder) MyExcept(myExcept *MyException) *MyServicePingResultBuilder { - m.obj.MyExcept = myExcept - return m -} - -func (m *MyServicePingResult) SetMyExcept(myExcept *MyException) *MyServicePingResult { - m.MyExcept = myExcept - return m -} - -func (p *MyServicePingResult) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyServicePingResult) ReadField1(iprot thrift.Protocol) error { - p.MyExcept = NewMyException() - if err := p.MyExcept.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.MyExcept), err) - } - return nil -} - -func (p *MyServicePingResult) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("ping_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyServicePingResult) writeField1(oprot thrift.Protocol) (err error) { - if p.IsSetMyExcept() { - if err := oprot.WriteFieldBegin("myExcept", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:myExcept: ", p), err) } - if err := p.MyExcept.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.MyExcept), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:myExcept: ", p), err) } - } - return err -} - -func (p *MyServicePingResult) String() string { - if p == nil { - return "" - } - - var myExceptVal string - if p.MyExcept == nil { - myExceptVal = "" - } else { - myExceptVal = fmt.Sprintf("%v", p.MyExcept) - } - return fmt.Sprintf("MyServicePingResult({MyExcept:%s})", myExceptVal) -} - -type MyServiceGetRandomDataArgs struct { - thrift.IRequest -} - -func NewMyServiceGetRandomDataArgs() *MyServiceGetRandomDataArgs { - return &MyServiceGetRandomDataArgs{} -} - -type MyServiceGetRandomDataArgsBuilder struct { - obj *MyServiceGetRandomDataArgs -} - -func NewMyServiceGetRandomDataArgsBuilder() *MyServiceGetRandomDataArgsBuilder{ - return &MyServiceGetRandomDataArgsBuilder{ - obj: NewMyServiceGetRandomDataArgs(), - } -} - -func (p MyServiceGetRandomDataArgsBuilder) Emit() *MyServiceGetRandomDataArgs{ - return &MyServiceGetRandomDataArgs{ - } -} - -func (p *MyServiceGetRandomDataArgs) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyServiceGetRandomDataArgs) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("getRandomData_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyServiceGetRandomDataArgs) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("MyServiceGetRandomDataArgs({})") -} - -// Attributes: -// - Success -type MyServiceGetRandomDataResult struct { - thrift.IResponse - Success *string `thrift:"success,0,optional" db:"success" json:"success,omitempty"` -} - -func NewMyServiceGetRandomDataResult() *MyServiceGetRandomDataResult { - return &MyServiceGetRandomDataResult{} -} - -var MyServiceGetRandomDataResult_Success_DEFAULT string -func (p *MyServiceGetRandomDataResult) GetSuccess() string { - if !p.IsSetSuccess() { - return MyServiceGetRandomDataResult_Success_DEFAULT - } - return *p.Success -} -func (p *MyServiceGetRandomDataResult) IsSetSuccess() bool { - return p != nil && p.Success != nil -} - -type MyServiceGetRandomDataResultBuilder struct { - obj *MyServiceGetRandomDataResult -} - -func NewMyServiceGetRandomDataResultBuilder() *MyServiceGetRandomDataResultBuilder{ - return &MyServiceGetRandomDataResultBuilder{ - obj: NewMyServiceGetRandomDataResult(), - } -} - -func (p MyServiceGetRandomDataResultBuilder) Emit() *MyServiceGetRandomDataResult{ - return &MyServiceGetRandomDataResult{ - Success: p.obj.Success, - } -} - -func (m *MyServiceGetRandomDataResultBuilder) Success(success *string) *MyServiceGetRandomDataResultBuilder { - m.obj.Success = success - return m -} - -func (m *MyServiceGetRandomDataResult) SetSuccess(success *string) *MyServiceGetRandomDataResult { - m.Success = success - return m -} - -func (p *MyServiceGetRandomDataResult) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 0: - if err := p.ReadField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyServiceGetRandomDataResult) ReadField0(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - p.Success = &v - } - return nil -} - -func (p *MyServiceGetRandomDataResult) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("getRandomData_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField0(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyServiceGetRandomDataResult) writeField0(oprot thrift.Protocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRING, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := oprot.WriteString(string(*p.Success)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.success (0) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } - } - return err -} - -func (p *MyServiceGetRandomDataResult) String() string { - if p == nil { - return "" - } - - var successVal string - if p.Success == nil { - successVal = "" - } else { - successVal = fmt.Sprintf("%v", *p.Success) - } - return fmt.Sprintf("MyServiceGetRandomDataResult({Success:%s})", successVal) -} - -// Attributes: -// - Id -type MyServiceHasDataByIdArgs struct { - thrift.IRequest - Id int64 `thrift:"id,1" db:"id" json:"id"` -} - -func NewMyServiceHasDataByIdArgs() *MyServiceHasDataByIdArgs { - return &MyServiceHasDataByIdArgs{} -} - - -func (p *MyServiceHasDataByIdArgs) GetId() int64 { - return p.Id -} -type MyServiceHasDataByIdArgsBuilder struct { - obj *MyServiceHasDataByIdArgs -} - -func NewMyServiceHasDataByIdArgsBuilder() *MyServiceHasDataByIdArgsBuilder{ - return &MyServiceHasDataByIdArgsBuilder{ - obj: NewMyServiceHasDataByIdArgs(), - } -} - -func (p MyServiceHasDataByIdArgsBuilder) Emit() *MyServiceHasDataByIdArgs{ - return &MyServiceHasDataByIdArgs{ - Id: p.obj.Id, - } -} - -func (m *MyServiceHasDataByIdArgsBuilder) Id(id int64) *MyServiceHasDataByIdArgsBuilder { - m.obj.Id = id - return m -} - -func (m *MyServiceHasDataByIdArgs) SetId(id int64) *MyServiceHasDataByIdArgs { - m.Id = id - return m -} - -func (p *MyServiceHasDataByIdArgs) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyServiceHasDataByIdArgs) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Id = v - } - return nil -} - -func (p *MyServiceHasDataByIdArgs) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("hasDataById_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyServiceHasDataByIdArgs) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("id", thrift.I64, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:id: ", p), err) } - if err := oprot.WriteI64(int64(p.Id)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.id (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:id: ", p), err) } - return err -} - -func (p *MyServiceHasDataByIdArgs) String() string { - if p == nil { - return "" - } - - idVal := fmt.Sprintf("%v", p.Id) - return fmt.Sprintf("MyServiceHasDataByIdArgs({Id:%s})", idVal) -} - -// Attributes: -// - Success -type MyServiceHasDataByIdResult struct { - thrift.IResponse - Success *bool `thrift:"success,0,optional" db:"success" json:"success,omitempty"` -} - -func NewMyServiceHasDataByIdResult() *MyServiceHasDataByIdResult { - return &MyServiceHasDataByIdResult{} -} - -var MyServiceHasDataByIdResult_Success_DEFAULT bool -func (p *MyServiceHasDataByIdResult) GetSuccess() bool { - if !p.IsSetSuccess() { - return MyServiceHasDataByIdResult_Success_DEFAULT - } - return *p.Success -} -func (p *MyServiceHasDataByIdResult) IsSetSuccess() bool { - return p != nil && p.Success != nil -} - -type MyServiceHasDataByIdResultBuilder struct { - obj *MyServiceHasDataByIdResult -} - -func NewMyServiceHasDataByIdResultBuilder() *MyServiceHasDataByIdResultBuilder{ - return &MyServiceHasDataByIdResultBuilder{ - obj: NewMyServiceHasDataByIdResult(), - } -} - -func (p MyServiceHasDataByIdResultBuilder) Emit() *MyServiceHasDataByIdResult{ - return &MyServiceHasDataByIdResult{ - Success: p.obj.Success, - } -} - -func (m *MyServiceHasDataByIdResultBuilder) Success(success *bool) *MyServiceHasDataByIdResultBuilder { - m.obj.Success = success - return m -} - -func (m *MyServiceHasDataByIdResult) SetSuccess(success *bool) *MyServiceHasDataByIdResult { - m.Success = success - return m -} - -func (p *MyServiceHasDataByIdResult) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 0: - if err := p.ReadField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyServiceHasDataByIdResult) ReadField0(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - p.Success = &v - } - return nil -} - -func (p *MyServiceHasDataByIdResult) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("hasDataById_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField0(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyServiceHasDataByIdResult) writeField0(oprot thrift.Protocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.BOOL, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := oprot.WriteBool(bool(*p.Success)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.success (0) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } - } - return err -} - -func (p *MyServiceHasDataByIdResult) String() string { - if p == nil { - return "" - } - - var successVal string - if p.Success == nil { - successVal = "" - } else { - successVal = fmt.Sprintf("%v", *p.Success) - } - return fmt.Sprintf("MyServiceHasDataByIdResult({Success:%s})", successVal) -} - -// Attributes: -// - Id -type MyServiceGetDataByIdArgs struct { - thrift.IRequest - Id int64 `thrift:"id,1" db:"id" json:"id"` -} - -func NewMyServiceGetDataByIdArgs() *MyServiceGetDataByIdArgs { - return &MyServiceGetDataByIdArgs{} -} - - -func (p *MyServiceGetDataByIdArgs) GetId() int64 { - return p.Id -} -type MyServiceGetDataByIdArgsBuilder struct { - obj *MyServiceGetDataByIdArgs -} - -func NewMyServiceGetDataByIdArgsBuilder() *MyServiceGetDataByIdArgsBuilder{ - return &MyServiceGetDataByIdArgsBuilder{ - obj: NewMyServiceGetDataByIdArgs(), - } -} - -func (p MyServiceGetDataByIdArgsBuilder) Emit() *MyServiceGetDataByIdArgs{ - return &MyServiceGetDataByIdArgs{ - Id: p.obj.Id, - } -} - -func (m *MyServiceGetDataByIdArgsBuilder) Id(id int64) *MyServiceGetDataByIdArgsBuilder { - m.obj.Id = id - return m -} - -func (m *MyServiceGetDataByIdArgs) SetId(id int64) *MyServiceGetDataByIdArgs { - m.Id = id - return m -} - -func (p *MyServiceGetDataByIdArgs) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyServiceGetDataByIdArgs) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Id = v - } - return nil -} - -func (p *MyServiceGetDataByIdArgs) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("getDataById_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyServiceGetDataByIdArgs) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("id", thrift.I64, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:id: ", p), err) } - if err := oprot.WriteI64(int64(p.Id)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.id (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:id: ", p), err) } - return err -} - -func (p *MyServiceGetDataByIdArgs) String() string { - if p == nil { - return "" - } - - idVal := fmt.Sprintf("%v", p.Id) - return fmt.Sprintf("MyServiceGetDataByIdArgs({Id:%s})", idVal) -} - -// Attributes: -// - Success -type MyServiceGetDataByIdResult struct { - thrift.IResponse - Success *string `thrift:"success,0,optional" db:"success" json:"success,omitempty"` -} - -func NewMyServiceGetDataByIdResult() *MyServiceGetDataByIdResult { - return &MyServiceGetDataByIdResult{} -} - -var MyServiceGetDataByIdResult_Success_DEFAULT string -func (p *MyServiceGetDataByIdResult) GetSuccess() string { - if !p.IsSetSuccess() { - return MyServiceGetDataByIdResult_Success_DEFAULT - } - return *p.Success -} -func (p *MyServiceGetDataByIdResult) IsSetSuccess() bool { - return p != nil && p.Success != nil -} - -type MyServiceGetDataByIdResultBuilder struct { - obj *MyServiceGetDataByIdResult -} - -func NewMyServiceGetDataByIdResultBuilder() *MyServiceGetDataByIdResultBuilder{ - return &MyServiceGetDataByIdResultBuilder{ - obj: NewMyServiceGetDataByIdResult(), - } -} - -func (p MyServiceGetDataByIdResultBuilder) Emit() *MyServiceGetDataByIdResult{ - return &MyServiceGetDataByIdResult{ - Success: p.obj.Success, - } -} - -func (m *MyServiceGetDataByIdResultBuilder) Success(success *string) *MyServiceGetDataByIdResultBuilder { - m.obj.Success = success - return m -} - -func (m *MyServiceGetDataByIdResult) SetSuccess(success *string) *MyServiceGetDataByIdResult { - m.Success = success - return m -} - -func (p *MyServiceGetDataByIdResult) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 0: - if err := p.ReadField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyServiceGetDataByIdResult) ReadField0(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - p.Success = &v - } - return nil -} - -func (p *MyServiceGetDataByIdResult) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("getDataById_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField0(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyServiceGetDataByIdResult) writeField0(oprot thrift.Protocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRING, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := oprot.WriteString(string(*p.Success)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.success (0) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } - } - return err -} - -func (p *MyServiceGetDataByIdResult) String() string { - if p == nil { - return "" - } - - var successVal string - if p.Success == nil { - successVal = "" - } else { - successVal = fmt.Sprintf("%v", *p.Success) - } - return fmt.Sprintf("MyServiceGetDataByIdResult({Success:%s})", successVal) -} - -// Attributes: -// - Id -// - Data -type MyServicePutDataByIdArgs struct { - thrift.IRequest - Id int64 `thrift:"id,1" db:"id" json:"id"` - Data string `thrift:"data,2" db:"data" json:"data"` -} - -func NewMyServicePutDataByIdArgs() *MyServicePutDataByIdArgs { - return &MyServicePutDataByIdArgs{} -} - - -func (p *MyServicePutDataByIdArgs) GetId() int64 { - return p.Id -} - -func (p *MyServicePutDataByIdArgs) GetData() string { - return p.Data -} -type MyServicePutDataByIdArgsBuilder struct { - obj *MyServicePutDataByIdArgs -} - -func NewMyServicePutDataByIdArgsBuilder() *MyServicePutDataByIdArgsBuilder{ - return &MyServicePutDataByIdArgsBuilder{ - obj: NewMyServicePutDataByIdArgs(), - } -} - -func (p MyServicePutDataByIdArgsBuilder) Emit() *MyServicePutDataByIdArgs{ - return &MyServicePutDataByIdArgs{ - Id: p.obj.Id, - Data: p.obj.Data, - } -} - -func (m *MyServicePutDataByIdArgsBuilder) Id(id int64) *MyServicePutDataByIdArgsBuilder { - m.obj.Id = id - return m -} - -func (m *MyServicePutDataByIdArgsBuilder) Data(data string) *MyServicePutDataByIdArgsBuilder { - m.obj.Data = data - return m -} - -func (m *MyServicePutDataByIdArgs) SetId(id int64) *MyServicePutDataByIdArgs { - m.Id = id - return m -} - -func (m *MyServicePutDataByIdArgs) SetData(data string) *MyServicePutDataByIdArgs { - m.Data = data - return m -} - -func (p *MyServicePutDataByIdArgs) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyServicePutDataByIdArgs) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Id = v - } - return nil -} - -func (p *MyServicePutDataByIdArgs) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Data = v - } - return nil -} - -func (p *MyServicePutDataByIdArgs) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("putDataById_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyServicePutDataByIdArgs) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("id", thrift.I64, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:id: ", p), err) } - if err := oprot.WriteI64(int64(p.Id)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.id (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:id: ", p), err) } - return err -} - -func (p *MyServicePutDataByIdArgs) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("data", thrift.STRING, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:data: ", p), err) } - if err := oprot.WriteString(string(p.Data)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.data (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:data: ", p), err) } - return err -} - -func (p *MyServicePutDataByIdArgs) String() string { - if p == nil { - return "" - } - - idVal := fmt.Sprintf("%v", p.Id) - dataVal := fmt.Sprintf("%v", p.Data) - return fmt.Sprintf("MyServicePutDataByIdArgs({Id:%s Data:%s})", idVal, dataVal) -} - -type MyServicePutDataByIdResult struct { - thrift.IResponse -} - -func NewMyServicePutDataByIdResult() *MyServicePutDataByIdResult { - return &MyServicePutDataByIdResult{} -} - -type MyServicePutDataByIdResultBuilder struct { - obj *MyServicePutDataByIdResult -} - -func NewMyServicePutDataByIdResultBuilder() *MyServicePutDataByIdResultBuilder{ - return &MyServicePutDataByIdResultBuilder{ - obj: NewMyServicePutDataByIdResult(), - } -} - -func (p MyServicePutDataByIdResultBuilder) Emit() *MyServicePutDataByIdResult{ - return &MyServicePutDataByIdResult{ - } -} - -func (p *MyServicePutDataByIdResult) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyServicePutDataByIdResult) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("putDataById_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyServicePutDataByIdResult) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("MyServicePutDataByIdResult({})") -} - -// Attributes: -// - Id -// - Data -type MyServiceLobDataByIdArgs struct { - thrift.IRequest - Id int64 `thrift:"id,1" db:"id" json:"id"` - Data string `thrift:"data,2" db:"data" json:"data"` -} - -func NewMyServiceLobDataByIdArgs() *MyServiceLobDataByIdArgs { - return &MyServiceLobDataByIdArgs{} -} - - -func (p *MyServiceLobDataByIdArgs) GetId() int64 { - return p.Id -} - -func (p *MyServiceLobDataByIdArgs) GetData() string { - return p.Data -} -type MyServiceLobDataByIdArgsBuilder struct { - obj *MyServiceLobDataByIdArgs -} - -func NewMyServiceLobDataByIdArgsBuilder() *MyServiceLobDataByIdArgsBuilder{ - return &MyServiceLobDataByIdArgsBuilder{ - obj: NewMyServiceLobDataByIdArgs(), - } -} - -func (p MyServiceLobDataByIdArgsBuilder) Emit() *MyServiceLobDataByIdArgs{ - return &MyServiceLobDataByIdArgs{ - Id: p.obj.Id, - Data: p.obj.Data, - } -} - -func (m *MyServiceLobDataByIdArgsBuilder) Id(id int64) *MyServiceLobDataByIdArgsBuilder { - m.obj.Id = id - return m -} - -func (m *MyServiceLobDataByIdArgsBuilder) Data(data string) *MyServiceLobDataByIdArgsBuilder { - m.obj.Data = data - return m -} - -func (m *MyServiceLobDataByIdArgs) SetId(id int64) *MyServiceLobDataByIdArgs { - m.Id = id - return m -} - -func (m *MyServiceLobDataByIdArgs) SetData(data string) *MyServiceLobDataByIdArgs { - m.Data = data - return m -} - -func (p *MyServiceLobDataByIdArgs) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyServiceLobDataByIdArgs) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Id = v - } - return nil -} - -func (p *MyServiceLobDataByIdArgs) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Data = v - } - return nil -} - -func (p *MyServiceLobDataByIdArgs) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("lobDataById_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyServiceLobDataByIdArgs) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("id", thrift.I64, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:id: ", p), err) } - if err := oprot.WriteI64(int64(p.Id)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.id (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:id: ", p), err) } - return err -} - -func (p *MyServiceLobDataByIdArgs) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("data", thrift.STRING, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:data: ", p), err) } - if err := oprot.WriteString(string(p.Data)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.data (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:data: ", p), err) } - return err -} - -func (p *MyServiceLobDataByIdArgs) String() string { - if p == nil { - return "" - } - - idVal := fmt.Sprintf("%v", p.Id) - dataVal := fmt.Sprintf("%v", p.Data) - return fmt.Sprintf("MyServiceLobDataByIdArgs({Id:%s Data:%s})", idVal, dataVal) -} - -type MyServiceDoNothingArgs struct { - thrift.IRequest -} - -func NewMyServiceDoNothingArgs() *MyServiceDoNothingArgs { - return &MyServiceDoNothingArgs{} -} - -type MyServiceDoNothingArgsBuilder struct { - obj *MyServiceDoNothingArgs -} - -func NewMyServiceDoNothingArgsBuilder() *MyServiceDoNothingArgsBuilder{ - return &MyServiceDoNothingArgsBuilder{ - obj: NewMyServiceDoNothingArgs(), - } -} - -func (p MyServiceDoNothingArgsBuilder) Emit() *MyServiceDoNothingArgs{ - return &MyServiceDoNothingArgs{ - } -} - -func (p *MyServiceDoNothingArgs) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyServiceDoNothingArgs) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("doNothing_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyServiceDoNothingArgs) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("MyServiceDoNothingArgs({})") -} - -type MyServiceDoNothingResult struct { - thrift.IResponse -} - -func NewMyServiceDoNothingResult() *MyServiceDoNothingResult { - return &MyServiceDoNothingResult{} -} - -type MyServiceDoNothingResultBuilder struct { - obj *MyServiceDoNothingResult -} - -func NewMyServiceDoNothingResultBuilder() *MyServiceDoNothingResultBuilder{ - return &MyServiceDoNothingResultBuilder{ - obj: NewMyServiceDoNothingResult(), - } -} - -func (p MyServiceDoNothingResultBuilder) Emit() *MyServiceDoNothingResult{ - return &MyServiceDoNothingResult{ - } -} - -func (p *MyServiceDoNothingResult) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyServiceDoNothingResult) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("doNothing_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyServiceDoNothingResult) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("MyServiceDoNothingResult({})") -} - - diff --git a/thrift/compiler/test/fixtures/basic-annotations/gen-go/module/myservicepriochild.go b/thrift/compiler/test/fixtures/basic-annotations/gen-go/module/myservicepriochild.go deleted file mode 100644 index 2fe106b972c..00000000000 --- a/thrift/compiler/test/fixtures/basic-annotations/gen-go/module/myservicepriochild.go +++ /dev/null @@ -1,356 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package module - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -type MyServicePrioChild interface { -MyServicePrioParent - - Pang() (err error) -} - -type MyServicePrioChildClientInterface interface { - thrift.ClientInterface - Pang() (err error) -} - -type MyServicePrioChildClient struct { - MyServicePrioChildClientInterface - *MyServicePrioParentClient -} - -func(client *MyServicePrioChildClient) Open() error { - return client.CC.Open() -} - -func(client *MyServicePrioChildClient) Close() error { - return client.CC.Close() -} - -func(client *MyServicePrioChildClient) IsOpen() bool { - return client.CC.IsOpen() -} - -func NewMyServicePrioChildClientFactory(t thrift.Transport, f thrift.ProtocolFactory) *MyServicePrioChildClient { - return &MyServicePrioChildClient{MyServicePrioParentClient: NewMyServicePrioParentClientFactory(t, f)} -} - -func NewMyServicePrioChildClient(t thrift.Transport, iprot thrift.Protocol, oprot thrift.Protocol) *MyServicePrioChildClient { - return &MyServicePrioChildClient{MyServicePrioParentClient: NewMyServicePrioParentClient(t, iprot, oprot)} -} - -func NewMyServicePrioChildClientProtocol(prot thrift.Protocol) *MyServicePrioChildClient { - return NewMyServicePrioChildClient(prot.Transport(), prot, prot) -} - -func (p *MyServicePrioChildClient) Pang() (err error) { - var args MyServicePrioChildPangArgs - err = p.CC.SendMsg("pang", &args, thrift.CALL) - if err != nil { return } - return p.recvPang() -} - - -func (p *MyServicePrioChildClient) recvPang() (err error) { - var __result MyServicePrioChildPangResult - return p.CC.RecvMsg("pang", &__result) -} - - -type MyServicePrioChildThreadsafeClient struct { - MyServicePrioChildClientInterface - *MyServicePrioParentThreadsafeClient -} - -func(client *MyServicePrioChildThreadsafeClient) Open() error { - client.Mu.Lock() - defer client.Mu.Unlock() - return client.CC.Open() -} - -func(client *MyServicePrioChildThreadsafeClient) Close() error { - client.Mu.Lock() - defer client.Mu.Unlock() - return client.CC.Close() -} - -func(client *MyServicePrioChildThreadsafeClient) IsOpen() bool { - client.Mu.Lock() - defer client.Mu.Unlock() - return client.CC.IsOpen() -} - -func NewMyServicePrioChildThreadsafeClientFactory(t thrift.Transport, f thrift.ProtocolFactory) *MyServicePrioChildThreadsafeClient { - return &MyServicePrioChildThreadsafeClient{MyServicePrioParentThreadsafeClient: NewMyServicePrioParentThreadsafeClientFactory(t, f)} -} - -func NewMyServicePrioChildThreadsafeClient(t thrift.Transport, iprot thrift.Protocol, oprot thrift.Protocol) *MyServicePrioChildThreadsafeClient { - return &MyServicePrioChildThreadsafeClient{MyServicePrioParentThreadsafeClient: NewMyServicePrioParentThreadsafeClient(t, iprot, oprot)} -} - -func NewMyServicePrioChildThreadsafeClientProtocol(prot thrift.Protocol) *MyServicePrioChildThreadsafeClient { - return NewMyServicePrioChildThreadsafeClient(prot.Transport(), prot, prot) -} - -func (p *MyServicePrioChildThreadsafeClient) Pang() (err error) { - p.Mu.Lock() - defer p.Mu.Unlock() - var args MyServicePrioChildPangArgs - err = p.CC.SendMsg("pang", &args, thrift.CALL) - if err != nil { return } - return p.recvPang() -} - - -func (p *MyServicePrioChildThreadsafeClient) recvPang() (err error) { - var __result MyServicePrioChildPangResult - return p.CC.RecvMsg("pang", &__result) -} - - -type MyServicePrioChildChannelClient struct { - *MyServicePrioParentChannelClient -} - -func (c *MyServicePrioChildChannelClient) Close() error { - return c.RequestChannel.Close() -} - -func (c *MyServicePrioChildChannelClient) IsOpen() bool { - return c.RequestChannel.IsOpen() -} - -func (c *MyServicePrioChildChannelClient) Open() error { - return c.RequestChannel.Open() -} - -func NewMyServicePrioChildChannelClient(channel thrift.RequestChannel) *MyServicePrioChildChannelClient { - return &MyServicePrioChildChannelClient{MyServicePrioParentChannelClient: NewMyServicePrioParentChannelClient(channel)} -} - -func (p *MyServicePrioChildChannelClient) Pang(ctx context.Context) (err error) { - args := MyServicePrioChildPangArgs{ - } - var __result MyServicePrioChildPangResult - err = p.RequestChannel.Call(ctx, "pang", &args, &__result) - if err != nil { return } - - return nil -} - - -type MyServicePrioChildProcessor struct { - *MyServicePrioParentProcessor -} - -func NewMyServicePrioChildProcessor(handler MyServicePrioChild) *MyServicePrioChildProcessor { - self5 := &MyServicePrioChildProcessor{NewMyServicePrioParentProcessor(handler)} - self5.AddToProcessorMap("pang", &myServicePrioChildProcessorPang{handler:handler}) - self5.AddToFunctionServiceMap("pang", "MyServicePrioChild") - return self5 -} - -type myServicePrioChildProcessorPang struct { - handler MyServicePrioChild -} - -func (p *MyServicePrioChildPangResult) Exception() thrift.WritableException { - if p == nil { return nil } - return nil -} - -func (p *myServicePrioChildProcessorPang) Read(iprot thrift.Protocol) (thrift.Struct, thrift.Exception) { - args := MyServicePrioChildPangArgs{} - if err := args.Read(iprot); err != nil { - return nil, err - } - iprot.ReadMessageEnd() - return &args, nil -} - -func (p *myServicePrioChildProcessorPang) Write(seqId int32, result thrift.WritableStruct, oprot thrift.Protocol) (err thrift.Exception) { - var err2 error - messageType := thrift.REPLY - switch result.(type) { - case thrift.ApplicationException: - messageType = thrift.EXCEPTION - } - if err2 = oprot.WriteMessageBegin("pang", messageType, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - return err -} - -func (p *myServicePrioChildProcessorPang) Run(argStruct thrift.Struct) (thrift.WritableStruct, thrift.ApplicationException) { - var __result MyServicePrioChildPangResult - if err := p.handler.Pang(); err != nil { - switch err.(type) { - default: - x := thrift.NewApplicationExceptionCause(thrift.INTERNAL_ERROR, "Internal error processing pang: " + err.Error(), err) - return x, x - } - } - return &__result, nil -} - - -// HELPER FUNCTIONS AND STRUCTURES - -type MyServicePrioChildPangArgs struct { - thrift.IRequest -} - -func NewMyServicePrioChildPangArgs() *MyServicePrioChildPangArgs { - return &MyServicePrioChildPangArgs{} -} - -type MyServicePrioChildPangArgsBuilder struct { - obj *MyServicePrioChildPangArgs -} - -func NewMyServicePrioChildPangArgsBuilder() *MyServicePrioChildPangArgsBuilder{ - return &MyServicePrioChildPangArgsBuilder{ - obj: NewMyServicePrioChildPangArgs(), - } -} - -func (p MyServicePrioChildPangArgsBuilder) Emit() *MyServicePrioChildPangArgs{ - return &MyServicePrioChildPangArgs{ - } -} - -func (p *MyServicePrioChildPangArgs) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyServicePrioChildPangArgs) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("pang_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyServicePrioChildPangArgs) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("MyServicePrioChildPangArgs({})") -} - -type MyServicePrioChildPangResult struct { - thrift.IResponse -} - -func NewMyServicePrioChildPangResult() *MyServicePrioChildPangResult { - return &MyServicePrioChildPangResult{} -} - -type MyServicePrioChildPangResultBuilder struct { - obj *MyServicePrioChildPangResult -} - -func NewMyServicePrioChildPangResultBuilder() *MyServicePrioChildPangResultBuilder{ - return &MyServicePrioChildPangResultBuilder{ - obj: NewMyServicePrioChildPangResult(), - } -} - -func (p MyServicePrioChildPangResultBuilder) Emit() *MyServicePrioChildPangResult{ - return &MyServicePrioChildPangResult{ - } -} - -func (p *MyServicePrioChildPangResult) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyServicePrioChildPangResult) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("pang_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyServicePrioChildPangResult) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("MyServicePrioChildPangResult({})") -} - - diff --git a/thrift/compiler/test/fixtures/basic-annotations/gen-go/module/myserviceprioparent.go b/thrift/compiler/test/fixtures/basic-annotations/gen-go/module/myserviceprioparent.go deleted file mode 100644 index a24b997c2a2..00000000000 --- a/thrift/compiler/test/fixtures/basic-annotations/gen-go/module/myserviceprioparent.go +++ /dev/null @@ -1,606 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package module - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -type MyServicePrioParent interface { - Ping() (err error) - Pong() (err error) -} - -type MyServicePrioParentClientInterface interface { - thrift.ClientInterface - Ping() (err error) - Pong() (err error) -} - -type MyServicePrioParentClient struct { - MyServicePrioParentClientInterface - CC thrift.ClientConn -} - -func(client *MyServicePrioParentClient) Open() error { - return client.CC.Open() -} - -func(client *MyServicePrioParentClient) Close() error { - return client.CC.Close() -} - -func(client *MyServicePrioParentClient) IsOpen() bool { - return client.CC.IsOpen() -} - -func NewMyServicePrioParentClientFactory(t thrift.Transport, f thrift.ProtocolFactory) *MyServicePrioParentClient { - return &MyServicePrioParentClient{ CC: thrift.NewClientConn(t, f) } -} - -func NewMyServicePrioParentClient(t thrift.Transport, iprot thrift.Protocol, oprot thrift.Protocol) *MyServicePrioParentClient { - return &MyServicePrioParentClient{ CC: thrift.NewClientConnWithProtocols(t, iprot, oprot) } -} - -func NewMyServicePrioParentClientProtocol(prot thrift.Protocol) *MyServicePrioParentClient { - return NewMyServicePrioParentClient(prot.Transport(), prot, prot) -} - -func (p *MyServicePrioParentClient) Ping() (err error) { - var args MyServicePrioParentPingArgs - err = p.CC.SendMsg("ping", &args, thrift.CALL) - if err != nil { return } - return p.recvPing() -} - - -func (p *MyServicePrioParentClient) recvPing() (err error) { - var __result MyServicePrioParentPingResult - return p.CC.RecvMsg("ping", &__result) -} - -func (p *MyServicePrioParentClient) Pong() (err error) { - var args MyServicePrioParentPongArgs - err = p.CC.SendMsg("pong", &args, thrift.CALL) - if err != nil { return } - return p.recvPong() -} - - -func (p *MyServicePrioParentClient) recvPong() (err error) { - var __result MyServicePrioParentPongResult - return p.CC.RecvMsg("pong", &__result) -} - - -type MyServicePrioParentThreadsafeClient struct { - MyServicePrioParentClientInterface - CC thrift.ClientConn - Mu sync.Mutex -} - -func(client *MyServicePrioParentThreadsafeClient) Open() error { - client.Mu.Lock() - defer client.Mu.Unlock() - return client.CC.Open() -} - -func(client *MyServicePrioParentThreadsafeClient) Close() error { - client.Mu.Lock() - defer client.Mu.Unlock() - return client.CC.Close() -} - -func(client *MyServicePrioParentThreadsafeClient) IsOpen() bool { - client.Mu.Lock() - defer client.Mu.Unlock() - return client.CC.IsOpen() -} - -func NewMyServicePrioParentThreadsafeClientFactory(t thrift.Transport, f thrift.ProtocolFactory) *MyServicePrioParentThreadsafeClient { - return &MyServicePrioParentThreadsafeClient{ CC: thrift.NewClientConn(t, f) } -} - -func NewMyServicePrioParentThreadsafeClient(t thrift.Transport, iprot thrift.Protocol, oprot thrift.Protocol) *MyServicePrioParentThreadsafeClient { - return &MyServicePrioParentThreadsafeClient{ CC: thrift.NewClientConnWithProtocols(t, iprot, oprot) } -} - -func NewMyServicePrioParentThreadsafeClientProtocol(prot thrift.Protocol) *MyServicePrioParentThreadsafeClient { - return NewMyServicePrioParentThreadsafeClient(prot.Transport(), prot, prot) -} - -func (p *MyServicePrioParentThreadsafeClient) Ping() (err error) { - p.Mu.Lock() - defer p.Mu.Unlock() - var args MyServicePrioParentPingArgs - err = p.CC.SendMsg("ping", &args, thrift.CALL) - if err != nil { return } - return p.recvPing() -} - - -func (p *MyServicePrioParentThreadsafeClient) recvPing() (err error) { - var __result MyServicePrioParentPingResult - return p.CC.RecvMsg("ping", &__result) -} - -func (p *MyServicePrioParentThreadsafeClient) Pong() (err error) { - p.Mu.Lock() - defer p.Mu.Unlock() - var args MyServicePrioParentPongArgs - err = p.CC.SendMsg("pong", &args, thrift.CALL) - if err != nil { return } - return p.recvPong() -} - - -func (p *MyServicePrioParentThreadsafeClient) recvPong() (err error) { - var __result MyServicePrioParentPongResult - return p.CC.RecvMsg("pong", &__result) -} - - -type MyServicePrioParentChannelClient struct { - RequestChannel thrift.RequestChannel -} - -func (c *MyServicePrioParentChannelClient) Close() error { - return c.RequestChannel.Close() -} - -func (c *MyServicePrioParentChannelClient) IsOpen() bool { - return c.RequestChannel.IsOpen() -} - -func (c *MyServicePrioParentChannelClient) Open() error { - return c.RequestChannel.Open() -} - -func NewMyServicePrioParentChannelClient(channel thrift.RequestChannel) *MyServicePrioParentChannelClient { - return &MyServicePrioParentChannelClient{RequestChannel: channel} -} - -func (p *MyServicePrioParentChannelClient) Ping(ctx context.Context) (err error) { - args := MyServicePrioParentPingArgs{ - } - var __result MyServicePrioParentPingResult - err = p.RequestChannel.Call(ctx, "ping", &args, &__result) - if err != nil { return } - - return nil -} - -func (p *MyServicePrioParentChannelClient) Pong(ctx context.Context) (err error) { - args := MyServicePrioParentPongArgs{ - } - var __result MyServicePrioParentPongResult - err = p.RequestChannel.Call(ctx, "pong", &args, &__result) - if err != nil { return } - - return nil -} - - -type MyServicePrioParentProcessor struct { - processorMap map[string]thrift.ProcessorFunction - functionServiceMap map[string]string - handler MyServicePrioParent -} - -func (p *MyServicePrioParentProcessor) AddToProcessorMap(key string, processor thrift.ProcessorFunction) { - p.processorMap[key] = processor -} - -func (p *MyServicePrioParentProcessor) AddToFunctionServiceMap(key, service string) { - p.functionServiceMap[key] = service -} - -func (p *MyServicePrioParentProcessor) GetProcessorFunction(key string) (processor thrift.ProcessorFunction, err error) { - if processor, ok := p.processorMap[key]; ok { - return processor, nil - } - return nil, nil // generic error message will be sent -} - -func (p *MyServicePrioParentProcessor) ProcessorMap() map[string]thrift.ProcessorFunction { - return p.processorMap -} - -func (p *MyServicePrioParentProcessor) FunctionServiceMap() map[string]string { - return p.functionServiceMap -} - -func NewMyServicePrioParentProcessor(handler MyServicePrioParent) *MyServicePrioParentProcessor { - self3 := &MyServicePrioParentProcessor{handler:handler, processorMap:make(map[string]thrift.ProcessorFunction), functionServiceMap:make(map[string]string)} - self3.processorMap["ping"] = &myServicePrioParentProcessorPing{handler:handler} - self3.processorMap["pong"] = &myServicePrioParentProcessorPong{handler:handler} - self3.functionServiceMap["ping"] = "MyServicePrioParent" - self3.functionServiceMap["pong"] = "MyServicePrioParent" - return self3 -} - -type myServicePrioParentProcessorPing struct { - handler MyServicePrioParent -} - -func (p *MyServicePrioParentPingResult) Exception() thrift.WritableException { - if p == nil { return nil } - return nil -} - -func (p *myServicePrioParentProcessorPing) Read(iprot thrift.Protocol) (thrift.Struct, thrift.Exception) { - args := MyServicePrioParentPingArgs{} - if err := args.Read(iprot); err != nil { - return nil, err - } - iprot.ReadMessageEnd() - return &args, nil -} - -func (p *myServicePrioParentProcessorPing) Write(seqId int32, result thrift.WritableStruct, oprot thrift.Protocol) (err thrift.Exception) { - var err2 error - messageType := thrift.REPLY - switch result.(type) { - case thrift.ApplicationException: - messageType = thrift.EXCEPTION - } - if err2 = oprot.WriteMessageBegin("ping", messageType, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - return err -} - -func (p *myServicePrioParentProcessorPing) Run(argStruct thrift.Struct) (thrift.WritableStruct, thrift.ApplicationException) { - var __result MyServicePrioParentPingResult - if err := p.handler.Ping(); err != nil { - switch err.(type) { - default: - x := thrift.NewApplicationExceptionCause(thrift.INTERNAL_ERROR, "Internal error processing ping: " + err.Error(), err) - return x, x - } - } - return &__result, nil -} - -type myServicePrioParentProcessorPong struct { - handler MyServicePrioParent -} - -func (p *MyServicePrioParentPongResult) Exception() thrift.WritableException { - if p == nil { return nil } - return nil -} - -func (p *myServicePrioParentProcessorPong) Read(iprot thrift.Protocol) (thrift.Struct, thrift.Exception) { - args := MyServicePrioParentPongArgs{} - if err := args.Read(iprot); err != nil { - return nil, err - } - iprot.ReadMessageEnd() - return &args, nil -} - -func (p *myServicePrioParentProcessorPong) Write(seqId int32, result thrift.WritableStruct, oprot thrift.Protocol) (err thrift.Exception) { - var err2 error - messageType := thrift.REPLY - switch result.(type) { - case thrift.ApplicationException: - messageType = thrift.EXCEPTION - } - if err2 = oprot.WriteMessageBegin("pong", messageType, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - return err -} - -func (p *myServicePrioParentProcessorPong) Run(argStruct thrift.Struct) (thrift.WritableStruct, thrift.ApplicationException) { - var __result MyServicePrioParentPongResult - if err := p.handler.Pong(); err != nil { - switch err.(type) { - default: - x := thrift.NewApplicationExceptionCause(thrift.INTERNAL_ERROR, "Internal error processing pong: " + err.Error(), err) - return x, x - } - } - return &__result, nil -} - - -// HELPER FUNCTIONS AND STRUCTURES - -type MyServicePrioParentPingArgs struct { - thrift.IRequest -} - -func NewMyServicePrioParentPingArgs() *MyServicePrioParentPingArgs { - return &MyServicePrioParentPingArgs{} -} - -type MyServicePrioParentPingArgsBuilder struct { - obj *MyServicePrioParentPingArgs -} - -func NewMyServicePrioParentPingArgsBuilder() *MyServicePrioParentPingArgsBuilder{ - return &MyServicePrioParentPingArgsBuilder{ - obj: NewMyServicePrioParentPingArgs(), - } -} - -func (p MyServicePrioParentPingArgsBuilder) Emit() *MyServicePrioParentPingArgs{ - return &MyServicePrioParentPingArgs{ - } -} - -func (p *MyServicePrioParentPingArgs) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyServicePrioParentPingArgs) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("ping_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyServicePrioParentPingArgs) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("MyServicePrioParentPingArgs({})") -} - -type MyServicePrioParentPingResult struct { - thrift.IResponse -} - -func NewMyServicePrioParentPingResult() *MyServicePrioParentPingResult { - return &MyServicePrioParentPingResult{} -} - -type MyServicePrioParentPingResultBuilder struct { - obj *MyServicePrioParentPingResult -} - -func NewMyServicePrioParentPingResultBuilder() *MyServicePrioParentPingResultBuilder{ - return &MyServicePrioParentPingResultBuilder{ - obj: NewMyServicePrioParentPingResult(), - } -} - -func (p MyServicePrioParentPingResultBuilder) Emit() *MyServicePrioParentPingResult{ - return &MyServicePrioParentPingResult{ - } -} - -func (p *MyServicePrioParentPingResult) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyServicePrioParentPingResult) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("ping_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyServicePrioParentPingResult) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("MyServicePrioParentPingResult({})") -} - -type MyServicePrioParentPongArgs struct { - thrift.IRequest -} - -func NewMyServicePrioParentPongArgs() *MyServicePrioParentPongArgs { - return &MyServicePrioParentPongArgs{} -} - -type MyServicePrioParentPongArgsBuilder struct { - obj *MyServicePrioParentPongArgs -} - -func NewMyServicePrioParentPongArgsBuilder() *MyServicePrioParentPongArgsBuilder{ - return &MyServicePrioParentPongArgsBuilder{ - obj: NewMyServicePrioParentPongArgs(), - } -} - -func (p MyServicePrioParentPongArgsBuilder) Emit() *MyServicePrioParentPongArgs{ - return &MyServicePrioParentPongArgs{ - } -} - -func (p *MyServicePrioParentPongArgs) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyServicePrioParentPongArgs) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("pong_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyServicePrioParentPongArgs) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("MyServicePrioParentPongArgs({})") -} - -type MyServicePrioParentPongResult struct { - thrift.IResponse -} - -func NewMyServicePrioParentPongResult() *MyServicePrioParentPongResult { - return &MyServicePrioParentPongResult{} -} - -type MyServicePrioParentPongResultBuilder struct { - obj *MyServicePrioParentPongResult -} - -func NewMyServicePrioParentPongResultBuilder() *MyServicePrioParentPongResultBuilder{ - return &MyServicePrioParentPongResultBuilder{ - obj: NewMyServicePrioParentPongResult(), - } -} - -func (p MyServicePrioParentPongResultBuilder) Emit() *MyServicePrioParentPongResult{ - return &MyServicePrioParentPongResult{ - } -} - -func (p *MyServicePrioParentPongResult) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyServicePrioParentPongResult) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("pong_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyServicePrioParentPongResult) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("MyServicePrioParentPongResult({})") -} - - diff --git a/thrift/compiler/test/fixtures/basic-annotations/gen-go/module/ttypes.go b/thrift/compiler/test/fixtures/basic-annotations/gen-go/module/ttypes.go deleted file mode 100644 index e9df0bb76b0..00000000000 --- a/thrift/compiler/test/fixtures/basic-annotations/gen-go/module/ttypes.go +++ /dev/null @@ -1,971 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package module - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var GoUnusedProtection__ int; - -type MyEnum int64 -const ( - MyEnum_MyValue1 MyEnum = 0 - MyEnum_MyValue2 MyEnum = 1 - MyEnum_DOMAIN MyEnum = 2 -) - -var MyEnumToName = map[MyEnum]string { - MyEnum_MyValue1: "MyValue1", - MyEnum_MyValue2: "MyValue2", - MyEnum_DOMAIN: "DOMAIN", -} - -var MyEnumToValue = map[string]MyEnum { - "MyValue1": MyEnum_MyValue1, - "MyValue2": MyEnum_MyValue2, - "DOMAIN": MyEnum_DOMAIN, -} - -var MyEnumNames = []string { - "MyValue1", - "MyValue2", - "DOMAIN", -} - -var MyEnumValues = []MyEnum { - MyEnum_MyValue1, - MyEnum_MyValue2, - MyEnum_DOMAIN, -} - -func (p MyEnum) String() string { - if v, ok := MyEnumToName[p]; ok { - return v - } - return "" -} - -func MyEnumFromString(s string) (MyEnum, error) { - if v, ok := MyEnumToValue[s]; ok { - return v, nil - } - return MyEnum(0), fmt.Errorf("not a valid MyEnum string") -} - -func MyEnumPtr(v MyEnum) *MyEnum { return &v } - -type AwesomeStruct = MyStruct - -func AwesomeStructPtr(v AwesomeStruct) *AwesomeStruct { return &v } - -func NewAwesomeStruct() *AwesomeStruct { return NewMyStruct() } - -type FantasticStruct = MyStruct - -func FantasticStructPtr(v FantasticStruct) *FantasticStruct { return &v } - -func NewFantasticStruct() *FantasticStruct { return NewMyStruct() } - -type ListString_6884 = []string - -func ListString_6884Ptr(v ListString_6884) *ListString_6884 { return &v } - -// Attributes: -// - Name -type MyStructNestedAnnotation struct { - Name string `thrift:"name,1" db:"name" json:"name"` -} - -func NewMyStructNestedAnnotation() *MyStructNestedAnnotation { - return &MyStructNestedAnnotation{} -} - - -func (p *MyStructNestedAnnotation) GetName() string { - return p.Name -} -type MyStructNestedAnnotationBuilder struct { - obj *MyStructNestedAnnotation -} - -func NewMyStructNestedAnnotationBuilder() *MyStructNestedAnnotationBuilder{ - return &MyStructNestedAnnotationBuilder{ - obj: NewMyStructNestedAnnotation(), - } -} - -func (p MyStructNestedAnnotationBuilder) Emit() *MyStructNestedAnnotation{ - return &MyStructNestedAnnotation{ - Name: p.obj.Name, - } -} - -func (m *MyStructNestedAnnotationBuilder) Name(name string) *MyStructNestedAnnotationBuilder { - m.obj.Name = name - return m -} - -func (m *MyStructNestedAnnotation) SetName(name string) *MyStructNestedAnnotation { - m.Name = name - return m -} - -func (p *MyStructNestedAnnotation) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyStructNestedAnnotation) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Name = v - } - return nil -} - -func (p *MyStructNestedAnnotation) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("MyStructNestedAnnotation"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyStructNestedAnnotation) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) } - if err := oprot.WriteString(string(p.Name)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) } - return err -} - -func (p *MyStructNestedAnnotation) String() string { - if p == nil { - return "" - } - - nameVal := fmt.Sprintf("%v", p.Name) - return fmt.Sprintf("MyStructNestedAnnotation({Name:%s})", nameVal) -} - -type MyUnion struct { -} - -func NewMyUnion() *MyUnion { - return &MyUnion{} -} - -type MyUnionBuilder struct { - obj *MyUnion -} - -func NewMyUnionBuilder() *MyUnionBuilder{ - return &MyUnionBuilder{ - obj: NewMyUnion(), - } -} - -func (p MyUnionBuilder) Emit() *MyUnion{ - return &MyUnion{ - } -} - -func (p *MyUnion) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyUnion) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("MyUnion"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyUnion) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("MyUnion({})") -} - -type MyException struct { -} - -func NewMyException() *MyException { - return &MyException{} -} - -type MyExceptionBuilder struct { - obj *MyException -} - -func NewMyExceptionBuilder() *MyExceptionBuilder{ - return &MyExceptionBuilder{ - obj: NewMyException(), - } -} - -func (p MyExceptionBuilder) Emit() *MyException{ - return &MyException{ - } -} - -func (p *MyException) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyException) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("MyException"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyException) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("MyException({})") -} - -func (p *MyException) Error() string { - return p.String() -} - -// Attributes: -// - Major -// - Abstract -// - AnnotationWithQuote -// - Class_ -// - AnnotationWithTrailingComma -// - EmptyAnnotations -// - MyEnum -// - CppTypeAnnotation -// - MyUnion -type MyStruct struct { - Abstract string `thrift:"abstract,1" tag:"some_abstract"` - Major int64 `thrift:"major,2" db:"major" json:"major"` - AnnotationWithQuote string `thrift:"annotation_with_quote,3" tag:"somevalue"` - Class_ string `thrift:"class_,4" db:"class_" json:"class_"` - AnnotationWithTrailingComma string `thrift:"annotation_with_trailing_comma,5" db:"annotation_with_trailing_comma" json:"annotation_with_trailing_comma"` - EmptyAnnotations string `thrift:"empty_annotations,6" db:"empty_annotations" json:"empty_annotations"` - MyEnum MyEnum `thrift:"my_enum,7" db:"my_enum" json:"my_enum"` - CppTypeAnnotation []string `thrift:"cpp_type_annotation,8" db:"cpp_type_annotation" json:"cpp_type_annotation"` - MyUnion *MyUnion `thrift:"my_union,9" db:"my_union" json:"my_union"` -} - -func NewMyStruct() *MyStruct { - return &MyStruct{} -} - - -func (p *MyStruct) GetMajor() int64 { - return p.Major -} - -func (p *MyStruct) GetAbstract() string { - return p.Abstract -} - -func (p *MyStruct) GetAnnotationWithQuote() string { - return p.AnnotationWithQuote -} - -func (p *MyStruct) GetClass_() string { - return p.Class_ -} - -func (p *MyStruct) GetAnnotationWithTrailingComma() string { - return p.AnnotationWithTrailingComma -} - -func (p *MyStruct) GetEmptyAnnotations() string { - return p.EmptyAnnotations -} - -func (p *MyStruct) GetMyEnum() MyEnum { - return p.MyEnum -} - -func (p *MyStruct) GetCppTypeAnnotation() []string { - return p.CppTypeAnnotation -} -var MyStruct_MyUnion_DEFAULT *MyUnion -func (p *MyStruct) GetMyUnion() *MyUnion { - if !p.IsSetMyUnion() { - return MyStruct_MyUnion_DEFAULT - } - return p.MyUnion -} -func (p *MyStruct) DefaultGetMyUnion() *MyUnion { - if !p.IsSetMyUnion() { - return NewMyUnion() - } - return p.MyUnion -} -func (p *MyStruct) IsSetMyUnion() bool { - return p != nil && p.MyUnion != nil -} - -type MyStructBuilder struct { - obj *MyStruct -} - -func NewMyStructBuilder() *MyStructBuilder{ - return &MyStructBuilder{ - obj: NewMyStruct(), - } -} - -func (p MyStructBuilder) Emit() *MyStruct{ - return &MyStruct{ - Major: p.obj.Major, - Abstract: p.obj.Abstract, - AnnotationWithQuote: p.obj.AnnotationWithQuote, - Class_: p.obj.Class_, - AnnotationWithTrailingComma: p.obj.AnnotationWithTrailingComma, - EmptyAnnotations: p.obj.EmptyAnnotations, - MyEnum: p.obj.MyEnum, - CppTypeAnnotation: p.obj.CppTypeAnnotation, - MyUnion: p.obj.MyUnion, - } -} - -func (m *MyStructBuilder) Major(major int64) *MyStructBuilder { - m.obj.Major = major - return m -} - -func (m *MyStructBuilder) Abstract(abstract string) *MyStructBuilder { - m.obj.Abstract = abstract - return m -} - -func (m *MyStructBuilder) AnnotationWithQuote(annotationWithQuote string) *MyStructBuilder { - m.obj.AnnotationWithQuote = annotationWithQuote - return m -} - -func (m *MyStructBuilder) Class_(class_ string) *MyStructBuilder { - m.obj.Class_ = class_ - return m -} - -func (m *MyStructBuilder) AnnotationWithTrailingComma(annotationWithTrailingComma string) *MyStructBuilder { - m.obj.AnnotationWithTrailingComma = annotationWithTrailingComma - return m -} - -func (m *MyStructBuilder) EmptyAnnotations(emptyAnnotations string) *MyStructBuilder { - m.obj.EmptyAnnotations = emptyAnnotations - return m -} - -func (m *MyStructBuilder) MyEnum(myEnum MyEnum) *MyStructBuilder { - m.obj.MyEnum = myEnum - return m -} - -func (m *MyStructBuilder) CppTypeAnnotation(cppTypeAnnotation []string) *MyStructBuilder { - m.obj.CppTypeAnnotation = cppTypeAnnotation - return m -} - -func (m *MyStructBuilder) MyUnion(myUnion *MyUnion) *MyStructBuilder { - m.obj.MyUnion = myUnion - return m -} - -func (m *MyStruct) SetMajor(major int64) *MyStruct { - m.Major = major - return m -} - -func (m *MyStruct) SetAbstract(abstract string) *MyStruct { - m.Abstract = abstract - return m -} - -func (m *MyStruct) SetAnnotationWithQuote(annotationWithQuote string) *MyStruct { - m.AnnotationWithQuote = annotationWithQuote - return m -} - -func (m *MyStruct) SetClass_(class_ string) *MyStruct { - m.Class_ = class_ - return m -} - -func (m *MyStruct) SetAnnotationWithTrailingComma(annotationWithTrailingComma string) *MyStruct { - m.AnnotationWithTrailingComma = annotationWithTrailingComma - return m -} - -func (m *MyStruct) SetEmptyAnnotations(emptyAnnotations string) *MyStruct { - m.EmptyAnnotations = emptyAnnotations - return m -} - -func (m *MyStruct) SetMyEnum(myEnum MyEnum) *MyStruct { - m.MyEnum = myEnum - return m -} - -func (m *MyStruct) SetCppTypeAnnotation(cppTypeAnnotation []string) *MyStruct { - m.CppTypeAnnotation = cppTypeAnnotation - return m -} - -func (m *MyStruct) SetMyUnion(myUnion *MyUnion) *MyStruct { - m.MyUnion = myUnion - return m -} - -func (p *MyStruct) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 3: - if err := p.ReadField3(iprot); err != nil { - return err - } - case 4: - if err := p.ReadField4(iprot); err != nil { - return err - } - case 5: - if err := p.ReadField5(iprot); err != nil { - return err - } - case 6: - if err := p.ReadField6(iprot); err != nil { - return err - } - case 7: - if err := p.ReadField7(iprot); err != nil { - return err - } - case 8: - if err := p.ReadField8(iprot); err != nil { - return err - } - case 9: - if err := p.ReadField9(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyStruct) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Major = v - } - return nil -} - -func (p *MyStruct) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Abstract = v - } - return nil -} - -func (p *MyStruct) ReadField3(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 3: ", err) - } else { - p.AnnotationWithQuote = v - } - return nil -} - -func (p *MyStruct) ReadField4(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 4: ", err) - } else { - p.Class_ = v - } - return nil -} - -func (p *MyStruct) ReadField5(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 5: ", err) - } else { - p.AnnotationWithTrailingComma = v - } - return nil -} - -func (p *MyStruct) ReadField6(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 6: ", err) - } else { - p.EmptyAnnotations = v - } - return nil -} - -func (p *MyStruct) ReadField7(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 7: ", err) - } else { - temp := MyEnum(v) - p.MyEnum = temp - } - return nil -} - -func (p *MyStruct) ReadField8(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]string, 0, size) - p.CppTypeAnnotation = tSlice - for i := 0; i < size; i ++ { - var _elem0 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem0 = v - } - p.CppTypeAnnotation = append(p.CppTypeAnnotation, _elem0) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *MyStruct) ReadField9(iprot thrift.Protocol) error { - p.MyUnion = NewMyUnion() - if err := p.MyUnion.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.MyUnion), err) - } - return nil -} - -func (p *MyStruct) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("MyStruct"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := p.writeField4(oprot); err != nil { return err } - if err := p.writeField5(oprot); err != nil { return err } - if err := p.writeField6(oprot); err != nil { return err } - if err := p.writeField7(oprot); err != nil { return err } - if err := p.writeField8(oprot); err != nil { return err } - if err := p.writeField9(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyStruct) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("abstract", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:abstract: ", p), err) } - if err := oprot.WriteString(string(p.Abstract)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.abstract (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:abstract: ", p), err) } - return err -} - -func (p *MyStruct) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("major", thrift.I64, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:major: ", p), err) } - if err := oprot.WriteI64(int64(p.Major)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.major (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:major: ", p), err) } - return err -} - -func (p *MyStruct) writeField3(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("annotation_with_quote", thrift.STRING, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:annotation_with_quote: ", p), err) } - if err := oprot.WriteString(string(p.AnnotationWithQuote)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.annotation_with_quote (3) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:annotation_with_quote: ", p), err) } - return err -} - -func (p *MyStruct) writeField4(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("class_", thrift.STRING, 4); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:class_: ", p), err) } - if err := oprot.WriteString(string(p.Class_)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.class_ (4) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 4:class_: ", p), err) } - return err -} - -func (p *MyStruct) writeField5(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("annotation_with_trailing_comma", thrift.STRING, 5); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:annotation_with_trailing_comma: ", p), err) } - if err := oprot.WriteString(string(p.AnnotationWithTrailingComma)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.annotation_with_trailing_comma (5) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 5:annotation_with_trailing_comma: ", p), err) } - return err -} - -func (p *MyStruct) writeField6(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("empty_annotations", thrift.STRING, 6); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 6:empty_annotations: ", p), err) } - if err := oprot.WriteString(string(p.EmptyAnnotations)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.empty_annotations (6) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 6:empty_annotations: ", p), err) } - return err -} - -func (p *MyStruct) writeField7(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("my_enum", thrift.I32, 7); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 7:my_enum: ", p), err) } - if err := oprot.WriteI32(int32(p.MyEnum)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.my_enum (7) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 7:my_enum: ", p), err) } - return err -} - -func (p *MyStruct) writeField8(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("cpp_type_annotation", thrift.LIST, 8); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 8:cpp_type_annotation: ", p), err) } - if err := oprot.WriteListBegin(thrift.STRING, len(p.CppTypeAnnotation)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.CppTypeAnnotation { - if err := oprot.WriteString(string(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 8:cpp_type_annotation: ", p), err) } - return err -} - -func (p *MyStruct) writeField9(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("my_union", thrift.STRUCT, 9); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 9:my_union: ", p), err) } - if err := p.MyUnion.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.MyUnion), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 9:my_union: ", p), err) } - return err -} - -func (p *MyStruct) String() string { - if p == nil { - return "" - } - - abstractVal := fmt.Sprintf("%v", p.Abstract) - majorVal := fmt.Sprintf("%v", p.Major) - annotationWithQuoteVal := fmt.Sprintf("%v", p.AnnotationWithQuote) - class_Val := fmt.Sprintf("%v", p.Class_) - annotationWithTrailingCommaVal := fmt.Sprintf("%v", p.AnnotationWithTrailingComma) - emptyAnnotationsVal := fmt.Sprintf("%v", p.EmptyAnnotations) - myEnumVal := fmt.Sprintf("%v", p.MyEnum) - cppTypeAnnotationVal := fmt.Sprintf("%v", p.CppTypeAnnotation) - var myUnionVal string - if p.MyUnion == nil { - myUnionVal = "" - } else { - myUnionVal = fmt.Sprintf("%v", p.MyUnion) - } - return fmt.Sprintf("MyStruct({Abstract:%s Major:%s AnnotationWithQuote:%s Class_:%s AnnotationWithTrailingComma:%s EmptyAnnotations:%s MyEnum:%s CppTypeAnnotation:%s MyUnion:%s})", abstractVal, majorVal, annotationWithQuoteVal, class_Val, annotationWithTrailingCommaVal, emptyAnnotationsVal, myEnumVal, cppTypeAnnotationVal, myUnionVal) -} - -// Attributes: -// - Id -// - Password -type SecretStruct struct { - Id int64 `thrift:"id,1" db:"id" json:"id"` - Password string `thrift:"password,2" db:"password" json:"password"` -} - -func NewSecretStruct() *SecretStruct { - return &SecretStruct{} -} - - -func (p *SecretStruct) GetId() int64 { - return p.Id -} - -func (p *SecretStruct) GetPassword() string { - return p.Password -} -type SecretStructBuilder struct { - obj *SecretStruct -} - -func NewSecretStructBuilder() *SecretStructBuilder{ - return &SecretStructBuilder{ - obj: NewSecretStruct(), - } -} - -func (p SecretStructBuilder) Emit() *SecretStruct{ - return &SecretStruct{ - Id: p.obj.Id, - Password: p.obj.Password, - } -} - -func (s *SecretStructBuilder) Id(id int64) *SecretStructBuilder { - s.obj.Id = id - return s -} - -func (s *SecretStructBuilder) Password(password string) *SecretStructBuilder { - s.obj.Password = password - return s -} - -func (s *SecretStruct) SetId(id int64) *SecretStruct { - s.Id = id - return s -} - -func (s *SecretStruct) SetPassword(password string) *SecretStruct { - s.Password = password - return s -} - -func (p *SecretStruct) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *SecretStruct) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Id = v - } - return nil -} - -func (p *SecretStruct) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Password = v - } - return nil -} - -func (p *SecretStruct) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("SecretStruct"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *SecretStruct) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("id", thrift.I64, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:id: ", p), err) } - if err := oprot.WriteI64(int64(p.Id)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.id (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:id: ", p), err) } - return err -} - -func (p *SecretStruct) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("password", thrift.STRING, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:password: ", p), err) } - if err := oprot.WriteString(string(p.Password)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.password (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:password: ", p), err) } - return err -} - -func (p *SecretStruct) String() string { - if p == nil { - return "" - } - - idVal := fmt.Sprintf("%v", p.Id) - passwordVal := fmt.Sprintf("%v", p.Password) - return fmt.Sprintf("SecretStruct({Id:%s Password:%s})", idVal, passwordVal) -} - diff --git a/thrift/compiler/test/fixtures/basic-annotations/gen-go/thrift/annotation/cpp/constants.go b/thrift/compiler/test/fixtures/basic-annotations/gen-go/thrift/annotation/cpp/constants.go deleted file mode 100644 index 966e368e2dd..00000000000 --- a/thrift/compiler/test/fixtures/basic-annotations/gen-go/thrift/annotation/cpp/constants.go +++ /dev/null @@ -1,25 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package cpp - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - - -func init() { -} - diff --git a/thrift/compiler/test/fixtures/basic-annotations/gen-go/thrift/annotation/cpp/ttypes.go b/thrift/compiler/test/fixtures/basic-annotations/gen-go/thrift/annotation/cpp/ttypes.go deleted file mode 100644 index 209f29e21fd..00000000000 --- a/thrift/compiler/test/fixtures/basic-annotations/gen-go/thrift/annotation/cpp/ttypes.go +++ /dev/null @@ -1,2188 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package cpp - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var GoUnusedProtection__ int; - -//Optional, defaults to Unique -type RefType int64 -const ( - RefType_Unique RefType = 0 - RefType_Shared RefType = 1 - RefType_SharedMutable RefType = 2 -) - -var RefTypeToName = map[RefType]string { - RefType_Unique: "Unique", - RefType_Shared: "Shared", - RefType_SharedMutable: "SharedMutable", -} - -var RefTypeToValue = map[string]RefType { - "Unique": RefType_Unique, - "Shared": RefType_Shared, - "SharedMutable": RefType_SharedMutable, -} - -var RefTypeNames = []string { - "Unique", - "Shared", - "SharedMutable", -} - -var RefTypeValues = []RefType { - RefType_Unique, - RefType_Shared, - RefType_SharedMutable, -} - -func (p RefType) String() string { - if v, ok := RefTypeToName[p]; ok { - return v - } - return "" -} - -func RefTypeFromString(s string) (RefType, error) { - if v, ok := RefTypeToValue[s]; ok { - return v, nil - } - return RefType(0), fmt.Errorf("not a valid RefType string") -} - -func RefTypePtr(v RefType) *RefType { return &v } - -//Enum in C++ by default uses signed 32 bit integer. There is no need to specify -//underlying type for signed 32 bit integer. -//64-bit is not supported to avoid truncation since enums are sent as 32-bit integers over the wire. -type EnumUnderlyingType int64 -const ( - EnumUnderlyingType_I8 EnumUnderlyingType = 0 - EnumUnderlyingType_U8 EnumUnderlyingType = 1 - EnumUnderlyingType_I16 EnumUnderlyingType = 2 - EnumUnderlyingType_U16 EnumUnderlyingType = 3 - EnumUnderlyingType_U32 EnumUnderlyingType = 4 -) - -var EnumUnderlyingTypeToName = map[EnumUnderlyingType]string { - EnumUnderlyingType_I8: "I8", - EnumUnderlyingType_U8: "U8", - EnumUnderlyingType_I16: "I16", - EnumUnderlyingType_U16: "U16", - EnumUnderlyingType_U32: "U32", -} - -var EnumUnderlyingTypeToValue = map[string]EnumUnderlyingType { - "I8": EnumUnderlyingType_I8, - "U8": EnumUnderlyingType_U8, - "I16": EnumUnderlyingType_I16, - "U16": EnumUnderlyingType_U16, - "U32": EnumUnderlyingType_U32, -} - -var EnumUnderlyingTypeNames = []string { - "I8", - "U8", - "I16", - "U16", - "U32", -} - -var EnumUnderlyingTypeValues = []EnumUnderlyingType { - EnumUnderlyingType_I8, - EnumUnderlyingType_U8, - EnumUnderlyingType_I16, - EnumUnderlyingType_U16, - EnumUnderlyingType_U32, -} - -func (p EnumUnderlyingType) String() string { - if v, ok := EnumUnderlyingTypeToName[p]; ok { - return v - } - return "" -} - -func EnumUnderlyingTypeFromString(s string) (EnumUnderlyingType, error) { - if v, ok := EnumUnderlyingTypeToValue[s]; ok { - return v, nil - } - return EnumUnderlyingType(0), fmt.Errorf("not a valid EnumUnderlyingType string") -} - -func EnumUnderlyingTypePtr(v EnumUnderlyingType) *EnumUnderlyingType { return &v } - -// Changes the native type of a Thrift object (the C++ type used in codegen) to the value of the `name` field. -// Container types may instead provide the `template` field, in which case template parameters will be filled in by thrift. -// (e.g. `template = "folly::sorted_vector_set"` is equivalent to `type = "folly::sorted_vector_set"` on `set`) -// -// It is also possible to add `cpp_include` to bring in additional data structures and use them here. -// It is required that the custom type matches the specified Thrift type even for internal container types. -// Prefer types that can leverage `reserve(size_t)` as Thrift makes uses these optimizations. -// *Special Case*: This annotation can be used to define a string/binary type as `IOBuf` or `unique_ptr` so that you can leverage Thrift's support for zero-copy buffer manipulation through `IOBuf`. -// During deserialization, thrift receives a buffer that is used to allocate the appropriate fields in the struct. When using smart pointers, instead of making a copy of the data, it only modifies the pointer to point to the address that is used by the buffer. -// -// The custom type must provide the following methods -// * `list`: `push_back(T)` -// * `map`: `insert(std::pair)` -// * `set`: `insert(T)` -// -// Attributes: -// - Name -// - Template -type Type struct { - Name string `thrift:"name,1" db:"name" json:"name"` - Template string `thrift:"template,2" db:"template" json:"template"` -} - -func NewType() *Type { - return &Type{} -} - - -func (p *Type) GetName() string { - return p.Name -} - -func (p *Type) GetTemplate() string { - return p.Template -} -type TypeBuilder struct { - obj *Type -} - -func NewTypeBuilder() *TypeBuilder{ - return &TypeBuilder{ - obj: NewType(), - } -} - -func (p TypeBuilder) Emit() *Type{ - return &Type{ - Name: p.obj.Name, - Template: p.obj.Template, - } -} - -func (t *TypeBuilder) Name(name string) *TypeBuilder { - t.obj.Name = name - return t -} - -func (t *TypeBuilder) Template(template string) *TypeBuilder { - t.obj.Template = template - return t -} - -func (t *Type) SetName(name string) *Type { - t.Name = name - return t -} - -func (t *Type) SetTemplate(template string) *Type { - t.Template = template - return t -} - -func (p *Type) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Type) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Name = v - } - return nil -} - -func (p *Type) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Template = v - } - return nil -} - -func (p *Type) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Type"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Type) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) } - if err := oprot.WriteString(string(p.Name)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) } - return err -} - -func (p *Type) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("template", thrift.STRING, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:template: ", p), err) } - if err := oprot.WriteString(string(p.Template)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.template (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:template: ", p), err) } - return err -} - -func (p *Type) String() string { - if p == nil { - return "" - } - - nameVal := fmt.Sprintf("%v", p.Name) - templateVal := fmt.Sprintf("%v", p.Template) - return fmt.Sprintf("Type({Name:%s Template:%s})", nameVal, templateVal) -} - -// Allocates a field on the heap instead of inline. -// This annotation is added to support recursive types. However, you can also use it to turn a field from a value to a smart pointer. -// `@cpp.Ref` is equivalent having type`@cpp.RefType.Unique`. -// -// NOTE: A struct may transitively contain itself as a field only if at least one of the fields in the inclusion chain is either an optional Ref field or a container. Otherwise the struct would have infinite size. -// -// Attributes: -// - Type -type Ref struct { - Type RefType `thrift:"type,1" db:"type" json:"type"` -} - -func NewRef() *Ref { - return &Ref{} -} - - -func (p *Ref) GetType() RefType { - return p.Type -} -type RefBuilder struct { - obj *Ref -} - -func NewRefBuilder() *RefBuilder{ - return &RefBuilder{ - obj: NewRef(), - } -} - -func (p RefBuilder) Emit() *Ref{ - return &Ref{ - Type: p.obj.Type, - } -} - -func (r *RefBuilder) Type(type_a1 RefType) *RefBuilder { - r.obj.Type = type_a1 - return r -} - -func (r *Ref) SetType(type_a1 RefType) *Ref { - r.Type = type_a1 - return r -} - -func (p *Ref) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Ref) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - temp := RefType(v) - p.Type = temp - } - return nil -} - -func (p *Ref) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Ref"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Ref) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("type", thrift.I32, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:type: ", p), err) } - if err := oprot.WriteI32(int32(p.Type)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.type (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:type: ", p), err) } - return err -} - -func (p *Ref) String() string { - if p == nil { - return "" - } - - typeVal := fmt.Sprintf("%v", p.Type) - return fmt.Sprintf("Ref({Type:%s})", typeVal) -} - -// Changes the name of the definition in generated C++ code. -// In most cases a much better solution is to rename the problematic Thrift field itself. Only use the `cpp.name` annotation if such renaming is problematic, -// e.g. when the field name appears in code as a string, particularly when using JSON serialization, and it is hard to change all usage sites. -// -// Attributes: -// - Value -type Name struct { - Value string `thrift:"value,1" db:"value" json:"value"` -} - -func NewName() *Name { - return &Name{} -} - - -func (p *Name) GetValue() string { - return p.Value -} -type NameBuilder struct { - obj *Name -} - -func NewNameBuilder() *NameBuilder{ - return &NameBuilder{ - obj: NewName(), - } -} - -func (p NameBuilder) Emit() *Name{ - return &Name{ - Value: p.obj.Value, - } -} - -func (n *NameBuilder) Value(value string) *NameBuilder { - n.obj.Value = value - return n -} - -func (n *Name) SetValue(value string) *Name { - n.Value = value - return n -} - -func (p *Name) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Name) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Value = v - } - return nil -} - -func (p *Name) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Name"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Name) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("value", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:value: ", p), err) } - if err := oprot.WriteString(string(p.Value)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.value (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:value: ", p), err) } - return err -} - -func (p *Name) String() string { - if p == nil { - return "" - } - - valueVal := fmt.Sprintf("%v", p.Value) - return fmt.Sprintf("Name({Value:%s})", valueVal) -} - -// Lazily deserialize large field on first access. -// -// ``` -// FooWithLazyField foo; -// apache::thrift::CompactSerializer::deserialize(serializedData, foo); -// -// // large_field is lazy field, it will be deserialized on first access -// // The data will be deserialized in method call large_field_ref() -// LOG(INFO) << foo.large_field_ref()->size(); -// -// // Result will be cached, we won't deserialize again -// LOG(INFO) << foo.large_field_ref()->size(); -// ``` -// -// Read more: /doc/fb/languages/cpp/lazy.md -// -// Attributes: -// - Ref -type Lazy struct { - Ref bool `thrift:"ref,1" db:"ref" json:"ref"` -} - -func NewLazy() *Lazy { - return &Lazy{} -} - - -func (p *Lazy) GetRef() bool { - return p.Ref -} -type LazyBuilder struct { - obj *Lazy -} - -func NewLazyBuilder() *LazyBuilder{ - return &LazyBuilder{ - obj: NewLazy(), - } -} - -func (p LazyBuilder) Emit() *Lazy{ - return &Lazy{ - Ref: p.obj.Ref, - } -} - -func (l *LazyBuilder) Ref(ref bool) *LazyBuilder { - l.obj.Ref = ref - return l -} - -func (l *Lazy) SetRef(ref bool) *Lazy { - l.Ref = ref - return l -} - -func (p *Lazy) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Lazy) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Ref = v - } - return nil -} - -func (p *Lazy) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Lazy"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Lazy) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("ref", thrift.BOOL, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:ref: ", p), err) } - if err := oprot.WriteBool(bool(p.Ref)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.ref (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:ref: ", p), err) } - return err -} - -func (p *Lazy) String() string { - if p == nil { - return "" - } - - refVal := fmt.Sprintf("%v", p.Ref) - return fmt.Sprintf("Lazy({Ref:%s})", refVal) -} - -type DisableLazyChecksum struct { -} - -func NewDisableLazyChecksum() *DisableLazyChecksum { - return &DisableLazyChecksum{} -} - -type DisableLazyChecksumBuilder struct { - obj *DisableLazyChecksum -} - -func NewDisableLazyChecksumBuilder() *DisableLazyChecksumBuilder{ - return &DisableLazyChecksumBuilder{ - obj: NewDisableLazyChecksum(), - } -} - -func (p DisableLazyChecksumBuilder) Emit() *DisableLazyChecksum{ - return &DisableLazyChecksum{ - } -} - -func (p *DisableLazyChecksum) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *DisableLazyChecksum) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("DisableLazyChecksum"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *DisableLazyChecksum) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("DisableLazyChecksum({})") -} - -// An annotation that applies a C++ adapter to typedef, field, or struct. -// -// For example: -// -// @cpp.Adapter{name = "::ns::IdAdapter"} -// typedef i64 MyI64; -// -// Here the type `MyI64` has the C++ adapter `IdAdapter`. -// -// struct User { -// @cpp.Adapter{name = "::ns::IdAdapter"} -// 1: i64 id; -// } -// -// Here the field `id` has the C++ adapter `IdAdapter`. -// -// Attributes: -// - Name: The name of a C++ adapter type used to convert between Thrift and native -// C++ representation. -// -// The adapter can be either a Type or Field adapter, providing either of the following APIs: -// -// struct ThriftTypeAdapter { -// static AdaptedType fromThrift(ThriftType thrift); -// static {const ThriftType& | ThriftType} toThrift(const AdaptedType& native); -// }; -// -// struct ThriftFieldAdapter { -// // Context is an instantiation of apache::thrift::FieldContext -// template -// static void construct(AdaptedType& field, Context ctx); -// -// template -// static AdaptedType fromThriftField(ThriftType value, Context ctx); -// -// template -// static {const ThriftType& | ThriftType} toThrift(const AdaptedType& adapted, Context ctx); -// }; -// - AdaptedType: It is sometimes necessary to specify AdaptedType here (in case the codegen would -// have a circular depdenceny, which will cause the C++ build to fail). -// - UnderlyingName: The name and/or extra namespace to use when directly adapting a type -// (as opposed a typedef). -// -// In this case, the IDL name of the type will refer to the adapted type in -// C++ and the underlying thrift type will be generated in a nested -// namespace and/or with a different name. -// -// If neither `underlyingName` or `extraNamespace` is provided, the -// underlying type will be generated in a nested 'detail' namespace with -// the same name. -// - ExtraNamespace -// - MoveOnly: Must set to true when adapted type is not copyable. -type Adapter struct { - Name string `thrift:"name,1" db:"name" json:"name"` - AdaptedType string `thrift:"adaptedType,2" db:"adaptedType" json:"adaptedType"` - UnderlyingName string `thrift:"underlyingName,3" db:"underlyingName" json:"underlyingName"` - ExtraNamespace string `thrift:"extraNamespace,4" db:"extraNamespace" json:"extraNamespace"` - MoveOnly bool `thrift:"moveOnly,5" db:"moveOnly" json:"moveOnly"` -} - -func NewAdapter() *Adapter { - return &Adapter{} -} - - -func (p *Adapter) GetName() string { - return p.Name -} - -func (p *Adapter) GetAdaptedType() string { - return p.AdaptedType -} - -func (p *Adapter) GetUnderlyingName() string { - return p.UnderlyingName -} - -func (p *Adapter) GetExtraNamespace() string { - return p.ExtraNamespace -} - -func (p *Adapter) GetMoveOnly() bool { - return p.MoveOnly -} -type AdapterBuilder struct { - obj *Adapter -} - -func NewAdapterBuilder() *AdapterBuilder{ - return &AdapterBuilder{ - obj: NewAdapter(), - } -} - -func (p AdapterBuilder) Emit() *Adapter{ - return &Adapter{ - Name: p.obj.Name, - AdaptedType: p.obj.AdaptedType, - UnderlyingName: p.obj.UnderlyingName, - ExtraNamespace: p.obj.ExtraNamespace, - MoveOnly: p.obj.MoveOnly, - } -} - -func (a *AdapterBuilder) Name(name string) *AdapterBuilder { - a.obj.Name = name - return a -} - -func (a *AdapterBuilder) AdaptedType(adaptedType string) *AdapterBuilder { - a.obj.AdaptedType = adaptedType - return a -} - -func (a *AdapterBuilder) UnderlyingName(underlyingName string) *AdapterBuilder { - a.obj.UnderlyingName = underlyingName - return a -} - -func (a *AdapterBuilder) ExtraNamespace(extraNamespace string) *AdapterBuilder { - a.obj.ExtraNamespace = extraNamespace - return a -} - -func (a *AdapterBuilder) MoveOnly(moveOnly bool) *AdapterBuilder { - a.obj.MoveOnly = moveOnly - return a -} - -func (a *Adapter) SetName(name string) *Adapter { - a.Name = name - return a -} - -func (a *Adapter) SetAdaptedType(adaptedType string) *Adapter { - a.AdaptedType = adaptedType - return a -} - -func (a *Adapter) SetUnderlyingName(underlyingName string) *Adapter { - a.UnderlyingName = underlyingName - return a -} - -func (a *Adapter) SetExtraNamespace(extraNamespace string) *Adapter { - a.ExtraNamespace = extraNamespace - return a -} - -func (a *Adapter) SetMoveOnly(moveOnly bool) *Adapter { - a.MoveOnly = moveOnly - return a -} - -func (p *Adapter) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 3: - if err := p.ReadField3(iprot); err != nil { - return err - } - case 4: - if err := p.ReadField4(iprot); err != nil { - return err - } - case 5: - if err := p.ReadField5(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Adapter) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Name = v - } - return nil -} - -func (p *Adapter) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.AdaptedType = v - } - return nil -} - -func (p *Adapter) ReadField3(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 3: ", err) - } else { - p.UnderlyingName = v - } - return nil -} - -func (p *Adapter) ReadField4(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 4: ", err) - } else { - p.ExtraNamespace = v - } - return nil -} - -func (p *Adapter) ReadField5(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 5: ", err) - } else { - p.MoveOnly = v - } - return nil -} - -func (p *Adapter) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Adapter"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := p.writeField4(oprot); err != nil { return err } - if err := p.writeField5(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Adapter) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) } - if err := oprot.WriteString(string(p.Name)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) } - return err -} - -func (p *Adapter) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("adaptedType", thrift.STRING, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:adaptedType: ", p), err) } - if err := oprot.WriteString(string(p.AdaptedType)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.adaptedType (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:adaptedType: ", p), err) } - return err -} - -func (p *Adapter) writeField3(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("underlyingName", thrift.STRING, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:underlyingName: ", p), err) } - if err := oprot.WriteString(string(p.UnderlyingName)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.underlyingName (3) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:underlyingName: ", p), err) } - return err -} - -func (p *Adapter) writeField4(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("extraNamespace", thrift.STRING, 4); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:extraNamespace: ", p), err) } - if err := oprot.WriteString(string(p.ExtraNamespace)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.extraNamespace (4) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 4:extraNamespace: ", p), err) } - return err -} - -func (p *Adapter) writeField5(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("moveOnly", thrift.BOOL, 5); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:moveOnly: ", p), err) } - if err := oprot.WriteBool(bool(p.MoveOnly)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.moveOnly (5) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 5:moveOnly: ", p), err) } - return err -} - -func (p *Adapter) String() string { - if p == nil { - return "" - } - - nameVal := fmt.Sprintf("%v", p.Name) - adaptedTypeVal := fmt.Sprintf("%v", p.AdaptedType) - underlyingNameVal := fmt.Sprintf("%v", p.UnderlyingName) - extraNamespaceVal := fmt.Sprintf("%v", p.ExtraNamespace) - moveOnlyVal := fmt.Sprintf("%v", p.MoveOnly) - return fmt.Sprintf("Adapter({Name:%s AdaptedType:%s UnderlyingName:%s ExtraNamespace:%s MoveOnly:%s})", nameVal, adaptedTypeVal, underlyingNameVal, extraNamespaceVal, moveOnlyVal) -} - -// Packs isset bits into fewer bytes to save space at the cost of making access more expensive. -// Passing `atomic = false` reduces the access cost while making concurrent writes UB. -// Read more: /doc/fb/languages/cpp/isset-bitpacking.md -// -// Attributes: -// - Atomic -type PackIsset struct { - Atomic bool `thrift:"atomic,1" db:"atomic" json:"atomic"` -} - -func NewPackIsset() *PackIsset { - return &PackIsset{ - Atomic: true, - } -} - - -func (p *PackIsset) GetAtomic() bool { - return p.Atomic -} -type PackIssetBuilder struct { - obj *PackIsset -} - -func NewPackIssetBuilder() *PackIssetBuilder{ - return &PackIssetBuilder{ - obj: NewPackIsset(), - } -} - -func (p PackIssetBuilder) Emit() *PackIsset{ - return &PackIsset{ - Atomic: p.obj.Atomic, - } -} - -func (p *PackIssetBuilder) Atomic(atomic bool) *PackIssetBuilder { - p.obj.Atomic = atomic - return p -} - -func (p *PackIsset) SetAtomic(atomic bool) *PackIsset { - p.Atomic = atomic - return p -} - -func (p *PackIsset) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *PackIsset) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Atomic = v - } - return nil -} - -func (p *PackIsset) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("PackIsset"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *PackIsset) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("atomic", thrift.BOOL, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:atomic: ", p), err) } - if err := oprot.WriteBool(bool(p.Atomic)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.atomic (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:atomic: ", p), err) } - return err -} - -func (p *PackIsset) String() string { - if p == nil { - return "" - } - - atomicVal := fmt.Sprintf("%v", p.Atomic) - return fmt.Sprintf("PackIsset({Atomic:%s})", atomicVal) -} - -// This annotation enables reordering of fields in the generated C++ struct to minimize padding. -// This is achieved by placing the fields in the order of decreasing alignments. The order of fields with the same alignment is preserved. -// -// ``` -// @cpp.MinimizePadding -// struct Padded { -// 1: byte small -// 2: i64 big -// 3: i16 medium -// 4: i32 biggish -// 5: byte tiny -// } -// ``` -// -// For example, the C++ fields for the `Padded` Thrift struct above will be generated in the following order: -// -// ``` -// int64_t big; -// int32_t biggish; -// int16_t medium; -// int8_t small; -// int8_t tiny; -// ``` -// -// which gives the size of 16 bytes compared to 32 bytes if `cpp.MinimizePadding` was not specified. -type MinimizePadding struct { -} - -func NewMinimizePadding() *MinimizePadding { - return &MinimizePadding{} -} - -type MinimizePaddingBuilder struct { - obj *MinimizePadding -} - -func NewMinimizePaddingBuilder() *MinimizePaddingBuilder{ - return &MinimizePaddingBuilder{ - obj: NewMinimizePadding(), - } -} - -func (p MinimizePaddingBuilder) Emit() *MinimizePadding{ - return &MinimizePadding{ - } -} - -func (p *MinimizePadding) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MinimizePadding) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("MinimizePadding"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MinimizePadding) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("MinimizePadding({})") -} - -type TriviallyRelocatable struct { -} - -func NewTriviallyRelocatable() *TriviallyRelocatable { - return &TriviallyRelocatable{} -} - -type TriviallyRelocatableBuilder struct { - obj *TriviallyRelocatable -} - -func NewTriviallyRelocatableBuilder() *TriviallyRelocatableBuilder{ - return &TriviallyRelocatableBuilder{ - obj: NewTriviallyRelocatable(), - } -} - -func (p TriviallyRelocatableBuilder) Emit() *TriviallyRelocatable{ - return &TriviallyRelocatable{ - } -} - -func (p *TriviallyRelocatable) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *TriviallyRelocatable) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("TriviallyRelocatable"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *TriviallyRelocatable) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("TriviallyRelocatable({})") -} - -type ScopedEnumAsUnionType struct { -} - -func NewScopedEnumAsUnionType() *ScopedEnumAsUnionType { - return &ScopedEnumAsUnionType{} -} - -type ScopedEnumAsUnionTypeBuilder struct { - obj *ScopedEnumAsUnionType -} - -func NewScopedEnumAsUnionTypeBuilder() *ScopedEnumAsUnionTypeBuilder{ - return &ScopedEnumAsUnionTypeBuilder{ - obj: NewScopedEnumAsUnionType(), - } -} - -func (p ScopedEnumAsUnionTypeBuilder) Emit() *ScopedEnumAsUnionType{ - return &ScopedEnumAsUnionType{ - } -} - -func (p *ScopedEnumAsUnionType) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ScopedEnumAsUnionType) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("ScopedEnumAsUnionType"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *ScopedEnumAsUnionType) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("ScopedEnumAsUnionType({})") -} - -// Indicates a typedef should be 'strong', and require an explicit cast to -// the underlying type. -// -// Currently only works for integer typedefs, for example: -// -// @cpp.StrongType -// typedef i32 MyId; -// -// Will cause an enum class to be used instead of a typedef in the genearte code, for example: -// -// enum class MyId : ::std::int32_t {}; -// -type StrongType struct { -} - -func NewStrongType() *StrongType { - return &StrongType{} -} - -type StrongTypeBuilder struct { - obj *StrongType -} - -func NewStrongTypeBuilder() *StrongTypeBuilder{ - return &StrongTypeBuilder{ - obj: NewStrongType(), - } -} - -func (p StrongTypeBuilder) Emit() *StrongType{ - return &StrongType{ - } -} - -func (p *StrongType) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *StrongType) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("StrongType"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *StrongType) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("StrongType({})") -} - -// An annotation that intercepts field access with C++ field interceptor. -// Use with *caution* since this may introduce substantial performance overhead on each field access. -// -// For example: -// -// struct Foo { -// @cpp.FieldInterceptor{name = "MyFieldInterceptor"} -// 1: i64 id; -// } -// -// The field interceptor `MyFieldInterceptor` will intercept with `interceptThriftFieldAccess` -// when the field `id` is accessed. -// -// Attributes: -// - Name: The name of a field interceptor. -// -// The field interceptor provides the following API: -// -// struct ThriftFieldInterceptor { -// template -// static void interceptThriftFieldAccess(T&& field, -// apache::thrift::FieldContext&& ctx); -// }; -// -// The field interceptor intercepts with the field value and the field context. -// It enforces an easily searchable function name `interceptThriftFieldAccess`. -// - Noinline: Setting to true makes compiler not inline and erase function signature for -// the intercepting field accessor. -type FieldInterceptor struct { - Name string `thrift:"name,1" db:"name" json:"name"` - Noinline bool `thrift:"noinline,2" db:"noinline" json:"noinline"` -} - -func NewFieldInterceptor() *FieldInterceptor { - return &FieldInterceptor{} -} - - -func (p *FieldInterceptor) GetName() string { - return p.Name -} - -func (p *FieldInterceptor) GetNoinline() bool { - return p.Noinline -} -type FieldInterceptorBuilder struct { - obj *FieldInterceptor -} - -func NewFieldInterceptorBuilder() *FieldInterceptorBuilder{ - return &FieldInterceptorBuilder{ - obj: NewFieldInterceptor(), - } -} - -func (p FieldInterceptorBuilder) Emit() *FieldInterceptor{ - return &FieldInterceptor{ - Name: p.obj.Name, - Noinline: p.obj.Noinline, - } -} - -func (f *FieldInterceptorBuilder) Name(name string) *FieldInterceptorBuilder { - f.obj.Name = name - return f -} - -func (f *FieldInterceptorBuilder) Noinline(noinline bool) *FieldInterceptorBuilder { - f.obj.Noinline = noinline - return f -} - -func (f *FieldInterceptor) SetName(name string) *FieldInterceptor { - f.Name = name - return f -} - -func (f *FieldInterceptor) SetNoinline(noinline bool) *FieldInterceptor { - f.Noinline = noinline - return f -} - -func (p *FieldInterceptor) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *FieldInterceptor) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Name = v - } - return nil -} - -func (p *FieldInterceptor) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Noinline = v - } - return nil -} - -func (p *FieldInterceptor) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("FieldInterceptor"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *FieldInterceptor) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) } - if err := oprot.WriteString(string(p.Name)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) } - return err -} - -func (p *FieldInterceptor) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("noinline", thrift.BOOL, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:noinline: ", p), err) } - if err := oprot.WriteBool(bool(p.Noinline)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.noinline (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:noinline: ", p), err) } - return err -} - -func (p *FieldInterceptor) String() string { - if p == nil { - return "" - } - - nameVal := fmt.Sprintf("%v", p.Name) - noinlineVal := fmt.Sprintf("%v", p.Noinline) - return fmt.Sprintf("FieldInterceptor({Name:%s Noinline:%s})", nameVal, noinlineVal) -} - -type UseOpEncode struct { -} - -func NewUseOpEncode() *UseOpEncode { - return &UseOpEncode{} -} - -type UseOpEncodeBuilder struct { - obj *UseOpEncode -} - -func NewUseOpEncodeBuilder() *UseOpEncodeBuilder{ - return &UseOpEncodeBuilder{ - obj: NewUseOpEncode(), - } -} - -func (p UseOpEncodeBuilder) Emit() *UseOpEncode{ - return &UseOpEncode{ - } -} - -func (p *UseOpEncode) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *UseOpEncode) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("UseOpEncode"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *UseOpEncode) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("UseOpEncode({})") -} - -// Indicates an integer type for C++ to use as the underlying type of enum, for example: -// -// @cpp.EnumType{type = cpp.EnumUnderlyingType.I8} -// enum Fruit { -// Apple = 0, -// Banana = 1, -// } -// -// will be generated into the following: -// -// enum class Fruit : ::std::int8_t { -// Apple = 0, -// Banana = 1, -// }; -// -// -// Attributes: -// - Type -type EnumType struct { - Type EnumUnderlyingType `thrift:"type,1" db:"type" json:"type"` -} - -func NewEnumType() *EnumType { - return &EnumType{} -} - - -func (p *EnumType) GetType() EnumUnderlyingType { - return p.Type -} -type EnumTypeBuilder struct { - obj *EnumType -} - -func NewEnumTypeBuilder() *EnumTypeBuilder{ - return &EnumTypeBuilder{ - obj: NewEnumType(), - } -} - -func (p EnumTypeBuilder) Emit() *EnumType{ - return &EnumType{ - Type: p.obj.Type, - } -} - -func (e *EnumTypeBuilder) Type(type_a1 EnumUnderlyingType) *EnumTypeBuilder { - e.obj.Type = type_a1 - return e -} - -func (e *EnumType) SetType(type_a1 EnumUnderlyingType) *EnumType { - e.Type = type_a1 - return e -} - -func (p *EnumType) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *EnumType) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - temp := EnumUnderlyingType(v) - p.Type = temp - } - return nil -} - -func (p *EnumType) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("EnumType"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *EnumType) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("type", thrift.I32, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:type: ", p), err) } - if err := oprot.WriteI32(int32(p.Type)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.type (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:type: ", p), err) } - return err -} - -func (p *EnumType) String() string { - if p == nil { - return "" - } - - typeVal := fmt.Sprintf("%v", p.Type) - return fmt.Sprintf("EnumType({Type:%s})", typeVal) -} - -// Indicates that frozen types should not be generated for a given struct. -type Frozen2Exclude struct { -} - -func NewFrozen2Exclude() *Frozen2Exclude { - return &Frozen2Exclude{} -} - -type Frozen2ExcludeBuilder struct { - obj *Frozen2Exclude -} - -func NewFrozen2ExcludeBuilder() *Frozen2ExcludeBuilder{ - return &Frozen2ExcludeBuilder{ - obj: NewFrozen2Exclude(), - } -} - -func (p Frozen2ExcludeBuilder) Emit() *Frozen2Exclude{ - return &Frozen2Exclude{ - } -} - -func (p *Frozen2Exclude) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Frozen2Exclude) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Frozen2Exclude"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Frozen2Exclude) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Frozen2Exclude({})") -} - -// Indicates that the container params must be complete at the time this type is instantiated. -// Only required in rare cases where the build fails with a frozen-related assert failure. -type Frozen2RequiresCompleteContainerParams struct { -} - -func NewFrozen2RequiresCompleteContainerParams() *Frozen2RequiresCompleteContainerParams { - return &Frozen2RequiresCompleteContainerParams{} -} - -type Frozen2RequiresCompleteContainerParamsBuilder struct { - obj *Frozen2RequiresCompleteContainerParams -} - -func NewFrozen2RequiresCompleteContainerParamsBuilder() *Frozen2RequiresCompleteContainerParamsBuilder{ - return &Frozen2RequiresCompleteContainerParamsBuilder{ - obj: NewFrozen2RequiresCompleteContainerParams(), - } -} - -func (p Frozen2RequiresCompleteContainerParamsBuilder) Emit() *Frozen2RequiresCompleteContainerParams{ - return &Frozen2RequiresCompleteContainerParams{ - } -} - -func (p *Frozen2RequiresCompleteContainerParams) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Frozen2RequiresCompleteContainerParams) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Frozen2RequiresCompleteContainerParams"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Frozen2RequiresCompleteContainerParams) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Frozen2RequiresCompleteContainerParams({})") -} - -// Generates typed interceptor stubs that can be overriden by user, -// and adorn the handler methods. This can be used on individual functions -// or on services (equivalent to adding it to all functions). -// -// service MyService { -// @cpp.GenerateTypedInterceptor -// void ping(); -// } -// -// This will generate the following interface: -// -// class TypedInterceptor { -// TypeErasedStorage before_ping(); -// TypeErasedStorage after_ping(); -// } -// -type GenerateTypedInterceptor struct { -} - -func NewGenerateTypedInterceptor() *GenerateTypedInterceptor { - return &GenerateTypedInterceptor{} -} - -type GenerateTypedInterceptorBuilder struct { - obj *GenerateTypedInterceptor -} - -func NewGenerateTypedInterceptorBuilder() *GenerateTypedInterceptorBuilder{ - return &GenerateTypedInterceptorBuilder{ - obj: NewGenerateTypedInterceptor(), - } -} - -func (p GenerateTypedInterceptorBuilder) Emit() *GenerateTypedInterceptor{ - return &GenerateTypedInterceptor{ - } -} - -func (p *GenerateTypedInterceptor) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *GenerateTypedInterceptor) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("GenerateTypedInterceptor"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *GenerateTypedInterceptor) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("GenerateTypedInterceptor({})") -} - -// Causes C++ handler code to run inline on the EventBase thread. -// Disables overload protection, use with caution. -// Cannot be applied to individual functions in interactions. -// -// Causes the request to be executed on the event base thread directly instead of rescheduling onto a thread manager thread, provided the async_eb_ handler method is implemented. -// You should only execute the request on the event base thread if it is very fast and you have measured that rescheduling is a substantial chunk of your service's CPU usage. -// If a request executing on the event base thread blocks or takes a long time, all other requests sharing the same event base are affected and latency will increase significantly. -// We strongly discourage the use of this annotation unless strictly necessary. You will have to implement the harder-to-use async_eb_ handler method. -// This also disables queue timeouts, an important form of overload protection. -type ProcessInEbThreadUnsafe struct { -} - -func NewProcessInEbThreadUnsafe() *ProcessInEbThreadUnsafe { - return &ProcessInEbThreadUnsafe{} -} - -type ProcessInEbThreadUnsafeBuilder struct { - obj *ProcessInEbThreadUnsafe -} - -func NewProcessInEbThreadUnsafeBuilder() *ProcessInEbThreadUnsafeBuilder{ - return &ProcessInEbThreadUnsafeBuilder{ - obj: NewProcessInEbThreadUnsafe(), - } -} - -func (p ProcessInEbThreadUnsafeBuilder) Emit() *ProcessInEbThreadUnsafe{ - return &ProcessInEbThreadUnsafe{ - } -} - -func (p *ProcessInEbThreadUnsafe) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ProcessInEbThreadUnsafe) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("ProcessInEbThreadUnsafe"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *ProcessInEbThreadUnsafe) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("ProcessInEbThreadUnsafe({})") -} - -// Applies to structured annotation that need to be accessed in Runtime. -type RuntimeAnnotation struct { -} - -func NewRuntimeAnnotation() *RuntimeAnnotation { - return &RuntimeAnnotation{} -} - -type RuntimeAnnotationBuilder struct { - obj *RuntimeAnnotation -} - -func NewRuntimeAnnotationBuilder() *RuntimeAnnotationBuilder{ - return &RuntimeAnnotationBuilder{ - obj: NewRuntimeAnnotation(), - } -} - -func (p RuntimeAnnotationBuilder) Emit() *RuntimeAnnotation{ - return &RuntimeAnnotation{ - } -} - -func (p *RuntimeAnnotation) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *RuntimeAnnotation) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("RuntimeAnnotation"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *RuntimeAnnotation) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("RuntimeAnnotation({})") -} - diff --git a/thrift/compiler/test/fixtures/basic-annotations/gen-go/thrift/annotation/go/constants.go b/thrift/compiler/test/fixtures/basic-annotations/gen-go/thrift/annotation/go/constants.go deleted file mode 100644 index 1e70fdfe4c3..00000000000 --- a/thrift/compiler/test/fixtures/basic-annotations/gen-go/thrift/annotation/go/constants.go +++ /dev/null @@ -1,25 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package go - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - - -func init() { -} - diff --git a/thrift/compiler/test/fixtures/basic-annotations/gen-go/thrift/annotation/go/ttypes.go b/thrift/compiler/test/fixtures/basic-annotations/gen-go/thrift/annotation/go/ttypes.go deleted file mode 100644 index dd186114d3a..00000000000 --- a/thrift/compiler/test/fixtures/basic-annotations/gen-go/thrift/annotation/go/ttypes.go +++ /dev/null @@ -1,310 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package go - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var GoUnusedProtection__ int; - -// Attributes: -// - Name -type Name struct { - Name string `thrift:"name,1" db:"name" json:"name"` -} - -func NewName() *Name { - return &Name{} -} - - -func (p *Name) GetName() string { - return p.Name -} -type NameBuilder struct { - obj *Name -} - -func NewNameBuilder() *NameBuilder{ - return &NameBuilder{ - obj: NewName(), - } -} - -func (p NameBuilder) Emit() *Name{ - return &Name{ - Name: p.obj.Name, - } -} - -func (n *NameBuilder) Name(name string) *NameBuilder { - n.obj.Name = name - return n -} - -func (n *Name) SetName(name string) *Name { - n.Name = name - return n -} - -func (p *Name) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Name) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Name = v - } - return nil -} - -func (p *Name) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Name"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Name) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) } - if err := oprot.WriteString(string(p.Name)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) } - return err -} - -func (p *Name) String() string { - if p == nil { - return "" - } - - nameVal := fmt.Sprintf("%v", p.Name) - return fmt.Sprintf("Name({Name:%s})", nameVal) -} - -// Attributes: -// - Tag -type Tag struct { - Tag string `thrift:"tag,1" db:"tag" json:"tag"` -} - -func NewTag() *Tag { - return &Tag{} -} - - -func (p *Tag) GetTag() string { - return p.Tag -} -type TagBuilder struct { - obj *Tag -} - -func NewTagBuilder() *TagBuilder{ - return &TagBuilder{ - obj: NewTag(), - } -} - -func (p TagBuilder) Emit() *Tag{ - return &Tag{ - Tag: p.obj.Tag, - } -} - -func (t *TagBuilder) Tag(tag string) *TagBuilder { - t.obj.Tag = tag - return t -} - -func (t *Tag) SetTag(tag string) *Tag { - t.Tag = tag - return t -} - -func (p *Tag) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Tag) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Tag = v - } - return nil -} - -func (p *Tag) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Tag"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Tag) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("tag", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:tag: ", p), err) } - if err := oprot.WriteString(string(p.Tag)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.tag (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:tag: ", p), err) } - return err -} - -func (p *Tag) String() string { - if p == nil { - return "" - } - - tagVal := fmt.Sprintf("%v", p.Tag) - return fmt.Sprintf("Tag({Tag:%s})", tagVal) -} - -type NewType_ struct { -} - -func NewNewType_() *NewType_ { - return &NewType_{} -} - -type NewType_Builder struct { - obj *NewType_ -} - -func NewNewType_Builder() *NewType_Builder{ - return &NewType_Builder{ - obj: NewNewType_(), - } -} - -func (p NewType_Builder) Emit() *NewType_{ - return &NewType_{ - } -} - -func (p *NewType_) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *NewType_) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("NewType"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *NewType_) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("NewType_({})") -} - diff --git a/thrift/compiler/test/fixtures/basic-annotations/gen-go/thrift/annotation/hack/constants.go b/thrift/compiler/test/fixtures/basic-annotations/gen-go/thrift/annotation/hack/constants.go deleted file mode 100644 index 4054b104418..00000000000 --- a/thrift/compiler/test/fixtures/basic-annotations/gen-go/thrift/annotation/hack/constants.go +++ /dev/null @@ -1,25 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package hack - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - - -func init() { -} - diff --git a/thrift/compiler/test/fixtures/basic-annotations/gen-go/thrift/annotation/hack/ttypes.go b/thrift/compiler/test/fixtures/basic-annotations/gen-go/thrift/annotation/hack/ttypes.go deleted file mode 100644 index 4d27cf73b43..00000000000 --- a/thrift/compiler/test/fixtures/basic-annotations/gen-go/thrift/annotation/hack/ttypes.go +++ /dev/null @@ -1,1315 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package hack - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var GoUnusedProtection__ int; - -// An experimental annotation that applies a Hack wrapper to fields. -// For example: -// -// struct User { -// @hack.FieldWrapper{name="MyWrapper"} -// 1: i64 id; -// } -// -// Attributes: -// - Name: The name of a Hack wrapper class used to wrap the field -type FieldWrapper struct { - Name string `thrift:"name,1" db:"name" json:"name"` -} - -func NewFieldWrapper() *FieldWrapper { - return &FieldWrapper{} -} - - -func (p *FieldWrapper) GetName() string { - return p.Name -} -type FieldWrapperBuilder struct { - obj *FieldWrapper -} - -func NewFieldWrapperBuilder() *FieldWrapperBuilder{ - return &FieldWrapperBuilder{ - obj: NewFieldWrapper(), - } -} - -func (p FieldWrapperBuilder) Emit() *FieldWrapper{ - return &FieldWrapper{ - Name: p.obj.Name, - } -} - -func (f *FieldWrapperBuilder) Name(name string) *FieldWrapperBuilder { - f.obj.Name = name - return f -} - -func (f *FieldWrapper) SetName(name string) *FieldWrapper { - f.Name = name - return f -} - -func (p *FieldWrapper) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *FieldWrapper) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Name = v - } - return nil -} - -func (p *FieldWrapper) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("FieldWrapper"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *FieldWrapper) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) } - if err := oprot.WriteString(string(p.Name)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) } - return err -} - -func (p *FieldWrapper) String() string { - if p == nil { - return "" - } - - nameVal := fmt.Sprintf("%v", p.Name) - return fmt.Sprintf("FieldWrapper({Name:%s})", nameVal) -} - -// An annotation that applies a Hack wrapper to fields, typedef or structs. -// For example: -// -// struct User { -// @hack.FieldWrapper{name="MyWrapper"} -// 1: i64 id; -// } -// -// Attributes: -// - Name: The name of a Hack wrapper class used to wrap the field -// - UnderlyingName: When applied directly to a typedef or struct, the IDL name of the -// type will refer to the adapted type in Hack and the underlying thrift struct will be -// generated in a nested namespace and/or with a different name. By default the type/struct -// will be generated in a nested 'thrift_adapted_types' namespace with the same name, -// but both of these can be changed by setting these fields. -// Empty string enables the nested namespace and uses the IDL name for the struct. -// - ExtraNamespace -type Wrapper struct { - Name string `thrift:"name,1" db:"name" json:"name"` - UnderlyingName string `thrift:"underlyingName,2" db:"underlyingName" json:"underlyingName"` - ExtraNamespace string `thrift:"extraNamespace,3" db:"extraNamespace" json:"extraNamespace"` -} - -func NewWrapper() *Wrapper { - return &Wrapper{ - ExtraNamespace: "thrift_adapted_types", - } -} - - -func (p *Wrapper) GetName() string { - return p.Name -} - -func (p *Wrapper) GetUnderlyingName() string { - return p.UnderlyingName -} - -func (p *Wrapper) GetExtraNamespace() string { - return p.ExtraNamespace -} -type WrapperBuilder struct { - obj *Wrapper -} - -func NewWrapperBuilder() *WrapperBuilder{ - return &WrapperBuilder{ - obj: NewWrapper(), - } -} - -func (p WrapperBuilder) Emit() *Wrapper{ - return &Wrapper{ - Name: p.obj.Name, - UnderlyingName: p.obj.UnderlyingName, - ExtraNamespace: p.obj.ExtraNamespace, - } -} - -func (w *WrapperBuilder) Name(name string) *WrapperBuilder { - w.obj.Name = name - return w -} - -func (w *WrapperBuilder) UnderlyingName(underlyingName string) *WrapperBuilder { - w.obj.UnderlyingName = underlyingName - return w -} - -func (w *WrapperBuilder) ExtraNamespace(extraNamespace string) *WrapperBuilder { - w.obj.ExtraNamespace = extraNamespace - return w -} - -func (w *Wrapper) SetName(name string) *Wrapper { - w.Name = name - return w -} - -func (w *Wrapper) SetUnderlyingName(underlyingName string) *Wrapper { - w.UnderlyingName = underlyingName - return w -} - -func (w *Wrapper) SetExtraNamespace(extraNamespace string) *Wrapper { - w.ExtraNamespace = extraNamespace - return w -} - -func (p *Wrapper) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 3: - if err := p.ReadField3(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Wrapper) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Name = v - } - return nil -} - -func (p *Wrapper) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.UnderlyingName = v - } - return nil -} - -func (p *Wrapper) ReadField3(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 3: ", err) - } else { - p.ExtraNamespace = v - } - return nil -} - -func (p *Wrapper) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Wrapper"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Wrapper) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) } - if err := oprot.WriteString(string(p.Name)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) } - return err -} - -func (p *Wrapper) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("underlyingName", thrift.STRING, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:underlyingName: ", p), err) } - if err := oprot.WriteString(string(p.UnderlyingName)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.underlyingName (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:underlyingName: ", p), err) } - return err -} - -func (p *Wrapper) writeField3(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("extraNamespace", thrift.STRING, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:extraNamespace: ", p), err) } - if err := oprot.WriteString(string(p.ExtraNamespace)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.extraNamespace (3) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:extraNamespace: ", p), err) } - return err -} - -func (p *Wrapper) String() string { - if p == nil { - return "" - } - - nameVal := fmt.Sprintf("%v", p.Name) - underlyingNameVal := fmt.Sprintf("%v", p.UnderlyingName) - extraNamespaceVal := fmt.Sprintf("%v", p.ExtraNamespace) - return fmt.Sprintf("Wrapper({Name:%s UnderlyingName:%s ExtraNamespace:%s})", nameVal, underlyingNameVal, extraNamespaceVal) -} - -// An annotation that applies a Hack adapter to types. For example: -// @hack.Adapter{name="\\TimestampAdapter"} -// typedef i64 Timestamp; -// -// struct User { -// 1: Timestamp account_creation_time; -// } -// -// Here the field `account_creation_time` will have type TimestampAdapter::THackType instead of i64. -// -// in hack: -// ``` -// final class TimestampAdapter implements IThriftAdapter { -// const type TThriftType = int; -// const type THackType = Time; -// public static function fromThrift(int $seconds)[]: Time { -// return Time::fromEpochSeconds($seconds); -// } -// public static function toThrift(Time $time): int { -// return $hack_value->asFullSecondsSinceEpoch(); -// } -// } -// ``` -// elsewhere in hack: -// ``` -// function timeSinceCreated(Document $doc): Duration { -// // $doc->created_time is of type Time -// return Duration::between(Time::now(), $doc->created_time); -// } -// ``` -// This completely replaces the underlying type of a thrift for a custom implementation and uses -// the specified adapter to convert to and from the underlying Thrift type during (de)serialization. -// -// Attributes: -// - Name: The name of a Hack adapter class that implements IThriftAdapter -type Adapter struct { - Name string `thrift:"name,1" db:"name" json:"name"` -} - -func NewAdapter() *Adapter { - return &Adapter{} -} - - -func (p *Adapter) GetName() string { - return p.Name -} -type AdapterBuilder struct { - obj *Adapter -} - -func NewAdapterBuilder() *AdapterBuilder{ - return &AdapterBuilder{ - obj: NewAdapter(), - } -} - -func (p AdapterBuilder) Emit() *Adapter{ - return &Adapter{ - Name: p.obj.Name, - } -} - -func (a *AdapterBuilder) Name(name string) *AdapterBuilder { - a.obj.Name = name - return a -} - -func (a *Adapter) SetName(name string) *Adapter { - a.Name = name - return a -} - -func (p *Adapter) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Adapter) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Name = v - } - return nil -} - -func (p *Adapter) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Adapter"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Adapter) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) } - if err := oprot.WriteString(string(p.Name)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) } - return err -} - -func (p *Adapter) String() string { - if p == nil { - return "" - } - - nameVal := fmt.Sprintf("%v", p.Name) - return fmt.Sprintf("Adapter({Name:%s})", nameVal) -} - -// Attributes: -// - Reason -type SkipCodegen struct { - Reason string `thrift:"reason,1" db:"reason" json:"reason"` -} - -func NewSkipCodegen() *SkipCodegen { - return &SkipCodegen{} -} - - -func (p *SkipCodegen) GetReason() string { - return p.Reason -} -type SkipCodegenBuilder struct { - obj *SkipCodegen -} - -func NewSkipCodegenBuilder() *SkipCodegenBuilder{ - return &SkipCodegenBuilder{ - obj: NewSkipCodegen(), - } -} - -func (p SkipCodegenBuilder) Emit() *SkipCodegen{ - return &SkipCodegen{ - Reason: p.obj.Reason, - } -} - -func (s *SkipCodegenBuilder) Reason(reason string) *SkipCodegenBuilder { - s.obj.Reason = reason - return s -} - -func (s *SkipCodegen) SetReason(reason string) *SkipCodegen { - s.Reason = reason - return s -} - -func (p *SkipCodegen) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *SkipCodegen) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Reason = v - } - return nil -} - -func (p *SkipCodegen) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("SkipCodegen"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *SkipCodegen) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("reason", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:reason: ", p), err) } - if err := oprot.WriteString(string(p.Reason)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.reason (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:reason: ", p), err) } - return err -} - -func (p *SkipCodegen) String() string { - if p == nil { - return "" - } - - reasonVal := fmt.Sprintf("%v", p.Reason) - return fmt.Sprintf("SkipCodegen({Reason:%s})", reasonVal) -} - -// This annotation is mainly used to rename symbols which can result in symbol -// conflict errors in Hack codegen. -// For ex: reserved keywords in Hack language, symbols with similar names from -// other files in Hack -// -// Attributes: -// - Name -// - Reason -type Name struct { - Name string `thrift:"name,1" db:"name" json:"name"` - Reason string `thrift:"reason,2" db:"reason" json:"reason"` -} - -func NewName() *Name { - return &Name{} -} - - -func (p *Name) GetName() string { - return p.Name -} - -func (p *Name) GetReason() string { - return p.Reason -} -type NameBuilder struct { - obj *Name -} - -func NewNameBuilder() *NameBuilder{ - return &NameBuilder{ - obj: NewName(), - } -} - -func (p NameBuilder) Emit() *Name{ - return &Name{ - Name: p.obj.Name, - Reason: p.obj.Reason, - } -} - -func (n *NameBuilder) Name(name string) *NameBuilder { - n.obj.Name = name - return n -} - -func (n *NameBuilder) Reason(reason string) *NameBuilder { - n.obj.Reason = reason - return n -} - -func (n *Name) SetName(name string) *Name { - n.Name = name - return n -} - -func (n *Name) SetReason(reason string) *Name { - n.Reason = reason - return n -} - -func (p *Name) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Name) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Name = v - } - return nil -} - -func (p *Name) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Reason = v - } - return nil -} - -func (p *Name) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Name"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Name) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) } - if err := oprot.WriteString(string(p.Name)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) } - return err -} - -func (p *Name) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("reason", thrift.STRING, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:reason: ", p), err) } - if err := oprot.WriteString(string(p.Reason)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.reason (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:reason: ", p), err) } - return err -} - -func (p *Name) String() string { - if p == nil { - return "" - } - - nameVal := fmt.Sprintf("%v", p.Name) - reasonVal := fmt.Sprintf("%v", p.Reason) - return fmt.Sprintf("Name({Name:%s Reason:%s})", nameVal, reasonVal) -} - -// This annotation is for adding Hack attributes to union enums. -// -// Attributes: -// - Attributes -type UnionEnumAttributes struct { - Attributes []string `thrift:"attributes,1" db:"attributes" json:"attributes"` -} - -func NewUnionEnumAttributes() *UnionEnumAttributes { - return &UnionEnumAttributes{} -} - - -func (p *UnionEnumAttributes) GetAttributes() []string { - return p.Attributes -} -type UnionEnumAttributesBuilder struct { - obj *UnionEnumAttributes -} - -func NewUnionEnumAttributesBuilder() *UnionEnumAttributesBuilder{ - return &UnionEnumAttributesBuilder{ - obj: NewUnionEnumAttributes(), - } -} - -func (p UnionEnumAttributesBuilder) Emit() *UnionEnumAttributes{ - return &UnionEnumAttributes{ - Attributes: p.obj.Attributes, - } -} - -func (u *UnionEnumAttributesBuilder) Attributes(attributes []string) *UnionEnumAttributesBuilder { - u.obj.Attributes = attributes - return u -} - -func (u *UnionEnumAttributes) SetAttributes(attributes []string) *UnionEnumAttributes { - u.Attributes = attributes - return u -} - -func (p *UnionEnumAttributes) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *UnionEnumAttributes) ReadField1(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]string, 0, size) - p.Attributes = tSlice - for i := 0; i < size; i ++ { - var _elem0 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem0 = v - } - p.Attributes = append(p.Attributes, _elem0) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *UnionEnumAttributes) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("UnionEnumAttributes"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *UnionEnumAttributes) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("attributes", thrift.LIST, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:attributes: ", p), err) } - if err := oprot.WriteListBegin(thrift.STRING, len(p.Attributes)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.Attributes { - if err := oprot.WriteString(string(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:attributes: ", p), err) } - return err -} - -func (p *UnionEnumAttributes) String() string { - if p == nil { - return "" - } - - attributesVal := fmt.Sprintf("%v", p.Attributes) - return fmt.Sprintf("UnionEnumAttributes({Attributes:%s})", attributesVal) -} - -// This annotation is for using a custom trait for structs. -// -// Attributes: -// - Name -type StructTrait struct { - Name string `thrift:"name,1" db:"name" json:"name"` -} - -func NewStructTrait() *StructTrait { - return &StructTrait{} -} - - -func (p *StructTrait) GetName() string { - return p.Name -} -type StructTraitBuilder struct { - obj *StructTrait -} - -func NewStructTraitBuilder() *StructTraitBuilder{ - return &StructTraitBuilder{ - obj: NewStructTrait(), - } -} - -func (p StructTraitBuilder) Emit() *StructTrait{ - return &StructTrait{ - Name: p.obj.Name, - } -} - -func (s *StructTraitBuilder) Name(name string) *StructTraitBuilder { - s.obj.Name = name - return s -} - -func (s *StructTrait) SetName(name string) *StructTrait { - s.Name = name - return s -} - -func (p *StructTrait) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *StructTrait) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Name = v - } - return nil -} - -func (p *StructTrait) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("StructTrait"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *StructTrait) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) } - if err := oprot.WriteString(string(p.Name)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) } - return err -} - -func (p *StructTrait) String() string { - if p == nil { - return "" - } - - nameVal := fmt.Sprintf("%v", p.Name) - return fmt.Sprintf("StructTrait({Name:%s})", nameVal) -} - -// This annotation is for adding Hack attributes. -// * Where to use: field or struct type -// * Value: add attributes like `JSEnum` to structs or fields -// * Example: -// -// ``` -// // In thrift -// enum MyEnum { -// ALLOWED = 1, -// THIS_IS_ALLOWED = 2, -// THIS_IS_ALLOWED_2 = 3, -// }( -// hack.attributes= -// "\JSEnum(shape('name' => 'MyEnum')), -// \GraphQLEnum('MyEnum', 'Description for my enum',)" -// ) -// struct MyThriftStruct { -// 1: string foo (hack.attributes = "FieldAttribute"); -// 2: string bar; -// 3: string baz; -// } (hack.attributes = "ClassAttribute") -// ``` -// ``` -// //thrift compiler will generate this for you -// <<\JSEnum(shape('name' => 'MyEnum')), -// \GraphQLEnum('MyEnum', 'Description for my enum',)>> -// enum MyEnum: int { -// ALLOWED = 1; -// THIS_IS_ALLOWED = 2; -// THIS_IS_ALLOWED_2 = 3; -// } -// <> -// class MyThriftStruct implements \IThriftStruct { -// .... -// <> -// public string $foo; -// .... -// } -// ``` -// -// Attributes: -// - Attributes -type Attributes struct { - Attributes []string `thrift:"attributes,1" db:"attributes" json:"attributes"` -} - -func NewAttributes() *Attributes { - return &Attributes{} -} - - -func (p *Attributes) GetAttributes() []string { - return p.Attributes -} -type AttributesBuilder struct { - obj *Attributes -} - -func NewAttributesBuilder() *AttributesBuilder{ - return &AttributesBuilder{ - obj: NewAttributes(), - } -} - -func (p AttributesBuilder) Emit() *Attributes{ - return &Attributes{ - Attributes: p.obj.Attributes, - } -} - -func (a *AttributesBuilder) Attributes(attributes []string) *AttributesBuilder { - a.obj.Attributes = attributes - return a -} - -func (a *Attributes) SetAttributes(attributes []string) *Attributes { - a.Attributes = attributes - return a -} - -func (p *Attributes) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Attributes) ReadField1(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]string, 0, size) - p.Attributes = tSlice - for i := 0; i < size; i ++ { - var _elem1 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem1 = v - } - p.Attributes = append(p.Attributes, _elem1) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *Attributes) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Attributes"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Attributes) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("attributes", thrift.LIST, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:attributes: ", p), err) } - if err := oprot.WriteListBegin(thrift.STRING, len(p.Attributes)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.Attributes { - if err := oprot.WriteString(string(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:attributes: ", p), err) } - return err -} - -func (p *Attributes) String() string { - if p == nil { - return "" - } - - attributesVal := fmt.Sprintf("%v", p.Attributes) - return fmt.Sprintf("Attributes({Attributes:%s})", attributesVal) -} - -type StructAsTrait struct { -} - -func NewStructAsTrait() *StructAsTrait { - return &StructAsTrait{} -} - -type StructAsTraitBuilder struct { - obj *StructAsTrait -} - -func NewStructAsTraitBuilder() *StructAsTraitBuilder{ - return &StructAsTraitBuilder{ - obj: NewStructAsTrait(), - } -} - -func (p StructAsTraitBuilder) Emit() *StructAsTrait{ - return &StructAsTrait{ - } -} - -func (p *StructAsTrait) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *StructAsTrait) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("StructAsTrait"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *StructAsTrait) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("StructAsTrait({})") -} - -// This annotation is to generate an entity as internal -type ModuleInternal struct { -} - -func NewModuleInternal() *ModuleInternal { - return &ModuleInternal{} -} - -type ModuleInternalBuilder struct { - obj *ModuleInternal -} - -func NewModuleInternalBuilder() *ModuleInternalBuilder{ - return &ModuleInternalBuilder{ - obj: NewModuleInternal(), - } -} - -func (p ModuleInternalBuilder) Emit() *ModuleInternal{ - return &ModuleInternal{ - } -} - -func (p *ModuleInternal) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ModuleInternal) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("ModuleInternal"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *ModuleInternal) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("ModuleInternal({})") -} - diff --git a/thrift/compiler/test/fixtures/basic-annotations/gen-go/thrift/annotation/scope/constants.go b/thrift/compiler/test/fixtures/basic-annotations/gen-go/thrift/annotation/scope/constants.go deleted file mode 100644 index 0c3448a7126..00000000000 --- a/thrift/compiler/test/fixtures/basic-annotations/gen-go/thrift/annotation/scope/constants.go +++ /dev/null @@ -1,25 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package scope - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - - -func init() { -} - diff --git a/thrift/compiler/test/fixtures/basic-annotations/gen-go/thrift/annotation/scope/ttypes.go b/thrift/compiler/test/fixtures/basic-annotations/gen-go/thrift/annotation/scope/ttypes.go deleted file mode 100644 index 580c39e775c..00000000000 --- a/thrift/compiler/test/fixtures/basic-annotations/gen-go/thrift/annotation/scope/ttypes.go +++ /dev/null @@ -1,1169 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package scope - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var GoUnusedProtection__ int; - -// Indicates that the scope of sibling annotations is transitive. -// -// For example: -// -// @scope.Struct -// @scope.Union -// @scope.Exception -// @scope.Transitive -// struct Structured {} -// -// Annotating a Thrift struct with @Structured automatically applies -// @scope.Struct, @scope.Union and @scope.Exception annotations, i.e. -// -// @Structured -// struct MyAnnotation {} -// -// is equivalent to -// -// @scope.Struct -// @scope.Union -// @scope.Exception -// struct MyAnnotation {} -// -type Transitive struct { -} - -func NewTransitive() *Transitive { - return &Transitive{} -} - -type TransitiveBuilder struct { - obj *Transitive -} - -func NewTransitiveBuilder() *TransitiveBuilder{ - return &TransitiveBuilder{ - obj: NewTransitive(), - } -} - -func (p TransitiveBuilder) Emit() *Transitive{ - return &Transitive{ - } -} - -func (p *Transitive) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Transitive) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Transitive"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Transitive) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Transitive({})") -} - -// The Program scope. -// -// This allows annotations on the `package` definition, which implies the -// annotaiton applies to the entire program. -type Program struct { -} - -func NewProgram() *Program { - return &Program{} -} - -type ProgramBuilder struct { - obj *Program -} - -func NewProgramBuilder() *ProgramBuilder{ - return &ProgramBuilder{ - obj: NewProgram(), - } -} - -func (p ProgramBuilder) Emit() *Program{ - return &Program{ - } -} - -func (p *Program) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Program) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Program"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Program) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Program({})") -} - -// The `struct` definition scope. -type Struct struct { -} - -func NewStruct() *Struct { - return &Struct{} -} - -type StructBuilder struct { - obj *Struct -} - -func NewStructBuilder() *StructBuilder{ - return &StructBuilder{ - obj: NewStruct(), - } -} - -func (p StructBuilder) Emit() *Struct{ - return &Struct{ - } -} - -func (p *Struct) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Struct) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Struct"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Struct) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Struct({})") -} - -// The `union` definition scope. -type Union struct { -} - -func NewUnion() *Union { - return &Union{} -} - -type UnionBuilder struct { - obj *Union -} - -func NewUnionBuilder() *UnionBuilder{ - return &UnionBuilder{ - obj: NewUnion(), - } -} - -func (p UnionBuilder) Emit() *Union{ - return &Union{ - } -} - -func (p *Union) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Union) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Union"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Union) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Union({})") -} - -// The `exception` definition scope. -type Exception struct { -} - -func NewException() *Exception { - return &Exception{} -} - -type ExceptionBuilder struct { - obj *Exception -} - -func NewExceptionBuilder() *ExceptionBuilder{ - return &ExceptionBuilder{ - obj: NewException(), - } -} - -func (p ExceptionBuilder) Emit() *Exception{ - return &Exception{ - } -} - -func (p *Exception) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Exception) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Exception"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Exception) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Exception({})") -} - -// Field declartaions, for example in `struct` or `function` declartions. -type Field struct { -} - -func NewField() *Field { - return &Field{} -} - -type FieldBuilder struct { - obj *Field -} - -func NewFieldBuilder() *FieldBuilder{ - return &FieldBuilder{ - obj: NewField(), - } -} - -func (p FieldBuilder) Emit() *Field{ - return &Field{ - } -} - -func (p *Field) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Field) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Field"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Field) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Field({})") -} - -// The `typedef` definition scope. -type Typedef struct { -} - -func NewTypedef() *Typedef { - return &Typedef{} -} - -type TypedefBuilder struct { - obj *Typedef -} - -func NewTypedefBuilder() *TypedefBuilder{ - return &TypedefBuilder{ - obj: NewTypedef(), - } -} - -func (p TypedefBuilder) Emit() *Typedef{ - return &Typedef{ - } -} - -func (p *Typedef) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Typedef) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Typedef"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Typedef) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Typedef({})") -} - -// The `service` definition scope. -type Service struct { -} - -func NewService() *Service { - return &Service{} -} - -type ServiceBuilder struct { - obj *Service -} - -func NewServiceBuilder() *ServiceBuilder{ - return &ServiceBuilder{ - obj: NewService(), - } -} - -func (p ServiceBuilder) Emit() *Service{ - return &Service{ - } -} - -func (p *Service) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Service) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Service"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Service) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Service({})") -} - -// The `interaction` definition scope. -type Interaction struct { -} - -func NewInteraction() *Interaction { - return &Interaction{} -} - -type InteractionBuilder struct { - obj *Interaction -} - -func NewInteractionBuilder() *InteractionBuilder{ - return &InteractionBuilder{ - obj: NewInteraction(), - } -} - -func (p InteractionBuilder) Emit() *Interaction{ - return &Interaction{ - } -} - -func (p *Interaction) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Interaction) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Interaction"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Interaction) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Interaction({})") -} - -// The `function` definition scope. -type Function struct { -} - -func NewFunction() *Function { - return &Function{} -} - -type FunctionBuilder struct { - obj *Function -} - -func NewFunctionBuilder() *FunctionBuilder{ - return &FunctionBuilder{ - obj: NewFunction(), - } -} - -func (p FunctionBuilder) Emit() *Function{ - return &Function{ - } -} - -func (p *Function) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Function) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Function"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Function) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Function({})") -} - -// The Enum value definition scope. -type EnumValue struct { -} - -func NewEnumValue() *EnumValue { - return &EnumValue{} -} - -type EnumValueBuilder struct { - obj *EnumValue -} - -func NewEnumValueBuilder() *EnumValueBuilder{ - return &EnumValueBuilder{ - obj: NewEnumValue(), - } -} - -func (p EnumValueBuilder) Emit() *EnumValue{ - return &EnumValue{ - } -} - -func (p *EnumValue) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *EnumValue) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("EnumValue"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *EnumValue) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("EnumValue({})") -} - -// The `const` definition scope. -type Const struct { -} - -func NewConst() *Const { - return &Const{} -} - -type ConstBuilder struct { - obj *Const -} - -func NewConstBuilder() *ConstBuilder{ - return &ConstBuilder{ - obj: NewConst(), - } -} - -func (p ConstBuilder) Emit() *Const{ - return &Const{ - } -} - -func (p *Const) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Const) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Const"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Const) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Const({})") -} - -type Enum struct { -} - -func NewEnum() *Enum { - return &Enum{} -} - -type EnumBuilder struct { - obj *Enum -} - -func NewEnumBuilder() *EnumBuilder{ - return &EnumBuilder{ - obj: NewEnum(), - } -} - -func (p EnumBuilder) Emit() *Enum{ - return &Enum{ - } -} - -func (p *Enum) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Enum) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Enum"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Enum) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Enum({})") -} - -// A scope that includes all 'structured' definitions. -type Structured struct { -} - -func NewStructured() *Structured { - return &Structured{} -} - -type StructuredBuilder struct { - obj *Structured -} - -func NewStructuredBuilder() *StructuredBuilder{ - return &StructuredBuilder{ - obj: NewStructured(), - } -} - -func (p StructuredBuilder) Emit() *Structured{ - return &Structured{ - } -} - -func (p *Structured) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Structured) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Structured"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Structured) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Structured({})") -} - -// A scope that includes all 'interface' definitions. -type Interface struct { -} - -func NewInterface() *Interface { - return &Interface{} -} - -type InterfaceBuilder struct { - obj *Interface -} - -func NewInterfaceBuilder() *InterfaceBuilder{ - return &InterfaceBuilder{ - obj: NewInterface(), - } -} - -func (p InterfaceBuilder) Emit() *Interface{ - return &Interface{ - } -} - -func (p *Interface) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Interface) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Interface"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Interface) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Interface({})") -} - -// A scope that includes all program-scoped definition. -type RootDefinition struct { -} - -func NewRootDefinition() *RootDefinition { - return &RootDefinition{} -} - -type RootDefinitionBuilder struct { - obj *RootDefinition -} - -func NewRootDefinitionBuilder() *RootDefinitionBuilder{ - return &RootDefinitionBuilder{ - obj: NewRootDefinition(), - } -} - -func (p RootDefinitionBuilder) Emit() *RootDefinition{ - return &RootDefinition{ - } -} - -func (p *RootDefinition) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *RootDefinition) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("RootDefinition"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *RootDefinition) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("RootDefinition({})") -} - -// A scope that includes all definitions. -type Definition struct { -} - -func NewDefinition() *Definition { - return &Definition{} -} - -type DefinitionBuilder struct { - obj *Definition -} - -func NewDefinitionBuilder() *DefinitionBuilder{ - return &DefinitionBuilder{ - obj: NewDefinition(), - } -} - -func (p DefinitionBuilder) Emit() *Definition{ - return &Definition{ - } -} - -func (p *Definition) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Definition) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Definition"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Definition) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Definition({})") -} - diff --git a/thrift/compiler/test/fixtures/basic-annotations/gen-go/thrift/annotation/thrift/constants.go b/thrift/compiler/test/fixtures/basic-annotations/gen-go/thrift/annotation/thrift/constants.go deleted file mode 100644 index 50d9b0fe3ee..00000000000 --- a/thrift/compiler/test/fixtures/basic-annotations/gen-go/thrift/annotation/thrift/constants.go +++ /dev/null @@ -1,25 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package thrift - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - - -func init() { -} - diff --git a/thrift/compiler/test/fixtures/basic-annotations/gen-go/thrift/annotation/thrift/ttypes.go b/thrift/compiler/test/fixtures/basic-annotations/gen-go/thrift/annotation/thrift/ttypes.go deleted file mode 100644 index 35ea75e3dd0..00000000000 --- a/thrift/compiler/test/fixtures/basic-annotations/gen-go/thrift/annotation/thrift/ttypes.go +++ /dev/null @@ -1,1545 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package thrift - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var GoUnusedProtection__ int; - -type RpcPriority int64 -const ( - RpcPriority_HIGH_IMPORTANT RpcPriority = 0 - RpcPriority_HIGH RpcPriority = 1 - RpcPriority_IMPORTANT RpcPriority = 2 - RpcPriority_NORMAL RpcPriority = 3 - RpcPriority_BEST_EFFORT RpcPriority = 4 -) - -var RpcPriorityToName = map[RpcPriority]string { - RpcPriority_HIGH_IMPORTANT: "HIGH_IMPORTANT", - RpcPriority_HIGH: "HIGH", - RpcPriority_IMPORTANT: "IMPORTANT", - RpcPriority_NORMAL: "NORMAL", - RpcPriority_BEST_EFFORT: "BEST_EFFORT", -} - -var RpcPriorityToValue = map[string]RpcPriority { - "HIGH_IMPORTANT": RpcPriority_HIGH_IMPORTANT, - "HIGH": RpcPriority_HIGH, - "IMPORTANT": RpcPriority_IMPORTANT, - "NORMAL": RpcPriority_NORMAL, - "BEST_EFFORT": RpcPriority_BEST_EFFORT, -} - -var RpcPriorityNames = []string { - "HIGH_IMPORTANT", - "HIGH", - "IMPORTANT", - "NORMAL", - "BEST_EFFORT", -} - -var RpcPriorityValues = []RpcPriority { - RpcPriority_HIGH_IMPORTANT, - RpcPriority_HIGH, - RpcPriority_IMPORTANT, - RpcPriority_NORMAL, - RpcPriority_BEST_EFFORT, -} - -func (p RpcPriority) String() string { - if v, ok := RpcPriorityToName[p]; ok { - return v - } - return "" -} - -func RpcPriorityFromString(s string) (RpcPriority, error) { - if v, ok := RpcPriorityToValue[s]; ok { - return v, nil - } - return RpcPriority(0), fmt.Errorf("not a valid RpcPriority string") -} - -func RpcPriorityPtr(v RpcPriority) *RpcPriority { return &v } - -// Indicates a definition/feature should only be used with permission, may -// only work in specific contexts, and may change in incompatible ways without -// notice. Note that this is primarily intended to annotate features by the Thrift Team -// and isn't recommended for general use. -type Experimental struct { -} - -func NewExperimental() *Experimental { - return &Experimental{} -} - -type ExperimentalBuilder struct { - obj *Experimental -} - -func NewExperimentalBuilder() *ExperimentalBuilder{ - return &ExperimentalBuilder{ - obj: NewExperimental(), - } -} - -func (p ExperimentalBuilder) Emit() *Experimental{ - return &Experimental{ - } -} - -func (p *Experimental) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Experimental) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Experimental"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Experimental) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Experimental({})") -} - -// Annotate a thrift structured or enum to indicate if ids or values should not -// be used. -// -// For example, you may want to mark ids as deprecated, or these ids -// might be reserved for other use cases or annotations. -// -// The resolved set of disallowed ids is the union of the values in `ids` and -// the range of values represented in `id_ranges`. Example: -// -// // These ids are not allowed: 3, 8, half-open ranges [10, 15), [20, 30) -// @thrift.ReserveIds{ids = [3, 8], id_ranges = {10: 15, 20: 30}} -// struct Foo { -// ... -// 3: i64 f; // Build failure: 3 cannot be used -// } -// -// Attributes: -// - Ids: Individual ids that cannot be used. -// - IdRanges: Represents ranges of ids that cannot be used. -// -// Each (key: value) pair represents the half-open range `[key, value)`, -// where `key` is included and `value` is not. For example, the map -// `{10: 15, 20: 30}` represents the union of id/value ranges `[10, 15)` and -// `[20, 30)`. -type ReserveIds struct { - Ids []int32 `thrift:"ids,1" db:"ids" json:"ids"` - IdRanges map[int32]int32 `thrift:"id_ranges,2" db:"id_ranges" json:"id_ranges"` -} - -func NewReserveIds() *ReserveIds { - return &ReserveIds{} -} - - -func (p *ReserveIds) GetIds() []int32 { - return p.Ids -} - -func (p *ReserveIds) GetIdRanges() map[int32]int32 { - return p.IdRanges -} -type ReserveIdsBuilder struct { - obj *ReserveIds -} - -func NewReserveIdsBuilder() *ReserveIdsBuilder{ - return &ReserveIdsBuilder{ - obj: NewReserveIds(), - } -} - -func (p ReserveIdsBuilder) Emit() *ReserveIds{ - return &ReserveIds{ - Ids: p.obj.Ids, - IdRanges: p.obj.IdRanges, - } -} - -func (r *ReserveIdsBuilder) Ids(ids []int32) *ReserveIdsBuilder { - r.obj.Ids = ids - return r -} - -func (r *ReserveIdsBuilder) IdRanges(idRanges map[int32]int32) *ReserveIdsBuilder { - r.obj.IdRanges = idRanges - return r -} - -func (r *ReserveIds) SetIds(ids []int32) *ReserveIds { - r.Ids = ids - return r -} - -func (r *ReserveIds) SetIdRanges(idRanges map[int32]int32) *ReserveIds { - r.IdRanges = idRanges - return r -} - -func (p *ReserveIds) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ReserveIds) ReadField1(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]int32, 0, size) - p.Ids = tSlice - for i := 0; i < size; i ++ { - var _elem0 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem0 = v - } - p.Ids = append(p.Ids, _elem0) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *ReserveIds) ReadField2(iprot thrift.Protocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[int32]int32, size) - p.IdRanges = tMap - for i := 0; i < size; i ++ { - var _key1 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key1 = v - } - var _val2 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _val2 = v - } - p.IdRanges[_key1] = _val2 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *ReserveIds) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("ReserveIds"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *ReserveIds) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("ids", thrift.LIST, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:ids: ", p), err) } - if err := oprot.WriteListBegin(thrift.I32, len(p.Ids)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.Ids { - if err := oprot.WriteI32(int32(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:ids: ", p), err) } - return err -} - -func (p *ReserveIds) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("id_ranges", thrift.MAP, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:id_ranges: ", p), err) } - if err := oprot.WriteMapBegin(thrift.I32, thrift.I32, len(p.IdRanges)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.IdRanges { - if err := oprot.WriteI32(int32(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := oprot.WriteI32(int32(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:id_ranges: ", p), err) } - return err -} - -func (p *ReserveIds) String() string { - if p == nil { - return "" - } - - idsVal := fmt.Sprintf("%v", p.Ids) - idRangesVal := fmt.Sprintf("%v", p.IdRanges) - return fmt.Sprintf("ReserveIds({Ids:%s IdRanges:%s})", idsVal, idRangesVal) -} - -// Indicates additional backward compatibility restrictions, beyond the -// standard Thrift required 'wire' compatibility. -// -// Attributes: -// - FieldName -type RequiresBackwardCompatibility struct { - FieldName bool `thrift:"field_name,1" db:"field_name" json:"field_name"` -} - -func NewRequiresBackwardCompatibility() *RequiresBackwardCompatibility { - return &RequiresBackwardCompatibility{} -} - - -func (p *RequiresBackwardCompatibility) GetFieldName() bool { - return p.FieldName -} -type RequiresBackwardCompatibilityBuilder struct { - obj *RequiresBackwardCompatibility -} - -func NewRequiresBackwardCompatibilityBuilder() *RequiresBackwardCompatibilityBuilder{ - return &RequiresBackwardCompatibilityBuilder{ - obj: NewRequiresBackwardCompatibility(), - } -} - -func (p RequiresBackwardCompatibilityBuilder) Emit() *RequiresBackwardCompatibility{ - return &RequiresBackwardCompatibility{ - FieldName: p.obj.FieldName, - } -} - -func (r *RequiresBackwardCompatibilityBuilder) FieldName(fieldName bool) *RequiresBackwardCompatibilityBuilder { - r.obj.FieldName = fieldName - return r -} - -func (r *RequiresBackwardCompatibility) SetFieldName(fieldName bool) *RequiresBackwardCompatibility { - r.FieldName = fieldName - return r -} - -func (p *RequiresBackwardCompatibility) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *RequiresBackwardCompatibility) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.FieldName = v - } - return nil -} - -func (p *RequiresBackwardCompatibility) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("RequiresBackwardCompatibility"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *RequiresBackwardCompatibility) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("field_name", thrift.BOOL, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:field_name: ", p), err) } - if err := oprot.WriteBool(bool(p.FieldName)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.field_name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:field_name: ", p), err) } - return err -} - -func (p *RequiresBackwardCompatibility) String() string { - if p == nil { - return "" - } - - fieldNameVal := fmt.Sprintf("%v", p.FieldName) - return fmt.Sprintf("RequiresBackwardCompatibility({FieldName:%s})", fieldNameVal) -} - -// An annotation that changes the field qualifier from 'none' to 'terse'. -// A terse field is eligible to skip serialization, when it equals to the -// intrinsic default value. It also clears to the intrinsic default value -// before deserialization to distinguish between if a terse field was skipped -// or missing during serialization. This is different from an unqualified -// field, as an unqualified field is always serialized regardless of its value, -// and it is not cleared before deserialization. -// -// The annotation can be only used to annotate an unqualified field, and when -// it is annotating a struct or exception, it changes all unqualified fields to -// terse fields. Note, the annotation can not be used for union. -type TerseWrite struct { -} - -func NewTerseWrite() *TerseWrite { - return &TerseWrite{} -} - -type TerseWriteBuilder struct { - obj *TerseWrite -} - -func NewTerseWriteBuilder() *TerseWriteBuilder{ - return &TerseWriteBuilder{ - obj: NewTerseWrite(), - } -} - -func (p TerseWriteBuilder) Emit() *TerseWrite{ - return &TerseWrite{ - } -} - -func (p *TerseWrite) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *TerseWrite) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("TerseWrite"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *TerseWrite) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("TerseWrite({})") -} - -// Indicates that an optional field's value should never be stored on the stack, -// i.e. the subobject should be allocated separately (e.g. because it is large and infrequently set). -// -// NOTE: The APIs and initialization behavior are same as normal field, but different from `@cpp.Ref`. e.g. -// -// ``` -// struct Foo { -// 1: optional i32 normal; -// @thrift.Box -// 2: optional i32 boxed; -// @cpp.Ref -// 3: optional i32 referred; -// } -// ``` -// in C++ -// -// ``` -// Foo foo; -// EXPECT_FALSE(foo.normal().has_value()); // okay -// EXPECT_FALSE(foo.boxed().has_value()); // okay -// EXPECT_FALSE(foo.referred().has_value()); // build failure: std::unique_ptr doesn't have has_value method -// -// EXPECT_EQ(*foo.normal(), 0); // throw bad_field_access exception -// EXPECT_EQ(*foo.boxed(), 0); // throw bad_field_access exception -// EXPECT_EQ(*foo.referred(), 0); // okay, field has value by default -// ``` -// -// Affects C++ and Rust. -// TODO: replace with @cpp.Box + @rust.Box -type Box struct { -} - -func NewBox() *Box { - return &Box{} -} - -type BoxBuilder struct { - obj *Box -} - -func NewBoxBuilder() *BoxBuilder{ - return &BoxBuilder{ - obj: NewBox(), - } -} - -func (p BoxBuilder) Emit() *Box{ - return &Box{ - } -} - -func (p *Box) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Box) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Box"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Box) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Box({})") -} - -// Indicates whether the nested fields are accessible directly. -// https://github.com/facebook/fbthrift/blob/v2023.11.20.00/thrift/doc/idl/mixins.md -type Mixin struct { -} - -func NewMixin() *Mixin { - return &Mixin{} -} - -type MixinBuilder struct { - obj *Mixin -} - -func NewMixinBuilder() *MixinBuilder{ - return &MixinBuilder{ - obj: NewMixin(), - } -} - -func (p MixinBuilder) Emit() *Mixin{ - return &Mixin{ - } -} - -func (p *Mixin) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Mixin) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Mixin"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Mixin) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Mixin({})") -} - -// Option to serialize thrift struct in ascending field id order instead of field declaration order. -// -// This can potentially make serialized data size smaller in compact protocol, -// since compact protocol can write deltas between subsequent field ids instead of full ids. -// -// NOTE: This annotation won't reduce payload size for other protocols. -type SerializeInFieldIdOrder struct { -} - -func NewSerializeInFieldIdOrder() *SerializeInFieldIdOrder { - return &SerializeInFieldIdOrder{} -} - -type SerializeInFieldIdOrderBuilder struct { - obj *SerializeInFieldIdOrder -} - -func NewSerializeInFieldIdOrderBuilder() *SerializeInFieldIdOrderBuilder{ - return &SerializeInFieldIdOrderBuilder{ - obj: NewSerializeInFieldIdOrder(), - } -} - -func (p SerializeInFieldIdOrderBuilder) Emit() *SerializeInFieldIdOrder{ - return &SerializeInFieldIdOrder{ - } -} - -func (p *SerializeInFieldIdOrder) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *SerializeInFieldIdOrder) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("SerializeInFieldIdOrder"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *SerializeInFieldIdOrder) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("SerializeInFieldIdOrder({})") -} - -// Indicates an enum is a bitmask and should support bit-wise operators. -// Currently generates additional code in C++ and Hack. -type BitmaskEnum struct { -} - -func NewBitmaskEnum() *BitmaskEnum { - return &BitmaskEnum{} -} - -type BitmaskEnumBuilder struct { - obj *BitmaskEnum -} - -func NewBitmaskEnumBuilder() *BitmaskEnumBuilder{ - return &BitmaskEnumBuilder{ - obj: NewBitmaskEnum(), - } -} - -func (p BitmaskEnumBuilder) Emit() *BitmaskEnum{ - return &BitmaskEnum{ - } -} - -func (p *BitmaskEnum) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *BitmaskEnum) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("BitmaskEnum"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *BitmaskEnum) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("BitmaskEnum({})") -} - -// Specifies the field where the exception message is stored. -type ExceptionMessage struct { -} - -func NewExceptionMessage() *ExceptionMessage { - return &ExceptionMessage{} -} - -type ExceptionMessageBuilder struct { - obj *ExceptionMessage -} - -func NewExceptionMessageBuilder() *ExceptionMessageBuilder{ - return &ExceptionMessageBuilder{ - obj: NewExceptionMessage(), - } -} - -func (p ExceptionMessageBuilder) Emit() *ExceptionMessage{ - return &ExceptionMessage{ - } -} - -func (p *ExceptionMessage) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ExceptionMessage) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("ExceptionMessage"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *ExceptionMessage) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("ExceptionMessage({})") -} - -// Generates a const of type schema. Struct containing the schema of the -// annotated type. Optionally specify name to override default -// schema. -// -// Attributes: -// - Name -type GenerateRuntimeSchema struct { - Name string `thrift:"name,1" db:"name" json:"name"` -} - -func NewGenerateRuntimeSchema() *GenerateRuntimeSchema { - return &GenerateRuntimeSchema{} -} - - -func (p *GenerateRuntimeSchema) GetName() string { - return p.Name -} -type GenerateRuntimeSchemaBuilder struct { - obj *GenerateRuntimeSchema -} - -func NewGenerateRuntimeSchemaBuilder() *GenerateRuntimeSchemaBuilder{ - return &GenerateRuntimeSchemaBuilder{ - obj: NewGenerateRuntimeSchema(), - } -} - -func (p GenerateRuntimeSchemaBuilder) Emit() *GenerateRuntimeSchema{ - return &GenerateRuntimeSchema{ - Name: p.obj.Name, - } -} - -func (g *GenerateRuntimeSchemaBuilder) Name(name string) *GenerateRuntimeSchemaBuilder { - g.obj.Name = name - return g -} - -func (g *GenerateRuntimeSchema) SetName(name string) *GenerateRuntimeSchema { - g.Name = name - return g -} - -func (p *GenerateRuntimeSchema) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *GenerateRuntimeSchema) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Name = v - } - return nil -} - -func (p *GenerateRuntimeSchema) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("GenerateRuntimeSchema"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *GenerateRuntimeSchema) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) } - if err := oprot.WriteString(string(p.Name)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) } - return err -} - -func (p *GenerateRuntimeSchema) String() string { - if p == nil { - return "" - } - - nameVal := fmt.Sprintf("%v", p.Name) - return fmt.Sprintf("GenerateRuntimeSchema({Name:%s})", nameVal) -} - -// Indicates that a field's value should never be stored on the stack, and that -// identical values can be shared in immutable contexts. -type InternBox struct { -} - -func NewInternBox() *InternBox { - return &InternBox{} -} - -type InternBoxBuilder struct { - obj *InternBox -} - -func NewInternBoxBuilder() *InternBoxBuilder{ - return &InternBoxBuilder{ - obj: NewInternBox(), - } -} - -func (p InternBoxBuilder) Emit() *InternBox{ - return &InternBox{ - } -} - -func (p *InternBox) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *InternBox) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("InternBox"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *InternBox) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("InternBox({})") -} - -// Indicates that an interaction's methods should be processed sequentially. -type Serial struct { -} - -func NewSerial() *Serial { - return &Serial{} -} - -type SerialBuilder struct { - obj *Serial -} - -func NewSerialBuilder() *SerialBuilder{ - return &SerialBuilder{ - obj: NewSerial(), - } -} - -func (p SerialBuilder) Emit() *Serial{ - return &Serial{ - } -} - -func (p *Serial) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Serial) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Serial"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Serial) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Serial({})") -} - -// Changes the URI of this definition away from the default-generated one. -// -// Attributes: -// - Value -type Uri struct { - Value string `thrift:"value,1" db:"value" json:"value"` -} - -func NewUri() *Uri { - return &Uri{} -} - - -func (p *Uri) GetValue() string { - return p.Value -} -type UriBuilder struct { - obj *Uri -} - -func NewUriBuilder() *UriBuilder{ - return &UriBuilder{ - obj: NewUri(), - } -} - -func (p UriBuilder) Emit() *Uri{ - return &Uri{ - Value: p.obj.Value, - } -} - -func (u *UriBuilder) Value(value string) *UriBuilder { - u.obj.Value = value - return u -} - -func (u *Uri) SetValue(value string) *Uri { - u.Value = value - return u -} - -func (p *Uri) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Uri) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Value = v - } - return nil -} - -func (p *Uri) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Uri"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Uri) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("value", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:value: ", p), err) } - if err := oprot.WriteString(string(p.Value)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.value (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:value: ", p), err) } - return err -} - -func (p *Uri) String() string { - if p == nil { - return "" - } - - valueVal := fmt.Sprintf("%v", p.Value) - return fmt.Sprintf("Uri({Value:%s})", valueVal) -} - -// Changes the priority of this function (default NORMAL). -// -// Attributes: -// - Level -type Priority struct { - Level RpcPriority `thrift:"level,1" db:"level" json:"level"` -} - -func NewPriority() *Priority { - return &Priority{} -} - - -func (p *Priority) GetLevel() RpcPriority { - return p.Level -} -type PriorityBuilder struct { - obj *Priority -} - -func NewPriorityBuilder() *PriorityBuilder{ - return &PriorityBuilder{ - obj: NewPriority(), - } -} - -func (p PriorityBuilder) Emit() *Priority{ - return &Priority{ - Level: p.obj.Level, - } -} - -func (p *PriorityBuilder) Level(level RpcPriority) *PriorityBuilder { - p.obj.Level = level - return p -} - -func (p *Priority) SetLevel(level RpcPriority) *Priority { - p.Level = level - return p -} - -func (p *Priority) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Priority) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - temp := RpcPriority(v) - p.Level = temp - } - return nil -} - -func (p *Priority) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Priority"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Priority) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("level", thrift.I32, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:level: ", p), err) } - if err := oprot.WriteI32(int32(p.Level)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.level (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:level: ", p), err) } - return err -} - -func (p *Priority) String() string { - if p == nil { - return "" - } - - levelVal := fmt.Sprintf("%v", p.Level) - return fmt.Sprintf("Priority({Level:%s})", levelVal) -} - -// Applies unstructured annotations to a definition. -// -// Attributes: -// - Items -type DeprecatedUnvalidatedAnnotations struct { - Items map[string]string `thrift:"items,1" db:"items" json:"items"` -} - -func NewDeprecatedUnvalidatedAnnotations() *DeprecatedUnvalidatedAnnotations { - return &DeprecatedUnvalidatedAnnotations{} -} - - -func (p *DeprecatedUnvalidatedAnnotations) GetItems() map[string]string { - return p.Items -} -type DeprecatedUnvalidatedAnnotationsBuilder struct { - obj *DeprecatedUnvalidatedAnnotations -} - -func NewDeprecatedUnvalidatedAnnotationsBuilder() *DeprecatedUnvalidatedAnnotationsBuilder{ - return &DeprecatedUnvalidatedAnnotationsBuilder{ - obj: NewDeprecatedUnvalidatedAnnotations(), - } -} - -func (p DeprecatedUnvalidatedAnnotationsBuilder) Emit() *DeprecatedUnvalidatedAnnotations{ - return &DeprecatedUnvalidatedAnnotations{ - Items: p.obj.Items, - } -} - -func (d *DeprecatedUnvalidatedAnnotationsBuilder) Items(items map[string]string) *DeprecatedUnvalidatedAnnotationsBuilder { - d.obj.Items = items - return d -} - -func (d *DeprecatedUnvalidatedAnnotations) SetItems(items map[string]string) *DeprecatedUnvalidatedAnnotations { - d.Items = items - return d -} - -func (p *DeprecatedUnvalidatedAnnotations) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *DeprecatedUnvalidatedAnnotations) ReadField1(iprot thrift.Protocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[string]string, size) - p.Items = tMap - for i := 0; i < size; i ++ { - var _key3 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key3 = v - } - var _val4 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _val4 = v - } - p.Items[_key3] = _val4 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *DeprecatedUnvalidatedAnnotations) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("DeprecatedUnvalidatedAnnotations"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *DeprecatedUnvalidatedAnnotations) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("items", thrift.MAP, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:items: ", p), err) } - if err := oprot.WriteMapBegin(thrift.STRING, thrift.STRING, len(p.Items)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.Items { - if err := oprot.WriteString(string(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := oprot.WriteString(string(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:items: ", p), err) } - return err -} - -func (p *DeprecatedUnvalidatedAnnotations) String() string { - if p == nil { - return "" - } - - itemsVal := fmt.Sprintf("%v", p.Items) - return fmt.Sprintf("DeprecatedUnvalidatedAnnotations({Items:%s})", itemsVal) -} - diff --git a/thrift/compiler/test/fixtures/basic/gen-go/module/constants.go b/thrift/compiler/test/fixtures/basic/gen-go/module/constants.go deleted file mode 100644 index 477cf91a64b..00000000000 --- a/thrift/compiler/test/fixtures/basic/gen-go/module/constants.go +++ /dev/null @@ -1,25 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package module - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - - -func init() { -} - diff --git a/thrift/compiler/test/fixtures/basic/gen-go/module/dbmixedstackarguments.go b/thrift/compiler/test/fixtures/basic/gen-go/module/dbmixedstackarguments.go deleted file mode 100644 index 10809e63b4d..00000000000 --- a/thrift/compiler/test/fixtures/basic/gen-go/module/dbmixedstackarguments.go +++ /dev/null @@ -1,852 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package module - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -type DbMixedStackArguments interface { - // Parameters: - // - Key - GetDataByKey0(key string) (_r []byte, err error) - // Parameters: - // - Key - GetDataByKey1(key string) (_r []byte, err error) -} - -type DbMixedStackArgumentsClientInterface interface { - thrift.ClientInterface - // Parameters: - // - Key - GetDataByKey0(key string) (_r []byte, err error) - // Parameters: - // - Key - GetDataByKey1(key string) (_r []byte, err error) -} - -type DbMixedStackArgumentsClient struct { - DbMixedStackArgumentsClientInterface - CC thrift.ClientConn -} - -func(client *DbMixedStackArgumentsClient) Open() error { - return client.CC.Open() -} - -func(client *DbMixedStackArgumentsClient) Close() error { - return client.CC.Close() -} - -func(client *DbMixedStackArgumentsClient) IsOpen() bool { - return client.CC.IsOpen() -} - -func NewDbMixedStackArgumentsClientFactory(t thrift.Transport, f thrift.ProtocolFactory) *DbMixedStackArgumentsClient { - return &DbMixedStackArgumentsClient{ CC: thrift.NewClientConn(t, f) } -} - -func NewDbMixedStackArgumentsClient(t thrift.Transport, iprot thrift.Protocol, oprot thrift.Protocol) *DbMixedStackArgumentsClient { - return &DbMixedStackArgumentsClient{ CC: thrift.NewClientConnWithProtocols(t, iprot, oprot) } -} - -func NewDbMixedStackArgumentsClientProtocol(prot thrift.Protocol) *DbMixedStackArgumentsClient { - return NewDbMixedStackArgumentsClient(prot.Transport(), prot, prot) -} - -// Parameters: -// - Key -func (p *DbMixedStackArgumentsClient) GetDataByKey0(key string) (_r []byte, err error) { - args := DbMixedStackArgumentsGetDataByKey0Args{ - Key : key, - } - err = p.CC.SendMsg("getDataByKey0", &args, thrift.CALL) - if err != nil { return } - return p.recvGetDataByKey0() -} - - -func (p *DbMixedStackArgumentsClient) recvGetDataByKey0() (value []byte, err error) { - var __result DbMixedStackArgumentsGetDataByKey0Result - err = p.CC.RecvMsg("getDataByKey0", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -// Parameters: -// - Key -func (p *DbMixedStackArgumentsClient) GetDataByKey1(key string) (_r []byte, err error) { - args := DbMixedStackArgumentsGetDataByKey1Args{ - Key : key, - } - err = p.CC.SendMsg("getDataByKey1", &args, thrift.CALL) - if err != nil { return } - return p.recvGetDataByKey1() -} - - -func (p *DbMixedStackArgumentsClient) recvGetDataByKey1() (value []byte, err error) { - var __result DbMixedStackArgumentsGetDataByKey1Result - err = p.CC.RecvMsg("getDataByKey1", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - - -type DbMixedStackArgumentsThreadsafeClient struct { - DbMixedStackArgumentsClientInterface - CC thrift.ClientConn - Mu sync.Mutex -} - -func(client *DbMixedStackArgumentsThreadsafeClient) Open() error { - client.Mu.Lock() - defer client.Mu.Unlock() - return client.CC.Open() -} - -func(client *DbMixedStackArgumentsThreadsafeClient) Close() error { - client.Mu.Lock() - defer client.Mu.Unlock() - return client.CC.Close() -} - -func(client *DbMixedStackArgumentsThreadsafeClient) IsOpen() bool { - client.Mu.Lock() - defer client.Mu.Unlock() - return client.CC.IsOpen() -} - -func NewDbMixedStackArgumentsThreadsafeClientFactory(t thrift.Transport, f thrift.ProtocolFactory) *DbMixedStackArgumentsThreadsafeClient { - return &DbMixedStackArgumentsThreadsafeClient{ CC: thrift.NewClientConn(t, f) } -} - -func NewDbMixedStackArgumentsThreadsafeClient(t thrift.Transport, iprot thrift.Protocol, oprot thrift.Protocol) *DbMixedStackArgumentsThreadsafeClient { - return &DbMixedStackArgumentsThreadsafeClient{ CC: thrift.NewClientConnWithProtocols(t, iprot, oprot) } -} - -func NewDbMixedStackArgumentsThreadsafeClientProtocol(prot thrift.Protocol) *DbMixedStackArgumentsThreadsafeClient { - return NewDbMixedStackArgumentsThreadsafeClient(prot.Transport(), prot, prot) -} - -// Parameters: -// - Key -func (p *DbMixedStackArgumentsThreadsafeClient) GetDataByKey0(key string) (_r []byte, err error) { - p.Mu.Lock() - defer p.Mu.Unlock() - args := DbMixedStackArgumentsGetDataByKey0Args{ - Key : key, - } - err = p.CC.SendMsg("getDataByKey0", &args, thrift.CALL) - if err != nil { return } - return p.recvGetDataByKey0() -} - - -func (p *DbMixedStackArgumentsThreadsafeClient) recvGetDataByKey0() (value []byte, err error) { - var __result DbMixedStackArgumentsGetDataByKey0Result - err = p.CC.RecvMsg("getDataByKey0", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -// Parameters: -// - Key -func (p *DbMixedStackArgumentsThreadsafeClient) GetDataByKey1(key string) (_r []byte, err error) { - p.Mu.Lock() - defer p.Mu.Unlock() - args := DbMixedStackArgumentsGetDataByKey1Args{ - Key : key, - } - err = p.CC.SendMsg("getDataByKey1", &args, thrift.CALL) - if err != nil { return } - return p.recvGetDataByKey1() -} - - -func (p *DbMixedStackArgumentsThreadsafeClient) recvGetDataByKey1() (value []byte, err error) { - var __result DbMixedStackArgumentsGetDataByKey1Result - err = p.CC.RecvMsg("getDataByKey1", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - - -type DbMixedStackArgumentsChannelClient struct { - RequestChannel thrift.RequestChannel -} - -func (c *DbMixedStackArgumentsChannelClient) Close() error { - return c.RequestChannel.Close() -} - -func (c *DbMixedStackArgumentsChannelClient) IsOpen() bool { - return c.RequestChannel.IsOpen() -} - -func (c *DbMixedStackArgumentsChannelClient) Open() error { - return c.RequestChannel.Open() -} - -func NewDbMixedStackArgumentsChannelClient(channel thrift.RequestChannel) *DbMixedStackArgumentsChannelClient { - return &DbMixedStackArgumentsChannelClient{RequestChannel: channel} -} - -// Parameters: -// - Key -func (p *DbMixedStackArgumentsChannelClient) GetDataByKey0(ctx context.Context, key string) (_r []byte, err error) { - args := DbMixedStackArgumentsGetDataByKey0Args{ - Key : key, - } - var __result DbMixedStackArgumentsGetDataByKey0Result - err = p.RequestChannel.Call(ctx, "getDataByKey0", &args, &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -// Parameters: -// - Key -func (p *DbMixedStackArgumentsChannelClient) GetDataByKey1(ctx context.Context, key string) (_r []byte, err error) { - args := DbMixedStackArgumentsGetDataByKey1Args{ - Key : key, - } - var __result DbMixedStackArgumentsGetDataByKey1Result - err = p.RequestChannel.Call(ctx, "getDataByKey1", &args, &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - - -type DbMixedStackArgumentsProcessor struct { - processorMap map[string]thrift.ProcessorFunction - functionServiceMap map[string]string - handler DbMixedStackArguments -} - -func (p *DbMixedStackArgumentsProcessor) AddToProcessorMap(key string, processor thrift.ProcessorFunction) { - p.processorMap[key] = processor -} - -func (p *DbMixedStackArgumentsProcessor) AddToFunctionServiceMap(key, service string) { - p.functionServiceMap[key] = service -} - -func (p *DbMixedStackArgumentsProcessor) GetProcessorFunction(key string) (processor thrift.ProcessorFunction, err error) { - if processor, ok := p.processorMap[key]; ok { - return processor, nil - } - return nil, nil // generic error message will be sent -} - -func (p *DbMixedStackArgumentsProcessor) ProcessorMap() map[string]thrift.ProcessorFunction { - return p.processorMap -} - -func (p *DbMixedStackArgumentsProcessor) FunctionServiceMap() map[string]string { - return p.functionServiceMap -} - -func NewDbMixedStackArgumentsProcessor(handler DbMixedStackArguments) *DbMixedStackArgumentsProcessor { - self9 := &DbMixedStackArgumentsProcessor{handler:handler, processorMap:make(map[string]thrift.ProcessorFunction), functionServiceMap:make(map[string]string)} - self9.processorMap["getDataByKey0"] = &dbMixedStackArgumentsProcessorGetDataByKey0{handler:handler} - self9.processorMap["getDataByKey1"] = &dbMixedStackArgumentsProcessorGetDataByKey1{handler:handler} - self9.functionServiceMap["getDataByKey0"] = "DbMixedStackArguments" - self9.functionServiceMap["getDataByKey1"] = "DbMixedStackArguments" - return self9 -} - -type dbMixedStackArgumentsProcessorGetDataByKey0 struct { - handler DbMixedStackArguments -} - -func (p *DbMixedStackArgumentsGetDataByKey0Result) Exception() thrift.WritableException { - if p == nil { return nil } - return nil -} - -func (p *dbMixedStackArgumentsProcessorGetDataByKey0) Read(iprot thrift.Protocol) (thrift.Struct, thrift.Exception) { - args := DbMixedStackArgumentsGetDataByKey0Args{} - if err := args.Read(iprot); err != nil { - return nil, err - } - iprot.ReadMessageEnd() - return &args, nil -} - -func (p *dbMixedStackArgumentsProcessorGetDataByKey0) Write(seqId int32, result thrift.WritableStruct, oprot thrift.Protocol) (err thrift.Exception) { - var err2 error - messageType := thrift.REPLY - switch result.(type) { - case thrift.ApplicationException: - messageType = thrift.EXCEPTION - } - if err2 = oprot.WriteMessageBegin("getDataByKey0", messageType, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - return err -} - -func (p *dbMixedStackArgumentsProcessorGetDataByKey0) Run(argStruct thrift.Struct) (thrift.WritableStruct, thrift.ApplicationException) { - args := argStruct.(*DbMixedStackArgumentsGetDataByKey0Args) - var __result DbMixedStackArgumentsGetDataByKey0Result - if retval, err := p.handler.GetDataByKey0(args.Key); err != nil { - switch err.(type) { - default: - x := thrift.NewApplicationExceptionCause(thrift.INTERNAL_ERROR, "Internal error processing getDataByKey0: " + err.Error(), err) - return x, x - } - } else { - __result.Success = retval - } - return &__result, nil -} - -type dbMixedStackArgumentsProcessorGetDataByKey1 struct { - handler DbMixedStackArguments -} - -func (p *DbMixedStackArgumentsGetDataByKey1Result) Exception() thrift.WritableException { - if p == nil { return nil } - return nil -} - -func (p *dbMixedStackArgumentsProcessorGetDataByKey1) Read(iprot thrift.Protocol) (thrift.Struct, thrift.Exception) { - args := DbMixedStackArgumentsGetDataByKey1Args{} - if err := args.Read(iprot); err != nil { - return nil, err - } - iprot.ReadMessageEnd() - return &args, nil -} - -func (p *dbMixedStackArgumentsProcessorGetDataByKey1) Write(seqId int32, result thrift.WritableStruct, oprot thrift.Protocol) (err thrift.Exception) { - var err2 error - messageType := thrift.REPLY - switch result.(type) { - case thrift.ApplicationException: - messageType = thrift.EXCEPTION - } - if err2 = oprot.WriteMessageBegin("getDataByKey1", messageType, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - return err -} - -func (p *dbMixedStackArgumentsProcessorGetDataByKey1) Run(argStruct thrift.Struct) (thrift.WritableStruct, thrift.ApplicationException) { - args := argStruct.(*DbMixedStackArgumentsGetDataByKey1Args) - var __result DbMixedStackArgumentsGetDataByKey1Result - if retval, err := p.handler.GetDataByKey1(args.Key); err != nil { - switch err.(type) { - default: - x := thrift.NewApplicationExceptionCause(thrift.INTERNAL_ERROR, "Internal error processing getDataByKey1: " + err.Error(), err) - return x, x - } - } else { - __result.Success = retval - } - return &__result, nil -} - - -// HELPER FUNCTIONS AND STRUCTURES - -// Attributes: -// - Key -type DbMixedStackArgumentsGetDataByKey0Args struct { - thrift.IRequest - Key string `thrift:"key,1" db:"key" json:"key"` -} - -func NewDbMixedStackArgumentsGetDataByKey0Args() *DbMixedStackArgumentsGetDataByKey0Args { - return &DbMixedStackArgumentsGetDataByKey0Args{} -} - - -func (p *DbMixedStackArgumentsGetDataByKey0Args) GetKey() string { - return p.Key -} -type DbMixedStackArgumentsGetDataByKey0ArgsBuilder struct { - obj *DbMixedStackArgumentsGetDataByKey0Args -} - -func NewDbMixedStackArgumentsGetDataByKey0ArgsBuilder() *DbMixedStackArgumentsGetDataByKey0ArgsBuilder{ - return &DbMixedStackArgumentsGetDataByKey0ArgsBuilder{ - obj: NewDbMixedStackArgumentsGetDataByKey0Args(), - } -} - -func (p DbMixedStackArgumentsGetDataByKey0ArgsBuilder) Emit() *DbMixedStackArgumentsGetDataByKey0Args{ - return &DbMixedStackArgumentsGetDataByKey0Args{ - Key: p.obj.Key, - } -} - -func (d *DbMixedStackArgumentsGetDataByKey0ArgsBuilder) Key(key string) *DbMixedStackArgumentsGetDataByKey0ArgsBuilder { - d.obj.Key = key - return d -} - -func (d *DbMixedStackArgumentsGetDataByKey0Args) SetKey(key string) *DbMixedStackArgumentsGetDataByKey0Args { - d.Key = key - return d -} - -func (p *DbMixedStackArgumentsGetDataByKey0Args) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *DbMixedStackArgumentsGetDataByKey0Args) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Key = v - } - return nil -} - -func (p *DbMixedStackArgumentsGetDataByKey0Args) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("getDataByKey0_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *DbMixedStackArgumentsGetDataByKey0Args) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("key", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:key: ", p), err) } - if err := oprot.WriteString(string(p.Key)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.key (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:key: ", p), err) } - return err -} - -func (p *DbMixedStackArgumentsGetDataByKey0Args) String() string { - if p == nil { - return "" - } - - keyVal := fmt.Sprintf("%v", p.Key) - return fmt.Sprintf("DbMixedStackArgumentsGetDataByKey0Args({Key:%s})", keyVal) -} - -// Attributes: -// - Success -type DbMixedStackArgumentsGetDataByKey0Result struct { - thrift.IResponse - Success []byte `thrift:"success,0,optional" db:"success" json:"success,omitempty"` -} - -func NewDbMixedStackArgumentsGetDataByKey0Result() *DbMixedStackArgumentsGetDataByKey0Result { - return &DbMixedStackArgumentsGetDataByKey0Result{} -} - -var DbMixedStackArgumentsGetDataByKey0Result_Success_DEFAULT []byte - -func (p *DbMixedStackArgumentsGetDataByKey0Result) GetSuccess() []byte { - return p.Success -} -func (p *DbMixedStackArgumentsGetDataByKey0Result) IsSetSuccess() bool { - return p != nil && p.Success != nil -} - -type DbMixedStackArgumentsGetDataByKey0ResultBuilder struct { - obj *DbMixedStackArgumentsGetDataByKey0Result -} - -func NewDbMixedStackArgumentsGetDataByKey0ResultBuilder() *DbMixedStackArgumentsGetDataByKey0ResultBuilder{ - return &DbMixedStackArgumentsGetDataByKey0ResultBuilder{ - obj: NewDbMixedStackArgumentsGetDataByKey0Result(), - } -} - -func (p DbMixedStackArgumentsGetDataByKey0ResultBuilder) Emit() *DbMixedStackArgumentsGetDataByKey0Result{ - return &DbMixedStackArgumentsGetDataByKey0Result{ - Success: p.obj.Success, - } -} - -func (d *DbMixedStackArgumentsGetDataByKey0ResultBuilder) Success(success []byte) *DbMixedStackArgumentsGetDataByKey0ResultBuilder { - d.obj.Success = success - return d -} - -func (d *DbMixedStackArgumentsGetDataByKey0Result) SetSuccess(success []byte) *DbMixedStackArgumentsGetDataByKey0Result { - d.Success = success - return d -} - -func (p *DbMixedStackArgumentsGetDataByKey0Result) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 0: - if err := p.ReadField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *DbMixedStackArgumentsGetDataByKey0Result) ReadField0(iprot thrift.Protocol) error { - if v, err := iprot.ReadBinary(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - p.Success = v - } - return nil -} - -func (p *DbMixedStackArgumentsGetDataByKey0Result) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("getDataByKey0_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField0(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *DbMixedStackArgumentsGetDataByKey0Result) writeField0(oprot thrift.Protocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRING, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := oprot.WriteBinary(p.Success); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.success (0) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } - } - return err -} - -func (p *DbMixedStackArgumentsGetDataByKey0Result) String() string { - if p == nil { - return "" - } - - successVal := fmt.Sprintf("%v", p.Success) - return fmt.Sprintf("DbMixedStackArgumentsGetDataByKey0Result({Success:%s})", successVal) -} - -// Attributes: -// - Key -type DbMixedStackArgumentsGetDataByKey1Args struct { - thrift.IRequest - Key string `thrift:"key,1" db:"key" json:"key"` -} - -func NewDbMixedStackArgumentsGetDataByKey1Args() *DbMixedStackArgumentsGetDataByKey1Args { - return &DbMixedStackArgumentsGetDataByKey1Args{} -} - - -func (p *DbMixedStackArgumentsGetDataByKey1Args) GetKey() string { - return p.Key -} -type DbMixedStackArgumentsGetDataByKey1ArgsBuilder struct { - obj *DbMixedStackArgumentsGetDataByKey1Args -} - -func NewDbMixedStackArgumentsGetDataByKey1ArgsBuilder() *DbMixedStackArgumentsGetDataByKey1ArgsBuilder{ - return &DbMixedStackArgumentsGetDataByKey1ArgsBuilder{ - obj: NewDbMixedStackArgumentsGetDataByKey1Args(), - } -} - -func (p DbMixedStackArgumentsGetDataByKey1ArgsBuilder) Emit() *DbMixedStackArgumentsGetDataByKey1Args{ - return &DbMixedStackArgumentsGetDataByKey1Args{ - Key: p.obj.Key, - } -} - -func (d *DbMixedStackArgumentsGetDataByKey1ArgsBuilder) Key(key string) *DbMixedStackArgumentsGetDataByKey1ArgsBuilder { - d.obj.Key = key - return d -} - -func (d *DbMixedStackArgumentsGetDataByKey1Args) SetKey(key string) *DbMixedStackArgumentsGetDataByKey1Args { - d.Key = key - return d -} - -func (p *DbMixedStackArgumentsGetDataByKey1Args) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *DbMixedStackArgumentsGetDataByKey1Args) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Key = v - } - return nil -} - -func (p *DbMixedStackArgumentsGetDataByKey1Args) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("getDataByKey1_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *DbMixedStackArgumentsGetDataByKey1Args) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("key", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:key: ", p), err) } - if err := oprot.WriteString(string(p.Key)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.key (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:key: ", p), err) } - return err -} - -func (p *DbMixedStackArgumentsGetDataByKey1Args) String() string { - if p == nil { - return "" - } - - keyVal := fmt.Sprintf("%v", p.Key) - return fmt.Sprintf("DbMixedStackArgumentsGetDataByKey1Args({Key:%s})", keyVal) -} - -// Attributes: -// - Success -type DbMixedStackArgumentsGetDataByKey1Result struct { - thrift.IResponse - Success []byte `thrift:"success,0,optional" db:"success" json:"success,omitempty"` -} - -func NewDbMixedStackArgumentsGetDataByKey1Result() *DbMixedStackArgumentsGetDataByKey1Result { - return &DbMixedStackArgumentsGetDataByKey1Result{} -} - -var DbMixedStackArgumentsGetDataByKey1Result_Success_DEFAULT []byte - -func (p *DbMixedStackArgumentsGetDataByKey1Result) GetSuccess() []byte { - return p.Success -} -func (p *DbMixedStackArgumentsGetDataByKey1Result) IsSetSuccess() bool { - return p != nil && p.Success != nil -} - -type DbMixedStackArgumentsGetDataByKey1ResultBuilder struct { - obj *DbMixedStackArgumentsGetDataByKey1Result -} - -func NewDbMixedStackArgumentsGetDataByKey1ResultBuilder() *DbMixedStackArgumentsGetDataByKey1ResultBuilder{ - return &DbMixedStackArgumentsGetDataByKey1ResultBuilder{ - obj: NewDbMixedStackArgumentsGetDataByKey1Result(), - } -} - -func (p DbMixedStackArgumentsGetDataByKey1ResultBuilder) Emit() *DbMixedStackArgumentsGetDataByKey1Result{ - return &DbMixedStackArgumentsGetDataByKey1Result{ - Success: p.obj.Success, - } -} - -func (d *DbMixedStackArgumentsGetDataByKey1ResultBuilder) Success(success []byte) *DbMixedStackArgumentsGetDataByKey1ResultBuilder { - d.obj.Success = success - return d -} - -func (d *DbMixedStackArgumentsGetDataByKey1Result) SetSuccess(success []byte) *DbMixedStackArgumentsGetDataByKey1Result { - d.Success = success - return d -} - -func (p *DbMixedStackArgumentsGetDataByKey1Result) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 0: - if err := p.ReadField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *DbMixedStackArgumentsGetDataByKey1Result) ReadField0(iprot thrift.Protocol) error { - if v, err := iprot.ReadBinary(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - p.Success = v - } - return nil -} - -func (p *DbMixedStackArgumentsGetDataByKey1Result) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("getDataByKey1_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField0(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *DbMixedStackArgumentsGetDataByKey1Result) writeField0(oprot thrift.Protocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRING, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := oprot.WriteBinary(p.Success); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.success (0) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } - } - return err -} - -func (p *DbMixedStackArgumentsGetDataByKey1Result) String() string { - if p == nil { - return "" - } - - successVal := fmt.Sprintf("%v", p.Success) - return fmt.Sprintf("DbMixedStackArgumentsGetDataByKey1Result({Success:%s})", successVal) -} - - diff --git a/thrift/compiler/test/fixtures/basic/gen-go/module/fb303service.go b/thrift/compiler/test/fixtures/basic/gen-go/module/fb303service.go deleted file mode 100644 index e91e4e6f83d..00000000000 --- a/thrift/compiler/test/fixtures/basic/gen-go/module/fb303service.go +++ /dev/null @@ -1,516 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package module - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -type FB303Service interface { - // Parameters: - // - IntParameter - SimpleRPC(int_parameter int32) (_r *ReservedKeyword, err error) -} - -type FB303ServiceClientInterface interface { - thrift.ClientInterface - // Parameters: - // - IntParameter - SimpleRPC(int_parameter int32) (_r *ReservedKeyword, err error) -} - -type FB303ServiceClient struct { - FB303ServiceClientInterface - CC thrift.ClientConn -} - -func(client *FB303ServiceClient) Open() error { - return client.CC.Open() -} - -func(client *FB303ServiceClient) Close() error { - return client.CC.Close() -} - -func(client *FB303ServiceClient) IsOpen() bool { - return client.CC.IsOpen() -} - -func NewFB303ServiceClientFactory(t thrift.Transport, f thrift.ProtocolFactory) *FB303ServiceClient { - return &FB303ServiceClient{ CC: thrift.NewClientConn(t, f) } -} - -func NewFB303ServiceClient(t thrift.Transport, iprot thrift.Protocol, oprot thrift.Protocol) *FB303ServiceClient { - return &FB303ServiceClient{ CC: thrift.NewClientConnWithProtocols(t, iprot, oprot) } -} - -func NewFB303ServiceClientProtocol(prot thrift.Protocol) *FB303ServiceClient { - return NewFB303ServiceClient(prot.Transport(), prot, prot) -} - -// Parameters: -// - IntParameter -func (p *FB303ServiceClient) SimpleRPC(int_parameter int32) (_r *ReservedKeyword, err error) { - args := FB303ServiceSimpleRpcArgs{ - IntParameter : int_parameter, - } - err = p.CC.SendMsg("simple_rpc", &args, thrift.CALL) - if err != nil { return } - return p.recvSimpleRPC() -} - - -func (p *FB303ServiceClient) recvSimpleRPC() (value *ReservedKeyword, err error) { - var __result FB303ServiceSimpleRpcResult - err = p.CC.RecvMsg("simple_rpc", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - - -type FB303ServiceThreadsafeClient struct { - FB303ServiceClientInterface - CC thrift.ClientConn - Mu sync.Mutex -} - -func(client *FB303ServiceThreadsafeClient) Open() error { - client.Mu.Lock() - defer client.Mu.Unlock() - return client.CC.Open() -} - -func(client *FB303ServiceThreadsafeClient) Close() error { - client.Mu.Lock() - defer client.Mu.Unlock() - return client.CC.Close() -} - -func(client *FB303ServiceThreadsafeClient) IsOpen() bool { - client.Mu.Lock() - defer client.Mu.Unlock() - return client.CC.IsOpen() -} - -func NewFB303ServiceThreadsafeClientFactory(t thrift.Transport, f thrift.ProtocolFactory) *FB303ServiceThreadsafeClient { - return &FB303ServiceThreadsafeClient{ CC: thrift.NewClientConn(t, f) } -} - -func NewFB303ServiceThreadsafeClient(t thrift.Transport, iprot thrift.Protocol, oprot thrift.Protocol) *FB303ServiceThreadsafeClient { - return &FB303ServiceThreadsafeClient{ CC: thrift.NewClientConnWithProtocols(t, iprot, oprot) } -} - -func NewFB303ServiceThreadsafeClientProtocol(prot thrift.Protocol) *FB303ServiceThreadsafeClient { - return NewFB303ServiceThreadsafeClient(prot.Transport(), prot, prot) -} - -// Parameters: -// - IntParameter -func (p *FB303ServiceThreadsafeClient) SimpleRPC(int_parameter int32) (_r *ReservedKeyword, err error) { - p.Mu.Lock() - defer p.Mu.Unlock() - args := FB303ServiceSimpleRpcArgs{ - IntParameter : int_parameter, - } - err = p.CC.SendMsg("simple_rpc", &args, thrift.CALL) - if err != nil { return } - return p.recvSimpleRPC() -} - - -func (p *FB303ServiceThreadsafeClient) recvSimpleRPC() (value *ReservedKeyword, err error) { - var __result FB303ServiceSimpleRpcResult - err = p.CC.RecvMsg("simple_rpc", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - - -type FB303ServiceChannelClient struct { - RequestChannel thrift.RequestChannel -} - -func (c *FB303ServiceChannelClient) Close() error { - return c.RequestChannel.Close() -} - -func (c *FB303ServiceChannelClient) IsOpen() bool { - return c.RequestChannel.IsOpen() -} - -func (c *FB303ServiceChannelClient) Open() error { - return c.RequestChannel.Open() -} - -func NewFB303ServiceChannelClient(channel thrift.RequestChannel) *FB303ServiceChannelClient { - return &FB303ServiceChannelClient{RequestChannel: channel} -} - -// Parameters: -// - IntParameter -func (p *FB303ServiceChannelClient) SimpleRPC(ctx context.Context, int_parameter int32) (_r *ReservedKeyword, err error) { - args := FB303ServiceSimpleRpcArgs{ - IntParameter : int_parameter, - } - var __result FB303ServiceSimpleRpcResult - err = p.RequestChannel.Call(ctx, "simple_rpc", &args, &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - - -type FB303ServiceProcessor struct { - processorMap map[string]thrift.ProcessorFunction - functionServiceMap map[string]string - handler FB303Service -} - -func (p *FB303ServiceProcessor) AddToProcessorMap(key string, processor thrift.ProcessorFunction) { - p.processorMap[key] = processor -} - -func (p *FB303ServiceProcessor) AddToFunctionServiceMap(key, service string) { - p.functionServiceMap[key] = service -} - -func (p *FB303ServiceProcessor) GetProcessorFunction(key string) (processor thrift.ProcessorFunction, err error) { - if processor, ok := p.processorMap[key]; ok { - return processor, nil - } - return nil, nil // generic error message will be sent -} - -func (p *FB303ServiceProcessor) ProcessorMap() map[string]thrift.ProcessorFunction { - return p.processorMap -} - -func (p *FB303ServiceProcessor) FunctionServiceMap() map[string]string { - return p.functionServiceMap -} - -func NewFB303ServiceProcessor(handler FB303Service) *FB303ServiceProcessor { - self4 := &FB303ServiceProcessor{handler:handler, processorMap:make(map[string]thrift.ProcessorFunction), functionServiceMap:make(map[string]string)} - self4.processorMap["simple_rpc"] = &fB303ServiceProcessorSimpleRPC{handler:handler} - self4.functionServiceMap["simple_rpc"] = "FB303Service" - return self4 -} - -type fB303ServiceProcessorSimpleRPC struct { - handler FB303Service -} - -func (p *FB303ServiceSimpleRpcResult) Exception() thrift.WritableException { - if p == nil { return nil } - return nil -} - -func (p *fB303ServiceProcessorSimpleRPC) Read(iprot thrift.Protocol) (thrift.Struct, thrift.Exception) { - args := FB303ServiceSimpleRpcArgs{} - if err := args.Read(iprot); err != nil { - return nil, err - } - iprot.ReadMessageEnd() - return &args, nil -} - -func (p *fB303ServiceProcessorSimpleRPC) Write(seqId int32, result thrift.WritableStruct, oprot thrift.Protocol) (err thrift.Exception) { - var err2 error - messageType := thrift.REPLY - switch result.(type) { - case thrift.ApplicationException: - messageType = thrift.EXCEPTION - } - if err2 = oprot.WriteMessageBegin("simple_rpc", messageType, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - return err -} - -func (p *fB303ServiceProcessorSimpleRPC) Run(argStruct thrift.Struct) (thrift.WritableStruct, thrift.ApplicationException) { - args := argStruct.(*FB303ServiceSimpleRpcArgs) - var __result FB303ServiceSimpleRpcResult - if retval, err := p.handler.SimpleRPC(args.IntParameter); err != nil { - switch err.(type) { - default: - x := thrift.NewApplicationExceptionCause(thrift.INTERNAL_ERROR, "Internal error processing simple_rpc: " + err.Error(), err) - return x, x - } - } else { - __result.Success = retval - } - return &__result, nil -} - - -// HELPER FUNCTIONS AND STRUCTURES - -// Attributes: -// - IntParameter -type FB303ServiceSimpleRpcArgs struct { - thrift.IRequest - IntParameter int32 `thrift:"int_parameter,1" db:"int_parameter" json:"int_parameter"` -} - -func NewFB303ServiceSimpleRpcArgs() *FB303ServiceSimpleRpcArgs { - return &FB303ServiceSimpleRpcArgs{} -} - - -func (p *FB303ServiceSimpleRpcArgs) GetIntParameter() int32 { - return p.IntParameter -} -type FB303ServiceSimpleRpcArgsBuilder struct { - obj *FB303ServiceSimpleRpcArgs -} - -func NewFB303ServiceSimpleRpcArgsBuilder() *FB303ServiceSimpleRpcArgsBuilder{ - return &FB303ServiceSimpleRpcArgsBuilder{ - obj: NewFB303ServiceSimpleRpcArgs(), - } -} - -func (p FB303ServiceSimpleRpcArgsBuilder) Emit() *FB303ServiceSimpleRpcArgs{ - return &FB303ServiceSimpleRpcArgs{ - IntParameter: p.obj.IntParameter, - } -} - -func (f *FB303ServiceSimpleRpcArgsBuilder) IntParameter(intParameter int32) *FB303ServiceSimpleRpcArgsBuilder { - f.obj.IntParameter = intParameter - return f -} - -func (f *FB303ServiceSimpleRpcArgs) SetIntParameter(intParameter int32) *FB303ServiceSimpleRpcArgs { - f.IntParameter = intParameter - return f -} - -func (p *FB303ServiceSimpleRpcArgs) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *FB303ServiceSimpleRpcArgs) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.IntParameter = v - } - return nil -} - -func (p *FB303ServiceSimpleRpcArgs) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("simple_rpc_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *FB303ServiceSimpleRpcArgs) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("int_parameter", thrift.I32, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:int_parameter: ", p), err) } - if err := oprot.WriteI32(int32(p.IntParameter)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.int_parameter (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:int_parameter: ", p), err) } - return err -} - -func (p *FB303ServiceSimpleRpcArgs) String() string { - if p == nil { - return "" - } - - intParameterVal := fmt.Sprintf("%v", p.IntParameter) - return fmt.Sprintf("FB303ServiceSimpleRpcArgs({IntParameter:%s})", intParameterVal) -} - -// Attributes: -// - Success -type FB303ServiceSimpleRpcResult struct { - thrift.IResponse - Success *ReservedKeyword `thrift:"success,0,optional" db:"success" json:"success,omitempty"` -} - -func NewFB303ServiceSimpleRpcResult() *FB303ServiceSimpleRpcResult { - return &FB303ServiceSimpleRpcResult{} -} - -var FB303ServiceSimpleRpcResult_Success_DEFAULT *ReservedKeyword -func (p *FB303ServiceSimpleRpcResult) GetSuccess() *ReservedKeyword { - if !p.IsSetSuccess() { - return FB303ServiceSimpleRpcResult_Success_DEFAULT - } - return p.Success -} -func (p *FB303ServiceSimpleRpcResult) DefaultGetSuccess() *ReservedKeyword { - if !p.IsSetSuccess() { - return NewReservedKeyword() - } - return p.Success -} -func (p *FB303ServiceSimpleRpcResult) IsSetSuccess() bool { - return p != nil && p.Success != nil -} - -type FB303ServiceSimpleRpcResultBuilder struct { - obj *FB303ServiceSimpleRpcResult -} - -func NewFB303ServiceSimpleRpcResultBuilder() *FB303ServiceSimpleRpcResultBuilder{ - return &FB303ServiceSimpleRpcResultBuilder{ - obj: NewFB303ServiceSimpleRpcResult(), - } -} - -func (p FB303ServiceSimpleRpcResultBuilder) Emit() *FB303ServiceSimpleRpcResult{ - return &FB303ServiceSimpleRpcResult{ - Success: p.obj.Success, - } -} - -func (f *FB303ServiceSimpleRpcResultBuilder) Success(success *ReservedKeyword) *FB303ServiceSimpleRpcResultBuilder { - f.obj.Success = success - return f -} - -func (f *FB303ServiceSimpleRpcResult) SetSuccess(success *ReservedKeyword) *FB303ServiceSimpleRpcResult { - f.Success = success - return f -} - -func (p *FB303ServiceSimpleRpcResult) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 0: - if err := p.ReadField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *FB303ServiceSimpleRpcResult) ReadField0(iprot thrift.Protocol) error { - p.Success = NewReservedKeyword() - if err := p.Success.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) - } - return nil -} - -func (p *FB303ServiceSimpleRpcResult) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("simple_rpc_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField0(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *FB303ServiceSimpleRpcResult) writeField0(oprot thrift.Protocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := p.Success.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } - } - return err -} - -func (p *FB303ServiceSimpleRpcResult) String() string { - if p == nil { - return "" - } - - var successVal string - if p.Success == nil { - successVal = "" - } else { - successVal = fmt.Sprintf("%v", p.Success) - } - return fmt.Sprintf("FB303ServiceSimpleRpcResult({Success:%s})", successVal) -} - - diff --git a/thrift/compiler/test/fixtures/basic/gen-go/module/fooservice.go b/thrift/compiler/test/fixtures/basic/gen-go/module/fooservice.go deleted file mode 100644 index 755e99b0360..00000000000 --- a/thrift/compiler/test/fixtures/basic/gen-go/module/fooservice.go +++ /dev/null @@ -1,380 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package module - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -type FooService interface { - SimpleRPC() (err error) -} - -type FooServiceClientInterface interface { - thrift.ClientInterface - SimpleRPC() (err error) -} - -type FooServiceClient struct { - FooServiceClientInterface - CC thrift.ClientConn -} - -func(client *FooServiceClient) Open() error { - return client.CC.Open() -} - -func(client *FooServiceClient) Close() error { - return client.CC.Close() -} - -func(client *FooServiceClient) IsOpen() bool { - return client.CC.IsOpen() -} - -func NewFooServiceClientFactory(t thrift.Transport, f thrift.ProtocolFactory) *FooServiceClient { - return &FooServiceClient{ CC: thrift.NewClientConn(t, f) } -} - -func NewFooServiceClient(t thrift.Transport, iprot thrift.Protocol, oprot thrift.Protocol) *FooServiceClient { - return &FooServiceClient{ CC: thrift.NewClientConnWithProtocols(t, iprot, oprot) } -} - -func NewFooServiceClientProtocol(prot thrift.Protocol) *FooServiceClient { - return NewFooServiceClient(prot.Transport(), prot, prot) -} - -func (p *FooServiceClient) SimpleRPC() (err error) { - var args FooServiceSimpleRpcArgs - err = p.CC.SendMsg("simple_rpc", &args, thrift.CALL) - if err != nil { return } - return p.recvSimpleRPC() -} - - -func (p *FooServiceClient) recvSimpleRPC() (err error) { - var __result FooServiceSimpleRpcResult - return p.CC.RecvMsg("simple_rpc", &__result) -} - - -type FooServiceThreadsafeClient struct { - FooServiceClientInterface - CC thrift.ClientConn - Mu sync.Mutex -} - -func(client *FooServiceThreadsafeClient) Open() error { - client.Mu.Lock() - defer client.Mu.Unlock() - return client.CC.Open() -} - -func(client *FooServiceThreadsafeClient) Close() error { - client.Mu.Lock() - defer client.Mu.Unlock() - return client.CC.Close() -} - -func(client *FooServiceThreadsafeClient) IsOpen() bool { - client.Mu.Lock() - defer client.Mu.Unlock() - return client.CC.IsOpen() -} - -func NewFooServiceThreadsafeClientFactory(t thrift.Transport, f thrift.ProtocolFactory) *FooServiceThreadsafeClient { - return &FooServiceThreadsafeClient{ CC: thrift.NewClientConn(t, f) } -} - -func NewFooServiceThreadsafeClient(t thrift.Transport, iprot thrift.Protocol, oprot thrift.Protocol) *FooServiceThreadsafeClient { - return &FooServiceThreadsafeClient{ CC: thrift.NewClientConnWithProtocols(t, iprot, oprot) } -} - -func NewFooServiceThreadsafeClientProtocol(prot thrift.Protocol) *FooServiceThreadsafeClient { - return NewFooServiceThreadsafeClient(prot.Transport(), prot, prot) -} - -func (p *FooServiceThreadsafeClient) SimpleRPC() (err error) { - p.Mu.Lock() - defer p.Mu.Unlock() - var args FooServiceSimpleRpcArgs - err = p.CC.SendMsg("simple_rpc", &args, thrift.CALL) - if err != nil { return } - return p.recvSimpleRPC() -} - - -func (p *FooServiceThreadsafeClient) recvSimpleRPC() (err error) { - var __result FooServiceSimpleRpcResult - return p.CC.RecvMsg("simple_rpc", &__result) -} - - -type FooServiceChannelClient struct { - RequestChannel thrift.RequestChannel -} - -func (c *FooServiceChannelClient) Close() error { - return c.RequestChannel.Close() -} - -func (c *FooServiceChannelClient) IsOpen() bool { - return c.RequestChannel.IsOpen() -} - -func (c *FooServiceChannelClient) Open() error { - return c.RequestChannel.Open() -} - -func NewFooServiceChannelClient(channel thrift.RequestChannel) *FooServiceChannelClient { - return &FooServiceChannelClient{RequestChannel: channel} -} - -func (p *FooServiceChannelClient) SimpleRPC(ctx context.Context) (err error) { - args := FooServiceSimpleRpcArgs{ - } - var __result FooServiceSimpleRpcResult - err = p.RequestChannel.Call(ctx, "simple_rpc", &args, &__result) - if err != nil { return } - - return nil -} - - -type FooServiceProcessor struct { - processorMap map[string]thrift.ProcessorFunction - functionServiceMap map[string]string - handler FooService -} - -func (p *FooServiceProcessor) AddToProcessorMap(key string, processor thrift.ProcessorFunction) { - p.processorMap[key] = processor -} - -func (p *FooServiceProcessor) AddToFunctionServiceMap(key, service string) { - p.functionServiceMap[key] = service -} - -func (p *FooServiceProcessor) GetProcessorFunction(key string) (processor thrift.ProcessorFunction, err error) { - if processor, ok := p.processorMap[key]; ok { - return processor, nil - } - return nil, nil // generic error message will be sent -} - -func (p *FooServiceProcessor) ProcessorMap() map[string]thrift.ProcessorFunction { - return p.processorMap -} - -func (p *FooServiceProcessor) FunctionServiceMap() map[string]string { - return p.functionServiceMap -} - -func NewFooServiceProcessor(handler FooService) *FooServiceProcessor { - self2 := &FooServiceProcessor{handler:handler, processorMap:make(map[string]thrift.ProcessorFunction), functionServiceMap:make(map[string]string)} - self2.processorMap["simple_rpc"] = &fooServiceProcessorSimpleRPC{handler:handler} - self2.functionServiceMap["simple_rpc"] = "FooService" - return self2 -} - -type fooServiceProcessorSimpleRPC struct { - handler FooService -} - -func (p *FooServiceSimpleRpcResult) Exception() thrift.WritableException { - if p == nil { return nil } - return nil -} - -func (p *fooServiceProcessorSimpleRPC) Read(iprot thrift.Protocol) (thrift.Struct, thrift.Exception) { - args := FooServiceSimpleRpcArgs{} - if err := args.Read(iprot); err != nil { - return nil, err - } - iprot.ReadMessageEnd() - return &args, nil -} - -func (p *fooServiceProcessorSimpleRPC) Write(seqId int32, result thrift.WritableStruct, oprot thrift.Protocol) (err thrift.Exception) { - var err2 error - messageType := thrift.REPLY - switch result.(type) { - case thrift.ApplicationException: - messageType = thrift.EXCEPTION - } - if err2 = oprot.WriteMessageBegin("simple_rpc", messageType, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - return err -} - -func (p *fooServiceProcessorSimpleRPC) Run(argStruct thrift.Struct) (thrift.WritableStruct, thrift.ApplicationException) { - var __result FooServiceSimpleRpcResult - if err := p.handler.SimpleRPC(); err != nil { - switch err.(type) { - default: - x := thrift.NewApplicationExceptionCause(thrift.INTERNAL_ERROR, "Internal error processing simple_rpc: " + err.Error(), err) - return x, x - } - } - return &__result, nil -} - - -// HELPER FUNCTIONS AND STRUCTURES - -type FooServiceSimpleRpcArgs struct { - thrift.IRequest -} - -func NewFooServiceSimpleRpcArgs() *FooServiceSimpleRpcArgs { - return &FooServiceSimpleRpcArgs{} -} - -type FooServiceSimpleRpcArgsBuilder struct { - obj *FooServiceSimpleRpcArgs -} - -func NewFooServiceSimpleRpcArgsBuilder() *FooServiceSimpleRpcArgsBuilder{ - return &FooServiceSimpleRpcArgsBuilder{ - obj: NewFooServiceSimpleRpcArgs(), - } -} - -func (p FooServiceSimpleRpcArgsBuilder) Emit() *FooServiceSimpleRpcArgs{ - return &FooServiceSimpleRpcArgs{ - } -} - -func (p *FooServiceSimpleRpcArgs) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *FooServiceSimpleRpcArgs) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("simple_rpc_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *FooServiceSimpleRpcArgs) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("FooServiceSimpleRpcArgs({})") -} - -type FooServiceSimpleRpcResult struct { - thrift.IResponse -} - -func NewFooServiceSimpleRpcResult() *FooServiceSimpleRpcResult { - return &FooServiceSimpleRpcResult{} -} - -type FooServiceSimpleRpcResultBuilder struct { - obj *FooServiceSimpleRpcResult -} - -func NewFooServiceSimpleRpcResultBuilder() *FooServiceSimpleRpcResultBuilder{ - return &FooServiceSimpleRpcResultBuilder{ - obj: NewFooServiceSimpleRpcResult(), - } -} - -func (p FooServiceSimpleRpcResultBuilder) Emit() *FooServiceSimpleRpcResult{ - return &FooServiceSimpleRpcResult{ - } -} - -func (p *FooServiceSimpleRpcResult) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *FooServiceSimpleRpcResult) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("simple_rpc_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *FooServiceSimpleRpcResult) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("FooServiceSimpleRpcResult({})") -} - - diff --git a/thrift/compiler/test/fixtures/basic/gen-go/module/myservice.go b/thrift/compiler/test/fixtures/basic/gen-go/module/myservice.go deleted file mode 100644 index 5de88a7a309..00000000000 --- a/thrift/compiler/test/fixtures/basic/gen-go/module/myservice.go +++ /dev/null @@ -1,3094 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package module - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -type MyService interface { - Ping() (err error) - GetRandomData() (_r string, err error) - // Parameters: - // - Sink - Sink(sink int64) (err error) - // Parameters: - // - Id - // - Data - PutDataById(id int64, data string) (err error) - // Parameters: - // - Id - HasDataById(id int64) (_r bool, err error) - // Parameters: - // - Id - GetDataById(id int64) (_r string, err error) - // Parameters: - // - Id - DeleteDataById(id int64) (err error) - // Parameters: - // - Id - // - Data - LobDataById(id int64, data string) (err error) - InvalidReturnForHack() (_r []float32, err error) - RpcSkippedCodegen() (err error) -} - -type MyServiceClientInterface interface { - thrift.ClientInterface - Ping() (err error) - GetRandomData() (_r string, err error) - // Parameters: - // - Sink - Sink(sink int64) (err error) - // Parameters: - // - Id - // - Data - PutDataById(id int64, data string) (err error) - // Parameters: - // - Id - HasDataById(id int64) (_r bool, err error) - // Parameters: - // - Id - GetDataById(id int64) (_r string, err error) - // Parameters: - // - Id - DeleteDataById(id int64) (err error) - // Parameters: - // - Id - // - Data - LobDataById(id int64, data string) (err error) - InvalidReturnForHack() (_r []float32, err error) - RpcSkippedCodegen() (err error) -} - -type MyServiceClient struct { - MyServiceClientInterface - CC thrift.ClientConn -} - -func(client *MyServiceClient) Open() error { - return client.CC.Open() -} - -func(client *MyServiceClient) Close() error { - return client.CC.Close() -} - -func(client *MyServiceClient) IsOpen() bool { - return client.CC.IsOpen() -} - -func NewMyServiceClientFactory(t thrift.Transport, f thrift.ProtocolFactory) *MyServiceClient { - return &MyServiceClient{ CC: thrift.NewClientConn(t, f) } -} - -func NewMyServiceClient(t thrift.Transport, iprot thrift.Protocol, oprot thrift.Protocol) *MyServiceClient { - return &MyServiceClient{ CC: thrift.NewClientConnWithProtocols(t, iprot, oprot) } -} - -func NewMyServiceClientProtocol(prot thrift.Protocol) *MyServiceClient { - return NewMyServiceClient(prot.Transport(), prot, prot) -} - -func (p *MyServiceClient) Ping() (err error) { - var args MyServicePingArgs - err = p.CC.SendMsg("ping", &args, thrift.CALL) - if err != nil { return } - return p.recvPing() -} - - -func (p *MyServiceClient) recvPing() (err error) { - var __result MyServicePingResult - return p.CC.RecvMsg("ping", &__result) -} - -func (p *MyServiceClient) GetRandomData() (_r string, err error) { - var args MyServiceGetRandomDataArgs - err = p.CC.SendMsg("getRandomData", &args, thrift.CALL) - if err != nil { return } - return p.recvGetRandomData() -} - - -func (p *MyServiceClient) recvGetRandomData() (value string, err error) { - var __result MyServiceGetRandomDataResult - err = p.CC.RecvMsg("getRandomData", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -// Parameters: -// - Sink -func (p *MyServiceClient) Sink(sink int64) (err error) { - args := MyServiceSinkArgs{ - Sink : sink, - } - err = p.CC.SendMsg("sink", &args, thrift.CALL) - if err != nil { return } - return p.recvSink() -} - - -func (p *MyServiceClient) recvSink() (err error) { - var __result MyServiceSinkResult - return p.CC.RecvMsg("sink", &__result) -} - -// Parameters: -// - Id -// - Data -func (p *MyServiceClient) PutDataById(id int64, data string) (err error) { - args := MyServicePutDataByIdArgs{ - Id : id, - Data : data, - } - err = p.CC.SendMsg("putDataById", &args, thrift.CALL) - if err != nil { return } - return p.recvPutDataById() -} - - -func (p *MyServiceClient) recvPutDataById() (err error) { - var __result MyServicePutDataByIdResult - return p.CC.RecvMsg("putDataById", &__result) -} - -// Parameters: -// - Id -func (p *MyServiceClient) HasDataById(id int64) (_r bool, err error) { - args := MyServiceHasDataByIdArgs{ - Id : id, - } - err = p.CC.SendMsg("hasDataById", &args, thrift.CALL) - if err != nil { return } - return p.recvHasDataById() -} - - -func (p *MyServiceClient) recvHasDataById() (value bool, err error) { - var __result MyServiceHasDataByIdResult - err = p.CC.RecvMsg("hasDataById", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -// Parameters: -// - Id -func (p *MyServiceClient) GetDataById(id int64) (_r string, err error) { - args := MyServiceGetDataByIdArgs{ - Id : id, - } - err = p.CC.SendMsg("getDataById", &args, thrift.CALL) - if err != nil { return } - return p.recvGetDataById() -} - - -func (p *MyServiceClient) recvGetDataById() (value string, err error) { - var __result MyServiceGetDataByIdResult - err = p.CC.RecvMsg("getDataById", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -// Parameters: -// - Id -func (p *MyServiceClient) DeleteDataById(id int64) (err error) { - args := MyServiceDeleteDataByIdArgs{ - Id : id, - } - err = p.CC.SendMsg("deleteDataById", &args, thrift.CALL) - if err != nil { return } - return p.recvDeleteDataById() -} - - -func (p *MyServiceClient) recvDeleteDataById() (err error) { - var __result MyServiceDeleteDataByIdResult - return p.CC.RecvMsg("deleteDataById", &__result) -} - -// Parameters: -// - Id -// - Data -func (p *MyServiceClient) LobDataById(id int64, data string) (err error) { - args := MyServiceLobDataByIdArgs{ - Id : id, - Data : data, - } - err = p.CC.SendMsg("lobDataById", &args, thrift.ONEWAY) - if err != nil { return } - return -} - -func (p *MyServiceClient) InvalidReturnForHack() (_r []float32, err error) { - var args MyServiceInvalidReturnForHackArgs - err = p.CC.SendMsg("invalid_return_for_hack", &args, thrift.CALL) - if err != nil { return } - return p.recvInvalidReturnForHack() -} - - -func (p *MyServiceClient) recvInvalidReturnForHack() (value []float32, err error) { - var __result MyServiceInvalidReturnForHackResult - err = p.CC.RecvMsg("invalid_return_for_hack", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -func (p *MyServiceClient) RpcSkippedCodegen() (err error) { - var args MyServiceRpcSkippedCodegenArgs - err = p.CC.SendMsg("rpc_skipped_codegen", &args, thrift.CALL) - if err != nil { return } - return p.recvRpcSkippedCodegen() -} - - -func (p *MyServiceClient) recvRpcSkippedCodegen() (err error) { - var __result MyServiceRpcSkippedCodegenResult - return p.CC.RecvMsg("rpc_skipped_codegen", &__result) -} - - -type MyServiceThreadsafeClient struct { - MyServiceClientInterface - CC thrift.ClientConn - Mu sync.Mutex -} - -func(client *MyServiceThreadsafeClient) Open() error { - client.Mu.Lock() - defer client.Mu.Unlock() - return client.CC.Open() -} - -func(client *MyServiceThreadsafeClient) Close() error { - client.Mu.Lock() - defer client.Mu.Unlock() - return client.CC.Close() -} - -func(client *MyServiceThreadsafeClient) IsOpen() bool { - client.Mu.Lock() - defer client.Mu.Unlock() - return client.CC.IsOpen() -} - -func NewMyServiceThreadsafeClientFactory(t thrift.Transport, f thrift.ProtocolFactory) *MyServiceThreadsafeClient { - return &MyServiceThreadsafeClient{ CC: thrift.NewClientConn(t, f) } -} - -func NewMyServiceThreadsafeClient(t thrift.Transport, iprot thrift.Protocol, oprot thrift.Protocol) *MyServiceThreadsafeClient { - return &MyServiceThreadsafeClient{ CC: thrift.NewClientConnWithProtocols(t, iprot, oprot) } -} - -func NewMyServiceThreadsafeClientProtocol(prot thrift.Protocol) *MyServiceThreadsafeClient { - return NewMyServiceThreadsafeClient(prot.Transport(), prot, prot) -} - -func (p *MyServiceThreadsafeClient) Ping() (err error) { - p.Mu.Lock() - defer p.Mu.Unlock() - var args MyServicePingArgs - err = p.CC.SendMsg("ping", &args, thrift.CALL) - if err != nil { return } - return p.recvPing() -} - - -func (p *MyServiceThreadsafeClient) recvPing() (err error) { - var __result MyServicePingResult - return p.CC.RecvMsg("ping", &__result) -} - -func (p *MyServiceThreadsafeClient) GetRandomData() (_r string, err error) { - p.Mu.Lock() - defer p.Mu.Unlock() - var args MyServiceGetRandomDataArgs - err = p.CC.SendMsg("getRandomData", &args, thrift.CALL) - if err != nil { return } - return p.recvGetRandomData() -} - - -func (p *MyServiceThreadsafeClient) recvGetRandomData() (value string, err error) { - var __result MyServiceGetRandomDataResult - err = p.CC.RecvMsg("getRandomData", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -// Parameters: -// - Sink -func (p *MyServiceThreadsafeClient) Sink(sink int64) (err error) { - p.Mu.Lock() - defer p.Mu.Unlock() - args := MyServiceSinkArgs{ - Sink : sink, - } - err = p.CC.SendMsg("sink", &args, thrift.CALL) - if err != nil { return } - return p.recvSink() -} - - -func (p *MyServiceThreadsafeClient) recvSink() (err error) { - var __result MyServiceSinkResult - return p.CC.RecvMsg("sink", &__result) -} - -// Parameters: -// - Id -// - Data -func (p *MyServiceThreadsafeClient) PutDataById(id int64, data string) (err error) { - p.Mu.Lock() - defer p.Mu.Unlock() - args := MyServicePutDataByIdArgs{ - Id : id, - Data : data, - } - err = p.CC.SendMsg("putDataById", &args, thrift.CALL) - if err != nil { return } - return p.recvPutDataById() -} - - -func (p *MyServiceThreadsafeClient) recvPutDataById() (err error) { - var __result MyServicePutDataByIdResult - return p.CC.RecvMsg("putDataById", &__result) -} - -// Parameters: -// - Id -func (p *MyServiceThreadsafeClient) HasDataById(id int64) (_r bool, err error) { - p.Mu.Lock() - defer p.Mu.Unlock() - args := MyServiceHasDataByIdArgs{ - Id : id, - } - err = p.CC.SendMsg("hasDataById", &args, thrift.CALL) - if err != nil { return } - return p.recvHasDataById() -} - - -func (p *MyServiceThreadsafeClient) recvHasDataById() (value bool, err error) { - var __result MyServiceHasDataByIdResult - err = p.CC.RecvMsg("hasDataById", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -// Parameters: -// - Id -func (p *MyServiceThreadsafeClient) GetDataById(id int64) (_r string, err error) { - p.Mu.Lock() - defer p.Mu.Unlock() - args := MyServiceGetDataByIdArgs{ - Id : id, - } - err = p.CC.SendMsg("getDataById", &args, thrift.CALL) - if err != nil { return } - return p.recvGetDataById() -} - - -func (p *MyServiceThreadsafeClient) recvGetDataById() (value string, err error) { - var __result MyServiceGetDataByIdResult - err = p.CC.RecvMsg("getDataById", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -// Parameters: -// - Id -func (p *MyServiceThreadsafeClient) DeleteDataById(id int64) (err error) { - p.Mu.Lock() - defer p.Mu.Unlock() - args := MyServiceDeleteDataByIdArgs{ - Id : id, - } - err = p.CC.SendMsg("deleteDataById", &args, thrift.CALL) - if err != nil { return } - return p.recvDeleteDataById() -} - - -func (p *MyServiceThreadsafeClient) recvDeleteDataById() (err error) { - var __result MyServiceDeleteDataByIdResult - return p.CC.RecvMsg("deleteDataById", &__result) -} - -// Parameters: -// - Id -// - Data -func (p *MyServiceThreadsafeClient) LobDataById(id int64, data string) (err error) { - p.Mu.Lock() - defer p.Mu.Unlock() - args := MyServiceLobDataByIdArgs{ - Id : id, - Data : data, - } - err = p.CC.SendMsg("lobDataById", &args, thrift.ONEWAY) - if err != nil { return } - return -} - -func (p *MyServiceThreadsafeClient) InvalidReturnForHack() (_r []float32, err error) { - p.Mu.Lock() - defer p.Mu.Unlock() - var args MyServiceInvalidReturnForHackArgs - err = p.CC.SendMsg("invalid_return_for_hack", &args, thrift.CALL) - if err != nil { return } - return p.recvInvalidReturnForHack() -} - - -func (p *MyServiceThreadsafeClient) recvInvalidReturnForHack() (value []float32, err error) { - var __result MyServiceInvalidReturnForHackResult - err = p.CC.RecvMsg("invalid_return_for_hack", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -func (p *MyServiceThreadsafeClient) RpcSkippedCodegen() (err error) { - p.Mu.Lock() - defer p.Mu.Unlock() - var args MyServiceRpcSkippedCodegenArgs - err = p.CC.SendMsg("rpc_skipped_codegen", &args, thrift.CALL) - if err != nil { return } - return p.recvRpcSkippedCodegen() -} - - -func (p *MyServiceThreadsafeClient) recvRpcSkippedCodegen() (err error) { - var __result MyServiceRpcSkippedCodegenResult - return p.CC.RecvMsg("rpc_skipped_codegen", &__result) -} - - -type MyServiceChannelClient struct { - RequestChannel thrift.RequestChannel -} - -func (c *MyServiceChannelClient) Close() error { - return c.RequestChannel.Close() -} - -func (c *MyServiceChannelClient) IsOpen() bool { - return c.RequestChannel.IsOpen() -} - -func (c *MyServiceChannelClient) Open() error { - return c.RequestChannel.Open() -} - -func NewMyServiceChannelClient(channel thrift.RequestChannel) *MyServiceChannelClient { - return &MyServiceChannelClient{RequestChannel: channel} -} - -func (p *MyServiceChannelClient) Ping(ctx context.Context) (err error) { - args := MyServicePingArgs{ - } - var __result MyServicePingResult - err = p.RequestChannel.Call(ctx, "ping", &args, &__result) - if err != nil { return } - - return nil -} - -func (p *MyServiceChannelClient) GetRandomData(ctx context.Context) (_r string, err error) { - args := MyServiceGetRandomDataArgs{ - } - var __result MyServiceGetRandomDataResult - err = p.RequestChannel.Call(ctx, "getRandomData", &args, &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -// Parameters: -// - Sink -func (p *MyServiceChannelClient) Sink(ctx context.Context, sink int64) (err error) { - args := MyServiceSinkArgs{ - Sink : sink, - } - var __result MyServiceSinkResult - err = p.RequestChannel.Call(ctx, "sink", &args, &__result) - if err != nil { return } - - return nil -} - -// Parameters: -// - Id -// - Data -func (p *MyServiceChannelClient) PutDataById(ctx context.Context, id int64, data string) (err error) { - args := MyServicePutDataByIdArgs{ - Id : id, - Data : data, - } - var __result MyServicePutDataByIdResult - err = p.RequestChannel.Call(ctx, "putDataById", &args, &__result) - if err != nil { return } - - return nil -} - -// Parameters: -// - Id -func (p *MyServiceChannelClient) HasDataById(ctx context.Context, id int64) (_r bool, err error) { - args := MyServiceHasDataByIdArgs{ - Id : id, - } - var __result MyServiceHasDataByIdResult - err = p.RequestChannel.Call(ctx, "hasDataById", &args, &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -// Parameters: -// - Id -func (p *MyServiceChannelClient) GetDataById(ctx context.Context, id int64) (_r string, err error) { - args := MyServiceGetDataByIdArgs{ - Id : id, - } - var __result MyServiceGetDataByIdResult - err = p.RequestChannel.Call(ctx, "getDataById", &args, &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -// Parameters: -// - Id -func (p *MyServiceChannelClient) DeleteDataById(ctx context.Context, id int64) (err error) { - args := MyServiceDeleteDataByIdArgs{ - Id : id, - } - var __result MyServiceDeleteDataByIdResult - err = p.RequestChannel.Call(ctx, "deleteDataById", &args, &__result) - if err != nil { return } - - return nil -} - -// Parameters: -// - Id -// - Data -func (p *MyServiceChannelClient) LobDataById(ctx context.Context, id int64, data string) (err error) { - args := MyServiceLobDataByIdArgs{ - Id : id, - Data : data, - } - err = p.RequestChannel.Oneway(ctx, "lobDataById", &args) - if err != nil { return } - - return nil -} - -func (p *MyServiceChannelClient) InvalidReturnForHack(ctx context.Context) (_r []float32, err error) { - args := MyServiceInvalidReturnForHackArgs{ - } - var __result MyServiceInvalidReturnForHackResult - err = p.RequestChannel.Call(ctx, "invalid_return_for_hack", &args, &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -func (p *MyServiceChannelClient) RpcSkippedCodegen(ctx context.Context) (err error) { - args := MyServiceRpcSkippedCodegenArgs{ - } - var __result MyServiceRpcSkippedCodegenResult - err = p.RequestChannel.Call(ctx, "rpc_skipped_codegen", &args, &__result) - if err != nil { return } - - return nil -} - - -type MyServiceProcessor struct { - processorMap map[string]thrift.ProcessorFunction - functionServiceMap map[string]string - handler MyService -} - -func (p *MyServiceProcessor) AddToProcessorMap(key string, processor thrift.ProcessorFunction) { - p.processorMap[key] = processor -} - -func (p *MyServiceProcessor) AddToFunctionServiceMap(key, service string) { - p.functionServiceMap[key] = service -} - -func (p *MyServiceProcessor) GetProcessorFunction(key string) (processor thrift.ProcessorFunction, err error) { - if processor, ok := p.processorMap[key]; ok { - return processor, nil - } - return nil, nil // generic error message will be sent -} - -func (p *MyServiceProcessor) ProcessorMap() map[string]thrift.ProcessorFunction { - return p.processorMap -} - -func (p *MyServiceProcessor) FunctionServiceMap() map[string]string { - return p.functionServiceMap -} - -func NewMyServiceProcessor(handler MyService) *MyServiceProcessor { - self6 := &MyServiceProcessor{handler:handler, processorMap:make(map[string]thrift.ProcessorFunction), functionServiceMap:make(map[string]string)} - self6.processorMap["ping"] = &myServiceProcessorPing{handler:handler} - self6.processorMap["getRandomData"] = &myServiceProcessorGetRandomData{handler:handler} - self6.processorMap["sink"] = &myServiceProcessorSink{handler:handler} - self6.processorMap["putDataById"] = &myServiceProcessorPutDataById{handler:handler} - self6.processorMap["hasDataById"] = &myServiceProcessorHasDataById{handler:handler} - self6.processorMap["getDataById"] = &myServiceProcessorGetDataById{handler:handler} - self6.processorMap["deleteDataById"] = &myServiceProcessorDeleteDataById{handler:handler} - self6.processorMap["lobDataById"] = &myServiceProcessorLobDataById{handler:handler} - self6.processorMap["invalid_return_for_hack"] = &myServiceProcessorInvalidReturnForHack{handler:handler} - self6.processorMap["rpc_skipped_codegen"] = &myServiceProcessorRpcSkippedCodegen{handler:handler} - self6.functionServiceMap["ping"] = "MyService" - self6.functionServiceMap["getRandomData"] = "MyService" - self6.functionServiceMap["sink"] = "MyService" - self6.functionServiceMap["putDataById"] = "MyService" - self6.functionServiceMap["hasDataById"] = "MyService" - self6.functionServiceMap["getDataById"] = "MyService" - self6.functionServiceMap["deleteDataById"] = "MyService" - self6.functionServiceMap["lobDataById"] = "MyService" - self6.functionServiceMap["invalid_return_for_hack"] = "MyService" - self6.functionServiceMap["rpc_skipped_codegen"] = "MyService" - return self6 -} - -type myServiceProcessorPing struct { - handler MyService -} - -func (p *MyServicePingResult) Exception() thrift.WritableException { - if p == nil { return nil } - return nil -} - -func (p *myServiceProcessorPing) Read(iprot thrift.Protocol) (thrift.Struct, thrift.Exception) { - args := MyServicePingArgs{} - if err := args.Read(iprot); err != nil { - return nil, err - } - iprot.ReadMessageEnd() - return &args, nil -} - -func (p *myServiceProcessorPing) Write(seqId int32, result thrift.WritableStruct, oprot thrift.Protocol) (err thrift.Exception) { - var err2 error - messageType := thrift.REPLY - switch result.(type) { - case thrift.ApplicationException: - messageType = thrift.EXCEPTION - } - if err2 = oprot.WriteMessageBegin("ping", messageType, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - return err -} - -func (p *myServiceProcessorPing) Run(argStruct thrift.Struct) (thrift.WritableStruct, thrift.ApplicationException) { - var __result MyServicePingResult - if err := p.handler.Ping(); err != nil { - switch err.(type) { - default: - x := thrift.NewApplicationExceptionCause(thrift.INTERNAL_ERROR, "Internal error processing ping: " + err.Error(), err) - return x, x - } - } - return &__result, nil -} - -type myServiceProcessorGetRandomData struct { - handler MyService -} - -func (p *MyServiceGetRandomDataResult) Exception() thrift.WritableException { - if p == nil { return nil } - return nil -} - -func (p *myServiceProcessorGetRandomData) Read(iprot thrift.Protocol) (thrift.Struct, thrift.Exception) { - args := MyServiceGetRandomDataArgs{} - if err := args.Read(iprot); err != nil { - return nil, err - } - iprot.ReadMessageEnd() - return &args, nil -} - -func (p *myServiceProcessorGetRandomData) Write(seqId int32, result thrift.WritableStruct, oprot thrift.Protocol) (err thrift.Exception) { - var err2 error - messageType := thrift.REPLY - switch result.(type) { - case thrift.ApplicationException: - messageType = thrift.EXCEPTION - } - if err2 = oprot.WriteMessageBegin("getRandomData", messageType, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - return err -} - -func (p *myServiceProcessorGetRandomData) Run(argStruct thrift.Struct) (thrift.WritableStruct, thrift.ApplicationException) { - var __result MyServiceGetRandomDataResult - if retval, err := p.handler.GetRandomData(); err != nil { - switch err.(type) { - default: - x := thrift.NewApplicationExceptionCause(thrift.INTERNAL_ERROR, "Internal error processing getRandomData: " + err.Error(), err) - return x, x - } - } else { - __result.Success = &retval - } - return &__result, nil -} - -type myServiceProcessorSink struct { - handler MyService -} - -func (p *MyServiceSinkResult) Exception() thrift.WritableException { - if p == nil { return nil } - return nil -} - -func (p *myServiceProcessorSink) Read(iprot thrift.Protocol) (thrift.Struct, thrift.Exception) { - args := MyServiceSinkArgs{} - if err := args.Read(iprot); err != nil { - return nil, err - } - iprot.ReadMessageEnd() - return &args, nil -} - -func (p *myServiceProcessorSink) Write(seqId int32, result thrift.WritableStruct, oprot thrift.Protocol) (err thrift.Exception) { - var err2 error - messageType := thrift.REPLY - switch result.(type) { - case thrift.ApplicationException: - messageType = thrift.EXCEPTION - } - if err2 = oprot.WriteMessageBegin("sink", messageType, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - return err -} - -func (p *myServiceProcessorSink) Run(argStruct thrift.Struct) (thrift.WritableStruct, thrift.ApplicationException) { - args := argStruct.(*MyServiceSinkArgs) - var __result MyServiceSinkResult - if err := p.handler.Sink(args.Sink); err != nil { - switch err.(type) { - default: - x := thrift.NewApplicationExceptionCause(thrift.INTERNAL_ERROR, "Internal error processing sink: " + err.Error(), err) - return x, x - } - } - return &__result, nil -} - -type myServiceProcessorPutDataById struct { - handler MyService -} - -func (p *MyServicePutDataByIdResult) Exception() thrift.WritableException { - if p == nil { return nil } - return nil -} - -func (p *myServiceProcessorPutDataById) Read(iprot thrift.Protocol) (thrift.Struct, thrift.Exception) { - args := MyServicePutDataByIdArgs{} - if err := args.Read(iprot); err != nil { - return nil, err - } - iprot.ReadMessageEnd() - return &args, nil -} - -func (p *myServiceProcessorPutDataById) Write(seqId int32, result thrift.WritableStruct, oprot thrift.Protocol) (err thrift.Exception) { - var err2 error - messageType := thrift.REPLY - switch result.(type) { - case thrift.ApplicationException: - messageType = thrift.EXCEPTION - } - if err2 = oprot.WriteMessageBegin("putDataById", messageType, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - return err -} - -func (p *myServiceProcessorPutDataById) Run(argStruct thrift.Struct) (thrift.WritableStruct, thrift.ApplicationException) { - args := argStruct.(*MyServicePutDataByIdArgs) - var __result MyServicePutDataByIdResult - if err := p.handler.PutDataById(args.Id, args.Data); err != nil { - switch err.(type) { - default: - x := thrift.NewApplicationExceptionCause(thrift.INTERNAL_ERROR, "Internal error processing putDataById: " + err.Error(), err) - return x, x - } - } - return &__result, nil -} - -type myServiceProcessorHasDataById struct { - handler MyService -} - -func (p *MyServiceHasDataByIdResult) Exception() thrift.WritableException { - if p == nil { return nil } - return nil -} - -func (p *myServiceProcessorHasDataById) Read(iprot thrift.Protocol) (thrift.Struct, thrift.Exception) { - args := MyServiceHasDataByIdArgs{} - if err := args.Read(iprot); err != nil { - return nil, err - } - iprot.ReadMessageEnd() - return &args, nil -} - -func (p *myServiceProcessorHasDataById) Write(seqId int32, result thrift.WritableStruct, oprot thrift.Protocol) (err thrift.Exception) { - var err2 error - messageType := thrift.REPLY - switch result.(type) { - case thrift.ApplicationException: - messageType = thrift.EXCEPTION - } - if err2 = oprot.WriteMessageBegin("hasDataById", messageType, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - return err -} - -func (p *myServiceProcessorHasDataById) Run(argStruct thrift.Struct) (thrift.WritableStruct, thrift.ApplicationException) { - args := argStruct.(*MyServiceHasDataByIdArgs) - var __result MyServiceHasDataByIdResult - if retval, err := p.handler.HasDataById(args.Id); err != nil { - switch err.(type) { - default: - x := thrift.NewApplicationExceptionCause(thrift.INTERNAL_ERROR, "Internal error processing hasDataById: " + err.Error(), err) - return x, x - } - } else { - __result.Success = &retval - } - return &__result, nil -} - -type myServiceProcessorGetDataById struct { - handler MyService -} - -func (p *MyServiceGetDataByIdResult) Exception() thrift.WritableException { - if p == nil { return nil } - return nil -} - -func (p *myServiceProcessorGetDataById) Read(iprot thrift.Protocol) (thrift.Struct, thrift.Exception) { - args := MyServiceGetDataByIdArgs{} - if err := args.Read(iprot); err != nil { - return nil, err - } - iprot.ReadMessageEnd() - return &args, nil -} - -func (p *myServiceProcessorGetDataById) Write(seqId int32, result thrift.WritableStruct, oprot thrift.Protocol) (err thrift.Exception) { - var err2 error - messageType := thrift.REPLY - switch result.(type) { - case thrift.ApplicationException: - messageType = thrift.EXCEPTION - } - if err2 = oprot.WriteMessageBegin("getDataById", messageType, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - return err -} - -func (p *myServiceProcessorGetDataById) Run(argStruct thrift.Struct) (thrift.WritableStruct, thrift.ApplicationException) { - args := argStruct.(*MyServiceGetDataByIdArgs) - var __result MyServiceGetDataByIdResult - if retval, err := p.handler.GetDataById(args.Id); err != nil { - switch err.(type) { - default: - x := thrift.NewApplicationExceptionCause(thrift.INTERNAL_ERROR, "Internal error processing getDataById: " + err.Error(), err) - return x, x - } - } else { - __result.Success = &retval - } - return &__result, nil -} - -type myServiceProcessorDeleteDataById struct { - handler MyService -} - -func (p *MyServiceDeleteDataByIdResult) Exception() thrift.WritableException { - if p == nil { return nil } - return nil -} - -func (p *myServiceProcessorDeleteDataById) Read(iprot thrift.Protocol) (thrift.Struct, thrift.Exception) { - args := MyServiceDeleteDataByIdArgs{} - if err := args.Read(iprot); err != nil { - return nil, err - } - iprot.ReadMessageEnd() - return &args, nil -} - -func (p *myServiceProcessorDeleteDataById) Write(seqId int32, result thrift.WritableStruct, oprot thrift.Protocol) (err thrift.Exception) { - var err2 error - messageType := thrift.REPLY - switch result.(type) { - case thrift.ApplicationException: - messageType = thrift.EXCEPTION - } - if err2 = oprot.WriteMessageBegin("deleteDataById", messageType, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - return err -} - -func (p *myServiceProcessorDeleteDataById) Run(argStruct thrift.Struct) (thrift.WritableStruct, thrift.ApplicationException) { - args := argStruct.(*MyServiceDeleteDataByIdArgs) - var __result MyServiceDeleteDataByIdResult - if err := p.handler.DeleteDataById(args.Id); err != nil { - switch err.(type) { - default: - x := thrift.NewApplicationExceptionCause(thrift.INTERNAL_ERROR, "Internal error processing deleteDataById: " + err.Error(), err) - return x, x - } - } - return &__result, nil -} - -type myServiceProcessorLobDataById struct { - handler MyService -} - -func (p *myServiceProcessorLobDataById) Read(iprot thrift.Protocol) (thrift.Struct, thrift.Exception) { - args := MyServiceLobDataByIdArgs{} - if err := args.Read(iprot); err != nil { - return nil, err - } - iprot.ReadMessageEnd() - return &args, nil -} - -func (p *myServiceProcessorLobDataById) Write(seqId int32, result thrift.WritableStruct, oprot thrift.Protocol) (err thrift.Exception) { - var err2 error - messageType := thrift.REPLY - switch result.(type) { - case thrift.ApplicationException: - messageType = thrift.EXCEPTION - } - if err2 = oprot.WriteMessageBegin("lobDataById", messageType, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - return err -} - -func (p *myServiceProcessorLobDataById) Run(argStruct thrift.Struct) (thrift.WritableStruct, thrift.ApplicationException) { - args := argStruct.(*MyServiceLobDataByIdArgs) - if err := p.handler.LobDataById(args.Id, args.Data); err != nil { - switch err.(type) { - default: - x := thrift.NewApplicationExceptionCause(thrift.INTERNAL_ERROR, "Internal error processing lobDataById: " + err.Error(), err) - return x, x - } - } - return nil, nil -} - -type myServiceProcessorInvalidReturnForHack struct { - handler MyService -} - -func (p *MyServiceInvalidReturnForHackResult) Exception() thrift.WritableException { - if p == nil { return nil } - return nil -} - -func (p *myServiceProcessorInvalidReturnForHack) Read(iprot thrift.Protocol) (thrift.Struct, thrift.Exception) { - args := MyServiceInvalidReturnForHackArgs{} - if err := args.Read(iprot); err != nil { - return nil, err - } - iprot.ReadMessageEnd() - return &args, nil -} - -func (p *myServiceProcessorInvalidReturnForHack) Write(seqId int32, result thrift.WritableStruct, oprot thrift.Protocol) (err thrift.Exception) { - var err2 error - messageType := thrift.REPLY - switch result.(type) { - case thrift.ApplicationException: - messageType = thrift.EXCEPTION - } - if err2 = oprot.WriteMessageBegin("invalid_return_for_hack", messageType, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - return err -} - -func (p *myServiceProcessorInvalidReturnForHack) Run(argStruct thrift.Struct) (thrift.WritableStruct, thrift.ApplicationException) { - var __result MyServiceInvalidReturnForHackResult - if retval, err := p.handler.InvalidReturnForHack(); err != nil { - switch err.(type) { - default: - x := thrift.NewApplicationExceptionCause(thrift.INTERNAL_ERROR, "Internal error processing invalid_return_for_hack: " + err.Error(), err) - return x, x - } - } else { - __result.Success = retval - } - return &__result, nil -} - -type myServiceProcessorRpcSkippedCodegen struct { - handler MyService -} - -func (p *MyServiceRpcSkippedCodegenResult) Exception() thrift.WritableException { - if p == nil { return nil } - return nil -} - -func (p *myServiceProcessorRpcSkippedCodegen) Read(iprot thrift.Protocol) (thrift.Struct, thrift.Exception) { - args := MyServiceRpcSkippedCodegenArgs{} - if err := args.Read(iprot); err != nil { - return nil, err - } - iprot.ReadMessageEnd() - return &args, nil -} - -func (p *myServiceProcessorRpcSkippedCodegen) Write(seqId int32, result thrift.WritableStruct, oprot thrift.Protocol) (err thrift.Exception) { - var err2 error - messageType := thrift.REPLY - switch result.(type) { - case thrift.ApplicationException: - messageType = thrift.EXCEPTION - } - if err2 = oprot.WriteMessageBegin("rpc_skipped_codegen", messageType, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - return err -} - -func (p *myServiceProcessorRpcSkippedCodegen) Run(argStruct thrift.Struct) (thrift.WritableStruct, thrift.ApplicationException) { - var __result MyServiceRpcSkippedCodegenResult - if err := p.handler.RpcSkippedCodegen(); err != nil { - switch err.(type) { - default: - x := thrift.NewApplicationExceptionCause(thrift.INTERNAL_ERROR, "Internal error processing rpc_skipped_codegen: " + err.Error(), err) - return x, x - } - } - return &__result, nil -} - - -// HELPER FUNCTIONS AND STRUCTURES - -type MyServicePingArgs struct { - thrift.IRequest -} - -func NewMyServicePingArgs() *MyServicePingArgs { - return &MyServicePingArgs{} -} - -type MyServicePingArgsBuilder struct { - obj *MyServicePingArgs -} - -func NewMyServicePingArgsBuilder() *MyServicePingArgsBuilder{ - return &MyServicePingArgsBuilder{ - obj: NewMyServicePingArgs(), - } -} - -func (p MyServicePingArgsBuilder) Emit() *MyServicePingArgs{ - return &MyServicePingArgs{ - } -} - -func (p *MyServicePingArgs) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyServicePingArgs) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("ping_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyServicePingArgs) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("MyServicePingArgs({})") -} - -type MyServicePingResult struct { - thrift.IResponse -} - -func NewMyServicePingResult() *MyServicePingResult { - return &MyServicePingResult{} -} - -type MyServicePingResultBuilder struct { - obj *MyServicePingResult -} - -func NewMyServicePingResultBuilder() *MyServicePingResultBuilder{ - return &MyServicePingResultBuilder{ - obj: NewMyServicePingResult(), - } -} - -func (p MyServicePingResultBuilder) Emit() *MyServicePingResult{ - return &MyServicePingResult{ - } -} - -func (p *MyServicePingResult) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyServicePingResult) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("ping_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyServicePingResult) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("MyServicePingResult({})") -} - -type MyServiceGetRandomDataArgs struct { - thrift.IRequest -} - -func NewMyServiceGetRandomDataArgs() *MyServiceGetRandomDataArgs { - return &MyServiceGetRandomDataArgs{} -} - -type MyServiceGetRandomDataArgsBuilder struct { - obj *MyServiceGetRandomDataArgs -} - -func NewMyServiceGetRandomDataArgsBuilder() *MyServiceGetRandomDataArgsBuilder{ - return &MyServiceGetRandomDataArgsBuilder{ - obj: NewMyServiceGetRandomDataArgs(), - } -} - -func (p MyServiceGetRandomDataArgsBuilder) Emit() *MyServiceGetRandomDataArgs{ - return &MyServiceGetRandomDataArgs{ - } -} - -func (p *MyServiceGetRandomDataArgs) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyServiceGetRandomDataArgs) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("getRandomData_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyServiceGetRandomDataArgs) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("MyServiceGetRandomDataArgs({})") -} - -// Attributes: -// - Success -type MyServiceGetRandomDataResult struct { - thrift.IResponse - Success *string `thrift:"success,0,optional" db:"success" json:"success,omitempty"` -} - -func NewMyServiceGetRandomDataResult() *MyServiceGetRandomDataResult { - return &MyServiceGetRandomDataResult{} -} - -var MyServiceGetRandomDataResult_Success_DEFAULT string -func (p *MyServiceGetRandomDataResult) GetSuccess() string { - if !p.IsSetSuccess() { - return MyServiceGetRandomDataResult_Success_DEFAULT - } - return *p.Success -} -func (p *MyServiceGetRandomDataResult) IsSetSuccess() bool { - return p != nil && p.Success != nil -} - -type MyServiceGetRandomDataResultBuilder struct { - obj *MyServiceGetRandomDataResult -} - -func NewMyServiceGetRandomDataResultBuilder() *MyServiceGetRandomDataResultBuilder{ - return &MyServiceGetRandomDataResultBuilder{ - obj: NewMyServiceGetRandomDataResult(), - } -} - -func (p MyServiceGetRandomDataResultBuilder) Emit() *MyServiceGetRandomDataResult{ - return &MyServiceGetRandomDataResult{ - Success: p.obj.Success, - } -} - -func (m *MyServiceGetRandomDataResultBuilder) Success(success *string) *MyServiceGetRandomDataResultBuilder { - m.obj.Success = success - return m -} - -func (m *MyServiceGetRandomDataResult) SetSuccess(success *string) *MyServiceGetRandomDataResult { - m.Success = success - return m -} - -func (p *MyServiceGetRandomDataResult) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 0: - if err := p.ReadField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyServiceGetRandomDataResult) ReadField0(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - p.Success = &v - } - return nil -} - -func (p *MyServiceGetRandomDataResult) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("getRandomData_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField0(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyServiceGetRandomDataResult) writeField0(oprot thrift.Protocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRING, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := oprot.WriteString(string(*p.Success)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.success (0) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } - } - return err -} - -func (p *MyServiceGetRandomDataResult) String() string { - if p == nil { - return "" - } - - var successVal string - if p.Success == nil { - successVal = "" - } else { - successVal = fmt.Sprintf("%v", *p.Success) - } - return fmt.Sprintf("MyServiceGetRandomDataResult({Success:%s})", successVal) -} - -// Attributes: -// - Sink -type MyServiceSinkArgs struct { - thrift.IRequest - Sink int64 `thrift:"sink,1" db:"sink" json:"sink"` -} - -func NewMyServiceSinkArgs() *MyServiceSinkArgs { - return &MyServiceSinkArgs{} -} - - -func (p *MyServiceSinkArgs) GetSink() int64 { - return p.Sink -} -type MyServiceSinkArgsBuilder struct { - obj *MyServiceSinkArgs -} - -func NewMyServiceSinkArgsBuilder() *MyServiceSinkArgsBuilder{ - return &MyServiceSinkArgsBuilder{ - obj: NewMyServiceSinkArgs(), - } -} - -func (p MyServiceSinkArgsBuilder) Emit() *MyServiceSinkArgs{ - return &MyServiceSinkArgs{ - Sink: p.obj.Sink, - } -} - -func (m *MyServiceSinkArgsBuilder) Sink(sink int64) *MyServiceSinkArgsBuilder { - m.obj.Sink = sink - return m -} - -func (m *MyServiceSinkArgs) SetSink(sink int64) *MyServiceSinkArgs { - m.Sink = sink - return m -} - -func (p *MyServiceSinkArgs) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyServiceSinkArgs) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Sink = v - } - return nil -} - -func (p *MyServiceSinkArgs) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("sink_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyServiceSinkArgs) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("sink", thrift.I64, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:sink: ", p), err) } - if err := oprot.WriteI64(int64(p.Sink)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.sink (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:sink: ", p), err) } - return err -} - -func (p *MyServiceSinkArgs) String() string { - if p == nil { - return "" - } - - sinkVal := fmt.Sprintf("%v", p.Sink) - return fmt.Sprintf("MyServiceSinkArgs({Sink:%s})", sinkVal) -} - -type MyServiceSinkResult struct { - thrift.IResponse -} - -func NewMyServiceSinkResult() *MyServiceSinkResult { - return &MyServiceSinkResult{} -} - -type MyServiceSinkResultBuilder struct { - obj *MyServiceSinkResult -} - -func NewMyServiceSinkResultBuilder() *MyServiceSinkResultBuilder{ - return &MyServiceSinkResultBuilder{ - obj: NewMyServiceSinkResult(), - } -} - -func (p MyServiceSinkResultBuilder) Emit() *MyServiceSinkResult{ - return &MyServiceSinkResult{ - } -} - -func (p *MyServiceSinkResult) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyServiceSinkResult) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("sink_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyServiceSinkResult) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("MyServiceSinkResult({})") -} - -// Attributes: -// - Id -// - Data -type MyServicePutDataByIdArgs struct { - thrift.IRequest - Id int64 `thrift:"id,1" db:"id" json:"id"` - Data string `thrift:"data,2" db:"data" json:"data"` -} - -func NewMyServicePutDataByIdArgs() *MyServicePutDataByIdArgs { - return &MyServicePutDataByIdArgs{} -} - - -func (p *MyServicePutDataByIdArgs) GetId() int64 { - return p.Id -} - -func (p *MyServicePutDataByIdArgs) GetData() string { - return p.Data -} -type MyServicePutDataByIdArgsBuilder struct { - obj *MyServicePutDataByIdArgs -} - -func NewMyServicePutDataByIdArgsBuilder() *MyServicePutDataByIdArgsBuilder{ - return &MyServicePutDataByIdArgsBuilder{ - obj: NewMyServicePutDataByIdArgs(), - } -} - -func (p MyServicePutDataByIdArgsBuilder) Emit() *MyServicePutDataByIdArgs{ - return &MyServicePutDataByIdArgs{ - Id: p.obj.Id, - Data: p.obj.Data, - } -} - -func (m *MyServicePutDataByIdArgsBuilder) Id(id int64) *MyServicePutDataByIdArgsBuilder { - m.obj.Id = id - return m -} - -func (m *MyServicePutDataByIdArgsBuilder) Data(data string) *MyServicePutDataByIdArgsBuilder { - m.obj.Data = data - return m -} - -func (m *MyServicePutDataByIdArgs) SetId(id int64) *MyServicePutDataByIdArgs { - m.Id = id - return m -} - -func (m *MyServicePutDataByIdArgs) SetData(data string) *MyServicePutDataByIdArgs { - m.Data = data - return m -} - -func (p *MyServicePutDataByIdArgs) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyServicePutDataByIdArgs) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Id = v - } - return nil -} - -func (p *MyServicePutDataByIdArgs) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Data = v - } - return nil -} - -func (p *MyServicePutDataByIdArgs) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("putDataById_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyServicePutDataByIdArgs) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("id", thrift.I64, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:id: ", p), err) } - if err := oprot.WriteI64(int64(p.Id)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.id (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:id: ", p), err) } - return err -} - -func (p *MyServicePutDataByIdArgs) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("data", thrift.STRING, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:data: ", p), err) } - if err := oprot.WriteString(string(p.Data)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.data (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:data: ", p), err) } - return err -} - -func (p *MyServicePutDataByIdArgs) String() string { - if p == nil { - return "" - } - - idVal := fmt.Sprintf("%v", p.Id) - dataVal := fmt.Sprintf("%v", p.Data) - return fmt.Sprintf("MyServicePutDataByIdArgs({Id:%s Data:%s})", idVal, dataVal) -} - -type MyServicePutDataByIdResult struct { - thrift.IResponse -} - -func NewMyServicePutDataByIdResult() *MyServicePutDataByIdResult { - return &MyServicePutDataByIdResult{} -} - -type MyServicePutDataByIdResultBuilder struct { - obj *MyServicePutDataByIdResult -} - -func NewMyServicePutDataByIdResultBuilder() *MyServicePutDataByIdResultBuilder{ - return &MyServicePutDataByIdResultBuilder{ - obj: NewMyServicePutDataByIdResult(), - } -} - -func (p MyServicePutDataByIdResultBuilder) Emit() *MyServicePutDataByIdResult{ - return &MyServicePutDataByIdResult{ - } -} - -func (p *MyServicePutDataByIdResult) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyServicePutDataByIdResult) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("putDataById_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyServicePutDataByIdResult) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("MyServicePutDataByIdResult({})") -} - -// Attributes: -// - Id -type MyServiceHasDataByIdArgs struct { - thrift.IRequest - Id int64 `thrift:"id,1" db:"id" json:"id"` -} - -func NewMyServiceHasDataByIdArgs() *MyServiceHasDataByIdArgs { - return &MyServiceHasDataByIdArgs{} -} - - -func (p *MyServiceHasDataByIdArgs) GetId() int64 { - return p.Id -} -type MyServiceHasDataByIdArgsBuilder struct { - obj *MyServiceHasDataByIdArgs -} - -func NewMyServiceHasDataByIdArgsBuilder() *MyServiceHasDataByIdArgsBuilder{ - return &MyServiceHasDataByIdArgsBuilder{ - obj: NewMyServiceHasDataByIdArgs(), - } -} - -func (p MyServiceHasDataByIdArgsBuilder) Emit() *MyServiceHasDataByIdArgs{ - return &MyServiceHasDataByIdArgs{ - Id: p.obj.Id, - } -} - -func (m *MyServiceHasDataByIdArgsBuilder) Id(id int64) *MyServiceHasDataByIdArgsBuilder { - m.obj.Id = id - return m -} - -func (m *MyServiceHasDataByIdArgs) SetId(id int64) *MyServiceHasDataByIdArgs { - m.Id = id - return m -} - -func (p *MyServiceHasDataByIdArgs) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyServiceHasDataByIdArgs) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Id = v - } - return nil -} - -func (p *MyServiceHasDataByIdArgs) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("hasDataById_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyServiceHasDataByIdArgs) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("id", thrift.I64, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:id: ", p), err) } - if err := oprot.WriteI64(int64(p.Id)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.id (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:id: ", p), err) } - return err -} - -func (p *MyServiceHasDataByIdArgs) String() string { - if p == nil { - return "" - } - - idVal := fmt.Sprintf("%v", p.Id) - return fmt.Sprintf("MyServiceHasDataByIdArgs({Id:%s})", idVal) -} - -// Attributes: -// - Success -type MyServiceHasDataByIdResult struct { - thrift.IResponse - Success *bool `thrift:"success,0,optional" db:"success" json:"success,omitempty"` -} - -func NewMyServiceHasDataByIdResult() *MyServiceHasDataByIdResult { - return &MyServiceHasDataByIdResult{} -} - -var MyServiceHasDataByIdResult_Success_DEFAULT bool -func (p *MyServiceHasDataByIdResult) GetSuccess() bool { - if !p.IsSetSuccess() { - return MyServiceHasDataByIdResult_Success_DEFAULT - } - return *p.Success -} -func (p *MyServiceHasDataByIdResult) IsSetSuccess() bool { - return p != nil && p.Success != nil -} - -type MyServiceHasDataByIdResultBuilder struct { - obj *MyServiceHasDataByIdResult -} - -func NewMyServiceHasDataByIdResultBuilder() *MyServiceHasDataByIdResultBuilder{ - return &MyServiceHasDataByIdResultBuilder{ - obj: NewMyServiceHasDataByIdResult(), - } -} - -func (p MyServiceHasDataByIdResultBuilder) Emit() *MyServiceHasDataByIdResult{ - return &MyServiceHasDataByIdResult{ - Success: p.obj.Success, - } -} - -func (m *MyServiceHasDataByIdResultBuilder) Success(success *bool) *MyServiceHasDataByIdResultBuilder { - m.obj.Success = success - return m -} - -func (m *MyServiceHasDataByIdResult) SetSuccess(success *bool) *MyServiceHasDataByIdResult { - m.Success = success - return m -} - -func (p *MyServiceHasDataByIdResult) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 0: - if err := p.ReadField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyServiceHasDataByIdResult) ReadField0(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - p.Success = &v - } - return nil -} - -func (p *MyServiceHasDataByIdResult) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("hasDataById_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField0(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyServiceHasDataByIdResult) writeField0(oprot thrift.Protocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.BOOL, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := oprot.WriteBool(bool(*p.Success)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.success (0) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } - } - return err -} - -func (p *MyServiceHasDataByIdResult) String() string { - if p == nil { - return "" - } - - var successVal string - if p.Success == nil { - successVal = "" - } else { - successVal = fmt.Sprintf("%v", *p.Success) - } - return fmt.Sprintf("MyServiceHasDataByIdResult({Success:%s})", successVal) -} - -// Attributes: -// - Id -type MyServiceGetDataByIdArgs struct { - thrift.IRequest - Id int64 `thrift:"id,1" db:"id" json:"id"` -} - -func NewMyServiceGetDataByIdArgs() *MyServiceGetDataByIdArgs { - return &MyServiceGetDataByIdArgs{} -} - - -func (p *MyServiceGetDataByIdArgs) GetId() int64 { - return p.Id -} -type MyServiceGetDataByIdArgsBuilder struct { - obj *MyServiceGetDataByIdArgs -} - -func NewMyServiceGetDataByIdArgsBuilder() *MyServiceGetDataByIdArgsBuilder{ - return &MyServiceGetDataByIdArgsBuilder{ - obj: NewMyServiceGetDataByIdArgs(), - } -} - -func (p MyServiceGetDataByIdArgsBuilder) Emit() *MyServiceGetDataByIdArgs{ - return &MyServiceGetDataByIdArgs{ - Id: p.obj.Id, - } -} - -func (m *MyServiceGetDataByIdArgsBuilder) Id(id int64) *MyServiceGetDataByIdArgsBuilder { - m.obj.Id = id - return m -} - -func (m *MyServiceGetDataByIdArgs) SetId(id int64) *MyServiceGetDataByIdArgs { - m.Id = id - return m -} - -func (p *MyServiceGetDataByIdArgs) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyServiceGetDataByIdArgs) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Id = v - } - return nil -} - -func (p *MyServiceGetDataByIdArgs) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("getDataById_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyServiceGetDataByIdArgs) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("id", thrift.I64, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:id: ", p), err) } - if err := oprot.WriteI64(int64(p.Id)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.id (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:id: ", p), err) } - return err -} - -func (p *MyServiceGetDataByIdArgs) String() string { - if p == nil { - return "" - } - - idVal := fmt.Sprintf("%v", p.Id) - return fmt.Sprintf("MyServiceGetDataByIdArgs({Id:%s})", idVal) -} - -// Attributes: -// - Success -type MyServiceGetDataByIdResult struct { - thrift.IResponse - Success *string `thrift:"success,0,optional" db:"success" json:"success,omitempty"` -} - -func NewMyServiceGetDataByIdResult() *MyServiceGetDataByIdResult { - return &MyServiceGetDataByIdResult{} -} - -var MyServiceGetDataByIdResult_Success_DEFAULT string -func (p *MyServiceGetDataByIdResult) GetSuccess() string { - if !p.IsSetSuccess() { - return MyServiceGetDataByIdResult_Success_DEFAULT - } - return *p.Success -} -func (p *MyServiceGetDataByIdResult) IsSetSuccess() bool { - return p != nil && p.Success != nil -} - -type MyServiceGetDataByIdResultBuilder struct { - obj *MyServiceGetDataByIdResult -} - -func NewMyServiceGetDataByIdResultBuilder() *MyServiceGetDataByIdResultBuilder{ - return &MyServiceGetDataByIdResultBuilder{ - obj: NewMyServiceGetDataByIdResult(), - } -} - -func (p MyServiceGetDataByIdResultBuilder) Emit() *MyServiceGetDataByIdResult{ - return &MyServiceGetDataByIdResult{ - Success: p.obj.Success, - } -} - -func (m *MyServiceGetDataByIdResultBuilder) Success(success *string) *MyServiceGetDataByIdResultBuilder { - m.obj.Success = success - return m -} - -func (m *MyServiceGetDataByIdResult) SetSuccess(success *string) *MyServiceGetDataByIdResult { - m.Success = success - return m -} - -func (p *MyServiceGetDataByIdResult) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 0: - if err := p.ReadField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyServiceGetDataByIdResult) ReadField0(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - p.Success = &v - } - return nil -} - -func (p *MyServiceGetDataByIdResult) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("getDataById_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField0(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyServiceGetDataByIdResult) writeField0(oprot thrift.Protocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRING, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := oprot.WriteString(string(*p.Success)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.success (0) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } - } - return err -} - -func (p *MyServiceGetDataByIdResult) String() string { - if p == nil { - return "" - } - - var successVal string - if p.Success == nil { - successVal = "" - } else { - successVal = fmt.Sprintf("%v", *p.Success) - } - return fmt.Sprintf("MyServiceGetDataByIdResult({Success:%s})", successVal) -} - -// Attributes: -// - Id -type MyServiceDeleteDataByIdArgs struct { - thrift.IRequest - Id int64 `thrift:"id,1" db:"id" json:"id"` -} - -func NewMyServiceDeleteDataByIdArgs() *MyServiceDeleteDataByIdArgs { - return &MyServiceDeleteDataByIdArgs{} -} - - -func (p *MyServiceDeleteDataByIdArgs) GetId() int64 { - return p.Id -} -type MyServiceDeleteDataByIdArgsBuilder struct { - obj *MyServiceDeleteDataByIdArgs -} - -func NewMyServiceDeleteDataByIdArgsBuilder() *MyServiceDeleteDataByIdArgsBuilder{ - return &MyServiceDeleteDataByIdArgsBuilder{ - obj: NewMyServiceDeleteDataByIdArgs(), - } -} - -func (p MyServiceDeleteDataByIdArgsBuilder) Emit() *MyServiceDeleteDataByIdArgs{ - return &MyServiceDeleteDataByIdArgs{ - Id: p.obj.Id, - } -} - -func (m *MyServiceDeleteDataByIdArgsBuilder) Id(id int64) *MyServiceDeleteDataByIdArgsBuilder { - m.obj.Id = id - return m -} - -func (m *MyServiceDeleteDataByIdArgs) SetId(id int64) *MyServiceDeleteDataByIdArgs { - m.Id = id - return m -} - -func (p *MyServiceDeleteDataByIdArgs) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyServiceDeleteDataByIdArgs) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Id = v - } - return nil -} - -func (p *MyServiceDeleteDataByIdArgs) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("deleteDataById_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyServiceDeleteDataByIdArgs) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("id", thrift.I64, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:id: ", p), err) } - if err := oprot.WriteI64(int64(p.Id)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.id (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:id: ", p), err) } - return err -} - -func (p *MyServiceDeleteDataByIdArgs) String() string { - if p == nil { - return "" - } - - idVal := fmt.Sprintf("%v", p.Id) - return fmt.Sprintf("MyServiceDeleteDataByIdArgs({Id:%s})", idVal) -} - -type MyServiceDeleteDataByIdResult struct { - thrift.IResponse -} - -func NewMyServiceDeleteDataByIdResult() *MyServiceDeleteDataByIdResult { - return &MyServiceDeleteDataByIdResult{} -} - -type MyServiceDeleteDataByIdResultBuilder struct { - obj *MyServiceDeleteDataByIdResult -} - -func NewMyServiceDeleteDataByIdResultBuilder() *MyServiceDeleteDataByIdResultBuilder{ - return &MyServiceDeleteDataByIdResultBuilder{ - obj: NewMyServiceDeleteDataByIdResult(), - } -} - -func (p MyServiceDeleteDataByIdResultBuilder) Emit() *MyServiceDeleteDataByIdResult{ - return &MyServiceDeleteDataByIdResult{ - } -} - -func (p *MyServiceDeleteDataByIdResult) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyServiceDeleteDataByIdResult) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("deleteDataById_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyServiceDeleteDataByIdResult) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("MyServiceDeleteDataByIdResult({})") -} - -// Attributes: -// - Id -// - Data -type MyServiceLobDataByIdArgs struct { - thrift.IRequest - Id int64 `thrift:"id,1" db:"id" json:"id"` - Data string `thrift:"data,2" db:"data" json:"data"` -} - -func NewMyServiceLobDataByIdArgs() *MyServiceLobDataByIdArgs { - return &MyServiceLobDataByIdArgs{} -} - - -func (p *MyServiceLobDataByIdArgs) GetId() int64 { - return p.Id -} - -func (p *MyServiceLobDataByIdArgs) GetData() string { - return p.Data -} -type MyServiceLobDataByIdArgsBuilder struct { - obj *MyServiceLobDataByIdArgs -} - -func NewMyServiceLobDataByIdArgsBuilder() *MyServiceLobDataByIdArgsBuilder{ - return &MyServiceLobDataByIdArgsBuilder{ - obj: NewMyServiceLobDataByIdArgs(), - } -} - -func (p MyServiceLobDataByIdArgsBuilder) Emit() *MyServiceLobDataByIdArgs{ - return &MyServiceLobDataByIdArgs{ - Id: p.obj.Id, - Data: p.obj.Data, - } -} - -func (m *MyServiceLobDataByIdArgsBuilder) Id(id int64) *MyServiceLobDataByIdArgsBuilder { - m.obj.Id = id - return m -} - -func (m *MyServiceLobDataByIdArgsBuilder) Data(data string) *MyServiceLobDataByIdArgsBuilder { - m.obj.Data = data - return m -} - -func (m *MyServiceLobDataByIdArgs) SetId(id int64) *MyServiceLobDataByIdArgs { - m.Id = id - return m -} - -func (m *MyServiceLobDataByIdArgs) SetData(data string) *MyServiceLobDataByIdArgs { - m.Data = data - return m -} - -func (p *MyServiceLobDataByIdArgs) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyServiceLobDataByIdArgs) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Id = v - } - return nil -} - -func (p *MyServiceLobDataByIdArgs) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Data = v - } - return nil -} - -func (p *MyServiceLobDataByIdArgs) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("lobDataById_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyServiceLobDataByIdArgs) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("id", thrift.I64, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:id: ", p), err) } - if err := oprot.WriteI64(int64(p.Id)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.id (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:id: ", p), err) } - return err -} - -func (p *MyServiceLobDataByIdArgs) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("data", thrift.STRING, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:data: ", p), err) } - if err := oprot.WriteString(string(p.Data)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.data (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:data: ", p), err) } - return err -} - -func (p *MyServiceLobDataByIdArgs) String() string { - if p == nil { - return "" - } - - idVal := fmt.Sprintf("%v", p.Id) - dataVal := fmt.Sprintf("%v", p.Data) - return fmt.Sprintf("MyServiceLobDataByIdArgs({Id:%s Data:%s})", idVal, dataVal) -} - -type MyServiceInvalidReturnForHackArgs struct { - thrift.IRequest -} - -func NewMyServiceInvalidReturnForHackArgs() *MyServiceInvalidReturnForHackArgs { - return &MyServiceInvalidReturnForHackArgs{} -} - -type MyServiceInvalidReturnForHackArgsBuilder struct { - obj *MyServiceInvalidReturnForHackArgs -} - -func NewMyServiceInvalidReturnForHackArgsBuilder() *MyServiceInvalidReturnForHackArgsBuilder{ - return &MyServiceInvalidReturnForHackArgsBuilder{ - obj: NewMyServiceInvalidReturnForHackArgs(), - } -} - -func (p MyServiceInvalidReturnForHackArgsBuilder) Emit() *MyServiceInvalidReturnForHackArgs{ - return &MyServiceInvalidReturnForHackArgs{ - } -} - -func (p *MyServiceInvalidReturnForHackArgs) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyServiceInvalidReturnForHackArgs) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("invalid_return_for_hack_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyServiceInvalidReturnForHackArgs) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("MyServiceInvalidReturnForHackArgs({})") -} - -// Attributes: -// - Success -type MyServiceInvalidReturnForHackResult struct { - thrift.IResponse - Success []float32 `thrift:"success,0,optional" db:"success" json:"success,omitempty"` -} - -func NewMyServiceInvalidReturnForHackResult() *MyServiceInvalidReturnForHackResult { - return &MyServiceInvalidReturnForHackResult{} -} - -var MyServiceInvalidReturnForHackResult_Success_DEFAULT []float32 - -func (p *MyServiceInvalidReturnForHackResult) GetSuccess() []float32 { - return p.Success -} -func (p *MyServiceInvalidReturnForHackResult) IsSetSuccess() bool { - return p != nil && p.Success != nil -} - -type MyServiceInvalidReturnForHackResultBuilder struct { - obj *MyServiceInvalidReturnForHackResult -} - -func NewMyServiceInvalidReturnForHackResultBuilder() *MyServiceInvalidReturnForHackResultBuilder{ - return &MyServiceInvalidReturnForHackResultBuilder{ - obj: NewMyServiceInvalidReturnForHackResult(), - } -} - -func (p MyServiceInvalidReturnForHackResultBuilder) Emit() *MyServiceInvalidReturnForHackResult{ - return &MyServiceInvalidReturnForHackResult{ - Success: p.obj.Success, - } -} - -func (m *MyServiceInvalidReturnForHackResultBuilder) Success(success []float32) *MyServiceInvalidReturnForHackResultBuilder { - m.obj.Success = success - return m -} - -func (m *MyServiceInvalidReturnForHackResult) SetSuccess(success []float32) *MyServiceInvalidReturnForHackResult { - m.Success = success - return m -} - -func (p *MyServiceInvalidReturnForHackResult) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 0: - if err := p.ReadField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyServiceInvalidReturnForHackResult) ReadField0(iprot thrift.Protocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return thrift.PrependError("error reading set begin: ", err) - } - tSet := make([]float32, 0, size) - p.Success = tSet - for i := 0; i < size; i ++ { - var _elem8 float32 - if v, err := iprot.ReadFloat(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem8 = v - } - p.Success = append(p.Success, _elem8) - } - if err := iprot.ReadSetEnd(); err != nil { - return thrift.PrependError("error reading set end: ", err) - } - return nil -} - -func (p *MyServiceInvalidReturnForHackResult) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("invalid_return_for_hack_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField0(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyServiceInvalidReturnForHackResult) writeField0(oprot thrift.Protocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.SET, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := oprot.WriteSetBegin(thrift.FLOAT, len(p.Success)); err != nil { - return thrift.PrependError("error writing set begin: ", err) - } - set := make(map[float32]bool, len(p.Success)) - for _, v := range p.Success { - if ok := set[v]; ok { - return thrift.PrependError("", fmt.Errorf("%T error writing set field: slice is not unique", v)) - } - set[v] = true - } - for _, v := range p.Success { - if err := oprot.WriteFloat(float32(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteSetEnd(); err != nil { - return thrift.PrependError("error writing set end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } - } - return err -} - -func (p *MyServiceInvalidReturnForHackResult) String() string { - if p == nil { - return "" - } - - successVal := fmt.Sprintf("%v", p.Success) - return fmt.Sprintf("MyServiceInvalidReturnForHackResult({Success:%s})", successVal) -} - -type MyServiceRpcSkippedCodegenArgs struct { - thrift.IRequest -} - -func NewMyServiceRpcSkippedCodegenArgs() *MyServiceRpcSkippedCodegenArgs { - return &MyServiceRpcSkippedCodegenArgs{} -} - -type MyServiceRpcSkippedCodegenArgsBuilder struct { - obj *MyServiceRpcSkippedCodegenArgs -} - -func NewMyServiceRpcSkippedCodegenArgsBuilder() *MyServiceRpcSkippedCodegenArgsBuilder{ - return &MyServiceRpcSkippedCodegenArgsBuilder{ - obj: NewMyServiceRpcSkippedCodegenArgs(), - } -} - -func (p MyServiceRpcSkippedCodegenArgsBuilder) Emit() *MyServiceRpcSkippedCodegenArgs{ - return &MyServiceRpcSkippedCodegenArgs{ - } -} - -func (p *MyServiceRpcSkippedCodegenArgs) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyServiceRpcSkippedCodegenArgs) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("rpc_skipped_codegen_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyServiceRpcSkippedCodegenArgs) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("MyServiceRpcSkippedCodegenArgs({})") -} - -type MyServiceRpcSkippedCodegenResult struct { - thrift.IResponse -} - -func NewMyServiceRpcSkippedCodegenResult() *MyServiceRpcSkippedCodegenResult { - return &MyServiceRpcSkippedCodegenResult{} -} - -type MyServiceRpcSkippedCodegenResultBuilder struct { - obj *MyServiceRpcSkippedCodegenResult -} - -func NewMyServiceRpcSkippedCodegenResultBuilder() *MyServiceRpcSkippedCodegenResultBuilder{ - return &MyServiceRpcSkippedCodegenResultBuilder{ - obj: NewMyServiceRpcSkippedCodegenResult(), - } -} - -func (p MyServiceRpcSkippedCodegenResultBuilder) Emit() *MyServiceRpcSkippedCodegenResult{ - return &MyServiceRpcSkippedCodegenResult{ - } -} - -func (p *MyServiceRpcSkippedCodegenResult) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyServiceRpcSkippedCodegenResult) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("rpc_skipped_codegen_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyServiceRpcSkippedCodegenResult) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("MyServiceRpcSkippedCodegenResult({})") -} - - diff --git a/thrift/compiler/test/fixtures/basic/gen-go/module/ttypes.go b/thrift/compiler/test/fixtures/basic/gen-go/module/ttypes.go deleted file mode 100644 index f1cde5f9c0b..00000000000 --- a/thrift/compiler/test/fixtures/basic/gen-go/module/ttypes.go +++ /dev/null @@ -1,1258 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package module - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var GoUnusedProtection__ int; - -type MyEnum int64 -const ( - MyEnum_MyValue1 MyEnum = 0 - MyEnum_MyValue2 MyEnum = 1 -) - -var MyEnumToName = map[MyEnum]string { - MyEnum_MyValue1: "MyValue1", - MyEnum_MyValue2: "MyValue2", -} - -var MyEnumToValue = map[string]MyEnum { - "MyValue1": MyEnum_MyValue1, - "MyValue2": MyEnum_MyValue2, -} - -var MyEnumNames = []string { - "MyValue1", - "MyValue2", -} - -var MyEnumValues = []MyEnum { - MyEnum_MyValue1, - MyEnum_MyValue2, -} - -func (p MyEnum) String() string { - if v, ok := MyEnumToName[p]; ok { - return v - } - return "" -} - -func MyEnumFromString(s string) (MyEnum, error) { - if v, ok := MyEnumToValue[s]; ok { - return v, nil - } - return MyEnum(0), fmt.Errorf("not a valid MyEnum string") -} - -func MyEnumPtr(v MyEnum) *MyEnum { return &v } - -type HackEnum int64 -const ( - HackEnum_Value1 HackEnum = 0 - HackEnum_Value2 HackEnum = 1 -) - -var HackEnumToName = map[HackEnum]string { - HackEnum_Value1: "Value1", - HackEnum_Value2: "Value2", -} - -var HackEnumToValue = map[string]HackEnum { - "Value1": HackEnum_Value1, - "Value2": HackEnum_Value2, -} - -var HackEnumNames = []string { - "Value1", - "Value2", -} - -var HackEnumValues = []HackEnum { - HackEnum_Value1, - HackEnum_Value2, -} - -func (p HackEnum) String() string { - if v, ok := HackEnumToName[p]; ok { - return v - } - return "" -} - -func HackEnumFromString(s string) (HackEnum, error) { - if v, ok := HackEnumToValue[s]; ok { - return v, nil - } - return HackEnum(0), fmt.Errorf("not a valid HackEnum string") -} - -func HackEnumPtr(v HackEnum) *HackEnum { return &v } - -// Attributes: -// - MyIntField -// - MyStringField -// - MyDataField -// - MyEnum -// - Oneway -// - Readonly -// - Idempotent -// - FloatSet -// - NoHackCodegenField -type MyStruct struct { - MyIntField int64 `thrift:"MyIntField,1" db:"MyIntField" json:"MyIntField"` - MyStringField string `thrift:"MyStringField,2" db:"MyStringField" json:"MyStringField"` - MyDataField *MyDataItem `thrift:"MyDataField,3" db:"MyDataField" json:"MyDataField"` - MyEnum MyEnum `thrift:"myEnum,4" db:"myEnum" json:"myEnum"` - Oneway bool `thrift:"oneway,5" db:"oneway" json:"oneway"` - Readonly bool `thrift:"readonly,6" db:"readonly" json:"readonly"` - Idempotent bool `thrift:"idempotent,7" db:"idempotent" json:"idempotent"` - FloatSet []float32 `thrift:"floatSet,8" db:"floatSet" json:"floatSet"` - NoHackCodegenField string `thrift:"no_hack_codegen_field,9" db:"no_hack_codegen_field" json:"no_hack_codegen_field"` -} - -func NewMyStruct() *MyStruct { - return &MyStruct{ - MyDataField: NewMyDataItem(), - } -} - - -func (p *MyStruct) GetMyIntField() int64 { - return p.MyIntField -} - -func (p *MyStruct) GetMyStringField() string { - return p.MyStringField -} -var MyStruct_MyDataField_DEFAULT *MyDataItem -func (p *MyStruct) GetMyDataField() *MyDataItem { - if !p.IsSetMyDataField() { - return MyStruct_MyDataField_DEFAULT - } - return p.MyDataField -} - -func (p *MyStruct) GetMyEnum() MyEnum { - return p.MyEnum -} - -func (p *MyStruct) GetOneway() bool { - return p.Oneway -} - -func (p *MyStruct) GetReadonly() bool { - return p.Readonly -} - -func (p *MyStruct) GetIdempotent() bool { - return p.Idempotent -} - -func (p *MyStruct) GetFloatSet() []float32 { - return p.FloatSet -} - -func (p *MyStruct) GetNoHackCodegenField() string { - return p.NoHackCodegenField -} -func (p *MyStruct) IsSetMyDataField() bool { - return p != nil && p.MyDataField != nil -} - -type MyStructBuilder struct { - obj *MyStruct -} - -func NewMyStructBuilder() *MyStructBuilder{ - return &MyStructBuilder{ - obj: NewMyStruct(), - } -} - -func (p MyStructBuilder) Emit() *MyStruct{ - return &MyStruct{ - MyIntField: p.obj.MyIntField, - MyStringField: p.obj.MyStringField, - MyDataField: p.obj.MyDataField, - MyEnum: p.obj.MyEnum, - Oneway: p.obj.Oneway, - Readonly: p.obj.Readonly, - Idempotent: p.obj.Idempotent, - FloatSet: p.obj.FloatSet, - NoHackCodegenField: p.obj.NoHackCodegenField, - } -} - -func (m *MyStructBuilder) MyIntField(myIntField int64) *MyStructBuilder { - m.obj.MyIntField = myIntField - return m -} - -func (m *MyStructBuilder) MyStringField(myStringField string) *MyStructBuilder { - m.obj.MyStringField = myStringField - return m -} - -func (m *MyStructBuilder) MyDataField(myDataField *MyDataItem) *MyStructBuilder { - m.obj.MyDataField = myDataField - return m -} - -func (m *MyStructBuilder) MyEnum(myEnum MyEnum) *MyStructBuilder { - m.obj.MyEnum = myEnum - return m -} - -func (m *MyStructBuilder) Oneway(oneway bool) *MyStructBuilder { - m.obj.Oneway = oneway - return m -} - -func (m *MyStructBuilder) Readonly(readonly bool) *MyStructBuilder { - m.obj.Readonly = readonly - return m -} - -func (m *MyStructBuilder) Idempotent(idempotent bool) *MyStructBuilder { - m.obj.Idempotent = idempotent - return m -} - -func (m *MyStructBuilder) FloatSet(floatSet []float32) *MyStructBuilder { - m.obj.FloatSet = floatSet - return m -} - -func (m *MyStructBuilder) NoHackCodegenField(noHackCodegenField string) *MyStructBuilder { - m.obj.NoHackCodegenField = noHackCodegenField - return m -} - -func (m *MyStruct) SetMyIntField(myIntField int64) *MyStruct { - m.MyIntField = myIntField - return m -} - -func (m *MyStruct) SetMyStringField(myStringField string) *MyStruct { - m.MyStringField = myStringField - return m -} - -func (m *MyStruct) SetMyDataField(myDataField *MyDataItem) *MyStruct { - m.MyDataField = myDataField - return m -} - -func (m *MyStruct) SetMyEnum(myEnum MyEnum) *MyStruct { - m.MyEnum = myEnum - return m -} - -func (m *MyStruct) SetOneway(oneway bool) *MyStruct { - m.Oneway = oneway - return m -} - -func (m *MyStruct) SetReadonly(readonly bool) *MyStruct { - m.Readonly = readonly - return m -} - -func (m *MyStruct) SetIdempotent(idempotent bool) *MyStruct { - m.Idempotent = idempotent - return m -} - -func (m *MyStruct) SetFloatSet(floatSet []float32) *MyStruct { - m.FloatSet = floatSet - return m -} - -func (m *MyStruct) SetNoHackCodegenField(noHackCodegenField string) *MyStruct { - m.NoHackCodegenField = noHackCodegenField - return m -} - -func (p *MyStruct) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 3: - if err := p.ReadField3(iprot); err != nil { - return err - } - case 4: - if err := p.ReadField4(iprot); err != nil { - return err - } - case 5: - if err := p.ReadField5(iprot); err != nil { - return err - } - case 6: - if err := p.ReadField6(iprot); err != nil { - return err - } - case 7: - if err := p.ReadField7(iprot); err != nil { - return err - } - case 8: - if err := p.ReadField8(iprot); err != nil { - return err - } - case 9: - if err := p.ReadField9(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyStruct) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.MyIntField = v - } - return nil -} - -func (p *MyStruct) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.MyStringField = v - } - return nil -} - -func (p *MyStruct) ReadField3(iprot thrift.Protocol) error { - p.MyDataField = NewMyDataItem() - if err := p.MyDataField.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.MyDataField), err) - } - return nil -} - -func (p *MyStruct) ReadField4(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 4: ", err) - } else { - temp := MyEnum(v) - p.MyEnum = temp - } - return nil -} - -func (p *MyStruct) ReadField5(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 5: ", err) - } else { - p.Oneway = v - } - return nil -} - -func (p *MyStruct) ReadField6(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 6: ", err) - } else { - p.Readonly = v - } - return nil -} - -func (p *MyStruct) ReadField7(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 7: ", err) - } else { - p.Idempotent = v - } - return nil -} - -func (p *MyStruct) ReadField8(iprot thrift.Protocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return thrift.PrependError("error reading set begin: ", err) - } - tSet := make([]float32, 0, size) - p.FloatSet = tSet - for i := 0; i < size; i ++ { - var _elem0 float32 - if v, err := iprot.ReadFloat(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem0 = v - } - p.FloatSet = append(p.FloatSet, _elem0) - } - if err := iprot.ReadSetEnd(); err != nil { - return thrift.PrependError("error reading set end: ", err) - } - return nil -} - -func (p *MyStruct) ReadField9(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 9: ", err) - } else { - p.NoHackCodegenField = v - } - return nil -} - -func (p *MyStruct) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("MyStruct"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := p.writeField4(oprot); err != nil { return err } - if err := p.writeField5(oprot); err != nil { return err } - if err := p.writeField6(oprot); err != nil { return err } - if err := p.writeField7(oprot); err != nil { return err } - if err := p.writeField8(oprot); err != nil { return err } - if err := p.writeField9(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyStruct) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("MyIntField", thrift.I64, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:MyIntField: ", p), err) } - if err := oprot.WriteI64(int64(p.MyIntField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.MyIntField (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:MyIntField: ", p), err) } - return err -} - -func (p *MyStruct) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("MyStringField", thrift.STRING, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:MyStringField: ", p), err) } - if err := oprot.WriteString(string(p.MyStringField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.MyStringField (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:MyStringField: ", p), err) } - return err -} - -func (p *MyStruct) writeField3(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("MyDataField", thrift.STRUCT, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:MyDataField: ", p), err) } - if err := p.MyDataField.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.MyDataField), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:MyDataField: ", p), err) } - return err -} - -func (p *MyStruct) writeField4(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("myEnum", thrift.I32, 4); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:myEnum: ", p), err) } - if err := oprot.WriteI32(int32(p.MyEnum)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.myEnum (4) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 4:myEnum: ", p), err) } - return err -} - -func (p *MyStruct) writeField5(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("oneway", thrift.BOOL, 5); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:oneway: ", p), err) } - if err := oprot.WriteBool(bool(p.Oneway)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.oneway (5) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 5:oneway: ", p), err) } - return err -} - -func (p *MyStruct) writeField6(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("readonly", thrift.BOOL, 6); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 6:readonly: ", p), err) } - if err := oprot.WriteBool(bool(p.Readonly)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.readonly (6) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 6:readonly: ", p), err) } - return err -} - -func (p *MyStruct) writeField7(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("idempotent", thrift.BOOL, 7); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 7:idempotent: ", p), err) } - if err := oprot.WriteBool(bool(p.Idempotent)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.idempotent (7) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 7:idempotent: ", p), err) } - return err -} - -func (p *MyStruct) writeField8(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("floatSet", thrift.SET, 8); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 8:floatSet: ", p), err) } - if err := oprot.WriteSetBegin(thrift.FLOAT, len(p.FloatSet)); err != nil { - return thrift.PrependError("error writing set begin: ", err) - } - set := make(map[float32]bool, len(p.FloatSet)) - for _, v := range p.FloatSet { - if ok := set[v]; ok { - return thrift.PrependError("", fmt.Errorf("%T error writing set field: slice is not unique", v)) - } - set[v] = true - } - for _, v := range p.FloatSet { - if err := oprot.WriteFloat(float32(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteSetEnd(); err != nil { - return thrift.PrependError("error writing set end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 8:floatSet: ", p), err) } - return err -} - -func (p *MyStruct) writeField9(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("no_hack_codegen_field", thrift.STRING, 9); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 9:no_hack_codegen_field: ", p), err) } - if err := oprot.WriteString(string(p.NoHackCodegenField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.no_hack_codegen_field (9) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 9:no_hack_codegen_field: ", p), err) } - return err -} - -func (p *MyStruct) String() string { - if p == nil { - return "" - } - - myIntFieldVal := fmt.Sprintf("%v", p.MyIntField) - myStringFieldVal := fmt.Sprintf("%v", p.MyStringField) - var myDataFieldVal string - if p.MyDataField == nil { - myDataFieldVal = "" - } else { - myDataFieldVal = fmt.Sprintf("%v", p.MyDataField) - } - myEnumVal := fmt.Sprintf("%v", p.MyEnum) - onewayVal := fmt.Sprintf("%v", p.Oneway) - readonlyVal := fmt.Sprintf("%v", p.Readonly) - idempotentVal := fmt.Sprintf("%v", p.Idempotent) - floatSetVal := fmt.Sprintf("%v", p.FloatSet) - noHackCodegenFieldVal := fmt.Sprintf("%v", p.NoHackCodegenField) - return fmt.Sprintf("MyStruct({MyIntField:%s MyStringField:%s MyDataField:%s MyEnum:%s Oneway:%s Readonly:%s Idempotent:%s FloatSet:%s NoHackCodegenField:%s})", myIntFieldVal, myStringFieldVal, myDataFieldVal, myEnumVal, onewayVal, readonlyVal, idempotentVal, floatSetVal, noHackCodegenFieldVal) -} - -type MyDataItem struct { -} - -func NewMyDataItem() *MyDataItem { - return &MyDataItem{} -} - -type MyDataItemBuilder struct { - obj *MyDataItem -} - -func NewMyDataItemBuilder() *MyDataItemBuilder{ - return &MyDataItemBuilder{ - obj: NewMyDataItem(), - } -} - -func (p MyDataItemBuilder) Emit() *MyDataItem{ - return &MyDataItem{ - } -} - -func (p *MyDataItem) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyDataItem) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("MyDataItem"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyDataItem) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("MyDataItem({})") -} - -// Attributes: -// - MyEnum -// - MyStruct -// - MyDataItem -// - FloatSet -type MyUnion struct { - MyEnum *MyEnum `thrift:"myEnum,1,optional" db:"myEnum" json:"myEnum,omitempty"` - MyStruct *MyStruct `thrift:"myStruct,2,optional" db:"myStruct" json:"myStruct,omitempty"` - MyDataItem *MyDataItem `thrift:"myDataItem,3,optional" db:"myDataItem" json:"myDataItem,omitempty"` - FloatSet []float32 `thrift:"floatSet,4,optional" db:"floatSet" json:"floatSet,omitempty"` -} - -func NewMyUnion() *MyUnion { - return &MyUnion{} -} - -var MyUnion_MyEnum_DEFAULT MyEnum -func (p *MyUnion) GetMyEnum() MyEnum { - if !p.IsSetMyEnum() { - return MyUnion_MyEnum_DEFAULT - } - return *p.MyEnum -} -var MyUnion_MyStruct_DEFAULT *MyStruct -func (p *MyUnion) GetMyStruct() *MyStruct { - if !p.IsSetMyStruct() { - return MyUnion_MyStruct_DEFAULT - } - return p.MyStruct -} -func (p *MyUnion) DefaultGetMyStruct() *MyStruct { - if !p.IsSetMyStruct() { - return NewMyStruct() - } - return p.MyStruct -} -var MyUnion_MyDataItem_DEFAULT *MyDataItem -func (p *MyUnion) GetMyDataItem() *MyDataItem { - if !p.IsSetMyDataItem() { - return MyUnion_MyDataItem_DEFAULT - } - return p.MyDataItem -} -func (p *MyUnion) DefaultGetMyDataItem() *MyDataItem { - if !p.IsSetMyDataItem() { - return NewMyDataItem() - } - return p.MyDataItem -} -var MyUnion_FloatSet_DEFAULT []float32 - -func (p *MyUnion) GetFloatSet() []float32 { - return p.FloatSet -} -func (p *MyUnion) CountSetFieldsMyUnion() int { - count := 0 - if (p.IsSetMyEnum()) { - count++ - } - if (p.IsSetMyStruct()) { - count++ - } - if (p.IsSetMyDataItem()) { - count++ - } - if (p.IsSetFloatSet()) { - count++ - } - return count - -} - -func (p *MyUnion) IsSetMyEnum() bool { - return p != nil && p.MyEnum != nil -} - -func (p *MyUnion) IsSetMyStruct() bool { - return p != nil && p.MyStruct != nil -} - -func (p *MyUnion) IsSetMyDataItem() bool { - return p != nil && p.MyDataItem != nil -} - -func (p *MyUnion) IsSetFloatSet() bool { - return p != nil && p.FloatSet != nil -} - -type MyUnionBuilder struct { - obj *MyUnion -} - -func NewMyUnionBuilder() *MyUnionBuilder{ - return &MyUnionBuilder{ - obj: NewMyUnion(), - } -} - -func (p MyUnionBuilder) Emit() *MyUnion{ - return &MyUnion{ - MyEnum: p.obj.MyEnum, - MyStruct: p.obj.MyStruct, - MyDataItem: p.obj.MyDataItem, - FloatSet: p.obj.FloatSet, - } -} - -func (m *MyUnionBuilder) MyEnum(myEnum *MyEnum) *MyUnionBuilder { - m.obj.MyEnum = myEnum - return m -} - -func (m *MyUnionBuilder) MyStruct(myStruct *MyStruct) *MyUnionBuilder { - m.obj.MyStruct = myStruct - return m -} - -func (m *MyUnionBuilder) MyDataItem(myDataItem *MyDataItem) *MyUnionBuilder { - m.obj.MyDataItem = myDataItem - return m -} - -func (m *MyUnionBuilder) FloatSet(floatSet []float32) *MyUnionBuilder { - m.obj.FloatSet = floatSet - return m -} - -func (m *MyUnion) SetMyEnum(myEnum *MyEnum) *MyUnion { - m.MyEnum = myEnum - return m -} - -func (m *MyUnion) SetMyStruct(myStruct *MyStruct) *MyUnion { - m.MyStruct = myStruct - return m -} - -func (m *MyUnion) SetMyDataItem(myDataItem *MyDataItem) *MyUnion { - m.MyDataItem = myDataItem - return m -} - -func (m *MyUnion) SetFloatSet(floatSet []float32) *MyUnion { - m.FloatSet = floatSet - return m -} - -func (p *MyUnion) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 3: - if err := p.ReadField3(iprot); err != nil { - return err - } - case 4: - if err := p.ReadField4(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyUnion) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - temp := MyEnum(v) - p.MyEnum = &temp - } - return nil -} - -func (p *MyUnion) ReadField2(iprot thrift.Protocol) error { - p.MyStruct = NewMyStruct() - if err := p.MyStruct.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.MyStruct), err) - } - return nil -} - -func (p *MyUnion) ReadField3(iprot thrift.Protocol) error { - p.MyDataItem = NewMyDataItem() - if err := p.MyDataItem.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.MyDataItem), err) - } - return nil -} - -func (p *MyUnion) ReadField4(iprot thrift.Protocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return thrift.PrependError("error reading set begin: ", err) - } - tSet := make([]float32, 0, size) - p.FloatSet = tSet - for i := 0; i < size; i ++ { - var _elem1 float32 - if v, err := iprot.ReadFloat(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem1 = v - } - p.FloatSet = append(p.FloatSet, _elem1) - } - if err := iprot.ReadSetEnd(); err != nil { - return thrift.PrependError("error reading set end: ", err) - } - return nil -} - -func (p *MyUnion) Write(oprot thrift.Protocol) error { - if c := p.CountSetFieldsMyUnion(); c > 1 { - return fmt.Errorf("%T write union: no more than one field must be set (%d set).", p, c) - } - if err := oprot.WriteStructBegin("MyUnion"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := p.writeField4(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyUnion) writeField1(oprot thrift.Protocol) (err error) { - if p.IsSetMyEnum() { - if err := oprot.WriteFieldBegin("myEnum", thrift.I32, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:myEnum: ", p), err) } - if err := oprot.WriteI32(int32(*p.MyEnum)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.myEnum (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:myEnum: ", p), err) } - } - return err -} - -func (p *MyUnion) writeField2(oprot thrift.Protocol) (err error) { - if p.IsSetMyStruct() { - if err := oprot.WriteFieldBegin("myStruct", thrift.STRUCT, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:myStruct: ", p), err) } - if err := p.MyStruct.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.MyStruct), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:myStruct: ", p), err) } - } - return err -} - -func (p *MyUnion) writeField3(oprot thrift.Protocol) (err error) { - if p.IsSetMyDataItem() { - if err := oprot.WriteFieldBegin("myDataItem", thrift.STRUCT, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:myDataItem: ", p), err) } - if err := p.MyDataItem.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.MyDataItem), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:myDataItem: ", p), err) } - } - return err -} - -func (p *MyUnion) writeField4(oprot thrift.Protocol) (err error) { - if p.IsSetFloatSet() { - if err := oprot.WriteFieldBegin("floatSet", thrift.SET, 4); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:floatSet: ", p), err) } - if err := oprot.WriteSetBegin(thrift.FLOAT, len(p.FloatSet)); err != nil { - return thrift.PrependError("error writing set begin: ", err) - } - set := make(map[float32]bool, len(p.FloatSet)) - for _, v := range p.FloatSet { - if ok := set[v]; ok { - return thrift.PrependError("", fmt.Errorf("%T error writing set field: slice is not unique", v)) - } - set[v] = true - } - for _, v := range p.FloatSet { - if err := oprot.WriteFloat(float32(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteSetEnd(); err != nil { - return thrift.PrependError("error writing set end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 4:floatSet: ", p), err) } - } - return err -} - -func (p *MyUnion) String() string { - if p == nil { - return "" - } - - var myEnumVal string - if p.MyEnum == nil { - myEnumVal = "" - } else { - myEnumVal = fmt.Sprintf("%v", *p.MyEnum) - } - var myStructVal string - if p.MyStruct == nil { - myStructVal = "" - } else { - myStructVal = fmt.Sprintf("%v", p.MyStruct) - } - var myDataItemVal string - if p.MyDataItem == nil { - myDataItemVal = "" - } else { - myDataItemVal = fmt.Sprintf("%v", p.MyDataItem) - } - floatSetVal := fmt.Sprintf("%v", p.FloatSet) - return fmt.Sprintf("MyUnion({MyEnum:%s MyStruct:%s MyDataItem:%s FloatSet:%s})", myEnumVal, myStructVal, myDataItemVal, floatSetVal) -} - -// Attributes: -// - ReservedField -type ReservedKeyword struct { - ReservedField int32 `thrift:"reserved_field,1" db:"reserved_field" json:"reserved_field"` -} - -func NewReservedKeyword() *ReservedKeyword { - return &ReservedKeyword{} -} - - -func (p *ReservedKeyword) GetReservedField() int32 { - return p.ReservedField -} -type ReservedKeywordBuilder struct { - obj *ReservedKeyword -} - -func NewReservedKeywordBuilder() *ReservedKeywordBuilder{ - return &ReservedKeywordBuilder{ - obj: NewReservedKeyword(), - } -} - -func (p ReservedKeywordBuilder) Emit() *ReservedKeyword{ - return &ReservedKeyword{ - ReservedField: p.obj.ReservedField, - } -} - -func (r *ReservedKeywordBuilder) ReservedField(reservedField int32) *ReservedKeywordBuilder { - r.obj.ReservedField = reservedField - return r -} - -func (r *ReservedKeyword) SetReservedField(reservedField int32) *ReservedKeyword { - r.ReservedField = reservedField - return r -} - -func (p *ReservedKeyword) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ReservedKeyword) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.ReservedField = v - } - return nil -} - -func (p *ReservedKeyword) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("ReservedKeyword"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *ReservedKeyword) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("reserved_field", thrift.I32, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:reserved_field: ", p), err) } - if err := oprot.WriteI32(int32(p.ReservedField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.reserved_field (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:reserved_field: ", p), err) } - return err -} - -func (p *ReservedKeyword) String() string { - if p == nil { - return "" - } - - reservedFieldVal := fmt.Sprintf("%v", p.ReservedField) - return fmt.Sprintf("ReservedKeyword({ReservedField:%s})", reservedFieldVal) -} - -// Attributes: -// - ReservedField -type UnionToBeRenamed struct { - ReservedField *int32 `thrift:"reserved_field,1,optional" db:"reserved_field" json:"reserved_field,omitempty"` -} - -func NewUnionToBeRenamed() *UnionToBeRenamed { - return &UnionToBeRenamed{} -} - -var UnionToBeRenamed_ReservedField_DEFAULT int32 -func (p *UnionToBeRenamed) GetReservedField() int32 { - if !p.IsSetReservedField() { - return UnionToBeRenamed_ReservedField_DEFAULT - } - return *p.ReservedField -} -func (p *UnionToBeRenamed) CountSetFieldsUnionToBeRenamed() int { - count := 0 - if (p.IsSetReservedField()) { - count++ - } - return count - -} - -func (p *UnionToBeRenamed) IsSetReservedField() bool { - return p != nil && p.ReservedField != nil -} - -type UnionToBeRenamedBuilder struct { - obj *UnionToBeRenamed -} - -func NewUnionToBeRenamedBuilder() *UnionToBeRenamedBuilder{ - return &UnionToBeRenamedBuilder{ - obj: NewUnionToBeRenamed(), - } -} - -func (p UnionToBeRenamedBuilder) Emit() *UnionToBeRenamed{ - return &UnionToBeRenamed{ - ReservedField: p.obj.ReservedField, - } -} - -func (u *UnionToBeRenamedBuilder) ReservedField(reservedField *int32) *UnionToBeRenamedBuilder { - u.obj.ReservedField = reservedField - return u -} - -func (u *UnionToBeRenamed) SetReservedField(reservedField *int32) *UnionToBeRenamed { - u.ReservedField = reservedField - return u -} - -func (p *UnionToBeRenamed) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *UnionToBeRenamed) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.ReservedField = &v - } - return nil -} - -func (p *UnionToBeRenamed) Write(oprot thrift.Protocol) error { - if c := p.CountSetFieldsUnionToBeRenamed(); c > 1 { - return fmt.Errorf("%T write union: no more than one field must be set (%d set).", p, c) - } - if err := oprot.WriteStructBegin("UnionToBeRenamed"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *UnionToBeRenamed) writeField1(oprot thrift.Protocol) (err error) { - if p.IsSetReservedField() { - if err := oprot.WriteFieldBegin("reserved_field", thrift.I32, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:reserved_field: ", p), err) } - if err := oprot.WriteI32(int32(*p.ReservedField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.reserved_field (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:reserved_field: ", p), err) } - } - return err -} - -func (p *UnionToBeRenamed) String() string { - if p == nil { - return "" - } - - var reservedFieldVal string - if p.ReservedField == nil { - reservedFieldVal = "" - } else { - reservedFieldVal = fmt.Sprintf("%v", *p.ReservedField) - } - return fmt.Sprintf("UnionToBeRenamed({ReservedField:%s})", reservedFieldVal) -} - diff --git a/thrift/compiler/test/fixtures/basic/gen-go/thrift/annotation/hack/constants.go b/thrift/compiler/test/fixtures/basic/gen-go/thrift/annotation/hack/constants.go deleted file mode 100644 index 4054b104418..00000000000 --- a/thrift/compiler/test/fixtures/basic/gen-go/thrift/annotation/hack/constants.go +++ /dev/null @@ -1,25 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package hack - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - - -func init() { -} - diff --git a/thrift/compiler/test/fixtures/basic/gen-go/thrift/annotation/hack/ttypes.go b/thrift/compiler/test/fixtures/basic/gen-go/thrift/annotation/hack/ttypes.go deleted file mode 100644 index 4d27cf73b43..00000000000 --- a/thrift/compiler/test/fixtures/basic/gen-go/thrift/annotation/hack/ttypes.go +++ /dev/null @@ -1,1315 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package hack - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var GoUnusedProtection__ int; - -// An experimental annotation that applies a Hack wrapper to fields. -// For example: -// -// struct User { -// @hack.FieldWrapper{name="MyWrapper"} -// 1: i64 id; -// } -// -// Attributes: -// - Name: The name of a Hack wrapper class used to wrap the field -type FieldWrapper struct { - Name string `thrift:"name,1" db:"name" json:"name"` -} - -func NewFieldWrapper() *FieldWrapper { - return &FieldWrapper{} -} - - -func (p *FieldWrapper) GetName() string { - return p.Name -} -type FieldWrapperBuilder struct { - obj *FieldWrapper -} - -func NewFieldWrapperBuilder() *FieldWrapperBuilder{ - return &FieldWrapperBuilder{ - obj: NewFieldWrapper(), - } -} - -func (p FieldWrapperBuilder) Emit() *FieldWrapper{ - return &FieldWrapper{ - Name: p.obj.Name, - } -} - -func (f *FieldWrapperBuilder) Name(name string) *FieldWrapperBuilder { - f.obj.Name = name - return f -} - -func (f *FieldWrapper) SetName(name string) *FieldWrapper { - f.Name = name - return f -} - -func (p *FieldWrapper) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *FieldWrapper) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Name = v - } - return nil -} - -func (p *FieldWrapper) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("FieldWrapper"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *FieldWrapper) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) } - if err := oprot.WriteString(string(p.Name)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) } - return err -} - -func (p *FieldWrapper) String() string { - if p == nil { - return "" - } - - nameVal := fmt.Sprintf("%v", p.Name) - return fmt.Sprintf("FieldWrapper({Name:%s})", nameVal) -} - -// An annotation that applies a Hack wrapper to fields, typedef or structs. -// For example: -// -// struct User { -// @hack.FieldWrapper{name="MyWrapper"} -// 1: i64 id; -// } -// -// Attributes: -// - Name: The name of a Hack wrapper class used to wrap the field -// - UnderlyingName: When applied directly to a typedef or struct, the IDL name of the -// type will refer to the adapted type in Hack and the underlying thrift struct will be -// generated in a nested namespace and/or with a different name. By default the type/struct -// will be generated in a nested 'thrift_adapted_types' namespace with the same name, -// but both of these can be changed by setting these fields. -// Empty string enables the nested namespace and uses the IDL name for the struct. -// - ExtraNamespace -type Wrapper struct { - Name string `thrift:"name,1" db:"name" json:"name"` - UnderlyingName string `thrift:"underlyingName,2" db:"underlyingName" json:"underlyingName"` - ExtraNamespace string `thrift:"extraNamespace,3" db:"extraNamespace" json:"extraNamespace"` -} - -func NewWrapper() *Wrapper { - return &Wrapper{ - ExtraNamespace: "thrift_adapted_types", - } -} - - -func (p *Wrapper) GetName() string { - return p.Name -} - -func (p *Wrapper) GetUnderlyingName() string { - return p.UnderlyingName -} - -func (p *Wrapper) GetExtraNamespace() string { - return p.ExtraNamespace -} -type WrapperBuilder struct { - obj *Wrapper -} - -func NewWrapperBuilder() *WrapperBuilder{ - return &WrapperBuilder{ - obj: NewWrapper(), - } -} - -func (p WrapperBuilder) Emit() *Wrapper{ - return &Wrapper{ - Name: p.obj.Name, - UnderlyingName: p.obj.UnderlyingName, - ExtraNamespace: p.obj.ExtraNamespace, - } -} - -func (w *WrapperBuilder) Name(name string) *WrapperBuilder { - w.obj.Name = name - return w -} - -func (w *WrapperBuilder) UnderlyingName(underlyingName string) *WrapperBuilder { - w.obj.UnderlyingName = underlyingName - return w -} - -func (w *WrapperBuilder) ExtraNamespace(extraNamespace string) *WrapperBuilder { - w.obj.ExtraNamespace = extraNamespace - return w -} - -func (w *Wrapper) SetName(name string) *Wrapper { - w.Name = name - return w -} - -func (w *Wrapper) SetUnderlyingName(underlyingName string) *Wrapper { - w.UnderlyingName = underlyingName - return w -} - -func (w *Wrapper) SetExtraNamespace(extraNamespace string) *Wrapper { - w.ExtraNamespace = extraNamespace - return w -} - -func (p *Wrapper) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 3: - if err := p.ReadField3(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Wrapper) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Name = v - } - return nil -} - -func (p *Wrapper) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.UnderlyingName = v - } - return nil -} - -func (p *Wrapper) ReadField3(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 3: ", err) - } else { - p.ExtraNamespace = v - } - return nil -} - -func (p *Wrapper) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Wrapper"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Wrapper) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) } - if err := oprot.WriteString(string(p.Name)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) } - return err -} - -func (p *Wrapper) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("underlyingName", thrift.STRING, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:underlyingName: ", p), err) } - if err := oprot.WriteString(string(p.UnderlyingName)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.underlyingName (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:underlyingName: ", p), err) } - return err -} - -func (p *Wrapper) writeField3(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("extraNamespace", thrift.STRING, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:extraNamespace: ", p), err) } - if err := oprot.WriteString(string(p.ExtraNamespace)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.extraNamespace (3) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:extraNamespace: ", p), err) } - return err -} - -func (p *Wrapper) String() string { - if p == nil { - return "" - } - - nameVal := fmt.Sprintf("%v", p.Name) - underlyingNameVal := fmt.Sprintf("%v", p.UnderlyingName) - extraNamespaceVal := fmt.Sprintf("%v", p.ExtraNamespace) - return fmt.Sprintf("Wrapper({Name:%s UnderlyingName:%s ExtraNamespace:%s})", nameVal, underlyingNameVal, extraNamespaceVal) -} - -// An annotation that applies a Hack adapter to types. For example: -// @hack.Adapter{name="\\TimestampAdapter"} -// typedef i64 Timestamp; -// -// struct User { -// 1: Timestamp account_creation_time; -// } -// -// Here the field `account_creation_time` will have type TimestampAdapter::THackType instead of i64. -// -// in hack: -// ``` -// final class TimestampAdapter implements IThriftAdapter { -// const type TThriftType = int; -// const type THackType = Time; -// public static function fromThrift(int $seconds)[]: Time { -// return Time::fromEpochSeconds($seconds); -// } -// public static function toThrift(Time $time): int { -// return $hack_value->asFullSecondsSinceEpoch(); -// } -// } -// ``` -// elsewhere in hack: -// ``` -// function timeSinceCreated(Document $doc): Duration { -// // $doc->created_time is of type Time -// return Duration::between(Time::now(), $doc->created_time); -// } -// ``` -// This completely replaces the underlying type of a thrift for a custom implementation and uses -// the specified adapter to convert to and from the underlying Thrift type during (de)serialization. -// -// Attributes: -// - Name: The name of a Hack adapter class that implements IThriftAdapter -type Adapter struct { - Name string `thrift:"name,1" db:"name" json:"name"` -} - -func NewAdapter() *Adapter { - return &Adapter{} -} - - -func (p *Adapter) GetName() string { - return p.Name -} -type AdapterBuilder struct { - obj *Adapter -} - -func NewAdapterBuilder() *AdapterBuilder{ - return &AdapterBuilder{ - obj: NewAdapter(), - } -} - -func (p AdapterBuilder) Emit() *Adapter{ - return &Adapter{ - Name: p.obj.Name, - } -} - -func (a *AdapterBuilder) Name(name string) *AdapterBuilder { - a.obj.Name = name - return a -} - -func (a *Adapter) SetName(name string) *Adapter { - a.Name = name - return a -} - -func (p *Adapter) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Adapter) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Name = v - } - return nil -} - -func (p *Adapter) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Adapter"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Adapter) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) } - if err := oprot.WriteString(string(p.Name)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) } - return err -} - -func (p *Adapter) String() string { - if p == nil { - return "" - } - - nameVal := fmt.Sprintf("%v", p.Name) - return fmt.Sprintf("Adapter({Name:%s})", nameVal) -} - -// Attributes: -// - Reason -type SkipCodegen struct { - Reason string `thrift:"reason,1" db:"reason" json:"reason"` -} - -func NewSkipCodegen() *SkipCodegen { - return &SkipCodegen{} -} - - -func (p *SkipCodegen) GetReason() string { - return p.Reason -} -type SkipCodegenBuilder struct { - obj *SkipCodegen -} - -func NewSkipCodegenBuilder() *SkipCodegenBuilder{ - return &SkipCodegenBuilder{ - obj: NewSkipCodegen(), - } -} - -func (p SkipCodegenBuilder) Emit() *SkipCodegen{ - return &SkipCodegen{ - Reason: p.obj.Reason, - } -} - -func (s *SkipCodegenBuilder) Reason(reason string) *SkipCodegenBuilder { - s.obj.Reason = reason - return s -} - -func (s *SkipCodegen) SetReason(reason string) *SkipCodegen { - s.Reason = reason - return s -} - -func (p *SkipCodegen) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *SkipCodegen) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Reason = v - } - return nil -} - -func (p *SkipCodegen) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("SkipCodegen"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *SkipCodegen) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("reason", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:reason: ", p), err) } - if err := oprot.WriteString(string(p.Reason)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.reason (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:reason: ", p), err) } - return err -} - -func (p *SkipCodegen) String() string { - if p == nil { - return "" - } - - reasonVal := fmt.Sprintf("%v", p.Reason) - return fmt.Sprintf("SkipCodegen({Reason:%s})", reasonVal) -} - -// This annotation is mainly used to rename symbols which can result in symbol -// conflict errors in Hack codegen. -// For ex: reserved keywords in Hack language, symbols with similar names from -// other files in Hack -// -// Attributes: -// - Name -// - Reason -type Name struct { - Name string `thrift:"name,1" db:"name" json:"name"` - Reason string `thrift:"reason,2" db:"reason" json:"reason"` -} - -func NewName() *Name { - return &Name{} -} - - -func (p *Name) GetName() string { - return p.Name -} - -func (p *Name) GetReason() string { - return p.Reason -} -type NameBuilder struct { - obj *Name -} - -func NewNameBuilder() *NameBuilder{ - return &NameBuilder{ - obj: NewName(), - } -} - -func (p NameBuilder) Emit() *Name{ - return &Name{ - Name: p.obj.Name, - Reason: p.obj.Reason, - } -} - -func (n *NameBuilder) Name(name string) *NameBuilder { - n.obj.Name = name - return n -} - -func (n *NameBuilder) Reason(reason string) *NameBuilder { - n.obj.Reason = reason - return n -} - -func (n *Name) SetName(name string) *Name { - n.Name = name - return n -} - -func (n *Name) SetReason(reason string) *Name { - n.Reason = reason - return n -} - -func (p *Name) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Name) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Name = v - } - return nil -} - -func (p *Name) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Reason = v - } - return nil -} - -func (p *Name) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Name"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Name) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) } - if err := oprot.WriteString(string(p.Name)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) } - return err -} - -func (p *Name) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("reason", thrift.STRING, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:reason: ", p), err) } - if err := oprot.WriteString(string(p.Reason)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.reason (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:reason: ", p), err) } - return err -} - -func (p *Name) String() string { - if p == nil { - return "" - } - - nameVal := fmt.Sprintf("%v", p.Name) - reasonVal := fmt.Sprintf("%v", p.Reason) - return fmt.Sprintf("Name({Name:%s Reason:%s})", nameVal, reasonVal) -} - -// This annotation is for adding Hack attributes to union enums. -// -// Attributes: -// - Attributes -type UnionEnumAttributes struct { - Attributes []string `thrift:"attributes,1" db:"attributes" json:"attributes"` -} - -func NewUnionEnumAttributes() *UnionEnumAttributes { - return &UnionEnumAttributes{} -} - - -func (p *UnionEnumAttributes) GetAttributes() []string { - return p.Attributes -} -type UnionEnumAttributesBuilder struct { - obj *UnionEnumAttributes -} - -func NewUnionEnumAttributesBuilder() *UnionEnumAttributesBuilder{ - return &UnionEnumAttributesBuilder{ - obj: NewUnionEnumAttributes(), - } -} - -func (p UnionEnumAttributesBuilder) Emit() *UnionEnumAttributes{ - return &UnionEnumAttributes{ - Attributes: p.obj.Attributes, - } -} - -func (u *UnionEnumAttributesBuilder) Attributes(attributes []string) *UnionEnumAttributesBuilder { - u.obj.Attributes = attributes - return u -} - -func (u *UnionEnumAttributes) SetAttributes(attributes []string) *UnionEnumAttributes { - u.Attributes = attributes - return u -} - -func (p *UnionEnumAttributes) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *UnionEnumAttributes) ReadField1(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]string, 0, size) - p.Attributes = tSlice - for i := 0; i < size; i ++ { - var _elem0 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem0 = v - } - p.Attributes = append(p.Attributes, _elem0) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *UnionEnumAttributes) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("UnionEnumAttributes"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *UnionEnumAttributes) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("attributes", thrift.LIST, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:attributes: ", p), err) } - if err := oprot.WriteListBegin(thrift.STRING, len(p.Attributes)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.Attributes { - if err := oprot.WriteString(string(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:attributes: ", p), err) } - return err -} - -func (p *UnionEnumAttributes) String() string { - if p == nil { - return "" - } - - attributesVal := fmt.Sprintf("%v", p.Attributes) - return fmt.Sprintf("UnionEnumAttributes({Attributes:%s})", attributesVal) -} - -// This annotation is for using a custom trait for structs. -// -// Attributes: -// - Name -type StructTrait struct { - Name string `thrift:"name,1" db:"name" json:"name"` -} - -func NewStructTrait() *StructTrait { - return &StructTrait{} -} - - -func (p *StructTrait) GetName() string { - return p.Name -} -type StructTraitBuilder struct { - obj *StructTrait -} - -func NewStructTraitBuilder() *StructTraitBuilder{ - return &StructTraitBuilder{ - obj: NewStructTrait(), - } -} - -func (p StructTraitBuilder) Emit() *StructTrait{ - return &StructTrait{ - Name: p.obj.Name, - } -} - -func (s *StructTraitBuilder) Name(name string) *StructTraitBuilder { - s.obj.Name = name - return s -} - -func (s *StructTrait) SetName(name string) *StructTrait { - s.Name = name - return s -} - -func (p *StructTrait) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *StructTrait) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Name = v - } - return nil -} - -func (p *StructTrait) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("StructTrait"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *StructTrait) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) } - if err := oprot.WriteString(string(p.Name)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) } - return err -} - -func (p *StructTrait) String() string { - if p == nil { - return "" - } - - nameVal := fmt.Sprintf("%v", p.Name) - return fmt.Sprintf("StructTrait({Name:%s})", nameVal) -} - -// This annotation is for adding Hack attributes. -// * Where to use: field or struct type -// * Value: add attributes like `JSEnum` to structs or fields -// * Example: -// -// ``` -// // In thrift -// enum MyEnum { -// ALLOWED = 1, -// THIS_IS_ALLOWED = 2, -// THIS_IS_ALLOWED_2 = 3, -// }( -// hack.attributes= -// "\JSEnum(shape('name' => 'MyEnum')), -// \GraphQLEnum('MyEnum', 'Description for my enum',)" -// ) -// struct MyThriftStruct { -// 1: string foo (hack.attributes = "FieldAttribute"); -// 2: string bar; -// 3: string baz; -// } (hack.attributes = "ClassAttribute") -// ``` -// ``` -// //thrift compiler will generate this for you -// <<\JSEnum(shape('name' => 'MyEnum')), -// \GraphQLEnum('MyEnum', 'Description for my enum',)>> -// enum MyEnum: int { -// ALLOWED = 1; -// THIS_IS_ALLOWED = 2; -// THIS_IS_ALLOWED_2 = 3; -// } -// <> -// class MyThriftStruct implements \IThriftStruct { -// .... -// <> -// public string $foo; -// .... -// } -// ``` -// -// Attributes: -// - Attributes -type Attributes struct { - Attributes []string `thrift:"attributes,1" db:"attributes" json:"attributes"` -} - -func NewAttributes() *Attributes { - return &Attributes{} -} - - -func (p *Attributes) GetAttributes() []string { - return p.Attributes -} -type AttributesBuilder struct { - obj *Attributes -} - -func NewAttributesBuilder() *AttributesBuilder{ - return &AttributesBuilder{ - obj: NewAttributes(), - } -} - -func (p AttributesBuilder) Emit() *Attributes{ - return &Attributes{ - Attributes: p.obj.Attributes, - } -} - -func (a *AttributesBuilder) Attributes(attributes []string) *AttributesBuilder { - a.obj.Attributes = attributes - return a -} - -func (a *Attributes) SetAttributes(attributes []string) *Attributes { - a.Attributes = attributes - return a -} - -func (p *Attributes) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Attributes) ReadField1(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]string, 0, size) - p.Attributes = tSlice - for i := 0; i < size; i ++ { - var _elem1 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem1 = v - } - p.Attributes = append(p.Attributes, _elem1) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *Attributes) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Attributes"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Attributes) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("attributes", thrift.LIST, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:attributes: ", p), err) } - if err := oprot.WriteListBegin(thrift.STRING, len(p.Attributes)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.Attributes { - if err := oprot.WriteString(string(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:attributes: ", p), err) } - return err -} - -func (p *Attributes) String() string { - if p == nil { - return "" - } - - attributesVal := fmt.Sprintf("%v", p.Attributes) - return fmt.Sprintf("Attributes({Attributes:%s})", attributesVal) -} - -type StructAsTrait struct { -} - -func NewStructAsTrait() *StructAsTrait { - return &StructAsTrait{} -} - -type StructAsTraitBuilder struct { - obj *StructAsTrait -} - -func NewStructAsTraitBuilder() *StructAsTraitBuilder{ - return &StructAsTraitBuilder{ - obj: NewStructAsTrait(), - } -} - -func (p StructAsTraitBuilder) Emit() *StructAsTrait{ - return &StructAsTrait{ - } -} - -func (p *StructAsTrait) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *StructAsTrait) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("StructAsTrait"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *StructAsTrait) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("StructAsTrait({})") -} - -// This annotation is to generate an entity as internal -type ModuleInternal struct { -} - -func NewModuleInternal() *ModuleInternal { - return &ModuleInternal{} -} - -type ModuleInternalBuilder struct { - obj *ModuleInternal -} - -func NewModuleInternalBuilder() *ModuleInternalBuilder{ - return &ModuleInternalBuilder{ - obj: NewModuleInternal(), - } -} - -func (p ModuleInternalBuilder) Emit() *ModuleInternal{ - return &ModuleInternal{ - } -} - -func (p *ModuleInternal) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ModuleInternal) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("ModuleInternal"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *ModuleInternal) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("ModuleInternal({})") -} - diff --git a/thrift/compiler/test/fixtures/basic/gen-go/thrift/annotation/scope/constants.go b/thrift/compiler/test/fixtures/basic/gen-go/thrift/annotation/scope/constants.go deleted file mode 100644 index 0c3448a7126..00000000000 --- a/thrift/compiler/test/fixtures/basic/gen-go/thrift/annotation/scope/constants.go +++ /dev/null @@ -1,25 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package scope - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - - -func init() { -} - diff --git a/thrift/compiler/test/fixtures/basic/gen-go/thrift/annotation/scope/ttypes.go b/thrift/compiler/test/fixtures/basic/gen-go/thrift/annotation/scope/ttypes.go deleted file mode 100644 index 580c39e775c..00000000000 --- a/thrift/compiler/test/fixtures/basic/gen-go/thrift/annotation/scope/ttypes.go +++ /dev/null @@ -1,1169 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package scope - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var GoUnusedProtection__ int; - -// Indicates that the scope of sibling annotations is transitive. -// -// For example: -// -// @scope.Struct -// @scope.Union -// @scope.Exception -// @scope.Transitive -// struct Structured {} -// -// Annotating a Thrift struct with @Structured automatically applies -// @scope.Struct, @scope.Union and @scope.Exception annotations, i.e. -// -// @Structured -// struct MyAnnotation {} -// -// is equivalent to -// -// @scope.Struct -// @scope.Union -// @scope.Exception -// struct MyAnnotation {} -// -type Transitive struct { -} - -func NewTransitive() *Transitive { - return &Transitive{} -} - -type TransitiveBuilder struct { - obj *Transitive -} - -func NewTransitiveBuilder() *TransitiveBuilder{ - return &TransitiveBuilder{ - obj: NewTransitive(), - } -} - -func (p TransitiveBuilder) Emit() *Transitive{ - return &Transitive{ - } -} - -func (p *Transitive) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Transitive) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Transitive"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Transitive) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Transitive({})") -} - -// The Program scope. -// -// This allows annotations on the `package` definition, which implies the -// annotaiton applies to the entire program. -type Program struct { -} - -func NewProgram() *Program { - return &Program{} -} - -type ProgramBuilder struct { - obj *Program -} - -func NewProgramBuilder() *ProgramBuilder{ - return &ProgramBuilder{ - obj: NewProgram(), - } -} - -func (p ProgramBuilder) Emit() *Program{ - return &Program{ - } -} - -func (p *Program) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Program) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Program"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Program) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Program({})") -} - -// The `struct` definition scope. -type Struct struct { -} - -func NewStruct() *Struct { - return &Struct{} -} - -type StructBuilder struct { - obj *Struct -} - -func NewStructBuilder() *StructBuilder{ - return &StructBuilder{ - obj: NewStruct(), - } -} - -func (p StructBuilder) Emit() *Struct{ - return &Struct{ - } -} - -func (p *Struct) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Struct) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Struct"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Struct) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Struct({})") -} - -// The `union` definition scope. -type Union struct { -} - -func NewUnion() *Union { - return &Union{} -} - -type UnionBuilder struct { - obj *Union -} - -func NewUnionBuilder() *UnionBuilder{ - return &UnionBuilder{ - obj: NewUnion(), - } -} - -func (p UnionBuilder) Emit() *Union{ - return &Union{ - } -} - -func (p *Union) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Union) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Union"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Union) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Union({})") -} - -// The `exception` definition scope. -type Exception struct { -} - -func NewException() *Exception { - return &Exception{} -} - -type ExceptionBuilder struct { - obj *Exception -} - -func NewExceptionBuilder() *ExceptionBuilder{ - return &ExceptionBuilder{ - obj: NewException(), - } -} - -func (p ExceptionBuilder) Emit() *Exception{ - return &Exception{ - } -} - -func (p *Exception) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Exception) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Exception"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Exception) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Exception({})") -} - -// Field declartaions, for example in `struct` or `function` declartions. -type Field struct { -} - -func NewField() *Field { - return &Field{} -} - -type FieldBuilder struct { - obj *Field -} - -func NewFieldBuilder() *FieldBuilder{ - return &FieldBuilder{ - obj: NewField(), - } -} - -func (p FieldBuilder) Emit() *Field{ - return &Field{ - } -} - -func (p *Field) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Field) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Field"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Field) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Field({})") -} - -// The `typedef` definition scope. -type Typedef struct { -} - -func NewTypedef() *Typedef { - return &Typedef{} -} - -type TypedefBuilder struct { - obj *Typedef -} - -func NewTypedefBuilder() *TypedefBuilder{ - return &TypedefBuilder{ - obj: NewTypedef(), - } -} - -func (p TypedefBuilder) Emit() *Typedef{ - return &Typedef{ - } -} - -func (p *Typedef) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Typedef) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Typedef"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Typedef) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Typedef({})") -} - -// The `service` definition scope. -type Service struct { -} - -func NewService() *Service { - return &Service{} -} - -type ServiceBuilder struct { - obj *Service -} - -func NewServiceBuilder() *ServiceBuilder{ - return &ServiceBuilder{ - obj: NewService(), - } -} - -func (p ServiceBuilder) Emit() *Service{ - return &Service{ - } -} - -func (p *Service) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Service) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Service"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Service) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Service({})") -} - -// The `interaction` definition scope. -type Interaction struct { -} - -func NewInteraction() *Interaction { - return &Interaction{} -} - -type InteractionBuilder struct { - obj *Interaction -} - -func NewInteractionBuilder() *InteractionBuilder{ - return &InteractionBuilder{ - obj: NewInteraction(), - } -} - -func (p InteractionBuilder) Emit() *Interaction{ - return &Interaction{ - } -} - -func (p *Interaction) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Interaction) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Interaction"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Interaction) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Interaction({})") -} - -// The `function` definition scope. -type Function struct { -} - -func NewFunction() *Function { - return &Function{} -} - -type FunctionBuilder struct { - obj *Function -} - -func NewFunctionBuilder() *FunctionBuilder{ - return &FunctionBuilder{ - obj: NewFunction(), - } -} - -func (p FunctionBuilder) Emit() *Function{ - return &Function{ - } -} - -func (p *Function) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Function) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Function"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Function) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Function({})") -} - -// The Enum value definition scope. -type EnumValue struct { -} - -func NewEnumValue() *EnumValue { - return &EnumValue{} -} - -type EnumValueBuilder struct { - obj *EnumValue -} - -func NewEnumValueBuilder() *EnumValueBuilder{ - return &EnumValueBuilder{ - obj: NewEnumValue(), - } -} - -func (p EnumValueBuilder) Emit() *EnumValue{ - return &EnumValue{ - } -} - -func (p *EnumValue) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *EnumValue) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("EnumValue"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *EnumValue) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("EnumValue({})") -} - -// The `const` definition scope. -type Const struct { -} - -func NewConst() *Const { - return &Const{} -} - -type ConstBuilder struct { - obj *Const -} - -func NewConstBuilder() *ConstBuilder{ - return &ConstBuilder{ - obj: NewConst(), - } -} - -func (p ConstBuilder) Emit() *Const{ - return &Const{ - } -} - -func (p *Const) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Const) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Const"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Const) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Const({})") -} - -type Enum struct { -} - -func NewEnum() *Enum { - return &Enum{} -} - -type EnumBuilder struct { - obj *Enum -} - -func NewEnumBuilder() *EnumBuilder{ - return &EnumBuilder{ - obj: NewEnum(), - } -} - -func (p EnumBuilder) Emit() *Enum{ - return &Enum{ - } -} - -func (p *Enum) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Enum) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Enum"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Enum) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Enum({})") -} - -// A scope that includes all 'structured' definitions. -type Structured struct { -} - -func NewStructured() *Structured { - return &Structured{} -} - -type StructuredBuilder struct { - obj *Structured -} - -func NewStructuredBuilder() *StructuredBuilder{ - return &StructuredBuilder{ - obj: NewStructured(), - } -} - -func (p StructuredBuilder) Emit() *Structured{ - return &Structured{ - } -} - -func (p *Structured) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Structured) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Structured"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Structured) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Structured({})") -} - -// A scope that includes all 'interface' definitions. -type Interface struct { -} - -func NewInterface() *Interface { - return &Interface{} -} - -type InterfaceBuilder struct { - obj *Interface -} - -func NewInterfaceBuilder() *InterfaceBuilder{ - return &InterfaceBuilder{ - obj: NewInterface(), - } -} - -func (p InterfaceBuilder) Emit() *Interface{ - return &Interface{ - } -} - -func (p *Interface) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Interface) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Interface"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Interface) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Interface({})") -} - -// A scope that includes all program-scoped definition. -type RootDefinition struct { -} - -func NewRootDefinition() *RootDefinition { - return &RootDefinition{} -} - -type RootDefinitionBuilder struct { - obj *RootDefinition -} - -func NewRootDefinitionBuilder() *RootDefinitionBuilder{ - return &RootDefinitionBuilder{ - obj: NewRootDefinition(), - } -} - -func (p RootDefinitionBuilder) Emit() *RootDefinition{ - return &RootDefinition{ - } -} - -func (p *RootDefinition) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *RootDefinition) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("RootDefinition"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *RootDefinition) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("RootDefinition({})") -} - -// A scope that includes all definitions. -type Definition struct { -} - -func NewDefinition() *Definition { - return &Definition{} -} - -type DefinitionBuilder struct { - obj *Definition -} - -func NewDefinitionBuilder() *DefinitionBuilder{ - return &DefinitionBuilder{ - obj: NewDefinition(), - } -} - -func (p DefinitionBuilder) Emit() *Definition{ - return &Definition{ - } -} - -func (p *Definition) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Definition) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Definition"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Definition) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Definition({})") -} - diff --git a/thrift/compiler/test/fixtures/complex-union/gen-go/module/constants.go b/thrift/compiler/test/fixtures/complex-union/gen-go/module/constants.go deleted file mode 100644 index 477cf91a64b..00000000000 --- a/thrift/compiler/test/fixtures/complex-union/gen-go/module/constants.go +++ /dev/null @@ -1,25 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package module - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - - -func init() { -} - diff --git a/thrift/compiler/test/fixtures/complex-union/gen-go/module/ttypes.go b/thrift/compiler/test/fixtures/complex-union/gen-go/module/ttypes.go deleted file mode 100644 index 674f37b84c3..00000000000 --- a/thrift/compiler/test/fixtures/complex-union/gen-go/module/ttypes.go +++ /dev/null @@ -1,1794 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package module - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var GoUnusedProtection__ int; - -type ContainerTypedef = map[int16]string - -func ContainerTypedefPtr(v ContainerTypedef) *ContainerTypedef { return &v } - -// Attributes: -// - IntValue -// - StringValue -// - IntListValue -// - StringListValue -// - TypedefValue -// - StringRef -type ComplexUnion struct { - IntValue *int64 `thrift:"intValue,1,optional" db:"intValue" json:"intValue,omitempty"` - IntListValue []int64 `thrift:"intListValue,2,optional" db:"intListValue" json:"intListValue,omitempty"` - StringListValue []string `thrift:"stringListValue,3,optional" db:"stringListValue" json:"stringListValue,omitempty"` - // unused field # 4 - StringValue *string `thrift:"stringValue,5,optional" db:"stringValue" json:"stringValue,omitempty"` - // unused fields # 6 to 8 - TypedefValue ContainerTypedef `thrift:"typedefValue,9,optional" db:"typedefValue" json:"typedefValue,omitempty"` - // unused fields # 10 to 13 - StringRef *string `thrift:"stringRef,14,optional" db:"stringRef" json:"stringRef,omitempty"` -} - -func NewComplexUnion() *ComplexUnion { - return &ComplexUnion{} -} - -var ComplexUnion_IntValue_DEFAULT int64 -func (p *ComplexUnion) GetIntValue() int64 { - if !p.IsSetIntValue() { - return ComplexUnion_IntValue_DEFAULT - } - return *p.IntValue -} -var ComplexUnion_StringValue_DEFAULT string -func (p *ComplexUnion) GetStringValue() string { - if !p.IsSetStringValue() { - return ComplexUnion_StringValue_DEFAULT - } - return *p.StringValue -} -var ComplexUnion_IntListValue_DEFAULT []int64 - -func (p *ComplexUnion) GetIntListValue() []int64 { - return p.IntListValue -} -var ComplexUnion_StringListValue_DEFAULT []string - -func (p *ComplexUnion) GetStringListValue() []string { - return p.StringListValue -} -var ComplexUnion_TypedefValue_DEFAULT ContainerTypedef - -func (p *ComplexUnion) GetTypedefValue() ContainerTypedef { - return p.TypedefValue -} -var ComplexUnion_StringRef_DEFAULT string -func (p *ComplexUnion) GetStringRef() string { - if !p.IsSetStringRef() { - return ComplexUnion_StringRef_DEFAULT - } - return *p.StringRef -} -func (p *ComplexUnion) CountSetFieldsComplexUnion() int { - count := 0 - if (p.IsSetIntValue()) { - count++ - } - if (p.IsSetStringValue()) { - count++ - } - if (p.IsSetIntListValue()) { - count++ - } - if (p.IsSetStringListValue()) { - count++ - } - if (p.IsSetTypedefValue()) { - count++ - } - if (p.IsSetStringRef()) { - count++ - } - return count - -} - -func (p *ComplexUnion) IsSetIntValue() bool { - return p != nil && p.IntValue != nil -} - -func (p *ComplexUnion) IsSetStringValue() bool { - return p != nil && p.StringValue != nil -} - -func (p *ComplexUnion) IsSetIntListValue() bool { - return p != nil && p.IntListValue != nil -} - -func (p *ComplexUnion) IsSetStringListValue() bool { - return p != nil && p.StringListValue != nil -} - -func (p *ComplexUnion) IsSetTypedefValue() bool { - return p != nil && p.TypedefValue != nil -} - -func (p *ComplexUnion) IsSetStringRef() bool { - return p != nil && p.StringRef != nil -} - -type ComplexUnionBuilder struct { - obj *ComplexUnion -} - -func NewComplexUnionBuilder() *ComplexUnionBuilder{ - return &ComplexUnionBuilder{ - obj: NewComplexUnion(), - } -} - -func (p ComplexUnionBuilder) Emit() *ComplexUnion{ - return &ComplexUnion{ - IntValue: p.obj.IntValue, - StringValue: p.obj.StringValue, - IntListValue: p.obj.IntListValue, - StringListValue: p.obj.StringListValue, - TypedefValue: p.obj.TypedefValue, - StringRef: p.obj.StringRef, - } -} - -func (c *ComplexUnionBuilder) IntValue(intValue *int64) *ComplexUnionBuilder { - c.obj.IntValue = intValue - return c -} - -func (c *ComplexUnionBuilder) StringValue(stringValue *string) *ComplexUnionBuilder { - c.obj.StringValue = stringValue - return c -} - -func (c *ComplexUnionBuilder) IntListValue(intListValue []int64) *ComplexUnionBuilder { - c.obj.IntListValue = intListValue - return c -} - -func (c *ComplexUnionBuilder) StringListValue(stringListValue []string) *ComplexUnionBuilder { - c.obj.StringListValue = stringListValue - return c -} - -func (c *ComplexUnionBuilder) TypedefValue(typedefValue ContainerTypedef) *ComplexUnionBuilder { - c.obj.TypedefValue = typedefValue - return c -} - -func (c *ComplexUnionBuilder) StringRef(stringRef *string) *ComplexUnionBuilder { - c.obj.StringRef = stringRef - return c -} - -func (c *ComplexUnion) SetIntValue(intValue *int64) *ComplexUnion { - c.IntValue = intValue - return c -} - -func (c *ComplexUnion) SetStringValue(stringValue *string) *ComplexUnion { - c.StringValue = stringValue - return c -} - -func (c *ComplexUnion) SetIntListValue(intListValue []int64) *ComplexUnion { - c.IntListValue = intListValue - return c -} - -func (c *ComplexUnion) SetStringListValue(stringListValue []string) *ComplexUnion { - c.StringListValue = stringListValue - return c -} - -func (c *ComplexUnion) SetTypedefValue(typedefValue ContainerTypedef) *ComplexUnion { - c.TypedefValue = typedefValue - return c -} - -func (c *ComplexUnion) SetStringRef(stringRef *string) *ComplexUnion { - c.StringRef = stringRef - return c -} - -func (p *ComplexUnion) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 5: - if err := p.ReadField5(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 3: - if err := p.ReadField3(iprot); err != nil { - return err - } - case 9: - if err := p.ReadField9(iprot); err != nil { - return err - } - case 14: - if err := p.ReadField14(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ComplexUnion) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.IntValue = &v - } - return nil -} - -func (p *ComplexUnion) ReadField5(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 5: ", err) - } else { - p.StringValue = &v - } - return nil -} - -func (p *ComplexUnion) ReadField2(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]int64, 0, size) - p.IntListValue = tSlice - for i := 0; i < size; i ++ { - var _elem0 int64 - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem0 = v - } - p.IntListValue = append(p.IntListValue, _elem0) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *ComplexUnion) ReadField3(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]string, 0, size) - p.StringListValue = tSlice - for i := 0; i < size; i ++ { - var _elem1 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem1 = v - } - p.StringListValue = append(p.StringListValue, _elem1) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *ComplexUnion) ReadField9(iprot thrift.Protocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(ContainerTypedef, size) - p.TypedefValue = tMap - for i := 0; i < size; i ++ { - var _key2 int16 - if v, err := iprot.ReadI16(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key2 = v - } - var _val3 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _val3 = v - } - p.TypedefValue[_key2] = _val3 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *ComplexUnion) ReadField14(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 14: ", err) - } else { - p.StringRef = &v - } - return nil -} - -func (p *ComplexUnion) Write(oprot thrift.Protocol) error { - if c := p.CountSetFieldsComplexUnion(); c > 1 { - return fmt.Errorf("%T write union: no more than one field must be set (%d set).", p, c) - } - if err := oprot.WriteStructBegin("ComplexUnion"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := p.writeField5(oprot); err != nil { return err } - if err := p.writeField9(oprot); err != nil { return err } - if err := p.writeField14(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *ComplexUnion) writeField1(oprot thrift.Protocol) (err error) { - if p.IsSetIntValue() { - if err := oprot.WriteFieldBegin("intValue", thrift.I64, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:intValue: ", p), err) } - if err := oprot.WriteI64(int64(*p.IntValue)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.intValue (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:intValue: ", p), err) } - } - return err -} - -func (p *ComplexUnion) writeField2(oprot thrift.Protocol) (err error) { - if p.IsSetIntListValue() { - if err := oprot.WriteFieldBegin("intListValue", thrift.LIST, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:intListValue: ", p), err) } - if err := oprot.WriteListBegin(thrift.I64, len(p.IntListValue)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.IntListValue { - if err := oprot.WriteI64(int64(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:intListValue: ", p), err) } - } - return err -} - -func (p *ComplexUnion) writeField3(oprot thrift.Protocol) (err error) { - if p.IsSetStringListValue() { - if err := oprot.WriteFieldBegin("stringListValue", thrift.LIST, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:stringListValue: ", p), err) } - if err := oprot.WriteListBegin(thrift.STRING, len(p.StringListValue)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.StringListValue { - if err := oprot.WriteString(string(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:stringListValue: ", p), err) } - } - return err -} - -func (p *ComplexUnion) writeField5(oprot thrift.Protocol) (err error) { - if p.IsSetStringValue() { - if err := oprot.WriteFieldBegin("stringValue", thrift.STRING, 5); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:stringValue: ", p), err) } - if err := oprot.WriteString(string(*p.StringValue)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.stringValue (5) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 5:stringValue: ", p), err) } - } - return err -} - -func (p *ComplexUnion) writeField9(oprot thrift.Protocol) (err error) { - if p.IsSetTypedefValue() { - if err := oprot.WriteFieldBegin("typedefValue", thrift.MAP, 9); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 9:typedefValue: ", p), err) } - if err := oprot.WriteMapBegin(thrift.I16, thrift.STRING, len(p.TypedefValue)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.TypedefValue { - if err := oprot.WriteI16(int16(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := oprot.WriteString(string(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 9:typedefValue: ", p), err) } - } - return err -} - -func (p *ComplexUnion) writeField14(oprot thrift.Protocol) (err error) { - if p.IsSetStringRef() { - if err := oprot.WriteFieldBegin("stringRef", thrift.STRING, 14); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 14:stringRef: ", p), err) } - if err := oprot.WriteString(string(*p.StringRef)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.stringRef (14) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 14:stringRef: ", p), err) } - } - return err -} - -func (p *ComplexUnion) String() string { - if p == nil { - return "" - } - - var intValueVal string - if p.IntValue == nil { - intValueVal = "" - } else { - intValueVal = fmt.Sprintf("%v", *p.IntValue) - } - intListValueVal := fmt.Sprintf("%v", p.IntListValue) - stringListValueVal := fmt.Sprintf("%v", p.StringListValue) - var stringValueVal string - if p.StringValue == nil { - stringValueVal = "" - } else { - stringValueVal = fmt.Sprintf("%v", *p.StringValue) - } - typedefValueVal := fmt.Sprintf("%v", p.TypedefValue) - var stringRefVal string - if p.StringRef == nil { - stringRefVal = "" - } else { - stringRefVal = fmt.Sprintf("%v", *p.StringRef) - } - return fmt.Sprintf("ComplexUnion({IntValue:%s IntListValue:%s StringListValue:%s StringValue:%s TypedefValue:%s StringRef:%s})", intValueVal, intListValueVal, stringListValueVal, stringValueVal, typedefValueVal, stringRefVal) -} - -// Attributes: -// - IntListValue -// - StringListValue -type ListUnion struct { - // unused field # 1 - IntListValue []int64 `thrift:"intListValue,2,optional" db:"intListValue" json:"intListValue,omitempty"` - StringListValue []string `thrift:"stringListValue,3,optional" db:"stringListValue" json:"stringListValue,omitempty"` -} - -func NewListUnion() *ListUnion { - return &ListUnion{} -} - -var ListUnion_IntListValue_DEFAULT []int64 - -func (p *ListUnion) GetIntListValue() []int64 { - return p.IntListValue -} -var ListUnion_StringListValue_DEFAULT []string - -func (p *ListUnion) GetStringListValue() []string { - return p.StringListValue -} -func (p *ListUnion) IsSetIntListValue() bool { - return p != nil && p.IntListValue != nil -} - -func (p *ListUnion) IsSetStringListValue() bool { - return p != nil && p.StringListValue != nil -} - -type ListUnionBuilder struct { - obj *ListUnion -} - -func NewListUnionBuilder() *ListUnionBuilder{ - return &ListUnionBuilder{ - obj: NewListUnion(), - } -} - -func (p ListUnionBuilder) Emit() *ListUnion{ - return &ListUnion{ - IntListValue: p.obj.IntListValue, - StringListValue: p.obj.StringListValue, - } -} - -func (l *ListUnionBuilder) IntListValue(intListValue []int64) *ListUnionBuilder { - l.obj.IntListValue = intListValue - return l -} - -func (l *ListUnionBuilder) StringListValue(stringListValue []string) *ListUnionBuilder { - l.obj.StringListValue = stringListValue - return l -} - -func (l *ListUnion) SetIntListValue(intListValue []int64) *ListUnion { - l.IntListValue = intListValue - return l -} - -func (l *ListUnion) SetStringListValue(stringListValue []string) *ListUnion { - l.StringListValue = stringListValue - return l -} - -func (p *ListUnion) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 3: - if err := p.ReadField3(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ListUnion) ReadField2(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]int64, 0, size) - p.IntListValue = tSlice - for i := 0; i < size; i ++ { - var _elem4 int64 - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem4 = v - } - p.IntListValue = append(p.IntListValue, _elem4) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *ListUnion) ReadField3(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]string, 0, size) - p.StringListValue = tSlice - for i := 0; i < size; i ++ { - var _elem5 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem5 = v - } - p.StringListValue = append(p.StringListValue, _elem5) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *ListUnion) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("ListUnion"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *ListUnion) writeField2(oprot thrift.Protocol) (err error) { - if p.IsSetIntListValue() { - if err := oprot.WriteFieldBegin("intListValue", thrift.LIST, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:intListValue: ", p), err) } - if err := oprot.WriteListBegin(thrift.I64, len(p.IntListValue)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.IntListValue { - if err := oprot.WriteI64(int64(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:intListValue: ", p), err) } - } - return err -} - -func (p *ListUnion) writeField3(oprot thrift.Protocol) (err error) { - if p.IsSetStringListValue() { - if err := oprot.WriteFieldBegin("stringListValue", thrift.LIST, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:stringListValue: ", p), err) } - if err := oprot.WriteListBegin(thrift.STRING, len(p.StringListValue)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.StringListValue { - if err := oprot.WriteString(string(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:stringListValue: ", p), err) } - } - return err -} - -func (p *ListUnion) String() string { - if p == nil { - return "" - } - - intListValueVal := fmt.Sprintf("%v", p.IntListValue) - stringListValueVal := fmt.Sprintf("%v", p.StringListValue) - return fmt.Sprintf("ListUnion({IntListValue:%s StringListValue:%s})", intListValueVal, stringListValueVal) -} - -// Attributes: -// - BinaryData -// - StringData -type DataUnion struct { - BinaryData []byte `thrift:"binaryData,1,optional" db:"binaryData" json:"binaryData,omitempty"` - StringData *string `thrift:"stringData,2,optional" db:"stringData" json:"stringData,omitempty"` -} - -func NewDataUnion() *DataUnion { - return &DataUnion{} -} - -var DataUnion_BinaryData_DEFAULT []byte - -func (p *DataUnion) GetBinaryData() []byte { - return p.BinaryData -} -var DataUnion_StringData_DEFAULT string -func (p *DataUnion) GetStringData() string { - if !p.IsSetStringData() { - return DataUnion_StringData_DEFAULT - } - return *p.StringData -} -func (p *DataUnion) CountSetFieldsDataUnion() int { - count := 0 - if (p.IsSetBinaryData()) { - count++ - } - if (p.IsSetStringData()) { - count++ - } - return count - -} - -func (p *DataUnion) IsSetBinaryData() bool { - return p != nil && p.BinaryData != nil -} - -func (p *DataUnion) IsSetStringData() bool { - return p != nil && p.StringData != nil -} - -type DataUnionBuilder struct { - obj *DataUnion -} - -func NewDataUnionBuilder() *DataUnionBuilder{ - return &DataUnionBuilder{ - obj: NewDataUnion(), - } -} - -func (p DataUnionBuilder) Emit() *DataUnion{ - return &DataUnion{ - BinaryData: p.obj.BinaryData, - StringData: p.obj.StringData, - } -} - -func (d *DataUnionBuilder) BinaryData(binaryData []byte) *DataUnionBuilder { - d.obj.BinaryData = binaryData - return d -} - -func (d *DataUnionBuilder) StringData(stringData *string) *DataUnionBuilder { - d.obj.StringData = stringData - return d -} - -func (d *DataUnion) SetBinaryData(binaryData []byte) *DataUnion { - d.BinaryData = binaryData - return d -} - -func (d *DataUnion) SetStringData(stringData *string) *DataUnion { - d.StringData = stringData - return d -} - -func (p *DataUnion) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *DataUnion) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadBinary(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.BinaryData = v - } - return nil -} - -func (p *DataUnion) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.StringData = &v - } - return nil -} - -func (p *DataUnion) Write(oprot thrift.Protocol) error { - if c := p.CountSetFieldsDataUnion(); c > 1 { - return fmt.Errorf("%T write union: no more than one field must be set (%d set).", p, c) - } - if err := oprot.WriteStructBegin("DataUnion"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *DataUnion) writeField1(oprot thrift.Protocol) (err error) { - if p.IsSetBinaryData() { - if err := oprot.WriteFieldBegin("binaryData", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:binaryData: ", p), err) } - if err := oprot.WriteBinary(p.BinaryData); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.binaryData (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:binaryData: ", p), err) } - } - return err -} - -func (p *DataUnion) writeField2(oprot thrift.Protocol) (err error) { - if p.IsSetStringData() { - if err := oprot.WriteFieldBegin("stringData", thrift.STRING, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:stringData: ", p), err) } - if err := oprot.WriteString(string(*p.StringData)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.stringData (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:stringData: ", p), err) } - } - return err -} - -func (p *DataUnion) String() string { - if p == nil { - return "" - } - - binaryDataVal := fmt.Sprintf("%v", p.BinaryData) - var stringDataVal string - if p.StringData == nil { - stringDataVal = "" - } else { - stringDataVal = fmt.Sprintf("%v", *p.StringData) - } - return fmt.Sprintf("DataUnion({BinaryData:%s StringData:%s})", binaryDataVal, stringDataVal) -} - -// Attributes: -// - StrVal -// - IntVal -// - TypedefValue -type Val struct { - StrVal string `thrift:"strVal,1" db:"strVal" json:"strVal"` - IntVal int32 `thrift:"intVal,2" db:"intVal" json:"intVal"` - // unused fields # 3 to 8 - TypedefValue ContainerTypedef `thrift:"typedefValue,9" db:"typedefValue" json:"typedefValue"` -} - -func NewVal() *Val { - return &Val{} -} - - -func (p *Val) GetStrVal() string { - return p.StrVal -} - -func (p *Val) GetIntVal() int32 { - return p.IntVal -} - -func (p *Val) GetTypedefValue() ContainerTypedef { - return p.TypedefValue -} -type ValBuilder struct { - obj *Val -} - -func NewValBuilder() *ValBuilder{ - return &ValBuilder{ - obj: NewVal(), - } -} - -func (p ValBuilder) Emit() *Val{ - return &Val{ - StrVal: p.obj.StrVal, - IntVal: p.obj.IntVal, - TypedefValue: p.obj.TypedefValue, - } -} - -func (v *ValBuilder) StrVal(strVal string) *ValBuilder { - v.obj.StrVal = strVal - return v -} - -func (v *ValBuilder) IntVal(intVal int32) *ValBuilder { - v.obj.IntVal = intVal - return v -} - -func (v *ValBuilder) TypedefValue(typedefValue ContainerTypedef) *ValBuilder { - v.obj.TypedefValue = typedefValue - return v -} - -func (v *Val) SetStrVal(strVal string) *Val { - v.StrVal = strVal - return v -} - -func (v *Val) SetIntVal(intVal int32) *Val { - v.IntVal = intVal - return v -} - -func (v *Val) SetTypedefValue(typedefValue ContainerTypedef) *Val { - v.TypedefValue = typedefValue - return v -} - -func (p *Val) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 9: - if err := p.ReadField9(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Val) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.StrVal = v - } - return nil -} - -func (p *Val) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.IntVal = v - } - return nil -} - -func (p *Val) ReadField9(iprot thrift.Protocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(ContainerTypedef, size) - p.TypedefValue = tMap - for i := 0; i < size; i ++ { - var _key6 int16 - if v, err := iprot.ReadI16(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key6 = v - } - var _val7 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _val7 = v - } - p.TypedefValue[_key6] = _val7 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *Val) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Val"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField9(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Val) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("strVal", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:strVal: ", p), err) } - if err := oprot.WriteString(string(p.StrVal)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.strVal (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:strVal: ", p), err) } - return err -} - -func (p *Val) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("intVal", thrift.I32, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:intVal: ", p), err) } - if err := oprot.WriteI32(int32(p.IntVal)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.intVal (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:intVal: ", p), err) } - return err -} - -func (p *Val) writeField9(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("typedefValue", thrift.MAP, 9); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 9:typedefValue: ", p), err) } - if err := oprot.WriteMapBegin(thrift.I16, thrift.STRING, len(p.TypedefValue)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.TypedefValue { - if err := oprot.WriteI16(int16(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := oprot.WriteString(string(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 9:typedefValue: ", p), err) } - return err -} - -func (p *Val) String() string { - if p == nil { - return "" - } - - strValVal := fmt.Sprintf("%v", p.StrVal) - intValVal := fmt.Sprintf("%v", p.IntVal) - typedefValueVal := fmt.Sprintf("%v", p.TypedefValue) - return fmt.Sprintf("Val({StrVal:%s IntVal:%s TypedefValue:%s})", strValVal, intValVal, typedefValueVal) -} - -// Attributes: -// - V1 -// - V2 -type ValUnion struct { - V1 *Val `thrift:"v1,1,optional" db:"v1" json:"v1,omitempty"` - V2 *Val `thrift:"v2,2,optional" db:"v2" json:"v2,omitempty"` -} - -func NewValUnion() *ValUnion { - return &ValUnion{} -} - -var ValUnion_V1_DEFAULT *Val -func (p *ValUnion) GetV1() *Val { - if !p.IsSetV1() { - return ValUnion_V1_DEFAULT - } - return p.V1 -} -func (p *ValUnion) DefaultGetV1() *Val { - if !p.IsSetV1() { - return NewVal() - } - return p.V1 -} -var ValUnion_V2_DEFAULT *Val -func (p *ValUnion) GetV2() *Val { - if !p.IsSetV2() { - return ValUnion_V2_DEFAULT - } - return p.V2 -} -func (p *ValUnion) DefaultGetV2() *Val { - if !p.IsSetV2() { - return NewVal() - } - return p.V2 -} -func (p *ValUnion) CountSetFieldsValUnion() int { - count := 0 - if (p.IsSetV1()) { - count++ - } - if (p.IsSetV2()) { - count++ - } - return count - -} - -func (p *ValUnion) IsSetV1() bool { - return p != nil && p.V1 != nil -} - -func (p *ValUnion) IsSetV2() bool { - return p != nil && p.V2 != nil -} - -type ValUnionBuilder struct { - obj *ValUnion -} - -func NewValUnionBuilder() *ValUnionBuilder{ - return &ValUnionBuilder{ - obj: NewValUnion(), - } -} - -func (p ValUnionBuilder) Emit() *ValUnion{ - return &ValUnion{ - V1: p.obj.V1, - V2: p.obj.V2, - } -} - -func (v *ValUnionBuilder) V1(v1 *Val) *ValUnionBuilder { - v.obj.V1 = v1 - return v -} - -func (v *ValUnionBuilder) V2(v2 *Val) *ValUnionBuilder { - v.obj.V2 = v2 - return v -} - -func (v *ValUnion) SetV1(v1 *Val) *ValUnion { - v.V1 = v1 - return v -} - -func (v *ValUnion) SetV2(v2 *Val) *ValUnion { - v.V2 = v2 - return v -} - -func (p *ValUnion) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ValUnion) ReadField1(iprot thrift.Protocol) error { - p.V1 = NewVal() - if err := p.V1.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.V1), err) - } - return nil -} - -func (p *ValUnion) ReadField2(iprot thrift.Protocol) error { - p.V2 = NewVal() - if err := p.V2.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.V2), err) - } - return nil -} - -func (p *ValUnion) Write(oprot thrift.Protocol) error { - if c := p.CountSetFieldsValUnion(); c > 1 { - return fmt.Errorf("%T write union: no more than one field must be set (%d set).", p, c) - } - if err := oprot.WriteStructBegin("ValUnion"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *ValUnion) writeField1(oprot thrift.Protocol) (err error) { - if p.IsSetV1() { - if err := oprot.WriteFieldBegin("v1", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:v1: ", p), err) } - if err := p.V1.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.V1), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:v1: ", p), err) } - } - return err -} - -func (p *ValUnion) writeField2(oprot thrift.Protocol) (err error) { - if p.IsSetV2() { - if err := oprot.WriteFieldBegin("v2", thrift.STRUCT, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:v2: ", p), err) } - if err := p.V2.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.V2), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:v2: ", p), err) } - } - return err -} - -func (p *ValUnion) String() string { - if p == nil { - return "" - } - - var v1Val string - if p.V1 == nil { - v1Val = "" - } else { - v1Val = fmt.Sprintf("%v", p.V1) - } - var v2Val string - if p.V2 == nil { - v2Val = "" - } else { - v2Val = fmt.Sprintf("%v", p.V2) - } - return fmt.Sprintf("ValUnion({V1:%s V2:%s})", v1Val, v2Val) -} - -// Attributes: -// - ThingOne -// - ThingTwo -type VirtualComplexUnion struct { - ThingOne *string `thrift:"thingOne,1,optional" db:"thingOne" json:"thingOne,omitempty"` - ThingTwo *string `thrift:"thingTwo,2,optional" db:"thingTwo" json:"thingTwo,omitempty"` -} - -func NewVirtualComplexUnion() *VirtualComplexUnion { - return &VirtualComplexUnion{} -} - -var VirtualComplexUnion_ThingOne_DEFAULT string -func (p *VirtualComplexUnion) GetThingOne() string { - if !p.IsSetThingOne() { - return VirtualComplexUnion_ThingOne_DEFAULT - } - return *p.ThingOne -} -var VirtualComplexUnion_ThingTwo_DEFAULT string -func (p *VirtualComplexUnion) GetThingTwo() string { - if !p.IsSetThingTwo() { - return VirtualComplexUnion_ThingTwo_DEFAULT - } - return *p.ThingTwo -} -func (p *VirtualComplexUnion) CountSetFieldsVirtualComplexUnion() int { - count := 0 - if (p.IsSetThingOne()) { - count++ - } - if (p.IsSetThingTwo()) { - count++ - } - return count - -} - -func (p *VirtualComplexUnion) IsSetThingOne() bool { - return p != nil && p.ThingOne != nil -} - -func (p *VirtualComplexUnion) IsSetThingTwo() bool { - return p != nil && p.ThingTwo != nil -} - -type VirtualComplexUnionBuilder struct { - obj *VirtualComplexUnion -} - -func NewVirtualComplexUnionBuilder() *VirtualComplexUnionBuilder{ - return &VirtualComplexUnionBuilder{ - obj: NewVirtualComplexUnion(), - } -} - -func (p VirtualComplexUnionBuilder) Emit() *VirtualComplexUnion{ - return &VirtualComplexUnion{ - ThingOne: p.obj.ThingOne, - ThingTwo: p.obj.ThingTwo, - } -} - -func (v *VirtualComplexUnionBuilder) ThingOne(thingOne *string) *VirtualComplexUnionBuilder { - v.obj.ThingOne = thingOne - return v -} - -func (v *VirtualComplexUnionBuilder) ThingTwo(thingTwo *string) *VirtualComplexUnionBuilder { - v.obj.ThingTwo = thingTwo - return v -} - -func (v *VirtualComplexUnion) SetThingOne(thingOne *string) *VirtualComplexUnion { - v.ThingOne = thingOne - return v -} - -func (v *VirtualComplexUnion) SetThingTwo(thingTwo *string) *VirtualComplexUnion { - v.ThingTwo = thingTwo - return v -} - -func (p *VirtualComplexUnion) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *VirtualComplexUnion) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.ThingOne = &v - } - return nil -} - -func (p *VirtualComplexUnion) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.ThingTwo = &v - } - return nil -} - -func (p *VirtualComplexUnion) Write(oprot thrift.Protocol) error { - if c := p.CountSetFieldsVirtualComplexUnion(); c > 1 { - return fmt.Errorf("%T write union: no more than one field must be set (%d set).", p, c) - } - if err := oprot.WriteStructBegin("VirtualComplexUnion"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *VirtualComplexUnion) writeField1(oprot thrift.Protocol) (err error) { - if p.IsSetThingOne() { - if err := oprot.WriteFieldBegin("thingOne", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:thingOne: ", p), err) } - if err := oprot.WriteString(string(*p.ThingOne)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.thingOne (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:thingOne: ", p), err) } - } - return err -} - -func (p *VirtualComplexUnion) writeField2(oprot thrift.Protocol) (err error) { - if p.IsSetThingTwo() { - if err := oprot.WriteFieldBegin("thingTwo", thrift.STRING, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:thingTwo: ", p), err) } - if err := oprot.WriteString(string(*p.ThingTwo)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.thingTwo (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:thingTwo: ", p), err) } - } - return err -} - -func (p *VirtualComplexUnion) String() string { - if p == nil { - return "" - } - - var thingOneVal string - if p.ThingOne == nil { - thingOneVal = "" - } else { - thingOneVal = fmt.Sprintf("%v", *p.ThingOne) - } - var thingTwoVal string - if p.ThingTwo == nil { - thingTwoVal = "" - } else { - thingTwoVal = fmt.Sprintf("%v", *p.ThingTwo) - } - return fmt.Sprintf("VirtualComplexUnion({ThingOne:%s ThingTwo:%s})", thingOneVal, thingTwoVal) -} - -// Attributes: -// - Num -type NonCopyableStruct struct { - Num int64 `thrift:"num,1" db:"num" json:"num"` -} - -func NewNonCopyableStruct() *NonCopyableStruct { - return &NonCopyableStruct{} -} - - -func (p *NonCopyableStruct) GetNum() int64 { - return p.Num -} -type NonCopyableStructBuilder struct { - obj *NonCopyableStruct -} - -func NewNonCopyableStructBuilder() *NonCopyableStructBuilder{ - return &NonCopyableStructBuilder{ - obj: NewNonCopyableStruct(), - } -} - -func (p NonCopyableStructBuilder) Emit() *NonCopyableStruct{ - return &NonCopyableStruct{ - Num: p.obj.Num, - } -} - -func (n *NonCopyableStructBuilder) Num(num int64) *NonCopyableStructBuilder { - n.obj.Num = num - return n -} - -func (n *NonCopyableStruct) SetNum(num int64) *NonCopyableStruct { - n.Num = num - return n -} - -func (p *NonCopyableStruct) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *NonCopyableStruct) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Num = v - } - return nil -} - -func (p *NonCopyableStruct) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("NonCopyableStruct"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *NonCopyableStruct) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("num", thrift.I64, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:num: ", p), err) } - if err := oprot.WriteI64(int64(p.Num)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.num (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:num: ", p), err) } - return err -} - -func (p *NonCopyableStruct) String() string { - if p == nil { - return "" - } - - numVal := fmt.Sprintf("%v", p.Num) - return fmt.Sprintf("NonCopyableStruct({Num:%s})", numVal) -} - -// Attributes: -// - S -type NonCopyableUnion struct { - S *NonCopyableStruct `thrift:"s,1,optional" db:"s" json:"s,omitempty"` -} - -func NewNonCopyableUnion() *NonCopyableUnion { - return &NonCopyableUnion{} -} - -var NonCopyableUnion_S_DEFAULT *NonCopyableStruct -func (p *NonCopyableUnion) GetS() *NonCopyableStruct { - if !p.IsSetS() { - return NonCopyableUnion_S_DEFAULT - } - return p.S -} -func (p *NonCopyableUnion) DefaultGetS() *NonCopyableStruct { - if !p.IsSetS() { - return NewNonCopyableStruct() - } - return p.S -} -func (p *NonCopyableUnion) CountSetFieldsNonCopyableUnion() int { - count := 0 - if (p.IsSetS()) { - count++ - } - return count - -} - -func (p *NonCopyableUnion) IsSetS() bool { - return p != nil && p.S != nil -} - -type NonCopyableUnionBuilder struct { - obj *NonCopyableUnion -} - -func NewNonCopyableUnionBuilder() *NonCopyableUnionBuilder{ - return &NonCopyableUnionBuilder{ - obj: NewNonCopyableUnion(), - } -} - -func (p NonCopyableUnionBuilder) Emit() *NonCopyableUnion{ - return &NonCopyableUnion{ - S: p.obj.S, - } -} - -func (n *NonCopyableUnionBuilder) S(s *NonCopyableStruct) *NonCopyableUnionBuilder { - n.obj.S = s - return n -} - -func (n *NonCopyableUnion) SetS(s *NonCopyableStruct) *NonCopyableUnion { - n.S = s - return n -} - -func (p *NonCopyableUnion) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *NonCopyableUnion) ReadField1(iprot thrift.Protocol) error { - p.S = NewNonCopyableStruct() - if err := p.S.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.S), err) - } - return nil -} - -func (p *NonCopyableUnion) Write(oprot thrift.Protocol) error { - if c := p.CountSetFieldsNonCopyableUnion(); c > 1 { - return fmt.Errorf("%T write union: no more than one field must be set (%d set).", p, c) - } - if err := oprot.WriteStructBegin("NonCopyableUnion"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *NonCopyableUnion) writeField1(oprot thrift.Protocol) (err error) { - if p.IsSetS() { - if err := oprot.WriteFieldBegin("s", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:s: ", p), err) } - if err := p.S.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.S), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:s: ", p), err) } - } - return err -} - -func (p *NonCopyableUnion) String() string { - if p == nil { - return "" - } - - var sVal string - if p.S == nil { - sVal = "" - } else { - sVal = fmt.Sprintf("%v", p.S) - } - return fmt.Sprintf("NonCopyableUnion({S:%s})", sVal) -} - diff --git a/thrift/compiler/test/fixtures/complex-union/gen-go/thrift/annotation/cpp/constants.go b/thrift/compiler/test/fixtures/complex-union/gen-go/thrift/annotation/cpp/constants.go deleted file mode 100644 index 966e368e2dd..00000000000 --- a/thrift/compiler/test/fixtures/complex-union/gen-go/thrift/annotation/cpp/constants.go +++ /dev/null @@ -1,25 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package cpp - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - - -func init() { -} - diff --git a/thrift/compiler/test/fixtures/complex-union/gen-go/thrift/annotation/cpp/ttypes.go b/thrift/compiler/test/fixtures/complex-union/gen-go/thrift/annotation/cpp/ttypes.go deleted file mode 100644 index 209f29e21fd..00000000000 --- a/thrift/compiler/test/fixtures/complex-union/gen-go/thrift/annotation/cpp/ttypes.go +++ /dev/null @@ -1,2188 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package cpp - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var GoUnusedProtection__ int; - -//Optional, defaults to Unique -type RefType int64 -const ( - RefType_Unique RefType = 0 - RefType_Shared RefType = 1 - RefType_SharedMutable RefType = 2 -) - -var RefTypeToName = map[RefType]string { - RefType_Unique: "Unique", - RefType_Shared: "Shared", - RefType_SharedMutable: "SharedMutable", -} - -var RefTypeToValue = map[string]RefType { - "Unique": RefType_Unique, - "Shared": RefType_Shared, - "SharedMutable": RefType_SharedMutable, -} - -var RefTypeNames = []string { - "Unique", - "Shared", - "SharedMutable", -} - -var RefTypeValues = []RefType { - RefType_Unique, - RefType_Shared, - RefType_SharedMutable, -} - -func (p RefType) String() string { - if v, ok := RefTypeToName[p]; ok { - return v - } - return "" -} - -func RefTypeFromString(s string) (RefType, error) { - if v, ok := RefTypeToValue[s]; ok { - return v, nil - } - return RefType(0), fmt.Errorf("not a valid RefType string") -} - -func RefTypePtr(v RefType) *RefType { return &v } - -//Enum in C++ by default uses signed 32 bit integer. There is no need to specify -//underlying type for signed 32 bit integer. -//64-bit is not supported to avoid truncation since enums are sent as 32-bit integers over the wire. -type EnumUnderlyingType int64 -const ( - EnumUnderlyingType_I8 EnumUnderlyingType = 0 - EnumUnderlyingType_U8 EnumUnderlyingType = 1 - EnumUnderlyingType_I16 EnumUnderlyingType = 2 - EnumUnderlyingType_U16 EnumUnderlyingType = 3 - EnumUnderlyingType_U32 EnumUnderlyingType = 4 -) - -var EnumUnderlyingTypeToName = map[EnumUnderlyingType]string { - EnumUnderlyingType_I8: "I8", - EnumUnderlyingType_U8: "U8", - EnumUnderlyingType_I16: "I16", - EnumUnderlyingType_U16: "U16", - EnumUnderlyingType_U32: "U32", -} - -var EnumUnderlyingTypeToValue = map[string]EnumUnderlyingType { - "I8": EnumUnderlyingType_I8, - "U8": EnumUnderlyingType_U8, - "I16": EnumUnderlyingType_I16, - "U16": EnumUnderlyingType_U16, - "U32": EnumUnderlyingType_U32, -} - -var EnumUnderlyingTypeNames = []string { - "I8", - "U8", - "I16", - "U16", - "U32", -} - -var EnumUnderlyingTypeValues = []EnumUnderlyingType { - EnumUnderlyingType_I8, - EnumUnderlyingType_U8, - EnumUnderlyingType_I16, - EnumUnderlyingType_U16, - EnumUnderlyingType_U32, -} - -func (p EnumUnderlyingType) String() string { - if v, ok := EnumUnderlyingTypeToName[p]; ok { - return v - } - return "" -} - -func EnumUnderlyingTypeFromString(s string) (EnumUnderlyingType, error) { - if v, ok := EnumUnderlyingTypeToValue[s]; ok { - return v, nil - } - return EnumUnderlyingType(0), fmt.Errorf("not a valid EnumUnderlyingType string") -} - -func EnumUnderlyingTypePtr(v EnumUnderlyingType) *EnumUnderlyingType { return &v } - -// Changes the native type of a Thrift object (the C++ type used in codegen) to the value of the `name` field. -// Container types may instead provide the `template` field, in which case template parameters will be filled in by thrift. -// (e.g. `template = "folly::sorted_vector_set"` is equivalent to `type = "folly::sorted_vector_set"` on `set`) -// -// It is also possible to add `cpp_include` to bring in additional data structures and use them here. -// It is required that the custom type matches the specified Thrift type even for internal container types. -// Prefer types that can leverage `reserve(size_t)` as Thrift makes uses these optimizations. -// *Special Case*: This annotation can be used to define a string/binary type as `IOBuf` or `unique_ptr` so that you can leverage Thrift's support for zero-copy buffer manipulation through `IOBuf`. -// During deserialization, thrift receives a buffer that is used to allocate the appropriate fields in the struct. When using smart pointers, instead of making a copy of the data, it only modifies the pointer to point to the address that is used by the buffer. -// -// The custom type must provide the following methods -// * `list`: `push_back(T)` -// * `map`: `insert(std::pair)` -// * `set`: `insert(T)` -// -// Attributes: -// - Name -// - Template -type Type struct { - Name string `thrift:"name,1" db:"name" json:"name"` - Template string `thrift:"template,2" db:"template" json:"template"` -} - -func NewType() *Type { - return &Type{} -} - - -func (p *Type) GetName() string { - return p.Name -} - -func (p *Type) GetTemplate() string { - return p.Template -} -type TypeBuilder struct { - obj *Type -} - -func NewTypeBuilder() *TypeBuilder{ - return &TypeBuilder{ - obj: NewType(), - } -} - -func (p TypeBuilder) Emit() *Type{ - return &Type{ - Name: p.obj.Name, - Template: p.obj.Template, - } -} - -func (t *TypeBuilder) Name(name string) *TypeBuilder { - t.obj.Name = name - return t -} - -func (t *TypeBuilder) Template(template string) *TypeBuilder { - t.obj.Template = template - return t -} - -func (t *Type) SetName(name string) *Type { - t.Name = name - return t -} - -func (t *Type) SetTemplate(template string) *Type { - t.Template = template - return t -} - -func (p *Type) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Type) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Name = v - } - return nil -} - -func (p *Type) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Template = v - } - return nil -} - -func (p *Type) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Type"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Type) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) } - if err := oprot.WriteString(string(p.Name)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) } - return err -} - -func (p *Type) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("template", thrift.STRING, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:template: ", p), err) } - if err := oprot.WriteString(string(p.Template)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.template (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:template: ", p), err) } - return err -} - -func (p *Type) String() string { - if p == nil { - return "" - } - - nameVal := fmt.Sprintf("%v", p.Name) - templateVal := fmt.Sprintf("%v", p.Template) - return fmt.Sprintf("Type({Name:%s Template:%s})", nameVal, templateVal) -} - -// Allocates a field on the heap instead of inline. -// This annotation is added to support recursive types. However, you can also use it to turn a field from a value to a smart pointer. -// `@cpp.Ref` is equivalent having type`@cpp.RefType.Unique`. -// -// NOTE: A struct may transitively contain itself as a field only if at least one of the fields in the inclusion chain is either an optional Ref field or a container. Otherwise the struct would have infinite size. -// -// Attributes: -// - Type -type Ref struct { - Type RefType `thrift:"type,1" db:"type" json:"type"` -} - -func NewRef() *Ref { - return &Ref{} -} - - -func (p *Ref) GetType() RefType { - return p.Type -} -type RefBuilder struct { - obj *Ref -} - -func NewRefBuilder() *RefBuilder{ - return &RefBuilder{ - obj: NewRef(), - } -} - -func (p RefBuilder) Emit() *Ref{ - return &Ref{ - Type: p.obj.Type, - } -} - -func (r *RefBuilder) Type(type_a1 RefType) *RefBuilder { - r.obj.Type = type_a1 - return r -} - -func (r *Ref) SetType(type_a1 RefType) *Ref { - r.Type = type_a1 - return r -} - -func (p *Ref) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Ref) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - temp := RefType(v) - p.Type = temp - } - return nil -} - -func (p *Ref) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Ref"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Ref) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("type", thrift.I32, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:type: ", p), err) } - if err := oprot.WriteI32(int32(p.Type)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.type (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:type: ", p), err) } - return err -} - -func (p *Ref) String() string { - if p == nil { - return "" - } - - typeVal := fmt.Sprintf("%v", p.Type) - return fmt.Sprintf("Ref({Type:%s})", typeVal) -} - -// Changes the name of the definition in generated C++ code. -// In most cases a much better solution is to rename the problematic Thrift field itself. Only use the `cpp.name` annotation if such renaming is problematic, -// e.g. when the field name appears in code as a string, particularly when using JSON serialization, and it is hard to change all usage sites. -// -// Attributes: -// - Value -type Name struct { - Value string `thrift:"value,1" db:"value" json:"value"` -} - -func NewName() *Name { - return &Name{} -} - - -func (p *Name) GetValue() string { - return p.Value -} -type NameBuilder struct { - obj *Name -} - -func NewNameBuilder() *NameBuilder{ - return &NameBuilder{ - obj: NewName(), - } -} - -func (p NameBuilder) Emit() *Name{ - return &Name{ - Value: p.obj.Value, - } -} - -func (n *NameBuilder) Value(value string) *NameBuilder { - n.obj.Value = value - return n -} - -func (n *Name) SetValue(value string) *Name { - n.Value = value - return n -} - -func (p *Name) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Name) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Value = v - } - return nil -} - -func (p *Name) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Name"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Name) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("value", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:value: ", p), err) } - if err := oprot.WriteString(string(p.Value)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.value (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:value: ", p), err) } - return err -} - -func (p *Name) String() string { - if p == nil { - return "" - } - - valueVal := fmt.Sprintf("%v", p.Value) - return fmt.Sprintf("Name({Value:%s})", valueVal) -} - -// Lazily deserialize large field on first access. -// -// ``` -// FooWithLazyField foo; -// apache::thrift::CompactSerializer::deserialize(serializedData, foo); -// -// // large_field is lazy field, it will be deserialized on first access -// // The data will be deserialized in method call large_field_ref() -// LOG(INFO) << foo.large_field_ref()->size(); -// -// // Result will be cached, we won't deserialize again -// LOG(INFO) << foo.large_field_ref()->size(); -// ``` -// -// Read more: /doc/fb/languages/cpp/lazy.md -// -// Attributes: -// - Ref -type Lazy struct { - Ref bool `thrift:"ref,1" db:"ref" json:"ref"` -} - -func NewLazy() *Lazy { - return &Lazy{} -} - - -func (p *Lazy) GetRef() bool { - return p.Ref -} -type LazyBuilder struct { - obj *Lazy -} - -func NewLazyBuilder() *LazyBuilder{ - return &LazyBuilder{ - obj: NewLazy(), - } -} - -func (p LazyBuilder) Emit() *Lazy{ - return &Lazy{ - Ref: p.obj.Ref, - } -} - -func (l *LazyBuilder) Ref(ref bool) *LazyBuilder { - l.obj.Ref = ref - return l -} - -func (l *Lazy) SetRef(ref bool) *Lazy { - l.Ref = ref - return l -} - -func (p *Lazy) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Lazy) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Ref = v - } - return nil -} - -func (p *Lazy) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Lazy"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Lazy) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("ref", thrift.BOOL, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:ref: ", p), err) } - if err := oprot.WriteBool(bool(p.Ref)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.ref (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:ref: ", p), err) } - return err -} - -func (p *Lazy) String() string { - if p == nil { - return "" - } - - refVal := fmt.Sprintf("%v", p.Ref) - return fmt.Sprintf("Lazy({Ref:%s})", refVal) -} - -type DisableLazyChecksum struct { -} - -func NewDisableLazyChecksum() *DisableLazyChecksum { - return &DisableLazyChecksum{} -} - -type DisableLazyChecksumBuilder struct { - obj *DisableLazyChecksum -} - -func NewDisableLazyChecksumBuilder() *DisableLazyChecksumBuilder{ - return &DisableLazyChecksumBuilder{ - obj: NewDisableLazyChecksum(), - } -} - -func (p DisableLazyChecksumBuilder) Emit() *DisableLazyChecksum{ - return &DisableLazyChecksum{ - } -} - -func (p *DisableLazyChecksum) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *DisableLazyChecksum) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("DisableLazyChecksum"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *DisableLazyChecksum) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("DisableLazyChecksum({})") -} - -// An annotation that applies a C++ adapter to typedef, field, or struct. -// -// For example: -// -// @cpp.Adapter{name = "::ns::IdAdapter"} -// typedef i64 MyI64; -// -// Here the type `MyI64` has the C++ adapter `IdAdapter`. -// -// struct User { -// @cpp.Adapter{name = "::ns::IdAdapter"} -// 1: i64 id; -// } -// -// Here the field `id` has the C++ adapter `IdAdapter`. -// -// Attributes: -// - Name: The name of a C++ adapter type used to convert between Thrift and native -// C++ representation. -// -// The adapter can be either a Type or Field adapter, providing either of the following APIs: -// -// struct ThriftTypeAdapter { -// static AdaptedType fromThrift(ThriftType thrift); -// static {const ThriftType& | ThriftType} toThrift(const AdaptedType& native); -// }; -// -// struct ThriftFieldAdapter { -// // Context is an instantiation of apache::thrift::FieldContext -// template -// static void construct(AdaptedType& field, Context ctx); -// -// template -// static AdaptedType fromThriftField(ThriftType value, Context ctx); -// -// template -// static {const ThriftType& | ThriftType} toThrift(const AdaptedType& adapted, Context ctx); -// }; -// - AdaptedType: It is sometimes necessary to specify AdaptedType here (in case the codegen would -// have a circular depdenceny, which will cause the C++ build to fail). -// - UnderlyingName: The name and/or extra namespace to use when directly adapting a type -// (as opposed a typedef). -// -// In this case, the IDL name of the type will refer to the adapted type in -// C++ and the underlying thrift type will be generated in a nested -// namespace and/or with a different name. -// -// If neither `underlyingName` or `extraNamespace` is provided, the -// underlying type will be generated in a nested 'detail' namespace with -// the same name. -// - ExtraNamespace -// - MoveOnly: Must set to true when adapted type is not copyable. -type Adapter struct { - Name string `thrift:"name,1" db:"name" json:"name"` - AdaptedType string `thrift:"adaptedType,2" db:"adaptedType" json:"adaptedType"` - UnderlyingName string `thrift:"underlyingName,3" db:"underlyingName" json:"underlyingName"` - ExtraNamespace string `thrift:"extraNamespace,4" db:"extraNamespace" json:"extraNamespace"` - MoveOnly bool `thrift:"moveOnly,5" db:"moveOnly" json:"moveOnly"` -} - -func NewAdapter() *Adapter { - return &Adapter{} -} - - -func (p *Adapter) GetName() string { - return p.Name -} - -func (p *Adapter) GetAdaptedType() string { - return p.AdaptedType -} - -func (p *Adapter) GetUnderlyingName() string { - return p.UnderlyingName -} - -func (p *Adapter) GetExtraNamespace() string { - return p.ExtraNamespace -} - -func (p *Adapter) GetMoveOnly() bool { - return p.MoveOnly -} -type AdapterBuilder struct { - obj *Adapter -} - -func NewAdapterBuilder() *AdapterBuilder{ - return &AdapterBuilder{ - obj: NewAdapter(), - } -} - -func (p AdapterBuilder) Emit() *Adapter{ - return &Adapter{ - Name: p.obj.Name, - AdaptedType: p.obj.AdaptedType, - UnderlyingName: p.obj.UnderlyingName, - ExtraNamespace: p.obj.ExtraNamespace, - MoveOnly: p.obj.MoveOnly, - } -} - -func (a *AdapterBuilder) Name(name string) *AdapterBuilder { - a.obj.Name = name - return a -} - -func (a *AdapterBuilder) AdaptedType(adaptedType string) *AdapterBuilder { - a.obj.AdaptedType = adaptedType - return a -} - -func (a *AdapterBuilder) UnderlyingName(underlyingName string) *AdapterBuilder { - a.obj.UnderlyingName = underlyingName - return a -} - -func (a *AdapterBuilder) ExtraNamespace(extraNamespace string) *AdapterBuilder { - a.obj.ExtraNamespace = extraNamespace - return a -} - -func (a *AdapterBuilder) MoveOnly(moveOnly bool) *AdapterBuilder { - a.obj.MoveOnly = moveOnly - return a -} - -func (a *Adapter) SetName(name string) *Adapter { - a.Name = name - return a -} - -func (a *Adapter) SetAdaptedType(adaptedType string) *Adapter { - a.AdaptedType = adaptedType - return a -} - -func (a *Adapter) SetUnderlyingName(underlyingName string) *Adapter { - a.UnderlyingName = underlyingName - return a -} - -func (a *Adapter) SetExtraNamespace(extraNamespace string) *Adapter { - a.ExtraNamespace = extraNamespace - return a -} - -func (a *Adapter) SetMoveOnly(moveOnly bool) *Adapter { - a.MoveOnly = moveOnly - return a -} - -func (p *Adapter) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 3: - if err := p.ReadField3(iprot); err != nil { - return err - } - case 4: - if err := p.ReadField4(iprot); err != nil { - return err - } - case 5: - if err := p.ReadField5(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Adapter) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Name = v - } - return nil -} - -func (p *Adapter) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.AdaptedType = v - } - return nil -} - -func (p *Adapter) ReadField3(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 3: ", err) - } else { - p.UnderlyingName = v - } - return nil -} - -func (p *Adapter) ReadField4(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 4: ", err) - } else { - p.ExtraNamespace = v - } - return nil -} - -func (p *Adapter) ReadField5(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 5: ", err) - } else { - p.MoveOnly = v - } - return nil -} - -func (p *Adapter) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Adapter"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := p.writeField4(oprot); err != nil { return err } - if err := p.writeField5(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Adapter) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) } - if err := oprot.WriteString(string(p.Name)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) } - return err -} - -func (p *Adapter) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("adaptedType", thrift.STRING, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:adaptedType: ", p), err) } - if err := oprot.WriteString(string(p.AdaptedType)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.adaptedType (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:adaptedType: ", p), err) } - return err -} - -func (p *Adapter) writeField3(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("underlyingName", thrift.STRING, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:underlyingName: ", p), err) } - if err := oprot.WriteString(string(p.UnderlyingName)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.underlyingName (3) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:underlyingName: ", p), err) } - return err -} - -func (p *Adapter) writeField4(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("extraNamespace", thrift.STRING, 4); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:extraNamespace: ", p), err) } - if err := oprot.WriteString(string(p.ExtraNamespace)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.extraNamespace (4) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 4:extraNamespace: ", p), err) } - return err -} - -func (p *Adapter) writeField5(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("moveOnly", thrift.BOOL, 5); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:moveOnly: ", p), err) } - if err := oprot.WriteBool(bool(p.MoveOnly)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.moveOnly (5) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 5:moveOnly: ", p), err) } - return err -} - -func (p *Adapter) String() string { - if p == nil { - return "" - } - - nameVal := fmt.Sprintf("%v", p.Name) - adaptedTypeVal := fmt.Sprintf("%v", p.AdaptedType) - underlyingNameVal := fmt.Sprintf("%v", p.UnderlyingName) - extraNamespaceVal := fmt.Sprintf("%v", p.ExtraNamespace) - moveOnlyVal := fmt.Sprintf("%v", p.MoveOnly) - return fmt.Sprintf("Adapter({Name:%s AdaptedType:%s UnderlyingName:%s ExtraNamespace:%s MoveOnly:%s})", nameVal, adaptedTypeVal, underlyingNameVal, extraNamespaceVal, moveOnlyVal) -} - -// Packs isset bits into fewer bytes to save space at the cost of making access more expensive. -// Passing `atomic = false` reduces the access cost while making concurrent writes UB. -// Read more: /doc/fb/languages/cpp/isset-bitpacking.md -// -// Attributes: -// - Atomic -type PackIsset struct { - Atomic bool `thrift:"atomic,1" db:"atomic" json:"atomic"` -} - -func NewPackIsset() *PackIsset { - return &PackIsset{ - Atomic: true, - } -} - - -func (p *PackIsset) GetAtomic() bool { - return p.Atomic -} -type PackIssetBuilder struct { - obj *PackIsset -} - -func NewPackIssetBuilder() *PackIssetBuilder{ - return &PackIssetBuilder{ - obj: NewPackIsset(), - } -} - -func (p PackIssetBuilder) Emit() *PackIsset{ - return &PackIsset{ - Atomic: p.obj.Atomic, - } -} - -func (p *PackIssetBuilder) Atomic(atomic bool) *PackIssetBuilder { - p.obj.Atomic = atomic - return p -} - -func (p *PackIsset) SetAtomic(atomic bool) *PackIsset { - p.Atomic = atomic - return p -} - -func (p *PackIsset) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *PackIsset) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Atomic = v - } - return nil -} - -func (p *PackIsset) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("PackIsset"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *PackIsset) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("atomic", thrift.BOOL, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:atomic: ", p), err) } - if err := oprot.WriteBool(bool(p.Atomic)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.atomic (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:atomic: ", p), err) } - return err -} - -func (p *PackIsset) String() string { - if p == nil { - return "" - } - - atomicVal := fmt.Sprintf("%v", p.Atomic) - return fmt.Sprintf("PackIsset({Atomic:%s})", atomicVal) -} - -// This annotation enables reordering of fields in the generated C++ struct to minimize padding. -// This is achieved by placing the fields in the order of decreasing alignments. The order of fields with the same alignment is preserved. -// -// ``` -// @cpp.MinimizePadding -// struct Padded { -// 1: byte small -// 2: i64 big -// 3: i16 medium -// 4: i32 biggish -// 5: byte tiny -// } -// ``` -// -// For example, the C++ fields for the `Padded` Thrift struct above will be generated in the following order: -// -// ``` -// int64_t big; -// int32_t biggish; -// int16_t medium; -// int8_t small; -// int8_t tiny; -// ``` -// -// which gives the size of 16 bytes compared to 32 bytes if `cpp.MinimizePadding` was not specified. -type MinimizePadding struct { -} - -func NewMinimizePadding() *MinimizePadding { - return &MinimizePadding{} -} - -type MinimizePaddingBuilder struct { - obj *MinimizePadding -} - -func NewMinimizePaddingBuilder() *MinimizePaddingBuilder{ - return &MinimizePaddingBuilder{ - obj: NewMinimizePadding(), - } -} - -func (p MinimizePaddingBuilder) Emit() *MinimizePadding{ - return &MinimizePadding{ - } -} - -func (p *MinimizePadding) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MinimizePadding) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("MinimizePadding"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MinimizePadding) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("MinimizePadding({})") -} - -type TriviallyRelocatable struct { -} - -func NewTriviallyRelocatable() *TriviallyRelocatable { - return &TriviallyRelocatable{} -} - -type TriviallyRelocatableBuilder struct { - obj *TriviallyRelocatable -} - -func NewTriviallyRelocatableBuilder() *TriviallyRelocatableBuilder{ - return &TriviallyRelocatableBuilder{ - obj: NewTriviallyRelocatable(), - } -} - -func (p TriviallyRelocatableBuilder) Emit() *TriviallyRelocatable{ - return &TriviallyRelocatable{ - } -} - -func (p *TriviallyRelocatable) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *TriviallyRelocatable) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("TriviallyRelocatable"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *TriviallyRelocatable) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("TriviallyRelocatable({})") -} - -type ScopedEnumAsUnionType struct { -} - -func NewScopedEnumAsUnionType() *ScopedEnumAsUnionType { - return &ScopedEnumAsUnionType{} -} - -type ScopedEnumAsUnionTypeBuilder struct { - obj *ScopedEnumAsUnionType -} - -func NewScopedEnumAsUnionTypeBuilder() *ScopedEnumAsUnionTypeBuilder{ - return &ScopedEnumAsUnionTypeBuilder{ - obj: NewScopedEnumAsUnionType(), - } -} - -func (p ScopedEnumAsUnionTypeBuilder) Emit() *ScopedEnumAsUnionType{ - return &ScopedEnumAsUnionType{ - } -} - -func (p *ScopedEnumAsUnionType) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ScopedEnumAsUnionType) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("ScopedEnumAsUnionType"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *ScopedEnumAsUnionType) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("ScopedEnumAsUnionType({})") -} - -// Indicates a typedef should be 'strong', and require an explicit cast to -// the underlying type. -// -// Currently only works for integer typedefs, for example: -// -// @cpp.StrongType -// typedef i32 MyId; -// -// Will cause an enum class to be used instead of a typedef in the genearte code, for example: -// -// enum class MyId : ::std::int32_t {}; -// -type StrongType struct { -} - -func NewStrongType() *StrongType { - return &StrongType{} -} - -type StrongTypeBuilder struct { - obj *StrongType -} - -func NewStrongTypeBuilder() *StrongTypeBuilder{ - return &StrongTypeBuilder{ - obj: NewStrongType(), - } -} - -func (p StrongTypeBuilder) Emit() *StrongType{ - return &StrongType{ - } -} - -func (p *StrongType) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *StrongType) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("StrongType"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *StrongType) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("StrongType({})") -} - -// An annotation that intercepts field access with C++ field interceptor. -// Use with *caution* since this may introduce substantial performance overhead on each field access. -// -// For example: -// -// struct Foo { -// @cpp.FieldInterceptor{name = "MyFieldInterceptor"} -// 1: i64 id; -// } -// -// The field interceptor `MyFieldInterceptor` will intercept with `interceptThriftFieldAccess` -// when the field `id` is accessed. -// -// Attributes: -// - Name: The name of a field interceptor. -// -// The field interceptor provides the following API: -// -// struct ThriftFieldInterceptor { -// template -// static void interceptThriftFieldAccess(T&& field, -// apache::thrift::FieldContext&& ctx); -// }; -// -// The field interceptor intercepts with the field value and the field context. -// It enforces an easily searchable function name `interceptThriftFieldAccess`. -// - Noinline: Setting to true makes compiler not inline and erase function signature for -// the intercepting field accessor. -type FieldInterceptor struct { - Name string `thrift:"name,1" db:"name" json:"name"` - Noinline bool `thrift:"noinline,2" db:"noinline" json:"noinline"` -} - -func NewFieldInterceptor() *FieldInterceptor { - return &FieldInterceptor{} -} - - -func (p *FieldInterceptor) GetName() string { - return p.Name -} - -func (p *FieldInterceptor) GetNoinline() bool { - return p.Noinline -} -type FieldInterceptorBuilder struct { - obj *FieldInterceptor -} - -func NewFieldInterceptorBuilder() *FieldInterceptorBuilder{ - return &FieldInterceptorBuilder{ - obj: NewFieldInterceptor(), - } -} - -func (p FieldInterceptorBuilder) Emit() *FieldInterceptor{ - return &FieldInterceptor{ - Name: p.obj.Name, - Noinline: p.obj.Noinline, - } -} - -func (f *FieldInterceptorBuilder) Name(name string) *FieldInterceptorBuilder { - f.obj.Name = name - return f -} - -func (f *FieldInterceptorBuilder) Noinline(noinline bool) *FieldInterceptorBuilder { - f.obj.Noinline = noinline - return f -} - -func (f *FieldInterceptor) SetName(name string) *FieldInterceptor { - f.Name = name - return f -} - -func (f *FieldInterceptor) SetNoinline(noinline bool) *FieldInterceptor { - f.Noinline = noinline - return f -} - -func (p *FieldInterceptor) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *FieldInterceptor) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Name = v - } - return nil -} - -func (p *FieldInterceptor) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Noinline = v - } - return nil -} - -func (p *FieldInterceptor) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("FieldInterceptor"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *FieldInterceptor) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) } - if err := oprot.WriteString(string(p.Name)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) } - return err -} - -func (p *FieldInterceptor) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("noinline", thrift.BOOL, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:noinline: ", p), err) } - if err := oprot.WriteBool(bool(p.Noinline)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.noinline (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:noinline: ", p), err) } - return err -} - -func (p *FieldInterceptor) String() string { - if p == nil { - return "" - } - - nameVal := fmt.Sprintf("%v", p.Name) - noinlineVal := fmt.Sprintf("%v", p.Noinline) - return fmt.Sprintf("FieldInterceptor({Name:%s Noinline:%s})", nameVal, noinlineVal) -} - -type UseOpEncode struct { -} - -func NewUseOpEncode() *UseOpEncode { - return &UseOpEncode{} -} - -type UseOpEncodeBuilder struct { - obj *UseOpEncode -} - -func NewUseOpEncodeBuilder() *UseOpEncodeBuilder{ - return &UseOpEncodeBuilder{ - obj: NewUseOpEncode(), - } -} - -func (p UseOpEncodeBuilder) Emit() *UseOpEncode{ - return &UseOpEncode{ - } -} - -func (p *UseOpEncode) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *UseOpEncode) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("UseOpEncode"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *UseOpEncode) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("UseOpEncode({})") -} - -// Indicates an integer type for C++ to use as the underlying type of enum, for example: -// -// @cpp.EnumType{type = cpp.EnumUnderlyingType.I8} -// enum Fruit { -// Apple = 0, -// Banana = 1, -// } -// -// will be generated into the following: -// -// enum class Fruit : ::std::int8_t { -// Apple = 0, -// Banana = 1, -// }; -// -// -// Attributes: -// - Type -type EnumType struct { - Type EnumUnderlyingType `thrift:"type,1" db:"type" json:"type"` -} - -func NewEnumType() *EnumType { - return &EnumType{} -} - - -func (p *EnumType) GetType() EnumUnderlyingType { - return p.Type -} -type EnumTypeBuilder struct { - obj *EnumType -} - -func NewEnumTypeBuilder() *EnumTypeBuilder{ - return &EnumTypeBuilder{ - obj: NewEnumType(), - } -} - -func (p EnumTypeBuilder) Emit() *EnumType{ - return &EnumType{ - Type: p.obj.Type, - } -} - -func (e *EnumTypeBuilder) Type(type_a1 EnumUnderlyingType) *EnumTypeBuilder { - e.obj.Type = type_a1 - return e -} - -func (e *EnumType) SetType(type_a1 EnumUnderlyingType) *EnumType { - e.Type = type_a1 - return e -} - -func (p *EnumType) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *EnumType) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - temp := EnumUnderlyingType(v) - p.Type = temp - } - return nil -} - -func (p *EnumType) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("EnumType"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *EnumType) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("type", thrift.I32, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:type: ", p), err) } - if err := oprot.WriteI32(int32(p.Type)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.type (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:type: ", p), err) } - return err -} - -func (p *EnumType) String() string { - if p == nil { - return "" - } - - typeVal := fmt.Sprintf("%v", p.Type) - return fmt.Sprintf("EnumType({Type:%s})", typeVal) -} - -// Indicates that frozen types should not be generated for a given struct. -type Frozen2Exclude struct { -} - -func NewFrozen2Exclude() *Frozen2Exclude { - return &Frozen2Exclude{} -} - -type Frozen2ExcludeBuilder struct { - obj *Frozen2Exclude -} - -func NewFrozen2ExcludeBuilder() *Frozen2ExcludeBuilder{ - return &Frozen2ExcludeBuilder{ - obj: NewFrozen2Exclude(), - } -} - -func (p Frozen2ExcludeBuilder) Emit() *Frozen2Exclude{ - return &Frozen2Exclude{ - } -} - -func (p *Frozen2Exclude) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Frozen2Exclude) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Frozen2Exclude"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Frozen2Exclude) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Frozen2Exclude({})") -} - -// Indicates that the container params must be complete at the time this type is instantiated. -// Only required in rare cases where the build fails with a frozen-related assert failure. -type Frozen2RequiresCompleteContainerParams struct { -} - -func NewFrozen2RequiresCompleteContainerParams() *Frozen2RequiresCompleteContainerParams { - return &Frozen2RequiresCompleteContainerParams{} -} - -type Frozen2RequiresCompleteContainerParamsBuilder struct { - obj *Frozen2RequiresCompleteContainerParams -} - -func NewFrozen2RequiresCompleteContainerParamsBuilder() *Frozen2RequiresCompleteContainerParamsBuilder{ - return &Frozen2RequiresCompleteContainerParamsBuilder{ - obj: NewFrozen2RequiresCompleteContainerParams(), - } -} - -func (p Frozen2RequiresCompleteContainerParamsBuilder) Emit() *Frozen2RequiresCompleteContainerParams{ - return &Frozen2RequiresCompleteContainerParams{ - } -} - -func (p *Frozen2RequiresCompleteContainerParams) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Frozen2RequiresCompleteContainerParams) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Frozen2RequiresCompleteContainerParams"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Frozen2RequiresCompleteContainerParams) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Frozen2RequiresCompleteContainerParams({})") -} - -// Generates typed interceptor stubs that can be overriden by user, -// and adorn the handler methods. This can be used on individual functions -// or on services (equivalent to adding it to all functions). -// -// service MyService { -// @cpp.GenerateTypedInterceptor -// void ping(); -// } -// -// This will generate the following interface: -// -// class TypedInterceptor { -// TypeErasedStorage before_ping(); -// TypeErasedStorage after_ping(); -// } -// -type GenerateTypedInterceptor struct { -} - -func NewGenerateTypedInterceptor() *GenerateTypedInterceptor { - return &GenerateTypedInterceptor{} -} - -type GenerateTypedInterceptorBuilder struct { - obj *GenerateTypedInterceptor -} - -func NewGenerateTypedInterceptorBuilder() *GenerateTypedInterceptorBuilder{ - return &GenerateTypedInterceptorBuilder{ - obj: NewGenerateTypedInterceptor(), - } -} - -func (p GenerateTypedInterceptorBuilder) Emit() *GenerateTypedInterceptor{ - return &GenerateTypedInterceptor{ - } -} - -func (p *GenerateTypedInterceptor) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *GenerateTypedInterceptor) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("GenerateTypedInterceptor"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *GenerateTypedInterceptor) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("GenerateTypedInterceptor({})") -} - -// Causes C++ handler code to run inline on the EventBase thread. -// Disables overload protection, use with caution. -// Cannot be applied to individual functions in interactions. -// -// Causes the request to be executed on the event base thread directly instead of rescheduling onto a thread manager thread, provided the async_eb_ handler method is implemented. -// You should only execute the request on the event base thread if it is very fast and you have measured that rescheduling is a substantial chunk of your service's CPU usage. -// If a request executing on the event base thread blocks or takes a long time, all other requests sharing the same event base are affected and latency will increase significantly. -// We strongly discourage the use of this annotation unless strictly necessary. You will have to implement the harder-to-use async_eb_ handler method. -// This also disables queue timeouts, an important form of overload protection. -type ProcessInEbThreadUnsafe struct { -} - -func NewProcessInEbThreadUnsafe() *ProcessInEbThreadUnsafe { - return &ProcessInEbThreadUnsafe{} -} - -type ProcessInEbThreadUnsafeBuilder struct { - obj *ProcessInEbThreadUnsafe -} - -func NewProcessInEbThreadUnsafeBuilder() *ProcessInEbThreadUnsafeBuilder{ - return &ProcessInEbThreadUnsafeBuilder{ - obj: NewProcessInEbThreadUnsafe(), - } -} - -func (p ProcessInEbThreadUnsafeBuilder) Emit() *ProcessInEbThreadUnsafe{ - return &ProcessInEbThreadUnsafe{ - } -} - -func (p *ProcessInEbThreadUnsafe) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ProcessInEbThreadUnsafe) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("ProcessInEbThreadUnsafe"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *ProcessInEbThreadUnsafe) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("ProcessInEbThreadUnsafe({})") -} - -// Applies to structured annotation that need to be accessed in Runtime. -type RuntimeAnnotation struct { -} - -func NewRuntimeAnnotation() *RuntimeAnnotation { - return &RuntimeAnnotation{} -} - -type RuntimeAnnotationBuilder struct { - obj *RuntimeAnnotation -} - -func NewRuntimeAnnotationBuilder() *RuntimeAnnotationBuilder{ - return &RuntimeAnnotationBuilder{ - obj: NewRuntimeAnnotation(), - } -} - -func (p RuntimeAnnotationBuilder) Emit() *RuntimeAnnotation{ - return &RuntimeAnnotation{ - } -} - -func (p *RuntimeAnnotation) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *RuntimeAnnotation) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("RuntimeAnnotation"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *RuntimeAnnotation) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("RuntimeAnnotation({})") -} - diff --git a/thrift/compiler/test/fixtures/complex-union/gen-go/thrift/annotation/scope/constants.go b/thrift/compiler/test/fixtures/complex-union/gen-go/thrift/annotation/scope/constants.go deleted file mode 100644 index 0c3448a7126..00000000000 --- a/thrift/compiler/test/fixtures/complex-union/gen-go/thrift/annotation/scope/constants.go +++ /dev/null @@ -1,25 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package scope - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - - -func init() { -} - diff --git a/thrift/compiler/test/fixtures/complex-union/gen-go/thrift/annotation/scope/ttypes.go b/thrift/compiler/test/fixtures/complex-union/gen-go/thrift/annotation/scope/ttypes.go deleted file mode 100644 index 580c39e775c..00000000000 --- a/thrift/compiler/test/fixtures/complex-union/gen-go/thrift/annotation/scope/ttypes.go +++ /dev/null @@ -1,1169 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package scope - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var GoUnusedProtection__ int; - -// Indicates that the scope of sibling annotations is transitive. -// -// For example: -// -// @scope.Struct -// @scope.Union -// @scope.Exception -// @scope.Transitive -// struct Structured {} -// -// Annotating a Thrift struct with @Structured automatically applies -// @scope.Struct, @scope.Union and @scope.Exception annotations, i.e. -// -// @Structured -// struct MyAnnotation {} -// -// is equivalent to -// -// @scope.Struct -// @scope.Union -// @scope.Exception -// struct MyAnnotation {} -// -type Transitive struct { -} - -func NewTransitive() *Transitive { - return &Transitive{} -} - -type TransitiveBuilder struct { - obj *Transitive -} - -func NewTransitiveBuilder() *TransitiveBuilder{ - return &TransitiveBuilder{ - obj: NewTransitive(), - } -} - -func (p TransitiveBuilder) Emit() *Transitive{ - return &Transitive{ - } -} - -func (p *Transitive) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Transitive) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Transitive"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Transitive) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Transitive({})") -} - -// The Program scope. -// -// This allows annotations on the `package` definition, which implies the -// annotaiton applies to the entire program. -type Program struct { -} - -func NewProgram() *Program { - return &Program{} -} - -type ProgramBuilder struct { - obj *Program -} - -func NewProgramBuilder() *ProgramBuilder{ - return &ProgramBuilder{ - obj: NewProgram(), - } -} - -func (p ProgramBuilder) Emit() *Program{ - return &Program{ - } -} - -func (p *Program) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Program) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Program"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Program) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Program({})") -} - -// The `struct` definition scope. -type Struct struct { -} - -func NewStruct() *Struct { - return &Struct{} -} - -type StructBuilder struct { - obj *Struct -} - -func NewStructBuilder() *StructBuilder{ - return &StructBuilder{ - obj: NewStruct(), - } -} - -func (p StructBuilder) Emit() *Struct{ - return &Struct{ - } -} - -func (p *Struct) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Struct) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Struct"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Struct) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Struct({})") -} - -// The `union` definition scope. -type Union struct { -} - -func NewUnion() *Union { - return &Union{} -} - -type UnionBuilder struct { - obj *Union -} - -func NewUnionBuilder() *UnionBuilder{ - return &UnionBuilder{ - obj: NewUnion(), - } -} - -func (p UnionBuilder) Emit() *Union{ - return &Union{ - } -} - -func (p *Union) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Union) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Union"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Union) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Union({})") -} - -// The `exception` definition scope. -type Exception struct { -} - -func NewException() *Exception { - return &Exception{} -} - -type ExceptionBuilder struct { - obj *Exception -} - -func NewExceptionBuilder() *ExceptionBuilder{ - return &ExceptionBuilder{ - obj: NewException(), - } -} - -func (p ExceptionBuilder) Emit() *Exception{ - return &Exception{ - } -} - -func (p *Exception) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Exception) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Exception"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Exception) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Exception({})") -} - -// Field declartaions, for example in `struct` or `function` declartions. -type Field struct { -} - -func NewField() *Field { - return &Field{} -} - -type FieldBuilder struct { - obj *Field -} - -func NewFieldBuilder() *FieldBuilder{ - return &FieldBuilder{ - obj: NewField(), - } -} - -func (p FieldBuilder) Emit() *Field{ - return &Field{ - } -} - -func (p *Field) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Field) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Field"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Field) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Field({})") -} - -// The `typedef` definition scope. -type Typedef struct { -} - -func NewTypedef() *Typedef { - return &Typedef{} -} - -type TypedefBuilder struct { - obj *Typedef -} - -func NewTypedefBuilder() *TypedefBuilder{ - return &TypedefBuilder{ - obj: NewTypedef(), - } -} - -func (p TypedefBuilder) Emit() *Typedef{ - return &Typedef{ - } -} - -func (p *Typedef) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Typedef) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Typedef"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Typedef) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Typedef({})") -} - -// The `service` definition scope. -type Service struct { -} - -func NewService() *Service { - return &Service{} -} - -type ServiceBuilder struct { - obj *Service -} - -func NewServiceBuilder() *ServiceBuilder{ - return &ServiceBuilder{ - obj: NewService(), - } -} - -func (p ServiceBuilder) Emit() *Service{ - return &Service{ - } -} - -func (p *Service) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Service) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Service"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Service) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Service({})") -} - -// The `interaction` definition scope. -type Interaction struct { -} - -func NewInteraction() *Interaction { - return &Interaction{} -} - -type InteractionBuilder struct { - obj *Interaction -} - -func NewInteractionBuilder() *InteractionBuilder{ - return &InteractionBuilder{ - obj: NewInteraction(), - } -} - -func (p InteractionBuilder) Emit() *Interaction{ - return &Interaction{ - } -} - -func (p *Interaction) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Interaction) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Interaction"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Interaction) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Interaction({})") -} - -// The `function` definition scope. -type Function struct { -} - -func NewFunction() *Function { - return &Function{} -} - -type FunctionBuilder struct { - obj *Function -} - -func NewFunctionBuilder() *FunctionBuilder{ - return &FunctionBuilder{ - obj: NewFunction(), - } -} - -func (p FunctionBuilder) Emit() *Function{ - return &Function{ - } -} - -func (p *Function) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Function) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Function"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Function) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Function({})") -} - -// The Enum value definition scope. -type EnumValue struct { -} - -func NewEnumValue() *EnumValue { - return &EnumValue{} -} - -type EnumValueBuilder struct { - obj *EnumValue -} - -func NewEnumValueBuilder() *EnumValueBuilder{ - return &EnumValueBuilder{ - obj: NewEnumValue(), - } -} - -func (p EnumValueBuilder) Emit() *EnumValue{ - return &EnumValue{ - } -} - -func (p *EnumValue) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *EnumValue) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("EnumValue"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *EnumValue) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("EnumValue({})") -} - -// The `const` definition scope. -type Const struct { -} - -func NewConst() *Const { - return &Const{} -} - -type ConstBuilder struct { - obj *Const -} - -func NewConstBuilder() *ConstBuilder{ - return &ConstBuilder{ - obj: NewConst(), - } -} - -func (p ConstBuilder) Emit() *Const{ - return &Const{ - } -} - -func (p *Const) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Const) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Const"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Const) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Const({})") -} - -type Enum struct { -} - -func NewEnum() *Enum { - return &Enum{} -} - -type EnumBuilder struct { - obj *Enum -} - -func NewEnumBuilder() *EnumBuilder{ - return &EnumBuilder{ - obj: NewEnum(), - } -} - -func (p EnumBuilder) Emit() *Enum{ - return &Enum{ - } -} - -func (p *Enum) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Enum) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Enum"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Enum) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Enum({})") -} - -// A scope that includes all 'structured' definitions. -type Structured struct { -} - -func NewStructured() *Structured { - return &Structured{} -} - -type StructuredBuilder struct { - obj *Structured -} - -func NewStructuredBuilder() *StructuredBuilder{ - return &StructuredBuilder{ - obj: NewStructured(), - } -} - -func (p StructuredBuilder) Emit() *Structured{ - return &Structured{ - } -} - -func (p *Structured) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Structured) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Structured"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Structured) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Structured({})") -} - -// A scope that includes all 'interface' definitions. -type Interface struct { -} - -func NewInterface() *Interface { - return &Interface{} -} - -type InterfaceBuilder struct { - obj *Interface -} - -func NewInterfaceBuilder() *InterfaceBuilder{ - return &InterfaceBuilder{ - obj: NewInterface(), - } -} - -func (p InterfaceBuilder) Emit() *Interface{ - return &Interface{ - } -} - -func (p *Interface) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Interface) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Interface"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Interface) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Interface({})") -} - -// A scope that includes all program-scoped definition. -type RootDefinition struct { -} - -func NewRootDefinition() *RootDefinition { - return &RootDefinition{} -} - -type RootDefinitionBuilder struct { - obj *RootDefinition -} - -func NewRootDefinitionBuilder() *RootDefinitionBuilder{ - return &RootDefinitionBuilder{ - obj: NewRootDefinition(), - } -} - -func (p RootDefinitionBuilder) Emit() *RootDefinition{ - return &RootDefinition{ - } -} - -func (p *RootDefinition) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *RootDefinition) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("RootDefinition"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *RootDefinition) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("RootDefinition({})") -} - -// A scope that includes all definitions. -type Definition struct { -} - -func NewDefinition() *Definition { - return &Definition{} -} - -type DefinitionBuilder struct { - obj *Definition -} - -func NewDefinitionBuilder() *DefinitionBuilder{ - return &DefinitionBuilder{ - obj: NewDefinition(), - } -} - -func (p DefinitionBuilder) Emit() *Definition{ - return &Definition{ - } -} - -func (p *Definition) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Definition) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Definition"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Definition) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Definition({})") -} - diff --git a/thrift/compiler/test/fixtures/complex-union/gen-go/thrift/annotation/thrift/constants.go b/thrift/compiler/test/fixtures/complex-union/gen-go/thrift/annotation/thrift/constants.go deleted file mode 100644 index 50d9b0fe3ee..00000000000 --- a/thrift/compiler/test/fixtures/complex-union/gen-go/thrift/annotation/thrift/constants.go +++ /dev/null @@ -1,25 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package thrift - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - - -func init() { -} - diff --git a/thrift/compiler/test/fixtures/complex-union/gen-go/thrift/annotation/thrift/ttypes.go b/thrift/compiler/test/fixtures/complex-union/gen-go/thrift/annotation/thrift/ttypes.go deleted file mode 100644 index 35ea75e3dd0..00000000000 --- a/thrift/compiler/test/fixtures/complex-union/gen-go/thrift/annotation/thrift/ttypes.go +++ /dev/null @@ -1,1545 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package thrift - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var GoUnusedProtection__ int; - -type RpcPriority int64 -const ( - RpcPriority_HIGH_IMPORTANT RpcPriority = 0 - RpcPriority_HIGH RpcPriority = 1 - RpcPriority_IMPORTANT RpcPriority = 2 - RpcPriority_NORMAL RpcPriority = 3 - RpcPriority_BEST_EFFORT RpcPriority = 4 -) - -var RpcPriorityToName = map[RpcPriority]string { - RpcPriority_HIGH_IMPORTANT: "HIGH_IMPORTANT", - RpcPriority_HIGH: "HIGH", - RpcPriority_IMPORTANT: "IMPORTANT", - RpcPriority_NORMAL: "NORMAL", - RpcPriority_BEST_EFFORT: "BEST_EFFORT", -} - -var RpcPriorityToValue = map[string]RpcPriority { - "HIGH_IMPORTANT": RpcPriority_HIGH_IMPORTANT, - "HIGH": RpcPriority_HIGH, - "IMPORTANT": RpcPriority_IMPORTANT, - "NORMAL": RpcPriority_NORMAL, - "BEST_EFFORT": RpcPriority_BEST_EFFORT, -} - -var RpcPriorityNames = []string { - "HIGH_IMPORTANT", - "HIGH", - "IMPORTANT", - "NORMAL", - "BEST_EFFORT", -} - -var RpcPriorityValues = []RpcPriority { - RpcPriority_HIGH_IMPORTANT, - RpcPriority_HIGH, - RpcPriority_IMPORTANT, - RpcPriority_NORMAL, - RpcPriority_BEST_EFFORT, -} - -func (p RpcPriority) String() string { - if v, ok := RpcPriorityToName[p]; ok { - return v - } - return "" -} - -func RpcPriorityFromString(s string) (RpcPriority, error) { - if v, ok := RpcPriorityToValue[s]; ok { - return v, nil - } - return RpcPriority(0), fmt.Errorf("not a valid RpcPriority string") -} - -func RpcPriorityPtr(v RpcPriority) *RpcPriority { return &v } - -// Indicates a definition/feature should only be used with permission, may -// only work in specific contexts, and may change in incompatible ways without -// notice. Note that this is primarily intended to annotate features by the Thrift Team -// and isn't recommended for general use. -type Experimental struct { -} - -func NewExperimental() *Experimental { - return &Experimental{} -} - -type ExperimentalBuilder struct { - obj *Experimental -} - -func NewExperimentalBuilder() *ExperimentalBuilder{ - return &ExperimentalBuilder{ - obj: NewExperimental(), - } -} - -func (p ExperimentalBuilder) Emit() *Experimental{ - return &Experimental{ - } -} - -func (p *Experimental) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Experimental) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Experimental"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Experimental) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Experimental({})") -} - -// Annotate a thrift structured or enum to indicate if ids or values should not -// be used. -// -// For example, you may want to mark ids as deprecated, or these ids -// might be reserved for other use cases or annotations. -// -// The resolved set of disallowed ids is the union of the values in `ids` and -// the range of values represented in `id_ranges`. Example: -// -// // These ids are not allowed: 3, 8, half-open ranges [10, 15), [20, 30) -// @thrift.ReserveIds{ids = [3, 8], id_ranges = {10: 15, 20: 30}} -// struct Foo { -// ... -// 3: i64 f; // Build failure: 3 cannot be used -// } -// -// Attributes: -// - Ids: Individual ids that cannot be used. -// - IdRanges: Represents ranges of ids that cannot be used. -// -// Each (key: value) pair represents the half-open range `[key, value)`, -// where `key` is included and `value` is not. For example, the map -// `{10: 15, 20: 30}` represents the union of id/value ranges `[10, 15)` and -// `[20, 30)`. -type ReserveIds struct { - Ids []int32 `thrift:"ids,1" db:"ids" json:"ids"` - IdRanges map[int32]int32 `thrift:"id_ranges,2" db:"id_ranges" json:"id_ranges"` -} - -func NewReserveIds() *ReserveIds { - return &ReserveIds{} -} - - -func (p *ReserveIds) GetIds() []int32 { - return p.Ids -} - -func (p *ReserveIds) GetIdRanges() map[int32]int32 { - return p.IdRanges -} -type ReserveIdsBuilder struct { - obj *ReserveIds -} - -func NewReserveIdsBuilder() *ReserveIdsBuilder{ - return &ReserveIdsBuilder{ - obj: NewReserveIds(), - } -} - -func (p ReserveIdsBuilder) Emit() *ReserveIds{ - return &ReserveIds{ - Ids: p.obj.Ids, - IdRanges: p.obj.IdRanges, - } -} - -func (r *ReserveIdsBuilder) Ids(ids []int32) *ReserveIdsBuilder { - r.obj.Ids = ids - return r -} - -func (r *ReserveIdsBuilder) IdRanges(idRanges map[int32]int32) *ReserveIdsBuilder { - r.obj.IdRanges = idRanges - return r -} - -func (r *ReserveIds) SetIds(ids []int32) *ReserveIds { - r.Ids = ids - return r -} - -func (r *ReserveIds) SetIdRanges(idRanges map[int32]int32) *ReserveIds { - r.IdRanges = idRanges - return r -} - -func (p *ReserveIds) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ReserveIds) ReadField1(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]int32, 0, size) - p.Ids = tSlice - for i := 0; i < size; i ++ { - var _elem0 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem0 = v - } - p.Ids = append(p.Ids, _elem0) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *ReserveIds) ReadField2(iprot thrift.Protocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[int32]int32, size) - p.IdRanges = tMap - for i := 0; i < size; i ++ { - var _key1 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key1 = v - } - var _val2 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _val2 = v - } - p.IdRanges[_key1] = _val2 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *ReserveIds) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("ReserveIds"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *ReserveIds) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("ids", thrift.LIST, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:ids: ", p), err) } - if err := oprot.WriteListBegin(thrift.I32, len(p.Ids)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.Ids { - if err := oprot.WriteI32(int32(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:ids: ", p), err) } - return err -} - -func (p *ReserveIds) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("id_ranges", thrift.MAP, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:id_ranges: ", p), err) } - if err := oprot.WriteMapBegin(thrift.I32, thrift.I32, len(p.IdRanges)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.IdRanges { - if err := oprot.WriteI32(int32(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := oprot.WriteI32(int32(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:id_ranges: ", p), err) } - return err -} - -func (p *ReserveIds) String() string { - if p == nil { - return "" - } - - idsVal := fmt.Sprintf("%v", p.Ids) - idRangesVal := fmt.Sprintf("%v", p.IdRanges) - return fmt.Sprintf("ReserveIds({Ids:%s IdRanges:%s})", idsVal, idRangesVal) -} - -// Indicates additional backward compatibility restrictions, beyond the -// standard Thrift required 'wire' compatibility. -// -// Attributes: -// - FieldName -type RequiresBackwardCompatibility struct { - FieldName bool `thrift:"field_name,1" db:"field_name" json:"field_name"` -} - -func NewRequiresBackwardCompatibility() *RequiresBackwardCompatibility { - return &RequiresBackwardCompatibility{} -} - - -func (p *RequiresBackwardCompatibility) GetFieldName() bool { - return p.FieldName -} -type RequiresBackwardCompatibilityBuilder struct { - obj *RequiresBackwardCompatibility -} - -func NewRequiresBackwardCompatibilityBuilder() *RequiresBackwardCompatibilityBuilder{ - return &RequiresBackwardCompatibilityBuilder{ - obj: NewRequiresBackwardCompatibility(), - } -} - -func (p RequiresBackwardCompatibilityBuilder) Emit() *RequiresBackwardCompatibility{ - return &RequiresBackwardCompatibility{ - FieldName: p.obj.FieldName, - } -} - -func (r *RequiresBackwardCompatibilityBuilder) FieldName(fieldName bool) *RequiresBackwardCompatibilityBuilder { - r.obj.FieldName = fieldName - return r -} - -func (r *RequiresBackwardCompatibility) SetFieldName(fieldName bool) *RequiresBackwardCompatibility { - r.FieldName = fieldName - return r -} - -func (p *RequiresBackwardCompatibility) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *RequiresBackwardCompatibility) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.FieldName = v - } - return nil -} - -func (p *RequiresBackwardCompatibility) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("RequiresBackwardCompatibility"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *RequiresBackwardCompatibility) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("field_name", thrift.BOOL, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:field_name: ", p), err) } - if err := oprot.WriteBool(bool(p.FieldName)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.field_name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:field_name: ", p), err) } - return err -} - -func (p *RequiresBackwardCompatibility) String() string { - if p == nil { - return "" - } - - fieldNameVal := fmt.Sprintf("%v", p.FieldName) - return fmt.Sprintf("RequiresBackwardCompatibility({FieldName:%s})", fieldNameVal) -} - -// An annotation that changes the field qualifier from 'none' to 'terse'. -// A terse field is eligible to skip serialization, when it equals to the -// intrinsic default value. It also clears to the intrinsic default value -// before deserialization to distinguish between if a terse field was skipped -// or missing during serialization. This is different from an unqualified -// field, as an unqualified field is always serialized regardless of its value, -// and it is not cleared before deserialization. -// -// The annotation can be only used to annotate an unqualified field, and when -// it is annotating a struct or exception, it changes all unqualified fields to -// terse fields. Note, the annotation can not be used for union. -type TerseWrite struct { -} - -func NewTerseWrite() *TerseWrite { - return &TerseWrite{} -} - -type TerseWriteBuilder struct { - obj *TerseWrite -} - -func NewTerseWriteBuilder() *TerseWriteBuilder{ - return &TerseWriteBuilder{ - obj: NewTerseWrite(), - } -} - -func (p TerseWriteBuilder) Emit() *TerseWrite{ - return &TerseWrite{ - } -} - -func (p *TerseWrite) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *TerseWrite) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("TerseWrite"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *TerseWrite) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("TerseWrite({})") -} - -// Indicates that an optional field's value should never be stored on the stack, -// i.e. the subobject should be allocated separately (e.g. because it is large and infrequently set). -// -// NOTE: The APIs and initialization behavior are same as normal field, but different from `@cpp.Ref`. e.g. -// -// ``` -// struct Foo { -// 1: optional i32 normal; -// @thrift.Box -// 2: optional i32 boxed; -// @cpp.Ref -// 3: optional i32 referred; -// } -// ``` -// in C++ -// -// ``` -// Foo foo; -// EXPECT_FALSE(foo.normal().has_value()); // okay -// EXPECT_FALSE(foo.boxed().has_value()); // okay -// EXPECT_FALSE(foo.referred().has_value()); // build failure: std::unique_ptr doesn't have has_value method -// -// EXPECT_EQ(*foo.normal(), 0); // throw bad_field_access exception -// EXPECT_EQ(*foo.boxed(), 0); // throw bad_field_access exception -// EXPECT_EQ(*foo.referred(), 0); // okay, field has value by default -// ``` -// -// Affects C++ and Rust. -// TODO: replace with @cpp.Box + @rust.Box -type Box struct { -} - -func NewBox() *Box { - return &Box{} -} - -type BoxBuilder struct { - obj *Box -} - -func NewBoxBuilder() *BoxBuilder{ - return &BoxBuilder{ - obj: NewBox(), - } -} - -func (p BoxBuilder) Emit() *Box{ - return &Box{ - } -} - -func (p *Box) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Box) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Box"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Box) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Box({})") -} - -// Indicates whether the nested fields are accessible directly. -// https://github.com/facebook/fbthrift/blob/v2023.11.20.00/thrift/doc/idl/mixins.md -type Mixin struct { -} - -func NewMixin() *Mixin { - return &Mixin{} -} - -type MixinBuilder struct { - obj *Mixin -} - -func NewMixinBuilder() *MixinBuilder{ - return &MixinBuilder{ - obj: NewMixin(), - } -} - -func (p MixinBuilder) Emit() *Mixin{ - return &Mixin{ - } -} - -func (p *Mixin) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Mixin) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Mixin"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Mixin) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Mixin({})") -} - -// Option to serialize thrift struct in ascending field id order instead of field declaration order. -// -// This can potentially make serialized data size smaller in compact protocol, -// since compact protocol can write deltas between subsequent field ids instead of full ids. -// -// NOTE: This annotation won't reduce payload size for other protocols. -type SerializeInFieldIdOrder struct { -} - -func NewSerializeInFieldIdOrder() *SerializeInFieldIdOrder { - return &SerializeInFieldIdOrder{} -} - -type SerializeInFieldIdOrderBuilder struct { - obj *SerializeInFieldIdOrder -} - -func NewSerializeInFieldIdOrderBuilder() *SerializeInFieldIdOrderBuilder{ - return &SerializeInFieldIdOrderBuilder{ - obj: NewSerializeInFieldIdOrder(), - } -} - -func (p SerializeInFieldIdOrderBuilder) Emit() *SerializeInFieldIdOrder{ - return &SerializeInFieldIdOrder{ - } -} - -func (p *SerializeInFieldIdOrder) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *SerializeInFieldIdOrder) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("SerializeInFieldIdOrder"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *SerializeInFieldIdOrder) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("SerializeInFieldIdOrder({})") -} - -// Indicates an enum is a bitmask and should support bit-wise operators. -// Currently generates additional code in C++ and Hack. -type BitmaskEnum struct { -} - -func NewBitmaskEnum() *BitmaskEnum { - return &BitmaskEnum{} -} - -type BitmaskEnumBuilder struct { - obj *BitmaskEnum -} - -func NewBitmaskEnumBuilder() *BitmaskEnumBuilder{ - return &BitmaskEnumBuilder{ - obj: NewBitmaskEnum(), - } -} - -func (p BitmaskEnumBuilder) Emit() *BitmaskEnum{ - return &BitmaskEnum{ - } -} - -func (p *BitmaskEnum) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *BitmaskEnum) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("BitmaskEnum"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *BitmaskEnum) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("BitmaskEnum({})") -} - -// Specifies the field where the exception message is stored. -type ExceptionMessage struct { -} - -func NewExceptionMessage() *ExceptionMessage { - return &ExceptionMessage{} -} - -type ExceptionMessageBuilder struct { - obj *ExceptionMessage -} - -func NewExceptionMessageBuilder() *ExceptionMessageBuilder{ - return &ExceptionMessageBuilder{ - obj: NewExceptionMessage(), - } -} - -func (p ExceptionMessageBuilder) Emit() *ExceptionMessage{ - return &ExceptionMessage{ - } -} - -func (p *ExceptionMessage) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ExceptionMessage) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("ExceptionMessage"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *ExceptionMessage) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("ExceptionMessage({})") -} - -// Generates a const of type schema. Struct containing the schema of the -// annotated type. Optionally specify name to override default -// schema. -// -// Attributes: -// - Name -type GenerateRuntimeSchema struct { - Name string `thrift:"name,1" db:"name" json:"name"` -} - -func NewGenerateRuntimeSchema() *GenerateRuntimeSchema { - return &GenerateRuntimeSchema{} -} - - -func (p *GenerateRuntimeSchema) GetName() string { - return p.Name -} -type GenerateRuntimeSchemaBuilder struct { - obj *GenerateRuntimeSchema -} - -func NewGenerateRuntimeSchemaBuilder() *GenerateRuntimeSchemaBuilder{ - return &GenerateRuntimeSchemaBuilder{ - obj: NewGenerateRuntimeSchema(), - } -} - -func (p GenerateRuntimeSchemaBuilder) Emit() *GenerateRuntimeSchema{ - return &GenerateRuntimeSchema{ - Name: p.obj.Name, - } -} - -func (g *GenerateRuntimeSchemaBuilder) Name(name string) *GenerateRuntimeSchemaBuilder { - g.obj.Name = name - return g -} - -func (g *GenerateRuntimeSchema) SetName(name string) *GenerateRuntimeSchema { - g.Name = name - return g -} - -func (p *GenerateRuntimeSchema) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *GenerateRuntimeSchema) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Name = v - } - return nil -} - -func (p *GenerateRuntimeSchema) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("GenerateRuntimeSchema"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *GenerateRuntimeSchema) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) } - if err := oprot.WriteString(string(p.Name)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) } - return err -} - -func (p *GenerateRuntimeSchema) String() string { - if p == nil { - return "" - } - - nameVal := fmt.Sprintf("%v", p.Name) - return fmt.Sprintf("GenerateRuntimeSchema({Name:%s})", nameVal) -} - -// Indicates that a field's value should never be stored on the stack, and that -// identical values can be shared in immutable contexts. -type InternBox struct { -} - -func NewInternBox() *InternBox { - return &InternBox{} -} - -type InternBoxBuilder struct { - obj *InternBox -} - -func NewInternBoxBuilder() *InternBoxBuilder{ - return &InternBoxBuilder{ - obj: NewInternBox(), - } -} - -func (p InternBoxBuilder) Emit() *InternBox{ - return &InternBox{ - } -} - -func (p *InternBox) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *InternBox) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("InternBox"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *InternBox) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("InternBox({})") -} - -// Indicates that an interaction's methods should be processed sequentially. -type Serial struct { -} - -func NewSerial() *Serial { - return &Serial{} -} - -type SerialBuilder struct { - obj *Serial -} - -func NewSerialBuilder() *SerialBuilder{ - return &SerialBuilder{ - obj: NewSerial(), - } -} - -func (p SerialBuilder) Emit() *Serial{ - return &Serial{ - } -} - -func (p *Serial) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Serial) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Serial"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Serial) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Serial({})") -} - -// Changes the URI of this definition away from the default-generated one. -// -// Attributes: -// - Value -type Uri struct { - Value string `thrift:"value,1" db:"value" json:"value"` -} - -func NewUri() *Uri { - return &Uri{} -} - - -func (p *Uri) GetValue() string { - return p.Value -} -type UriBuilder struct { - obj *Uri -} - -func NewUriBuilder() *UriBuilder{ - return &UriBuilder{ - obj: NewUri(), - } -} - -func (p UriBuilder) Emit() *Uri{ - return &Uri{ - Value: p.obj.Value, - } -} - -func (u *UriBuilder) Value(value string) *UriBuilder { - u.obj.Value = value - return u -} - -func (u *Uri) SetValue(value string) *Uri { - u.Value = value - return u -} - -func (p *Uri) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Uri) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Value = v - } - return nil -} - -func (p *Uri) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Uri"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Uri) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("value", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:value: ", p), err) } - if err := oprot.WriteString(string(p.Value)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.value (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:value: ", p), err) } - return err -} - -func (p *Uri) String() string { - if p == nil { - return "" - } - - valueVal := fmt.Sprintf("%v", p.Value) - return fmt.Sprintf("Uri({Value:%s})", valueVal) -} - -// Changes the priority of this function (default NORMAL). -// -// Attributes: -// - Level -type Priority struct { - Level RpcPriority `thrift:"level,1" db:"level" json:"level"` -} - -func NewPriority() *Priority { - return &Priority{} -} - - -func (p *Priority) GetLevel() RpcPriority { - return p.Level -} -type PriorityBuilder struct { - obj *Priority -} - -func NewPriorityBuilder() *PriorityBuilder{ - return &PriorityBuilder{ - obj: NewPriority(), - } -} - -func (p PriorityBuilder) Emit() *Priority{ - return &Priority{ - Level: p.obj.Level, - } -} - -func (p *PriorityBuilder) Level(level RpcPriority) *PriorityBuilder { - p.obj.Level = level - return p -} - -func (p *Priority) SetLevel(level RpcPriority) *Priority { - p.Level = level - return p -} - -func (p *Priority) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Priority) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - temp := RpcPriority(v) - p.Level = temp - } - return nil -} - -func (p *Priority) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Priority"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Priority) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("level", thrift.I32, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:level: ", p), err) } - if err := oprot.WriteI32(int32(p.Level)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.level (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:level: ", p), err) } - return err -} - -func (p *Priority) String() string { - if p == nil { - return "" - } - - levelVal := fmt.Sprintf("%v", p.Level) - return fmt.Sprintf("Priority({Level:%s})", levelVal) -} - -// Applies unstructured annotations to a definition. -// -// Attributes: -// - Items -type DeprecatedUnvalidatedAnnotations struct { - Items map[string]string `thrift:"items,1" db:"items" json:"items"` -} - -func NewDeprecatedUnvalidatedAnnotations() *DeprecatedUnvalidatedAnnotations { - return &DeprecatedUnvalidatedAnnotations{} -} - - -func (p *DeprecatedUnvalidatedAnnotations) GetItems() map[string]string { - return p.Items -} -type DeprecatedUnvalidatedAnnotationsBuilder struct { - obj *DeprecatedUnvalidatedAnnotations -} - -func NewDeprecatedUnvalidatedAnnotationsBuilder() *DeprecatedUnvalidatedAnnotationsBuilder{ - return &DeprecatedUnvalidatedAnnotationsBuilder{ - obj: NewDeprecatedUnvalidatedAnnotations(), - } -} - -func (p DeprecatedUnvalidatedAnnotationsBuilder) Emit() *DeprecatedUnvalidatedAnnotations{ - return &DeprecatedUnvalidatedAnnotations{ - Items: p.obj.Items, - } -} - -func (d *DeprecatedUnvalidatedAnnotationsBuilder) Items(items map[string]string) *DeprecatedUnvalidatedAnnotationsBuilder { - d.obj.Items = items - return d -} - -func (d *DeprecatedUnvalidatedAnnotations) SetItems(items map[string]string) *DeprecatedUnvalidatedAnnotations { - d.Items = items - return d -} - -func (p *DeprecatedUnvalidatedAnnotations) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *DeprecatedUnvalidatedAnnotations) ReadField1(iprot thrift.Protocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[string]string, size) - p.Items = tMap - for i := 0; i < size; i ++ { - var _key3 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key3 = v - } - var _val4 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _val4 = v - } - p.Items[_key3] = _val4 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *DeprecatedUnvalidatedAnnotations) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("DeprecatedUnvalidatedAnnotations"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *DeprecatedUnvalidatedAnnotations) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("items", thrift.MAP, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:items: ", p), err) } - if err := oprot.WriteMapBegin(thrift.STRING, thrift.STRING, len(p.Items)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.Items { - if err := oprot.WriteString(string(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := oprot.WriteString(string(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:items: ", p), err) } - return err -} - -func (p *DeprecatedUnvalidatedAnnotations) String() string { - if p == nil { - return "" - } - - itemsVal := fmt.Sprintf("%v", p.Items) - return fmt.Sprintf("DeprecatedUnvalidatedAnnotations({Items:%s})", itemsVal) -} - diff --git a/thrift/compiler/test/fixtures/constants/gen-go/module/constants.go b/thrift/compiler/test/fixtures/constants/gen-go/module/constants.go deleted file mode 100644 index 756ec42b95c..00000000000 --- a/thrift/compiler/test/fixtures/constants/gen-go/module/constants.go +++ /dev/null @@ -1,396 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package module - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -const MyInt = 1337 -const Name = "Mark Zuckerberg" -const MultiLineString = "This\nis a\nmulti line string.\n" -var States []map[string]int32 -const X = 1 -const Y = 1000000 -const Z = 1e+09 -const ZeroDoubleValue = 0 -const LongDoubleValue = 2.59961e-05 -var MyCompany MyCompany -var Foo MyStringIdentifier -var Bar MyIntIdentifier -var Mymap MyMapIdentifier -var Instagram *Internship -var PartialConst *Internship -var KRanges []*Range -var InternList []*Internship -var Pod_0 *Struct1 -var PodS_0 *Struct1 -var Pod_1 *Struct1 -var PodS_1 *Struct1 -var Pod_2 *Struct2 -var PodTrailingCommas *Struct2 -var PodS_2 *Struct2 -var Pod_3 *Struct3 -var PodS_3 *Struct3 -var Pod_4 *Struct4 -var U_1_1 *Union1 -var U_1_2 *Union1 -var U_1_3 *Union1 -var U_2_1 *Union2 -var U_2_2 *Union2 -var U_2_3 *Union2 -var U_2_4 *Union2 -var U_2_5 *Union2 -var U_2_6 *Union2 -const Apostrophe = "'" -const TripleApostrophe = "'''" -const QuotationMark = "\"" -const Backslash = "\\" -const EscapedA = "a" -var Char2ascii map[string]int32 -var EscapedStrings []string -const FalseC = false -const TrueC = true -const ZeroByte = 0 -const Zero16 = 0 -const Zero32 = 0 -const Zero64 = 0 -const ZeroDotZero = 0 -const EmptyString = "" -var EmptyIntList []int32 -var EmptyStringList []string -var EmptyIntSet []int32 -var EmptyStringSet []string -var EmptyIntIntMap map[int32]int32 -var EmptyIntStringMap map[int32]string -var EmptyStringIntMap map[string]int32 -var EmptyStringStringMap map[string]string -const MaxIntDec = 9223372036854775807 -const MaxIntOct = 9223372036854775807 -const MaxIntHex = 9223372036854775807 -const MaxIntBin = 9223372036854775807 -const MaxDub = 1.79769e+308 -const MinDub = 2.22507e-308 -const MinSDub = 4.94066e-324 -const MaxPIntDec = 9223372036854775807 -const MaxPIntOct = 9223372036854775807 -const MaxPIntHex = 9223372036854775807 -const MaxPIntBin = 9223372036854775807 -const MaxPDub = 1.79769e+308 -const MinPDub = 2.22507e-308 -const MinPSDub = 4.94066e-324 -const MinIntDec = -9223372036854775808 -const MinIntOct = -9223372036854775808 -const MinIntHex = -9223372036854775808 -const MinIntBin = -9223372036854775808 -const MaxNDub = -1.79769e+308 -const MinNDub = -2.22507e-308 -const MinNSDub = -4.94066e-324 -var I2B map[int32]bool -var I2B_REF map[int32]bool -var const_lit_Instagram_employer Company = 3 -var const_lit_Instagram_compensation float64 = 1200 -var const_lit_Instagram_school string = "Monters University" -var const_lit_InternList_0_employer Company = 3 -var const_lit_InternList_0_compensation float64 = 1200 -var const_lit_InternList_0_school string = "Monters University" -var const_lit_InternList_1_employer Company = 0 -var const_lit_InternList_1_compensation float64 = 1000 -var const_lit_Pod_4_b float64 = 0.333 -var const_lit_Pod_4_c int8 = 25 -var const_lit_U_1_1_i int32 = 97 -var const_lit_U_1_2_d float64 = 5.6 -var const_lit_U_2_1_i int32 = 51 -var const_lit_U_2_2_d float64 = 6.7 -var const_lit_U_2_4_u_i int32 = 43 -var const_lit_U_2_5_u_d float64 = 9.8 - -func init() { -States = []map[string]int32{ - map[string]int32{ - "San Diego": 3211000, - "Sacramento": 479600, - "SF": 837400, - }, - map[string]int32{ - "New York": 8406000, - "Albany": 98400, - }, -} - -MyCompany = 0 - -Foo = "foo" - -Bar = 42 - -Mymap = map[string]string{ - "keys": "values", -} - -Instagram = &Internship{ - Weeks: 12, - Title: "Software Engineer", - Employer: &const_lit_Instagram_employer, - Compensation: &const_lit_Instagram_compensation, - School: &const_lit_Instagram_school, -} - -PartialConst = &Internship{ - Weeks: 8, - Title: "Some Job", -} - -KRanges = []*Range{ - &Range{ - Min: 1, - Max: 2, - }, - &Range{ - Min: 5, - Max: 6, - }, -} - -InternList = []*Internship{ - &Internship{ - Weeks: 12, - Title: "Software Engineer", - Employer: &const_lit_InternList_0_employer, - Compensation: &const_lit_InternList_0_compensation, - School: &const_lit_InternList_0_school, - }, - &Internship{ - Weeks: 10, - Title: "Sales Intern", - Employer: &const_lit_InternList_1_employer, - Compensation: &const_lit_InternList_1_compensation, - }, -} - -Pod_0 = &Struct1{ -} - -PodS_0 = &Struct1{ -} - -Pod_1 = &Struct1{ - A: 10, - B: "foo", -} - -PodS_1 = &Struct1{ - A: 10, - B: "foo", -} - -Pod_2 = &Struct2{ - A: 98, - B: "gaz", - C: &Struct1{ - A: 12, - B: "bar", - }, - D: []int32{ - 11, - 22, - 33, - }, -} - -PodTrailingCommas = &Struct2{ - A: 98, - B: "gaz", - C: &Struct1{ - A: 12, - B: "bar", - }, - D: []int32{ - 11, - 22, - 33, - }, -} - -PodS_2 = &Struct2{ - A: 98, - B: "gaz", - C: &Struct1{ - A: 12, - B: "bar", - }, - D: []int32{ - 11, - 22, - 33, - }, -} - -Pod_3 = &Struct3{ - A: "abc", - B: 456, - C: &Struct2{ - A: 888, - C: &Struct1{ - B: "gaz", - }, - D: []int32{ - 1, - 2, - 3, - }, - }, -} - -PodS_3 = &Struct3{ - A: "abc", - B: 456, - C: &Struct2{ - A: 888, - C: &Struct1{ - B: "gaz", - }, - D: []int32{ - 1, - 2, - 3, - }, - }, -} - -Pod_4 = &Struct4{ - A: 1234, - B: &const_lit_Pod_4_b, - C: &const_lit_Pod_4_c, -} - -U_1_1 = &Union1{ - I: &const_lit_U_1_1_i, -} - -U_1_2 = &Union1{ - D: &const_lit_U_1_2_d, -} - -U_1_3 = &Union1{ -} - -U_2_1 = &Union2{ - I: &const_lit_U_2_1_i, -} - -U_2_2 = &Union2{ - D: &const_lit_U_2_2_d, -} - -U_2_3 = &Union2{ - S: &Struct1{ - A: 8, - B: "abacabb", - }, -} - -U_2_4 = &Union2{ - U: &Union1{ - I: &const_lit_U_2_4_u_i, - }, -} - -U_2_5 = &Union2{ - U: &Union1{ - D: &const_lit_U_2_5_u_d, - }, -} - -U_2_6 = &Union2{ - U: &Union1{ - }, -} - -Char2ascii = map[string]int32{ - "'": 39, - "\"": 34, - "\\": 92, - "a": 97, -} - -EscapedStrings = []string{ - "", - "", - " ", - "'", - "\"", - "\n", - "\r", - "\t", - "a", - "«", - "j", - "¦", - "ayyy", - "«yyy", - "jyyy", - "¦yyy", - "zzza", - "zzz«", - "zzzj", - "zzz¦", - "zzzayyy", - "zzz«yyy", - "zzzjyyy", - "zzz¦yyy", -} - -EmptyIntList = []int32{ -} - -EmptyStringList = []string{ -} - -EmptyIntSet = []int32{ -} - -EmptyStringSet = []string{ -} - -EmptyIntIntMap = map[int32]int32{ -} - -EmptyIntStringMap = map[int32]string{ -} - -EmptyStringIntMap = map[string]int32{ -} - -EmptyStringStringMap = map[string]string{ -} - -I2B = map[int32]bool{ - 0: false, - 1: true, - 2: true, - 3: false, -} - -I2B_REF = map[int32]bool{ - 0: false, - 1: true, - 2: true, - 3: false, -} - -} - diff --git a/thrift/compiler/test/fixtures/constants/gen-go/module/ttypes.go b/thrift/compiler/test/fixtures/constants/gen-go/module/ttypes.go deleted file mode 100644 index e99ce713a64..00000000000 --- a/thrift/compiler/test/fixtures/constants/gen-go/module/ttypes.go +++ /dev/null @@ -1,2060 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package module - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var GoUnusedProtection__ int; - -type EmptyEnum int64 -const ( -) - -var EmptyEnumToName = map[EmptyEnum]string { -} - -var EmptyEnumToValue = map[string]EmptyEnum { -} - -var EmptyEnumNames = []string { -} - -var EmptyEnumValues = []EmptyEnum { -} - -func (p EmptyEnum) String() string { - if v, ok := EmptyEnumToName[p]; ok { - return v - } - return "" -} - -func EmptyEnumFromString(s string) (EmptyEnum, error) { - if v, ok := EmptyEnumToValue[s]; ok { - return v, nil - } - return EmptyEnum(0), fmt.Errorf("not a valid EmptyEnum string") -} - -func EmptyEnumPtr(v EmptyEnum) *EmptyEnum { return &v } - -type City int64 -const ( - City_NYC City = 0 - City_MPK City = 1 - City_SEA City = 2 - City_LON City = 3 -) - -var CityToName = map[City]string { - City_NYC: "NYC", - City_MPK: "MPK", - City_SEA: "SEA", - City_LON: "LON", -} - -var CityToValue = map[string]City { - "NYC": City_NYC, - "MPK": City_MPK, - "SEA": City_SEA, - "LON": City_LON, -} - -var CityNames = []string { - "NYC", - "MPK", - "SEA", - "LON", -} - -var CityValues = []City { - City_NYC, - City_MPK, - City_SEA, - City_LON, -} - -func (p City) String() string { - if v, ok := CityToName[p]; ok { - return v - } - return "" -} - -func CityFromString(s string) (City, error) { - if v, ok := CityToValue[s]; ok { - return v, nil - } - return City(0), fmt.Errorf("not a valid City string") -} - -func CityPtr(v City) *City { return &v } - -type Company int64 -const ( - Company_FACEBOOK Company = 0 - Company_WHATSAPP Company = 1 - Company_OCULUS Company = 2 - Company_INSTAGRAM Company = 3 -) - -var CompanyToName = map[Company]string { - Company_FACEBOOK: "FACEBOOK", - Company_WHATSAPP: "WHATSAPP", - Company_OCULUS: "OCULUS", - Company_INSTAGRAM: "INSTAGRAM", -} - -var CompanyToValue = map[string]Company { - "FACEBOOK": Company_FACEBOOK, - "WHATSAPP": Company_WHATSAPP, - "OCULUS": Company_OCULUS, - "INSTAGRAM": Company_INSTAGRAM, -} - -var CompanyNames = []string { - "FACEBOOK", - "WHATSAPP", - "OCULUS", - "INSTAGRAM", -} - -var CompanyValues = []Company { - Company_FACEBOOK, - Company_WHATSAPP, - Company_OCULUS, - Company_INSTAGRAM, -} - -func (p Company) String() string { - if v, ok := CompanyToName[p]; ok { - return v - } - return "" -} - -func CompanyFromString(s string) (Company, error) { - if v, ok := CompanyToValue[s]; ok { - return v, nil - } - return Company(0), fmt.Errorf("not a valid Company string") -} - -func CompanyPtr(v Company) *Company { return &v } - -type MyCompany = Company - -func MyCompanyPtr(v MyCompany) *MyCompany { return &v } - -type MyStringIdentifier = string - -func MyStringIdentifierPtr(v MyStringIdentifier) *MyStringIdentifier { return &v } - -type MyIntIdentifier = int32 - -func MyIntIdentifierPtr(v MyIntIdentifier) *MyIntIdentifier { return &v } - -type MyMapIdentifier = map[string]string - -func MyMapIdentifierPtr(v MyMapIdentifier) *MyMapIdentifier { return &v } - -// Attributes: -// - Weeks -// - Title -// - Employer -// - Compensation -// - School -type Internship struct { - Weeks int32 `thrift:"weeks,1,required" db:"weeks" json:"weeks"` - Title string `thrift:"title,2" db:"title" json:"title"` - Employer *Company `thrift:"employer,3,optional" db:"employer" json:"employer,omitempty"` - Compensation *float64 `thrift:"compensation,4,optional" db:"compensation" json:"compensation,omitempty"` - School *string `thrift:"school,5,optional" db:"school" json:"school,omitempty"` -} - -func NewInternship() *Internship { - return &Internship{} -} - - -func (p *Internship) GetWeeks() int32 { - return p.Weeks -} - -func (p *Internship) GetTitle() string { - return p.Title -} -var Internship_Employer_DEFAULT Company -func (p *Internship) GetEmployer() Company { - if !p.IsSetEmployer() { - return Internship_Employer_DEFAULT - } - return *p.Employer -} -var Internship_Compensation_DEFAULT float64 -func (p *Internship) GetCompensation() float64 { - if !p.IsSetCompensation() { - return Internship_Compensation_DEFAULT - } - return *p.Compensation -} -var Internship_School_DEFAULT string -func (p *Internship) GetSchool() string { - if !p.IsSetSchool() { - return Internship_School_DEFAULT - } - return *p.School -} -func (p *Internship) IsSetEmployer() bool { - return p != nil && p.Employer != nil -} - -func (p *Internship) IsSetCompensation() bool { - return p != nil && p.Compensation != nil -} - -func (p *Internship) IsSetSchool() bool { - return p != nil && p.School != nil -} - -type InternshipBuilder struct { - obj *Internship -} - -func NewInternshipBuilder() *InternshipBuilder{ - return &InternshipBuilder{ - obj: NewInternship(), - } -} - -func (p InternshipBuilder) Emit() *Internship{ - return &Internship{ - Weeks: p.obj.Weeks, - Title: p.obj.Title, - Employer: p.obj.Employer, - Compensation: p.obj.Compensation, - School: p.obj.School, - } -} - -func (i *InternshipBuilder) Weeks(weeks int32) *InternshipBuilder { - i.obj.Weeks = weeks - return i -} - -func (i *InternshipBuilder) Title(title string) *InternshipBuilder { - i.obj.Title = title - return i -} - -func (i *InternshipBuilder) Employer(employer *Company) *InternshipBuilder { - i.obj.Employer = employer - return i -} - -func (i *InternshipBuilder) Compensation(compensation *float64) *InternshipBuilder { - i.obj.Compensation = compensation - return i -} - -func (i *InternshipBuilder) School(school *string) *InternshipBuilder { - i.obj.School = school - return i -} - -func (i *Internship) SetWeeks(weeks int32) *Internship { - i.Weeks = weeks - return i -} - -func (i *Internship) SetTitle(title string) *Internship { - i.Title = title - return i -} - -func (i *Internship) SetEmployer(employer *Company) *Internship { - i.Employer = employer - return i -} - -func (i *Internship) SetCompensation(compensation *float64) *Internship { - i.Compensation = compensation - return i -} - -func (i *Internship) SetSchool(school *string) *Internship { - i.School = school - return i -} - -func (p *Internship) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - var issetWeeks bool = false; - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - issetWeeks = true - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 3: - if err := p.ReadField3(iprot); err != nil { - return err - } - case 4: - if err := p.ReadField4(iprot); err != nil { - return err - } - case 5: - if err := p.ReadField5(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - if !issetWeeks{ - return thrift.NewProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field Weeks is not set")); - } - return nil -} - -func (p *Internship) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Weeks = v - } - return nil -} - -func (p *Internship) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Title = v - } - return nil -} - -func (p *Internship) ReadField3(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 3: ", err) - } else { - temp := Company(v) - p.Employer = &temp - } - return nil -} - -func (p *Internship) ReadField4(iprot thrift.Protocol) error { - if v, err := iprot.ReadDouble(); err != nil { - return thrift.PrependError("error reading field 4: ", err) - } else { - p.Compensation = &v - } - return nil -} - -func (p *Internship) ReadField5(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 5: ", err) - } else { - p.School = &v - } - return nil -} - -func (p *Internship) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Internship"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := p.writeField4(oprot); err != nil { return err } - if err := p.writeField5(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Internship) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("weeks", thrift.I32, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:weeks: ", p), err) } - if err := oprot.WriteI32(int32(p.Weeks)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.weeks (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:weeks: ", p), err) } - return err -} - -func (p *Internship) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("title", thrift.STRING, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:title: ", p), err) } - if err := oprot.WriteString(string(p.Title)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.title (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:title: ", p), err) } - return err -} - -func (p *Internship) writeField3(oprot thrift.Protocol) (err error) { - if p.IsSetEmployer() { - if err := oprot.WriteFieldBegin("employer", thrift.I32, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:employer: ", p), err) } - if err := oprot.WriteI32(int32(*p.Employer)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.employer (3) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:employer: ", p), err) } - } - return err -} - -func (p *Internship) writeField4(oprot thrift.Protocol) (err error) { - if p.IsSetCompensation() { - if err := oprot.WriteFieldBegin("compensation", thrift.DOUBLE, 4); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:compensation: ", p), err) } - if err := oprot.WriteDouble(float64(*p.Compensation)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.compensation (4) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 4:compensation: ", p), err) } - } - return err -} - -func (p *Internship) writeField5(oprot thrift.Protocol) (err error) { - if p.IsSetSchool() { - if err := oprot.WriteFieldBegin("school", thrift.STRING, 5); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:school: ", p), err) } - if err := oprot.WriteString(string(*p.School)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.school (5) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 5:school: ", p), err) } - } - return err -} - -func (p *Internship) String() string { - if p == nil { - return "" - } - - weeksVal := fmt.Sprintf("%v", p.Weeks) - titleVal := fmt.Sprintf("%v", p.Title) - var employerVal string - if p.Employer == nil { - employerVal = "" - } else { - employerVal = fmt.Sprintf("%v", *p.Employer) - } - var compensationVal string - if p.Compensation == nil { - compensationVal = "" - } else { - compensationVal = fmt.Sprintf("%v", *p.Compensation) - } - var schoolVal string - if p.School == nil { - schoolVal = "" - } else { - schoolVal = fmt.Sprintf("%v", *p.School) - } - return fmt.Sprintf("Internship({Weeks:%s Title:%s Employer:%s Compensation:%s School:%s})", weeksVal, titleVal, employerVal, compensationVal, schoolVal) -} - -// Attributes: -// - Min -// - Max -type Range struct { - Min int32 `thrift:"min,1,required" db:"min" json:"min"` - Max int32 `thrift:"max,2,required" db:"max" json:"max"` -} - -func NewRange() *Range { - return &Range{} -} - - -func (p *Range) GetMin() int32 { - return p.Min -} - -func (p *Range) GetMax() int32 { - return p.Max -} -type RangeBuilder struct { - obj *Range -} - -func NewRangeBuilder() *RangeBuilder{ - return &RangeBuilder{ - obj: NewRange(), - } -} - -func (p RangeBuilder) Emit() *Range{ - return &Range{ - Min: p.obj.Min, - Max: p.obj.Max, - } -} - -func (r *RangeBuilder) Min(min int32) *RangeBuilder { - r.obj.Min = min - return r -} - -func (r *RangeBuilder) Max(max int32) *RangeBuilder { - r.obj.Max = max - return r -} - -func (r *Range) SetMin(min int32) *Range { - r.Min = min - return r -} - -func (r *Range) SetMax(max int32) *Range { - r.Max = max - return r -} - -func (p *Range) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - var issetMin bool = false; - var issetMax bool = false; - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - issetMin = true - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - issetMax = true - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - if !issetMin{ - return thrift.NewProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field Min is not set")); - } - if !issetMax{ - return thrift.NewProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field Max is not set")); - } - return nil -} - -func (p *Range) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Min = v - } - return nil -} - -func (p *Range) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Max = v - } - return nil -} - -func (p *Range) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Range"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Range) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("min", thrift.I32, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:min: ", p), err) } - if err := oprot.WriteI32(int32(p.Min)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.min (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:min: ", p), err) } - return err -} - -func (p *Range) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("max", thrift.I32, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:max: ", p), err) } - if err := oprot.WriteI32(int32(p.Max)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.max (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:max: ", p), err) } - return err -} - -func (p *Range) String() string { - if p == nil { - return "" - } - - minVal := fmt.Sprintf("%v", p.Min) - maxVal := fmt.Sprintf("%v", p.Max) - return fmt.Sprintf("Range({Min:%s Max:%s})", minVal, maxVal) -} - -// Attributes: -// - A -// - B -type Struct1 struct { - A int32 `thrift:"a,1" db:"a" json:"a"` - B string `thrift:"b,2" db:"b" json:"b"` -} - -func NewStruct1() *Struct1 { - return &Struct1{ - A: 1234567, - B: "", - } -} - - -func (p *Struct1) GetA() int32 { - return p.A -} - -func (p *Struct1) GetB() string { - return p.B -} -type Struct1Builder struct { - obj *Struct1 -} - -func NewStruct1Builder() *Struct1Builder{ - return &Struct1Builder{ - obj: NewStruct1(), - } -} - -func (p Struct1Builder) Emit() *Struct1{ - return &Struct1{ - A: p.obj.A, - B: p.obj.B, - } -} - -func (s *Struct1Builder) A(a int32) *Struct1Builder { - s.obj.A = a - return s -} - -func (s *Struct1Builder) B(b string) *Struct1Builder { - s.obj.B = b - return s -} - -func (s *Struct1) SetA(a int32) *Struct1 { - s.A = a - return s -} - -func (s *Struct1) SetB(b string) *Struct1 { - s.B = b - return s -} - -func (p *Struct1) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Struct1) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.A = v - } - return nil -} - -func (p *Struct1) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.B = v - } - return nil -} - -func (p *Struct1) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("struct1"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Struct1) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("a", thrift.I32, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:a: ", p), err) } - if err := oprot.WriteI32(int32(p.A)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.a (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:a: ", p), err) } - return err -} - -func (p *Struct1) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("b", thrift.STRING, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:b: ", p), err) } - if err := oprot.WriteString(string(p.B)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.b (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:b: ", p), err) } - return err -} - -func (p *Struct1) String() string { - if p == nil { - return "" - } - - aVal := fmt.Sprintf("%v", p.A) - bVal := fmt.Sprintf("%v", p.B) - return fmt.Sprintf("Struct1({A:%s B:%s})", aVal, bVal) -} - -// Attributes: -// - A -// - B -// - C -// - D -type Struct2 struct { - A int32 `thrift:"a,1" db:"a" json:"a"` - B string `thrift:"b,2" db:"b" json:"b"` - C *Struct1 `thrift:"c,3" db:"c" json:"c"` - D []int32 `thrift:"d,4" db:"d" json:"d"` -} - -func NewStruct2() *Struct2 { - return &Struct2{ - C: NewStruct1(), - } -} - - -func (p *Struct2) GetA() int32 { - return p.A -} - -func (p *Struct2) GetB() string { - return p.B -} -var Struct2_C_DEFAULT *Struct1 -func (p *Struct2) GetC() *Struct1 { - if !p.IsSetC() { - return Struct2_C_DEFAULT - } - return p.C -} -func (p *Struct2) DefaultGetC() *Struct1 { - if !p.IsSetC() { - return NewStruct1() - } - return p.C -} - -func (p *Struct2) GetD() []int32 { - return p.D -} -func (p *Struct2) IsSetC() bool { - return p != nil && p.C != nil -} - -type Struct2Builder struct { - obj *Struct2 -} - -func NewStruct2Builder() *Struct2Builder{ - return &Struct2Builder{ - obj: NewStruct2(), - } -} - -func (p Struct2Builder) Emit() *Struct2{ - return &Struct2{ - A: p.obj.A, - B: p.obj.B, - C: p.obj.C, - D: p.obj.D, - } -} - -func (s *Struct2Builder) A(a int32) *Struct2Builder { - s.obj.A = a - return s -} - -func (s *Struct2Builder) B(b string) *Struct2Builder { - s.obj.B = b - return s -} - -func (s *Struct2Builder) C(c *Struct1) *Struct2Builder { - s.obj.C = c - return s -} - -func (s *Struct2Builder) D(d []int32) *Struct2Builder { - s.obj.D = d - return s -} - -func (s *Struct2) SetA(a int32) *Struct2 { - s.A = a - return s -} - -func (s *Struct2) SetB(b string) *Struct2 { - s.B = b - return s -} - -func (s *Struct2) SetC(c *Struct1) *Struct2 { - s.C = c - return s -} - -func (s *Struct2) SetD(d []int32) *Struct2 { - s.D = d - return s -} - -func (p *Struct2) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 3: - if err := p.ReadField3(iprot); err != nil { - return err - } - case 4: - if err := p.ReadField4(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Struct2) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.A = v - } - return nil -} - -func (p *Struct2) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.B = v - } - return nil -} - -func (p *Struct2) ReadField3(iprot thrift.Protocol) error { - p.C = NewStruct1() - if err := p.C.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.C), err) - } - return nil -} - -func (p *Struct2) ReadField4(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]int32, 0, size) - p.D = tSlice - for i := 0; i < size; i ++ { - var _elem0 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem0 = v - } - p.D = append(p.D, _elem0) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *Struct2) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("struct2"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := p.writeField4(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Struct2) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("a", thrift.I32, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:a: ", p), err) } - if err := oprot.WriteI32(int32(p.A)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.a (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:a: ", p), err) } - return err -} - -func (p *Struct2) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("b", thrift.STRING, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:b: ", p), err) } - if err := oprot.WriteString(string(p.B)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.b (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:b: ", p), err) } - return err -} - -func (p *Struct2) writeField3(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("c", thrift.STRUCT, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:c: ", p), err) } - if err := p.C.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.C), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:c: ", p), err) } - return err -} - -func (p *Struct2) writeField4(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("d", thrift.LIST, 4); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:d: ", p), err) } - if err := oprot.WriteListBegin(thrift.I32, len(p.D)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.D { - if err := oprot.WriteI32(int32(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 4:d: ", p), err) } - return err -} - -func (p *Struct2) String() string { - if p == nil { - return "" - } - - aVal := fmt.Sprintf("%v", p.A) - bVal := fmt.Sprintf("%v", p.B) - var cVal string - if p.C == nil { - cVal = "" - } else { - cVal = fmt.Sprintf("%v", p.C) - } - dVal := fmt.Sprintf("%v", p.D) - return fmt.Sprintf("Struct2({A:%s B:%s C:%s D:%s})", aVal, bVal, cVal, dVal) -} - -// Attributes: -// - A -// - B -// - C -type Struct3 struct { - A string `thrift:"a,1" db:"a" json:"a"` - B int32 `thrift:"b,2" db:"b" json:"b"` - C *Struct2 `thrift:"c,3" db:"c" json:"c"` -} - -func NewStruct3() *Struct3 { - return &Struct3{ - C: NewStruct2(), - } -} - - -func (p *Struct3) GetA() string { - return p.A -} - -func (p *Struct3) GetB() int32 { - return p.B -} -var Struct3_C_DEFAULT *Struct2 -func (p *Struct3) GetC() *Struct2 { - if !p.IsSetC() { - return Struct3_C_DEFAULT - } - return p.C -} -func (p *Struct3) DefaultGetC() *Struct2 { - if !p.IsSetC() { - return NewStruct2() - } - return p.C -} -func (p *Struct3) IsSetC() bool { - return p != nil && p.C != nil -} - -type Struct3Builder struct { - obj *Struct3 -} - -func NewStruct3Builder() *Struct3Builder{ - return &Struct3Builder{ - obj: NewStruct3(), - } -} - -func (p Struct3Builder) Emit() *Struct3{ - return &Struct3{ - A: p.obj.A, - B: p.obj.B, - C: p.obj.C, - } -} - -func (s *Struct3Builder) A(a string) *Struct3Builder { - s.obj.A = a - return s -} - -func (s *Struct3Builder) B(b int32) *Struct3Builder { - s.obj.B = b - return s -} - -func (s *Struct3Builder) C(c *Struct2) *Struct3Builder { - s.obj.C = c - return s -} - -func (s *Struct3) SetA(a string) *Struct3 { - s.A = a - return s -} - -func (s *Struct3) SetB(b int32) *Struct3 { - s.B = b - return s -} - -func (s *Struct3) SetC(c *Struct2) *Struct3 { - s.C = c - return s -} - -func (p *Struct3) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 3: - if err := p.ReadField3(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Struct3) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.A = v - } - return nil -} - -func (p *Struct3) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.B = v - } - return nil -} - -func (p *Struct3) ReadField3(iprot thrift.Protocol) error { - p.C = NewStruct2() - if err := p.C.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.C), err) - } - return nil -} - -func (p *Struct3) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("struct3"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Struct3) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("a", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:a: ", p), err) } - if err := oprot.WriteString(string(p.A)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.a (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:a: ", p), err) } - return err -} - -func (p *Struct3) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("b", thrift.I32, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:b: ", p), err) } - if err := oprot.WriteI32(int32(p.B)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.b (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:b: ", p), err) } - return err -} - -func (p *Struct3) writeField3(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("c", thrift.STRUCT, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:c: ", p), err) } - if err := p.C.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.C), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:c: ", p), err) } - return err -} - -func (p *Struct3) String() string { - if p == nil { - return "" - } - - aVal := fmt.Sprintf("%v", p.A) - bVal := fmt.Sprintf("%v", p.B) - var cVal string - if p.C == nil { - cVal = "" - } else { - cVal = fmt.Sprintf("%v", p.C) - } - return fmt.Sprintf("Struct3({A:%s B:%s C:%s})", aVal, bVal, cVal) -} - -// Attributes: -// - A -// - B -// - C -type Struct4 struct { - A int32 `thrift:"a,1" db:"a" json:"a"` - B *float64 `thrift:"b,2,optional" db:"b" json:"b,omitempty"` - C *int8 `thrift:"c,3,optional" db:"c" json:"c,omitempty"` -} - -func NewStruct4() *Struct4 { - return &Struct4{} -} - - -func (p *Struct4) GetA() int32 { - return p.A -} -var Struct4_B_DEFAULT float64 -func (p *Struct4) GetB() float64 { - if !p.IsSetB() { - return Struct4_B_DEFAULT - } - return *p.B -} -var Struct4_C_DEFAULT int8 -func (p *Struct4) GetC() int8 { - if !p.IsSetC() { - return Struct4_C_DEFAULT - } - return *p.C -} -func (p *Struct4) IsSetB() bool { - return p != nil && p.B != nil -} - -func (p *Struct4) IsSetC() bool { - return p != nil && p.C != nil -} - -type Struct4Builder struct { - obj *Struct4 -} - -func NewStruct4Builder() *Struct4Builder{ - return &Struct4Builder{ - obj: NewStruct4(), - } -} - -func (p Struct4Builder) Emit() *Struct4{ - return &Struct4{ - A: p.obj.A, - B: p.obj.B, - C: p.obj.C, - } -} - -func (s *Struct4Builder) A(a int32) *Struct4Builder { - s.obj.A = a - return s -} - -func (s *Struct4Builder) B(b *float64) *Struct4Builder { - s.obj.B = b - return s -} - -func (s *Struct4Builder) C(c *int8) *Struct4Builder { - s.obj.C = c - return s -} - -func (s *Struct4) SetA(a int32) *Struct4 { - s.A = a - return s -} - -func (s *Struct4) SetB(b *float64) *Struct4 { - s.B = b - return s -} - -func (s *Struct4) SetC(c *int8) *Struct4 { - s.C = c - return s -} - -func (p *Struct4) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 3: - if err := p.ReadField3(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Struct4) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.A = v - } - return nil -} - -func (p *Struct4) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadDouble(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.B = &v - } - return nil -} - -func (p *Struct4) ReadField3(iprot thrift.Protocol) error { - if v, err := iprot.ReadByte(); err != nil { - return thrift.PrependError("error reading field 3: ", err) - } else { - temp := int8(v) - p.C = &temp - } - return nil -} - -func (p *Struct4) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("struct4"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Struct4) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("a", thrift.I32, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:a: ", p), err) } - if err := oprot.WriteI32(int32(p.A)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.a (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:a: ", p), err) } - return err -} - -func (p *Struct4) writeField2(oprot thrift.Protocol) (err error) { - if p.IsSetB() { - if err := oprot.WriteFieldBegin("b", thrift.DOUBLE, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:b: ", p), err) } - if err := oprot.WriteDouble(float64(*p.B)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.b (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:b: ", p), err) } - } - return err -} - -func (p *Struct4) writeField3(oprot thrift.Protocol) (err error) { - if p.IsSetC() { - if err := oprot.WriteFieldBegin("c", thrift.BYTE, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:c: ", p), err) } - if err := oprot.WriteByte(byte(*p.C)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.c (3) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:c: ", p), err) } - } - return err -} - -func (p *Struct4) String() string { - if p == nil { - return "" - } - - aVal := fmt.Sprintf("%v", p.A) - var bVal string - if p.B == nil { - bVal = "" - } else { - bVal = fmt.Sprintf("%v", *p.B) - } - var cVal string - if p.C == nil { - cVal = "" - } else { - cVal = fmt.Sprintf("%v", *p.C) - } - return fmt.Sprintf("Struct4({A:%s B:%s C:%s})", aVal, bVal, cVal) -} - -// Attributes: -// - I -// - D -type Union1 struct { - I *int32 `thrift:"i,1,optional" db:"i" json:"i,omitempty"` - D *float64 `thrift:"d,2,optional" db:"d" json:"d,omitempty"` -} - -func NewUnion1() *Union1 { - return &Union1{} -} - -var Union1_I_DEFAULT int32 -func (p *Union1) GetI() int32 { - if !p.IsSetI() { - return Union1_I_DEFAULT - } - return *p.I -} -var Union1_D_DEFAULT float64 -func (p *Union1) GetD() float64 { - if !p.IsSetD() { - return Union1_D_DEFAULT - } - return *p.D -} -func (p *Union1) CountSetFieldsUnion1() int { - count := 0 - if (p.IsSetI()) { - count++ - } - if (p.IsSetD()) { - count++ - } - return count - -} - -func (p *Union1) IsSetI() bool { - return p != nil && p.I != nil -} - -func (p *Union1) IsSetD() bool { - return p != nil && p.D != nil -} - -type Union1Builder struct { - obj *Union1 -} - -func NewUnion1Builder() *Union1Builder{ - return &Union1Builder{ - obj: NewUnion1(), - } -} - -func (p Union1Builder) Emit() *Union1{ - return &Union1{ - I: p.obj.I, - D: p.obj.D, - } -} - -func (u *Union1Builder) I(i *int32) *Union1Builder { - u.obj.I = i - return u -} - -func (u *Union1Builder) D(d *float64) *Union1Builder { - u.obj.D = d - return u -} - -func (u *Union1) SetI(i *int32) *Union1 { - u.I = i - return u -} - -func (u *Union1) SetD(d *float64) *Union1 { - u.D = d - return u -} - -func (p *Union1) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Union1) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.I = &v - } - return nil -} - -func (p *Union1) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadDouble(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.D = &v - } - return nil -} - -func (p *Union1) Write(oprot thrift.Protocol) error { - if c := p.CountSetFieldsUnion1(); c > 1 { - return fmt.Errorf("%T write union: no more than one field must be set (%d set).", p, c) - } - if err := oprot.WriteStructBegin("union1"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Union1) writeField1(oprot thrift.Protocol) (err error) { - if p.IsSetI() { - if err := oprot.WriteFieldBegin("i", thrift.I32, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:i: ", p), err) } - if err := oprot.WriteI32(int32(*p.I)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.i (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:i: ", p), err) } - } - return err -} - -func (p *Union1) writeField2(oprot thrift.Protocol) (err error) { - if p.IsSetD() { - if err := oprot.WriteFieldBegin("d", thrift.DOUBLE, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:d: ", p), err) } - if err := oprot.WriteDouble(float64(*p.D)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.d (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:d: ", p), err) } - } - return err -} - -func (p *Union1) String() string { - if p == nil { - return "" - } - - var iVal string - if p.I == nil { - iVal = "" - } else { - iVal = fmt.Sprintf("%v", *p.I) - } - var dVal string - if p.D == nil { - dVal = "" - } else { - dVal = fmt.Sprintf("%v", *p.D) - } - return fmt.Sprintf("Union1({I:%s D:%s})", iVal, dVal) -} - -// Attributes: -// - I -// - D -// - S -// - U -type Union2 struct { - I *int32 `thrift:"i,1,optional" db:"i" json:"i,omitempty"` - D *float64 `thrift:"d,2,optional" db:"d" json:"d,omitempty"` - S *Struct1 `thrift:"s,3,optional" db:"s" json:"s,omitempty"` - U *Union1 `thrift:"u,4,optional" db:"u" json:"u,omitempty"` -} - -func NewUnion2() *Union2 { - return &Union2{} -} - -var Union2_I_DEFAULT int32 -func (p *Union2) GetI() int32 { - if !p.IsSetI() { - return Union2_I_DEFAULT - } - return *p.I -} -var Union2_D_DEFAULT float64 -func (p *Union2) GetD() float64 { - if !p.IsSetD() { - return Union2_D_DEFAULT - } - return *p.D -} -var Union2_S_DEFAULT *Struct1 -func (p *Union2) GetS() *Struct1 { - if !p.IsSetS() { - return Union2_S_DEFAULT - } - return p.S -} -func (p *Union2) DefaultGetS() *Struct1 { - if !p.IsSetS() { - return NewStruct1() - } - return p.S -} -var Union2_U_DEFAULT *Union1 -func (p *Union2) GetU() *Union1 { - if !p.IsSetU() { - return Union2_U_DEFAULT - } - return p.U -} -func (p *Union2) DefaultGetU() *Union1 { - if !p.IsSetU() { - return NewUnion1() - } - return p.U -} -func (p *Union2) CountSetFieldsUnion2() int { - count := 0 - if (p.IsSetI()) { - count++ - } - if (p.IsSetD()) { - count++ - } - if (p.IsSetS()) { - count++ - } - if (p.IsSetU()) { - count++ - } - return count - -} - -func (p *Union2) IsSetI() bool { - return p != nil && p.I != nil -} - -func (p *Union2) IsSetD() bool { - return p != nil && p.D != nil -} - -func (p *Union2) IsSetS() bool { - return p != nil && p.S != nil -} - -func (p *Union2) IsSetU() bool { - return p != nil && p.U != nil -} - -type Union2Builder struct { - obj *Union2 -} - -func NewUnion2Builder() *Union2Builder{ - return &Union2Builder{ - obj: NewUnion2(), - } -} - -func (p Union2Builder) Emit() *Union2{ - return &Union2{ - I: p.obj.I, - D: p.obj.D, - S: p.obj.S, - U: p.obj.U, - } -} - -func (u *Union2Builder) I(i *int32) *Union2Builder { - u.obj.I = i - return u -} - -func (u *Union2Builder) D(d *float64) *Union2Builder { - u.obj.D = d - return u -} - -func (u *Union2Builder) S(s *Struct1) *Union2Builder { - u.obj.S = s - return u -} - -func (un *Union2Builder) U(u *Union1) *Union2Builder { - un.obj.U = u - return un -} - -func (u *Union2) SetI(i *int32) *Union2 { - u.I = i - return u -} - -func (u *Union2) SetD(d *float64) *Union2 { - u.D = d - return u -} - -func (u *Union2) SetS(s *Struct1) *Union2 { - u.S = s - return u -} - -func (un *Union2) SetU(u *Union1) *Union2 { - un.U = u - return un -} - -func (p *Union2) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 3: - if err := p.ReadField3(iprot); err != nil { - return err - } - case 4: - if err := p.ReadField4(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Union2) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.I = &v - } - return nil -} - -func (p *Union2) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadDouble(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.D = &v - } - return nil -} - -func (p *Union2) ReadField3(iprot thrift.Protocol) error { - p.S = NewStruct1() - if err := p.S.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.S), err) - } - return nil -} - -func (p *Union2) ReadField4(iprot thrift.Protocol) error { - p.U = NewUnion1() - if err := p.U.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.U), err) - } - return nil -} - -func (p *Union2) Write(oprot thrift.Protocol) error { - if c := p.CountSetFieldsUnion2(); c > 1 { - return fmt.Errorf("%T write union: no more than one field must be set (%d set).", p, c) - } - if err := oprot.WriteStructBegin("union2"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := p.writeField4(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Union2) writeField1(oprot thrift.Protocol) (err error) { - if p.IsSetI() { - if err := oprot.WriteFieldBegin("i", thrift.I32, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:i: ", p), err) } - if err := oprot.WriteI32(int32(*p.I)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.i (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:i: ", p), err) } - } - return err -} - -func (p *Union2) writeField2(oprot thrift.Protocol) (err error) { - if p.IsSetD() { - if err := oprot.WriteFieldBegin("d", thrift.DOUBLE, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:d: ", p), err) } - if err := oprot.WriteDouble(float64(*p.D)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.d (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:d: ", p), err) } - } - return err -} - -func (p *Union2) writeField3(oprot thrift.Protocol) (err error) { - if p.IsSetS() { - if err := oprot.WriteFieldBegin("s", thrift.STRUCT, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:s: ", p), err) } - if err := p.S.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.S), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:s: ", p), err) } - } - return err -} - -func (p *Union2) writeField4(oprot thrift.Protocol) (err error) { - if p.IsSetU() { - if err := oprot.WriteFieldBegin("u", thrift.STRUCT, 4); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:u: ", p), err) } - if err := p.U.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.U), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 4:u: ", p), err) } - } - return err -} - -func (p *Union2) String() string { - if p == nil { - return "" - } - - var iVal string - if p.I == nil { - iVal = "" - } else { - iVal = fmt.Sprintf("%v", *p.I) - } - var dVal string - if p.D == nil { - dVal = "" - } else { - dVal = fmt.Sprintf("%v", *p.D) - } - var sVal string - if p.S == nil { - sVal = "" - } else { - sVal = fmt.Sprintf("%v", p.S) - } - var uVal string - if p.U == nil { - uVal = "" - } else { - uVal = fmt.Sprintf("%v", p.U) - } - return fmt.Sprintf("Union2({I:%s D:%s S:%s U:%s})", iVal, dVal, sVal, uVal) -} - diff --git a/thrift/compiler/test/fixtures/empty-struct/gen-go/module/constants.go b/thrift/compiler/test/fixtures/empty-struct/gen-go/module/constants.go deleted file mode 100644 index 477cf91a64b..00000000000 --- a/thrift/compiler/test/fixtures/empty-struct/gen-go/module/constants.go +++ /dev/null @@ -1,25 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package module - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - - -func init() { -} - diff --git a/thrift/compiler/test/fixtures/empty-struct/gen-go/module/ttypes.go b/thrift/compiler/test/fixtures/empty-struct/gen-go/module/ttypes.go deleted file mode 100644 index 4de36b458b4..00000000000 --- a/thrift/compiler/test/fixtures/empty-struct/gen-go/module/ttypes.go +++ /dev/null @@ -1,153 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package module - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var GoUnusedProtection__ int; - -type Empty struct { -} - -func NewEmpty() *Empty { - return &Empty{} -} - -type EmptyBuilder struct { - obj *Empty -} - -func NewEmptyBuilder() *EmptyBuilder{ - return &EmptyBuilder{ - obj: NewEmpty(), - } -} - -func (p EmptyBuilder) Emit() *Empty{ - return &Empty{ - } -} - -func (p *Empty) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Empty) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Empty"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Empty) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Empty({})") -} - -type Nada struct { -} - -func NewNada() *Nada { - return &Nada{} -} - -type NadaBuilder struct { - obj *Nada -} - -func NewNadaBuilder() *NadaBuilder{ - return &NadaBuilder{ - obj: NewNada(), - } -} - -func (p NadaBuilder) Emit() *Nada{ - return &Nada{ - } -} - -func (p *Nada) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Nada) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Nada"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Nada) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Nada({})") -} - diff --git a/thrift/compiler/test/fixtures/enums/gen-go/module/constants.go b/thrift/compiler/test/fixtures/enums/gen-go/module/constants.go deleted file mode 100644 index 477cf91a64b..00000000000 --- a/thrift/compiler/test/fixtures/enums/gen-go/module/constants.go +++ /dev/null @@ -1,25 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package module - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - - -func init() { -} - diff --git a/thrift/compiler/test/fixtures/enums/gen-go/module/ttypes.go b/thrift/compiler/test/fixtures/enums/gen-go/module/ttypes.go deleted file mode 100644 index e3c6f2644a1..00000000000 --- a/thrift/compiler/test/fixtures/enums/gen-go/module/ttypes.go +++ /dev/null @@ -1,914 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package module - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var GoUnusedProtection__ int; - -type Metasyntactic int64 -const ( - Metasyntactic_FOO Metasyntactic = 1 - Metasyntactic_BAR Metasyntactic = 2 - Metasyntactic_BAZ Metasyntactic = 3 - Metasyntactic_BAX Metasyntactic = 4 -) - -var MetasyntacticToName = map[Metasyntactic]string { - Metasyntactic_FOO: "FOO", - Metasyntactic_BAR: "BAR", - Metasyntactic_BAZ: "BAZ", - Metasyntactic_BAX: "BAX", -} - -var MetasyntacticToValue = map[string]Metasyntactic { - "FOO": Metasyntactic_FOO, - "BAR": Metasyntactic_BAR, - "BAZ": Metasyntactic_BAZ, - "BAX": Metasyntactic_BAX, -} - -var MetasyntacticNames = []string { - "FOO", - "BAR", - "BAZ", - "BAX", -} - -var MetasyntacticValues = []Metasyntactic { - Metasyntactic_FOO, - Metasyntactic_BAR, - Metasyntactic_BAZ, - Metasyntactic_BAX, -} - -func (p Metasyntactic) String() string { - if v, ok := MetasyntacticToName[p]; ok { - return v - } - return "" -} - -func MetasyntacticFromString(s string) (Metasyntactic, error) { - if v, ok := MetasyntacticToValue[s]; ok { - return v, nil - } - return Metasyntactic(0), fmt.Errorf("not a valid Metasyntactic string") -} - -func MetasyntacticPtr(v Metasyntactic) *Metasyntactic { return &v } - -type MyEnum1 int64 -const ( - MyEnum1_ME1_0 MyEnum1 = 0 - MyEnum1_ME1_1 MyEnum1 = 1 - MyEnum1_ME1_2 MyEnum1 = 2 - MyEnum1_ME1_3 MyEnum1 = 3 - MyEnum1_ME1_5 MyEnum1 = 5 - MyEnum1_ME1_6 MyEnum1 = 6 -) - -var MyEnum1ToName = map[MyEnum1]string { - MyEnum1_ME1_0: "ME1_0", - MyEnum1_ME1_1: "ME1_1", - MyEnum1_ME1_2: "ME1_2", - MyEnum1_ME1_3: "ME1_3", - MyEnum1_ME1_5: "ME1_5", - MyEnum1_ME1_6: "ME1_6", -} - -var MyEnum1ToValue = map[string]MyEnum1 { - "ME1_0": MyEnum1_ME1_0, - "ME1_1": MyEnum1_ME1_1, - "ME1_2": MyEnum1_ME1_2, - "ME1_3": MyEnum1_ME1_3, - "ME1_5": MyEnum1_ME1_5, - "ME1_6": MyEnum1_ME1_6, -} - -var MyEnum1Names = []string { - "ME1_0", - "ME1_1", - "ME1_2", - "ME1_3", - "ME1_5", - "ME1_6", -} - -var MyEnum1Values = []MyEnum1 { - MyEnum1_ME1_0, - MyEnum1_ME1_1, - MyEnum1_ME1_2, - MyEnum1_ME1_3, - MyEnum1_ME1_5, - MyEnum1_ME1_6, -} - -func (p MyEnum1) String() string { - if v, ok := MyEnum1ToName[p]; ok { - return v - } - return "" -} - -func MyEnum1FromString(s string) (MyEnum1, error) { - if v, ok := MyEnum1ToValue[s]; ok { - return v, nil - } - return MyEnum1(0), fmt.Errorf("not a valid MyEnum1 string") -} - -func MyEnum1Ptr(v MyEnum1) *MyEnum1 { return &v } - -type MyEnum2 int64 -const ( - MyEnum2_ME2_0 MyEnum2 = 0 - MyEnum2_ME2_1 MyEnum2 = 1 - MyEnum2_ME2_2 MyEnum2 = 2 -) - -var MyEnum2ToName = map[MyEnum2]string { - MyEnum2_ME2_0: "ME2_0", - MyEnum2_ME2_1: "ME2_1", - MyEnum2_ME2_2: "ME2_2", -} - -var MyEnum2ToValue = map[string]MyEnum2 { - "ME2_0": MyEnum2_ME2_0, - "ME2_1": MyEnum2_ME2_1, - "ME2_2": MyEnum2_ME2_2, -} - -var MyEnum2Names = []string { - "ME2_0", - "ME2_1", - "ME2_2", -} - -var MyEnum2Values = []MyEnum2 { - MyEnum2_ME2_0, - MyEnum2_ME2_1, - MyEnum2_ME2_2, -} - -func (p MyEnum2) String() string { - if v, ok := MyEnum2ToName[p]; ok { - return v - } - return "" -} - -func MyEnum2FromString(s string) (MyEnum2, error) { - if v, ok := MyEnum2ToValue[s]; ok { - return v, nil - } - return MyEnum2(0), fmt.Errorf("not a valid MyEnum2 string") -} - -func MyEnum2Ptr(v MyEnum2) *MyEnum2 { return &v } - -type MyEnum3 int64 -const ( - MyEnum3_ME3_0 MyEnum3 = 0 - MyEnum3_ME3_1 MyEnum3 = 1 - MyEnum3_ME3_N2 MyEnum3 = -2 - MyEnum3_ME3_N1 MyEnum3 = -1 - MyEnum3_ME3_9 MyEnum3 = 9 - MyEnum3_ME3_10 MyEnum3 = 10 -) - -var MyEnum3ToName = map[MyEnum3]string { - MyEnum3_ME3_0: "ME3_0", - MyEnum3_ME3_1: "ME3_1", - MyEnum3_ME3_N2: "ME3_N2", - MyEnum3_ME3_N1: "ME3_N1", - MyEnum3_ME3_9: "ME3_9", - MyEnum3_ME3_10: "ME3_10", -} - -var MyEnum3ToValue = map[string]MyEnum3 { - "ME3_0": MyEnum3_ME3_0, - "ME3_1": MyEnum3_ME3_1, - "ME3_N2": MyEnum3_ME3_N2, - "ME3_N1": MyEnum3_ME3_N1, - "ME3_9": MyEnum3_ME3_9, - "ME3_10": MyEnum3_ME3_10, -} - -var MyEnum3Names = []string { - "ME3_0", - "ME3_1", - "ME3_N2", - "ME3_N1", - "ME3_9", - "ME3_10", -} - -var MyEnum3Values = []MyEnum3 { - MyEnum3_ME3_0, - MyEnum3_ME3_1, - MyEnum3_ME3_N2, - MyEnum3_ME3_N1, - MyEnum3_ME3_9, - MyEnum3_ME3_10, -} - -func (p MyEnum3) String() string { - if v, ok := MyEnum3ToName[p]; ok { - return v - } - return "" -} - -func MyEnum3FromString(s string) (MyEnum3, error) { - if v, ok := MyEnum3ToValue[s]; ok { - return v, nil - } - return MyEnum3(0), fmt.Errorf("not a valid MyEnum3 string") -} - -func MyEnum3Ptr(v MyEnum3) *MyEnum3 { return &v } - -type MyEnum4 int64 -const ( - MyEnum4_ME4_A MyEnum4 = 2147483645 - MyEnum4_ME4_B MyEnum4 = 2147483646 - MyEnum4_ME4_C MyEnum4 = 2147483647 - MyEnum4_ME4_D MyEnum4 = -2147483648 -) - -var MyEnum4ToName = map[MyEnum4]string { - MyEnum4_ME4_A: "ME4_A", - MyEnum4_ME4_B: "ME4_B", - MyEnum4_ME4_C: "ME4_C", - MyEnum4_ME4_D: "ME4_D", -} - -var MyEnum4ToValue = map[string]MyEnum4 { - "ME4_A": MyEnum4_ME4_A, - "ME4_B": MyEnum4_ME4_B, - "ME4_C": MyEnum4_ME4_C, - "ME4_D": MyEnum4_ME4_D, -} - -var MyEnum4Names = []string { - "ME4_A", - "ME4_B", - "ME4_C", - "ME4_D", -} - -var MyEnum4Values = []MyEnum4 { - MyEnum4_ME4_A, - MyEnum4_ME4_B, - MyEnum4_ME4_C, - MyEnum4_ME4_D, -} - -func (p MyEnum4) String() string { - if v, ok := MyEnum4ToName[p]; ok { - return v - } - return "" -} - -func MyEnum4FromString(s string) (MyEnum4, error) { - if v, ok := MyEnum4ToValue[s]; ok { - return v, nil - } - return MyEnum4(0), fmt.Errorf("not a valid MyEnum4 string") -} - -func MyEnum4Ptr(v MyEnum4) *MyEnum4 { return &v } - -type MyBitmaskEnum1 int64 -const ( - MyBitmaskEnum1_ONE MyBitmaskEnum1 = 1 - MyBitmaskEnum1_TWO MyBitmaskEnum1 = 2 - MyBitmaskEnum1_FOUR MyBitmaskEnum1 = 4 -) - -var MyBitmaskEnum1ToName = map[MyBitmaskEnum1]string { - MyBitmaskEnum1_ONE: "ONE", - MyBitmaskEnum1_TWO: "TWO", - MyBitmaskEnum1_FOUR: "FOUR", -} - -var MyBitmaskEnum1ToValue = map[string]MyBitmaskEnum1 { - "ONE": MyBitmaskEnum1_ONE, - "TWO": MyBitmaskEnum1_TWO, - "FOUR": MyBitmaskEnum1_FOUR, -} - -var MyBitmaskEnum1Names = []string { - "ONE", - "TWO", - "FOUR", -} - -var MyBitmaskEnum1Values = []MyBitmaskEnum1 { - MyBitmaskEnum1_ONE, - MyBitmaskEnum1_TWO, - MyBitmaskEnum1_FOUR, -} - -func (p MyBitmaskEnum1) String() string { - if v, ok := MyBitmaskEnum1ToName[p]; ok { - return v - } - return "" -} - -func MyBitmaskEnum1FromString(s string) (MyBitmaskEnum1, error) { - if v, ok := MyBitmaskEnum1ToValue[s]; ok { - return v, nil - } - return MyBitmaskEnum1(0), fmt.Errorf("not a valid MyBitmaskEnum1 string") -} - -func MyBitmaskEnum1Ptr(v MyBitmaskEnum1) *MyBitmaskEnum1 { return &v } - -type MyBitmaskEnum2 int64 -const ( - MyBitmaskEnum2_ONE MyBitmaskEnum2 = 1 - MyBitmaskEnum2_TWO MyBitmaskEnum2 = 2 - MyBitmaskEnum2_FOUR MyBitmaskEnum2 = 4 -) - -var MyBitmaskEnum2ToName = map[MyBitmaskEnum2]string { - MyBitmaskEnum2_ONE: "ONE", - MyBitmaskEnum2_TWO: "TWO", - MyBitmaskEnum2_FOUR: "FOUR", -} - -var MyBitmaskEnum2ToValue = map[string]MyBitmaskEnum2 { - "ONE": MyBitmaskEnum2_ONE, - "TWO": MyBitmaskEnum2_TWO, - "FOUR": MyBitmaskEnum2_FOUR, -} - -var MyBitmaskEnum2Names = []string { - "ONE", - "TWO", - "FOUR", -} - -var MyBitmaskEnum2Values = []MyBitmaskEnum2 { - MyBitmaskEnum2_ONE, - MyBitmaskEnum2_TWO, - MyBitmaskEnum2_FOUR, -} - -func (p MyBitmaskEnum2) String() string { - if v, ok := MyBitmaskEnum2ToName[p]; ok { - return v - } - return "" -} - -func MyBitmaskEnum2FromString(s string) (MyBitmaskEnum2, error) { - if v, ok := MyBitmaskEnum2ToValue[s]; ok { - return v, nil - } - return MyBitmaskEnum2(0), fmt.Errorf("not a valid MyBitmaskEnum2 string") -} - -func MyBitmaskEnum2Ptr(v MyBitmaskEnum2) *MyBitmaskEnum2 { return &v } - -// Attributes: -// - Reasonable -// - Fine -// - Questionable -// - Tags -type SomeStruct struct { - Reasonable Metasyntactic `thrift:"reasonable,1" db:"reasonable" json:"reasonable"` - Fine Metasyntactic `thrift:"fine,2" db:"fine" json:"fine"` - Questionable Metasyntactic `thrift:"questionable,3" db:"questionable" json:"questionable"` - Tags []int32 `thrift:"tags,4" db:"tags" json:"tags"` -} - -func NewSomeStruct() *SomeStruct { - return &SomeStruct{ - Reasonable: 1, - Fine: 2, - Questionable: -1, - Tags: []int32{ - }, - } -} - - -func (p *SomeStruct) GetReasonable() Metasyntactic { - return p.Reasonable -} - -func (p *SomeStruct) GetFine() Metasyntactic { - return p.Fine -} - -func (p *SomeStruct) GetQuestionable() Metasyntactic { - return p.Questionable -} - -func (p *SomeStruct) GetTags() []int32 { - return p.Tags -} -type SomeStructBuilder struct { - obj *SomeStruct -} - -func NewSomeStructBuilder() *SomeStructBuilder{ - return &SomeStructBuilder{ - obj: NewSomeStruct(), - } -} - -func (p SomeStructBuilder) Emit() *SomeStruct{ - return &SomeStruct{ - Reasonable: p.obj.Reasonable, - Fine: p.obj.Fine, - Questionable: p.obj.Questionable, - Tags: p.obj.Tags, - } -} - -func (s *SomeStructBuilder) Reasonable(reasonable Metasyntactic) *SomeStructBuilder { - s.obj.Reasonable = reasonable - return s -} - -func (s *SomeStructBuilder) Fine(fine Metasyntactic) *SomeStructBuilder { - s.obj.Fine = fine - return s -} - -func (s *SomeStructBuilder) Questionable(questionable Metasyntactic) *SomeStructBuilder { - s.obj.Questionable = questionable - return s -} - -func (s *SomeStructBuilder) Tags(tags []int32) *SomeStructBuilder { - s.obj.Tags = tags - return s -} - -func (s *SomeStruct) SetReasonable(reasonable Metasyntactic) *SomeStruct { - s.Reasonable = reasonable - return s -} - -func (s *SomeStruct) SetFine(fine Metasyntactic) *SomeStruct { - s.Fine = fine - return s -} - -func (s *SomeStruct) SetQuestionable(questionable Metasyntactic) *SomeStruct { - s.Questionable = questionable - return s -} - -func (s *SomeStruct) SetTags(tags []int32) *SomeStruct { - s.Tags = tags - return s -} - -func (p *SomeStruct) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 3: - if err := p.ReadField3(iprot); err != nil { - return err - } - case 4: - if err := p.ReadField4(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *SomeStruct) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - temp := Metasyntactic(v) - p.Reasonable = temp - } - return nil -} - -func (p *SomeStruct) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - temp := Metasyntactic(v) - p.Fine = temp - } - return nil -} - -func (p *SomeStruct) ReadField3(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 3: ", err) - } else { - temp := Metasyntactic(v) - p.Questionable = temp - } - return nil -} - -func (p *SomeStruct) ReadField4(iprot thrift.Protocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return thrift.PrependError("error reading set begin: ", err) - } - tSet := make([]int32, 0, size) - p.Tags = tSet - for i := 0; i < size; i ++ { - var _elem0 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem0 = v - } - p.Tags = append(p.Tags, _elem0) - } - if err := iprot.ReadSetEnd(); err != nil { - return thrift.PrependError("error reading set end: ", err) - } - return nil -} - -func (p *SomeStruct) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("SomeStruct"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := p.writeField4(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *SomeStruct) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("reasonable", thrift.I32, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:reasonable: ", p), err) } - if err := oprot.WriteI32(int32(p.Reasonable)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.reasonable (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:reasonable: ", p), err) } - return err -} - -func (p *SomeStruct) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("fine", thrift.I32, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:fine: ", p), err) } - if err := oprot.WriteI32(int32(p.Fine)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.fine (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:fine: ", p), err) } - return err -} - -func (p *SomeStruct) writeField3(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("questionable", thrift.I32, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:questionable: ", p), err) } - if err := oprot.WriteI32(int32(p.Questionable)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.questionable (3) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:questionable: ", p), err) } - return err -} - -func (p *SomeStruct) writeField4(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("tags", thrift.SET, 4); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:tags: ", p), err) } - if err := oprot.WriteSetBegin(thrift.I32, len(p.Tags)); err != nil { - return thrift.PrependError("error writing set begin: ", err) - } - set := make(map[int32]bool, len(p.Tags)) - for _, v := range p.Tags { - if ok := set[v]; ok { - return thrift.PrependError("", fmt.Errorf("%T error writing set field: slice is not unique", v)) - } - set[v] = true - } - for _, v := range p.Tags { - if err := oprot.WriteI32(int32(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteSetEnd(); err != nil { - return thrift.PrependError("error writing set end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 4:tags: ", p), err) } - return err -} - -func (p *SomeStruct) String() string { - if p == nil { - return "" - } - - reasonableVal := fmt.Sprintf("%v", p.Reasonable) - fineVal := fmt.Sprintf("%v", p.Fine) - questionableVal := fmt.Sprintf("%v", p.Questionable) - tagsVal := fmt.Sprintf("%v", p.Tags) - return fmt.Sprintf("SomeStruct({Reasonable:%s Fine:%s Questionable:%s Tags:%s})", reasonableVal, fineVal, questionableVal, tagsVal) -} - -// Attributes: -// - Me2_3 -// - Me3N3 -// - Me1T1 -// - Me1T2 -type MyStruct struct { - Me2_3 MyEnum2 `thrift:"me2_3,1" db:"me2_3" json:"me2_3"` - Me3N3 MyEnum3 `thrift:"me3_n3,2" db:"me3_n3" json:"me3_n3"` - // unused field # 3 - Me1T1 MyEnum1 `thrift:"me1_t1,4" db:"me1_t1" json:"me1_t1"` - // unused field # 5 - Me1T2 MyEnum1 `thrift:"me1_t2,6" db:"me1_t2" json:"me1_t2"` -} - -func NewMyStruct() *MyStruct { - return &MyStruct{ - Me2_3: 3, - Me3N3: -3, - Me1T1: 1, - Me1T2: 1, - } -} - - -func (p *MyStruct) GetMe2_3() MyEnum2 { - return p.Me2_3 -} - -func (p *MyStruct) GetMe3N3() MyEnum3 { - return p.Me3N3 -} - -func (p *MyStruct) GetMe1T1() MyEnum1 { - return p.Me1T1 -} - -func (p *MyStruct) GetMe1T2() MyEnum1 { - return p.Me1T2 -} -type MyStructBuilder struct { - obj *MyStruct -} - -func NewMyStructBuilder() *MyStructBuilder{ - return &MyStructBuilder{ - obj: NewMyStruct(), - } -} - -func (p MyStructBuilder) Emit() *MyStruct{ - return &MyStruct{ - Me2_3: p.obj.Me2_3, - Me3N3: p.obj.Me3N3, - Me1T1: p.obj.Me1T1, - Me1T2: p.obj.Me1T2, - } -} - -func (m *MyStructBuilder) Me2_3(me2_3 MyEnum2) *MyStructBuilder { - m.obj.Me2_3 = me2_3 - return m -} - -func (m *MyStructBuilder) Me3N3(me3N3 MyEnum3) *MyStructBuilder { - m.obj.Me3N3 = me3N3 - return m -} - -func (m *MyStructBuilder) Me1T1(me1T1 MyEnum1) *MyStructBuilder { - m.obj.Me1T1 = me1T1 - return m -} - -func (m *MyStructBuilder) Me1T2(me1T2 MyEnum1) *MyStructBuilder { - m.obj.Me1T2 = me1T2 - return m -} - -func (m *MyStruct) SetMe2_3(me2_3 MyEnum2) *MyStruct { - m.Me2_3 = me2_3 - return m -} - -func (m *MyStruct) SetMe3N3(me3N3 MyEnum3) *MyStruct { - m.Me3N3 = me3N3 - return m -} - -func (m *MyStruct) SetMe1T1(me1T1 MyEnum1) *MyStruct { - m.Me1T1 = me1T1 - return m -} - -func (m *MyStruct) SetMe1T2(me1T2 MyEnum1) *MyStruct { - m.Me1T2 = me1T2 - return m -} - -func (p *MyStruct) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 4: - if err := p.ReadField4(iprot); err != nil { - return err - } - case 6: - if err := p.ReadField6(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyStruct) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - temp := MyEnum2(v) - p.Me2_3 = temp - } - return nil -} - -func (p *MyStruct) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - temp := MyEnum3(v) - p.Me3N3 = temp - } - return nil -} - -func (p *MyStruct) ReadField4(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 4: ", err) - } else { - temp := MyEnum1(v) - p.Me1T1 = temp - } - return nil -} - -func (p *MyStruct) ReadField6(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 6: ", err) - } else { - temp := MyEnum1(v) - p.Me1T2 = temp - } - return nil -} - -func (p *MyStruct) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("MyStruct"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField4(oprot); err != nil { return err } - if err := p.writeField6(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyStruct) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("me2_3", thrift.I32, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:me2_3: ", p), err) } - if err := oprot.WriteI32(int32(p.Me2_3)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.me2_3 (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:me2_3: ", p), err) } - return err -} - -func (p *MyStruct) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("me3_n3", thrift.I32, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:me3_n3: ", p), err) } - if err := oprot.WriteI32(int32(p.Me3N3)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.me3_n3 (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:me3_n3: ", p), err) } - return err -} - -func (p *MyStruct) writeField4(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("me1_t1", thrift.I32, 4); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:me1_t1: ", p), err) } - if err := oprot.WriteI32(int32(p.Me1T1)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.me1_t1 (4) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 4:me1_t1: ", p), err) } - return err -} - -func (p *MyStruct) writeField6(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("me1_t2", thrift.I32, 6); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 6:me1_t2: ", p), err) } - if err := oprot.WriteI32(int32(p.Me1T2)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.me1_t2 (6) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 6:me1_t2: ", p), err) } - return err -} - -func (p *MyStruct) String() string { - if p == nil { - return "" - } - - me2_3Val := fmt.Sprintf("%v", p.Me2_3) - me3N3Val := fmt.Sprintf("%v", p.Me3N3) - me1T1Val := fmt.Sprintf("%v", p.Me1T1) - me1T2Val := fmt.Sprintf("%v", p.Me1T2) - return fmt.Sprintf("MyStruct({Me2_3:%s Me3N3:%s Me1T1:%s Me1T2:%s})", me2_3Val, me3N3Val, me1T1Val, me1T2Val) -} - diff --git a/thrift/compiler/test/fixtures/enums/gen-go/thrift/annotation/scope/constants.go b/thrift/compiler/test/fixtures/enums/gen-go/thrift/annotation/scope/constants.go deleted file mode 100644 index 0c3448a7126..00000000000 --- a/thrift/compiler/test/fixtures/enums/gen-go/thrift/annotation/scope/constants.go +++ /dev/null @@ -1,25 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package scope - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - - -func init() { -} - diff --git a/thrift/compiler/test/fixtures/enums/gen-go/thrift/annotation/scope/ttypes.go b/thrift/compiler/test/fixtures/enums/gen-go/thrift/annotation/scope/ttypes.go deleted file mode 100644 index 580c39e775c..00000000000 --- a/thrift/compiler/test/fixtures/enums/gen-go/thrift/annotation/scope/ttypes.go +++ /dev/null @@ -1,1169 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package scope - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var GoUnusedProtection__ int; - -// Indicates that the scope of sibling annotations is transitive. -// -// For example: -// -// @scope.Struct -// @scope.Union -// @scope.Exception -// @scope.Transitive -// struct Structured {} -// -// Annotating a Thrift struct with @Structured automatically applies -// @scope.Struct, @scope.Union and @scope.Exception annotations, i.e. -// -// @Structured -// struct MyAnnotation {} -// -// is equivalent to -// -// @scope.Struct -// @scope.Union -// @scope.Exception -// struct MyAnnotation {} -// -type Transitive struct { -} - -func NewTransitive() *Transitive { - return &Transitive{} -} - -type TransitiveBuilder struct { - obj *Transitive -} - -func NewTransitiveBuilder() *TransitiveBuilder{ - return &TransitiveBuilder{ - obj: NewTransitive(), - } -} - -func (p TransitiveBuilder) Emit() *Transitive{ - return &Transitive{ - } -} - -func (p *Transitive) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Transitive) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Transitive"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Transitive) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Transitive({})") -} - -// The Program scope. -// -// This allows annotations on the `package` definition, which implies the -// annotaiton applies to the entire program. -type Program struct { -} - -func NewProgram() *Program { - return &Program{} -} - -type ProgramBuilder struct { - obj *Program -} - -func NewProgramBuilder() *ProgramBuilder{ - return &ProgramBuilder{ - obj: NewProgram(), - } -} - -func (p ProgramBuilder) Emit() *Program{ - return &Program{ - } -} - -func (p *Program) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Program) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Program"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Program) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Program({})") -} - -// The `struct` definition scope. -type Struct struct { -} - -func NewStruct() *Struct { - return &Struct{} -} - -type StructBuilder struct { - obj *Struct -} - -func NewStructBuilder() *StructBuilder{ - return &StructBuilder{ - obj: NewStruct(), - } -} - -func (p StructBuilder) Emit() *Struct{ - return &Struct{ - } -} - -func (p *Struct) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Struct) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Struct"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Struct) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Struct({})") -} - -// The `union` definition scope. -type Union struct { -} - -func NewUnion() *Union { - return &Union{} -} - -type UnionBuilder struct { - obj *Union -} - -func NewUnionBuilder() *UnionBuilder{ - return &UnionBuilder{ - obj: NewUnion(), - } -} - -func (p UnionBuilder) Emit() *Union{ - return &Union{ - } -} - -func (p *Union) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Union) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Union"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Union) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Union({})") -} - -// The `exception` definition scope. -type Exception struct { -} - -func NewException() *Exception { - return &Exception{} -} - -type ExceptionBuilder struct { - obj *Exception -} - -func NewExceptionBuilder() *ExceptionBuilder{ - return &ExceptionBuilder{ - obj: NewException(), - } -} - -func (p ExceptionBuilder) Emit() *Exception{ - return &Exception{ - } -} - -func (p *Exception) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Exception) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Exception"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Exception) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Exception({})") -} - -// Field declartaions, for example in `struct` or `function` declartions. -type Field struct { -} - -func NewField() *Field { - return &Field{} -} - -type FieldBuilder struct { - obj *Field -} - -func NewFieldBuilder() *FieldBuilder{ - return &FieldBuilder{ - obj: NewField(), - } -} - -func (p FieldBuilder) Emit() *Field{ - return &Field{ - } -} - -func (p *Field) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Field) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Field"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Field) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Field({})") -} - -// The `typedef` definition scope. -type Typedef struct { -} - -func NewTypedef() *Typedef { - return &Typedef{} -} - -type TypedefBuilder struct { - obj *Typedef -} - -func NewTypedefBuilder() *TypedefBuilder{ - return &TypedefBuilder{ - obj: NewTypedef(), - } -} - -func (p TypedefBuilder) Emit() *Typedef{ - return &Typedef{ - } -} - -func (p *Typedef) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Typedef) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Typedef"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Typedef) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Typedef({})") -} - -// The `service` definition scope. -type Service struct { -} - -func NewService() *Service { - return &Service{} -} - -type ServiceBuilder struct { - obj *Service -} - -func NewServiceBuilder() *ServiceBuilder{ - return &ServiceBuilder{ - obj: NewService(), - } -} - -func (p ServiceBuilder) Emit() *Service{ - return &Service{ - } -} - -func (p *Service) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Service) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Service"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Service) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Service({})") -} - -// The `interaction` definition scope. -type Interaction struct { -} - -func NewInteraction() *Interaction { - return &Interaction{} -} - -type InteractionBuilder struct { - obj *Interaction -} - -func NewInteractionBuilder() *InteractionBuilder{ - return &InteractionBuilder{ - obj: NewInteraction(), - } -} - -func (p InteractionBuilder) Emit() *Interaction{ - return &Interaction{ - } -} - -func (p *Interaction) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Interaction) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Interaction"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Interaction) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Interaction({})") -} - -// The `function` definition scope. -type Function struct { -} - -func NewFunction() *Function { - return &Function{} -} - -type FunctionBuilder struct { - obj *Function -} - -func NewFunctionBuilder() *FunctionBuilder{ - return &FunctionBuilder{ - obj: NewFunction(), - } -} - -func (p FunctionBuilder) Emit() *Function{ - return &Function{ - } -} - -func (p *Function) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Function) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Function"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Function) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Function({})") -} - -// The Enum value definition scope. -type EnumValue struct { -} - -func NewEnumValue() *EnumValue { - return &EnumValue{} -} - -type EnumValueBuilder struct { - obj *EnumValue -} - -func NewEnumValueBuilder() *EnumValueBuilder{ - return &EnumValueBuilder{ - obj: NewEnumValue(), - } -} - -func (p EnumValueBuilder) Emit() *EnumValue{ - return &EnumValue{ - } -} - -func (p *EnumValue) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *EnumValue) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("EnumValue"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *EnumValue) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("EnumValue({})") -} - -// The `const` definition scope. -type Const struct { -} - -func NewConst() *Const { - return &Const{} -} - -type ConstBuilder struct { - obj *Const -} - -func NewConstBuilder() *ConstBuilder{ - return &ConstBuilder{ - obj: NewConst(), - } -} - -func (p ConstBuilder) Emit() *Const{ - return &Const{ - } -} - -func (p *Const) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Const) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Const"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Const) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Const({})") -} - -type Enum struct { -} - -func NewEnum() *Enum { - return &Enum{} -} - -type EnumBuilder struct { - obj *Enum -} - -func NewEnumBuilder() *EnumBuilder{ - return &EnumBuilder{ - obj: NewEnum(), - } -} - -func (p EnumBuilder) Emit() *Enum{ - return &Enum{ - } -} - -func (p *Enum) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Enum) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Enum"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Enum) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Enum({})") -} - -// A scope that includes all 'structured' definitions. -type Structured struct { -} - -func NewStructured() *Structured { - return &Structured{} -} - -type StructuredBuilder struct { - obj *Structured -} - -func NewStructuredBuilder() *StructuredBuilder{ - return &StructuredBuilder{ - obj: NewStructured(), - } -} - -func (p StructuredBuilder) Emit() *Structured{ - return &Structured{ - } -} - -func (p *Structured) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Structured) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Structured"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Structured) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Structured({})") -} - -// A scope that includes all 'interface' definitions. -type Interface struct { -} - -func NewInterface() *Interface { - return &Interface{} -} - -type InterfaceBuilder struct { - obj *Interface -} - -func NewInterfaceBuilder() *InterfaceBuilder{ - return &InterfaceBuilder{ - obj: NewInterface(), - } -} - -func (p InterfaceBuilder) Emit() *Interface{ - return &Interface{ - } -} - -func (p *Interface) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Interface) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Interface"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Interface) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Interface({})") -} - -// A scope that includes all program-scoped definition. -type RootDefinition struct { -} - -func NewRootDefinition() *RootDefinition { - return &RootDefinition{} -} - -type RootDefinitionBuilder struct { - obj *RootDefinition -} - -func NewRootDefinitionBuilder() *RootDefinitionBuilder{ - return &RootDefinitionBuilder{ - obj: NewRootDefinition(), - } -} - -func (p RootDefinitionBuilder) Emit() *RootDefinition{ - return &RootDefinition{ - } -} - -func (p *RootDefinition) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *RootDefinition) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("RootDefinition"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *RootDefinition) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("RootDefinition({})") -} - -// A scope that includes all definitions. -type Definition struct { -} - -func NewDefinition() *Definition { - return &Definition{} -} - -type DefinitionBuilder struct { - obj *Definition -} - -func NewDefinitionBuilder() *DefinitionBuilder{ - return &DefinitionBuilder{ - obj: NewDefinition(), - } -} - -func (p DefinitionBuilder) Emit() *Definition{ - return &Definition{ - } -} - -func (p *Definition) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Definition) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Definition"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Definition) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Definition({})") -} - diff --git a/thrift/compiler/test/fixtures/enums/gen-go/thrift/annotation/thrift/constants.go b/thrift/compiler/test/fixtures/enums/gen-go/thrift/annotation/thrift/constants.go deleted file mode 100644 index 50d9b0fe3ee..00000000000 --- a/thrift/compiler/test/fixtures/enums/gen-go/thrift/annotation/thrift/constants.go +++ /dev/null @@ -1,25 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package thrift - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - - -func init() { -} - diff --git a/thrift/compiler/test/fixtures/enums/gen-go/thrift/annotation/thrift/ttypes.go b/thrift/compiler/test/fixtures/enums/gen-go/thrift/annotation/thrift/ttypes.go deleted file mode 100644 index 35ea75e3dd0..00000000000 --- a/thrift/compiler/test/fixtures/enums/gen-go/thrift/annotation/thrift/ttypes.go +++ /dev/null @@ -1,1545 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package thrift - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var GoUnusedProtection__ int; - -type RpcPriority int64 -const ( - RpcPriority_HIGH_IMPORTANT RpcPriority = 0 - RpcPriority_HIGH RpcPriority = 1 - RpcPriority_IMPORTANT RpcPriority = 2 - RpcPriority_NORMAL RpcPriority = 3 - RpcPriority_BEST_EFFORT RpcPriority = 4 -) - -var RpcPriorityToName = map[RpcPriority]string { - RpcPriority_HIGH_IMPORTANT: "HIGH_IMPORTANT", - RpcPriority_HIGH: "HIGH", - RpcPriority_IMPORTANT: "IMPORTANT", - RpcPriority_NORMAL: "NORMAL", - RpcPriority_BEST_EFFORT: "BEST_EFFORT", -} - -var RpcPriorityToValue = map[string]RpcPriority { - "HIGH_IMPORTANT": RpcPriority_HIGH_IMPORTANT, - "HIGH": RpcPriority_HIGH, - "IMPORTANT": RpcPriority_IMPORTANT, - "NORMAL": RpcPriority_NORMAL, - "BEST_EFFORT": RpcPriority_BEST_EFFORT, -} - -var RpcPriorityNames = []string { - "HIGH_IMPORTANT", - "HIGH", - "IMPORTANT", - "NORMAL", - "BEST_EFFORT", -} - -var RpcPriorityValues = []RpcPriority { - RpcPriority_HIGH_IMPORTANT, - RpcPriority_HIGH, - RpcPriority_IMPORTANT, - RpcPriority_NORMAL, - RpcPriority_BEST_EFFORT, -} - -func (p RpcPriority) String() string { - if v, ok := RpcPriorityToName[p]; ok { - return v - } - return "" -} - -func RpcPriorityFromString(s string) (RpcPriority, error) { - if v, ok := RpcPriorityToValue[s]; ok { - return v, nil - } - return RpcPriority(0), fmt.Errorf("not a valid RpcPriority string") -} - -func RpcPriorityPtr(v RpcPriority) *RpcPriority { return &v } - -// Indicates a definition/feature should only be used with permission, may -// only work in specific contexts, and may change in incompatible ways without -// notice. Note that this is primarily intended to annotate features by the Thrift Team -// and isn't recommended for general use. -type Experimental struct { -} - -func NewExperimental() *Experimental { - return &Experimental{} -} - -type ExperimentalBuilder struct { - obj *Experimental -} - -func NewExperimentalBuilder() *ExperimentalBuilder{ - return &ExperimentalBuilder{ - obj: NewExperimental(), - } -} - -func (p ExperimentalBuilder) Emit() *Experimental{ - return &Experimental{ - } -} - -func (p *Experimental) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Experimental) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Experimental"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Experimental) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Experimental({})") -} - -// Annotate a thrift structured or enum to indicate if ids or values should not -// be used. -// -// For example, you may want to mark ids as deprecated, or these ids -// might be reserved for other use cases or annotations. -// -// The resolved set of disallowed ids is the union of the values in `ids` and -// the range of values represented in `id_ranges`. Example: -// -// // These ids are not allowed: 3, 8, half-open ranges [10, 15), [20, 30) -// @thrift.ReserveIds{ids = [3, 8], id_ranges = {10: 15, 20: 30}} -// struct Foo { -// ... -// 3: i64 f; // Build failure: 3 cannot be used -// } -// -// Attributes: -// - Ids: Individual ids that cannot be used. -// - IdRanges: Represents ranges of ids that cannot be used. -// -// Each (key: value) pair represents the half-open range `[key, value)`, -// where `key` is included and `value` is not. For example, the map -// `{10: 15, 20: 30}` represents the union of id/value ranges `[10, 15)` and -// `[20, 30)`. -type ReserveIds struct { - Ids []int32 `thrift:"ids,1" db:"ids" json:"ids"` - IdRanges map[int32]int32 `thrift:"id_ranges,2" db:"id_ranges" json:"id_ranges"` -} - -func NewReserveIds() *ReserveIds { - return &ReserveIds{} -} - - -func (p *ReserveIds) GetIds() []int32 { - return p.Ids -} - -func (p *ReserveIds) GetIdRanges() map[int32]int32 { - return p.IdRanges -} -type ReserveIdsBuilder struct { - obj *ReserveIds -} - -func NewReserveIdsBuilder() *ReserveIdsBuilder{ - return &ReserveIdsBuilder{ - obj: NewReserveIds(), - } -} - -func (p ReserveIdsBuilder) Emit() *ReserveIds{ - return &ReserveIds{ - Ids: p.obj.Ids, - IdRanges: p.obj.IdRanges, - } -} - -func (r *ReserveIdsBuilder) Ids(ids []int32) *ReserveIdsBuilder { - r.obj.Ids = ids - return r -} - -func (r *ReserveIdsBuilder) IdRanges(idRanges map[int32]int32) *ReserveIdsBuilder { - r.obj.IdRanges = idRanges - return r -} - -func (r *ReserveIds) SetIds(ids []int32) *ReserveIds { - r.Ids = ids - return r -} - -func (r *ReserveIds) SetIdRanges(idRanges map[int32]int32) *ReserveIds { - r.IdRanges = idRanges - return r -} - -func (p *ReserveIds) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ReserveIds) ReadField1(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]int32, 0, size) - p.Ids = tSlice - for i := 0; i < size; i ++ { - var _elem0 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem0 = v - } - p.Ids = append(p.Ids, _elem0) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *ReserveIds) ReadField2(iprot thrift.Protocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[int32]int32, size) - p.IdRanges = tMap - for i := 0; i < size; i ++ { - var _key1 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key1 = v - } - var _val2 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _val2 = v - } - p.IdRanges[_key1] = _val2 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *ReserveIds) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("ReserveIds"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *ReserveIds) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("ids", thrift.LIST, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:ids: ", p), err) } - if err := oprot.WriteListBegin(thrift.I32, len(p.Ids)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.Ids { - if err := oprot.WriteI32(int32(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:ids: ", p), err) } - return err -} - -func (p *ReserveIds) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("id_ranges", thrift.MAP, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:id_ranges: ", p), err) } - if err := oprot.WriteMapBegin(thrift.I32, thrift.I32, len(p.IdRanges)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.IdRanges { - if err := oprot.WriteI32(int32(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := oprot.WriteI32(int32(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:id_ranges: ", p), err) } - return err -} - -func (p *ReserveIds) String() string { - if p == nil { - return "" - } - - idsVal := fmt.Sprintf("%v", p.Ids) - idRangesVal := fmt.Sprintf("%v", p.IdRanges) - return fmt.Sprintf("ReserveIds({Ids:%s IdRanges:%s})", idsVal, idRangesVal) -} - -// Indicates additional backward compatibility restrictions, beyond the -// standard Thrift required 'wire' compatibility. -// -// Attributes: -// - FieldName -type RequiresBackwardCompatibility struct { - FieldName bool `thrift:"field_name,1" db:"field_name" json:"field_name"` -} - -func NewRequiresBackwardCompatibility() *RequiresBackwardCompatibility { - return &RequiresBackwardCompatibility{} -} - - -func (p *RequiresBackwardCompatibility) GetFieldName() bool { - return p.FieldName -} -type RequiresBackwardCompatibilityBuilder struct { - obj *RequiresBackwardCompatibility -} - -func NewRequiresBackwardCompatibilityBuilder() *RequiresBackwardCompatibilityBuilder{ - return &RequiresBackwardCompatibilityBuilder{ - obj: NewRequiresBackwardCompatibility(), - } -} - -func (p RequiresBackwardCompatibilityBuilder) Emit() *RequiresBackwardCompatibility{ - return &RequiresBackwardCompatibility{ - FieldName: p.obj.FieldName, - } -} - -func (r *RequiresBackwardCompatibilityBuilder) FieldName(fieldName bool) *RequiresBackwardCompatibilityBuilder { - r.obj.FieldName = fieldName - return r -} - -func (r *RequiresBackwardCompatibility) SetFieldName(fieldName bool) *RequiresBackwardCompatibility { - r.FieldName = fieldName - return r -} - -func (p *RequiresBackwardCompatibility) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *RequiresBackwardCompatibility) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.FieldName = v - } - return nil -} - -func (p *RequiresBackwardCompatibility) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("RequiresBackwardCompatibility"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *RequiresBackwardCompatibility) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("field_name", thrift.BOOL, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:field_name: ", p), err) } - if err := oprot.WriteBool(bool(p.FieldName)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.field_name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:field_name: ", p), err) } - return err -} - -func (p *RequiresBackwardCompatibility) String() string { - if p == nil { - return "" - } - - fieldNameVal := fmt.Sprintf("%v", p.FieldName) - return fmt.Sprintf("RequiresBackwardCompatibility({FieldName:%s})", fieldNameVal) -} - -// An annotation that changes the field qualifier from 'none' to 'terse'. -// A terse field is eligible to skip serialization, when it equals to the -// intrinsic default value. It also clears to the intrinsic default value -// before deserialization to distinguish between if a terse field was skipped -// or missing during serialization. This is different from an unqualified -// field, as an unqualified field is always serialized regardless of its value, -// and it is not cleared before deserialization. -// -// The annotation can be only used to annotate an unqualified field, and when -// it is annotating a struct or exception, it changes all unqualified fields to -// terse fields. Note, the annotation can not be used for union. -type TerseWrite struct { -} - -func NewTerseWrite() *TerseWrite { - return &TerseWrite{} -} - -type TerseWriteBuilder struct { - obj *TerseWrite -} - -func NewTerseWriteBuilder() *TerseWriteBuilder{ - return &TerseWriteBuilder{ - obj: NewTerseWrite(), - } -} - -func (p TerseWriteBuilder) Emit() *TerseWrite{ - return &TerseWrite{ - } -} - -func (p *TerseWrite) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *TerseWrite) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("TerseWrite"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *TerseWrite) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("TerseWrite({})") -} - -// Indicates that an optional field's value should never be stored on the stack, -// i.e. the subobject should be allocated separately (e.g. because it is large and infrequently set). -// -// NOTE: The APIs and initialization behavior are same as normal field, but different from `@cpp.Ref`. e.g. -// -// ``` -// struct Foo { -// 1: optional i32 normal; -// @thrift.Box -// 2: optional i32 boxed; -// @cpp.Ref -// 3: optional i32 referred; -// } -// ``` -// in C++ -// -// ``` -// Foo foo; -// EXPECT_FALSE(foo.normal().has_value()); // okay -// EXPECT_FALSE(foo.boxed().has_value()); // okay -// EXPECT_FALSE(foo.referred().has_value()); // build failure: std::unique_ptr doesn't have has_value method -// -// EXPECT_EQ(*foo.normal(), 0); // throw bad_field_access exception -// EXPECT_EQ(*foo.boxed(), 0); // throw bad_field_access exception -// EXPECT_EQ(*foo.referred(), 0); // okay, field has value by default -// ``` -// -// Affects C++ and Rust. -// TODO: replace with @cpp.Box + @rust.Box -type Box struct { -} - -func NewBox() *Box { - return &Box{} -} - -type BoxBuilder struct { - obj *Box -} - -func NewBoxBuilder() *BoxBuilder{ - return &BoxBuilder{ - obj: NewBox(), - } -} - -func (p BoxBuilder) Emit() *Box{ - return &Box{ - } -} - -func (p *Box) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Box) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Box"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Box) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Box({})") -} - -// Indicates whether the nested fields are accessible directly. -// https://github.com/facebook/fbthrift/blob/v2023.11.20.00/thrift/doc/idl/mixins.md -type Mixin struct { -} - -func NewMixin() *Mixin { - return &Mixin{} -} - -type MixinBuilder struct { - obj *Mixin -} - -func NewMixinBuilder() *MixinBuilder{ - return &MixinBuilder{ - obj: NewMixin(), - } -} - -func (p MixinBuilder) Emit() *Mixin{ - return &Mixin{ - } -} - -func (p *Mixin) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Mixin) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Mixin"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Mixin) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Mixin({})") -} - -// Option to serialize thrift struct in ascending field id order instead of field declaration order. -// -// This can potentially make serialized data size smaller in compact protocol, -// since compact protocol can write deltas between subsequent field ids instead of full ids. -// -// NOTE: This annotation won't reduce payload size for other protocols. -type SerializeInFieldIdOrder struct { -} - -func NewSerializeInFieldIdOrder() *SerializeInFieldIdOrder { - return &SerializeInFieldIdOrder{} -} - -type SerializeInFieldIdOrderBuilder struct { - obj *SerializeInFieldIdOrder -} - -func NewSerializeInFieldIdOrderBuilder() *SerializeInFieldIdOrderBuilder{ - return &SerializeInFieldIdOrderBuilder{ - obj: NewSerializeInFieldIdOrder(), - } -} - -func (p SerializeInFieldIdOrderBuilder) Emit() *SerializeInFieldIdOrder{ - return &SerializeInFieldIdOrder{ - } -} - -func (p *SerializeInFieldIdOrder) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *SerializeInFieldIdOrder) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("SerializeInFieldIdOrder"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *SerializeInFieldIdOrder) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("SerializeInFieldIdOrder({})") -} - -// Indicates an enum is a bitmask and should support bit-wise operators. -// Currently generates additional code in C++ and Hack. -type BitmaskEnum struct { -} - -func NewBitmaskEnum() *BitmaskEnum { - return &BitmaskEnum{} -} - -type BitmaskEnumBuilder struct { - obj *BitmaskEnum -} - -func NewBitmaskEnumBuilder() *BitmaskEnumBuilder{ - return &BitmaskEnumBuilder{ - obj: NewBitmaskEnum(), - } -} - -func (p BitmaskEnumBuilder) Emit() *BitmaskEnum{ - return &BitmaskEnum{ - } -} - -func (p *BitmaskEnum) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *BitmaskEnum) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("BitmaskEnum"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *BitmaskEnum) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("BitmaskEnum({})") -} - -// Specifies the field where the exception message is stored. -type ExceptionMessage struct { -} - -func NewExceptionMessage() *ExceptionMessage { - return &ExceptionMessage{} -} - -type ExceptionMessageBuilder struct { - obj *ExceptionMessage -} - -func NewExceptionMessageBuilder() *ExceptionMessageBuilder{ - return &ExceptionMessageBuilder{ - obj: NewExceptionMessage(), - } -} - -func (p ExceptionMessageBuilder) Emit() *ExceptionMessage{ - return &ExceptionMessage{ - } -} - -func (p *ExceptionMessage) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ExceptionMessage) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("ExceptionMessage"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *ExceptionMessage) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("ExceptionMessage({})") -} - -// Generates a const of type schema. Struct containing the schema of the -// annotated type. Optionally specify name to override default -// schema. -// -// Attributes: -// - Name -type GenerateRuntimeSchema struct { - Name string `thrift:"name,1" db:"name" json:"name"` -} - -func NewGenerateRuntimeSchema() *GenerateRuntimeSchema { - return &GenerateRuntimeSchema{} -} - - -func (p *GenerateRuntimeSchema) GetName() string { - return p.Name -} -type GenerateRuntimeSchemaBuilder struct { - obj *GenerateRuntimeSchema -} - -func NewGenerateRuntimeSchemaBuilder() *GenerateRuntimeSchemaBuilder{ - return &GenerateRuntimeSchemaBuilder{ - obj: NewGenerateRuntimeSchema(), - } -} - -func (p GenerateRuntimeSchemaBuilder) Emit() *GenerateRuntimeSchema{ - return &GenerateRuntimeSchema{ - Name: p.obj.Name, - } -} - -func (g *GenerateRuntimeSchemaBuilder) Name(name string) *GenerateRuntimeSchemaBuilder { - g.obj.Name = name - return g -} - -func (g *GenerateRuntimeSchema) SetName(name string) *GenerateRuntimeSchema { - g.Name = name - return g -} - -func (p *GenerateRuntimeSchema) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *GenerateRuntimeSchema) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Name = v - } - return nil -} - -func (p *GenerateRuntimeSchema) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("GenerateRuntimeSchema"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *GenerateRuntimeSchema) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) } - if err := oprot.WriteString(string(p.Name)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) } - return err -} - -func (p *GenerateRuntimeSchema) String() string { - if p == nil { - return "" - } - - nameVal := fmt.Sprintf("%v", p.Name) - return fmt.Sprintf("GenerateRuntimeSchema({Name:%s})", nameVal) -} - -// Indicates that a field's value should never be stored on the stack, and that -// identical values can be shared in immutable contexts. -type InternBox struct { -} - -func NewInternBox() *InternBox { - return &InternBox{} -} - -type InternBoxBuilder struct { - obj *InternBox -} - -func NewInternBoxBuilder() *InternBoxBuilder{ - return &InternBoxBuilder{ - obj: NewInternBox(), - } -} - -func (p InternBoxBuilder) Emit() *InternBox{ - return &InternBox{ - } -} - -func (p *InternBox) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *InternBox) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("InternBox"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *InternBox) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("InternBox({})") -} - -// Indicates that an interaction's methods should be processed sequentially. -type Serial struct { -} - -func NewSerial() *Serial { - return &Serial{} -} - -type SerialBuilder struct { - obj *Serial -} - -func NewSerialBuilder() *SerialBuilder{ - return &SerialBuilder{ - obj: NewSerial(), - } -} - -func (p SerialBuilder) Emit() *Serial{ - return &Serial{ - } -} - -func (p *Serial) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Serial) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Serial"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Serial) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Serial({})") -} - -// Changes the URI of this definition away from the default-generated one. -// -// Attributes: -// - Value -type Uri struct { - Value string `thrift:"value,1" db:"value" json:"value"` -} - -func NewUri() *Uri { - return &Uri{} -} - - -func (p *Uri) GetValue() string { - return p.Value -} -type UriBuilder struct { - obj *Uri -} - -func NewUriBuilder() *UriBuilder{ - return &UriBuilder{ - obj: NewUri(), - } -} - -func (p UriBuilder) Emit() *Uri{ - return &Uri{ - Value: p.obj.Value, - } -} - -func (u *UriBuilder) Value(value string) *UriBuilder { - u.obj.Value = value - return u -} - -func (u *Uri) SetValue(value string) *Uri { - u.Value = value - return u -} - -func (p *Uri) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Uri) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Value = v - } - return nil -} - -func (p *Uri) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Uri"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Uri) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("value", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:value: ", p), err) } - if err := oprot.WriteString(string(p.Value)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.value (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:value: ", p), err) } - return err -} - -func (p *Uri) String() string { - if p == nil { - return "" - } - - valueVal := fmt.Sprintf("%v", p.Value) - return fmt.Sprintf("Uri({Value:%s})", valueVal) -} - -// Changes the priority of this function (default NORMAL). -// -// Attributes: -// - Level -type Priority struct { - Level RpcPriority `thrift:"level,1" db:"level" json:"level"` -} - -func NewPriority() *Priority { - return &Priority{} -} - - -func (p *Priority) GetLevel() RpcPriority { - return p.Level -} -type PriorityBuilder struct { - obj *Priority -} - -func NewPriorityBuilder() *PriorityBuilder{ - return &PriorityBuilder{ - obj: NewPriority(), - } -} - -func (p PriorityBuilder) Emit() *Priority{ - return &Priority{ - Level: p.obj.Level, - } -} - -func (p *PriorityBuilder) Level(level RpcPriority) *PriorityBuilder { - p.obj.Level = level - return p -} - -func (p *Priority) SetLevel(level RpcPriority) *Priority { - p.Level = level - return p -} - -func (p *Priority) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Priority) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - temp := RpcPriority(v) - p.Level = temp - } - return nil -} - -func (p *Priority) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Priority"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Priority) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("level", thrift.I32, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:level: ", p), err) } - if err := oprot.WriteI32(int32(p.Level)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.level (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:level: ", p), err) } - return err -} - -func (p *Priority) String() string { - if p == nil { - return "" - } - - levelVal := fmt.Sprintf("%v", p.Level) - return fmt.Sprintf("Priority({Level:%s})", levelVal) -} - -// Applies unstructured annotations to a definition. -// -// Attributes: -// - Items -type DeprecatedUnvalidatedAnnotations struct { - Items map[string]string `thrift:"items,1" db:"items" json:"items"` -} - -func NewDeprecatedUnvalidatedAnnotations() *DeprecatedUnvalidatedAnnotations { - return &DeprecatedUnvalidatedAnnotations{} -} - - -func (p *DeprecatedUnvalidatedAnnotations) GetItems() map[string]string { - return p.Items -} -type DeprecatedUnvalidatedAnnotationsBuilder struct { - obj *DeprecatedUnvalidatedAnnotations -} - -func NewDeprecatedUnvalidatedAnnotationsBuilder() *DeprecatedUnvalidatedAnnotationsBuilder{ - return &DeprecatedUnvalidatedAnnotationsBuilder{ - obj: NewDeprecatedUnvalidatedAnnotations(), - } -} - -func (p DeprecatedUnvalidatedAnnotationsBuilder) Emit() *DeprecatedUnvalidatedAnnotations{ - return &DeprecatedUnvalidatedAnnotations{ - Items: p.obj.Items, - } -} - -func (d *DeprecatedUnvalidatedAnnotationsBuilder) Items(items map[string]string) *DeprecatedUnvalidatedAnnotationsBuilder { - d.obj.Items = items - return d -} - -func (d *DeprecatedUnvalidatedAnnotations) SetItems(items map[string]string) *DeprecatedUnvalidatedAnnotations { - d.Items = items - return d -} - -func (p *DeprecatedUnvalidatedAnnotations) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *DeprecatedUnvalidatedAnnotations) ReadField1(iprot thrift.Protocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[string]string, size) - p.Items = tMap - for i := 0; i < size; i ++ { - var _key3 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key3 = v - } - var _val4 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _val4 = v - } - p.Items[_key3] = _val4 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *DeprecatedUnvalidatedAnnotations) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("DeprecatedUnvalidatedAnnotations"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *DeprecatedUnvalidatedAnnotations) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("items", thrift.MAP, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:items: ", p), err) } - if err := oprot.WriteMapBegin(thrift.STRING, thrift.STRING, len(p.Items)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.Items { - if err := oprot.WriteString(string(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := oprot.WriteString(string(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:items: ", p), err) } - return err -} - -func (p *DeprecatedUnvalidatedAnnotations) String() string { - if p == nil { - return "" - } - - itemsVal := fmt.Sprintf("%v", p.Items) - return fmt.Sprintf("DeprecatedUnvalidatedAnnotations({Items:%s})", itemsVal) -} - diff --git a/thrift/compiler/test/fixtures/exceptions/gen-go/module/constants.go b/thrift/compiler/test/fixtures/exceptions/gen-go/module/constants.go deleted file mode 100644 index 477cf91a64b..00000000000 --- a/thrift/compiler/test/fixtures/exceptions/gen-go/module/constants.go +++ /dev/null @@ -1,25 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package module - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - - -func init() { -} - diff --git a/thrift/compiler/test/fixtures/exceptions/gen-go/module/raiser.go b/thrift/compiler/test/fixtures/exceptions/gen-go/module/raiser.go deleted file mode 100644 index 85d0d85bdde..00000000000 --- a/thrift/compiler/test/fixtures/exceptions/gen-go/module/raiser.go +++ /dev/null @@ -1,1642 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package module - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -type Raiser interface { - DoBland() (err error) - DoRaise() (err error) - Get200() (_r string, err error) - Get500() (_r string, err error) -} - -type RaiserClientInterface interface { - thrift.ClientInterface - DoBland() (err error) - DoRaise() (err error) - Get200() (_r string, err error) - Get500() (_r string, err error) -} - -type RaiserClient struct { - RaiserClientInterface - CC thrift.ClientConn -} - -func(client *RaiserClient) Open() error { - return client.CC.Open() -} - -func(client *RaiserClient) Close() error { - return client.CC.Close() -} - -func(client *RaiserClient) IsOpen() bool { - return client.CC.IsOpen() -} - -func NewRaiserClientFactory(t thrift.Transport, f thrift.ProtocolFactory) *RaiserClient { - return &RaiserClient{ CC: thrift.NewClientConn(t, f) } -} - -func NewRaiserClient(t thrift.Transport, iprot thrift.Protocol, oprot thrift.Protocol) *RaiserClient { - return &RaiserClient{ CC: thrift.NewClientConnWithProtocols(t, iprot, oprot) } -} - -func NewRaiserClientProtocol(prot thrift.Protocol) *RaiserClient { - return NewRaiserClient(prot.Transport(), prot, prot) -} - -func (p *RaiserClient) DoBland() (err error) { - var args RaiserDoBlandArgs - err = p.CC.SendMsg("doBland", &args, thrift.CALL) - if err != nil { return } - return p.recvDoBland() -} - - -func (p *RaiserClient) recvDoBland() (err error) { - var __result RaiserDoBlandResult - return p.CC.RecvMsg("doBland", &__result) -} - -func (p *RaiserClient) DoRaise() (err error) { - var args RaiserDoRaiseArgs - err = p.CC.SendMsg("doRaise", &args, thrift.CALL) - if err != nil { return } - return p.recvDoRaise() -} - - -func (p *RaiserClient) recvDoRaise() (err error) { - var __result RaiserDoRaiseResult - err = p.CC.RecvMsg("doRaise", &__result) - if err != nil { return } - if __result.B != nil { - err = __result.B - return - } else if __result.F != nil { - err = __result.F - return - } else if __result.S != nil { - err = __result.S - return - } - return nil -} - -func (p *RaiserClient) Get200() (_r string, err error) { - var args RaiserGet200Args - err = p.CC.SendMsg("get200", &args, thrift.CALL) - if err != nil { return } - return p.recvGet200() -} - - -func (p *RaiserClient) recvGet200() (value string, err error) { - var __result RaiserGet200Result - err = p.CC.RecvMsg("get200", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -func (p *RaiserClient) Get500() (_r string, err error) { - var args RaiserGet500Args - err = p.CC.SendMsg("get500", &args, thrift.CALL) - if err != nil { return } - return p.recvGet500() -} - - -func (p *RaiserClient) recvGet500() (value string, err error) { - var __result RaiserGet500Result - err = p.CC.RecvMsg("get500", &__result) - if err != nil { return } - if __result.F != nil { - err = __result.F - return - } else if __result.B != nil { - err = __result.B - return - } else if __result.S != nil { - err = __result.S - return - } - return __result.GetSuccess(), nil -} - - -type RaiserThreadsafeClient struct { - RaiserClientInterface - CC thrift.ClientConn - Mu sync.Mutex -} - -func(client *RaiserThreadsafeClient) Open() error { - client.Mu.Lock() - defer client.Mu.Unlock() - return client.CC.Open() -} - -func(client *RaiserThreadsafeClient) Close() error { - client.Mu.Lock() - defer client.Mu.Unlock() - return client.CC.Close() -} - -func(client *RaiserThreadsafeClient) IsOpen() bool { - client.Mu.Lock() - defer client.Mu.Unlock() - return client.CC.IsOpen() -} - -func NewRaiserThreadsafeClientFactory(t thrift.Transport, f thrift.ProtocolFactory) *RaiserThreadsafeClient { - return &RaiserThreadsafeClient{ CC: thrift.NewClientConn(t, f) } -} - -func NewRaiserThreadsafeClient(t thrift.Transport, iprot thrift.Protocol, oprot thrift.Protocol) *RaiserThreadsafeClient { - return &RaiserThreadsafeClient{ CC: thrift.NewClientConnWithProtocols(t, iprot, oprot) } -} - -func NewRaiserThreadsafeClientProtocol(prot thrift.Protocol) *RaiserThreadsafeClient { - return NewRaiserThreadsafeClient(prot.Transport(), prot, prot) -} - -func (p *RaiserThreadsafeClient) DoBland() (err error) { - p.Mu.Lock() - defer p.Mu.Unlock() - var args RaiserDoBlandArgs - err = p.CC.SendMsg("doBland", &args, thrift.CALL) - if err != nil { return } - return p.recvDoBland() -} - - -func (p *RaiserThreadsafeClient) recvDoBland() (err error) { - var __result RaiserDoBlandResult - return p.CC.RecvMsg("doBland", &__result) -} - -func (p *RaiserThreadsafeClient) DoRaise() (err error) { - p.Mu.Lock() - defer p.Mu.Unlock() - var args RaiserDoRaiseArgs - err = p.CC.SendMsg("doRaise", &args, thrift.CALL) - if err != nil { return } - return p.recvDoRaise() -} - - -func (p *RaiserThreadsafeClient) recvDoRaise() (err error) { - var __result RaiserDoRaiseResult - err = p.CC.RecvMsg("doRaise", &__result) - if err != nil { return } - if __result.B != nil { - err = __result.B - return - } else if __result.F != nil { - err = __result.F - return - } else if __result.S != nil { - err = __result.S - return - } - return nil -} - -func (p *RaiserThreadsafeClient) Get200() (_r string, err error) { - p.Mu.Lock() - defer p.Mu.Unlock() - var args RaiserGet200Args - err = p.CC.SendMsg("get200", &args, thrift.CALL) - if err != nil { return } - return p.recvGet200() -} - - -func (p *RaiserThreadsafeClient) recvGet200() (value string, err error) { - var __result RaiserGet200Result - err = p.CC.RecvMsg("get200", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -func (p *RaiserThreadsafeClient) Get500() (_r string, err error) { - p.Mu.Lock() - defer p.Mu.Unlock() - var args RaiserGet500Args - err = p.CC.SendMsg("get500", &args, thrift.CALL) - if err != nil { return } - return p.recvGet500() -} - - -func (p *RaiserThreadsafeClient) recvGet500() (value string, err error) { - var __result RaiserGet500Result - err = p.CC.RecvMsg("get500", &__result) - if err != nil { return } - if __result.F != nil { - err = __result.F - return - } else if __result.B != nil { - err = __result.B - return - } else if __result.S != nil { - err = __result.S - return - } - return __result.GetSuccess(), nil -} - - -type RaiserChannelClient struct { - RequestChannel thrift.RequestChannel -} - -func (c *RaiserChannelClient) Close() error { - return c.RequestChannel.Close() -} - -func (c *RaiserChannelClient) IsOpen() bool { - return c.RequestChannel.IsOpen() -} - -func (c *RaiserChannelClient) Open() error { - return c.RequestChannel.Open() -} - -func NewRaiserChannelClient(channel thrift.RequestChannel) *RaiserChannelClient { - return &RaiserChannelClient{RequestChannel: channel} -} - -func (p *RaiserChannelClient) DoBland(ctx context.Context) (err error) { - args := RaiserDoBlandArgs{ - } - var __result RaiserDoBlandResult - err = p.RequestChannel.Call(ctx, "doBland", &args, &__result) - if err != nil { return } - - return nil -} - -func (p *RaiserChannelClient) DoRaise(ctx context.Context) (err error) { - args := RaiserDoRaiseArgs{ - } - var __result RaiserDoRaiseResult - err = p.RequestChannel.Call(ctx, "doRaise", &args, &__result) - if err != nil { return } - if __result.B != nil { - err = __result.B - return - } else if __result.F != nil { - err = __result.F - return - } else if __result.S != nil { - err = __result.S - return - } - return nil -} - -func (p *RaiserChannelClient) Get200(ctx context.Context) (_r string, err error) { - args := RaiserGet200Args{ - } - var __result RaiserGet200Result - err = p.RequestChannel.Call(ctx, "get200", &args, &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -func (p *RaiserChannelClient) Get500(ctx context.Context) (_r string, err error) { - args := RaiserGet500Args{ - } - var __result RaiserGet500Result - err = p.RequestChannel.Call(ctx, "get500", &args, &__result) - if err != nil { return } - if __result.F != nil { - err = __result.F - return - } else if __result.B != nil { - err = __result.B - return - } else if __result.S != nil { - err = __result.S - return - } - return __result.GetSuccess(), nil -} - - -type RaiserProcessor struct { - processorMap map[string]thrift.ProcessorFunction - functionServiceMap map[string]string - handler Raiser -} - -func (p *RaiserProcessor) AddToProcessorMap(key string, processor thrift.ProcessorFunction) { - p.processorMap[key] = processor -} - -func (p *RaiserProcessor) AddToFunctionServiceMap(key, service string) { - p.functionServiceMap[key] = service -} - -func (p *RaiserProcessor) GetProcessorFunction(key string) (processor thrift.ProcessorFunction, err error) { - if processor, ok := p.processorMap[key]; ok { - return processor, nil - } - return nil, nil // generic error message will be sent -} - -func (p *RaiserProcessor) ProcessorMap() map[string]thrift.ProcessorFunction { - return p.processorMap -} - -func (p *RaiserProcessor) FunctionServiceMap() map[string]string { - return p.functionServiceMap -} - -func NewRaiserProcessor(handler Raiser) *RaiserProcessor { - self0 := &RaiserProcessor{handler:handler, processorMap:make(map[string]thrift.ProcessorFunction), functionServiceMap:make(map[string]string)} - self0.processorMap["doBland"] = &raiserProcessorDoBland{handler:handler} - self0.processorMap["doRaise"] = &raiserProcessorDoRaise{handler:handler} - self0.processorMap["get200"] = &raiserProcessorGet200{handler:handler} - self0.processorMap["get500"] = &raiserProcessorGet500{handler:handler} - self0.functionServiceMap["doBland"] = "Raiser" - self0.functionServiceMap["doRaise"] = "Raiser" - self0.functionServiceMap["get200"] = "Raiser" - self0.functionServiceMap["get500"] = "Raiser" - return self0 -} - -type raiserProcessorDoBland struct { - handler Raiser -} - -func (p *RaiserDoBlandResult) Exception() thrift.WritableException { - if p == nil { return nil } - return nil -} - -func (p *raiserProcessorDoBland) Read(iprot thrift.Protocol) (thrift.Struct, thrift.Exception) { - args := RaiserDoBlandArgs{} - if err := args.Read(iprot); err != nil { - return nil, err - } - iprot.ReadMessageEnd() - return &args, nil -} - -func (p *raiserProcessorDoBland) Write(seqId int32, result thrift.WritableStruct, oprot thrift.Protocol) (err thrift.Exception) { - var err2 error - messageType := thrift.REPLY - switch result.(type) { - case thrift.ApplicationException: - messageType = thrift.EXCEPTION - } - if err2 = oprot.WriteMessageBegin("doBland", messageType, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - return err -} - -func (p *raiserProcessorDoBland) Run(argStruct thrift.Struct) (thrift.WritableStruct, thrift.ApplicationException) { - var __result RaiserDoBlandResult - if err := p.handler.DoBland(); err != nil { - switch err.(type) { - default: - x := thrift.NewApplicationExceptionCause(thrift.INTERNAL_ERROR, "Internal error processing doBland: " + err.Error(), err) - return x, x - } - } - return &__result, nil -} - -type raiserProcessorDoRaise struct { - handler Raiser -} - -func (p *RaiserDoRaiseResult) Exception() thrift.WritableException { - if p == nil { return nil } - if p.B != nil { - return p.B - } - if p.F != nil { - return p.F - } - if p.S != nil { - return p.S - } - return nil -} - -func (p *raiserProcessorDoRaise) Read(iprot thrift.Protocol) (thrift.Struct, thrift.Exception) { - args := RaiserDoRaiseArgs{} - if err := args.Read(iprot); err != nil { - return nil, err - } - iprot.ReadMessageEnd() - return &args, nil -} - -func (p *raiserProcessorDoRaise) Write(seqId int32, result thrift.WritableStruct, oprot thrift.Protocol) (err thrift.Exception) { - var err2 error - messageType := thrift.REPLY - switch v := result.(type) { - case *Banal: - msg := RaiserDoRaiseResult{B: v} - result = &msg - case *Fiery: - msg := RaiserDoRaiseResult{F: v} - result = &msg - case *Serious: - msg := RaiserDoRaiseResult{S: v} - result = &msg - case thrift.ApplicationException: - messageType = thrift.EXCEPTION - } - if err2 = oprot.WriteMessageBegin("doRaise", messageType, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - return err -} - -func (p *raiserProcessorDoRaise) Run(argStruct thrift.Struct) (thrift.WritableStruct, thrift.ApplicationException) { - var __result RaiserDoRaiseResult - if err := p.handler.DoRaise(); err != nil { - switch v := err.(type) { - case *Banal: - __result.B = v - case *Fiery: - __result.F = v - case *Serious: - __result.S = v - default: - x := thrift.NewApplicationExceptionCause(thrift.INTERNAL_ERROR, "Internal error processing doRaise: " + err.Error(), err) - return x, x - } - } - return &__result, nil -} - -type raiserProcessorGet200 struct { - handler Raiser -} - -func (p *RaiserGet200Result) Exception() thrift.WritableException { - if p == nil { return nil } - return nil -} - -func (p *raiserProcessorGet200) Read(iprot thrift.Protocol) (thrift.Struct, thrift.Exception) { - args := RaiserGet200Args{} - if err := args.Read(iprot); err != nil { - return nil, err - } - iprot.ReadMessageEnd() - return &args, nil -} - -func (p *raiserProcessorGet200) Write(seqId int32, result thrift.WritableStruct, oprot thrift.Protocol) (err thrift.Exception) { - var err2 error - messageType := thrift.REPLY - switch result.(type) { - case thrift.ApplicationException: - messageType = thrift.EXCEPTION - } - if err2 = oprot.WriteMessageBegin("get200", messageType, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - return err -} - -func (p *raiserProcessorGet200) Run(argStruct thrift.Struct) (thrift.WritableStruct, thrift.ApplicationException) { - var __result RaiserGet200Result - if retval, err := p.handler.Get200(); err != nil { - switch err.(type) { - default: - x := thrift.NewApplicationExceptionCause(thrift.INTERNAL_ERROR, "Internal error processing get200: " + err.Error(), err) - return x, x - } - } else { - __result.Success = &retval - } - return &__result, nil -} - -type raiserProcessorGet500 struct { - handler Raiser -} - -func (p *RaiserGet500Result) Exception() thrift.WritableException { - if p == nil { return nil } - if p.F != nil { - return p.F - } - if p.B != nil { - return p.B - } - if p.S != nil { - return p.S - } - return nil -} - -func (p *raiserProcessorGet500) Read(iprot thrift.Protocol) (thrift.Struct, thrift.Exception) { - args := RaiserGet500Args{} - if err := args.Read(iprot); err != nil { - return nil, err - } - iprot.ReadMessageEnd() - return &args, nil -} - -func (p *raiserProcessorGet500) Write(seqId int32, result thrift.WritableStruct, oprot thrift.Protocol) (err thrift.Exception) { - var err2 error - messageType := thrift.REPLY - switch v := result.(type) { - case *Fiery: - msg := RaiserGet500Result{F: v} - result = &msg - case *Banal: - msg := RaiserGet500Result{B: v} - result = &msg - case *Serious: - msg := RaiserGet500Result{S: v} - result = &msg - case thrift.ApplicationException: - messageType = thrift.EXCEPTION - } - if err2 = oprot.WriteMessageBegin("get500", messageType, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - return err -} - -func (p *raiserProcessorGet500) Run(argStruct thrift.Struct) (thrift.WritableStruct, thrift.ApplicationException) { - var __result RaiserGet500Result - if retval, err := p.handler.Get500(); err != nil { - switch v := err.(type) { - case *Fiery: - __result.F = v - case *Banal: - __result.B = v - case *Serious: - __result.S = v - default: - x := thrift.NewApplicationExceptionCause(thrift.INTERNAL_ERROR, "Internal error processing get500: " + err.Error(), err) - return x, x - } - } else { - __result.Success = &retval - } - return &__result, nil -} - - -// HELPER FUNCTIONS AND STRUCTURES - -type RaiserDoBlandArgs struct { - thrift.IRequest -} - -func NewRaiserDoBlandArgs() *RaiserDoBlandArgs { - return &RaiserDoBlandArgs{} -} - -type RaiserDoBlandArgsBuilder struct { - obj *RaiserDoBlandArgs -} - -func NewRaiserDoBlandArgsBuilder() *RaiserDoBlandArgsBuilder{ - return &RaiserDoBlandArgsBuilder{ - obj: NewRaiserDoBlandArgs(), - } -} - -func (p RaiserDoBlandArgsBuilder) Emit() *RaiserDoBlandArgs{ - return &RaiserDoBlandArgs{ - } -} - -func (p *RaiserDoBlandArgs) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *RaiserDoBlandArgs) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("doBland_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *RaiserDoBlandArgs) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("RaiserDoBlandArgs({})") -} - -type RaiserDoBlandResult struct { - thrift.IResponse -} - -func NewRaiserDoBlandResult() *RaiserDoBlandResult { - return &RaiserDoBlandResult{} -} - -type RaiserDoBlandResultBuilder struct { - obj *RaiserDoBlandResult -} - -func NewRaiserDoBlandResultBuilder() *RaiserDoBlandResultBuilder{ - return &RaiserDoBlandResultBuilder{ - obj: NewRaiserDoBlandResult(), - } -} - -func (p RaiserDoBlandResultBuilder) Emit() *RaiserDoBlandResult{ - return &RaiserDoBlandResult{ - } -} - -func (p *RaiserDoBlandResult) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *RaiserDoBlandResult) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("doBland_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *RaiserDoBlandResult) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("RaiserDoBlandResult({})") -} - -type RaiserDoRaiseArgs struct { - thrift.IRequest -} - -func NewRaiserDoRaiseArgs() *RaiserDoRaiseArgs { - return &RaiserDoRaiseArgs{} -} - -type RaiserDoRaiseArgsBuilder struct { - obj *RaiserDoRaiseArgs -} - -func NewRaiserDoRaiseArgsBuilder() *RaiserDoRaiseArgsBuilder{ - return &RaiserDoRaiseArgsBuilder{ - obj: NewRaiserDoRaiseArgs(), - } -} - -func (p RaiserDoRaiseArgsBuilder) Emit() *RaiserDoRaiseArgs{ - return &RaiserDoRaiseArgs{ - } -} - -func (p *RaiserDoRaiseArgs) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *RaiserDoRaiseArgs) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("doRaise_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *RaiserDoRaiseArgs) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("RaiserDoRaiseArgs({})") -} - -// Attributes: -// - B -// - F -// - S -type RaiserDoRaiseResult struct { - thrift.IResponse - B *Banal `thrift:"b,1,optional" db:"b" json:"b,omitempty"` - F *Fiery `thrift:"f,2,optional" db:"f" json:"f,omitempty"` - S *Serious `thrift:"s,3,optional" db:"s" json:"s,omitempty"` -} - -func NewRaiserDoRaiseResult() *RaiserDoRaiseResult { - return &RaiserDoRaiseResult{} -} - -var RaiserDoRaiseResult_B_DEFAULT *Banal -func (p *RaiserDoRaiseResult) GetB() *Banal { - if !p.IsSetB() { - return RaiserDoRaiseResult_B_DEFAULT - } - return p.B -} -var RaiserDoRaiseResult_F_DEFAULT *Fiery -func (p *RaiserDoRaiseResult) GetF() *Fiery { - if !p.IsSetF() { - return RaiserDoRaiseResult_F_DEFAULT - } - return p.F -} -var RaiserDoRaiseResult_S_DEFAULT *Serious -func (p *RaiserDoRaiseResult) GetS() *Serious { - if !p.IsSetS() { - return RaiserDoRaiseResult_S_DEFAULT - } - return p.S -} -func (p *RaiserDoRaiseResult) IsSetB() bool { - return p != nil && p.B != nil -} - -func (p *RaiserDoRaiseResult) IsSetF() bool { - return p != nil && p.F != nil -} - -func (p *RaiserDoRaiseResult) IsSetS() bool { - return p != nil && p.S != nil -} - -type RaiserDoRaiseResultBuilder struct { - obj *RaiserDoRaiseResult -} - -func NewRaiserDoRaiseResultBuilder() *RaiserDoRaiseResultBuilder{ - return &RaiserDoRaiseResultBuilder{ - obj: NewRaiserDoRaiseResult(), - } -} - -func (p RaiserDoRaiseResultBuilder) Emit() *RaiserDoRaiseResult{ - return &RaiserDoRaiseResult{ - B: p.obj.B, - F: p.obj.F, - S: p.obj.S, - } -} - -func (r *RaiserDoRaiseResultBuilder) B(b *Banal) *RaiserDoRaiseResultBuilder { - r.obj.B = b - return r -} - -func (r *RaiserDoRaiseResultBuilder) F(f *Fiery) *RaiserDoRaiseResultBuilder { - r.obj.F = f - return r -} - -func (r *RaiserDoRaiseResultBuilder) S(s *Serious) *RaiserDoRaiseResultBuilder { - r.obj.S = s - return r -} - -func (r *RaiserDoRaiseResult) SetB(b *Banal) *RaiserDoRaiseResult { - r.B = b - return r -} - -func (r *RaiserDoRaiseResult) SetF(f *Fiery) *RaiserDoRaiseResult { - r.F = f - return r -} - -func (r *RaiserDoRaiseResult) SetS(s *Serious) *RaiserDoRaiseResult { - r.S = s - return r -} - -func (p *RaiserDoRaiseResult) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 3: - if err := p.ReadField3(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *RaiserDoRaiseResult) ReadField1(iprot thrift.Protocol) error { - p.B = NewBanal() - if err := p.B.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.B), err) - } - return nil -} - -func (p *RaiserDoRaiseResult) ReadField2(iprot thrift.Protocol) error { - p.F = NewFiery() - if err := p.F.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.F), err) - } - return nil -} - -func (p *RaiserDoRaiseResult) ReadField3(iprot thrift.Protocol) error { - p.S = NewSerious() - if err := p.S.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.S), err) - } - return nil -} - -func (p *RaiserDoRaiseResult) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("doRaise_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *RaiserDoRaiseResult) writeField1(oprot thrift.Protocol) (err error) { - if p.IsSetB() { - if err := oprot.WriteFieldBegin("b", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:b: ", p), err) } - if err := p.B.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.B), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:b: ", p), err) } - } - return err -} - -func (p *RaiserDoRaiseResult) writeField2(oprot thrift.Protocol) (err error) { - if p.IsSetF() { - if err := oprot.WriteFieldBegin("f", thrift.STRUCT, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:f: ", p), err) } - if err := p.F.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.F), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:f: ", p), err) } - } - return err -} - -func (p *RaiserDoRaiseResult) writeField3(oprot thrift.Protocol) (err error) { - if p.IsSetS() { - if err := oprot.WriteFieldBegin("s", thrift.STRUCT, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:s: ", p), err) } - if err := p.S.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.S), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:s: ", p), err) } - } - return err -} - -func (p *RaiserDoRaiseResult) String() string { - if p == nil { - return "" - } - - var bVal string - if p.B == nil { - bVal = "" - } else { - bVal = fmt.Sprintf("%v", p.B) - } - var fVal string - if p.F == nil { - fVal = "" - } else { - fVal = fmt.Sprintf("%v", p.F) - } - var sVal string - if p.S == nil { - sVal = "" - } else { - sVal = fmt.Sprintf("%v", p.S) - } - return fmt.Sprintf("RaiserDoRaiseResult({B:%s F:%s S:%s})", bVal, fVal, sVal) -} - -type RaiserGet200Args struct { - thrift.IRequest -} - -func NewRaiserGet200Args() *RaiserGet200Args { - return &RaiserGet200Args{} -} - -type RaiserGet200ArgsBuilder struct { - obj *RaiserGet200Args -} - -func NewRaiserGet200ArgsBuilder() *RaiserGet200ArgsBuilder{ - return &RaiserGet200ArgsBuilder{ - obj: NewRaiserGet200Args(), - } -} - -func (p RaiserGet200ArgsBuilder) Emit() *RaiserGet200Args{ - return &RaiserGet200Args{ - } -} - -func (p *RaiserGet200Args) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *RaiserGet200Args) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("get200_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *RaiserGet200Args) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("RaiserGet200Args({})") -} - -// Attributes: -// - Success -type RaiserGet200Result struct { - thrift.IResponse - Success *string `thrift:"success,0,optional" db:"success" json:"success,omitempty"` -} - -func NewRaiserGet200Result() *RaiserGet200Result { - return &RaiserGet200Result{} -} - -var RaiserGet200Result_Success_DEFAULT string -func (p *RaiserGet200Result) GetSuccess() string { - if !p.IsSetSuccess() { - return RaiserGet200Result_Success_DEFAULT - } - return *p.Success -} -func (p *RaiserGet200Result) IsSetSuccess() bool { - return p != nil && p.Success != nil -} - -type RaiserGet200ResultBuilder struct { - obj *RaiserGet200Result -} - -func NewRaiserGet200ResultBuilder() *RaiserGet200ResultBuilder{ - return &RaiserGet200ResultBuilder{ - obj: NewRaiserGet200Result(), - } -} - -func (p RaiserGet200ResultBuilder) Emit() *RaiserGet200Result{ - return &RaiserGet200Result{ - Success: p.obj.Success, - } -} - -func (r *RaiserGet200ResultBuilder) Success(success *string) *RaiserGet200ResultBuilder { - r.obj.Success = success - return r -} - -func (r *RaiserGet200Result) SetSuccess(success *string) *RaiserGet200Result { - r.Success = success - return r -} - -func (p *RaiserGet200Result) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 0: - if err := p.ReadField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *RaiserGet200Result) ReadField0(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - p.Success = &v - } - return nil -} - -func (p *RaiserGet200Result) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("get200_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField0(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *RaiserGet200Result) writeField0(oprot thrift.Protocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRING, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := oprot.WriteString(string(*p.Success)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.success (0) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } - } - return err -} - -func (p *RaiserGet200Result) String() string { - if p == nil { - return "" - } - - var successVal string - if p.Success == nil { - successVal = "" - } else { - successVal = fmt.Sprintf("%v", *p.Success) - } - return fmt.Sprintf("RaiserGet200Result({Success:%s})", successVal) -} - -type RaiserGet500Args struct { - thrift.IRequest -} - -func NewRaiserGet500Args() *RaiserGet500Args { - return &RaiserGet500Args{} -} - -type RaiserGet500ArgsBuilder struct { - obj *RaiserGet500Args -} - -func NewRaiserGet500ArgsBuilder() *RaiserGet500ArgsBuilder{ - return &RaiserGet500ArgsBuilder{ - obj: NewRaiserGet500Args(), - } -} - -func (p RaiserGet500ArgsBuilder) Emit() *RaiserGet500Args{ - return &RaiserGet500Args{ - } -} - -func (p *RaiserGet500Args) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *RaiserGet500Args) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("get500_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *RaiserGet500Args) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("RaiserGet500Args({})") -} - -// Attributes: -// - Success -// - F -// - B -// - S -type RaiserGet500Result struct { - thrift.IResponse - Success *string `thrift:"success,0,optional" db:"success" json:"success,omitempty"` - F *Fiery `thrift:"f,1,optional" db:"f" json:"f,omitempty"` - B *Banal `thrift:"b,2,optional" db:"b" json:"b,omitempty"` - S *Serious `thrift:"s,3,optional" db:"s" json:"s,omitempty"` -} - -func NewRaiserGet500Result() *RaiserGet500Result { - return &RaiserGet500Result{} -} - -var RaiserGet500Result_Success_DEFAULT string -func (p *RaiserGet500Result) GetSuccess() string { - if !p.IsSetSuccess() { - return RaiserGet500Result_Success_DEFAULT - } - return *p.Success -} -var RaiserGet500Result_F_DEFAULT *Fiery -func (p *RaiserGet500Result) GetF() *Fiery { - if !p.IsSetF() { - return RaiserGet500Result_F_DEFAULT - } - return p.F -} -var RaiserGet500Result_B_DEFAULT *Banal -func (p *RaiserGet500Result) GetB() *Banal { - if !p.IsSetB() { - return RaiserGet500Result_B_DEFAULT - } - return p.B -} -var RaiserGet500Result_S_DEFAULT *Serious -func (p *RaiserGet500Result) GetS() *Serious { - if !p.IsSetS() { - return RaiserGet500Result_S_DEFAULT - } - return p.S -} -func (p *RaiserGet500Result) IsSetSuccess() bool { - return p != nil && p.Success != nil -} - -func (p *RaiserGet500Result) IsSetF() bool { - return p != nil && p.F != nil -} - -func (p *RaiserGet500Result) IsSetB() bool { - return p != nil && p.B != nil -} - -func (p *RaiserGet500Result) IsSetS() bool { - return p != nil && p.S != nil -} - -type RaiserGet500ResultBuilder struct { - obj *RaiserGet500Result -} - -func NewRaiserGet500ResultBuilder() *RaiserGet500ResultBuilder{ - return &RaiserGet500ResultBuilder{ - obj: NewRaiserGet500Result(), - } -} - -func (p RaiserGet500ResultBuilder) Emit() *RaiserGet500Result{ - return &RaiserGet500Result{ - Success: p.obj.Success, - F: p.obj.F, - B: p.obj.B, - S: p.obj.S, - } -} - -func (r *RaiserGet500ResultBuilder) Success(success *string) *RaiserGet500ResultBuilder { - r.obj.Success = success - return r -} - -func (r *RaiserGet500ResultBuilder) F(f *Fiery) *RaiserGet500ResultBuilder { - r.obj.F = f - return r -} - -func (r *RaiserGet500ResultBuilder) B(b *Banal) *RaiserGet500ResultBuilder { - r.obj.B = b - return r -} - -func (r *RaiserGet500ResultBuilder) S(s *Serious) *RaiserGet500ResultBuilder { - r.obj.S = s - return r -} - -func (r *RaiserGet500Result) SetSuccess(success *string) *RaiserGet500Result { - r.Success = success - return r -} - -func (r *RaiserGet500Result) SetF(f *Fiery) *RaiserGet500Result { - r.F = f - return r -} - -func (r *RaiserGet500Result) SetB(b *Banal) *RaiserGet500Result { - r.B = b - return r -} - -func (r *RaiserGet500Result) SetS(s *Serious) *RaiserGet500Result { - r.S = s - return r -} - -func (p *RaiserGet500Result) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 0: - if err := p.ReadField0(iprot); err != nil { - return err - } - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 3: - if err := p.ReadField3(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *RaiserGet500Result) ReadField0(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - p.Success = &v - } - return nil -} - -func (p *RaiserGet500Result) ReadField1(iprot thrift.Protocol) error { - p.F = NewFiery() - if err := p.F.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.F), err) - } - return nil -} - -func (p *RaiserGet500Result) ReadField2(iprot thrift.Protocol) error { - p.B = NewBanal() - if err := p.B.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.B), err) - } - return nil -} - -func (p *RaiserGet500Result) ReadField3(iprot thrift.Protocol) error { - p.S = NewSerious() - if err := p.S.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.S), err) - } - return nil -} - -func (p *RaiserGet500Result) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("get500_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField0(oprot); err != nil { return err } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *RaiserGet500Result) writeField0(oprot thrift.Protocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRING, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := oprot.WriteString(string(*p.Success)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.success (0) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } - } - return err -} - -func (p *RaiserGet500Result) writeField1(oprot thrift.Protocol) (err error) { - if p.IsSetF() { - if err := oprot.WriteFieldBegin("f", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:f: ", p), err) } - if err := p.F.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.F), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:f: ", p), err) } - } - return err -} - -func (p *RaiserGet500Result) writeField2(oprot thrift.Protocol) (err error) { - if p.IsSetB() { - if err := oprot.WriteFieldBegin("b", thrift.STRUCT, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:b: ", p), err) } - if err := p.B.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.B), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:b: ", p), err) } - } - return err -} - -func (p *RaiserGet500Result) writeField3(oprot thrift.Protocol) (err error) { - if p.IsSetS() { - if err := oprot.WriteFieldBegin("s", thrift.STRUCT, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:s: ", p), err) } - if err := p.S.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.S), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:s: ", p), err) } - } - return err -} - -func (p *RaiserGet500Result) String() string { - if p == nil { - return "" - } - - var successVal string - if p.Success == nil { - successVal = "" - } else { - successVal = fmt.Sprintf("%v", *p.Success) - } - var fVal string - if p.F == nil { - fVal = "" - } else { - fVal = fmt.Sprintf("%v", p.F) - } - var bVal string - if p.B == nil { - bVal = "" - } else { - bVal = fmt.Sprintf("%v", p.B) - } - var sVal string - if p.S == nil { - sVal = "" - } else { - sVal = fmt.Sprintf("%v", p.S) - } - return fmt.Sprintf("RaiserGet500Result({Success:%s F:%s B:%s S:%s})", successVal, fVal, bVal, sVal) -} - - diff --git a/thrift/compiler/test/fixtures/exceptions/gen-go/module/ttypes.go b/thrift/compiler/test/fixtures/exceptions/gen-go/module/ttypes.go deleted file mode 100644 index 1794a64fa49..00000000000 --- a/thrift/compiler/test/fixtures/exceptions/gen-go/module/ttypes.go +++ /dev/null @@ -1,969 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package module - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var GoUnusedProtection__ int; - -// Attributes: -// - Message -type Fiery struct { - Message string `thrift:"message,1,required" db:"message" json:"message"` -} - -func NewFiery() *Fiery { - return &Fiery{} -} - - -func (p *Fiery) GetMessage() string { - return p.Message -} -type FieryBuilder struct { - obj *Fiery -} - -func NewFieryBuilder() *FieryBuilder{ - return &FieryBuilder{ - obj: NewFiery(), - } -} - -func (p FieryBuilder) Emit() *Fiery{ - return &Fiery{ - Message: p.obj.Message, - } -} - -func (f *FieryBuilder) Message(message string) *FieryBuilder { - f.obj.Message = message - return f -} - -func (f *Fiery) SetMessage(message string) *Fiery { - f.Message = message - return f -} - -func (p *Fiery) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - var issetMessage bool = false; - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - issetMessage = true - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - if !issetMessage{ - return thrift.NewProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field Message is not set")); - } - return nil -} - -func (p *Fiery) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Message = v - } - return nil -} - -func (p *Fiery) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Fiery"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Fiery) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("message", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:message: ", p), err) } - if err := oprot.WriteString(string(p.Message)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.message (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:message: ", p), err) } - return err -} - -func (p *Fiery) String() string { - if p == nil { - return "" - } - - messageVal := fmt.Sprintf("%v", p.Message) - return fmt.Sprintf("Fiery({Message:%s})", messageVal) -} - -func (p *Fiery) Error() string { - return p.String() -} - -// Attributes: -// - Sonnet -type Serious struct { - Sonnet *string `thrift:"sonnet,1,optional" db:"sonnet" json:"sonnet,omitempty"` -} - -func NewSerious() *Serious { - return &Serious{} -} - -var Serious_Sonnet_DEFAULT string -func (p *Serious) GetSonnet() string { - if !p.IsSetSonnet() { - return Serious_Sonnet_DEFAULT - } - return *p.Sonnet -} -func (p *Serious) IsSetSonnet() bool { - return p != nil && p.Sonnet != nil -} - -type SeriousBuilder struct { - obj *Serious -} - -func NewSeriousBuilder() *SeriousBuilder{ - return &SeriousBuilder{ - obj: NewSerious(), - } -} - -func (p SeriousBuilder) Emit() *Serious{ - return &Serious{ - Sonnet: p.obj.Sonnet, - } -} - -func (s *SeriousBuilder) Sonnet(sonnet *string) *SeriousBuilder { - s.obj.Sonnet = sonnet - return s -} - -func (s *Serious) SetSonnet(sonnet *string) *Serious { - s.Sonnet = sonnet - return s -} - -func (p *Serious) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Serious) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Sonnet = &v - } - return nil -} - -func (p *Serious) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Serious"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Serious) writeField1(oprot thrift.Protocol) (err error) { - if p.IsSetSonnet() { - if err := oprot.WriteFieldBegin("sonnet", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:sonnet: ", p), err) } - if err := oprot.WriteString(string(*p.Sonnet)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.sonnet (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:sonnet: ", p), err) } - } - return err -} - -func (p *Serious) String() string { - if p == nil { - return "" - } - - var sonnetVal string - if p.Sonnet == nil { - sonnetVal = "" - } else { - sonnetVal = fmt.Sprintf("%v", *p.Sonnet) - } - return fmt.Sprintf("Serious({Sonnet:%s})", sonnetVal) -} - -func (p *Serious) Error() string { - return p.String() -} - -// Attributes: -// - ErrorMessage -// - InternalErrorMessage -type ComplexFieldNames struct { - ErrorMessage string `thrift:"error_message,1" db:"error_message" json:"error_message"` - InternalErrorMessage string `thrift:"internal_error_message,2" db:"internal_error_message" json:"internal_error_message"` -} - -func NewComplexFieldNames() *ComplexFieldNames { - return &ComplexFieldNames{} -} - - -func (p *ComplexFieldNames) GetErrorMessage() string { - return p.ErrorMessage -} - -func (p *ComplexFieldNames) GetInternalErrorMessage() string { - return p.InternalErrorMessage -} -type ComplexFieldNamesBuilder struct { - obj *ComplexFieldNames -} - -func NewComplexFieldNamesBuilder() *ComplexFieldNamesBuilder{ - return &ComplexFieldNamesBuilder{ - obj: NewComplexFieldNames(), - } -} - -func (p ComplexFieldNamesBuilder) Emit() *ComplexFieldNames{ - return &ComplexFieldNames{ - ErrorMessage: p.obj.ErrorMessage, - InternalErrorMessage: p.obj.InternalErrorMessage, - } -} - -func (c *ComplexFieldNamesBuilder) ErrorMessage(errorMessage string) *ComplexFieldNamesBuilder { - c.obj.ErrorMessage = errorMessage - return c -} - -func (c *ComplexFieldNamesBuilder) InternalErrorMessage(internalErrorMessage string) *ComplexFieldNamesBuilder { - c.obj.InternalErrorMessage = internalErrorMessage - return c -} - -func (c *ComplexFieldNames) SetErrorMessage(errorMessage string) *ComplexFieldNames { - c.ErrorMessage = errorMessage - return c -} - -func (c *ComplexFieldNames) SetInternalErrorMessage(internalErrorMessage string) *ComplexFieldNames { - c.InternalErrorMessage = internalErrorMessage - return c -} - -func (p *ComplexFieldNames) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ComplexFieldNames) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.ErrorMessage = v - } - return nil -} - -func (p *ComplexFieldNames) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.InternalErrorMessage = v - } - return nil -} - -func (p *ComplexFieldNames) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("ComplexFieldNames"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *ComplexFieldNames) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("error_message", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:error_message: ", p), err) } - if err := oprot.WriteString(string(p.ErrorMessage)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.error_message (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:error_message: ", p), err) } - return err -} - -func (p *ComplexFieldNames) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("internal_error_message", thrift.STRING, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:internal_error_message: ", p), err) } - if err := oprot.WriteString(string(p.InternalErrorMessage)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.internal_error_message (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:internal_error_message: ", p), err) } - return err -} - -func (p *ComplexFieldNames) String() string { - if p == nil { - return "" - } - - errorMessageVal := fmt.Sprintf("%v", p.ErrorMessage) - internalErrorMessageVal := fmt.Sprintf("%v", p.InternalErrorMessage) - return fmt.Sprintf("ComplexFieldNames({ErrorMessage:%s InternalErrorMessage:%s})", errorMessageVal, internalErrorMessageVal) -} - -func (p *ComplexFieldNames) Error() string { - return p.String() -} - -// Attributes: -// - ErrorMessage -// - InternalErrorMessage -type CustomFieldNames struct { - ErrorMessage string `thrift:"error_message,1" db:"error_message" json:"error_message"` - InternalErrorMessage string `thrift:"internal_error_message,2" db:"internal_error_message" json:"internal_error_message"` -} - -func NewCustomFieldNames() *CustomFieldNames { - return &CustomFieldNames{} -} - - -func (p *CustomFieldNames) GetErrorMessage() string { - return p.ErrorMessage -} - -func (p *CustomFieldNames) GetInternalErrorMessage() string { - return p.InternalErrorMessage -} -type CustomFieldNamesBuilder struct { - obj *CustomFieldNames -} - -func NewCustomFieldNamesBuilder() *CustomFieldNamesBuilder{ - return &CustomFieldNamesBuilder{ - obj: NewCustomFieldNames(), - } -} - -func (p CustomFieldNamesBuilder) Emit() *CustomFieldNames{ - return &CustomFieldNames{ - ErrorMessage: p.obj.ErrorMessage, - InternalErrorMessage: p.obj.InternalErrorMessage, - } -} - -func (c *CustomFieldNamesBuilder) ErrorMessage(errorMessage string) *CustomFieldNamesBuilder { - c.obj.ErrorMessage = errorMessage - return c -} - -func (c *CustomFieldNamesBuilder) InternalErrorMessage(internalErrorMessage string) *CustomFieldNamesBuilder { - c.obj.InternalErrorMessage = internalErrorMessage - return c -} - -func (c *CustomFieldNames) SetErrorMessage(errorMessage string) *CustomFieldNames { - c.ErrorMessage = errorMessage - return c -} - -func (c *CustomFieldNames) SetInternalErrorMessage(internalErrorMessage string) *CustomFieldNames { - c.InternalErrorMessage = internalErrorMessage - return c -} - -func (p *CustomFieldNames) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *CustomFieldNames) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.ErrorMessage = v - } - return nil -} - -func (p *CustomFieldNames) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.InternalErrorMessage = v - } - return nil -} - -func (p *CustomFieldNames) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("CustomFieldNames"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *CustomFieldNames) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("error_message", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:error_message: ", p), err) } - if err := oprot.WriteString(string(p.ErrorMessage)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.error_message (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:error_message: ", p), err) } - return err -} - -func (p *CustomFieldNames) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("internal_error_message", thrift.STRING, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:internal_error_message: ", p), err) } - if err := oprot.WriteString(string(p.InternalErrorMessage)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.internal_error_message (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:internal_error_message: ", p), err) } - return err -} - -func (p *CustomFieldNames) String() string { - if p == nil { - return "" - } - - errorMessageVal := fmt.Sprintf("%v", p.ErrorMessage) - internalErrorMessageVal := fmt.Sprintf("%v", p.InternalErrorMessage) - return fmt.Sprintf("CustomFieldNames({ErrorMessage:%s InternalErrorMessage:%s})", errorMessageVal, internalErrorMessageVal) -} - -func (p *CustomFieldNames) Error() string { - return p.String() -} - -// Attributes: -// - Message -// - ErrorCode -type ExceptionWithPrimitiveField struct { - Message string `thrift:"message,1" db:"message" json:"message"` - ErrorCode int32 `thrift:"error_code,2" db:"error_code" json:"error_code"` -} - -func NewExceptionWithPrimitiveField() *ExceptionWithPrimitiveField { - return &ExceptionWithPrimitiveField{} -} - - -func (p *ExceptionWithPrimitiveField) GetMessage() string { - return p.Message -} - -func (p *ExceptionWithPrimitiveField) GetErrorCode() int32 { - return p.ErrorCode -} -type ExceptionWithPrimitiveFieldBuilder struct { - obj *ExceptionWithPrimitiveField -} - -func NewExceptionWithPrimitiveFieldBuilder() *ExceptionWithPrimitiveFieldBuilder{ - return &ExceptionWithPrimitiveFieldBuilder{ - obj: NewExceptionWithPrimitiveField(), - } -} - -func (p ExceptionWithPrimitiveFieldBuilder) Emit() *ExceptionWithPrimitiveField{ - return &ExceptionWithPrimitiveField{ - Message: p.obj.Message, - ErrorCode: p.obj.ErrorCode, - } -} - -func (e *ExceptionWithPrimitiveFieldBuilder) Message(message string) *ExceptionWithPrimitiveFieldBuilder { - e.obj.Message = message - return e -} - -func (e *ExceptionWithPrimitiveFieldBuilder) ErrorCode(errorCode int32) *ExceptionWithPrimitiveFieldBuilder { - e.obj.ErrorCode = errorCode - return e -} - -func (e *ExceptionWithPrimitiveField) SetMessage(message string) *ExceptionWithPrimitiveField { - e.Message = message - return e -} - -func (e *ExceptionWithPrimitiveField) SetErrorCode(errorCode int32) *ExceptionWithPrimitiveField { - e.ErrorCode = errorCode - return e -} - -func (p *ExceptionWithPrimitiveField) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ExceptionWithPrimitiveField) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Message = v - } - return nil -} - -func (p *ExceptionWithPrimitiveField) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.ErrorCode = v - } - return nil -} - -func (p *ExceptionWithPrimitiveField) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("ExceptionWithPrimitiveField"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *ExceptionWithPrimitiveField) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("message", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:message: ", p), err) } - if err := oprot.WriteString(string(p.Message)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.message (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:message: ", p), err) } - return err -} - -func (p *ExceptionWithPrimitiveField) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("error_code", thrift.I32, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:error_code: ", p), err) } - if err := oprot.WriteI32(int32(p.ErrorCode)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.error_code (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:error_code: ", p), err) } - return err -} - -func (p *ExceptionWithPrimitiveField) String() string { - if p == nil { - return "" - } - - messageVal := fmt.Sprintf("%v", p.Message) - errorCodeVal := fmt.Sprintf("%v", p.ErrorCode) - return fmt.Sprintf("ExceptionWithPrimitiveField({Message:%s ErrorCode:%s})", messageVal, errorCodeVal) -} - -func (p *ExceptionWithPrimitiveField) Error() string { - return p.String() -} - -// Attributes: -// - MessageField -// - ErrorCode -type ExceptionWithStructuredAnnotation struct { - MessageField string `thrift:"message_field,1" db:"message_field" json:"message_field"` - ErrorCode int32 `thrift:"error_code,2" db:"error_code" json:"error_code"` -} - -func NewExceptionWithStructuredAnnotation() *ExceptionWithStructuredAnnotation { - return &ExceptionWithStructuredAnnotation{} -} - - -func (p *ExceptionWithStructuredAnnotation) GetMessageField() string { - return p.MessageField -} - -func (p *ExceptionWithStructuredAnnotation) GetErrorCode() int32 { - return p.ErrorCode -} -type ExceptionWithStructuredAnnotationBuilder struct { - obj *ExceptionWithStructuredAnnotation -} - -func NewExceptionWithStructuredAnnotationBuilder() *ExceptionWithStructuredAnnotationBuilder{ - return &ExceptionWithStructuredAnnotationBuilder{ - obj: NewExceptionWithStructuredAnnotation(), - } -} - -func (p ExceptionWithStructuredAnnotationBuilder) Emit() *ExceptionWithStructuredAnnotation{ - return &ExceptionWithStructuredAnnotation{ - MessageField: p.obj.MessageField, - ErrorCode: p.obj.ErrorCode, - } -} - -func (e *ExceptionWithStructuredAnnotationBuilder) MessageField(messageField string) *ExceptionWithStructuredAnnotationBuilder { - e.obj.MessageField = messageField - return e -} - -func (e *ExceptionWithStructuredAnnotationBuilder) ErrorCode(errorCode int32) *ExceptionWithStructuredAnnotationBuilder { - e.obj.ErrorCode = errorCode - return e -} - -func (e *ExceptionWithStructuredAnnotation) SetMessageField(messageField string) *ExceptionWithStructuredAnnotation { - e.MessageField = messageField - return e -} - -func (e *ExceptionWithStructuredAnnotation) SetErrorCode(errorCode int32) *ExceptionWithStructuredAnnotation { - e.ErrorCode = errorCode - return e -} - -func (p *ExceptionWithStructuredAnnotation) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ExceptionWithStructuredAnnotation) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.MessageField = v - } - return nil -} - -func (p *ExceptionWithStructuredAnnotation) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.ErrorCode = v - } - return nil -} - -func (p *ExceptionWithStructuredAnnotation) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("ExceptionWithStructuredAnnotation"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *ExceptionWithStructuredAnnotation) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("message_field", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:message_field: ", p), err) } - if err := oprot.WriteString(string(p.MessageField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.message_field (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:message_field: ", p), err) } - return err -} - -func (p *ExceptionWithStructuredAnnotation) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("error_code", thrift.I32, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:error_code: ", p), err) } - if err := oprot.WriteI32(int32(p.ErrorCode)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.error_code (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:error_code: ", p), err) } - return err -} - -func (p *ExceptionWithStructuredAnnotation) String() string { - if p == nil { - return "" - } - - messageFieldVal := fmt.Sprintf("%v", p.MessageField) - errorCodeVal := fmt.Sprintf("%v", p.ErrorCode) - return fmt.Sprintf("ExceptionWithStructuredAnnotation({MessageField:%s ErrorCode:%s})", messageFieldVal, errorCodeVal) -} - -func (p *ExceptionWithStructuredAnnotation) Error() string { - return p.String() -} - -type Banal struct { -} - -func NewBanal() *Banal { - return &Banal{} -} - -type BanalBuilder struct { - obj *Banal -} - -func NewBanalBuilder() *BanalBuilder{ - return &BanalBuilder{ - obj: NewBanal(), - } -} - -func (p BanalBuilder) Emit() *Banal{ - return &Banal{ - } -} - -func (p *Banal) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Banal) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Banal"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Banal) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Banal({})") -} - -func (p *Banal) Error() string { - return p.String() -} - diff --git a/thrift/compiler/test/fixtures/exceptions/gen-go/thrift/annotation/scope/constants.go b/thrift/compiler/test/fixtures/exceptions/gen-go/thrift/annotation/scope/constants.go deleted file mode 100644 index 0c3448a7126..00000000000 --- a/thrift/compiler/test/fixtures/exceptions/gen-go/thrift/annotation/scope/constants.go +++ /dev/null @@ -1,25 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package scope - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - - -func init() { -} - diff --git a/thrift/compiler/test/fixtures/exceptions/gen-go/thrift/annotation/scope/ttypes.go b/thrift/compiler/test/fixtures/exceptions/gen-go/thrift/annotation/scope/ttypes.go deleted file mode 100644 index 580c39e775c..00000000000 --- a/thrift/compiler/test/fixtures/exceptions/gen-go/thrift/annotation/scope/ttypes.go +++ /dev/null @@ -1,1169 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package scope - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var GoUnusedProtection__ int; - -// Indicates that the scope of sibling annotations is transitive. -// -// For example: -// -// @scope.Struct -// @scope.Union -// @scope.Exception -// @scope.Transitive -// struct Structured {} -// -// Annotating a Thrift struct with @Structured automatically applies -// @scope.Struct, @scope.Union and @scope.Exception annotations, i.e. -// -// @Structured -// struct MyAnnotation {} -// -// is equivalent to -// -// @scope.Struct -// @scope.Union -// @scope.Exception -// struct MyAnnotation {} -// -type Transitive struct { -} - -func NewTransitive() *Transitive { - return &Transitive{} -} - -type TransitiveBuilder struct { - obj *Transitive -} - -func NewTransitiveBuilder() *TransitiveBuilder{ - return &TransitiveBuilder{ - obj: NewTransitive(), - } -} - -func (p TransitiveBuilder) Emit() *Transitive{ - return &Transitive{ - } -} - -func (p *Transitive) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Transitive) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Transitive"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Transitive) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Transitive({})") -} - -// The Program scope. -// -// This allows annotations on the `package` definition, which implies the -// annotaiton applies to the entire program. -type Program struct { -} - -func NewProgram() *Program { - return &Program{} -} - -type ProgramBuilder struct { - obj *Program -} - -func NewProgramBuilder() *ProgramBuilder{ - return &ProgramBuilder{ - obj: NewProgram(), - } -} - -func (p ProgramBuilder) Emit() *Program{ - return &Program{ - } -} - -func (p *Program) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Program) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Program"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Program) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Program({})") -} - -// The `struct` definition scope. -type Struct struct { -} - -func NewStruct() *Struct { - return &Struct{} -} - -type StructBuilder struct { - obj *Struct -} - -func NewStructBuilder() *StructBuilder{ - return &StructBuilder{ - obj: NewStruct(), - } -} - -func (p StructBuilder) Emit() *Struct{ - return &Struct{ - } -} - -func (p *Struct) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Struct) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Struct"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Struct) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Struct({})") -} - -// The `union` definition scope. -type Union struct { -} - -func NewUnion() *Union { - return &Union{} -} - -type UnionBuilder struct { - obj *Union -} - -func NewUnionBuilder() *UnionBuilder{ - return &UnionBuilder{ - obj: NewUnion(), - } -} - -func (p UnionBuilder) Emit() *Union{ - return &Union{ - } -} - -func (p *Union) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Union) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Union"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Union) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Union({})") -} - -// The `exception` definition scope. -type Exception struct { -} - -func NewException() *Exception { - return &Exception{} -} - -type ExceptionBuilder struct { - obj *Exception -} - -func NewExceptionBuilder() *ExceptionBuilder{ - return &ExceptionBuilder{ - obj: NewException(), - } -} - -func (p ExceptionBuilder) Emit() *Exception{ - return &Exception{ - } -} - -func (p *Exception) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Exception) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Exception"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Exception) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Exception({})") -} - -// Field declartaions, for example in `struct` or `function` declartions. -type Field struct { -} - -func NewField() *Field { - return &Field{} -} - -type FieldBuilder struct { - obj *Field -} - -func NewFieldBuilder() *FieldBuilder{ - return &FieldBuilder{ - obj: NewField(), - } -} - -func (p FieldBuilder) Emit() *Field{ - return &Field{ - } -} - -func (p *Field) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Field) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Field"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Field) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Field({})") -} - -// The `typedef` definition scope. -type Typedef struct { -} - -func NewTypedef() *Typedef { - return &Typedef{} -} - -type TypedefBuilder struct { - obj *Typedef -} - -func NewTypedefBuilder() *TypedefBuilder{ - return &TypedefBuilder{ - obj: NewTypedef(), - } -} - -func (p TypedefBuilder) Emit() *Typedef{ - return &Typedef{ - } -} - -func (p *Typedef) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Typedef) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Typedef"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Typedef) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Typedef({})") -} - -// The `service` definition scope. -type Service struct { -} - -func NewService() *Service { - return &Service{} -} - -type ServiceBuilder struct { - obj *Service -} - -func NewServiceBuilder() *ServiceBuilder{ - return &ServiceBuilder{ - obj: NewService(), - } -} - -func (p ServiceBuilder) Emit() *Service{ - return &Service{ - } -} - -func (p *Service) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Service) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Service"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Service) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Service({})") -} - -// The `interaction` definition scope. -type Interaction struct { -} - -func NewInteraction() *Interaction { - return &Interaction{} -} - -type InteractionBuilder struct { - obj *Interaction -} - -func NewInteractionBuilder() *InteractionBuilder{ - return &InteractionBuilder{ - obj: NewInteraction(), - } -} - -func (p InteractionBuilder) Emit() *Interaction{ - return &Interaction{ - } -} - -func (p *Interaction) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Interaction) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Interaction"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Interaction) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Interaction({})") -} - -// The `function` definition scope. -type Function struct { -} - -func NewFunction() *Function { - return &Function{} -} - -type FunctionBuilder struct { - obj *Function -} - -func NewFunctionBuilder() *FunctionBuilder{ - return &FunctionBuilder{ - obj: NewFunction(), - } -} - -func (p FunctionBuilder) Emit() *Function{ - return &Function{ - } -} - -func (p *Function) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Function) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Function"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Function) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Function({})") -} - -// The Enum value definition scope. -type EnumValue struct { -} - -func NewEnumValue() *EnumValue { - return &EnumValue{} -} - -type EnumValueBuilder struct { - obj *EnumValue -} - -func NewEnumValueBuilder() *EnumValueBuilder{ - return &EnumValueBuilder{ - obj: NewEnumValue(), - } -} - -func (p EnumValueBuilder) Emit() *EnumValue{ - return &EnumValue{ - } -} - -func (p *EnumValue) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *EnumValue) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("EnumValue"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *EnumValue) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("EnumValue({})") -} - -// The `const` definition scope. -type Const struct { -} - -func NewConst() *Const { - return &Const{} -} - -type ConstBuilder struct { - obj *Const -} - -func NewConstBuilder() *ConstBuilder{ - return &ConstBuilder{ - obj: NewConst(), - } -} - -func (p ConstBuilder) Emit() *Const{ - return &Const{ - } -} - -func (p *Const) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Const) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Const"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Const) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Const({})") -} - -type Enum struct { -} - -func NewEnum() *Enum { - return &Enum{} -} - -type EnumBuilder struct { - obj *Enum -} - -func NewEnumBuilder() *EnumBuilder{ - return &EnumBuilder{ - obj: NewEnum(), - } -} - -func (p EnumBuilder) Emit() *Enum{ - return &Enum{ - } -} - -func (p *Enum) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Enum) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Enum"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Enum) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Enum({})") -} - -// A scope that includes all 'structured' definitions. -type Structured struct { -} - -func NewStructured() *Structured { - return &Structured{} -} - -type StructuredBuilder struct { - obj *Structured -} - -func NewStructuredBuilder() *StructuredBuilder{ - return &StructuredBuilder{ - obj: NewStructured(), - } -} - -func (p StructuredBuilder) Emit() *Structured{ - return &Structured{ - } -} - -func (p *Structured) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Structured) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Structured"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Structured) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Structured({})") -} - -// A scope that includes all 'interface' definitions. -type Interface struct { -} - -func NewInterface() *Interface { - return &Interface{} -} - -type InterfaceBuilder struct { - obj *Interface -} - -func NewInterfaceBuilder() *InterfaceBuilder{ - return &InterfaceBuilder{ - obj: NewInterface(), - } -} - -func (p InterfaceBuilder) Emit() *Interface{ - return &Interface{ - } -} - -func (p *Interface) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Interface) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Interface"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Interface) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Interface({})") -} - -// A scope that includes all program-scoped definition. -type RootDefinition struct { -} - -func NewRootDefinition() *RootDefinition { - return &RootDefinition{} -} - -type RootDefinitionBuilder struct { - obj *RootDefinition -} - -func NewRootDefinitionBuilder() *RootDefinitionBuilder{ - return &RootDefinitionBuilder{ - obj: NewRootDefinition(), - } -} - -func (p RootDefinitionBuilder) Emit() *RootDefinition{ - return &RootDefinition{ - } -} - -func (p *RootDefinition) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *RootDefinition) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("RootDefinition"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *RootDefinition) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("RootDefinition({})") -} - -// A scope that includes all definitions. -type Definition struct { -} - -func NewDefinition() *Definition { - return &Definition{} -} - -type DefinitionBuilder struct { - obj *Definition -} - -func NewDefinitionBuilder() *DefinitionBuilder{ - return &DefinitionBuilder{ - obj: NewDefinition(), - } -} - -func (p DefinitionBuilder) Emit() *Definition{ - return &Definition{ - } -} - -func (p *Definition) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Definition) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Definition"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Definition) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Definition({})") -} - diff --git a/thrift/compiler/test/fixtures/exceptions/gen-go/thrift/annotation/thrift/constants.go b/thrift/compiler/test/fixtures/exceptions/gen-go/thrift/annotation/thrift/constants.go deleted file mode 100644 index 50d9b0fe3ee..00000000000 --- a/thrift/compiler/test/fixtures/exceptions/gen-go/thrift/annotation/thrift/constants.go +++ /dev/null @@ -1,25 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package thrift - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - - -func init() { -} - diff --git a/thrift/compiler/test/fixtures/exceptions/gen-go/thrift/annotation/thrift/ttypes.go b/thrift/compiler/test/fixtures/exceptions/gen-go/thrift/annotation/thrift/ttypes.go deleted file mode 100644 index 35ea75e3dd0..00000000000 --- a/thrift/compiler/test/fixtures/exceptions/gen-go/thrift/annotation/thrift/ttypes.go +++ /dev/null @@ -1,1545 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package thrift - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var GoUnusedProtection__ int; - -type RpcPriority int64 -const ( - RpcPriority_HIGH_IMPORTANT RpcPriority = 0 - RpcPriority_HIGH RpcPriority = 1 - RpcPriority_IMPORTANT RpcPriority = 2 - RpcPriority_NORMAL RpcPriority = 3 - RpcPriority_BEST_EFFORT RpcPriority = 4 -) - -var RpcPriorityToName = map[RpcPriority]string { - RpcPriority_HIGH_IMPORTANT: "HIGH_IMPORTANT", - RpcPriority_HIGH: "HIGH", - RpcPriority_IMPORTANT: "IMPORTANT", - RpcPriority_NORMAL: "NORMAL", - RpcPriority_BEST_EFFORT: "BEST_EFFORT", -} - -var RpcPriorityToValue = map[string]RpcPriority { - "HIGH_IMPORTANT": RpcPriority_HIGH_IMPORTANT, - "HIGH": RpcPriority_HIGH, - "IMPORTANT": RpcPriority_IMPORTANT, - "NORMAL": RpcPriority_NORMAL, - "BEST_EFFORT": RpcPriority_BEST_EFFORT, -} - -var RpcPriorityNames = []string { - "HIGH_IMPORTANT", - "HIGH", - "IMPORTANT", - "NORMAL", - "BEST_EFFORT", -} - -var RpcPriorityValues = []RpcPriority { - RpcPriority_HIGH_IMPORTANT, - RpcPriority_HIGH, - RpcPriority_IMPORTANT, - RpcPriority_NORMAL, - RpcPriority_BEST_EFFORT, -} - -func (p RpcPriority) String() string { - if v, ok := RpcPriorityToName[p]; ok { - return v - } - return "" -} - -func RpcPriorityFromString(s string) (RpcPriority, error) { - if v, ok := RpcPriorityToValue[s]; ok { - return v, nil - } - return RpcPriority(0), fmt.Errorf("not a valid RpcPriority string") -} - -func RpcPriorityPtr(v RpcPriority) *RpcPriority { return &v } - -// Indicates a definition/feature should only be used with permission, may -// only work in specific contexts, and may change in incompatible ways without -// notice. Note that this is primarily intended to annotate features by the Thrift Team -// and isn't recommended for general use. -type Experimental struct { -} - -func NewExperimental() *Experimental { - return &Experimental{} -} - -type ExperimentalBuilder struct { - obj *Experimental -} - -func NewExperimentalBuilder() *ExperimentalBuilder{ - return &ExperimentalBuilder{ - obj: NewExperimental(), - } -} - -func (p ExperimentalBuilder) Emit() *Experimental{ - return &Experimental{ - } -} - -func (p *Experimental) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Experimental) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Experimental"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Experimental) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Experimental({})") -} - -// Annotate a thrift structured or enum to indicate if ids or values should not -// be used. -// -// For example, you may want to mark ids as deprecated, or these ids -// might be reserved for other use cases or annotations. -// -// The resolved set of disallowed ids is the union of the values in `ids` and -// the range of values represented in `id_ranges`. Example: -// -// // These ids are not allowed: 3, 8, half-open ranges [10, 15), [20, 30) -// @thrift.ReserveIds{ids = [3, 8], id_ranges = {10: 15, 20: 30}} -// struct Foo { -// ... -// 3: i64 f; // Build failure: 3 cannot be used -// } -// -// Attributes: -// - Ids: Individual ids that cannot be used. -// - IdRanges: Represents ranges of ids that cannot be used. -// -// Each (key: value) pair represents the half-open range `[key, value)`, -// where `key` is included and `value` is not. For example, the map -// `{10: 15, 20: 30}` represents the union of id/value ranges `[10, 15)` and -// `[20, 30)`. -type ReserveIds struct { - Ids []int32 `thrift:"ids,1" db:"ids" json:"ids"` - IdRanges map[int32]int32 `thrift:"id_ranges,2" db:"id_ranges" json:"id_ranges"` -} - -func NewReserveIds() *ReserveIds { - return &ReserveIds{} -} - - -func (p *ReserveIds) GetIds() []int32 { - return p.Ids -} - -func (p *ReserveIds) GetIdRanges() map[int32]int32 { - return p.IdRanges -} -type ReserveIdsBuilder struct { - obj *ReserveIds -} - -func NewReserveIdsBuilder() *ReserveIdsBuilder{ - return &ReserveIdsBuilder{ - obj: NewReserveIds(), - } -} - -func (p ReserveIdsBuilder) Emit() *ReserveIds{ - return &ReserveIds{ - Ids: p.obj.Ids, - IdRanges: p.obj.IdRanges, - } -} - -func (r *ReserveIdsBuilder) Ids(ids []int32) *ReserveIdsBuilder { - r.obj.Ids = ids - return r -} - -func (r *ReserveIdsBuilder) IdRanges(idRanges map[int32]int32) *ReserveIdsBuilder { - r.obj.IdRanges = idRanges - return r -} - -func (r *ReserveIds) SetIds(ids []int32) *ReserveIds { - r.Ids = ids - return r -} - -func (r *ReserveIds) SetIdRanges(idRanges map[int32]int32) *ReserveIds { - r.IdRanges = idRanges - return r -} - -func (p *ReserveIds) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ReserveIds) ReadField1(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]int32, 0, size) - p.Ids = tSlice - for i := 0; i < size; i ++ { - var _elem0 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem0 = v - } - p.Ids = append(p.Ids, _elem0) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *ReserveIds) ReadField2(iprot thrift.Protocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[int32]int32, size) - p.IdRanges = tMap - for i := 0; i < size; i ++ { - var _key1 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key1 = v - } - var _val2 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _val2 = v - } - p.IdRanges[_key1] = _val2 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *ReserveIds) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("ReserveIds"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *ReserveIds) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("ids", thrift.LIST, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:ids: ", p), err) } - if err := oprot.WriteListBegin(thrift.I32, len(p.Ids)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.Ids { - if err := oprot.WriteI32(int32(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:ids: ", p), err) } - return err -} - -func (p *ReserveIds) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("id_ranges", thrift.MAP, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:id_ranges: ", p), err) } - if err := oprot.WriteMapBegin(thrift.I32, thrift.I32, len(p.IdRanges)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.IdRanges { - if err := oprot.WriteI32(int32(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := oprot.WriteI32(int32(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:id_ranges: ", p), err) } - return err -} - -func (p *ReserveIds) String() string { - if p == nil { - return "" - } - - idsVal := fmt.Sprintf("%v", p.Ids) - idRangesVal := fmt.Sprintf("%v", p.IdRanges) - return fmt.Sprintf("ReserveIds({Ids:%s IdRanges:%s})", idsVal, idRangesVal) -} - -// Indicates additional backward compatibility restrictions, beyond the -// standard Thrift required 'wire' compatibility. -// -// Attributes: -// - FieldName -type RequiresBackwardCompatibility struct { - FieldName bool `thrift:"field_name,1" db:"field_name" json:"field_name"` -} - -func NewRequiresBackwardCompatibility() *RequiresBackwardCompatibility { - return &RequiresBackwardCompatibility{} -} - - -func (p *RequiresBackwardCompatibility) GetFieldName() bool { - return p.FieldName -} -type RequiresBackwardCompatibilityBuilder struct { - obj *RequiresBackwardCompatibility -} - -func NewRequiresBackwardCompatibilityBuilder() *RequiresBackwardCompatibilityBuilder{ - return &RequiresBackwardCompatibilityBuilder{ - obj: NewRequiresBackwardCompatibility(), - } -} - -func (p RequiresBackwardCompatibilityBuilder) Emit() *RequiresBackwardCompatibility{ - return &RequiresBackwardCompatibility{ - FieldName: p.obj.FieldName, - } -} - -func (r *RequiresBackwardCompatibilityBuilder) FieldName(fieldName bool) *RequiresBackwardCompatibilityBuilder { - r.obj.FieldName = fieldName - return r -} - -func (r *RequiresBackwardCompatibility) SetFieldName(fieldName bool) *RequiresBackwardCompatibility { - r.FieldName = fieldName - return r -} - -func (p *RequiresBackwardCompatibility) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *RequiresBackwardCompatibility) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.FieldName = v - } - return nil -} - -func (p *RequiresBackwardCompatibility) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("RequiresBackwardCompatibility"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *RequiresBackwardCompatibility) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("field_name", thrift.BOOL, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:field_name: ", p), err) } - if err := oprot.WriteBool(bool(p.FieldName)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.field_name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:field_name: ", p), err) } - return err -} - -func (p *RequiresBackwardCompatibility) String() string { - if p == nil { - return "" - } - - fieldNameVal := fmt.Sprintf("%v", p.FieldName) - return fmt.Sprintf("RequiresBackwardCompatibility({FieldName:%s})", fieldNameVal) -} - -// An annotation that changes the field qualifier from 'none' to 'terse'. -// A terse field is eligible to skip serialization, when it equals to the -// intrinsic default value. It also clears to the intrinsic default value -// before deserialization to distinguish between if a terse field was skipped -// or missing during serialization. This is different from an unqualified -// field, as an unqualified field is always serialized regardless of its value, -// and it is not cleared before deserialization. -// -// The annotation can be only used to annotate an unqualified field, and when -// it is annotating a struct or exception, it changes all unqualified fields to -// terse fields. Note, the annotation can not be used for union. -type TerseWrite struct { -} - -func NewTerseWrite() *TerseWrite { - return &TerseWrite{} -} - -type TerseWriteBuilder struct { - obj *TerseWrite -} - -func NewTerseWriteBuilder() *TerseWriteBuilder{ - return &TerseWriteBuilder{ - obj: NewTerseWrite(), - } -} - -func (p TerseWriteBuilder) Emit() *TerseWrite{ - return &TerseWrite{ - } -} - -func (p *TerseWrite) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *TerseWrite) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("TerseWrite"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *TerseWrite) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("TerseWrite({})") -} - -// Indicates that an optional field's value should never be stored on the stack, -// i.e. the subobject should be allocated separately (e.g. because it is large and infrequently set). -// -// NOTE: The APIs and initialization behavior are same as normal field, but different from `@cpp.Ref`. e.g. -// -// ``` -// struct Foo { -// 1: optional i32 normal; -// @thrift.Box -// 2: optional i32 boxed; -// @cpp.Ref -// 3: optional i32 referred; -// } -// ``` -// in C++ -// -// ``` -// Foo foo; -// EXPECT_FALSE(foo.normal().has_value()); // okay -// EXPECT_FALSE(foo.boxed().has_value()); // okay -// EXPECT_FALSE(foo.referred().has_value()); // build failure: std::unique_ptr doesn't have has_value method -// -// EXPECT_EQ(*foo.normal(), 0); // throw bad_field_access exception -// EXPECT_EQ(*foo.boxed(), 0); // throw bad_field_access exception -// EXPECT_EQ(*foo.referred(), 0); // okay, field has value by default -// ``` -// -// Affects C++ and Rust. -// TODO: replace with @cpp.Box + @rust.Box -type Box struct { -} - -func NewBox() *Box { - return &Box{} -} - -type BoxBuilder struct { - obj *Box -} - -func NewBoxBuilder() *BoxBuilder{ - return &BoxBuilder{ - obj: NewBox(), - } -} - -func (p BoxBuilder) Emit() *Box{ - return &Box{ - } -} - -func (p *Box) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Box) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Box"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Box) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Box({})") -} - -// Indicates whether the nested fields are accessible directly. -// https://github.com/facebook/fbthrift/blob/v2023.11.20.00/thrift/doc/idl/mixins.md -type Mixin struct { -} - -func NewMixin() *Mixin { - return &Mixin{} -} - -type MixinBuilder struct { - obj *Mixin -} - -func NewMixinBuilder() *MixinBuilder{ - return &MixinBuilder{ - obj: NewMixin(), - } -} - -func (p MixinBuilder) Emit() *Mixin{ - return &Mixin{ - } -} - -func (p *Mixin) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Mixin) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Mixin"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Mixin) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Mixin({})") -} - -// Option to serialize thrift struct in ascending field id order instead of field declaration order. -// -// This can potentially make serialized data size smaller in compact protocol, -// since compact protocol can write deltas between subsequent field ids instead of full ids. -// -// NOTE: This annotation won't reduce payload size for other protocols. -type SerializeInFieldIdOrder struct { -} - -func NewSerializeInFieldIdOrder() *SerializeInFieldIdOrder { - return &SerializeInFieldIdOrder{} -} - -type SerializeInFieldIdOrderBuilder struct { - obj *SerializeInFieldIdOrder -} - -func NewSerializeInFieldIdOrderBuilder() *SerializeInFieldIdOrderBuilder{ - return &SerializeInFieldIdOrderBuilder{ - obj: NewSerializeInFieldIdOrder(), - } -} - -func (p SerializeInFieldIdOrderBuilder) Emit() *SerializeInFieldIdOrder{ - return &SerializeInFieldIdOrder{ - } -} - -func (p *SerializeInFieldIdOrder) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *SerializeInFieldIdOrder) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("SerializeInFieldIdOrder"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *SerializeInFieldIdOrder) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("SerializeInFieldIdOrder({})") -} - -// Indicates an enum is a bitmask and should support bit-wise operators. -// Currently generates additional code in C++ and Hack. -type BitmaskEnum struct { -} - -func NewBitmaskEnum() *BitmaskEnum { - return &BitmaskEnum{} -} - -type BitmaskEnumBuilder struct { - obj *BitmaskEnum -} - -func NewBitmaskEnumBuilder() *BitmaskEnumBuilder{ - return &BitmaskEnumBuilder{ - obj: NewBitmaskEnum(), - } -} - -func (p BitmaskEnumBuilder) Emit() *BitmaskEnum{ - return &BitmaskEnum{ - } -} - -func (p *BitmaskEnum) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *BitmaskEnum) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("BitmaskEnum"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *BitmaskEnum) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("BitmaskEnum({})") -} - -// Specifies the field where the exception message is stored. -type ExceptionMessage struct { -} - -func NewExceptionMessage() *ExceptionMessage { - return &ExceptionMessage{} -} - -type ExceptionMessageBuilder struct { - obj *ExceptionMessage -} - -func NewExceptionMessageBuilder() *ExceptionMessageBuilder{ - return &ExceptionMessageBuilder{ - obj: NewExceptionMessage(), - } -} - -func (p ExceptionMessageBuilder) Emit() *ExceptionMessage{ - return &ExceptionMessage{ - } -} - -func (p *ExceptionMessage) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ExceptionMessage) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("ExceptionMessage"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *ExceptionMessage) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("ExceptionMessage({})") -} - -// Generates a const of type schema. Struct containing the schema of the -// annotated type. Optionally specify name to override default -// schema. -// -// Attributes: -// - Name -type GenerateRuntimeSchema struct { - Name string `thrift:"name,1" db:"name" json:"name"` -} - -func NewGenerateRuntimeSchema() *GenerateRuntimeSchema { - return &GenerateRuntimeSchema{} -} - - -func (p *GenerateRuntimeSchema) GetName() string { - return p.Name -} -type GenerateRuntimeSchemaBuilder struct { - obj *GenerateRuntimeSchema -} - -func NewGenerateRuntimeSchemaBuilder() *GenerateRuntimeSchemaBuilder{ - return &GenerateRuntimeSchemaBuilder{ - obj: NewGenerateRuntimeSchema(), - } -} - -func (p GenerateRuntimeSchemaBuilder) Emit() *GenerateRuntimeSchema{ - return &GenerateRuntimeSchema{ - Name: p.obj.Name, - } -} - -func (g *GenerateRuntimeSchemaBuilder) Name(name string) *GenerateRuntimeSchemaBuilder { - g.obj.Name = name - return g -} - -func (g *GenerateRuntimeSchema) SetName(name string) *GenerateRuntimeSchema { - g.Name = name - return g -} - -func (p *GenerateRuntimeSchema) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *GenerateRuntimeSchema) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Name = v - } - return nil -} - -func (p *GenerateRuntimeSchema) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("GenerateRuntimeSchema"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *GenerateRuntimeSchema) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) } - if err := oprot.WriteString(string(p.Name)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) } - return err -} - -func (p *GenerateRuntimeSchema) String() string { - if p == nil { - return "" - } - - nameVal := fmt.Sprintf("%v", p.Name) - return fmt.Sprintf("GenerateRuntimeSchema({Name:%s})", nameVal) -} - -// Indicates that a field's value should never be stored on the stack, and that -// identical values can be shared in immutable contexts. -type InternBox struct { -} - -func NewInternBox() *InternBox { - return &InternBox{} -} - -type InternBoxBuilder struct { - obj *InternBox -} - -func NewInternBoxBuilder() *InternBoxBuilder{ - return &InternBoxBuilder{ - obj: NewInternBox(), - } -} - -func (p InternBoxBuilder) Emit() *InternBox{ - return &InternBox{ - } -} - -func (p *InternBox) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *InternBox) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("InternBox"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *InternBox) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("InternBox({})") -} - -// Indicates that an interaction's methods should be processed sequentially. -type Serial struct { -} - -func NewSerial() *Serial { - return &Serial{} -} - -type SerialBuilder struct { - obj *Serial -} - -func NewSerialBuilder() *SerialBuilder{ - return &SerialBuilder{ - obj: NewSerial(), - } -} - -func (p SerialBuilder) Emit() *Serial{ - return &Serial{ - } -} - -func (p *Serial) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Serial) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Serial"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Serial) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Serial({})") -} - -// Changes the URI of this definition away from the default-generated one. -// -// Attributes: -// - Value -type Uri struct { - Value string `thrift:"value,1" db:"value" json:"value"` -} - -func NewUri() *Uri { - return &Uri{} -} - - -func (p *Uri) GetValue() string { - return p.Value -} -type UriBuilder struct { - obj *Uri -} - -func NewUriBuilder() *UriBuilder{ - return &UriBuilder{ - obj: NewUri(), - } -} - -func (p UriBuilder) Emit() *Uri{ - return &Uri{ - Value: p.obj.Value, - } -} - -func (u *UriBuilder) Value(value string) *UriBuilder { - u.obj.Value = value - return u -} - -func (u *Uri) SetValue(value string) *Uri { - u.Value = value - return u -} - -func (p *Uri) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Uri) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Value = v - } - return nil -} - -func (p *Uri) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Uri"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Uri) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("value", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:value: ", p), err) } - if err := oprot.WriteString(string(p.Value)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.value (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:value: ", p), err) } - return err -} - -func (p *Uri) String() string { - if p == nil { - return "" - } - - valueVal := fmt.Sprintf("%v", p.Value) - return fmt.Sprintf("Uri({Value:%s})", valueVal) -} - -// Changes the priority of this function (default NORMAL). -// -// Attributes: -// - Level -type Priority struct { - Level RpcPriority `thrift:"level,1" db:"level" json:"level"` -} - -func NewPriority() *Priority { - return &Priority{} -} - - -func (p *Priority) GetLevel() RpcPriority { - return p.Level -} -type PriorityBuilder struct { - obj *Priority -} - -func NewPriorityBuilder() *PriorityBuilder{ - return &PriorityBuilder{ - obj: NewPriority(), - } -} - -func (p PriorityBuilder) Emit() *Priority{ - return &Priority{ - Level: p.obj.Level, - } -} - -func (p *PriorityBuilder) Level(level RpcPriority) *PriorityBuilder { - p.obj.Level = level - return p -} - -func (p *Priority) SetLevel(level RpcPriority) *Priority { - p.Level = level - return p -} - -func (p *Priority) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Priority) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - temp := RpcPriority(v) - p.Level = temp - } - return nil -} - -func (p *Priority) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Priority"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Priority) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("level", thrift.I32, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:level: ", p), err) } - if err := oprot.WriteI32(int32(p.Level)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.level (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:level: ", p), err) } - return err -} - -func (p *Priority) String() string { - if p == nil { - return "" - } - - levelVal := fmt.Sprintf("%v", p.Level) - return fmt.Sprintf("Priority({Level:%s})", levelVal) -} - -// Applies unstructured annotations to a definition. -// -// Attributes: -// - Items -type DeprecatedUnvalidatedAnnotations struct { - Items map[string]string `thrift:"items,1" db:"items" json:"items"` -} - -func NewDeprecatedUnvalidatedAnnotations() *DeprecatedUnvalidatedAnnotations { - return &DeprecatedUnvalidatedAnnotations{} -} - - -func (p *DeprecatedUnvalidatedAnnotations) GetItems() map[string]string { - return p.Items -} -type DeprecatedUnvalidatedAnnotationsBuilder struct { - obj *DeprecatedUnvalidatedAnnotations -} - -func NewDeprecatedUnvalidatedAnnotationsBuilder() *DeprecatedUnvalidatedAnnotationsBuilder{ - return &DeprecatedUnvalidatedAnnotationsBuilder{ - obj: NewDeprecatedUnvalidatedAnnotations(), - } -} - -func (p DeprecatedUnvalidatedAnnotationsBuilder) Emit() *DeprecatedUnvalidatedAnnotations{ - return &DeprecatedUnvalidatedAnnotations{ - Items: p.obj.Items, - } -} - -func (d *DeprecatedUnvalidatedAnnotationsBuilder) Items(items map[string]string) *DeprecatedUnvalidatedAnnotationsBuilder { - d.obj.Items = items - return d -} - -func (d *DeprecatedUnvalidatedAnnotations) SetItems(items map[string]string) *DeprecatedUnvalidatedAnnotations { - d.Items = items - return d -} - -func (p *DeprecatedUnvalidatedAnnotations) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *DeprecatedUnvalidatedAnnotations) ReadField1(iprot thrift.Protocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[string]string, size) - p.Items = tMap - for i := 0; i < size; i ++ { - var _key3 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key3 = v - } - var _val4 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _val4 = v - } - p.Items[_key3] = _val4 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *DeprecatedUnvalidatedAnnotations) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("DeprecatedUnvalidatedAnnotations"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *DeprecatedUnvalidatedAnnotations) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("items", thrift.MAP, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:items: ", p), err) } - if err := oprot.WriteMapBegin(thrift.STRING, thrift.STRING, len(p.Items)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.Items { - if err := oprot.WriteString(string(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := oprot.WriteString(string(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:items: ", p), err) } - return err -} - -func (p *DeprecatedUnvalidatedAnnotations) String() string { - if p == nil { - return "" - } - - itemsVal := fmt.Sprintf("%v", p.Items) - return fmt.Sprintf("DeprecatedUnvalidatedAnnotations({Items:%s})", itemsVal) -} - diff --git a/thrift/compiler/test/fixtures/go-service/gen-go/module/constants.go b/thrift/compiler/test/fixtures/go-service/gen-go/module/constants.go deleted file mode 100644 index 477cf91a64b..00000000000 --- a/thrift/compiler/test/fixtures/go-service/gen-go/module/constants.go +++ /dev/null @@ -1,25 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package module - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - - -func init() { -} - diff --git a/thrift/compiler/test/fixtures/go-service/gen-go/module/getentity.go b/thrift/compiler/test/fixtures/go-service/gen-go/module/getentity.go deleted file mode 100644 index c8ef3da3aca..00000000000 --- a/thrift/compiler/test/fixtures/go-service/gen-go/module/getentity.go +++ /dev/null @@ -1,5039 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package module - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -type GetEntity interface { - // Parameters: - // - R - GetEntity(r *GetEntityRequest) (_r *GetEntityResponse, err error) - GetBool() (_r bool, err error) - GetByte() (_r int8, err error) - GetI16() (_r int16, err error) - GetI32() (_r int32, err error) - GetI64() (_r int64, err error) - GetDouble() (_r float64, err error) - GetString() (_r string, err error) - GetBinary() (_r []byte, err error) - GetMap() (_r map[string]string, err error) - GetSet() (_r []string, err error) - GetList() (_r []string, err error) - // Parameters: - // - NumPos - // - NumNeg1 - // - NumNeg2 - GetLegacyStuff(numPos int64, numNeg1 int64, numNeg2 int64) (_r int32, err error) - // Parameters: - // - Ctx - GetCtxCollision(ctx int64) (_r int32, err error) - // Parameters: - // - Ctx - // - Ctx1 - GetCtx1Collision(ctx int64, ctx1 int64) (_r int32, err error) -} - -type GetEntityClientInterface interface { - thrift.ClientInterface - // Parameters: - // - R - GetEntity(r *GetEntityRequest) (_r *GetEntityResponse, err error) - GetBool() (_r bool, err error) - GetByte() (_r int8, err error) - GetI16() (_r int16, err error) - GetI32() (_r int32, err error) - GetI64() (_r int64, err error) - GetDouble() (_r float64, err error) - GetString() (_r string, err error) - GetBinary() (_r []byte, err error) - GetMap() (_r map[string]string, err error) - GetSet() (_r []string, err error) - GetList() (_r []string, err error) - // Parameters: - // - NumPos - // - NumNeg1 - // - NumNeg2 - GetLegacyStuff(numPos int64, numNeg1 int64, numNeg2 int64) (_r int32, err error) - // Parameters: - // - Ctx - GetCtxCollision(ctx int64) (_r int32, err error) - // Parameters: - // - Ctx - // - Ctx1 - GetCtx1Collision(ctx int64, ctx1 int64) (_r int32, err error) -} - -type GetEntityClient struct { - GetEntityClientInterface - CC thrift.ClientConn -} - -func(client *GetEntityClient) Open() error { - return client.CC.Open() -} - -func(client *GetEntityClient) Close() error { - return client.CC.Close() -} - -func(client *GetEntityClient) IsOpen() bool { - return client.CC.IsOpen() -} - -func NewGetEntityClientFactory(t thrift.Transport, f thrift.ProtocolFactory) *GetEntityClient { - return &GetEntityClient{ CC: thrift.NewClientConn(t, f) } -} - -func NewGetEntityClient(t thrift.Transport, iprot thrift.Protocol, oprot thrift.Protocol) *GetEntityClient { - return &GetEntityClient{ CC: thrift.NewClientConnWithProtocols(t, iprot, oprot) } -} - -func NewGetEntityClientProtocol(prot thrift.Protocol) *GetEntityClient { - return NewGetEntityClient(prot.Transport(), prot, prot) -} - -// Parameters: -// - R -func (p *GetEntityClient) GetEntity(r *GetEntityRequest) (_r *GetEntityResponse, err error) { - args := GetEntityGetEntityArgs{ - R : r, - } - err = p.CC.SendMsg("getEntity", &args, thrift.CALL) - if err != nil { return } - return p.recvGetEntity() -} - - -func (p *GetEntityClient) recvGetEntity() (value *GetEntityResponse, err error) { - var __result GetEntityGetEntityResult - err = p.CC.RecvMsg("getEntity", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -func (p *GetEntityClient) GetBool() (_r bool, err error) { - var args GetEntityGetBoolArgs - err = p.CC.SendMsg("getBool", &args, thrift.CALL) - if err != nil { return } - return p.recvGetBool() -} - - -func (p *GetEntityClient) recvGetBool() (value bool, err error) { - var __result GetEntityGetBoolResult - err = p.CC.RecvMsg("getBool", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -func (p *GetEntityClient) GetByte() (_r int8, err error) { - var args GetEntityGetByteArgs - err = p.CC.SendMsg("getByte", &args, thrift.CALL) - if err != nil { return } - return p.recvGetByte() -} - - -func (p *GetEntityClient) recvGetByte() (value int8, err error) { - var __result GetEntityGetByteResult - err = p.CC.RecvMsg("getByte", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -func (p *GetEntityClient) GetI16() (_r int16, err error) { - var args GetEntityGetI16Args - err = p.CC.SendMsg("getI16", &args, thrift.CALL) - if err != nil { return } - return p.recvGetI16() -} - - -func (p *GetEntityClient) recvGetI16() (value int16, err error) { - var __result GetEntityGetI16Result - err = p.CC.RecvMsg("getI16", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -func (p *GetEntityClient) GetI32() (_r int32, err error) { - var args GetEntityGetI32Args - err = p.CC.SendMsg("getI32", &args, thrift.CALL) - if err != nil { return } - return p.recvGetI32() -} - - -func (p *GetEntityClient) recvGetI32() (value int32, err error) { - var __result GetEntityGetI32Result - err = p.CC.RecvMsg("getI32", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -func (p *GetEntityClient) GetI64() (_r int64, err error) { - var args GetEntityGetI64Args - err = p.CC.SendMsg("getI64", &args, thrift.CALL) - if err != nil { return } - return p.recvGetI64() -} - - -func (p *GetEntityClient) recvGetI64() (value int64, err error) { - var __result GetEntityGetI64Result - err = p.CC.RecvMsg("getI64", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -func (p *GetEntityClient) GetDouble() (_r float64, err error) { - var args GetEntityGetDoubleArgs - err = p.CC.SendMsg("getDouble", &args, thrift.CALL) - if err != nil { return } - return p.recvGetDouble() -} - - -func (p *GetEntityClient) recvGetDouble() (value float64, err error) { - var __result GetEntityGetDoubleResult - err = p.CC.RecvMsg("getDouble", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -func (p *GetEntityClient) GetString() (_r string, err error) { - var args GetEntityGetStringArgs - err = p.CC.SendMsg("getString", &args, thrift.CALL) - if err != nil { return } - return p.recvGetString() -} - - -func (p *GetEntityClient) recvGetString() (value string, err error) { - var __result GetEntityGetStringResult - err = p.CC.RecvMsg("getString", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -func (p *GetEntityClient) GetBinary() (_r []byte, err error) { - var args GetEntityGetBinaryArgs - err = p.CC.SendMsg("getBinary", &args, thrift.CALL) - if err != nil { return } - return p.recvGetBinary() -} - - -func (p *GetEntityClient) recvGetBinary() (value []byte, err error) { - var __result GetEntityGetBinaryResult - err = p.CC.RecvMsg("getBinary", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -func (p *GetEntityClient) GetMap() (_r map[string]string, err error) { - var args GetEntityGetMapArgs - err = p.CC.SendMsg("getMap", &args, thrift.CALL) - if err != nil { return } - return p.recvGetMap() -} - - -func (p *GetEntityClient) recvGetMap() (value map[string]string, err error) { - var __result GetEntityGetMapResult - err = p.CC.RecvMsg("getMap", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -func (p *GetEntityClient) GetSet() (_r []string, err error) { - var args GetEntityGetSetArgs - err = p.CC.SendMsg("getSet", &args, thrift.CALL) - if err != nil { return } - return p.recvGetSet() -} - - -func (p *GetEntityClient) recvGetSet() (value []string, err error) { - var __result GetEntityGetSetResult - err = p.CC.RecvMsg("getSet", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -func (p *GetEntityClient) GetList() (_r []string, err error) { - var args GetEntityGetListArgs - err = p.CC.SendMsg("getList", &args, thrift.CALL) - if err != nil { return } - return p.recvGetList() -} - - -func (p *GetEntityClient) recvGetList() (value []string, err error) { - var __result GetEntityGetListResult - err = p.CC.RecvMsg("getList", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -// Parameters: -// - NumPos -// - NumNeg1 -// - NumNeg2 -func (p *GetEntityClient) GetLegacyStuff(numPos int64, numNeg1 int64, numNeg2 int64) (_r int32, err error) { - args := GetEntityGetLegacyStuffArgs{ - NumPos : numPos, - NumNeg1 : numNeg1, - NumNeg2 : numNeg2, - } - err = p.CC.SendMsg("getLegacyStuff", &args, thrift.CALL) - if err != nil { return } - return p.recvGetLegacyStuff() -} - - -func (p *GetEntityClient) recvGetLegacyStuff() (value int32, err error) { - var __result GetEntityGetLegacyStuffResult - err = p.CC.RecvMsg("getLegacyStuff", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -// Parameters: -// - Ctx -func (p *GetEntityClient) GetCtxCollision(ctx int64) (_r int32, err error) { - args := GetEntityGetCtxCollisionArgs{ - Ctx : ctx, - } - err = p.CC.SendMsg("getCtxCollision", &args, thrift.CALL) - if err != nil { return } - return p.recvGetCtxCollision() -} - - -func (p *GetEntityClient) recvGetCtxCollision() (value int32, err error) { - var __result GetEntityGetCtxCollisionResult - err = p.CC.RecvMsg("getCtxCollision", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -// Parameters: -// - Ctx -// - Ctx1 -func (p *GetEntityClient) GetCtx1Collision(ctx int64, ctx1 int64) (_r int32, err error) { - args := GetEntityGetCtx1CollisionArgs{ - Ctx : ctx, - Ctx1 : ctx1, - } - err = p.CC.SendMsg("getCtx1Collision", &args, thrift.CALL) - if err != nil { return } - return p.recvGetCtx1Collision() -} - - -func (p *GetEntityClient) recvGetCtx1Collision() (value int32, err error) { - var __result GetEntityGetCtx1CollisionResult - err = p.CC.RecvMsg("getCtx1Collision", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - - -type GetEntityThreadsafeClient struct { - GetEntityClientInterface - CC thrift.ClientConn - Mu sync.Mutex -} - -func(client *GetEntityThreadsafeClient) Open() error { - client.Mu.Lock() - defer client.Mu.Unlock() - return client.CC.Open() -} - -func(client *GetEntityThreadsafeClient) Close() error { - client.Mu.Lock() - defer client.Mu.Unlock() - return client.CC.Close() -} - -func(client *GetEntityThreadsafeClient) IsOpen() bool { - client.Mu.Lock() - defer client.Mu.Unlock() - return client.CC.IsOpen() -} - -func NewGetEntityThreadsafeClientFactory(t thrift.Transport, f thrift.ProtocolFactory) *GetEntityThreadsafeClient { - return &GetEntityThreadsafeClient{ CC: thrift.NewClientConn(t, f) } -} - -func NewGetEntityThreadsafeClient(t thrift.Transport, iprot thrift.Protocol, oprot thrift.Protocol) *GetEntityThreadsafeClient { - return &GetEntityThreadsafeClient{ CC: thrift.NewClientConnWithProtocols(t, iprot, oprot) } -} - -func NewGetEntityThreadsafeClientProtocol(prot thrift.Protocol) *GetEntityThreadsafeClient { - return NewGetEntityThreadsafeClient(prot.Transport(), prot, prot) -} - -// Parameters: -// - R -func (p *GetEntityThreadsafeClient) GetEntity(r *GetEntityRequest) (_r *GetEntityResponse, err error) { - p.Mu.Lock() - defer p.Mu.Unlock() - args := GetEntityGetEntityArgs{ - R : r, - } - err = p.CC.SendMsg("getEntity", &args, thrift.CALL) - if err != nil { return } - return p.recvGetEntity() -} - - -func (p *GetEntityThreadsafeClient) recvGetEntity() (value *GetEntityResponse, err error) { - var __result GetEntityGetEntityResult - err = p.CC.RecvMsg("getEntity", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -func (p *GetEntityThreadsafeClient) GetBool() (_r bool, err error) { - p.Mu.Lock() - defer p.Mu.Unlock() - var args GetEntityGetBoolArgs - err = p.CC.SendMsg("getBool", &args, thrift.CALL) - if err != nil { return } - return p.recvGetBool() -} - - -func (p *GetEntityThreadsafeClient) recvGetBool() (value bool, err error) { - var __result GetEntityGetBoolResult - err = p.CC.RecvMsg("getBool", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -func (p *GetEntityThreadsafeClient) GetByte() (_r int8, err error) { - p.Mu.Lock() - defer p.Mu.Unlock() - var args GetEntityGetByteArgs - err = p.CC.SendMsg("getByte", &args, thrift.CALL) - if err != nil { return } - return p.recvGetByte() -} - - -func (p *GetEntityThreadsafeClient) recvGetByte() (value int8, err error) { - var __result GetEntityGetByteResult - err = p.CC.RecvMsg("getByte", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -func (p *GetEntityThreadsafeClient) GetI16() (_r int16, err error) { - p.Mu.Lock() - defer p.Mu.Unlock() - var args GetEntityGetI16Args - err = p.CC.SendMsg("getI16", &args, thrift.CALL) - if err != nil { return } - return p.recvGetI16() -} - - -func (p *GetEntityThreadsafeClient) recvGetI16() (value int16, err error) { - var __result GetEntityGetI16Result - err = p.CC.RecvMsg("getI16", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -func (p *GetEntityThreadsafeClient) GetI32() (_r int32, err error) { - p.Mu.Lock() - defer p.Mu.Unlock() - var args GetEntityGetI32Args - err = p.CC.SendMsg("getI32", &args, thrift.CALL) - if err != nil { return } - return p.recvGetI32() -} - - -func (p *GetEntityThreadsafeClient) recvGetI32() (value int32, err error) { - var __result GetEntityGetI32Result - err = p.CC.RecvMsg("getI32", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -func (p *GetEntityThreadsafeClient) GetI64() (_r int64, err error) { - p.Mu.Lock() - defer p.Mu.Unlock() - var args GetEntityGetI64Args - err = p.CC.SendMsg("getI64", &args, thrift.CALL) - if err != nil { return } - return p.recvGetI64() -} - - -func (p *GetEntityThreadsafeClient) recvGetI64() (value int64, err error) { - var __result GetEntityGetI64Result - err = p.CC.RecvMsg("getI64", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -func (p *GetEntityThreadsafeClient) GetDouble() (_r float64, err error) { - p.Mu.Lock() - defer p.Mu.Unlock() - var args GetEntityGetDoubleArgs - err = p.CC.SendMsg("getDouble", &args, thrift.CALL) - if err != nil { return } - return p.recvGetDouble() -} - - -func (p *GetEntityThreadsafeClient) recvGetDouble() (value float64, err error) { - var __result GetEntityGetDoubleResult - err = p.CC.RecvMsg("getDouble", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -func (p *GetEntityThreadsafeClient) GetString() (_r string, err error) { - p.Mu.Lock() - defer p.Mu.Unlock() - var args GetEntityGetStringArgs - err = p.CC.SendMsg("getString", &args, thrift.CALL) - if err != nil { return } - return p.recvGetString() -} - - -func (p *GetEntityThreadsafeClient) recvGetString() (value string, err error) { - var __result GetEntityGetStringResult - err = p.CC.RecvMsg("getString", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -func (p *GetEntityThreadsafeClient) GetBinary() (_r []byte, err error) { - p.Mu.Lock() - defer p.Mu.Unlock() - var args GetEntityGetBinaryArgs - err = p.CC.SendMsg("getBinary", &args, thrift.CALL) - if err != nil { return } - return p.recvGetBinary() -} - - -func (p *GetEntityThreadsafeClient) recvGetBinary() (value []byte, err error) { - var __result GetEntityGetBinaryResult - err = p.CC.RecvMsg("getBinary", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -func (p *GetEntityThreadsafeClient) GetMap() (_r map[string]string, err error) { - p.Mu.Lock() - defer p.Mu.Unlock() - var args GetEntityGetMapArgs - err = p.CC.SendMsg("getMap", &args, thrift.CALL) - if err != nil { return } - return p.recvGetMap() -} - - -func (p *GetEntityThreadsafeClient) recvGetMap() (value map[string]string, err error) { - var __result GetEntityGetMapResult - err = p.CC.RecvMsg("getMap", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -func (p *GetEntityThreadsafeClient) GetSet() (_r []string, err error) { - p.Mu.Lock() - defer p.Mu.Unlock() - var args GetEntityGetSetArgs - err = p.CC.SendMsg("getSet", &args, thrift.CALL) - if err != nil { return } - return p.recvGetSet() -} - - -func (p *GetEntityThreadsafeClient) recvGetSet() (value []string, err error) { - var __result GetEntityGetSetResult - err = p.CC.RecvMsg("getSet", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -func (p *GetEntityThreadsafeClient) GetList() (_r []string, err error) { - p.Mu.Lock() - defer p.Mu.Unlock() - var args GetEntityGetListArgs - err = p.CC.SendMsg("getList", &args, thrift.CALL) - if err != nil { return } - return p.recvGetList() -} - - -func (p *GetEntityThreadsafeClient) recvGetList() (value []string, err error) { - var __result GetEntityGetListResult - err = p.CC.RecvMsg("getList", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -// Parameters: -// - NumPos -// - NumNeg1 -// - NumNeg2 -func (p *GetEntityThreadsafeClient) GetLegacyStuff(numPos int64, numNeg1 int64, numNeg2 int64) (_r int32, err error) { - p.Mu.Lock() - defer p.Mu.Unlock() - args := GetEntityGetLegacyStuffArgs{ - NumPos : numPos, - NumNeg1 : numNeg1, - NumNeg2 : numNeg2, - } - err = p.CC.SendMsg("getLegacyStuff", &args, thrift.CALL) - if err != nil { return } - return p.recvGetLegacyStuff() -} - - -func (p *GetEntityThreadsafeClient) recvGetLegacyStuff() (value int32, err error) { - var __result GetEntityGetLegacyStuffResult - err = p.CC.RecvMsg("getLegacyStuff", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -// Parameters: -// - Ctx -func (p *GetEntityThreadsafeClient) GetCtxCollision(ctx int64) (_r int32, err error) { - p.Mu.Lock() - defer p.Mu.Unlock() - args := GetEntityGetCtxCollisionArgs{ - Ctx : ctx, - } - err = p.CC.SendMsg("getCtxCollision", &args, thrift.CALL) - if err != nil { return } - return p.recvGetCtxCollision() -} - - -func (p *GetEntityThreadsafeClient) recvGetCtxCollision() (value int32, err error) { - var __result GetEntityGetCtxCollisionResult - err = p.CC.RecvMsg("getCtxCollision", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -// Parameters: -// - Ctx -// - Ctx1 -func (p *GetEntityThreadsafeClient) GetCtx1Collision(ctx int64, ctx1 int64) (_r int32, err error) { - p.Mu.Lock() - defer p.Mu.Unlock() - args := GetEntityGetCtx1CollisionArgs{ - Ctx : ctx, - Ctx1 : ctx1, - } - err = p.CC.SendMsg("getCtx1Collision", &args, thrift.CALL) - if err != nil { return } - return p.recvGetCtx1Collision() -} - - -func (p *GetEntityThreadsafeClient) recvGetCtx1Collision() (value int32, err error) { - var __result GetEntityGetCtx1CollisionResult - err = p.CC.RecvMsg("getCtx1Collision", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - - -type GetEntityChannelClient struct { - RequestChannel thrift.RequestChannel -} - -func (c *GetEntityChannelClient) Close() error { - return c.RequestChannel.Close() -} - -func (c *GetEntityChannelClient) IsOpen() bool { - return c.RequestChannel.IsOpen() -} - -func (c *GetEntityChannelClient) Open() error { - return c.RequestChannel.Open() -} - -func NewGetEntityChannelClient(channel thrift.RequestChannel) *GetEntityChannelClient { - return &GetEntityChannelClient{RequestChannel: channel} -} - -// Parameters: -// - R -func (p *GetEntityChannelClient) GetEntity(ctx context.Context, r *GetEntityRequest) (_r *GetEntityResponse, err error) { - args := GetEntityGetEntityArgs{ - R : r, - } - var __result GetEntityGetEntityResult - err = p.RequestChannel.Call(ctx, "getEntity", &args, &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -func (p *GetEntityChannelClient) GetBool(ctx context.Context) (_r bool, err error) { - args := GetEntityGetBoolArgs{ - } - var __result GetEntityGetBoolResult - err = p.RequestChannel.Call(ctx, "getBool", &args, &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -func (p *GetEntityChannelClient) GetByte(ctx context.Context) (_r int8, err error) { - args := GetEntityGetByteArgs{ - } - var __result GetEntityGetByteResult - err = p.RequestChannel.Call(ctx, "getByte", &args, &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -func (p *GetEntityChannelClient) GetI16(ctx context.Context) (_r int16, err error) { - args := GetEntityGetI16Args{ - } - var __result GetEntityGetI16Result - err = p.RequestChannel.Call(ctx, "getI16", &args, &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -func (p *GetEntityChannelClient) GetI32(ctx context.Context) (_r int32, err error) { - args := GetEntityGetI32Args{ - } - var __result GetEntityGetI32Result - err = p.RequestChannel.Call(ctx, "getI32", &args, &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -func (p *GetEntityChannelClient) GetI64(ctx context.Context) (_r int64, err error) { - args := GetEntityGetI64Args{ - } - var __result GetEntityGetI64Result - err = p.RequestChannel.Call(ctx, "getI64", &args, &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -func (p *GetEntityChannelClient) GetDouble(ctx context.Context) (_r float64, err error) { - args := GetEntityGetDoubleArgs{ - } - var __result GetEntityGetDoubleResult - err = p.RequestChannel.Call(ctx, "getDouble", &args, &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -func (p *GetEntityChannelClient) GetString(ctx context.Context) (_r string, err error) { - args := GetEntityGetStringArgs{ - } - var __result GetEntityGetStringResult - err = p.RequestChannel.Call(ctx, "getString", &args, &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -func (p *GetEntityChannelClient) GetBinary(ctx context.Context) (_r []byte, err error) { - args := GetEntityGetBinaryArgs{ - } - var __result GetEntityGetBinaryResult - err = p.RequestChannel.Call(ctx, "getBinary", &args, &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -func (p *GetEntityChannelClient) GetMap(ctx context.Context) (_r map[string]string, err error) { - args := GetEntityGetMapArgs{ - } - var __result GetEntityGetMapResult - err = p.RequestChannel.Call(ctx, "getMap", &args, &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -func (p *GetEntityChannelClient) GetSet(ctx context.Context) (_r []string, err error) { - args := GetEntityGetSetArgs{ - } - var __result GetEntityGetSetResult - err = p.RequestChannel.Call(ctx, "getSet", &args, &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -func (p *GetEntityChannelClient) GetList(ctx context.Context) (_r []string, err error) { - args := GetEntityGetListArgs{ - } - var __result GetEntityGetListResult - err = p.RequestChannel.Call(ctx, "getList", &args, &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -// Parameters: -// - NumPos -// - NumNeg1 -// - NumNeg2 -func (p *GetEntityChannelClient) GetLegacyStuff(ctx context.Context, numPos int64, numNeg1 int64, numNeg2 int64) (_r int32, err error) { - args := GetEntityGetLegacyStuffArgs{ - NumPos : numPos, - NumNeg1 : numNeg1, - NumNeg2 : numNeg2, - } - var __result GetEntityGetLegacyStuffResult - err = p.RequestChannel.Call(ctx, "getLegacyStuff", &args, &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -// Parameters: -// - Ctx -func (p *GetEntityChannelClient) GetCtxCollision(ctx context.Context, ctx int64) (_r int32, err error) { - args := GetEntityGetCtxCollisionArgs{ - Ctx : ctx, - } - var __result GetEntityGetCtxCollisionResult - err = p.RequestChannel.Call(ctx, "getCtxCollision", &args, &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -// Parameters: -// - Ctx -// - Ctx1 -func (p *GetEntityChannelClient) GetCtx1Collision(ctx context.Context, ctx int64, ctx1 int64) (_r int32, err error) { - args := GetEntityGetCtx1CollisionArgs{ - Ctx : ctx, - Ctx1 : ctx1, - } - var __result GetEntityGetCtx1CollisionResult - err = p.RequestChannel.Call(ctx, "getCtx1Collision", &args, &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - - -type GetEntityProcessor struct { - processorMap map[string]thrift.ProcessorFunction - functionServiceMap map[string]string - handler GetEntity -} - -func (p *GetEntityProcessor) AddToProcessorMap(key string, processor thrift.ProcessorFunction) { - p.processorMap[key] = processor -} - -func (p *GetEntityProcessor) AddToFunctionServiceMap(key, service string) { - p.functionServiceMap[key] = service -} - -func (p *GetEntityProcessor) GetProcessorFunction(key string) (processor thrift.ProcessorFunction, err error) { - if processor, ok := p.processorMap[key]; ok { - return processor, nil - } - return nil, nil // generic error message will be sent -} - -func (p *GetEntityProcessor) ProcessorMap() map[string]thrift.ProcessorFunction { - return p.processorMap -} - -func (p *GetEntityProcessor) FunctionServiceMap() map[string]string { - return p.functionServiceMap -} - -func NewGetEntityProcessor(handler GetEntity) *GetEntityProcessor { - self3 := &GetEntityProcessor{handler:handler, processorMap:make(map[string]thrift.ProcessorFunction), functionServiceMap:make(map[string]string)} - self3.processorMap["getEntity"] = &getEntityProcessorGetEntity{handler:handler} - self3.processorMap["getBool"] = &getEntityProcessorGetBool{handler:handler} - self3.processorMap["getByte"] = &getEntityProcessorGetByte{handler:handler} - self3.processorMap["getI16"] = &getEntityProcessorGetI16{handler:handler} - self3.processorMap["getI32"] = &getEntityProcessorGetI32{handler:handler} - self3.processorMap["getI64"] = &getEntityProcessorGetI64{handler:handler} - self3.processorMap["getDouble"] = &getEntityProcessorGetDouble{handler:handler} - self3.processorMap["getString"] = &getEntityProcessorGetString{handler:handler} - self3.processorMap["getBinary"] = &getEntityProcessorGetBinary{handler:handler} - self3.processorMap["getMap"] = &getEntityProcessorGetMap{handler:handler} - self3.processorMap["getSet"] = &getEntityProcessorGetSet{handler:handler} - self3.processorMap["getList"] = &getEntityProcessorGetList{handler:handler} - self3.processorMap["getLegacyStuff"] = &getEntityProcessorGetLegacyStuff{handler:handler} - self3.processorMap["getCtxCollision"] = &getEntityProcessorGetCtxCollision{handler:handler} - self3.processorMap["getCtx1Collision"] = &getEntityProcessorGetCtx1Collision{handler:handler} - self3.functionServiceMap["getEntity"] = "GetEntity" - self3.functionServiceMap["getBool"] = "GetEntity" - self3.functionServiceMap["getByte"] = "GetEntity" - self3.functionServiceMap["getI16"] = "GetEntity" - self3.functionServiceMap["getI32"] = "GetEntity" - self3.functionServiceMap["getI64"] = "GetEntity" - self3.functionServiceMap["getDouble"] = "GetEntity" - self3.functionServiceMap["getString"] = "GetEntity" - self3.functionServiceMap["getBinary"] = "GetEntity" - self3.functionServiceMap["getMap"] = "GetEntity" - self3.functionServiceMap["getSet"] = "GetEntity" - self3.functionServiceMap["getList"] = "GetEntity" - self3.functionServiceMap["getLegacyStuff"] = "GetEntity" - self3.functionServiceMap["getCtxCollision"] = "GetEntity" - self3.functionServiceMap["getCtx1Collision"] = "GetEntity" - return self3 -} - -type getEntityProcessorGetEntity struct { - handler GetEntity -} - -func (p *GetEntityGetEntityResult) Exception() thrift.WritableException { - if p == nil { return nil } - return nil -} - -func (p *getEntityProcessorGetEntity) Read(iprot thrift.Protocol) (thrift.Struct, thrift.Exception) { - args := GetEntityGetEntityArgs{} - if err := args.Read(iprot); err != nil { - return nil, err - } - iprot.ReadMessageEnd() - return &args, nil -} - -func (p *getEntityProcessorGetEntity) Write(seqId int32, result thrift.WritableStruct, oprot thrift.Protocol) (err thrift.Exception) { - var err2 error - messageType := thrift.REPLY - switch result.(type) { - case thrift.ApplicationException: - messageType = thrift.EXCEPTION - } - if err2 = oprot.WriteMessageBegin("getEntity", messageType, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - return err -} - -func (p *getEntityProcessorGetEntity) Run(argStruct thrift.Struct) (thrift.WritableStruct, thrift.ApplicationException) { - args := argStruct.(*GetEntityGetEntityArgs) - var __result GetEntityGetEntityResult - if retval, err := p.handler.GetEntity(args.R); err != nil { - switch err.(type) { - default: - x := thrift.NewApplicationExceptionCause(thrift.INTERNAL_ERROR, "Internal error processing getEntity: " + err.Error(), err) - return x, x - } - } else { - __result.Success = retval - } - return &__result, nil -} - -type getEntityProcessorGetBool struct { - handler GetEntity -} - -func (p *GetEntityGetBoolResult) Exception() thrift.WritableException { - if p == nil { return nil } - return nil -} - -func (p *getEntityProcessorGetBool) Read(iprot thrift.Protocol) (thrift.Struct, thrift.Exception) { - args := GetEntityGetBoolArgs{} - if err := args.Read(iprot); err != nil { - return nil, err - } - iprot.ReadMessageEnd() - return &args, nil -} - -func (p *getEntityProcessorGetBool) Write(seqId int32, result thrift.WritableStruct, oprot thrift.Protocol) (err thrift.Exception) { - var err2 error - messageType := thrift.REPLY - switch result.(type) { - case thrift.ApplicationException: - messageType = thrift.EXCEPTION - } - if err2 = oprot.WriteMessageBegin("getBool", messageType, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - return err -} - -func (p *getEntityProcessorGetBool) Run(argStruct thrift.Struct) (thrift.WritableStruct, thrift.ApplicationException) { - var __result GetEntityGetBoolResult - if retval, err := p.handler.GetBool(); err != nil { - switch err.(type) { - default: - x := thrift.NewApplicationExceptionCause(thrift.INTERNAL_ERROR, "Internal error processing getBool: " + err.Error(), err) - return x, x - } - } else { - __result.Success = &retval - } - return &__result, nil -} - -type getEntityProcessorGetByte struct { - handler GetEntity -} - -func (p *GetEntityGetByteResult) Exception() thrift.WritableException { - if p == nil { return nil } - return nil -} - -func (p *getEntityProcessorGetByte) Read(iprot thrift.Protocol) (thrift.Struct, thrift.Exception) { - args := GetEntityGetByteArgs{} - if err := args.Read(iprot); err != nil { - return nil, err - } - iprot.ReadMessageEnd() - return &args, nil -} - -func (p *getEntityProcessorGetByte) Write(seqId int32, result thrift.WritableStruct, oprot thrift.Protocol) (err thrift.Exception) { - var err2 error - messageType := thrift.REPLY - switch result.(type) { - case thrift.ApplicationException: - messageType = thrift.EXCEPTION - } - if err2 = oprot.WriteMessageBegin("getByte", messageType, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - return err -} - -func (p *getEntityProcessorGetByte) Run(argStruct thrift.Struct) (thrift.WritableStruct, thrift.ApplicationException) { - var __result GetEntityGetByteResult - if retval, err := p.handler.GetByte(); err != nil { - switch err.(type) { - default: - x := thrift.NewApplicationExceptionCause(thrift.INTERNAL_ERROR, "Internal error processing getByte: " + err.Error(), err) - return x, x - } - } else { - __result.Success = &retval - } - return &__result, nil -} - -type getEntityProcessorGetI16 struct { - handler GetEntity -} - -func (p *GetEntityGetI16Result) Exception() thrift.WritableException { - if p == nil { return nil } - return nil -} - -func (p *getEntityProcessorGetI16) Read(iprot thrift.Protocol) (thrift.Struct, thrift.Exception) { - args := GetEntityGetI16Args{} - if err := args.Read(iprot); err != nil { - return nil, err - } - iprot.ReadMessageEnd() - return &args, nil -} - -func (p *getEntityProcessorGetI16) Write(seqId int32, result thrift.WritableStruct, oprot thrift.Protocol) (err thrift.Exception) { - var err2 error - messageType := thrift.REPLY - switch result.(type) { - case thrift.ApplicationException: - messageType = thrift.EXCEPTION - } - if err2 = oprot.WriteMessageBegin("getI16", messageType, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - return err -} - -func (p *getEntityProcessorGetI16) Run(argStruct thrift.Struct) (thrift.WritableStruct, thrift.ApplicationException) { - var __result GetEntityGetI16Result - if retval, err := p.handler.GetI16(); err != nil { - switch err.(type) { - default: - x := thrift.NewApplicationExceptionCause(thrift.INTERNAL_ERROR, "Internal error processing getI16: " + err.Error(), err) - return x, x - } - } else { - __result.Success = &retval - } - return &__result, nil -} - -type getEntityProcessorGetI32 struct { - handler GetEntity -} - -func (p *GetEntityGetI32Result) Exception() thrift.WritableException { - if p == nil { return nil } - return nil -} - -func (p *getEntityProcessorGetI32) Read(iprot thrift.Protocol) (thrift.Struct, thrift.Exception) { - args := GetEntityGetI32Args{} - if err := args.Read(iprot); err != nil { - return nil, err - } - iprot.ReadMessageEnd() - return &args, nil -} - -func (p *getEntityProcessorGetI32) Write(seqId int32, result thrift.WritableStruct, oprot thrift.Protocol) (err thrift.Exception) { - var err2 error - messageType := thrift.REPLY - switch result.(type) { - case thrift.ApplicationException: - messageType = thrift.EXCEPTION - } - if err2 = oprot.WriteMessageBegin("getI32", messageType, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - return err -} - -func (p *getEntityProcessorGetI32) Run(argStruct thrift.Struct) (thrift.WritableStruct, thrift.ApplicationException) { - var __result GetEntityGetI32Result - if retval, err := p.handler.GetI32(); err != nil { - switch err.(type) { - default: - x := thrift.NewApplicationExceptionCause(thrift.INTERNAL_ERROR, "Internal error processing getI32: " + err.Error(), err) - return x, x - } - } else { - __result.Success = &retval - } - return &__result, nil -} - -type getEntityProcessorGetI64 struct { - handler GetEntity -} - -func (p *GetEntityGetI64Result) Exception() thrift.WritableException { - if p == nil { return nil } - return nil -} - -func (p *getEntityProcessorGetI64) Read(iprot thrift.Protocol) (thrift.Struct, thrift.Exception) { - args := GetEntityGetI64Args{} - if err := args.Read(iprot); err != nil { - return nil, err - } - iprot.ReadMessageEnd() - return &args, nil -} - -func (p *getEntityProcessorGetI64) Write(seqId int32, result thrift.WritableStruct, oprot thrift.Protocol) (err thrift.Exception) { - var err2 error - messageType := thrift.REPLY - switch result.(type) { - case thrift.ApplicationException: - messageType = thrift.EXCEPTION - } - if err2 = oprot.WriteMessageBegin("getI64", messageType, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - return err -} - -func (p *getEntityProcessorGetI64) Run(argStruct thrift.Struct) (thrift.WritableStruct, thrift.ApplicationException) { - var __result GetEntityGetI64Result - if retval, err := p.handler.GetI64(); err != nil { - switch err.(type) { - default: - x := thrift.NewApplicationExceptionCause(thrift.INTERNAL_ERROR, "Internal error processing getI64: " + err.Error(), err) - return x, x - } - } else { - __result.Success = &retval - } - return &__result, nil -} - -type getEntityProcessorGetDouble struct { - handler GetEntity -} - -func (p *GetEntityGetDoubleResult) Exception() thrift.WritableException { - if p == nil { return nil } - return nil -} - -func (p *getEntityProcessorGetDouble) Read(iprot thrift.Protocol) (thrift.Struct, thrift.Exception) { - args := GetEntityGetDoubleArgs{} - if err := args.Read(iprot); err != nil { - return nil, err - } - iprot.ReadMessageEnd() - return &args, nil -} - -func (p *getEntityProcessorGetDouble) Write(seqId int32, result thrift.WritableStruct, oprot thrift.Protocol) (err thrift.Exception) { - var err2 error - messageType := thrift.REPLY - switch result.(type) { - case thrift.ApplicationException: - messageType = thrift.EXCEPTION - } - if err2 = oprot.WriteMessageBegin("getDouble", messageType, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - return err -} - -func (p *getEntityProcessorGetDouble) Run(argStruct thrift.Struct) (thrift.WritableStruct, thrift.ApplicationException) { - var __result GetEntityGetDoubleResult - if retval, err := p.handler.GetDouble(); err != nil { - switch err.(type) { - default: - x := thrift.NewApplicationExceptionCause(thrift.INTERNAL_ERROR, "Internal error processing getDouble: " + err.Error(), err) - return x, x - } - } else { - __result.Success = &retval - } - return &__result, nil -} - -type getEntityProcessorGetString struct { - handler GetEntity -} - -func (p *GetEntityGetStringResult) Exception() thrift.WritableException { - if p == nil { return nil } - return nil -} - -func (p *getEntityProcessorGetString) Read(iprot thrift.Protocol) (thrift.Struct, thrift.Exception) { - args := GetEntityGetStringArgs{} - if err := args.Read(iprot); err != nil { - return nil, err - } - iprot.ReadMessageEnd() - return &args, nil -} - -func (p *getEntityProcessorGetString) Write(seqId int32, result thrift.WritableStruct, oprot thrift.Protocol) (err thrift.Exception) { - var err2 error - messageType := thrift.REPLY - switch result.(type) { - case thrift.ApplicationException: - messageType = thrift.EXCEPTION - } - if err2 = oprot.WriteMessageBegin("getString", messageType, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - return err -} - -func (p *getEntityProcessorGetString) Run(argStruct thrift.Struct) (thrift.WritableStruct, thrift.ApplicationException) { - var __result GetEntityGetStringResult - if retval, err := p.handler.GetString(); err != nil { - switch err.(type) { - default: - x := thrift.NewApplicationExceptionCause(thrift.INTERNAL_ERROR, "Internal error processing getString: " + err.Error(), err) - return x, x - } - } else { - __result.Success = &retval - } - return &__result, nil -} - -type getEntityProcessorGetBinary struct { - handler GetEntity -} - -func (p *GetEntityGetBinaryResult) Exception() thrift.WritableException { - if p == nil { return nil } - return nil -} - -func (p *getEntityProcessorGetBinary) Read(iprot thrift.Protocol) (thrift.Struct, thrift.Exception) { - args := GetEntityGetBinaryArgs{} - if err := args.Read(iprot); err != nil { - return nil, err - } - iprot.ReadMessageEnd() - return &args, nil -} - -func (p *getEntityProcessorGetBinary) Write(seqId int32, result thrift.WritableStruct, oprot thrift.Protocol) (err thrift.Exception) { - var err2 error - messageType := thrift.REPLY - switch result.(type) { - case thrift.ApplicationException: - messageType = thrift.EXCEPTION - } - if err2 = oprot.WriteMessageBegin("getBinary", messageType, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - return err -} - -func (p *getEntityProcessorGetBinary) Run(argStruct thrift.Struct) (thrift.WritableStruct, thrift.ApplicationException) { - var __result GetEntityGetBinaryResult - if retval, err := p.handler.GetBinary(); err != nil { - switch err.(type) { - default: - x := thrift.NewApplicationExceptionCause(thrift.INTERNAL_ERROR, "Internal error processing getBinary: " + err.Error(), err) - return x, x - } - } else { - __result.Success = retval - } - return &__result, nil -} - -type getEntityProcessorGetMap struct { - handler GetEntity -} - -func (p *GetEntityGetMapResult) Exception() thrift.WritableException { - if p == nil { return nil } - return nil -} - -func (p *getEntityProcessorGetMap) Read(iprot thrift.Protocol) (thrift.Struct, thrift.Exception) { - args := GetEntityGetMapArgs{} - if err := args.Read(iprot); err != nil { - return nil, err - } - iprot.ReadMessageEnd() - return &args, nil -} - -func (p *getEntityProcessorGetMap) Write(seqId int32, result thrift.WritableStruct, oprot thrift.Protocol) (err thrift.Exception) { - var err2 error - messageType := thrift.REPLY - switch result.(type) { - case thrift.ApplicationException: - messageType = thrift.EXCEPTION - } - if err2 = oprot.WriteMessageBegin("getMap", messageType, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - return err -} - -func (p *getEntityProcessorGetMap) Run(argStruct thrift.Struct) (thrift.WritableStruct, thrift.ApplicationException) { - var __result GetEntityGetMapResult - if retval, err := p.handler.GetMap(); err != nil { - switch err.(type) { - default: - x := thrift.NewApplicationExceptionCause(thrift.INTERNAL_ERROR, "Internal error processing getMap: " + err.Error(), err) - return x, x - } - } else { - __result.Success = retval - } - return &__result, nil -} - -type getEntityProcessorGetSet struct { - handler GetEntity -} - -func (p *GetEntityGetSetResult) Exception() thrift.WritableException { - if p == nil { return nil } - return nil -} - -func (p *getEntityProcessorGetSet) Read(iprot thrift.Protocol) (thrift.Struct, thrift.Exception) { - args := GetEntityGetSetArgs{} - if err := args.Read(iprot); err != nil { - return nil, err - } - iprot.ReadMessageEnd() - return &args, nil -} - -func (p *getEntityProcessorGetSet) Write(seqId int32, result thrift.WritableStruct, oprot thrift.Protocol) (err thrift.Exception) { - var err2 error - messageType := thrift.REPLY - switch result.(type) { - case thrift.ApplicationException: - messageType = thrift.EXCEPTION - } - if err2 = oprot.WriteMessageBegin("getSet", messageType, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - return err -} - -func (p *getEntityProcessorGetSet) Run(argStruct thrift.Struct) (thrift.WritableStruct, thrift.ApplicationException) { - var __result GetEntityGetSetResult - if retval, err := p.handler.GetSet(); err != nil { - switch err.(type) { - default: - x := thrift.NewApplicationExceptionCause(thrift.INTERNAL_ERROR, "Internal error processing getSet: " + err.Error(), err) - return x, x - } - } else { - __result.Success = retval - } - return &__result, nil -} - -type getEntityProcessorGetList struct { - handler GetEntity -} - -func (p *GetEntityGetListResult) Exception() thrift.WritableException { - if p == nil { return nil } - return nil -} - -func (p *getEntityProcessorGetList) Read(iprot thrift.Protocol) (thrift.Struct, thrift.Exception) { - args := GetEntityGetListArgs{} - if err := args.Read(iprot); err != nil { - return nil, err - } - iprot.ReadMessageEnd() - return &args, nil -} - -func (p *getEntityProcessorGetList) Write(seqId int32, result thrift.WritableStruct, oprot thrift.Protocol) (err thrift.Exception) { - var err2 error - messageType := thrift.REPLY - switch result.(type) { - case thrift.ApplicationException: - messageType = thrift.EXCEPTION - } - if err2 = oprot.WriteMessageBegin("getList", messageType, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - return err -} - -func (p *getEntityProcessorGetList) Run(argStruct thrift.Struct) (thrift.WritableStruct, thrift.ApplicationException) { - var __result GetEntityGetListResult - if retval, err := p.handler.GetList(); err != nil { - switch err.(type) { - default: - x := thrift.NewApplicationExceptionCause(thrift.INTERNAL_ERROR, "Internal error processing getList: " + err.Error(), err) - return x, x - } - } else { - __result.Success = retval - } - return &__result, nil -} - -type getEntityProcessorGetLegacyStuff struct { - handler GetEntity -} - -func (p *GetEntityGetLegacyStuffResult) Exception() thrift.WritableException { - if p == nil { return nil } - return nil -} - -func (p *getEntityProcessorGetLegacyStuff) Read(iprot thrift.Protocol) (thrift.Struct, thrift.Exception) { - args := GetEntityGetLegacyStuffArgs{} - if err := args.Read(iprot); err != nil { - return nil, err - } - iprot.ReadMessageEnd() - return &args, nil -} - -func (p *getEntityProcessorGetLegacyStuff) Write(seqId int32, result thrift.WritableStruct, oprot thrift.Protocol) (err thrift.Exception) { - var err2 error - messageType := thrift.REPLY - switch result.(type) { - case thrift.ApplicationException: - messageType = thrift.EXCEPTION - } - if err2 = oprot.WriteMessageBegin("getLegacyStuff", messageType, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - return err -} - -func (p *getEntityProcessorGetLegacyStuff) Run(argStruct thrift.Struct) (thrift.WritableStruct, thrift.ApplicationException) { - args := argStruct.(*GetEntityGetLegacyStuffArgs) - var __result GetEntityGetLegacyStuffResult - if retval, err := p.handler.GetLegacyStuff(args.NumPos, args.NumNeg1, args.NumNeg2); err != nil { - switch err.(type) { - default: - x := thrift.NewApplicationExceptionCause(thrift.INTERNAL_ERROR, "Internal error processing getLegacyStuff: " + err.Error(), err) - return x, x - } - } else { - __result.Success = &retval - } - return &__result, nil -} - -type getEntityProcessorGetCtxCollision struct { - handler GetEntity -} - -func (p *GetEntityGetCtxCollisionResult) Exception() thrift.WritableException { - if p == nil { return nil } - return nil -} - -func (p *getEntityProcessorGetCtxCollision) Read(iprot thrift.Protocol) (thrift.Struct, thrift.Exception) { - args := GetEntityGetCtxCollisionArgs{} - if err := args.Read(iprot); err != nil { - return nil, err - } - iprot.ReadMessageEnd() - return &args, nil -} - -func (p *getEntityProcessorGetCtxCollision) Write(seqId int32, result thrift.WritableStruct, oprot thrift.Protocol) (err thrift.Exception) { - var err2 error - messageType := thrift.REPLY - switch result.(type) { - case thrift.ApplicationException: - messageType = thrift.EXCEPTION - } - if err2 = oprot.WriteMessageBegin("getCtxCollision", messageType, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - return err -} - -func (p *getEntityProcessorGetCtxCollision) Run(argStruct thrift.Struct) (thrift.WritableStruct, thrift.ApplicationException) { - args := argStruct.(*GetEntityGetCtxCollisionArgs) - var __result GetEntityGetCtxCollisionResult - if retval, err := p.handler.GetCtxCollision(args.Ctx); err != nil { - switch err.(type) { - default: - x := thrift.NewApplicationExceptionCause(thrift.INTERNAL_ERROR, "Internal error processing getCtxCollision: " + err.Error(), err) - return x, x - } - } else { - __result.Success = &retval - } - return &__result, nil -} - -type getEntityProcessorGetCtx1Collision struct { - handler GetEntity -} - -func (p *GetEntityGetCtx1CollisionResult) Exception() thrift.WritableException { - if p == nil { return nil } - return nil -} - -func (p *getEntityProcessorGetCtx1Collision) Read(iprot thrift.Protocol) (thrift.Struct, thrift.Exception) { - args := GetEntityGetCtx1CollisionArgs{} - if err := args.Read(iprot); err != nil { - return nil, err - } - iprot.ReadMessageEnd() - return &args, nil -} - -func (p *getEntityProcessorGetCtx1Collision) Write(seqId int32, result thrift.WritableStruct, oprot thrift.Protocol) (err thrift.Exception) { - var err2 error - messageType := thrift.REPLY - switch result.(type) { - case thrift.ApplicationException: - messageType = thrift.EXCEPTION - } - if err2 = oprot.WriteMessageBegin("getCtx1Collision", messageType, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - return err -} - -func (p *getEntityProcessorGetCtx1Collision) Run(argStruct thrift.Struct) (thrift.WritableStruct, thrift.ApplicationException) { - args := argStruct.(*GetEntityGetCtx1CollisionArgs) - var __result GetEntityGetCtx1CollisionResult - if retval, err := p.handler.GetCtx1Collision(args.Ctx, args.Ctx1); err != nil { - switch err.(type) { - default: - x := thrift.NewApplicationExceptionCause(thrift.INTERNAL_ERROR, "Internal error processing getCtx1Collision: " + err.Error(), err) - return x, x - } - } else { - __result.Success = &retval - } - return &__result, nil -} - - -// HELPER FUNCTIONS AND STRUCTURES - -// Attributes: -// - R -type GetEntityGetEntityArgs struct { - thrift.IRequest - R *GetEntityRequest `thrift:"r,1" db:"r" json:"r"` -} - -func NewGetEntityGetEntityArgs() *GetEntityGetEntityArgs { - return &GetEntityGetEntityArgs{ - R: NewGetEntityRequest(), - } -} - -var GetEntityGetEntityArgs_R_DEFAULT *GetEntityRequest -func (p *GetEntityGetEntityArgs) GetR() *GetEntityRequest { - if !p.IsSetR() { - return GetEntityGetEntityArgs_R_DEFAULT - } - return p.R -} -func (p *GetEntityGetEntityArgs) DefaultGetR() *GetEntityRequest { - if !p.IsSetR() { - return NewGetEntityRequest() - } - return p.R -} -func (p *GetEntityGetEntityArgs) IsSetR() bool { - return p != nil && p.R != nil -} - -type GetEntityGetEntityArgsBuilder struct { - obj *GetEntityGetEntityArgs -} - -func NewGetEntityGetEntityArgsBuilder() *GetEntityGetEntityArgsBuilder{ - return &GetEntityGetEntityArgsBuilder{ - obj: NewGetEntityGetEntityArgs(), - } -} - -func (p GetEntityGetEntityArgsBuilder) Emit() *GetEntityGetEntityArgs{ - return &GetEntityGetEntityArgs{ - R: p.obj.R, - } -} - -func (g *GetEntityGetEntityArgsBuilder) R(r *GetEntityRequest) *GetEntityGetEntityArgsBuilder { - g.obj.R = r - return g -} - -func (g *GetEntityGetEntityArgs) SetR(r *GetEntityRequest) *GetEntityGetEntityArgs { - g.R = r - return g -} - -func (p *GetEntityGetEntityArgs) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *GetEntityGetEntityArgs) ReadField1(iprot thrift.Protocol) error { - p.R = NewGetEntityRequest() - if err := p.R.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.R), err) - } - return nil -} - -func (p *GetEntityGetEntityArgs) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("getEntity_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *GetEntityGetEntityArgs) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("r", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:r: ", p), err) } - if err := p.R.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.R), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:r: ", p), err) } - return err -} - -func (p *GetEntityGetEntityArgs) String() string { - if p == nil { - return "" - } - - var rVal string - if p.R == nil { - rVal = "" - } else { - rVal = fmt.Sprintf("%v", p.R) - } - return fmt.Sprintf("GetEntityGetEntityArgs({R:%s})", rVal) -} - -// Attributes: -// - Success -type GetEntityGetEntityResult struct { - thrift.IResponse - Success *GetEntityResponse `thrift:"success,0,optional" db:"success" json:"success,omitempty"` -} - -func NewGetEntityGetEntityResult() *GetEntityGetEntityResult { - return &GetEntityGetEntityResult{} -} - -var GetEntityGetEntityResult_Success_DEFAULT *GetEntityResponse -func (p *GetEntityGetEntityResult) GetSuccess() *GetEntityResponse { - if !p.IsSetSuccess() { - return GetEntityGetEntityResult_Success_DEFAULT - } - return p.Success -} -func (p *GetEntityGetEntityResult) DefaultGetSuccess() *GetEntityResponse { - if !p.IsSetSuccess() { - return NewGetEntityResponse() - } - return p.Success -} -func (p *GetEntityGetEntityResult) IsSetSuccess() bool { - return p != nil && p.Success != nil -} - -type GetEntityGetEntityResultBuilder struct { - obj *GetEntityGetEntityResult -} - -func NewGetEntityGetEntityResultBuilder() *GetEntityGetEntityResultBuilder{ - return &GetEntityGetEntityResultBuilder{ - obj: NewGetEntityGetEntityResult(), - } -} - -func (p GetEntityGetEntityResultBuilder) Emit() *GetEntityGetEntityResult{ - return &GetEntityGetEntityResult{ - Success: p.obj.Success, - } -} - -func (g *GetEntityGetEntityResultBuilder) Success(success *GetEntityResponse) *GetEntityGetEntityResultBuilder { - g.obj.Success = success - return g -} - -func (g *GetEntityGetEntityResult) SetSuccess(success *GetEntityResponse) *GetEntityGetEntityResult { - g.Success = success - return g -} - -func (p *GetEntityGetEntityResult) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 0: - if err := p.ReadField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *GetEntityGetEntityResult) ReadField0(iprot thrift.Protocol) error { - p.Success = NewGetEntityResponse() - if err := p.Success.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) - } - return nil -} - -func (p *GetEntityGetEntityResult) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("getEntity_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField0(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *GetEntityGetEntityResult) writeField0(oprot thrift.Protocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := p.Success.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } - } - return err -} - -func (p *GetEntityGetEntityResult) String() string { - if p == nil { - return "" - } - - var successVal string - if p.Success == nil { - successVal = "" - } else { - successVal = fmt.Sprintf("%v", p.Success) - } - return fmt.Sprintf("GetEntityGetEntityResult({Success:%s})", successVal) -} - -type GetEntityGetBoolArgs struct { - thrift.IRequest -} - -func NewGetEntityGetBoolArgs() *GetEntityGetBoolArgs { - return &GetEntityGetBoolArgs{} -} - -type GetEntityGetBoolArgsBuilder struct { - obj *GetEntityGetBoolArgs -} - -func NewGetEntityGetBoolArgsBuilder() *GetEntityGetBoolArgsBuilder{ - return &GetEntityGetBoolArgsBuilder{ - obj: NewGetEntityGetBoolArgs(), - } -} - -func (p GetEntityGetBoolArgsBuilder) Emit() *GetEntityGetBoolArgs{ - return &GetEntityGetBoolArgs{ - } -} - -func (p *GetEntityGetBoolArgs) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *GetEntityGetBoolArgs) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("getBool_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *GetEntityGetBoolArgs) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("GetEntityGetBoolArgs({})") -} - -// Attributes: -// - Success -type GetEntityGetBoolResult struct { - thrift.IResponse - Success *bool `thrift:"success,0,optional" db:"success" json:"success,omitempty"` -} - -func NewGetEntityGetBoolResult() *GetEntityGetBoolResult { - return &GetEntityGetBoolResult{} -} - -var GetEntityGetBoolResult_Success_DEFAULT bool -func (p *GetEntityGetBoolResult) GetSuccess() bool { - if !p.IsSetSuccess() { - return GetEntityGetBoolResult_Success_DEFAULT - } - return *p.Success -} -func (p *GetEntityGetBoolResult) IsSetSuccess() bool { - return p != nil && p.Success != nil -} - -type GetEntityGetBoolResultBuilder struct { - obj *GetEntityGetBoolResult -} - -func NewGetEntityGetBoolResultBuilder() *GetEntityGetBoolResultBuilder{ - return &GetEntityGetBoolResultBuilder{ - obj: NewGetEntityGetBoolResult(), - } -} - -func (p GetEntityGetBoolResultBuilder) Emit() *GetEntityGetBoolResult{ - return &GetEntityGetBoolResult{ - Success: p.obj.Success, - } -} - -func (g *GetEntityGetBoolResultBuilder) Success(success *bool) *GetEntityGetBoolResultBuilder { - g.obj.Success = success - return g -} - -func (g *GetEntityGetBoolResult) SetSuccess(success *bool) *GetEntityGetBoolResult { - g.Success = success - return g -} - -func (p *GetEntityGetBoolResult) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 0: - if err := p.ReadField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *GetEntityGetBoolResult) ReadField0(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - p.Success = &v - } - return nil -} - -func (p *GetEntityGetBoolResult) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("getBool_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField0(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *GetEntityGetBoolResult) writeField0(oprot thrift.Protocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.BOOL, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := oprot.WriteBool(bool(*p.Success)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.success (0) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } - } - return err -} - -func (p *GetEntityGetBoolResult) String() string { - if p == nil { - return "" - } - - var successVal string - if p.Success == nil { - successVal = "" - } else { - successVal = fmt.Sprintf("%v", *p.Success) - } - return fmt.Sprintf("GetEntityGetBoolResult({Success:%s})", successVal) -} - -type GetEntityGetByteArgs struct { - thrift.IRequest -} - -func NewGetEntityGetByteArgs() *GetEntityGetByteArgs { - return &GetEntityGetByteArgs{} -} - -type GetEntityGetByteArgsBuilder struct { - obj *GetEntityGetByteArgs -} - -func NewGetEntityGetByteArgsBuilder() *GetEntityGetByteArgsBuilder{ - return &GetEntityGetByteArgsBuilder{ - obj: NewGetEntityGetByteArgs(), - } -} - -func (p GetEntityGetByteArgsBuilder) Emit() *GetEntityGetByteArgs{ - return &GetEntityGetByteArgs{ - } -} - -func (p *GetEntityGetByteArgs) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *GetEntityGetByteArgs) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("getByte_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *GetEntityGetByteArgs) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("GetEntityGetByteArgs({})") -} - -// Attributes: -// - Success -type GetEntityGetByteResult struct { - thrift.IResponse - Success *int8 `thrift:"success,0,optional" db:"success" json:"success,omitempty"` -} - -func NewGetEntityGetByteResult() *GetEntityGetByteResult { - return &GetEntityGetByteResult{} -} - -var GetEntityGetByteResult_Success_DEFAULT int8 -func (p *GetEntityGetByteResult) GetSuccess() int8 { - if !p.IsSetSuccess() { - return GetEntityGetByteResult_Success_DEFAULT - } - return *p.Success -} -func (p *GetEntityGetByteResult) IsSetSuccess() bool { - return p != nil && p.Success != nil -} - -type GetEntityGetByteResultBuilder struct { - obj *GetEntityGetByteResult -} - -func NewGetEntityGetByteResultBuilder() *GetEntityGetByteResultBuilder{ - return &GetEntityGetByteResultBuilder{ - obj: NewGetEntityGetByteResult(), - } -} - -func (p GetEntityGetByteResultBuilder) Emit() *GetEntityGetByteResult{ - return &GetEntityGetByteResult{ - Success: p.obj.Success, - } -} - -func (g *GetEntityGetByteResultBuilder) Success(success *int8) *GetEntityGetByteResultBuilder { - g.obj.Success = success - return g -} - -func (g *GetEntityGetByteResult) SetSuccess(success *int8) *GetEntityGetByteResult { - g.Success = success - return g -} - -func (p *GetEntityGetByteResult) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 0: - if err := p.ReadField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *GetEntityGetByteResult) ReadField0(iprot thrift.Protocol) error { - if v, err := iprot.ReadByte(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - temp := int8(v) - p.Success = &temp - } - return nil -} - -func (p *GetEntityGetByteResult) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("getByte_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField0(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *GetEntityGetByteResult) writeField0(oprot thrift.Protocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.BYTE, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := oprot.WriteByte(byte(*p.Success)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.success (0) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } - } - return err -} - -func (p *GetEntityGetByteResult) String() string { - if p == nil { - return "" - } - - var successVal string - if p.Success == nil { - successVal = "" - } else { - successVal = fmt.Sprintf("%v", *p.Success) - } - return fmt.Sprintf("GetEntityGetByteResult({Success:%s})", successVal) -} - -type GetEntityGetI16Args struct { - thrift.IRequest -} - -func NewGetEntityGetI16Args() *GetEntityGetI16Args { - return &GetEntityGetI16Args{} -} - -type GetEntityGetI16ArgsBuilder struct { - obj *GetEntityGetI16Args -} - -func NewGetEntityGetI16ArgsBuilder() *GetEntityGetI16ArgsBuilder{ - return &GetEntityGetI16ArgsBuilder{ - obj: NewGetEntityGetI16Args(), - } -} - -func (p GetEntityGetI16ArgsBuilder) Emit() *GetEntityGetI16Args{ - return &GetEntityGetI16Args{ - } -} - -func (p *GetEntityGetI16Args) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *GetEntityGetI16Args) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("getI16_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *GetEntityGetI16Args) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("GetEntityGetI16Args({})") -} - -// Attributes: -// - Success -type GetEntityGetI16Result struct { - thrift.IResponse - Success *int16 `thrift:"success,0,optional" db:"success" json:"success,omitempty"` -} - -func NewGetEntityGetI16Result() *GetEntityGetI16Result { - return &GetEntityGetI16Result{} -} - -var GetEntityGetI16Result_Success_DEFAULT int16 -func (p *GetEntityGetI16Result) GetSuccess() int16 { - if !p.IsSetSuccess() { - return GetEntityGetI16Result_Success_DEFAULT - } - return *p.Success -} -func (p *GetEntityGetI16Result) IsSetSuccess() bool { - return p != nil && p.Success != nil -} - -type GetEntityGetI16ResultBuilder struct { - obj *GetEntityGetI16Result -} - -func NewGetEntityGetI16ResultBuilder() *GetEntityGetI16ResultBuilder{ - return &GetEntityGetI16ResultBuilder{ - obj: NewGetEntityGetI16Result(), - } -} - -func (p GetEntityGetI16ResultBuilder) Emit() *GetEntityGetI16Result{ - return &GetEntityGetI16Result{ - Success: p.obj.Success, - } -} - -func (g *GetEntityGetI16ResultBuilder) Success(success *int16) *GetEntityGetI16ResultBuilder { - g.obj.Success = success - return g -} - -func (g *GetEntityGetI16Result) SetSuccess(success *int16) *GetEntityGetI16Result { - g.Success = success - return g -} - -func (p *GetEntityGetI16Result) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 0: - if err := p.ReadField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *GetEntityGetI16Result) ReadField0(iprot thrift.Protocol) error { - if v, err := iprot.ReadI16(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - p.Success = &v - } - return nil -} - -func (p *GetEntityGetI16Result) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("getI16_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField0(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *GetEntityGetI16Result) writeField0(oprot thrift.Protocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.I16, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := oprot.WriteI16(int16(*p.Success)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.success (0) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } - } - return err -} - -func (p *GetEntityGetI16Result) String() string { - if p == nil { - return "" - } - - var successVal string - if p.Success == nil { - successVal = "" - } else { - successVal = fmt.Sprintf("%v", *p.Success) - } - return fmt.Sprintf("GetEntityGetI16Result({Success:%s})", successVal) -} - -type GetEntityGetI32Args struct { - thrift.IRequest -} - -func NewGetEntityGetI32Args() *GetEntityGetI32Args { - return &GetEntityGetI32Args{} -} - -type GetEntityGetI32ArgsBuilder struct { - obj *GetEntityGetI32Args -} - -func NewGetEntityGetI32ArgsBuilder() *GetEntityGetI32ArgsBuilder{ - return &GetEntityGetI32ArgsBuilder{ - obj: NewGetEntityGetI32Args(), - } -} - -func (p GetEntityGetI32ArgsBuilder) Emit() *GetEntityGetI32Args{ - return &GetEntityGetI32Args{ - } -} - -func (p *GetEntityGetI32Args) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *GetEntityGetI32Args) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("getI32_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *GetEntityGetI32Args) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("GetEntityGetI32Args({})") -} - -// Attributes: -// - Success -type GetEntityGetI32Result struct { - thrift.IResponse - Success *int32 `thrift:"success,0,optional" db:"success" json:"success,omitempty"` -} - -func NewGetEntityGetI32Result() *GetEntityGetI32Result { - return &GetEntityGetI32Result{} -} - -var GetEntityGetI32Result_Success_DEFAULT int32 -func (p *GetEntityGetI32Result) GetSuccess() int32 { - if !p.IsSetSuccess() { - return GetEntityGetI32Result_Success_DEFAULT - } - return *p.Success -} -func (p *GetEntityGetI32Result) IsSetSuccess() bool { - return p != nil && p.Success != nil -} - -type GetEntityGetI32ResultBuilder struct { - obj *GetEntityGetI32Result -} - -func NewGetEntityGetI32ResultBuilder() *GetEntityGetI32ResultBuilder{ - return &GetEntityGetI32ResultBuilder{ - obj: NewGetEntityGetI32Result(), - } -} - -func (p GetEntityGetI32ResultBuilder) Emit() *GetEntityGetI32Result{ - return &GetEntityGetI32Result{ - Success: p.obj.Success, - } -} - -func (g *GetEntityGetI32ResultBuilder) Success(success *int32) *GetEntityGetI32ResultBuilder { - g.obj.Success = success - return g -} - -func (g *GetEntityGetI32Result) SetSuccess(success *int32) *GetEntityGetI32Result { - g.Success = success - return g -} - -func (p *GetEntityGetI32Result) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 0: - if err := p.ReadField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *GetEntityGetI32Result) ReadField0(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - p.Success = &v - } - return nil -} - -func (p *GetEntityGetI32Result) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("getI32_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField0(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *GetEntityGetI32Result) writeField0(oprot thrift.Protocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.I32, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := oprot.WriteI32(int32(*p.Success)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.success (0) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } - } - return err -} - -func (p *GetEntityGetI32Result) String() string { - if p == nil { - return "" - } - - var successVal string - if p.Success == nil { - successVal = "" - } else { - successVal = fmt.Sprintf("%v", *p.Success) - } - return fmt.Sprintf("GetEntityGetI32Result({Success:%s})", successVal) -} - -type GetEntityGetI64Args struct { - thrift.IRequest -} - -func NewGetEntityGetI64Args() *GetEntityGetI64Args { - return &GetEntityGetI64Args{} -} - -type GetEntityGetI64ArgsBuilder struct { - obj *GetEntityGetI64Args -} - -func NewGetEntityGetI64ArgsBuilder() *GetEntityGetI64ArgsBuilder{ - return &GetEntityGetI64ArgsBuilder{ - obj: NewGetEntityGetI64Args(), - } -} - -func (p GetEntityGetI64ArgsBuilder) Emit() *GetEntityGetI64Args{ - return &GetEntityGetI64Args{ - } -} - -func (p *GetEntityGetI64Args) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *GetEntityGetI64Args) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("getI64_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *GetEntityGetI64Args) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("GetEntityGetI64Args({})") -} - -// Attributes: -// - Success -type GetEntityGetI64Result struct { - thrift.IResponse - Success *int64 `thrift:"success,0,optional" db:"success" json:"success,omitempty"` -} - -func NewGetEntityGetI64Result() *GetEntityGetI64Result { - return &GetEntityGetI64Result{} -} - -var GetEntityGetI64Result_Success_DEFAULT int64 -func (p *GetEntityGetI64Result) GetSuccess() int64 { - if !p.IsSetSuccess() { - return GetEntityGetI64Result_Success_DEFAULT - } - return *p.Success -} -func (p *GetEntityGetI64Result) IsSetSuccess() bool { - return p != nil && p.Success != nil -} - -type GetEntityGetI64ResultBuilder struct { - obj *GetEntityGetI64Result -} - -func NewGetEntityGetI64ResultBuilder() *GetEntityGetI64ResultBuilder{ - return &GetEntityGetI64ResultBuilder{ - obj: NewGetEntityGetI64Result(), - } -} - -func (p GetEntityGetI64ResultBuilder) Emit() *GetEntityGetI64Result{ - return &GetEntityGetI64Result{ - Success: p.obj.Success, - } -} - -func (g *GetEntityGetI64ResultBuilder) Success(success *int64) *GetEntityGetI64ResultBuilder { - g.obj.Success = success - return g -} - -func (g *GetEntityGetI64Result) SetSuccess(success *int64) *GetEntityGetI64Result { - g.Success = success - return g -} - -func (p *GetEntityGetI64Result) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 0: - if err := p.ReadField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *GetEntityGetI64Result) ReadField0(iprot thrift.Protocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - p.Success = &v - } - return nil -} - -func (p *GetEntityGetI64Result) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("getI64_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField0(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *GetEntityGetI64Result) writeField0(oprot thrift.Protocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.I64, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := oprot.WriteI64(int64(*p.Success)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.success (0) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } - } - return err -} - -func (p *GetEntityGetI64Result) String() string { - if p == nil { - return "" - } - - var successVal string - if p.Success == nil { - successVal = "" - } else { - successVal = fmt.Sprintf("%v", *p.Success) - } - return fmt.Sprintf("GetEntityGetI64Result({Success:%s})", successVal) -} - -type GetEntityGetDoubleArgs struct { - thrift.IRequest -} - -func NewGetEntityGetDoubleArgs() *GetEntityGetDoubleArgs { - return &GetEntityGetDoubleArgs{} -} - -type GetEntityGetDoubleArgsBuilder struct { - obj *GetEntityGetDoubleArgs -} - -func NewGetEntityGetDoubleArgsBuilder() *GetEntityGetDoubleArgsBuilder{ - return &GetEntityGetDoubleArgsBuilder{ - obj: NewGetEntityGetDoubleArgs(), - } -} - -func (p GetEntityGetDoubleArgsBuilder) Emit() *GetEntityGetDoubleArgs{ - return &GetEntityGetDoubleArgs{ - } -} - -func (p *GetEntityGetDoubleArgs) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *GetEntityGetDoubleArgs) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("getDouble_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *GetEntityGetDoubleArgs) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("GetEntityGetDoubleArgs({})") -} - -// Attributes: -// - Success -type GetEntityGetDoubleResult struct { - thrift.IResponse - Success *float64 `thrift:"success,0,optional" db:"success" json:"success,omitempty"` -} - -func NewGetEntityGetDoubleResult() *GetEntityGetDoubleResult { - return &GetEntityGetDoubleResult{} -} - -var GetEntityGetDoubleResult_Success_DEFAULT float64 -func (p *GetEntityGetDoubleResult) GetSuccess() float64 { - if !p.IsSetSuccess() { - return GetEntityGetDoubleResult_Success_DEFAULT - } - return *p.Success -} -func (p *GetEntityGetDoubleResult) IsSetSuccess() bool { - return p != nil && p.Success != nil -} - -type GetEntityGetDoubleResultBuilder struct { - obj *GetEntityGetDoubleResult -} - -func NewGetEntityGetDoubleResultBuilder() *GetEntityGetDoubleResultBuilder{ - return &GetEntityGetDoubleResultBuilder{ - obj: NewGetEntityGetDoubleResult(), - } -} - -func (p GetEntityGetDoubleResultBuilder) Emit() *GetEntityGetDoubleResult{ - return &GetEntityGetDoubleResult{ - Success: p.obj.Success, - } -} - -func (g *GetEntityGetDoubleResultBuilder) Success(success *float64) *GetEntityGetDoubleResultBuilder { - g.obj.Success = success - return g -} - -func (g *GetEntityGetDoubleResult) SetSuccess(success *float64) *GetEntityGetDoubleResult { - g.Success = success - return g -} - -func (p *GetEntityGetDoubleResult) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 0: - if err := p.ReadField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *GetEntityGetDoubleResult) ReadField0(iprot thrift.Protocol) error { - if v, err := iprot.ReadDouble(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - p.Success = &v - } - return nil -} - -func (p *GetEntityGetDoubleResult) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("getDouble_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField0(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *GetEntityGetDoubleResult) writeField0(oprot thrift.Protocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.DOUBLE, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := oprot.WriteDouble(float64(*p.Success)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.success (0) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } - } - return err -} - -func (p *GetEntityGetDoubleResult) String() string { - if p == nil { - return "" - } - - var successVal string - if p.Success == nil { - successVal = "" - } else { - successVal = fmt.Sprintf("%v", *p.Success) - } - return fmt.Sprintf("GetEntityGetDoubleResult({Success:%s})", successVal) -} - -type GetEntityGetStringArgs struct { - thrift.IRequest -} - -func NewGetEntityGetStringArgs() *GetEntityGetStringArgs { - return &GetEntityGetStringArgs{} -} - -type GetEntityGetStringArgsBuilder struct { - obj *GetEntityGetStringArgs -} - -func NewGetEntityGetStringArgsBuilder() *GetEntityGetStringArgsBuilder{ - return &GetEntityGetStringArgsBuilder{ - obj: NewGetEntityGetStringArgs(), - } -} - -func (p GetEntityGetStringArgsBuilder) Emit() *GetEntityGetStringArgs{ - return &GetEntityGetStringArgs{ - } -} - -func (p *GetEntityGetStringArgs) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *GetEntityGetStringArgs) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("getString_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *GetEntityGetStringArgs) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("GetEntityGetStringArgs({})") -} - -// Attributes: -// - Success -type GetEntityGetStringResult struct { - thrift.IResponse - Success *string `thrift:"success,0,optional" db:"success" json:"success,omitempty"` -} - -func NewGetEntityGetStringResult() *GetEntityGetStringResult { - return &GetEntityGetStringResult{} -} - -var GetEntityGetStringResult_Success_DEFAULT string -func (p *GetEntityGetStringResult) GetSuccess() string { - if !p.IsSetSuccess() { - return GetEntityGetStringResult_Success_DEFAULT - } - return *p.Success -} -func (p *GetEntityGetStringResult) IsSetSuccess() bool { - return p != nil && p.Success != nil -} - -type GetEntityGetStringResultBuilder struct { - obj *GetEntityGetStringResult -} - -func NewGetEntityGetStringResultBuilder() *GetEntityGetStringResultBuilder{ - return &GetEntityGetStringResultBuilder{ - obj: NewGetEntityGetStringResult(), - } -} - -func (p GetEntityGetStringResultBuilder) Emit() *GetEntityGetStringResult{ - return &GetEntityGetStringResult{ - Success: p.obj.Success, - } -} - -func (g *GetEntityGetStringResultBuilder) Success(success *string) *GetEntityGetStringResultBuilder { - g.obj.Success = success - return g -} - -func (g *GetEntityGetStringResult) SetSuccess(success *string) *GetEntityGetStringResult { - g.Success = success - return g -} - -func (p *GetEntityGetStringResult) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 0: - if err := p.ReadField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *GetEntityGetStringResult) ReadField0(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - p.Success = &v - } - return nil -} - -func (p *GetEntityGetStringResult) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("getString_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField0(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *GetEntityGetStringResult) writeField0(oprot thrift.Protocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRING, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := oprot.WriteString(string(*p.Success)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.success (0) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } - } - return err -} - -func (p *GetEntityGetStringResult) String() string { - if p == nil { - return "" - } - - var successVal string - if p.Success == nil { - successVal = "" - } else { - successVal = fmt.Sprintf("%v", *p.Success) - } - return fmt.Sprintf("GetEntityGetStringResult({Success:%s})", successVal) -} - -type GetEntityGetBinaryArgs struct { - thrift.IRequest -} - -func NewGetEntityGetBinaryArgs() *GetEntityGetBinaryArgs { - return &GetEntityGetBinaryArgs{} -} - -type GetEntityGetBinaryArgsBuilder struct { - obj *GetEntityGetBinaryArgs -} - -func NewGetEntityGetBinaryArgsBuilder() *GetEntityGetBinaryArgsBuilder{ - return &GetEntityGetBinaryArgsBuilder{ - obj: NewGetEntityGetBinaryArgs(), - } -} - -func (p GetEntityGetBinaryArgsBuilder) Emit() *GetEntityGetBinaryArgs{ - return &GetEntityGetBinaryArgs{ - } -} - -func (p *GetEntityGetBinaryArgs) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *GetEntityGetBinaryArgs) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("getBinary_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *GetEntityGetBinaryArgs) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("GetEntityGetBinaryArgs({})") -} - -// Attributes: -// - Success -type GetEntityGetBinaryResult struct { - thrift.IResponse - Success []byte `thrift:"success,0,optional" db:"success" json:"success,omitempty"` -} - -func NewGetEntityGetBinaryResult() *GetEntityGetBinaryResult { - return &GetEntityGetBinaryResult{} -} - -var GetEntityGetBinaryResult_Success_DEFAULT []byte - -func (p *GetEntityGetBinaryResult) GetSuccess() []byte { - return p.Success -} -func (p *GetEntityGetBinaryResult) IsSetSuccess() bool { - return p != nil && p.Success != nil -} - -type GetEntityGetBinaryResultBuilder struct { - obj *GetEntityGetBinaryResult -} - -func NewGetEntityGetBinaryResultBuilder() *GetEntityGetBinaryResultBuilder{ - return &GetEntityGetBinaryResultBuilder{ - obj: NewGetEntityGetBinaryResult(), - } -} - -func (p GetEntityGetBinaryResultBuilder) Emit() *GetEntityGetBinaryResult{ - return &GetEntityGetBinaryResult{ - Success: p.obj.Success, - } -} - -func (g *GetEntityGetBinaryResultBuilder) Success(success []byte) *GetEntityGetBinaryResultBuilder { - g.obj.Success = success - return g -} - -func (g *GetEntityGetBinaryResult) SetSuccess(success []byte) *GetEntityGetBinaryResult { - g.Success = success - return g -} - -func (p *GetEntityGetBinaryResult) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 0: - if err := p.ReadField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *GetEntityGetBinaryResult) ReadField0(iprot thrift.Protocol) error { - if v, err := iprot.ReadBinary(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - p.Success = v - } - return nil -} - -func (p *GetEntityGetBinaryResult) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("getBinary_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField0(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *GetEntityGetBinaryResult) writeField0(oprot thrift.Protocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRING, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := oprot.WriteBinary(p.Success); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.success (0) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } - } - return err -} - -func (p *GetEntityGetBinaryResult) String() string { - if p == nil { - return "" - } - - successVal := fmt.Sprintf("%v", p.Success) - return fmt.Sprintf("GetEntityGetBinaryResult({Success:%s})", successVal) -} - -type GetEntityGetMapArgs struct { - thrift.IRequest -} - -func NewGetEntityGetMapArgs() *GetEntityGetMapArgs { - return &GetEntityGetMapArgs{} -} - -type GetEntityGetMapArgsBuilder struct { - obj *GetEntityGetMapArgs -} - -func NewGetEntityGetMapArgsBuilder() *GetEntityGetMapArgsBuilder{ - return &GetEntityGetMapArgsBuilder{ - obj: NewGetEntityGetMapArgs(), - } -} - -func (p GetEntityGetMapArgsBuilder) Emit() *GetEntityGetMapArgs{ - return &GetEntityGetMapArgs{ - } -} - -func (p *GetEntityGetMapArgs) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *GetEntityGetMapArgs) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("getMap_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *GetEntityGetMapArgs) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("GetEntityGetMapArgs({})") -} - -// Attributes: -// - Success -type GetEntityGetMapResult struct { - thrift.IResponse - Success map[string]string `thrift:"success,0,optional" db:"success" json:"success,omitempty"` -} - -func NewGetEntityGetMapResult() *GetEntityGetMapResult { - return &GetEntityGetMapResult{} -} - -var GetEntityGetMapResult_Success_DEFAULT map[string]string - -func (p *GetEntityGetMapResult) GetSuccess() map[string]string { - return p.Success -} -func (p *GetEntityGetMapResult) IsSetSuccess() bool { - return p != nil && p.Success != nil -} - -type GetEntityGetMapResultBuilder struct { - obj *GetEntityGetMapResult -} - -func NewGetEntityGetMapResultBuilder() *GetEntityGetMapResultBuilder{ - return &GetEntityGetMapResultBuilder{ - obj: NewGetEntityGetMapResult(), - } -} - -func (p GetEntityGetMapResultBuilder) Emit() *GetEntityGetMapResult{ - return &GetEntityGetMapResult{ - Success: p.obj.Success, - } -} - -func (g *GetEntityGetMapResultBuilder) Success(success map[string]string) *GetEntityGetMapResultBuilder { - g.obj.Success = success - return g -} - -func (g *GetEntityGetMapResult) SetSuccess(success map[string]string) *GetEntityGetMapResult { - g.Success = success - return g -} - -func (p *GetEntityGetMapResult) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 0: - if err := p.ReadField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *GetEntityGetMapResult) ReadField0(iprot thrift.Protocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[string]string, size) - p.Success = tMap - for i := 0; i < size; i ++ { - var _key5 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key5 = v - } - var _val6 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _val6 = v - } - p.Success[_key5] = _val6 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *GetEntityGetMapResult) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("getMap_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField0(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *GetEntityGetMapResult) writeField0(oprot thrift.Protocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.MAP, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := oprot.WriteMapBegin(thrift.STRING, thrift.STRING, len(p.Success)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.Success { - if err := oprot.WriteString(string(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := oprot.WriteString(string(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } - } - return err -} - -func (p *GetEntityGetMapResult) String() string { - if p == nil { - return "" - } - - successVal := fmt.Sprintf("%v", p.Success) - return fmt.Sprintf("GetEntityGetMapResult({Success:%s})", successVal) -} - -type GetEntityGetSetArgs struct { - thrift.IRequest -} - -func NewGetEntityGetSetArgs() *GetEntityGetSetArgs { - return &GetEntityGetSetArgs{} -} - -type GetEntityGetSetArgsBuilder struct { - obj *GetEntityGetSetArgs -} - -func NewGetEntityGetSetArgsBuilder() *GetEntityGetSetArgsBuilder{ - return &GetEntityGetSetArgsBuilder{ - obj: NewGetEntityGetSetArgs(), - } -} - -func (p GetEntityGetSetArgsBuilder) Emit() *GetEntityGetSetArgs{ - return &GetEntityGetSetArgs{ - } -} - -func (p *GetEntityGetSetArgs) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *GetEntityGetSetArgs) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("getSet_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *GetEntityGetSetArgs) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("GetEntityGetSetArgs({})") -} - -// Attributes: -// - Success -type GetEntityGetSetResult struct { - thrift.IResponse - Success []string `thrift:"success,0,optional" db:"success" json:"success,omitempty"` -} - -func NewGetEntityGetSetResult() *GetEntityGetSetResult { - return &GetEntityGetSetResult{} -} - -var GetEntityGetSetResult_Success_DEFAULT []string - -func (p *GetEntityGetSetResult) GetSuccess() []string { - return p.Success -} -func (p *GetEntityGetSetResult) IsSetSuccess() bool { - return p != nil && p.Success != nil -} - -type GetEntityGetSetResultBuilder struct { - obj *GetEntityGetSetResult -} - -func NewGetEntityGetSetResultBuilder() *GetEntityGetSetResultBuilder{ - return &GetEntityGetSetResultBuilder{ - obj: NewGetEntityGetSetResult(), - } -} - -func (p GetEntityGetSetResultBuilder) Emit() *GetEntityGetSetResult{ - return &GetEntityGetSetResult{ - Success: p.obj.Success, - } -} - -func (g *GetEntityGetSetResultBuilder) Success(success []string) *GetEntityGetSetResultBuilder { - g.obj.Success = success - return g -} - -func (g *GetEntityGetSetResult) SetSuccess(success []string) *GetEntityGetSetResult { - g.Success = success - return g -} - -func (p *GetEntityGetSetResult) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 0: - if err := p.ReadField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *GetEntityGetSetResult) ReadField0(iprot thrift.Protocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return thrift.PrependError("error reading set begin: ", err) - } - tSet := make([]string, 0, size) - p.Success = tSet - for i := 0; i < size; i ++ { - var _elem7 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem7 = v - } - p.Success = append(p.Success, _elem7) - } - if err := iprot.ReadSetEnd(); err != nil { - return thrift.PrependError("error reading set end: ", err) - } - return nil -} - -func (p *GetEntityGetSetResult) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("getSet_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField0(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *GetEntityGetSetResult) writeField0(oprot thrift.Protocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.SET, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := oprot.WriteSetBegin(thrift.STRING, len(p.Success)); err != nil { - return thrift.PrependError("error writing set begin: ", err) - } - set := make(map[string]bool, len(p.Success)) - for _, v := range p.Success { - if ok := set[v]; ok { - return thrift.PrependError("", fmt.Errorf("%T error writing set field: slice is not unique", v)) - } - set[v] = true - } - for _, v := range p.Success { - if err := oprot.WriteString(string(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteSetEnd(); err != nil { - return thrift.PrependError("error writing set end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } - } - return err -} - -func (p *GetEntityGetSetResult) String() string { - if p == nil { - return "" - } - - successVal := fmt.Sprintf("%v", p.Success) - return fmt.Sprintf("GetEntityGetSetResult({Success:%s})", successVal) -} - -type GetEntityGetListArgs struct { - thrift.IRequest -} - -func NewGetEntityGetListArgs() *GetEntityGetListArgs { - return &GetEntityGetListArgs{} -} - -type GetEntityGetListArgsBuilder struct { - obj *GetEntityGetListArgs -} - -func NewGetEntityGetListArgsBuilder() *GetEntityGetListArgsBuilder{ - return &GetEntityGetListArgsBuilder{ - obj: NewGetEntityGetListArgs(), - } -} - -func (p GetEntityGetListArgsBuilder) Emit() *GetEntityGetListArgs{ - return &GetEntityGetListArgs{ - } -} - -func (p *GetEntityGetListArgs) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *GetEntityGetListArgs) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("getList_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *GetEntityGetListArgs) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("GetEntityGetListArgs({})") -} - -// Attributes: -// - Success -type GetEntityGetListResult struct { - thrift.IResponse - Success []string `thrift:"success,0,optional" db:"success" json:"success,omitempty"` -} - -func NewGetEntityGetListResult() *GetEntityGetListResult { - return &GetEntityGetListResult{} -} - -var GetEntityGetListResult_Success_DEFAULT []string - -func (p *GetEntityGetListResult) GetSuccess() []string { - return p.Success -} -func (p *GetEntityGetListResult) IsSetSuccess() bool { - return p != nil && p.Success != nil -} - -type GetEntityGetListResultBuilder struct { - obj *GetEntityGetListResult -} - -func NewGetEntityGetListResultBuilder() *GetEntityGetListResultBuilder{ - return &GetEntityGetListResultBuilder{ - obj: NewGetEntityGetListResult(), - } -} - -func (p GetEntityGetListResultBuilder) Emit() *GetEntityGetListResult{ - return &GetEntityGetListResult{ - Success: p.obj.Success, - } -} - -func (g *GetEntityGetListResultBuilder) Success(success []string) *GetEntityGetListResultBuilder { - g.obj.Success = success - return g -} - -func (g *GetEntityGetListResult) SetSuccess(success []string) *GetEntityGetListResult { - g.Success = success - return g -} - -func (p *GetEntityGetListResult) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 0: - if err := p.ReadField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *GetEntityGetListResult) ReadField0(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]string, 0, size) - p.Success = tSlice - for i := 0; i < size; i ++ { - var _elem8 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem8 = v - } - p.Success = append(p.Success, _elem8) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *GetEntityGetListResult) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("getList_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField0(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *GetEntityGetListResult) writeField0(oprot thrift.Protocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.LIST, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := oprot.WriteListBegin(thrift.STRING, len(p.Success)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.Success { - if err := oprot.WriteString(string(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } - } - return err -} - -func (p *GetEntityGetListResult) String() string { - if p == nil { - return "" - } - - successVal := fmt.Sprintf("%v", p.Success) - return fmt.Sprintf("GetEntityGetListResult({Success:%s})", successVal) -} - -// Attributes: -// - NumPos -// - NumNeg1 -// - NumNeg2 -type GetEntityGetLegacyStuffArgs struct { - thrift.IRequest - NumPos int64 - NumNeg1 int64 - NumNeg2 int64 -} - -func NewGetEntityGetLegacyStuffArgs() *GetEntityGetLegacyStuffArgs { - return &GetEntityGetLegacyStuffArgs{} -} - - -func (p *GetEntityGetLegacyStuffArgs) GetNumPos() int64 { - return p.NumPos -} - -func (p *GetEntityGetLegacyStuffArgs) GetNumNeg1() int64 { - return p.NumNeg1 -} - -func (p *GetEntityGetLegacyStuffArgs) GetNumNeg2() int64 { - return p.NumNeg2 -} -type GetEntityGetLegacyStuffArgsBuilder struct { - obj *GetEntityGetLegacyStuffArgs -} - -func NewGetEntityGetLegacyStuffArgsBuilder() *GetEntityGetLegacyStuffArgsBuilder{ - return &GetEntityGetLegacyStuffArgsBuilder{ - obj: NewGetEntityGetLegacyStuffArgs(), - } -} - -func (p GetEntityGetLegacyStuffArgsBuilder) Emit() *GetEntityGetLegacyStuffArgs{ - return &GetEntityGetLegacyStuffArgs{ - NumPos: p.obj.NumPos, - NumNeg1: p.obj.NumNeg1, - NumNeg2: p.obj.NumNeg2, - } -} - -func (g *GetEntityGetLegacyStuffArgsBuilder) NumPos(numPos int64) *GetEntityGetLegacyStuffArgsBuilder { - g.obj.NumPos = numPos - return g -} - -func (g *GetEntityGetLegacyStuffArgsBuilder) NumNeg1(numNeg1 int64) *GetEntityGetLegacyStuffArgsBuilder { - g.obj.NumNeg1 = numNeg1 - return g -} - -func (g *GetEntityGetLegacyStuffArgsBuilder) NumNeg2(numNeg2 int64) *GetEntityGetLegacyStuffArgsBuilder { - g.obj.NumNeg2 = numNeg2 - return g -} - -func (g *GetEntityGetLegacyStuffArgs) SetNumPos(numPos int64) *GetEntityGetLegacyStuffArgs { - g.NumPos = numPos - return g -} - -func (g *GetEntityGetLegacyStuffArgs) SetNumNeg1(numNeg1 int64) *GetEntityGetLegacyStuffArgs { - g.NumNeg1 = numNeg1 - return g -} - -func (g *GetEntityGetLegacyStuffArgs) SetNumNeg2(numNeg2 int64) *GetEntityGetLegacyStuffArgs { - g.NumNeg2 = numNeg2 - return g -} - -func (p *GetEntityGetLegacyStuffArgs) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case -1: - if err := p.ReadField_1(iprot); err != nil { - return err - } - case -2: - if err := p.ReadField_2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *GetEntityGetLegacyStuffArgs) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.NumPos = v - } - return nil -} - -func (p *GetEntityGetLegacyStuffArgs) ReadField_1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field -1: ", err) - } else { - p.NumNeg1 = v - } - return nil -} - -func (p *GetEntityGetLegacyStuffArgs) ReadField_2(iprot thrift.Protocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field -2: ", err) - } else { - p.NumNeg2 = v - } - return nil -} - -func (p *GetEntityGetLegacyStuffArgs) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("getLegacyStuff_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField_2(oprot); err != nil { return err } - if err := p.writeField_1(oprot); err != nil { return err } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *GetEntityGetLegacyStuffArgs) writeField_2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("numNeg2", thrift.I64, -2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -2:numNeg2: ", p), err) } - if err := oprot.WriteI64(int64(p.NumNeg2)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.numNeg2 (-2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -2:numNeg2: ", p), err) } - return err -} - -func (p *GetEntityGetLegacyStuffArgs) writeField_1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("numNeg1", thrift.I64, -1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -1:numNeg1: ", p), err) } - if err := oprot.WriteI64(int64(p.NumNeg1)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.numNeg1 (-1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -1:numNeg1: ", p), err) } - return err -} - -func (p *GetEntityGetLegacyStuffArgs) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("numPos", thrift.I64, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:numPos: ", p), err) } - if err := oprot.WriteI64(int64(p.NumPos)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.numPos (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:numPos: ", p), err) } - return err -} - -func (p *GetEntityGetLegacyStuffArgs) String() string { - if p == nil { - return "" - } - - numNeg2Val := fmt.Sprintf("%v", p.NumNeg2) - numNeg1Val := fmt.Sprintf("%v", p.NumNeg1) - numPosVal := fmt.Sprintf("%v", p.NumPos) - return fmt.Sprintf("GetEntityGetLegacyStuffArgs({NumNeg2:%s NumNeg1:%s NumPos:%s})", numNeg2Val, numNeg1Val, numPosVal) -} - -// Attributes: -// - Success -type GetEntityGetLegacyStuffResult struct { - thrift.IResponse - Success *int32 `thrift:"success,0,optional" db:"success" json:"success,omitempty"` -} - -func NewGetEntityGetLegacyStuffResult() *GetEntityGetLegacyStuffResult { - return &GetEntityGetLegacyStuffResult{} -} - -var GetEntityGetLegacyStuffResult_Success_DEFAULT int32 -func (p *GetEntityGetLegacyStuffResult) GetSuccess() int32 { - if !p.IsSetSuccess() { - return GetEntityGetLegacyStuffResult_Success_DEFAULT - } - return *p.Success -} -func (p *GetEntityGetLegacyStuffResult) IsSetSuccess() bool { - return p != nil && p.Success != nil -} - -type GetEntityGetLegacyStuffResultBuilder struct { - obj *GetEntityGetLegacyStuffResult -} - -func NewGetEntityGetLegacyStuffResultBuilder() *GetEntityGetLegacyStuffResultBuilder{ - return &GetEntityGetLegacyStuffResultBuilder{ - obj: NewGetEntityGetLegacyStuffResult(), - } -} - -func (p GetEntityGetLegacyStuffResultBuilder) Emit() *GetEntityGetLegacyStuffResult{ - return &GetEntityGetLegacyStuffResult{ - Success: p.obj.Success, - } -} - -func (g *GetEntityGetLegacyStuffResultBuilder) Success(success *int32) *GetEntityGetLegacyStuffResultBuilder { - g.obj.Success = success - return g -} - -func (g *GetEntityGetLegacyStuffResult) SetSuccess(success *int32) *GetEntityGetLegacyStuffResult { - g.Success = success - return g -} - -func (p *GetEntityGetLegacyStuffResult) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 0: - if err := p.ReadField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *GetEntityGetLegacyStuffResult) ReadField0(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - p.Success = &v - } - return nil -} - -func (p *GetEntityGetLegacyStuffResult) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("getLegacyStuff_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField0(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *GetEntityGetLegacyStuffResult) writeField0(oprot thrift.Protocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.I32, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := oprot.WriteI32(int32(*p.Success)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.success (0) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } - } - return err -} - -func (p *GetEntityGetLegacyStuffResult) String() string { - if p == nil { - return "" - } - - var successVal string - if p.Success == nil { - successVal = "" - } else { - successVal = fmt.Sprintf("%v", *p.Success) - } - return fmt.Sprintf("GetEntityGetLegacyStuffResult({Success:%s})", successVal) -} - -// Attributes: -// - Ctx -type GetEntityGetCtxCollisionArgs struct { - thrift.IRequest - Ctx int64 `thrift:"ctx,1" db:"ctx" json:"ctx"` -} - -func NewGetEntityGetCtxCollisionArgs() *GetEntityGetCtxCollisionArgs { - return &GetEntityGetCtxCollisionArgs{} -} - - -func (p *GetEntityGetCtxCollisionArgs) GetCtx() int64 { - return p.Ctx -} -type GetEntityGetCtxCollisionArgsBuilder struct { - obj *GetEntityGetCtxCollisionArgs -} - -func NewGetEntityGetCtxCollisionArgsBuilder() *GetEntityGetCtxCollisionArgsBuilder{ - return &GetEntityGetCtxCollisionArgsBuilder{ - obj: NewGetEntityGetCtxCollisionArgs(), - } -} - -func (p GetEntityGetCtxCollisionArgsBuilder) Emit() *GetEntityGetCtxCollisionArgs{ - return &GetEntityGetCtxCollisionArgs{ - Ctx: p.obj.Ctx, - } -} - -func (g *GetEntityGetCtxCollisionArgsBuilder) Ctx(ctx int64) *GetEntityGetCtxCollisionArgsBuilder { - g.obj.Ctx = ctx - return g -} - -func (g *GetEntityGetCtxCollisionArgs) SetCtx(ctx int64) *GetEntityGetCtxCollisionArgs { - g.Ctx = ctx - return g -} - -func (p *GetEntityGetCtxCollisionArgs) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *GetEntityGetCtxCollisionArgs) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Ctx = v - } - return nil -} - -func (p *GetEntityGetCtxCollisionArgs) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("getCtxCollision_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *GetEntityGetCtxCollisionArgs) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("ctx", thrift.I64, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:ctx: ", p), err) } - if err := oprot.WriteI64(int64(p.Ctx)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.ctx (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:ctx: ", p), err) } - return err -} - -func (p *GetEntityGetCtxCollisionArgs) String() string { - if p == nil { - return "" - } - - ctxVal := fmt.Sprintf("%v", p.Ctx) - return fmt.Sprintf("GetEntityGetCtxCollisionArgs({Ctx:%s})", ctxVal) -} - -// Attributes: -// - Success -type GetEntityGetCtxCollisionResult struct { - thrift.IResponse - Success *int32 `thrift:"success,0,optional" db:"success" json:"success,omitempty"` -} - -func NewGetEntityGetCtxCollisionResult() *GetEntityGetCtxCollisionResult { - return &GetEntityGetCtxCollisionResult{} -} - -var GetEntityGetCtxCollisionResult_Success_DEFAULT int32 -func (p *GetEntityGetCtxCollisionResult) GetSuccess() int32 { - if !p.IsSetSuccess() { - return GetEntityGetCtxCollisionResult_Success_DEFAULT - } - return *p.Success -} -func (p *GetEntityGetCtxCollisionResult) IsSetSuccess() bool { - return p != nil && p.Success != nil -} - -type GetEntityGetCtxCollisionResultBuilder struct { - obj *GetEntityGetCtxCollisionResult -} - -func NewGetEntityGetCtxCollisionResultBuilder() *GetEntityGetCtxCollisionResultBuilder{ - return &GetEntityGetCtxCollisionResultBuilder{ - obj: NewGetEntityGetCtxCollisionResult(), - } -} - -func (p GetEntityGetCtxCollisionResultBuilder) Emit() *GetEntityGetCtxCollisionResult{ - return &GetEntityGetCtxCollisionResult{ - Success: p.obj.Success, - } -} - -func (g *GetEntityGetCtxCollisionResultBuilder) Success(success *int32) *GetEntityGetCtxCollisionResultBuilder { - g.obj.Success = success - return g -} - -func (g *GetEntityGetCtxCollisionResult) SetSuccess(success *int32) *GetEntityGetCtxCollisionResult { - g.Success = success - return g -} - -func (p *GetEntityGetCtxCollisionResult) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 0: - if err := p.ReadField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *GetEntityGetCtxCollisionResult) ReadField0(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - p.Success = &v - } - return nil -} - -func (p *GetEntityGetCtxCollisionResult) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("getCtxCollision_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField0(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *GetEntityGetCtxCollisionResult) writeField0(oprot thrift.Protocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.I32, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := oprot.WriteI32(int32(*p.Success)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.success (0) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } - } - return err -} - -func (p *GetEntityGetCtxCollisionResult) String() string { - if p == nil { - return "" - } - - var successVal string - if p.Success == nil { - successVal = "" - } else { - successVal = fmt.Sprintf("%v", *p.Success) - } - return fmt.Sprintf("GetEntityGetCtxCollisionResult({Success:%s})", successVal) -} - -// Attributes: -// - Ctx -// - Ctx1 -type GetEntityGetCtx1CollisionArgs struct { - thrift.IRequest - Ctx int64 `thrift:"ctx,1" db:"ctx" json:"ctx"` - Ctx1 int64 `thrift:"ctx1,2" db:"ctx1" json:"ctx1"` -} - -func NewGetEntityGetCtx1CollisionArgs() *GetEntityGetCtx1CollisionArgs { - return &GetEntityGetCtx1CollisionArgs{} -} - - -func (p *GetEntityGetCtx1CollisionArgs) GetCtx() int64 { - return p.Ctx -} - -func (p *GetEntityGetCtx1CollisionArgs) GetCtx1() int64 { - return p.Ctx1 -} -type GetEntityGetCtx1CollisionArgsBuilder struct { - obj *GetEntityGetCtx1CollisionArgs -} - -func NewGetEntityGetCtx1CollisionArgsBuilder() *GetEntityGetCtx1CollisionArgsBuilder{ - return &GetEntityGetCtx1CollisionArgsBuilder{ - obj: NewGetEntityGetCtx1CollisionArgs(), - } -} - -func (p GetEntityGetCtx1CollisionArgsBuilder) Emit() *GetEntityGetCtx1CollisionArgs{ - return &GetEntityGetCtx1CollisionArgs{ - Ctx: p.obj.Ctx, - Ctx1: p.obj.Ctx1, - } -} - -func (g *GetEntityGetCtx1CollisionArgsBuilder) Ctx(ctx int64) *GetEntityGetCtx1CollisionArgsBuilder { - g.obj.Ctx = ctx - return g -} - -func (g *GetEntityGetCtx1CollisionArgsBuilder) Ctx1(ctx1 int64) *GetEntityGetCtx1CollisionArgsBuilder { - g.obj.Ctx1 = ctx1 - return g -} - -func (g *GetEntityGetCtx1CollisionArgs) SetCtx(ctx int64) *GetEntityGetCtx1CollisionArgs { - g.Ctx = ctx - return g -} - -func (g *GetEntityGetCtx1CollisionArgs) SetCtx1(ctx1 int64) *GetEntityGetCtx1CollisionArgs { - g.Ctx1 = ctx1 - return g -} - -func (p *GetEntityGetCtx1CollisionArgs) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *GetEntityGetCtx1CollisionArgs) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Ctx = v - } - return nil -} - -func (p *GetEntityGetCtx1CollisionArgs) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Ctx1 = v - } - return nil -} - -func (p *GetEntityGetCtx1CollisionArgs) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("getCtx1Collision_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *GetEntityGetCtx1CollisionArgs) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("ctx", thrift.I64, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:ctx: ", p), err) } - if err := oprot.WriteI64(int64(p.Ctx)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.ctx (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:ctx: ", p), err) } - return err -} - -func (p *GetEntityGetCtx1CollisionArgs) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("ctx1", thrift.I64, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:ctx1: ", p), err) } - if err := oprot.WriteI64(int64(p.Ctx1)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.ctx1 (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:ctx1: ", p), err) } - return err -} - -func (p *GetEntityGetCtx1CollisionArgs) String() string { - if p == nil { - return "" - } - - ctxVal := fmt.Sprintf("%v", p.Ctx) - ctx1Val := fmt.Sprintf("%v", p.Ctx1) - return fmt.Sprintf("GetEntityGetCtx1CollisionArgs({Ctx:%s Ctx1:%s})", ctxVal, ctx1Val) -} - -// Attributes: -// - Success -type GetEntityGetCtx1CollisionResult struct { - thrift.IResponse - Success *int32 `thrift:"success,0,optional" db:"success" json:"success,omitempty"` -} - -func NewGetEntityGetCtx1CollisionResult() *GetEntityGetCtx1CollisionResult { - return &GetEntityGetCtx1CollisionResult{} -} - -var GetEntityGetCtx1CollisionResult_Success_DEFAULT int32 -func (p *GetEntityGetCtx1CollisionResult) GetSuccess() int32 { - if !p.IsSetSuccess() { - return GetEntityGetCtx1CollisionResult_Success_DEFAULT - } - return *p.Success -} -func (p *GetEntityGetCtx1CollisionResult) IsSetSuccess() bool { - return p != nil && p.Success != nil -} - -type GetEntityGetCtx1CollisionResultBuilder struct { - obj *GetEntityGetCtx1CollisionResult -} - -func NewGetEntityGetCtx1CollisionResultBuilder() *GetEntityGetCtx1CollisionResultBuilder{ - return &GetEntityGetCtx1CollisionResultBuilder{ - obj: NewGetEntityGetCtx1CollisionResult(), - } -} - -func (p GetEntityGetCtx1CollisionResultBuilder) Emit() *GetEntityGetCtx1CollisionResult{ - return &GetEntityGetCtx1CollisionResult{ - Success: p.obj.Success, - } -} - -func (g *GetEntityGetCtx1CollisionResultBuilder) Success(success *int32) *GetEntityGetCtx1CollisionResultBuilder { - g.obj.Success = success - return g -} - -func (g *GetEntityGetCtx1CollisionResult) SetSuccess(success *int32) *GetEntityGetCtx1CollisionResult { - g.Success = success - return g -} - -func (p *GetEntityGetCtx1CollisionResult) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 0: - if err := p.ReadField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *GetEntityGetCtx1CollisionResult) ReadField0(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - p.Success = &v - } - return nil -} - -func (p *GetEntityGetCtx1CollisionResult) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("getCtx1Collision_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField0(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *GetEntityGetCtx1CollisionResult) writeField0(oprot thrift.Protocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.I32, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := oprot.WriteI32(int32(*p.Success)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.success (0) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } - } - return err -} - -func (p *GetEntityGetCtx1CollisionResult) String() string { - if p == nil { - return "" - } - - var successVal string - if p.Success == nil { - successVal = "" - } else { - successVal = fmt.Sprintf("%v", *p.Success) - } - return fmt.Sprintf("GetEntityGetCtx1CollisionResult({Success:%s})", successVal) -} - - diff --git a/thrift/compiler/test/fixtures/go-service/gen-go/module/ttypes.go b/thrift/compiler/test/fixtures/go-service/gen-go/module/ttypes.go deleted file mode 100644 index de1553374aa..00000000000 --- a/thrift/compiler/test/fixtures/go-service/gen-go/module/ttypes.go +++ /dev/null @@ -1,489 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package module - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var GoUnusedProtection__ int; - -// Attributes: -// - Id -type GetEntityRequest struct { - Id string `thrift:"id,1" db:"id" json:"id"` -} - -func NewGetEntityRequest() *GetEntityRequest { - return &GetEntityRequest{} -} - - -func (p *GetEntityRequest) GetId() string { - return p.Id -} -type GetEntityRequestBuilder struct { - obj *GetEntityRequest -} - -func NewGetEntityRequestBuilder() *GetEntityRequestBuilder{ - return &GetEntityRequestBuilder{ - obj: NewGetEntityRequest(), - } -} - -func (p GetEntityRequestBuilder) Emit() *GetEntityRequest{ - return &GetEntityRequest{ - Id: p.obj.Id, - } -} - -func (g *GetEntityRequestBuilder) Id(id string) *GetEntityRequestBuilder { - g.obj.Id = id - return g -} - -func (g *GetEntityRequest) SetId(id string) *GetEntityRequest { - g.Id = id - return g -} - -func (p *GetEntityRequest) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *GetEntityRequest) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Id = v - } - return nil -} - -func (p *GetEntityRequest) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("GetEntityRequest"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *GetEntityRequest) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("id", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:id: ", p), err) } - if err := oprot.WriteString(string(p.Id)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.id (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:id: ", p), err) } - return err -} - -func (p *GetEntityRequest) String() string { - if p == nil { - return "" - } - - idVal := fmt.Sprintf("%v", p.Id) - return fmt.Sprintf("GetEntityRequest({Id:%s})", idVal) -} - -// Attributes: -// - Entity -type GetEntityResponse struct { - Entity string `thrift:"entity,1" db:"entity" json:"entity"` -} - -func NewGetEntityResponse() *GetEntityResponse { - return &GetEntityResponse{} -} - - -func (p *GetEntityResponse) GetEntity() string { - return p.Entity -} -type GetEntityResponseBuilder struct { - obj *GetEntityResponse -} - -func NewGetEntityResponseBuilder() *GetEntityResponseBuilder{ - return &GetEntityResponseBuilder{ - obj: NewGetEntityResponse(), - } -} - -func (p GetEntityResponseBuilder) Emit() *GetEntityResponse{ - return &GetEntityResponse{ - Entity: p.obj.Entity, - } -} - -func (g *GetEntityResponseBuilder) Entity(entity string) *GetEntityResponseBuilder { - g.obj.Entity = entity - return g -} - -func (g *GetEntityResponse) SetEntity(entity string) *GetEntityResponse { - g.Entity = entity - return g -} - -func (p *GetEntityResponse) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *GetEntityResponse) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Entity = v - } - return nil -} - -func (p *GetEntityResponse) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("GetEntityResponse"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *GetEntityResponse) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("entity", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:entity: ", p), err) } - if err := oprot.WriteString(string(p.Entity)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.entity (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:entity: ", p), err) } - return err -} - -func (p *GetEntityResponse) String() string { - if p == nil { - return "" - } - - entityVal := fmt.Sprintf("%v", p.Entity) - return fmt.Sprintf("GetEntityResponse({Entity:%s})", entityVal) -} - -// Attributes: -// - Foo -// - Bar -// - Baz -type NonComparableStruct struct { - Foo string `thrift:"foo,1" db:"foo" json:"foo"` - Bar []string `thrift:"bar,2" db:"bar" json:"bar"` - Baz map[NonComparableStruct]int64 `thrift:"baz,3" db:"baz" json:"baz"` -} - -func NewNonComparableStruct() *NonComparableStruct { - return &NonComparableStruct{} -} - - -func (p *NonComparableStruct) GetFoo() string { - return p.Foo -} - -func (p *NonComparableStruct) GetBar() []string { - return p.Bar -} - -func (p *NonComparableStruct) GetBaz() map[NonComparableStruct]int64 { - return p.Baz -} -type NonComparableStructBuilder struct { - obj *NonComparableStruct -} - -func NewNonComparableStructBuilder() *NonComparableStructBuilder{ - return &NonComparableStructBuilder{ - obj: NewNonComparableStruct(), - } -} - -func (p NonComparableStructBuilder) Emit() *NonComparableStruct{ - return &NonComparableStruct{ - Foo: p.obj.Foo, - Bar: p.obj.Bar, - Baz: p.obj.Baz, - } -} - -func (n *NonComparableStructBuilder) Foo(foo string) *NonComparableStructBuilder { - n.obj.Foo = foo - return n -} - -func (n *NonComparableStructBuilder) Bar(bar []string) *NonComparableStructBuilder { - n.obj.Bar = bar - return n -} - -func (n *NonComparableStructBuilder) Baz(baz map[NonComparableStruct]int64) *NonComparableStructBuilder { - n.obj.Baz = baz - return n -} - -func (n *NonComparableStruct) SetFoo(foo string) *NonComparableStruct { - n.Foo = foo - return n -} - -func (n *NonComparableStruct) SetBar(bar []string) *NonComparableStruct { - n.Bar = bar - return n -} - -func (n *NonComparableStruct) SetBaz(baz map[NonComparableStruct]int64) *NonComparableStruct { - n.Baz = baz - return n -} - -func (p *NonComparableStruct) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 3: - if err := p.ReadField3(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *NonComparableStruct) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Foo = v - } - return nil -} - -func (p *NonComparableStruct) ReadField2(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]string, 0, size) - p.Bar = tSlice - for i := 0; i < size; i ++ { - var _elem0 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem0 = v - } - p.Bar = append(p.Bar, _elem0) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *NonComparableStruct) ReadField3(iprot thrift.Protocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[NonComparableStruct]int64, size) - p.Baz = tMap - for i := 0; i < size; i ++ { - _key1 := NewNonComparableStruct() - if err := _key1.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _key1), err) - } - var _val2 int64 - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _val2 = v - } - p.Baz[*_key1] = _val2 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *NonComparableStruct) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("NonComparableStruct"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *NonComparableStruct) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("foo", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:foo: ", p), err) } - if err := oprot.WriteString(string(p.Foo)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.foo (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:foo: ", p), err) } - return err -} - -func (p *NonComparableStruct) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("bar", thrift.LIST, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:bar: ", p), err) } - if err := oprot.WriteListBegin(thrift.STRING, len(p.Bar)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.Bar { - if err := oprot.WriteString(string(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:bar: ", p), err) } - return err -} - -func (p *NonComparableStruct) writeField3(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("baz", thrift.MAP, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:baz: ", p), err) } - if err := oprot.WriteMapBegin(thrift.STRUCT, thrift.I64, len(p.Baz)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.Baz { - if err := k.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", k), err) - } - if err := oprot.WriteI64(int64(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:baz: ", p), err) } - return err -} - -func (p *NonComparableStruct) String() string { - if p == nil { - return "" - } - - fooVal := fmt.Sprintf("%v", p.Foo) - barVal := fmt.Sprintf("%v", p.Bar) - bazVal := fmt.Sprintf("%v", p.Baz) - return fmt.Sprintf("NonComparableStruct({Foo:%s Bar:%s Baz:%s})", fooVal, barVal, bazVal) -} - diff --git a/thrift/compiler/test/fixtures/go-typedef/gen-go/module0/constants.go b/thrift/compiler/test/fixtures/go-typedef/gen-go/module0/constants.go deleted file mode 100644 index b13e4af3ee1..00000000000 --- a/thrift/compiler/test/fixtures/go-typedef/gen-go/module0/constants.go +++ /dev/null @@ -1,25 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package module0 - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - - -func init() { -} - diff --git a/thrift/compiler/test/fixtures/go-typedef/gen-go/module0/ttypes.go b/thrift/compiler/test/fixtures/go-typedef/gen-go/module0/ttypes.go deleted file mode 100644 index f4daf48cad9..00000000000 --- a/thrift/compiler/test/fixtures/go-typedef/gen-go/module0/ttypes.go +++ /dev/null @@ -1,329 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package module0 - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var GoUnusedProtection__ int; - -// Attributes: -// - InventoryId -// - Name -type Accessory struct { - InventoryId int32 `thrift:"InventoryId,1" db:"InventoryId" json:"InventoryId"` - Name string `thrift:"Name,2" db:"Name" json:"Name"` -} - -func NewAccessory() *Accessory { - return &Accessory{} -} - - -func (p *Accessory) GetInventoryId() int32 { - return p.InventoryId -} - -func (p *Accessory) GetName() string { - return p.Name -} -type AccessoryBuilder struct { - obj *Accessory -} - -func NewAccessoryBuilder() *AccessoryBuilder{ - return &AccessoryBuilder{ - obj: NewAccessory(), - } -} - -func (p AccessoryBuilder) Emit() *Accessory{ - return &Accessory{ - InventoryId: p.obj.InventoryId, - Name: p.obj.Name, - } -} - -func (a *AccessoryBuilder) InventoryId(inventoryId int32) *AccessoryBuilder { - a.obj.InventoryId = inventoryId - return a -} - -func (a *AccessoryBuilder) Name(name string) *AccessoryBuilder { - a.obj.Name = name - return a -} - -func (a *Accessory) SetInventoryId(inventoryId int32) *Accessory { - a.InventoryId = inventoryId - return a -} - -func (a *Accessory) SetName(name string) *Accessory { - a.Name = name - return a -} - -func (p *Accessory) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Accessory) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.InventoryId = v - } - return nil -} - -func (p *Accessory) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Name = v - } - return nil -} - -func (p *Accessory) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Accessory"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Accessory) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("InventoryId", thrift.I32, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:InventoryId: ", p), err) } - if err := oprot.WriteI32(int32(p.InventoryId)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.InventoryId (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:InventoryId: ", p), err) } - return err -} - -func (p *Accessory) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("Name", thrift.STRING, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:Name: ", p), err) } - if err := oprot.WriteString(string(p.Name)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.Name (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:Name: ", p), err) } - return err -} - -func (p *Accessory) String() string { - if p == nil { - return "" - } - - inventoryIdVal := fmt.Sprintf("%v", p.InventoryId) - nameVal := fmt.Sprintf("%v", p.Name) - return fmt.Sprintf("Accessory({InventoryId:%s Name:%s})", inventoryIdVal, nameVal) -} - -// Attributes: -// - InventoryId -// - Name -type PartName struct { - InventoryId int32 `thrift:"InventoryId,1" db:"InventoryId" json:"InventoryId"` - Name string `thrift:"Name,2" db:"Name" json:"Name"` -} - -func NewPartName() *PartName { - return &PartName{} -} - - -func (p *PartName) GetInventoryId() int32 { - return p.InventoryId -} - -func (p *PartName) GetName() string { - return p.Name -} -type PartNameBuilder struct { - obj *PartName -} - -func NewPartNameBuilder() *PartNameBuilder{ - return &PartNameBuilder{ - obj: NewPartName(), - } -} - -func (p PartNameBuilder) Emit() *PartName{ - return &PartName{ - InventoryId: p.obj.InventoryId, - Name: p.obj.Name, - } -} - -func (p *PartNameBuilder) InventoryId(inventoryId int32) *PartNameBuilder { - p.obj.InventoryId = inventoryId - return p -} - -func (p *PartNameBuilder) Name(name string) *PartNameBuilder { - p.obj.Name = name - return p -} - -func (p *PartName) SetInventoryId(inventoryId int32) *PartName { - p.InventoryId = inventoryId - return p -} - -func (p *PartName) SetName(name string) *PartName { - p.Name = name - return p -} - -func (p *PartName) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *PartName) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.InventoryId = v - } - return nil -} - -func (p *PartName) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Name = v - } - return nil -} - -func (p *PartName) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("PartName"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *PartName) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("InventoryId", thrift.I32, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:InventoryId: ", p), err) } - if err := oprot.WriteI32(int32(p.InventoryId)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.InventoryId (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:InventoryId: ", p), err) } - return err -} - -func (p *PartName) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("Name", thrift.STRING, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:Name: ", p), err) } - if err := oprot.WriteString(string(p.Name)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.Name (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:Name: ", p), err) } - return err -} - -func (p *PartName) String() string { - if p == nil { - return "" - } - - inventoryIdVal := fmt.Sprintf("%v", p.InventoryId) - nameVal := fmt.Sprintf("%v", p.Name) - return fmt.Sprintf("PartName({InventoryId:%s Name:%s})", inventoryIdVal, nameVal) -} - diff --git a/thrift/compiler/test/fixtures/go-typedef/gen-go/module1/constants.go b/thrift/compiler/test/fixtures/go-typedef/gen-go/module1/constants.go deleted file mode 100644 index 71f96494032..00000000000 --- a/thrift/compiler/test/fixtures/go-typedef/gen-go/module1/constants.go +++ /dev/null @@ -1,28 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package module1 - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" - module00 "module0" - -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var _ = module00.GoUnusedProtection__ - -func init() { -} - diff --git a/thrift/compiler/test/fixtures/go-typedef/gen-go/module1/finder.go b/thrift/compiler/test/fixtures/go-typedef/gen-go/module1/finder.go deleted file mode 100644 index 5aa2aa87b5e..00000000000 --- a/thrift/compiler/test/fixtures/go-typedef/gen-go/module1/finder.go +++ /dev/null @@ -1,1235 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package module1 - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" - module00 "module0" - -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var _ = module00.GoUnusedProtection__ -type Finder interface { - // Parameters: - // - Plate - ByPlate(plate Plate) (_r *Automobile, err error) - // Parameters: - // - Plate - AliasByPlate(plate Plate) (_r *Car, err error) - // Parameters: - // - Plate - PreviousPlate(plate Plate) (_r Plate, err error) -} - -type FinderClientInterface interface { - thrift.ClientInterface - // Parameters: - // - Plate - ByPlate(plate Plate) (_r *Automobile, err error) - // Parameters: - // - Plate - AliasByPlate(plate Plate) (_r *Car, err error) - // Parameters: - // - Plate - PreviousPlate(plate Plate) (_r Plate, err error) -} - -type FinderClient struct { - FinderClientInterface - CC thrift.ClientConn -} - -func(client *FinderClient) Open() error { - return client.CC.Open() -} - -func(client *FinderClient) Close() error { - return client.CC.Close() -} - -func(client *FinderClient) IsOpen() bool { - return client.CC.IsOpen() -} - -func NewFinderClientFactory(t thrift.Transport, f thrift.ProtocolFactory) *FinderClient { - return &FinderClient{ CC: thrift.NewClientConn(t, f) } -} - -func NewFinderClient(t thrift.Transport, iprot thrift.Protocol, oprot thrift.Protocol) *FinderClient { - return &FinderClient{ CC: thrift.NewClientConnWithProtocols(t, iprot, oprot) } -} - -func NewFinderClientProtocol(prot thrift.Protocol) *FinderClient { - return NewFinderClient(prot.Transport(), prot, prot) -} - -// Parameters: -// - Plate -func (p *FinderClient) ByPlate(plate Plate) (_r *Automobile, err error) { - args := FinderByPlateArgs{ - Plate : plate, - } - err = p.CC.SendMsg("byPlate", &args, thrift.CALL) - if err != nil { return } - return p.recvByPlate() -} - - -func (p *FinderClient) recvByPlate() (value *Automobile, err error) { - var __result FinderByPlateResult - err = p.CC.RecvMsg("byPlate", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -// Parameters: -// - Plate -func (p *FinderClient) AliasByPlate(plate Plate) (_r *Car, err error) { - args := FinderAliasByPlateArgs{ - Plate : plate, - } - err = p.CC.SendMsg("aliasByPlate", &args, thrift.CALL) - if err != nil { return } - return p.recvAliasByPlate() -} - - -func (p *FinderClient) recvAliasByPlate() (value *Car, err error) { - var __result FinderAliasByPlateResult - err = p.CC.RecvMsg("aliasByPlate", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -// Parameters: -// - Plate -func (p *FinderClient) PreviousPlate(plate Plate) (_r Plate, err error) { - args := FinderPreviousPlateArgs{ - Plate : plate, - } - err = p.CC.SendMsg("previousPlate", &args, thrift.CALL) - if err != nil { return } - return p.recvPreviousPlate() -} - - -func (p *FinderClient) recvPreviousPlate() (value Plate, err error) { - var __result FinderPreviousPlateResult - err = p.CC.RecvMsg("previousPlate", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - - -type FinderThreadsafeClient struct { - FinderClientInterface - CC thrift.ClientConn - Mu sync.Mutex -} - -func(client *FinderThreadsafeClient) Open() error { - client.Mu.Lock() - defer client.Mu.Unlock() - return client.CC.Open() -} - -func(client *FinderThreadsafeClient) Close() error { - client.Mu.Lock() - defer client.Mu.Unlock() - return client.CC.Close() -} - -func(client *FinderThreadsafeClient) IsOpen() bool { - client.Mu.Lock() - defer client.Mu.Unlock() - return client.CC.IsOpen() -} - -func NewFinderThreadsafeClientFactory(t thrift.Transport, f thrift.ProtocolFactory) *FinderThreadsafeClient { - return &FinderThreadsafeClient{ CC: thrift.NewClientConn(t, f) } -} - -func NewFinderThreadsafeClient(t thrift.Transport, iprot thrift.Protocol, oprot thrift.Protocol) *FinderThreadsafeClient { - return &FinderThreadsafeClient{ CC: thrift.NewClientConnWithProtocols(t, iprot, oprot) } -} - -func NewFinderThreadsafeClientProtocol(prot thrift.Protocol) *FinderThreadsafeClient { - return NewFinderThreadsafeClient(prot.Transport(), prot, prot) -} - -// Parameters: -// - Plate -func (p *FinderThreadsafeClient) ByPlate(plate Plate) (_r *Automobile, err error) { - p.Mu.Lock() - defer p.Mu.Unlock() - args := FinderByPlateArgs{ - Plate : plate, - } - err = p.CC.SendMsg("byPlate", &args, thrift.CALL) - if err != nil { return } - return p.recvByPlate() -} - - -func (p *FinderThreadsafeClient) recvByPlate() (value *Automobile, err error) { - var __result FinderByPlateResult - err = p.CC.RecvMsg("byPlate", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -// Parameters: -// - Plate -func (p *FinderThreadsafeClient) AliasByPlate(plate Plate) (_r *Car, err error) { - p.Mu.Lock() - defer p.Mu.Unlock() - args := FinderAliasByPlateArgs{ - Plate : plate, - } - err = p.CC.SendMsg("aliasByPlate", &args, thrift.CALL) - if err != nil { return } - return p.recvAliasByPlate() -} - - -func (p *FinderThreadsafeClient) recvAliasByPlate() (value *Car, err error) { - var __result FinderAliasByPlateResult - err = p.CC.RecvMsg("aliasByPlate", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -// Parameters: -// - Plate -func (p *FinderThreadsafeClient) PreviousPlate(plate Plate) (_r Plate, err error) { - p.Mu.Lock() - defer p.Mu.Unlock() - args := FinderPreviousPlateArgs{ - Plate : plate, - } - err = p.CC.SendMsg("previousPlate", &args, thrift.CALL) - if err != nil { return } - return p.recvPreviousPlate() -} - - -func (p *FinderThreadsafeClient) recvPreviousPlate() (value Plate, err error) { - var __result FinderPreviousPlateResult - err = p.CC.RecvMsg("previousPlate", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - - -type FinderChannelClient struct { - RequestChannel thrift.RequestChannel -} - -func (c *FinderChannelClient) Close() error { - return c.RequestChannel.Close() -} - -func (c *FinderChannelClient) IsOpen() bool { - return c.RequestChannel.IsOpen() -} - -func (c *FinderChannelClient) Open() error { - return c.RequestChannel.Open() -} - -func NewFinderChannelClient(channel thrift.RequestChannel) *FinderChannelClient { - return &FinderChannelClient{RequestChannel: channel} -} - -// Parameters: -// - Plate -func (p *FinderChannelClient) ByPlate(ctx context.Context, plate Plate) (_r *Automobile, err error) { - args := FinderByPlateArgs{ - Plate : plate, - } - var __result FinderByPlateResult - err = p.RequestChannel.Call(ctx, "byPlate", &args, &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -// Parameters: -// - Plate -func (p *FinderChannelClient) AliasByPlate(ctx context.Context, plate Plate) (_r *Car, err error) { - args := FinderAliasByPlateArgs{ - Plate : plate, - } - var __result FinderAliasByPlateResult - err = p.RequestChannel.Call(ctx, "aliasByPlate", &args, &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -// Parameters: -// - Plate -func (p *FinderChannelClient) PreviousPlate(ctx context.Context, plate Plate) (_r Plate, err error) { - args := FinderPreviousPlateArgs{ - Plate : plate, - } - var __result FinderPreviousPlateResult - err = p.RequestChannel.Call(ctx, "previousPlate", &args, &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - - -type FinderProcessor struct { - processorMap map[string]thrift.ProcessorFunction - functionServiceMap map[string]string - handler Finder -} - -func (p *FinderProcessor) AddToProcessorMap(key string, processor thrift.ProcessorFunction) { - p.processorMap[key] = processor -} - -func (p *FinderProcessor) AddToFunctionServiceMap(key, service string) { - p.functionServiceMap[key] = service -} - -func (p *FinderProcessor) GetProcessorFunction(key string) (processor thrift.ProcessorFunction, err error) { - if processor, ok := p.processorMap[key]; ok { - return processor, nil - } - return nil, nil // generic error message will be sent -} - -func (p *FinderProcessor) ProcessorMap() map[string]thrift.ProcessorFunction { - return p.processorMap -} - -func (p *FinderProcessor) FunctionServiceMap() map[string]string { - return p.functionServiceMap -} - -func NewFinderProcessor(handler Finder) *FinderProcessor { - self9 := &FinderProcessor{handler:handler, processorMap:make(map[string]thrift.ProcessorFunction), functionServiceMap:make(map[string]string)} - self9.processorMap["byPlate"] = &finderProcessorByPlate{handler:handler} - self9.processorMap["aliasByPlate"] = &finderProcessorAliasByPlate{handler:handler} - self9.processorMap["previousPlate"] = &finderProcessorPreviousPlate{handler:handler} - self9.functionServiceMap["byPlate"] = "Finder" - self9.functionServiceMap["aliasByPlate"] = "Finder" - self9.functionServiceMap["previousPlate"] = "Finder" - return self9 -} - -type finderProcessorByPlate struct { - handler Finder -} - -func (p *FinderByPlateResult) Exception() thrift.WritableException { - if p == nil { return nil } - return nil -} - -func (p *finderProcessorByPlate) Read(iprot thrift.Protocol) (thrift.Struct, thrift.Exception) { - args := FinderByPlateArgs{} - if err := args.Read(iprot); err != nil { - return nil, err - } - iprot.ReadMessageEnd() - return &args, nil -} - -func (p *finderProcessorByPlate) Write(seqId int32, result thrift.WritableStruct, oprot thrift.Protocol) (err thrift.Exception) { - var err2 error - messageType := thrift.REPLY - switch result.(type) { - case thrift.ApplicationException: - messageType = thrift.EXCEPTION - } - if err2 = oprot.WriteMessageBegin("byPlate", messageType, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - return err -} - -func (p *finderProcessorByPlate) Run(argStruct thrift.Struct) (thrift.WritableStruct, thrift.ApplicationException) { - args := argStruct.(*FinderByPlateArgs) - var __result FinderByPlateResult - if retval, err := p.handler.ByPlate(args.Plate); err != nil { - switch err.(type) { - default: - x := thrift.NewApplicationExceptionCause(thrift.INTERNAL_ERROR, "Internal error processing byPlate: " + err.Error(), err) - return x, x - } - } else { - __result.Success = retval - } - return &__result, nil -} - -type finderProcessorAliasByPlate struct { - handler Finder -} - -func (p *FinderAliasByPlateResult) Exception() thrift.WritableException { - if p == nil { return nil } - return nil -} - -func (p *finderProcessorAliasByPlate) Read(iprot thrift.Protocol) (thrift.Struct, thrift.Exception) { - args := FinderAliasByPlateArgs{} - if err := args.Read(iprot); err != nil { - return nil, err - } - iprot.ReadMessageEnd() - return &args, nil -} - -func (p *finderProcessorAliasByPlate) Write(seqId int32, result thrift.WritableStruct, oprot thrift.Protocol) (err thrift.Exception) { - var err2 error - messageType := thrift.REPLY - switch result.(type) { - case thrift.ApplicationException: - messageType = thrift.EXCEPTION - } - if err2 = oprot.WriteMessageBegin("aliasByPlate", messageType, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - return err -} - -func (p *finderProcessorAliasByPlate) Run(argStruct thrift.Struct) (thrift.WritableStruct, thrift.ApplicationException) { - args := argStruct.(*FinderAliasByPlateArgs) - var __result FinderAliasByPlateResult - if retval, err := p.handler.AliasByPlate(args.Plate); err != nil { - switch err.(type) { - default: - x := thrift.NewApplicationExceptionCause(thrift.INTERNAL_ERROR, "Internal error processing aliasByPlate: " + err.Error(), err) - return x, x - } - } else { - __result.Success = retval - } - return &__result, nil -} - -type finderProcessorPreviousPlate struct { - handler Finder -} - -func (p *FinderPreviousPlateResult) Exception() thrift.WritableException { - if p == nil { return nil } - return nil -} - -func (p *finderProcessorPreviousPlate) Read(iprot thrift.Protocol) (thrift.Struct, thrift.Exception) { - args := FinderPreviousPlateArgs{} - if err := args.Read(iprot); err != nil { - return nil, err - } - iprot.ReadMessageEnd() - return &args, nil -} - -func (p *finderProcessorPreviousPlate) Write(seqId int32, result thrift.WritableStruct, oprot thrift.Protocol) (err thrift.Exception) { - var err2 error - messageType := thrift.REPLY - switch result.(type) { - case thrift.ApplicationException: - messageType = thrift.EXCEPTION - } - if err2 = oprot.WriteMessageBegin("previousPlate", messageType, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - return err -} - -func (p *finderProcessorPreviousPlate) Run(argStruct thrift.Struct) (thrift.WritableStruct, thrift.ApplicationException) { - args := argStruct.(*FinderPreviousPlateArgs) - var __result FinderPreviousPlateResult - if retval, err := p.handler.PreviousPlate(args.Plate); err != nil { - switch err.(type) { - default: - x := thrift.NewApplicationExceptionCause(thrift.INTERNAL_ERROR, "Internal error processing previousPlate: " + err.Error(), err) - return x, x - } - } else { - __result.Success = &retval - } - return &__result, nil -} - - -// HELPER FUNCTIONS AND STRUCTURES - -// Attributes: -// - Plate -type FinderByPlateArgs struct { - thrift.IRequest - Plate Plate `thrift:"plate,1" db:"plate" json:"plate"` -} - -func NewFinderByPlateArgs() *FinderByPlateArgs { - return &FinderByPlateArgs{} -} - - -func (p *FinderByPlateArgs) GetPlate() Plate { - return p.Plate -} -type FinderByPlateArgsBuilder struct { - obj *FinderByPlateArgs -} - -func NewFinderByPlateArgsBuilder() *FinderByPlateArgsBuilder{ - return &FinderByPlateArgsBuilder{ - obj: NewFinderByPlateArgs(), - } -} - -func (p FinderByPlateArgsBuilder) Emit() *FinderByPlateArgs{ - return &FinderByPlateArgs{ - Plate: p.obj.Plate, - } -} - -func (f *FinderByPlateArgsBuilder) Plate(plate Plate) *FinderByPlateArgsBuilder { - f.obj.Plate = plate - return f -} - -func (f *FinderByPlateArgs) SetPlate(plate Plate) *FinderByPlateArgs { - f.Plate = plate - return f -} - -func (p *FinderByPlateArgs) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *FinderByPlateArgs) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - temp := Plate(v) - p.Plate = temp - } - return nil -} - -func (p *FinderByPlateArgs) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("byPlate_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *FinderByPlateArgs) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("plate", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:plate: ", p), err) } - if err := oprot.WriteString(string(p.Plate)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.plate (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:plate: ", p), err) } - return err -} - -func (p *FinderByPlateArgs) String() string { - if p == nil { - return "" - } - - plateVal := fmt.Sprintf("%v", p.Plate) - return fmt.Sprintf("FinderByPlateArgs({Plate:%s})", plateVal) -} - -// Attributes: -// - Success -type FinderByPlateResult struct { - thrift.IResponse - Success *Automobile `thrift:"success,0,optional" db:"success" json:"success,omitempty"` -} - -func NewFinderByPlateResult() *FinderByPlateResult { - return &FinderByPlateResult{} -} - -var FinderByPlateResult_Success_DEFAULT *Automobile -func (p *FinderByPlateResult) GetSuccess() *Automobile { - if !p.IsSetSuccess() { - return FinderByPlateResult_Success_DEFAULT - } - return p.Success -} -func (p *FinderByPlateResult) DefaultGetSuccess() *Automobile { - if !p.IsSetSuccess() { - return NewAutomobile() - } - return p.Success -} -func (p *FinderByPlateResult) IsSetSuccess() bool { - return p != nil && p.Success != nil -} - -type FinderByPlateResultBuilder struct { - obj *FinderByPlateResult -} - -func NewFinderByPlateResultBuilder() *FinderByPlateResultBuilder{ - return &FinderByPlateResultBuilder{ - obj: NewFinderByPlateResult(), - } -} - -func (p FinderByPlateResultBuilder) Emit() *FinderByPlateResult{ - return &FinderByPlateResult{ - Success: p.obj.Success, - } -} - -func (f *FinderByPlateResultBuilder) Success(success *Automobile) *FinderByPlateResultBuilder { - f.obj.Success = success - return f -} - -func (f *FinderByPlateResult) SetSuccess(success *Automobile) *FinderByPlateResult { - f.Success = success - return f -} - -func (p *FinderByPlateResult) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 0: - if err := p.ReadField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *FinderByPlateResult) ReadField0(iprot thrift.Protocol) error { - p.Success = NewAutomobile() - if err := p.Success.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) - } - return nil -} - -func (p *FinderByPlateResult) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("byPlate_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField0(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *FinderByPlateResult) writeField0(oprot thrift.Protocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := p.Success.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } - } - return err -} - -func (p *FinderByPlateResult) String() string { - if p == nil { - return "" - } - - var successVal string - if p.Success == nil { - successVal = "" - } else { - successVal = fmt.Sprintf("%v", p.Success) - } - return fmt.Sprintf("FinderByPlateResult({Success:%s})", successVal) -} - -// Attributes: -// - Plate -type FinderAliasByPlateArgs struct { - thrift.IRequest - Plate Plate `thrift:"plate,1" db:"plate" json:"plate"` -} - -func NewFinderAliasByPlateArgs() *FinderAliasByPlateArgs { - return &FinderAliasByPlateArgs{} -} - - -func (p *FinderAliasByPlateArgs) GetPlate() Plate { - return p.Plate -} -type FinderAliasByPlateArgsBuilder struct { - obj *FinderAliasByPlateArgs -} - -func NewFinderAliasByPlateArgsBuilder() *FinderAliasByPlateArgsBuilder{ - return &FinderAliasByPlateArgsBuilder{ - obj: NewFinderAliasByPlateArgs(), - } -} - -func (p FinderAliasByPlateArgsBuilder) Emit() *FinderAliasByPlateArgs{ - return &FinderAliasByPlateArgs{ - Plate: p.obj.Plate, - } -} - -func (f *FinderAliasByPlateArgsBuilder) Plate(plate Plate) *FinderAliasByPlateArgsBuilder { - f.obj.Plate = plate - return f -} - -func (f *FinderAliasByPlateArgs) SetPlate(plate Plate) *FinderAliasByPlateArgs { - f.Plate = plate - return f -} - -func (p *FinderAliasByPlateArgs) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *FinderAliasByPlateArgs) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - temp := Plate(v) - p.Plate = temp - } - return nil -} - -func (p *FinderAliasByPlateArgs) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("aliasByPlate_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *FinderAliasByPlateArgs) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("plate", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:plate: ", p), err) } - if err := oprot.WriteString(string(p.Plate)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.plate (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:plate: ", p), err) } - return err -} - -func (p *FinderAliasByPlateArgs) String() string { - if p == nil { - return "" - } - - plateVal := fmt.Sprintf("%v", p.Plate) - return fmt.Sprintf("FinderAliasByPlateArgs({Plate:%s})", plateVal) -} - -// Attributes: -// - Success -type FinderAliasByPlateResult struct { - thrift.IResponse - Success *Car `thrift:"success,0,optional" db:"success" json:"success,omitempty"` -} - -func NewFinderAliasByPlateResult() *FinderAliasByPlateResult { - return &FinderAliasByPlateResult{} -} - -var FinderAliasByPlateResult_Success_DEFAULT *Car -func (p *FinderAliasByPlateResult) GetSuccess() *Car { - if !p.IsSetSuccess() { - return FinderAliasByPlateResult_Success_DEFAULT - } - return p.Success -} -func (p *FinderAliasByPlateResult) IsSetSuccess() bool { - return p != nil && p.Success != nil -} - -type FinderAliasByPlateResultBuilder struct { - obj *FinderAliasByPlateResult -} - -func NewFinderAliasByPlateResultBuilder() *FinderAliasByPlateResultBuilder{ - return &FinderAliasByPlateResultBuilder{ - obj: NewFinderAliasByPlateResult(), - } -} - -func (p FinderAliasByPlateResultBuilder) Emit() *FinderAliasByPlateResult{ - return &FinderAliasByPlateResult{ - Success: p.obj.Success, - } -} - -func (f *FinderAliasByPlateResultBuilder) Success(success *Car) *FinderAliasByPlateResultBuilder { - f.obj.Success = success - return f -} - -func (f *FinderAliasByPlateResult) SetSuccess(success *Car) *FinderAliasByPlateResult { - f.Success = success - return f -} - -func (p *FinderAliasByPlateResult) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 0: - if err := p.ReadField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *FinderAliasByPlateResult) ReadField0(iprot thrift.Protocol) error { - p.Success = NewCar() - if err := p.Success.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) - } - return nil -} - -func (p *FinderAliasByPlateResult) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("aliasByPlate_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField0(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *FinderAliasByPlateResult) writeField0(oprot thrift.Protocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := p.Success.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } - } - return err -} - -func (p *FinderAliasByPlateResult) String() string { - if p == nil { - return "" - } - - var successVal string - if p.Success == nil { - successVal = "" - } else { - successVal = fmt.Sprintf("%v", p.Success) - } - return fmt.Sprintf("FinderAliasByPlateResult({Success:%s})", successVal) -} - -// Attributes: -// - Plate -type FinderPreviousPlateArgs struct { - thrift.IRequest - Plate Plate `thrift:"plate,1" db:"plate" json:"plate"` -} - -func NewFinderPreviousPlateArgs() *FinderPreviousPlateArgs { - return &FinderPreviousPlateArgs{} -} - - -func (p *FinderPreviousPlateArgs) GetPlate() Plate { - return p.Plate -} -type FinderPreviousPlateArgsBuilder struct { - obj *FinderPreviousPlateArgs -} - -func NewFinderPreviousPlateArgsBuilder() *FinderPreviousPlateArgsBuilder{ - return &FinderPreviousPlateArgsBuilder{ - obj: NewFinderPreviousPlateArgs(), - } -} - -func (p FinderPreviousPlateArgsBuilder) Emit() *FinderPreviousPlateArgs{ - return &FinderPreviousPlateArgs{ - Plate: p.obj.Plate, - } -} - -func (f *FinderPreviousPlateArgsBuilder) Plate(plate Plate) *FinderPreviousPlateArgsBuilder { - f.obj.Plate = plate - return f -} - -func (f *FinderPreviousPlateArgs) SetPlate(plate Plate) *FinderPreviousPlateArgs { - f.Plate = plate - return f -} - -func (p *FinderPreviousPlateArgs) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *FinderPreviousPlateArgs) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - temp := Plate(v) - p.Plate = temp - } - return nil -} - -func (p *FinderPreviousPlateArgs) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("previousPlate_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *FinderPreviousPlateArgs) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("plate", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:plate: ", p), err) } - if err := oprot.WriteString(string(p.Plate)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.plate (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:plate: ", p), err) } - return err -} - -func (p *FinderPreviousPlateArgs) String() string { - if p == nil { - return "" - } - - plateVal := fmt.Sprintf("%v", p.Plate) - return fmt.Sprintf("FinderPreviousPlateArgs({Plate:%s})", plateVal) -} - -// Attributes: -// - Success -type FinderPreviousPlateResult struct { - thrift.IResponse - Success *Plate `thrift:"success,0,optional" db:"success" json:"success,omitempty"` -} - -func NewFinderPreviousPlateResult() *FinderPreviousPlateResult { - return &FinderPreviousPlateResult{} -} - -var FinderPreviousPlateResult_Success_DEFAULT Plate -func (p *FinderPreviousPlateResult) GetSuccess() Plate { - if !p.IsSetSuccess() { - return FinderPreviousPlateResult_Success_DEFAULT - } - return *p.Success -} -func (p *FinderPreviousPlateResult) IsSetSuccess() bool { - return p != nil && p.Success != nil -} - -type FinderPreviousPlateResultBuilder struct { - obj *FinderPreviousPlateResult -} - -func NewFinderPreviousPlateResultBuilder() *FinderPreviousPlateResultBuilder{ - return &FinderPreviousPlateResultBuilder{ - obj: NewFinderPreviousPlateResult(), - } -} - -func (p FinderPreviousPlateResultBuilder) Emit() *FinderPreviousPlateResult{ - return &FinderPreviousPlateResult{ - Success: p.obj.Success, - } -} - -func (f *FinderPreviousPlateResultBuilder) Success(success *Plate) *FinderPreviousPlateResultBuilder { - f.obj.Success = success - return f -} - -func (f *FinderPreviousPlateResult) SetSuccess(success *Plate) *FinderPreviousPlateResult { - f.Success = success - return f -} - -func (p *FinderPreviousPlateResult) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 0: - if err := p.ReadField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *FinderPreviousPlateResult) ReadField0(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - temp := Plate(v) - p.Success = &temp - } - return nil -} - -func (p *FinderPreviousPlateResult) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("previousPlate_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField0(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *FinderPreviousPlateResult) writeField0(oprot thrift.Protocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRING, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := oprot.WriteString(string(*p.Success)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.success (0) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } - } - return err -} - -func (p *FinderPreviousPlateResult) String() string { - if p == nil { - return "" - } - - var successVal string - if p.Success == nil { - successVal = "" - } else { - successVal = fmt.Sprintf("%v", *p.Success) - } - return fmt.Sprintf("FinderPreviousPlateResult({Success:%s})", successVal) -} - - diff --git a/thrift/compiler/test/fixtures/go-typedef/gen-go/module1/ttypes.go b/thrift/compiler/test/fixtures/go-typedef/gen-go/module1/ttypes.go deleted file mode 100644 index 2e6fed5dd44..00000000000 --- a/thrift/compiler/test/fixtures/go-typedef/gen-go/module1/ttypes.go +++ /dev/null @@ -1,1190 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package module1 - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" - module00 "module0" - -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var _ = module00.GoUnusedProtection__ -var GoUnusedProtection__ int; - -type Plate = string - -func PlatePtr(v Plate) *Plate { return &v } - -type State = string - -func StatePtr(v State) *State { return &v } - -type Year = int32 - -func YearPtr(v Year) *Year { return &v } - -type Drivers = []string - -func DriversPtr(v Drivers) *Drivers { return &v } - -type Accessory = module00.Accessory - -func AccessoryPtr(v Accessory) *Accessory { return &v } - -func NewAccessory() *Accessory { return module00.NewAccessory() } - -type PartName = module00.PartName - -func PartNamePtr(v PartName) *PartName { return &v } - -func NewPartName() *PartName { return module00.NewPartName() } - -type Car = Automobile - -func CarPtr(v Car) *Car { return &v } - -func NewCar() *Car { return NewAutomobile() } - -// Attributes: -// - Plate -// - PreviousPlate -// - FirstPlate -// - Year -// - Drivers -// - Accessories -// - PartNames -type Automobile struct { - Plate Plate `thrift:"plate,1" db:"plate" json:"plate"` - PreviousPlate *Plate `thrift:"previous_plate,2,optional" db:"previous_plate" json:"previous_plate,omitempty"` - FirstPlate Plate `thrift:"first_plate,3,optional" db:"first_plate" json:"first_plate,omitempty"` - Year Year `thrift:"year,4" db:"year" json:"year"` - Drivers Drivers `thrift:"drivers,5" db:"drivers" json:"drivers"` - Accessories []*Accessory `thrift:"Accessories,6" db:"Accessories" json:"Accessories"` - PartNames map[int32]*PartName `thrift:"PartNames,7" db:"PartNames" json:"PartNames"` -} - -func NewAutomobile() *Automobile { - return &Automobile{ - FirstPlate: "0000", - } -} - - -func (p *Automobile) GetPlate() Plate { - return p.Plate -} -var Automobile_PreviousPlate_DEFAULT Plate -func (p *Automobile) GetPreviousPlate() Plate { - if !p.IsSetPreviousPlate() { - return Automobile_PreviousPlate_DEFAULT - } - return *p.PreviousPlate -} -var Automobile_FirstPlate_DEFAULT Plate = "0000" - -func (p *Automobile) GetFirstPlate() Plate { - return p.FirstPlate -} - -func (p *Automobile) GetYear() Year { - return p.Year -} - -func (p *Automobile) GetDrivers() Drivers { - return p.Drivers -} - -func (p *Automobile) GetAccessories() []*Accessory { - return p.Accessories -} - -func (p *Automobile) GetPartNames() map[int32]*PartName { - return p.PartNames -} -func (p *Automobile) IsSetPreviousPlate() bool { - return p != nil && p.PreviousPlate != nil -} - -func (p *Automobile) IsSetFirstPlate() bool { - return p != nil && p.FirstPlate != Automobile_FirstPlate_DEFAULT -} - -type AutomobileBuilder struct { - obj *Automobile -} - -func NewAutomobileBuilder() *AutomobileBuilder{ - return &AutomobileBuilder{ - obj: NewAutomobile(), - } -} - -func (p AutomobileBuilder) Emit() *Automobile{ - return &Automobile{ - Plate: p.obj.Plate, - PreviousPlate: p.obj.PreviousPlate, - FirstPlate: p.obj.FirstPlate, - Year: p.obj.Year, - Drivers: p.obj.Drivers, - Accessories: p.obj.Accessories, - PartNames: p.obj.PartNames, - } -} - -func (a *AutomobileBuilder) Plate(plate Plate) *AutomobileBuilder { - a.obj.Plate = plate - return a -} - -func (a *AutomobileBuilder) PreviousPlate(previousPlate *Plate) *AutomobileBuilder { - a.obj.PreviousPlate = previousPlate - return a -} - -func (a *AutomobileBuilder) FirstPlate(firstPlate Plate) *AutomobileBuilder { - a.obj.FirstPlate = firstPlate - return a -} - -func (a *AutomobileBuilder) Year(year Year) *AutomobileBuilder { - a.obj.Year = year - return a -} - -func (a *AutomobileBuilder) Drivers(drivers Drivers) *AutomobileBuilder { - a.obj.Drivers = drivers - return a -} - -func (a *AutomobileBuilder) Accessories(accessories []*Accessory) *AutomobileBuilder { - a.obj.Accessories = accessories - return a -} - -func (a *AutomobileBuilder) PartNames(partNames map[int32]*PartName) *AutomobileBuilder { - a.obj.PartNames = partNames - return a -} - -func (a *Automobile) SetPlate(plate Plate) *Automobile { - a.Plate = plate - return a -} - -func (a *Automobile) SetPreviousPlate(previousPlate *Plate) *Automobile { - a.PreviousPlate = previousPlate - return a -} - -func (a *Automobile) SetFirstPlate(firstPlate Plate) *Automobile { - a.FirstPlate = firstPlate - return a -} - -func (a *Automobile) SetYear(year Year) *Automobile { - a.Year = year - return a -} - -func (a *Automobile) SetDrivers(drivers Drivers) *Automobile { - a.Drivers = drivers - return a -} - -func (a *Automobile) SetAccessories(accessories []*Accessory) *Automobile { - a.Accessories = accessories - return a -} - -func (a *Automobile) SetPartNames(partNames map[int32]*PartName) *Automobile { - a.PartNames = partNames - return a -} - -func (p *Automobile) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 3: - if err := p.ReadField3(iprot); err != nil { - return err - } - case 4: - if err := p.ReadField4(iprot); err != nil { - return err - } - case 5: - if err := p.ReadField5(iprot); err != nil { - return err - } - case 6: - if err := p.ReadField6(iprot); err != nil { - return err - } - case 7: - if err := p.ReadField7(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Automobile) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - temp := Plate(v) - p.Plate = temp - } - return nil -} - -func (p *Automobile) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - temp := Plate(v) - p.PreviousPlate = &temp - } - return nil -} - -func (p *Automobile) ReadField3(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 3: ", err) - } else { - temp := Plate(v) - p.FirstPlate = temp - } - return nil -} - -func (p *Automobile) ReadField4(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 4: ", err) - } else { - temp := Year(v) - p.Year = temp - } - return nil -} - -func (p *Automobile) ReadField5(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make(Drivers, 0, size) - p.Drivers = tSlice - for i := 0; i < size; i ++ { - var _elem1 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem1 = v - } - p.Drivers = append(p.Drivers, _elem1) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *Automobile) ReadField6(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]*Accessory, 0, size) - p.Accessories = tSlice - for i := 0; i < size; i ++ { - _elem2 := NewAccessory() - if err := _elem2.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem2), err) - } - p.Accessories = append(p.Accessories, _elem2) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *Automobile) ReadField7(iprot thrift.Protocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[int32]*PartName, size) - p.PartNames = tMap - for i := 0; i < size; i ++ { - var _key3 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key3 = v - } - _val4 := NewPartName() - if err := _val4.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _val4), err) - } - p.PartNames[_key3] = _val4 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *Automobile) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Automobile"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := p.writeField4(oprot); err != nil { return err } - if err := p.writeField5(oprot); err != nil { return err } - if err := p.writeField6(oprot); err != nil { return err } - if err := p.writeField7(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Automobile) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("plate", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:plate: ", p), err) } - if err := oprot.WriteString(string(p.Plate)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.plate (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:plate: ", p), err) } - return err -} - -func (p *Automobile) writeField2(oprot thrift.Protocol) (err error) { - if p.IsSetPreviousPlate() { - if err := oprot.WriteFieldBegin("previous_plate", thrift.STRING, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:previous_plate: ", p), err) } - if err := oprot.WriteString(string(*p.PreviousPlate)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.previous_plate (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:previous_plate: ", p), err) } - } - return err -} - -func (p *Automobile) writeField3(oprot thrift.Protocol) (err error) { - if p.IsSetFirstPlate() { - if err := oprot.WriteFieldBegin("first_plate", thrift.STRING, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:first_plate: ", p), err) } - if err := oprot.WriteString(string(p.FirstPlate)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.first_plate (3) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:first_plate: ", p), err) } - } - return err -} - -func (p *Automobile) writeField4(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("year", thrift.I32, 4); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:year: ", p), err) } - if err := oprot.WriteI32(int32(p.Year)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.year (4) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 4:year: ", p), err) } - return err -} - -func (p *Automobile) writeField5(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("drivers", thrift.LIST, 5); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:drivers: ", p), err) } - if err := oprot.WriteListBegin(thrift.STRING, len(p.Drivers)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.Drivers { - if err := oprot.WriteString(string(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 5:drivers: ", p), err) } - return err -} - -func (p *Automobile) writeField6(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("Accessories", thrift.LIST, 6); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 6:Accessories: ", p), err) } - if err := oprot.WriteListBegin(thrift.STRUCT, len(p.Accessories)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.Accessories { - if err := v.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) - } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 6:Accessories: ", p), err) } - return err -} - -func (p *Automobile) writeField7(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("PartNames", thrift.MAP, 7); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 7:PartNames: ", p), err) } - if err := oprot.WriteMapBegin(thrift.I32, thrift.STRUCT, len(p.PartNames)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.PartNames { - if err := oprot.WriteI32(int32(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := v.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) - } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 7:PartNames: ", p), err) } - return err -} - -func (p *Automobile) String() string { - if p == nil { - return "" - } - - plateVal := fmt.Sprintf("%v", p.Plate) - var previousPlateVal string - if p.PreviousPlate == nil { - previousPlateVal = "" - } else { - previousPlateVal = fmt.Sprintf("%v", *p.PreviousPlate) - } - firstPlateVal := fmt.Sprintf("%v", p.FirstPlate) - yearVal := fmt.Sprintf("%v", p.Year) - driversVal := fmt.Sprintf("%v", p.Drivers) - accessoriesVal := fmt.Sprintf("%v", p.Accessories) - partNamesVal := fmt.Sprintf("%v", p.PartNames) - return fmt.Sprintf("Automobile({Plate:%s PreviousPlate:%s FirstPlate:%s Year:%s Drivers:%s Accessories:%s PartNames:%s})", plateVal, previousPlateVal, firstPlateVal, yearVal, driversVal, accessoriesVal, partNamesVal) -} - -// Attributes: -// - Num -// - Strval -type MapKey struct { - Num int64 `thrift:"num,1" db:"num" json:"num"` - Strval string `thrift:"strval,2" db:"strval" json:"strval"` -} - -func NewMapKey() *MapKey { - return &MapKey{} -} - - -func (p *MapKey) GetNum() int64 { - return p.Num -} - -func (p *MapKey) GetStrval() string { - return p.Strval -} -type MapKeyBuilder struct { - obj *MapKey -} - -func NewMapKeyBuilder() *MapKeyBuilder{ - return &MapKeyBuilder{ - obj: NewMapKey(), - } -} - -func (p MapKeyBuilder) Emit() *MapKey{ - return &MapKey{ - Num: p.obj.Num, - Strval: p.obj.Strval, - } -} - -func (m *MapKeyBuilder) Num(num int64) *MapKeyBuilder { - m.obj.Num = num - return m -} - -func (m *MapKeyBuilder) Strval(strval string) *MapKeyBuilder { - m.obj.Strval = strval - return m -} - -func (m *MapKey) SetNum(num int64) *MapKey { - m.Num = num - return m -} - -func (m *MapKey) SetStrval(strval string) *MapKey { - m.Strval = strval - return m -} - -func (p *MapKey) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MapKey) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Num = v - } - return nil -} - -func (p *MapKey) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Strval = v - } - return nil -} - -func (p *MapKey) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("MapKey"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MapKey) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("num", thrift.I64, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:num: ", p), err) } - if err := oprot.WriteI64(int64(p.Num)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.num (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:num: ", p), err) } - return err -} - -func (p *MapKey) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("strval", thrift.STRING, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:strval: ", p), err) } - if err := oprot.WriteString(string(p.Strval)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.strval (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:strval: ", p), err) } - return err -} - -func (p *MapKey) String() string { - if p == nil { - return "" - } - - numVal := fmt.Sprintf("%v", p.Num) - strvalVal := fmt.Sprintf("%v", p.Strval) - return fmt.Sprintf("MapKey({Num:%s Strval:%s})", numVal, strvalVal) -} - -// Attributes: -// - Mapval -type MapContainer struct { - Mapval map[MapKey]string `thrift:"mapval,1" db:"mapval" json:"mapval"` -} - -func NewMapContainer() *MapContainer { - return &MapContainer{} -} - - -func (p *MapContainer) GetMapval() map[MapKey]string { - return p.Mapval -} -type MapContainerBuilder struct { - obj *MapContainer -} - -func NewMapContainerBuilder() *MapContainerBuilder{ - return &MapContainerBuilder{ - obj: NewMapContainer(), - } -} - -func (p MapContainerBuilder) Emit() *MapContainer{ - return &MapContainer{ - Mapval: p.obj.Mapval, - } -} - -func (m *MapContainerBuilder) Mapval(mapval map[MapKey]string) *MapContainerBuilder { - m.obj.Mapval = mapval - return m -} - -func (m *MapContainer) SetMapval(mapval map[MapKey]string) *MapContainer { - m.Mapval = mapval - return m -} - -func (p *MapContainer) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MapContainer) ReadField1(iprot thrift.Protocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[MapKey]string, size) - p.Mapval = tMap - for i := 0; i < size; i ++ { - _key5 := NewMapKey() - if err := _key5.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _key5), err) - } - var _val6 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _val6 = v - } - p.Mapval[*_key5] = _val6 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *MapContainer) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("MapContainer"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MapContainer) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("mapval", thrift.MAP, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:mapval: ", p), err) } - if err := oprot.WriteMapBegin(thrift.STRUCT, thrift.STRING, len(p.Mapval)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.Mapval { - if err := k.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", k), err) - } - if err := oprot.WriteString(string(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:mapval: ", p), err) } - return err -} - -func (p *MapContainer) String() string { - if p == nil { - return "" - } - - mapvalVal := fmt.Sprintf("%v", p.Mapval) - return fmt.Sprintf("MapContainer({Mapval:%s})", mapvalVal) -} - -// Attributes: -// - Automobile -// - Car -type Pair struct { - Automobile *Automobile `thrift:"automobile,1" db:"automobile" json:"automobile"` - Car *Car `thrift:"car,2" db:"car" json:"car"` -} - -func NewPair() *Pair { - return &Pair{ - Automobile: NewAutomobile(), - Car: NewCar(), - } -} - -var Pair_Automobile_DEFAULT *Automobile -func (p *Pair) GetAutomobile() *Automobile { - if !p.IsSetAutomobile() { - return Pair_Automobile_DEFAULT - } - return p.Automobile -} -func (p *Pair) DefaultGetAutomobile() *Automobile { - if !p.IsSetAutomobile() { - return NewAutomobile() - } - return p.Automobile -} -var Pair_Car_DEFAULT *Car -func (p *Pair) GetCar() *Car { - if !p.IsSetCar() { - return Pair_Car_DEFAULT - } - return p.Car -} -func (p *Pair) IsSetAutomobile() bool { - return p != nil && p.Automobile != nil -} - -func (p *Pair) IsSetCar() bool { - return p != nil && p.Car != nil -} - -type PairBuilder struct { - obj *Pair -} - -func NewPairBuilder() *PairBuilder{ - return &PairBuilder{ - obj: NewPair(), - } -} - -func (p PairBuilder) Emit() *Pair{ - return &Pair{ - Automobile: p.obj.Automobile, - Car: p.obj.Car, - } -} - -func (p *PairBuilder) Automobile(automobile *Automobile) *PairBuilder { - p.obj.Automobile = automobile - return p -} - -func (p *PairBuilder) Car(car *Car) *PairBuilder { - p.obj.Car = car - return p -} - -func (p *Pair) SetAutomobile(automobile *Automobile) *Pair { - p.Automobile = automobile - return p -} - -func (p *Pair) SetCar(car *Car) *Pair { - p.Car = car - return p -} - -func (p *Pair) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Pair) ReadField1(iprot thrift.Protocol) error { - p.Automobile = NewAutomobile() - if err := p.Automobile.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Automobile), err) - } - return nil -} - -func (p *Pair) ReadField2(iprot thrift.Protocol) error { - p.Car = NewCar() - if err := p.Car.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Car), err) - } - return nil -} - -func (p *Pair) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Pair"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Pair) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("automobile", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:automobile: ", p), err) } - if err := p.Automobile.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Automobile), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:automobile: ", p), err) } - return err -} - -func (p *Pair) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("car", thrift.STRUCT, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:car: ", p), err) } - if err := p.Car.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Car), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:car: ", p), err) } - return err -} - -func (p *Pair) String() string { - if p == nil { - return "" - } - - var automobileVal string - if p.Automobile == nil { - automobileVal = "" - } else { - automobileVal = fmt.Sprintf("%v", p.Automobile) - } - var carVal string - if p.Car == nil { - carVal = "" - } else { - carVal = fmt.Sprintf("%v", p.Car) - } - return fmt.Sprintf("Pair({Automobile:%s Car:%s})", automobileVal, carVal) -} - -// Attributes: -// - Automobiles -// - Cars -type Collection struct { - Automobiles []*Automobile `thrift:"automobiles,1" db:"automobiles" json:"automobiles"` - Cars []*Car `thrift:"cars,2" db:"cars" json:"cars"` -} - -func NewCollection() *Collection { - return &Collection{} -} - - -func (p *Collection) GetAutomobiles() []*Automobile { - return p.Automobiles -} - -func (p *Collection) GetCars() []*Car { - return p.Cars -} -type CollectionBuilder struct { - obj *Collection -} - -func NewCollectionBuilder() *CollectionBuilder{ - return &CollectionBuilder{ - obj: NewCollection(), - } -} - -func (p CollectionBuilder) Emit() *Collection{ - return &Collection{ - Automobiles: p.obj.Automobiles, - Cars: p.obj.Cars, - } -} - -func (c *CollectionBuilder) Automobiles(automobiles []*Automobile) *CollectionBuilder { - c.obj.Automobiles = automobiles - return c -} - -func (c *CollectionBuilder) Cars(cars []*Car) *CollectionBuilder { - c.obj.Cars = cars - return c -} - -func (c *Collection) SetAutomobiles(automobiles []*Automobile) *Collection { - c.Automobiles = automobiles - return c -} - -func (c *Collection) SetCars(cars []*Car) *Collection { - c.Cars = cars - return c -} - -func (p *Collection) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Collection) ReadField1(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]*Automobile, 0, size) - p.Automobiles = tSlice - for i := 0; i < size; i ++ { - _elem7 := NewAutomobile() - if err := _elem7.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem7), err) - } - p.Automobiles = append(p.Automobiles, _elem7) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *Collection) ReadField2(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]*Car, 0, size) - p.Cars = tSlice - for i := 0; i < size; i ++ { - _elem8 := NewCar() - if err := _elem8.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem8), err) - } - p.Cars = append(p.Cars, _elem8) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *Collection) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Collection"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Collection) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("automobiles", thrift.LIST, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:automobiles: ", p), err) } - if err := oprot.WriteListBegin(thrift.STRUCT, len(p.Automobiles)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.Automobiles { - if err := v.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) - } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:automobiles: ", p), err) } - return err -} - -func (p *Collection) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("cars", thrift.LIST, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:cars: ", p), err) } - if err := oprot.WriteListBegin(thrift.STRUCT, len(p.Cars)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.Cars { - if err := v.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) - } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:cars: ", p), err) } - return err -} - -func (p *Collection) String() string { - if p == nil { - return "" - } - - automobilesVal := fmt.Sprintf("%v", p.Automobiles) - carsVal := fmt.Sprintf("%v", p.Cars) - return fmt.Sprintf("Collection({Automobiles:%s Cars:%s})", automobilesVal, carsVal) -} - diff --git a/thrift/compiler/test/fixtures/go-typedef/gen-go/module2/constants.go b/thrift/compiler/test/fixtures/go-typedef/gen-go/module2/constants.go deleted file mode 100644 index 9c5d8c0cd15..00000000000 --- a/thrift/compiler/test/fixtures/go-typedef/gen-go/module2/constants.go +++ /dev/null @@ -1,25 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package module2 - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - - -func init() { -} - diff --git a/thrift/compiler/test/fixtures/go-typedef/gen-go/module2/ttypes.go b/thrift/compiler/test/fixtures/go-typedef/gen-go/module2/ttypes.go deleted file mode 100644 index d30da3f1aa6..00000000000 --- a/thrift/compiler/test/fixtures/go-typedef/gen-go/module2/ttypes.go +++ /dev/null @@ -1,70 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package module2 - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var GoUnusedProtection__ int; - -type Enum int64 -const ( - Enum_A Enum = 0 - Enum_B Enum = 1 - Enum_C Enum = 2 -) - -var EnumToName = map[Enum]string { - Enum_A: "A", - Enum_B: "B", - Enum_C: "C", -} - -var EnumToValue = map[string]Enum { - "A": Enum_A, - "B": Enum_B, - "C": Enum_C, -} - -var EnumNames = []string { - "A", - "B", - "C", -} - -var EnumValues = []Enum { - Enum_A, - Enum_B, - Enum_C, -} - -func (p Enum) String() string { - if v, ok := EnumToName[p]; ok { - return v - } - return "" -} - -func EnumFromString(s string) (Enum, error) { - if v, ok := EnumToValue[s]; ok { - return v, nil - } - return Enum(0), fmt.Errorf("not a valid Enum string") -} - -func EnumPtr(v Enum) *Enum { return &v } - diff --git a/thrift/compiler/test/fixtures/go-typedef/gen-go/thrift/annotation/go/constants.go b/thrift/compiler/test/fixtures/go-typedef/gen-go/thrift/annotation/go/constants.go deleted file mode 100644 index 1e70fdfe4c3..00000000000 --- a/thrift/compiler/test/fixtures/go-typedef/gen-go/thrift/annotation/go/constants.go +++ /dev/null @@ -1,25 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package go - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - - -func init() { -} - diff --git a/thrift/compiler/test/fixtures/go-typedef/gen-go/thrift/annotation/go/ttypes.go b/thrift/compiler/test/fixtures/go-typedef/gen-go/thrift/annotation/go/ttypes.go deleted file mode 100644 index dd186114d3a..00000000000 --- a/thrift/compiler/test/fixtures/go-typedef/gen-go/thrift/annotation/go/ttypes.go +++ /dev/null @@ -1,310 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package go - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var GoUnusedProtection__ int; - -// Attributes: -// - Name -type Name struct { - Name string `thrift:"name,1" db:"name" json:"name"` -} - -func NewName() *Name { - return &Name{} -} - - -func (p *Name) GetName() string { - return p.Name -} -type NameBuilder struct { - obj *Name -} - -func NewNameBuilder() *NameBuilder{ - return &NameBuilder{ - obj: NewName(), - } -} - -func (p NameBuilder) Emit() *Name{ - return &Name{ - Name: p.obj.Name, - } -} - -func (n *NameBuilder) Name(name string) *NameBuilder { - n.obj.Name = name - return n -} - -func (n *Name) SetName(name string) *Name { - n.Name = name - return n -} - -func (p *Name) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Name) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Name = v - } - return nil -} - -func (p *Name) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Name"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Name) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) } - if err := oprot.WriteString(string(p.Name)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) } - return err -} - -func (p *Name) String() string { - if p == nil { - return "" - } - - nameVal := fmt.Sprintf("%v", p.Name) - return fmt.Sprintf("Name({Name:%s})", nameVal) -} - -// Attributes: -// - Tag -type Tag struct { - Tag string `thrift:"tag,1" db:"tag" json:"tag"` -} - -func NewTag() *Tag { - return &Tag{} -} - - -func (p *Tag) GetTag() string { - return p.Tag -} -type TagBuilder struct { - obj *Tag -} - -func NewTagBuilder() *TagBuilder{ - return &TagBuilder{ - obj: NewTag(), - } -} - -func (p TagBuilder) Emit() *Tag{ - return &Tag{ - Tag: p.obj.Tag, - } -} - -func (t *TagBuilder) Tag(tag string) *TagBuilder { - t.obj.Tag = tag - return t -} - -func (t *Tag) SetTag(tag string) *Tag { - t.Tag = tag - return t -} - -func (p *Tag) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Tag) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Tag = v - } - return nil -} - -func (p *Tag) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Tag"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Tag) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("tag", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:tag: ", p), err) } - if err := oprot.WriteString(string(p.Tag)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.tag (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:tag: ", p), err) } - return err -} - -func (p *Tag) String() string { - if p == nil { - return "" - } - - tagVal := fmt.Sprintf("%v", p.Tag) - return fmt.Sprintf("Tag({Tag:%s})", tagVal) -} - -type NewType_ struct { -} - -func NewNewType_() *NewType_ { - return &NewType_{} -} - -type NewType_Builder struct { - obj *NewType_ -} - -func NewNewType_Builder() *NewType_Builder{ - return &NewType_Builder{ - obj: NewNewType_(), - } -} - -func (p NewType_Builder) Emit() *NewType_{ - return &NewType_{ - } -} - -func (p *NewType_) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *NewType_) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("NewType"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *NewType_) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("NewType_({})") -} - diff --git a/thrift/compiler/test/fixtures/go-typedef/gen-go/thrift/annotation/scope/constants.go b/thrift/compiler/test/fixtures/go-typedef/gen-go/thrift/annotation/scope/constants.go deleted file mode 100644 index 0c3448a7126..00000000000 --- a/thrift/compiler/test/fixtures/go-typedef/gen-go/thrift/annotation/scope/constants.go +++ /dev/null @@ -1,25 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package scope - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - - -func init() { -} - diff --git a/thrift/compiler/test/fixtures/go-typedef/gen-go/thrift/annotation/scope/ttypes.go b/thrift/compiler/test/fixtures/go-typedef/gen-go/thrift/annotation/scope/ttypes.go deleted file mode 100644 index 580c39e775c..00000000000 --- a/thrift/compiler/test/fixtures/go-typedef/gen-go/thrift/annotation/scope/ttypes.go +++ /dev/null @@ -1,1169 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package scope - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var GoUnusedProtection__ int; - -// Indicates that the scope of sibling annotations is transitive. -// -// For example: -// -// @scope.Struct -// @scope.Union -// @scope.Exception -// @scope.Transitive -// struct Structured {} -// -// Annotating a Thrift struct with @Structured automatically applies -// @scope.Struct, @scope.Union and @scope.Exception annotations, i.e. -// -// @Structured -// struct MyAnnotation {} -// -// is equivalent to -// -// @scope.Struct -// @scope.Union -// @scope.Exception -// struct MyAnnotation {} -// -type Transitive struct { -} - -func NewTransitive() *Transitive { - return &Transitive{} -} - -type TransitiveBuilder struct { - obj *Transitive -} - -func NewTransitiveBuilder() *TransitiveBuilder{ - return &TransitiveBuilder{ - obj: NewTransitive(), - } -} - -func (p TransitiveBuilder) Emit() *Transitive{ - return &Transitive{ - } -} - -func (p *Transitive) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Transitive) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Transitive"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Transitive) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Transitive({})") -} - -// The Program scope. -// -// This allows annotations on the `package` definition, which implies the -// annotaiton applies to the entire program. -type Program struct { -} - -func NewProgram() *Program { - return &Program{} -} - -type ProgramBuilder struct { - obj *Program -} - -func NewProgramBuilder() *ProgramBuilder{ - return &ProgramBuilder{ - obj: NewProgram(), - } -} - -func (p ProgramBuilder) Emit() *Program{ - return &Program{ - } -} - -func (p *Program) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Program) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Program"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Program) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Program({})") -} - -// The `struct` definition scope. -type Struct struct { -} - -func NewStruct() *Struct { - return &Struct{} -} - -type StructBuilder struct { - obj *Struct -} - -func NewStructBuilder() *StructBuilder{ - return &StructBuilder{ - obj: NewStruct(), - } -} - -func (p StructBuilder) Emit() *Struct{ - return &Struct{ - } -} - -func (p *Struct) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Struct) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Struct"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Struct) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Struct({})") -} - -// The `union` definition scope. -type Union struct { -} - -func NewUnion() *Union { - return &Union{} -} - -type UnionBuilder struct { - obj *Union -} - -func NewUnionBuilder() *UnionBuilder{ - return &UnionBuilder{ - obj: NewUnion(), - } -} - -func (p UnionBuilder) Emit() *Union{ - return &Union{ - } -} - -func (p *Union) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Union) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Union"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Union) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Union({})") -} - -// The `exception` definition scope. -type Exception struct { -} - -func NewException() *Exception { - return &Exception{} -} - -type ExceptionBuilder struct { - obj *Exception -} - -func NewExceptionBuilder() *ExceptionBuilder{ - return &ExceptionBuilder{ - obj: NewException(), - } -} - -func (p ExceptionBuilder) Emit() *Exception{ - return &Exception{ - } -} - -func (p *Exception) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Exception) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Exception"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Exception) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Exception({})") -} - -// Field declartaions, for example in `struct` or `function` declartions. -type Field struct { -} - -func NewField() *Field { - return &Field{} -} - -type FieldBuilder struct { - obj *Field -} - -func NewFieldBuilder() *FieldBuilder{ - return &FieldBuilder{ - obj: NewField(), - } -} - -func (p FieldBuilder) Emit() *Field{ - return &Field{ - } -} - -func (p *Field) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Field) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Field"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Field) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Field({})") -} - -// The `typedef` definition scope. -type Typedef struct { -} - -func NewTypedef() *Typedef { - return &Typedef{} -} - -type TypedefBuilder struct { - obj *Typedef -} - -func NewTypedefBuilder() *TypedefBuilder{ - return &TypedefBuilder{ - obj: NewTypedef(), - } -} - -func (p TypedefBuilder) Emit() *Typedef{ - return &Typedef{ - } -} - -func (p *Typedef) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Typedef) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Typedef"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Typedef) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Typedef({})") -} - -// The `service` definition scope. -type Service struct { -} - -func NewService() *Service { - return &Service{} -} - -type ServiceBuilder struct { - obj *Service -} - -func NewServiceBuilder() *ServiceBuilder{ - return &ServiceBuilder{ - obj: NewService(), - } -} - -func (p ServiceBuilder) Emit() *Service{ - return &Service{ - } -} - -func (p *Service) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Service) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Service"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Service) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Service({})") -} - -// The `interaction` definition scope. -type Interaction struct { -} - -func NewInteraction() *Interaction { - return &Interaction{} -} - -type InteractionBuilder struct { - obj *Interaction -} - -func NewInteractionBuilder() *InteractionBuilder{ - return &InteractionBuilder{ - obj: NewInteraction(), - } -} - -func (p InteractionBuilder) Emit() *Interaction{ - return &Interaction{ - } -} - -func (p *Interaction) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Interaction) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Interaction"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Interaction) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Interaction({})") -} - -// The `function` definition scope. -type Function struct { -} - -func NewFunction() *Function { - return &Function{} -} - -type FunctionBuilder struct { - obj *Function -} - -func NewFunctionBuilder() *FunctionBuilder{ - return &FunctionBuilder{ - obj: NewFunction(), - } -} - -func (p FunctionBuilder) Emit() *Function{ - return &Function{ - } -} - -func (p *Function) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Function) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Function"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Function) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Function({})") -} - -// The Enum value definition scope. -type EnumValue struct { -} - -func NewEnumValue() *EnumValue { - return &EnumValue{} -} - -type EnumValueBuilder struct { - obj *EnumValue -} - -func NewEnumValueBuilder() *EnumValueBuilder{ - return &EnumValueBuilder{ - obj: NewEnumValue(), - } -} - -func (p EnumValueBuilder) Emit() *EnumValue{ - return &EnumValue{ - } -} - -func (p *EnumValue) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *EnumValue) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("EnumValue"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *EnumValue) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("EnumValue({})") -} - -// The `const` definition scope. -type Const struct { -} - -func NewConst() *Const { - return &Const{} -} - -type ConstBuilder struct { - obj *Const -} - -func NewConstBuilder() *ConstBuilder{ - return &ConstBuilder{ - obj: NewConst(), - } -} - -func (p ConstBuilder) Emit() *Const{ - return &Const{ - } -} - -func (p *Const) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Const) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Const"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Const) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Const({})") -} - -type Enum struct { -} - -func NewEnum() *Enum { - return &Enum{} -} - -type EnumBuilder struct { - obj *Enum -} - -func NewEnumBuilder() *EnumBuilder{ - return &EnumBuilder{ - obj: NewEnum(), - } -} - -func (p EnumBuilder) Emit() *Enum{ - return &Enum{ - } -} - -func (p *Enum) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Enum) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Enum"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Enum) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Enum({})") -} - -// A scope that includes all 'structured' definitions. -type Structured struct { -} - -func NewStructured() *Structured { - return &Structured{} -} - -type StructuredBuilder struct { - obj *Structured -} - -func NewStructuredBuilder() *StructuredBuilder{ - return &StructuredBuilder{ - obj: NewStructured(), - } -} - -func (p StructuredBuilder) Emit() *Structured{ - return &Structured{ - } -} - -func (p *Structured) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Structured) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Structured"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Structured) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Structured({})") -} - -// A scope that includes all 'interface' definitions. -type Interface struct { -} - -func NewInterface() *Interface { - return &Interface{} -} - -type InterfaceBuilder struct { - obj *Interface -} - -func NewInterfaceBuilder() *InterfaceBuilder{ - return &InterfaceBuilder{ - obj: NewInterface(), - } -} - -func (p InterfaceBuilder) Emit() *Interface{ - return &Interface{ - } -} - -func (p *Interface) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Interface) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Interface"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Interface) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Interface({})") -} - -// A scope that includes all program-scoped definition. -type RootDefinition struct { -} - -func NewRootDefinition() *RootDefinition { - return &RootDefinition{} -} - -type RootDefinitionBuilder struct { - obj *RootDefinition -} - -func NewRootDefinitionBuilder() *RootDefinitionBuilder{ - return &RootDefinitionBuilder{ - obj: NewRootDefinition(), - } -} - -func (p RootDefinitionBuilder) Emit() *RootDefinition{ - return &RootDefinition{ - } -} - -func (p *RootDefinition) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *RootDefinition) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("RootDefinition"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *RootDefinition) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("RootDefinition({})") -} - -// A scope that includes all definitions. -type Definition struct { -} - -func NewDefinition() *Definition { - return &Definition{} -} - -type DefinitionBuilder struct { - obj *Definition -} - -func NewDefinitionBuilder() *DefinitionBuilder{ - return &DefinitionBuilder{ - obj: NewDefinition(), - } -} - -func (p DefinitionBuilder) Emit() *Definition{ - return &Definition{ - } -} - -func (p *Definition) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Definition) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Definition"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Definition) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Definition({})") -} - diff --git a/thrift/compiler/test/fixtures/includes/gen-go/IncludesAlso/constants.go b/thrift/compiler/test/fixtures/includes/gen-go/IncludesAlso/constants.go deleted file mode 100644 index a3edee85e2b..00000000000 --- a/thrift/compiler/test/fixtures/includes/gen-go/IncludesAlso/constants.go +++ /dev/null @@ -1,25 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package IncludesAlso - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - - -func init() { -} - diff --git a/thrift/compiler/test/fixtures/includes/gen-go/IncludesAlso/ttypes.go b/thrift/compiler/test/fixtures/includes/gen-go/IncludesAlso/ttypes.go deleted file mode 100644 index ee4062980bb..00000000000 --- a/thrift/compiler/test/fixtures/includes/gen-go/IncludesAlso/ttypes.go +++ /dev/null @@ -1,88 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package IncludesAlso - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var GoUnusedProtection__ int; - -type Also struct { -} - -func NewAlso() *Also { - return &Also{} -} - -type AlsoBuilder struct { - obj *Also -} - -func NewAlsoBuilder() *AlsoBuilder{ - return &AlsoBuilder{ - obj: NewAlso(), - } -} - -func (p AlsoBuilder) Emit() *Also{ - return &Also{ - } -} - -func (p *Also) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Also) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Also"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Also) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Also({})") -} - diff --git a/thrift/compiler/test/fixtures/includes/gen-go/includes/constants.go b/thrift/compiler/test/fixtures/includes/gen-go/includes/constants.go deleted file mode 100644 index d9409dfee97..00000000000 --- a/thrift/compiler/test/fixtures/includes/gen-go/includes/constants.go +++ /dev/null @@ -1,37 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package includes - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" - transitive0 "transitive" - -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var _ = transitive0.GoUnusedProtection__ -var ExampleIncluded *Included -const IncludedConstant = 42 - -func init() { -ExampleIncluded = &Included{ - MyIntField: 2, - MyTransitiveField: &transitive0.Foo{ - A: 2, - }, -} - -} - diff --git a/thrift/compiler/test/fixtures/includes/gen-go/includes/ttypes.go b/thrift/compiler/test/fixtures/includes/gen-go/includes/ttypes.go deleted file mode 100644 index 8c70a375aac..00000000000 --- a/thrift/compiler/test/fixtures/includes/gen-go/includes/ttypes.go +++ /dev/null @@ -1,211 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package includes - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" - transitive0 "transitive" - -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var _ = transitive0.GoUnusedProtection__ -var GoUnusedProtection__ int; - -type IncludedInt64 = int64 - -func IncludedInt64Ptr(v IncludedInt64) *IncludedInt64 { return &v } - -type TransitiveFoo = transitive0.Foo - -func TransitiveFooPtr(v TransitiveFoo) *TransitiveFoo { return &v } - -func NewTransitiveFoo() *TransitiveFoo { return transitive0.NewFoo() } - -// Attributes: -// - MyIntField -// - MyTransitiveField -type Included struct { - MyIntField int64 `thrift:"MyIntField,1" db:"MyIntField" json:"MyIntField"` - MyTransitiveField *transitive0.Foo `thrift:"MyTransitiveField,2" db:"MyTransitiveField" json:"MyTransitiveField"` -} - -func NewIncluded() *Included { - return &Included{ - MyTransitiveField: transitive0.NewFoo(), - } -} - - -func (p *Included) GetMyIntField() int64 { - return p.MyIntField -} -var Included_MyTransitiveField_DEFAULT *transitive0.Foo = &transitive0.Foo{ - A: 2, -} -func (p *Included) GetMyTransitiveField() *transitive0.Foo { - if !p.IsSetMyTransitiveField() { - return Included_MyTransitiveField_DEFAULT - } - return p.MyTransitiveField -} -func (p *Included) DefaultGetMyTransitiveField() *transitive0.Foo { - if !p.IsSetMyTransitiveField() { - return transitive0.NewFoo() - } - return p.MyTransitiveField -} -func (p *Included) IsSetMyTransitiveField() bool { - return p != nil && p.MyTransitiveField != nil -} - -type IncludedBuilder struct { - obj *Included -} - -func NewIncludedBuilder() *IncludedBuilder{ - return &IncludedBuilder{ - obj: NewIncluded(), - } -} - -func (p IncludedBuilder) Emit() *Included{ - return &Included{ - MyIntField: p.obj.MyIntField, - MyTransitiveField: p.obj.MyTransitiveField, - } -} - -func (i *IncludedBuilder) MyIntField(myIntField int64) *IncludedBuilder { - i.obj.MyIntField = myIntField - return i -} - -func (i *IncludedBuilder) MyTransitiveField(myTransitiveField *transitive0.Foo) *IncludedBuilder { - i.obj.MyTransitiveField = myTransitiveField - return i -} - -func (i *Included) SetMyIntField(myIntField int64) *Included { - i.MyIntField = myIntField - return i -} - -func (i *Included) SetMyTransitiveField(myTransitiveField *transitive0.Foo) *Included { - i.MyTransitiveField = myTransitiveField - return i -} - -func (p *Included) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Included) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.MyIntField = v - } - return nil -} - -func (p *Included) ReadField2(iprot thrift.Protocol) error { - p.MyTransitiveField = transitive0.NewFoo() - if err := p.MyTransitiveField.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.MyTransitiveField), err) - } - return nil -} - -func (p *Included) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Included"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Included) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("MyIntField", thrift.I64, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:MyIntField: ", p), err) } - if err := oprot.WriteI64(int64(p.MyIntField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.MyIntField (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:MyIntField: ", p), err) } - return err -} - -func (p *Included) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("MyTransitiveField", thrift.STRUCT, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:MyTransitiveField: ", p), err) } - if err := p.MyTransitiveField.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.MyTransitiveField), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:MyTransitiveField: ", p), err) } - return err -} - -func (p *Included) String() string { - if p == nil { - return "" - } - - myIntFieldVal := fmt.Sprintf("%v", p.MyIntField) - var myTransitiveFieldVal string - if p.MyTransitiveField == nil { - myTransitiveFieldVal = "" - } else { - myTransitiveFieldVal = fmt.Sprintf("%v", p.MyTransitiveField) - } - return fmt.Sprintf("Included({MyIntField:%s MyTransitiveField:%s})", myIntFieldVal, myTransitiveFieldVal) -} - diff --git a/thrift/compiler/test/fixtures/includes/gen-go/matching_names/constants.go b/thrift/compiler/test/fixtures/includes/gen-go/matching_names/constants.go deleted file mode 100644 index 3e663716e29..00000000000 --- a/thrift/compiler/test/fixtures/includes/gen-go/matching_names/constants.go +++ /dev/null @@ -1,28 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package matching_names - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" - IncludesAlso0 "IncludesAlso" - -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var _ = IncludesAlso0.GoUnusedProtection__ - -func init() { -} - diff --git a/thrift/compiler/test/fixtures/includes/gen-go/matching_names/ttypes.go b/thrift/compiler/test/fixtures/includes/gen-go/matching_names/ttypes.go deleted file mode 100644 index 81c5498ed27..00000000000 --- a/thrift/compiler/test/fixtures/includes/gen-go/matching_names/ttypes.go +++ /dev/null @@ -1,157 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package matching_names - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" - IncludesAlso0 "IncludesAlso" - -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var _ = IncludesAlso0.GoUnusedProtection__ -var GoUnusedProtection__ int; - -// Attributes: -// - Also -type IncludesAlso struct { - Also *IncludesAlso0.Also `thrift:"also,1" db:"also" json:"also"` -} - -func NewIncludesAlso() *IncludesAlso { - return &IncludesAlso{ - Also: IncludesAlso0.NewAlso(), - } -} - -var IncludesAlso_Also_DEFAULT *IncludesAlso0.Also -func (p *IncludesAlso) GetAlso() *IncludesAlso0.Also { - if !p.IsSetAlso() { - return IncludesAlso_Also_DEFAULT - } - return p.Also -} -func (p *IncludesAlso) DefaultGetAlso() *IncludesAlso0.Also { - if !p.IsSetAlso() { - return IncludesAlso0.NewAlso() - } - return p.Also -} -func (p *IncludesAlso) IsSetAlso() bool { - return p != nil && p.Also != nil -} - -type IncludesAlsoBuilder struct { - obj *IncludesAlso -} - -func NewIncludesAlsoBuilder() *IncludesAlsoBuilder{ - return &IncludesAlsoBuilder{ - obj: NewIncludesAlso(), - } -} - -func (p IncludesAlsoBuilder) Emit() *IncludesAlso{ - return &IncludesAlso{ - Also: p.obj.Also, - } -} - -func (i *IncludesAlsoBuilder) Also(also *IncludesAlso0.Also) *IncludesAlsoBuilder { - i.obj.Also = also - return i -} - -func (i *IncludesAlso) SetAlso(also *IncludesAlso0.Also) *IncludesAlso { - i.Also = also - return i -} - -func (p *IncludesAlso) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *IncludesAlso) ReadField1(iprot thrift.Protocol) error { - p.Also = IncludesAlso0.NewAlso() - if err := p.Also.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Also), err) - } - return nil -} - -func (p *IncludesAlso) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("IncludesAlso"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *IncludesAlso) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("also", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:also: ", p), err) } - if err := p.Also.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Also), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:also: ", p), err) } - return err -} - -func (p *IncludesAlso) String() string { - if p == nil { - return "" - } - - var alsoVal string - if p.Also == nil { - alsoVal = "" - } else { - alsoVal = fmt.Sprintf("%v", p.Also) - } - return fmt.Sprintf("IncludesAlso({Also:%s})", alsoVal) -} - diff --git a/thrift/compiler/test/fixtures/includes/gen-go/module/constants.go b/thrift/compiler/test/fixtures/includes/gen-go/module/constants.go deleted file mode 100644 index 5e6ef1c276e..00000000000 --- a/thrift/compiler/test/fixtures/includes/gen-go/module/constants.go +++ /dev/null @@ -1,28 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package module - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" - includes0 "includes" - -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var _ = includes0.GoUnusedProtection__ - -func init() { -} - diff --git a/thrift/compiler/test/fixtures/includes/gen-go/module/ttypes.go b/thrift/compiler/test/fixtures/includes/gen-go/module/ttypes.go deleted file mode 100644 index eb73ca0789f..00000000000 --- a/thrift/compiler/test/fixtures/includes/gen-go/module/ttypes.go +++ /dev/null @@ -1,267 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package module - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" - includes0 "includes" - -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var _ = includes0.GoUnusedProtection__ -var GoUnusedProtection__ int; - -// Attributes: -// - MyIncludedField -// - MyOtherIncludedField -// - MyIncludedInt -type MyStruct struct { - MyIncludedField *includes0.Included `thrift:"MyIncludedField,1" db:"MyIncludedField" json:"MyIncludedField"` - MyOtherIncludedField *includes0.Included `thrift:"MyOtherIncludedField,2" db:"MyOtherIncludedField" json:"MyOtherIncludedField"` - MyIncludedInt includes0.IncludedInt64 `thrift:"MyIncludedInt,3" db:"MyIncludedInt" json:"MyIncludedInt"` -} - -func NewMyStruct() *MyStruct { - return &MyStruct{ - MyIncludedField: includes0.NewIncluded(), - MyOtherIncludedField: includes0.NewIncluded(), - MyIncludedInt: 42, - } -} - -var MyStruct_MyIncludedField_DEFAULT *includes0.Included = &includes0.Included{ - MyIntField: 2, - MyTransitiveField: &.Foo{ - A: 2, - }, -} -func (p *MyStruct) GetMyIncludedField() *includes0.Included { - if !p.IsSetMyIncludedField() { - return MyStruct_MyIncludedField_DEFAULT - } - return p.MyIncludedField -} -func (p *MyStruct) DefaultGetMyIncludedField() *includes0.Included { - if !p.IsSetMyIncludedField() { - return includes0.NewIncluded() - } - return p.MyIncludedField -} -var MyStruct_MyOtherIncludedField_DEFAULT *includes0.Included -func (p *MyStruct) GetMyOtherIncludedField() *includes0.Included { - if !p.IsSetMyOtherIncludedField() { - return MyStruct_MyOtherIncludedField_DEFAULT - } - return p.MyOtherIncludedField -} -func (p *MyStruct) DefaultGetMyOtherIncludedField() *includes0.Included { - if !p.IsSetMyOtherIncludedField() { - return includes0.NewIncluded() - } - return p.MyOtherIncludedField -} - -func (p *MyStruct) GetMyIncludedInt() includes0.IncludedInt64 { - return p.MyIncludedInt -} -func (p *MyStruct) IsSetMyIncludedField() bool { - return p != nil && p.MyIncludedField != nil -} - -func (p *MyStruct) IsSetMyOtherIncludedField() bool { - return p != nil && p.MyOtherIncludedField != nil -} - -type MyStructBuilder struct { - obj *MyStruct -} - -func NewMyStructBuilder() *MyStructBuilder{ - return &MyStructBuilder{ - obj: NewMyStruct(), - } -} - -func (p MyStructBuilder) Emit() *MyStruct{ - return &MyStruct{ - MyIncludedField: p.obj.MyIncludedField, - MyOtherIncludedField: p.obj.MyOtherIncludedField, - MyIncludedInt: p.obj.MyIncludedInt, - } -} - -func (m *MyStructBuilder) MyIncludedField(myIncludedField *includes0.Included) *MyStructBuilder { - m.obj.MyIncludedField = myIncludedField - return m -} - -func (m *MyStructBuilder) MyOtherIncludedField(myOtherIncludedField *includes0.Included) *MyStructBuilder { - m.obj.MyOtherIncludedField = myOtherIncludedField - return m -} - -func (m *MyStructBuilder) MyIncludedInt(myIncludedInt includes0.IncludedInt64) *MyStructBuilder { - m.obj.MyIncludedInt = myIncludedInt - return m -} - -func (m *MyStruct) SetMyIncludedField(myIncludedField *includes0.Included) *MyStruct { - m.MyIncludedField = myIncludedField - return m -} - -func (m *MyStruct) SetMyOtherIncludedField(myOtherIncludedField *includes0.Included) *MyStruct { - m.MyOtherIncludedField = myOtherIncludedField - return m -} - -func (m *MyStruct) SetMyIncludedInt(myIncludedInt includes0.IncludedInt64) *MyStruct { - m.MyIncludedInt = myIncludedInt - return m -} - -func (p *MyStruct) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 3: - if err := p.ReadField3(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyStruct) ReadField1(iprot thrift.Protocol) error { - p.MyIncludedField = includes0.NewIncluded() - if err := p.MyIncludedField.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.MyIncludedField), err) - } - return nil -} - -func (p *MyStruct) ReadField2(iprot thrift.Protocol) error { - p.MyOtherIncludedField = includes0.NewIncluded() - if err := p.MyOtherIncludedField.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.MyOtherIncludedField), err) - } - return nil -} - -func (p *MyStruct) ReadField3(iprot thrift.Protocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 3: ", err) - } else { - temp := includes0.IncludedInt64(v) - p.MyIncludedInt = temp - } - return nil -} - -func (p *MyStruct) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("MyStruct"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyStruct) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("MyIncludedField", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:MyIncludedField: ", p), err) } - if err := p.MyIncludedField.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.MyIncludedField), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:MyIncludedField: ", p), err) } - return err -} - -func (p *MyStruct) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("MyOtherIncludedField", thrift.STRUCT, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:MyOtherIncludedField: ", p), err) } - if err := p.MyOtherIncludedField.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.MyOtherIncludedField), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:MyOtherIncludedField: ", p), err) } - return err -} - -func (p *MyStruct) writeField3(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("MyIncludedInt", thrift.I64, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:MyIncludedInt: ", p), err) } - if err := oprot.WriteI64(int64(p.MyIncludedInt)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.MyIncludedInt (3) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:MyIncludedInt: ", p), err) } - return err -} - -func (p *MyStruct) String() string { - if p == nil { - return "" - } - - var myIncludedFieldVal string - if p.MyIncludedField == nil { - myIncludedFieldVal = "" - } else { - myIncludedFieldVal = fmt.Sprintf("%v", p.MyIncludedField) - } - var myOtherIncludedFieldVal string - if p.MyOtherIncludedField == nil { - myOtherIncludedFieldVal = "" - } else { - myOtherIncludedFieldVal = fmt.Sprintf("%v", p.MyOtherIncludedField) - } - myIncludedIntVal := fmt.Sprintf("%v", p.MyIncludedInt) - return fmt.Sprintf("MyStruct({MyIncludedField:%s MyOtherIncludedField:%s MyIncludedInt:%s})", myIncludedFieldVal, myOtherIncludedFieldVal, myIncludedIntVal) -} - diff --git a/thrift/compiler/test/fixtures/includes/gen-go/service/constants.go b/thrift/compiler/test/fixtures/includes/gen-go/service/constants.go deleted file mode 100644 index c178b576090..00000000000 --- a/thrift/compiler/test/fixtures/includes/gen-go/service/constants.go +++ /dev/null @@ -1,30 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package service - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" - module0 "module" - includes1 "includes" - -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var _ = module0.GoUnusedProtection__ -var _ = includes1.GoUnusedProtection__ - -func init() { -} - diff --git a/thrift/compiler/test/fixtures/includes/gen-go/service/myservice.go b/thrift/compiler/test/fixtures/includes/gen-go/service/myservice.go deleted file mode 100644 index c33a14d4fe5..00000000000 --- a/thrift/compiler/test/fixtures/includes/gen-go/service/myservice.go +++ /dev/null @@ -1,927 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package service - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" - module0 "module" - includes1 "includes" - -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var _ = module0.GoUnusedProtection__ -var _ = includes1.GoUnusedProtection__ -type MyService interface { //This is a service-level docblock - - // This is a function-level docblock - // - // Parameters: - // - S - // - I - Query(s *module0.MyStruct, i *includes1.Included) (err error) - // Parameters: - // - S - // - I: arg doc - HasArgDocs(s *module0.MyStruct, i *includes1.Included) (err error) -} - -type MyServiceClientInterface interface { - thrift.ClientInterface - // This is a function-level docblock - // - // Parameters: - // - S - // - I - Query(s *module0.MyStruct, i *includes1.Included) (err error) - // Parameters: - // - S - // - I: arg doc - HasArgDocs(s *module0.MyStruct, i *includes1.Included) (err error) -} - -//This is a service-level docblock -type MyServiceClient struct { - MyServiceClientInterface - CC thrift.ClientConn -} - -func(client *MyServiceClient) Open() error { - return client.CC.Open() -} - -func(client *MyServiceClient) Close() error { - return client.CC.Close() -} - -func(client *MyServiceClient) IsOpen() bool { - return client.CC.IsOpen() -} - -func NewMyServiceClientFactory(t thrift.Transport, f thrift.ProtocolFactory) *MyServiceClient { - return &MyServiceClient{ CC: thrift.NewClientConn(t, f) } -} - -func NewMyServiceClient(t thrift.Transport, iprot thrift.Protocol, oprot thrift.Protocol) *MyServiceClient { - return &MyServiceClient{ CC: thrift.NewClientConnWithProtocols(t, iprot, oprot) } -} - -func NewMyServiceClientProtocol(prot thrift.Protocol) *MyServiceClient { - return NewMyServiceClient(prot.Transport(), prot, prot) -} - -// This is a function-level docblock -// -// Parameters: -// - S -// - I -func (p *MyServiceClient) Query(s *module0.MyStruct, i *includes1.Included) (err error) { - args := MyServiceQueryArgs{ - S : s, - I : i, - } - err = p.CC.SendMsg("query", &args, thrift.CALL) - if err != nil { return } - return p.recvQuery() -} - - -func (p *MyServiceClient) recvQuery() (err error) { - var __result MyServiceQueryResult - return p.CC.RecvMsg("query", &__result) -} - -// Parameters: -// - S -// - I: arg doc -func (p *MyServiceClient) HasArgDocs(s *module0.MyStruct, i *includes1.Included) (err error) { - args := MyServiceHasArgDocsArgs{ - S : s, - I : i, - } - err = p.CC.SendMsg("has_arg_docs", &args, thrift.CALL) - if err != nil { return } - return p.recvHasArgDocs() -} - - -func (p *MyServiceClient) recvHasArgDocs() (err error) { - var __result MyServiceHasArgDocsResult - return p.CC.RecvMsg("has_arg_docs", &__result) -} - - -//This is a service-level docblock -type MyServiceThreadsafeClient struct { - MyServiceClientInterface - CC thrift.ClientConn - Mu sync.Mutex -} - -func(client *MyServiceThreadsafeClient) Open() error { - client.Mu.Lock() - defer client.Mu.Unlock() - return client.CC.Open() -} - -func(client *MyServiceThreadsafeClient) Close() error { - client.Mu.Lock() - defer client.Mu.Unlock() - return client.CC.Close() -} - -func(client *MyServiceThreadsafeClient) IsOpen() bool { - client.Mu.Lock() - defer client.Mu.Unlock() - return client.CC.IsOpen() -} - -func NewMyServiceThreadsafeClientFactory(t thrift.Transport, f thrift.ProtocolFactory) *MyServiceThreadsafeClient { - return &MyServiceThreadsafeClient{ CC: thrift.NewClientConn(t, f) } -} - -func NewMyServiceThreadsafeClient(t thrift.Transport, iprot thrift.Protocol, oprot thrift.Protocol) *MyServiceThreadsafeClient { - return &MyServiceThreadsafeClient{ CC: thrift.NewClientConnWithProtocols(t, iprot, oprot) } -} - -func NewMyServiceThreadsafeClientProtocol(prot thrift.Protocol) *MyServiceThreadsafeClient { - return NewMyServiceThreadsafeClient(prot.Transport(), prot, prot) -} - -// This is a function-level docblock -// -// Parameters: -// - S -// - I -func (p *MyServiceThreadsafeClient) Query(s *module0.MyStruct, i *includes1.Included) (err error) { - p.Mu.Lock() - defer p.Mu.Unlock() - args := MyServiceQueryArgs{ - S : s, - I : i, - } - err = p.CC.SendMsg("query", &args, thrift.CALL) - if err != nil { return } - return p.recvQuery() -} - - -func (p *MyServiceThreadsafeClient) recvQuery() (err error) { - var __result MyServiceQueryResult - return p.CC.RecvMsg("query", &__result) -} - -// Parameters: -// - S -// - I: arg doc -func (p *MyServiceThreadsafeClient) HasArgDocs(s *module0.MyStruct, i *includes1.Included) (err error) { - p.Mu.Lock() - defer p.Mu.Unlock() - args := MyServiceHasArgDocsArgs{ - S : s, - I : i, - } - err = p.CC.SendMsg("has_arg_docs", &args, thrift.CALL) - if err != nil { return } - return p.recvHasArgDocs() -} - - -func (p *MyServiceThreadsafeClient) recvHasArgDocs() (err error) { - var __result MyServiceHasArgDocsResult - return p.CC.RecvMsg("has_arg_docs", &__result) -} - - -//This is a service-level docblock -type MyServiceChannelClient struct { - RequestChannel thrift.RequestChannel -} - -func (c *MyServiceChannelClient) Close() error { - return c.RequestChannel.Close() -} - -func (c *MyServiceChannelClient) IsOpen() bool { - return c.RequestChannel.IsOpen() -} - -func (c *MyServiceChannelClient) Open() error { - return c.RequestChannel.Open() -} - -func NewMyServiceChannelClient(channel thrift.RequestChannel) *MyServiceChannelClient { - return &MyServiceChannelClient{RequestChannel: channel} -} - -// This is a function-level docblock -// -// Parameters: -// - S -// - I -func (p *MyServiceChannelClient) Query(ctx context.Context, s *module0.MyStruct, i *includes1.Included) (err error) { - args := MyServiceQueryArgs{ - S : s, - I : i, - } - var __result MyServiceQueryResult - err = p.RequestChannel.Call(ctx, "query", &args, &__result) - if err != nil { return } - - return nil -} - -// Parameters: -// - S -// - I: arg doc -func (p *MyServiceChannelClient) HasArgDocs(ctx context.Context, s *module0.MyStruct, i *includes1.Included) (err error) { - args := MyServiceHasArgDocsArgs{ - S : s, - I : i, - } - var __result MyServiceHasArgDocsResult - err = p.RequestChannel.Call(ctx, "has_arg_docs", &args, &__result) - if err != nil { return } - - return nil -} - - -type MyServiceProcessor struct { - processorMap map[string]thrift.ProcessorFunction - functionServiceMap map[string]string - handler MyService -} - -func (p *MyServiceProcessor) AddToProcessorMap(key string, processor thrift.ProcessorFunction) { - p.processorMap[key] = processor -} - -func (p *MyServiceProcessor) AddToFunctionServiceMap(key, service string) { - p.functionServiceMap[key] = service -} - -func (p *MyServiceProcessor) GetProcessorFunction(key string) (processor thrift.ProcessorFunction, err error) { - if processor, ok := p.processorMap[key]; ok { - return processor, nil - } - return nil, nil // generic error message will be sent -} - -func (p *MyServiceProcessor) ProcessorMap() map[string]thrift.ProcessorFunction { - return p.processorMap -} - -func (p *MyServiceProcessor) FunctionServiceMap() map[string]string { - return p.functionServiceMap -} - -func NewMyServiceProcessor(handler MyService) *MyServiceProcessor { - self2 := &MyServiceProcessor{handler:handler, processorMap:make(map[string]thrift.ProcessorFunction), functionServiceMap:make(map[string]string)} - self2.processorMap["query"] = &myServiceProcessorQuery{handler:handler} - self2.processorMap["has_arg_docs"] = &myServiceProcessorHasArgDocs{handler:handler} - self2.functionServiceMap["query"] = "MyService" - self2.functionServiceMap["has_arg_docs"] = "MyService" - return self2 -} - -type myServiceProcessorQuery struct { - handler MyService -} - -func (p *MyServiceQueryResult) Exception() thrift.WritableException { - if p == nil { return nil } - return nil -} - -func (p *myServiceProcessorQuery) Read(iprot thrift.Protocol) (thrift.Struct, thrift.Exception) { - args := MyServiceQueryArgs{} - if err := args.Read(iprot); err != nil { - return nil, err - } - iprot.ReadMessageEnd() - return &args, nil -} - -func (p *myServiceProcessorQuery) Write(seqId int32, result thrift.WritableStruct, oprot thrift.Protocol) (err thrift.Exception) { - var err2 error - messageType := thrift.REPLY - switch result.(type) { - case thrift.ApplicationException: - messageType = thrift.EXCEPTION - } - if err2 = oprot.WriteMessageBegin("query", messageType, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - return err -} - -func (p *myServiceProcessorQuery) Run(argStruct thrift.Struct) (thrift.WritableStruct, thrift.ApplicationException) { - args := argStruct.(*MyServiceQueryArgs) - var __result MyServiceQueryResult - if err := p.handler.Query(args.S, args.I); err != nil { - switch err.(type) { - default: - x := thrift.NewApplicationExceptionCause(thrift.INTERNAL_ERROR, "Internal error processing query: " + err.Error(), err) - return x, x - } - } - return &__result, nil -} - -type myServiceProcessorHasArgDocs struct { - handler MyService -} - -func (p *MyServiceHasArgDocsResult) Exception() thrift.WritableException { - if p == nil { return nil } - return nil -} - -func (p *myServiceProcessorHasArgDocs) Read(iprot thrift.Protocol) (thrift.Struct, thrift.Exception) { - args := MyServiceHasArgDocsArgs{} - if err := args.Read(iprot); err != nil { - return nil, err - } - iprot.ReadMessageEnd() - return &args, nil -} - -func (p *myServiceProcessorHasArgDocs) Write(seqId int32, result thrift.WritableStruct, oprot thrift.Protocol) (err thrift.Exception) { - var err2 error - messageType := thrift.REPLY - switch result.(type) { - case thrift.ApplicationException: - messageType = thrift.EXCEPTION - } - if err2 = oprot.WriteMessageBegin("has_arg_docs", messageType, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - return err -} - -func (p *myServiceProcessorHasArgDocs) Run(argStruct thrift.Struct) (thrift.WritableStruct, thrift.ApplicationException) { - args := argStruct.(*MyServiceHasArgDocsArgs) - var __result MyServiceHasArgDocsResult - if err := p.handler.HasArgDocs(args.S, args.I); err != nil { - switch err.(type) { - default: - x := thrift.NewApplicationExceptionCause(thrift.INTERNAL_ERROR, "Internal error processing has_arg_docs: " + err.Error(), err) - return x, x - } - } - return &__result, nil -} - - -// HELPER FUNCTIONS AND STRUCTURES - -// Attributes: -// - S -// - I -type MyServiceQueryArgs struct { - thrift.IRequest - S *module0.MyStruct `thrift:"s,1" db:"s" json:"s"` - I *includes1.Included `thrift:"i,2" db:"i" json:"i"` -} - -func NewMyServiceQueryArgs() *MyServiceQueryArgs { - return &MyServiceQueryArgs{ - S: module0.NewMyStruct(), - I: includes1.NewIncluded(), - } -} - -var MyServiceQueryArgs_S_DEFAULT *module0.MyStruct -func (p *MyServiceQueryArgs) GetS() *module0.MyStruct { - if !p.IsSetS() { - return MyServiceQueryArgs_S_DEFAULT - } - return p.S -} -func (p *MyServiceQueryArgs) DefaultGetS() *module0.MyStruct { - if !p.IsSetS() { - return module0.NewMyStruct() - } - return p.S -} -var MyServiceQueryArgs_I_DEFAULT *includes1.Included -func (p *MyServiceQueryArgs) GetI() *includes1.Included { - if !p.IsSetI() { - return MyServiceQueryArgs_I_DEFAULT - } - return p.I -} -func (p *MyServiceQueryArgs) DefaultGetI() *includes1.Included { - if !p.IsSetI() { - return includes1.NewIncluded() - } - return p.I -} -func (p *MyServiceQueryArgs) IsSetS() bool { - return p != nil && p.S != nil -} - -func (p *MyServiceQueryArgs) IsSetI() bool { - return p != nil && p.I != nil -} - -type MyServiceQueryArgsBuilder struct { - obj *MyServiceQueryArgs -} - -func NewMyServiceQueryArgsBuilder() *MyServiceQueryArgsBuilder{ - return &MyServiceQueryArgsBuilder{ - obj: NewMyServiceQueryArgs(), - } -} - -func (p MyServiceQueryArgsBuilder) Emit() *MyServiceQueryArgs{ - return &MyServiceQueryArgs{ - S: p.obj.S, - I: p.obj.I, - } -} - -func (m *MyServiceQueryArgsBuilder) S(s *module0.MyStruct) *MyServiceQueryArgsBuilder { - m.obj.S = s - return m -} - -func (m *MyServiceQueryArgsBuilder) I(i *includes1.Included) *MyServiceQueryArgsBuilder { - m.obj.I = i - return m -} - -func (m *MyServiceQueryArgs) SetS(s *module0.MyStruct) *MyServiceQueryArgs { - m.S = s - return m -} - -func (m *MyServiceQueryArgs) SetI(i *includes1.Included) *MyServiceQueryArgs { - m.I = i - return m -} - -func (p *MyServiceQueryArgs) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyServiceQueryArgs) ReadField1(iprot thrift.Protocol) error { - p.S = module0.NewMyStruct() - if err := p.S.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.S), err) - } - return nil -} - -func (p *MyServiceQueryArgs) ReadField2(iprot thrift.Protocol) error { - p.I = includes1.NewIncluded() - if err := p.I.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.I), err) - } - return nil -} - -func (p *MyServiceQueryArgs) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("query_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyServiceQueryArgs) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("s", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:s: ", p), err) } - if err := p.S.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.S), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:s: ", p), err) } - return err -} - -func (p *MyServiceQueryArgs) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("i", thrift.STRUCT, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:i: ", p), err) } - if err := p.I.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.I), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:i: ", p), err) } - return err -} - -func (p *MyServiceQueryArgs) String() string { - if p == nil { - return "" - } - - var sVal string - if p.S == nil { - sVal = "" - } else { - sVal = fmt.Sprintf("%v", p.S) - } - var iVal string - if p.I == nil { - iVal = "" - } else { - iVal = fmt.Sprintf("%v", p.I) - } - return fmt.Sprintf("MyServiceQueryArgs({S:%s I:%s})", sVal, iVal) -} - -type MyServiceQueryResult struct { - thrift.IResponse -} - -func NewMyServiceQueryResult() *MyServiceQueryResult { - return &MyServiceQueryResult{} -} - -type MyServiceQueryResultBuilder struct { - obj *MyServiceQueryResult -} - -func NewMyServiceQueryResultBuilder() *MyServiceQueryResultBuilder{ - return &MyServiceQueryResultBuilder{ - obj: NewMyServiceQueryResult(), - } -} - -func (p MyServiceQueryResultBuilder) Emit() *MyServiceQueryResult{ - return &MyServiceQueryResult{ - } -} - -func (p *MyServiceQueryResult) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyServiceQueryResult) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("query_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyServiceQueryResult) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("MyServiceQueryResult({})") -} - -// Attributes: -// - S -// - I: arg doc -type MyServiceHasArgDocsArgs struct { - thrift.IRequest - S *module0.MyStruct `thrift:"s,1" db:"s" json:"s"` - I *includes1.Included `thrift:"i,2" db:"i" json:"i"` -} - -func NewMyServiceHasArgDocsArgs() *MyServiceHasArgDocsArgs { - return &MyServiceHasArgDocsArgs{ - S: module0.NewMyStruct(), - I: includes1.NewIncluded(), - } -} - -var MyServiceHasArgDocsArgs_S_DEFAULT *module0.MyStruct -func (p *MyServiceHasArgDocsArgs) GetS() *module0.MyStruct { - if !p.IsSetS() { - return MyServiceHasArgDocsArgs_S_DEFAULT - } - return p.S -} -func (p *MyServiceHasArgDocsArgs) DefaultGetS() *module0.MyStruct { - if !p.IsSetS() { - return module0.NewMyStruct() - } - return p.S -} -var MyServiceHasArgDocsArgs_I_DEFAULT *includes1.Included -func (p *MyServiceHasArgDocsArgs) GetI() *includes1.Included { - if !p.IsSetI() { - return MyServiceHasArgDocsArgs_I_DEFAULT - } - return p.I -} -func (p *MyServiceHasArgDocsArgs) DefaultGetI() *includes1.Included { - if !p.IsSetI() { - return includes1.NewIncluded() - } - return p.I -} -func (p *MyServiceHasArgDocsArgs) IsSetS() bool { - return p != nil && p.S != nil -} - -func (p *MyServiceHasArgDocsArgs) IsSetI() bool { - return p != nil && p.I != nil -} - -type MyServiceHasArgDocsArgsBuilder struct { - obj *MyServiceHasArgDocsArgs -} - -func NewMyServiceHasArgDocsArgsBuilder() *MyServiceHasArgDocsArgsBuilder{ - return &MyServiceHasArgDocsArgsBuilder{ - obj: NewMyServiceHasArgDocsArgs(), - } -} - -func (p MyServiceHasArgDocsArgsBuilder) Emit() *MyServiceHasArgDocsArgs{ - return &MyServiceHasArgDocsArgs{ - S: p.obj.S, - I: p.obj.I, - } -} - -func (m *MyServiceHasArgDocsArgsBuilder) S(s *module0.MyStruct) *MyServiceHasArgDocsArgsBuilder { - m.obj.S = s - return m -} - -func (m *MyServiceHasArgDocsArgsBuilder) I(i *includes1.Included) *MyServiceHasArgDocsArgsBuilder { - m.obj.I = i - return m -} - -func (m *MyServiceHasArgDocsArgs) SetS(s *module0.MyStruct) *MyServiceHasArgDocsArgs { - m.S = s - return m -} - -func (m *MyServiceHasArgDocsArgs) SetI(i *includes1.Included) *MyServiceHasArgDocsArgs { - m.I = i - return m -} - -func (p *MyServiceHasArgDocsArgs) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyServiceHasArgDocsArgs) ReadField1(iprot thrift.Protocol) error { - p.S = module0.NewMyStruct() - if err := p.S.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.S), err) - } - return nil -} - -func (p *MyServiceHasArgDocsArgs) ReadField2(iprot thrift.Protocol) error { - p.I = includes1.NewIncluded() - if err := p.I.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.I), err) - } - return nil -} - -func (p *MyServiceHasArgDocsArgs) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("has_arg_docs_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyServiceHasArgDocsArgs) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("s", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:s: ", p), err) } - if err := p.S.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.S), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:s: ", p), err) } - return err -} - -func (p *MyServiceHasArgDocsArgs) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("i", thrift.STRUCT, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:i: ", p), err) } - if err := p.I.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.I), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:i: ", p), err) } - return err -} - -func (p *MyServiceHasArgDocsArgs) String() string { - if p == nil { - return "" - } - - var sVal string - if p.S == nil { - sVal = "" - } else { - sVal = fmt.Sprintf("%v", p.S) - } - var iVal string - if p.I == nil { - iVal = "" - } else { - iVal = fmt.Sprintf("%v", p.I) - } - return fmt.Sprintf("MyServiceHasArgDocsArgs({S:%s I:%s})", sVal, iVal) -} - -type MyServiceHasArgDocsResult struct { - thrift.IResponse -} - -func NewMyServiceHasArgDocsResult() *MyServiceHasArgDocsResult { - return &MyServiceHasArgDocsResult{} -} - -type MyServiceHasArgDocsResultBuilder struct { - obj *MyServiceHasArgDocsResult -} - -func NewMyServiceHasArgDocsResultBuilder() *MyServiceHasArgDocsResultBuilder{ - return &MyServiceHasArgDocsResultBuilder{ - obj: NewMyServiceHasArgDocsResult(), - } -} - -func (p MyServiceHasArgDocsResultBuilder) Emit() *MyServiceHasArgDocsResult{ - return &MyServiceHasArgDocsResult{ - } -} - -func (p *MyServiceHasArgDocsResult) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyServiceHasArgDocsResult) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("has_arg_docs_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyServiceHasArgDocsResult) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("MyServiceHasArgDocsResult({})") -} - - diff --git a/thrift/compiler/test/fixtures/includes/gen-go/service/ttypes.go b/thrift/compiler/test/fixtures/includes/gen-go/service/ttypes.go deleted file mode 100644 index 112145d9735..00000000000 --- a/thrift/compiler/test/fixtures/includes/gen-go/service/ttypes.go +++ /dev/null @@ -1,40 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package service - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" - module0 "module" - includes1 "includes" - -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var _ = module0.GoUnusedProtection__ -var _ = includes1.GoUnusedProtection__ -var GoUnusedProtection__ int; - -type IncludesIncluded = includes1.Included - -func IncludesIncludedPtr(v IncludesIncluded) *IncludesIncluded { return &v } - -func NewIncludesIncluded() *IncludesIncluded { return includes1.NewIncluded() } - -type IncludesTransitiveFoo = *includes1.TransitiveFoo - -func IncludesTransitiveFooPtr(v IncludesTransitiveFoo) *IncludesTransitiveFoo { return &v } - -func NewIncludesTransitiveFoo() IncludesTransitiveFoo { return includes1.NewTransitiveFoo() } - diff --git a/thrift/compiler/test/fixtures/includes/gen-go/transitive/constants.go b/thrift/compiler/test/fixtures/includes/gen-go/transitive/constants.go deleted file mode 100644 index c55df3364db..00000000000 --- a/thrift/compiler/test/fixtures/includes/gen-go/transitive/constants.go +++ /dev/null @@ -1,30 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package transitive - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var ExampleFoo *Foo - -func init() { -ExampleFoo = &Foo{ - A: 2, -} - -} - diff --git a/thrift/compiler/test/fixtures/includes/gen-go/transitive/ttypes.go b/thrift/compiler/test/fixtures/includes/gen-go/transitive/ttypes.go deleted file mode 100644 index bf8efe86f7d..00000000000 --- a/thrift/compiler/test/fixtures/includes/gen-go/transitive/ttypes.go +++ /dev/null @@ -1,136 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package transitive - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var GoUnusedProtection__ int; - -// Attributes: -// - A -type Foo struct { - A int64 `thrift:"a,1" db:"a" json:"a"` -} - -func NewFoo() *Foo { - return &Foo{ - A: 2, - } -} - - -func (p *Foo) GetA() int64 { - return p.A -} -type FooBuilder struct { - obj *Foo -} - -func NewFooBuilder() *FooBuilder{ - return &FooBuilder{ - obj: NewFoo(), - } -} - -func (p FooBuilder) Emit() *Foo{ - return &Foo{ - A: p.obj.A, - } -} - -func (f *FooBuilder) A(a int64) *FooBuilder { - f.obj.A = a - return f -} - -func (f *Foo) SetA(a int64) *Foo { - f.A = a - return f -} - -func (p *Foo) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Foo) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.A = v - } - return nil -} - -func (p *Foo) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Foo"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Foo) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("a", thrift.I64, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:a: ", p), err) } - if err := oprot.WriteI64(int64(p.A)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.a (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:a: ", p), err) } - return err -} - -func (p *Foo) String() string { - if p == nil { - return "" - } - - aVal := fmt.Sprintf("%v", p.A) - return fmt.Sprintf("Foo({A:%s})", aVal) -} - diff --git a/thrift/compiler/test/fixtures/inheritance/gen-go/module/constants.go b/thrift/compiler/test/fixtures/inheritance/gen-go/module/constants.go deleted file mode 100644 index 477cf91a64b..00000000000 --- a/thrift/compiler/test/fixtures/inheritance/gen-go/module/constants.go +++ /dev/null @@ -1,25 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package module - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - - -func init() { -} - diff --git a/thrift/compiler/test/fixtures/inheritance/gen-go/module/myleaf.go b/thrift/compiler/test/fixtures/inheritance/gen-go/module/myleaf.go deleted file mode 100644 index 7bce64dbd87..00000000000 --- a/thrift/compiler/test/fixtures/inheritance/gen-go/module/myleaf.go +++ /dev/null @@ -1,356 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package module - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -type MyLeaf interface { -MyNode - - DoLeaf() (err error) -} - -type MyLeafClientInterface interface { - thrift.ClientInterface - DoLeaf() (err error) -} - -type MyLeafClient struct { - MyLeafClientInterface - *MyNodeClient -} - -func(client *MyLeafClient) Open() error { - return client.CC.Open() -} - -func(client *MyLeafClient) Close() error { - return client.CC.Close() -} - -func(client *MyLeafClient) IsOpen() bool { - return client.CC.IsOpen() -} - -func NewMyLeafClientFactory(t thrift.Transport, f thrift.ProtocolFactory) *MyLeafClient { - return &MyLeafClient{MyNodeClient: NewMyNodeClientFactory(t, f)} -} - -func NewMyLeafClient(t thrift.Transport, iprot thrift.Protocol, oprot thrift.Protocol) *MyLeafClient { - return &MyLeafClient{MyNodeClient: NewMyNodeClient(t, iprot, oprot)} -} - -func NewMyLeafClientProtocol(prot thrift.Protocol) *MyLeafClient { - return NewMyLeafClient(prot.Transport(), prot, prot) -} - -func (p *MyLeafClient) DoLeaf() (err error) { - var args MyLeafDoLeafArgs - err = p.CC.SendMsg("do_leaf", &args, thrift.CALL) - if err != nil { return } - return p.recvDoLeaf() -} - - -func (p *MyLeafClient) recvDoLeaf() (err error) { - var __result MyLeafDoLeafResult - return p.CC.RecvMsg("do_leaf", &__result) -} - - -type MyLeafThreadsafeClient struct { - MyLeafClientInterface - *MyNodeThreadsafeClient -} - -func(client *MyLeafThreadsafeClient) Open() error { - client.Mu.Lock() - defer client.Mu.Unlock() - return client.CC.Open() -} - -func(client *MyLeafThreadsafeClient) Close() error { - client.Mu.Lock() - defer client.Mu.Unlock() - return client.CC.Close() -} - -func(client *MyLeafThreadsafeClient) IsOpen() bool { - client.Mu.Lock() - defer client.Mu.Unlock() - return client.CC.IsOpen() -} - -func NewMyLeafThreadsafeClientFactory(t thrift.Transport, f thrift.ProtocolFactory) *MyLeafThreadsafeClient { - return &MyLeafThreadsafeClient{MyNodeThreadsafeClient: NewMyNodeThreadsafeClientFactory(t, f)} -} - -func NewMyLeafThreadsafeClient(t thrift.Transport, iprot thrift.Protocol, oprot thrift.Protocol) *MyLeafThreadsafeClient { - return &MyLeafThreadsafeClient{MyNodeThreadsafeClient: NewMyNodeThreadsafeClient(t, iprot, oprot)} -} - -func NewMyLeafThreadsafeClientProtocol(prot thrift.Protocol) *MyLeafThreadsafeClient { - return NewMyLeafThreadsafeClient(prot.Transport(), prot, prot) -} - -func (p *MyLeafThreadsafeClient) DoLeaf() (err error) { - p.Mu.Lock() - defer p.Mu.Unlock() - var args MyLeafDoLeafArgs - err = p.CC.SendMsg("do_leaf", &args, thrift.CALL) - if err != nil { return } - return p.recvDoLeaf() -} - - -func (p *MyLeafThreadsafeClient) recvDoLeaf() (err error) { - var __result MyLeafDoLeafResult - return p.CC.RecvMsg("do_leaf", &__result) -} - - -type MyLeafChannelClient struct { - *MyNodeChannelClient -} - -func (c *MyLeafChannelClient) Close() error { - return c.RequestChannel.Close() -} - -func (c *MyLeafChannelClient) IsOpen() bool { - return c.RequestChannel.IsOpen() -} - -func (c *MyLeafChannelClient) Open() error { - return c.RequestChannel.Open() -} - -func NewMyLeafChannelClient(channel thrift.RequestChannel) *MyLeafChannelClient { - return &MyLeafChannelClient{MyNodeChannelClient: NewMyNodeChannelClient(channel)} -} - -func (p *MyLeafChannelClient) DoLeaf(ctx context.Context) (err error) { - args := MyLeafDoLeafArgs{ - } - var __result MyLeafDoLeafResult - err = p.RequestChannel.Call(ctx, "do_leaf", &args, &__result) - if err != nil { return } - - return nil -} - - -type MyLeafProcessor struct { - *MyNodeProcessor -} - -func NewMyLeafProcessor(handler MyLeaf) *MyLeafProcessor { - self3 := &MyLeafProcessor{NewMyNodeProcessor(handler)} - self3.AddToProcessorMap("do_leaf", &myLeafProcessorDoLeaf{handler:handler}) - self3.AddToFunctionServiceMap("do_leaf", "MyLeaf") - return self3 -} - -type myLeafProcessorDoLeaf struct { - handler MyLeaf -} - -func (p *MyLeafDoLeafResult) Exception() thrift.WritableException { - if p == nil { return nil } - return nil -} - -func (p *myLeafProcessorDoLeaf) Read(iprot thrift.Protocol) (thrift.Struct, thrift.Exception) { - args := MyLeafDoLeafArgs{} - if err := args.Read(iprot); err != nil { - return nil, err - } - iprot.ReadMessageEnd() - return &args, nil -} - -func (p *myLeafProcessorDoLeaf) Write(seqId int32, result thrift.WritableStruct, oprot thrift.Protocol) (err thrift.Exception) { - var err2 error - messageType := thrift.REPLY - switch result.(type) { - case thrift.ApplicationException: - messageType = thrift.EXCEPTION - } - if err2 = oprot.WriteMessageBegin("do_leaf", messageType, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - return err -} - -func (p *myLeafProcessorDoLeaf) Run(argStruct thrift.Struct) (thrift.WritableStruct, thrift.ApplicationException) { - var __result MyLeafDoLeafResult - if err := p.handler.DoLeaf(); err != nil { - switch err.(type) { - default: - x := thrift.NewApplicationExceptionCause(thrift.INTERNAL_ERROR, "Internal error processing do_leaf: " + err.Error(), err) - return x, x - } - } - return &__result, nil -} - - -// HELPER FUNCTIONS AND STRUCTURES - -type MyLeafDoLeafArgs struct { - thrift.IRequest -} - -func NewMyLeafDoLeafArgs() *MyLeafDoLeafArgs { - return &MyLeafDoLeafArgs{} -} - -type MyLeafDoLeafArgsBuilder struct { - obj *MyLeafDoLeafArgs -} - -func NewMyLeafDoLeafArgsBuilder() *MyLeafDoLeafArgsBuilder{ - return &MyLeafDoLeafArgsBuilder{ - obj: NewMyLeafDoLeafArgs(), - } -} - -func (p MyLeafDoLeafArgsBuilder) Emit() *MyLeafDoLeafArgs{ - return &MyLeafDoLeafArgs{ - } -} - -func (p *MyLeafDoLeafArgs) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyLeafDoLeafArgs) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("do_leaf_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyLeafDoLeafArgs) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("MyLeafDoLeafArgs({})") -} - -type MyLeafDoLeafResult struct { - thrift.IResponse -} - -func NewMyLeafDoLeafResult() *MyLeafDoLeafResult { - return &MyLeafDoLeafResult{} -} - -type MyLeafDoLeafResultBuilder struct { - obj *MyLeafDoLeafResult -} - -func NewMyLeafDoLeafResultBuilder() *MyLeafDoLeafResultBuilder{ - return &MyLeafDoLeafResultBuilder{ - obj: NewMyLeafDoLeafResult(), - } -} - -func (p MyLeafDoLeafResultBuilder) Emit() *MyLeafDoLeafResult{ - return &MyLeafDoLeafResult{ - } -} - -func (p *MyLeafDoLeafResult) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyLeafDoLeafResult) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("do_leaf_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyLeafDoLeafResult) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("MyLeafDoLeafResult({})") -} - - diff --git a/thrift/compiler/test/fixtures/inheritance/gen-go/module/mynode.go b/thrift/compiler/test/fixtures/inheritance/gen-go/module/mynode.go deleted file mode 100644 index 8ee6d603a10..00000000000 --- a/thrift/compiler/test/fixtures/inheritance/gen-go/module/mynode.go +++ /dev/null @@ -1,356 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package module - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -type MyNode interface { -MyRoot - - DoMid() (err error) -} - -type MyNodeClientInterface interface { - thrift.ClientInterface - DoMid() (err error) -} - -type MyNodeClient struct { - MyNodeClientInterface - *MyRootClient -} - -func(client *MyNodeClient) Open() error { - return client.CC.Open() -} - -func(client *MyNodeClient) Close() error { - return client.CC.Close() -} - -func(client *MyNodeClient) IsOpen() bool { - return client.CC.IsOpen() -} - -func NewMyNodeClientFactory(t thrift.Transport, f thrift.ProtocolFactory) *MyNodeClient { - return &MyNodeClient{MyRootClient: NewMyRootClientFactory(t, f)} -} - -func NewMyNodeClient(t thrift.Transport, iprot thrift.Protocol, oprot thrift.Protocol) *MyNodeClient { - return &MyNodeClient{MyRootClient: NewMyRootClient(t, iprot, oprot)} -} - -func NewMyNodeClientProtocol(prot thrift.Protocol) *MyNodeClient { - return NewMyNodeClient(prot.Transport(), prot, prot) -} - -func (p *MyNodeClient) DoMid() (err error) { - var args MyNodeDoMidArgs - err = p.CC.SendMsg("do_mid", &args, thrift.CALL) - if err != nil { return } - return p.recvDoMid() -} - - -func (p *MyNodeClient) recvDoMid() (err error) { - var __result MyNodeDoMidResult - return p.CC.RecvMsg("do_mid", &__result) -} - - -type MyNodeThreadsafeClient struct { - MyNodeClientInterface - *MyRootThreadsafeClient -} - -func(client *MyNodeThreadsafeClient) Open() error { - client.Mu.Lock() - defer client.Mu.Unlock() - return client.CC.Open() -} - -func(client *MyNodeThreadsafeClient) Close() error { - client.Mu.Lock() - defer client.Mu.Unlock() - return client.CC.Close() -} - -func(client *MyNodeThreadsafeClient) IsOpen() bool { - client.Mu.Lock() - defer client.Mu.Unlock() - return client.CC.IsOpen() -} - -func NewMyNodeThreadsafeClientFactory(t thrift.Transport, f thrift.ProtocolFactory) *MyNodeThreadsafeClient { - return &MyNodeThreadsafeClient{MyRootThreadsafeClient: NewMyRootThreadsafeClientFactory(t, f)} -} - -func NewMyNodeThreadsafeClient(t thrift.Transport, iprot thrift.Protocol, oprot thrift.Protocol) *MyNodeThreadsafeClient { - return &MyNodeThreadsafeClient{MyRootThreadsafeClient: NewMyRootThreadsafeClient(t, iprot, oprot)} -} - -func NewMyNodeThreadsafeClientProtocol(prot thrift.Protocol) *MyNodeThreadsafeClient { - return NewMyNodeThreadsafeClient(prot.Transport(), prot, prot) -} - -func (p *MyNodeThreadsafeClient) DoMid() (err error) { - p.Mu.Lock() - defer p.Mu.Unlock() - var args MyNodeDoMidArgs - err = p.CC.SendMsg("do_mid", &args, thrift.CALL) - if err != nil { return } - return p.recvDoMid() -} - - -func (p *MyNodeThreadsafeClient) recvDoMid() (err error) { - var __result MyNodeDoMidResult - return p.CC.RecvMsg("do_mid", &__result) -} - - -type MyNodeChannelClient struct { - *MyRootChannelClient -} - -func (c *MyNodeChannelClient) Close() error { - return c.RequestChannel.Close() -} - -func (c *MyNodeChannelClient) IsOpen() bool { - return c.RequestChannel.IsOpen() -} - -func (c *MyNodeChannelClient) Open() error { - return c.RequestChannel.Open() -} - -func NewMyNodeChannelClient(channel thrift.RequestChannel) *MyNodeChannelClient { - return &MyNodeChannelClient{MyRootChannelClient: NewMyRootChannelClient(channel)} -} - -func (p *MyNodeChannelClient) DoMid(ctx context.Context) (err error) { - args := MyNodeDoMidArgs{ - } - var __result MyNodeDoMidResult - err = p.RequestChannel.Call(ctx, "do_mid", &args, &__result) - if err != nil { return } - - return nil -} - - -type MyNodeProcessor struct { - *MyRootProcessor -} - -func NewMyNodeProcessor(handler MyNode) *MyNodeProcessor { - self2 := &MyNodeProcessor{NewMyRootProcessor(handler)} - self2.AddToProcessorMap("do_mid", &myNodeProcessorDoMid{handler:handler}) - self2.AddToFunctionServiceMap("do_mid", "MyNode") - return self2 -} - -type myNodeProcessorDoMid struct { - handler MyNode -} - -func (p *MyNodeDoMidResult) Exception() thrift.WritableException { - if p == nil { return nil } - return nil -} - -func (p *myNodeProcessorDoMid) Read(iprot thrift.Protocol) (thrift.Struct, thrift.Exception) { - args := MyNodeDoMidArgs{} - if err := args.Read(iprot); err != nil { - return nil, err - } - iprot.ReadMessageEnd() - return &args, nil -} - -func (p *myNodeProcessorDoMid) Write(seqId int32, result thrift.WritableStruct, oprot thrift.Protocol) (err thrift.Exception) { - var err2 error - messageType := thrift.REPLY - switch result.(type) { - case thrift.ApplicationException: - messageType = thrift.EXCEPTION - } - if err2 = oprot.WriteMessageBegin("do_mid", messageType, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - return err -} - -func (p *myNodeProcessorDoMid) Run(argStruct thrift.Struct) (thrift.WritableStruct, thrift.ApplicationException) { - var __result MyNodeDoMidResult - if err := p.handler.DoMid(); err != nil { - switch err.(type) { - default: - x := thrift.NewApplicationExceptionCause(thrift.INTERNAL_ERROR, "Internal error processing do_mid: " + err.Error(), err) - return x, x - } - } - return &__result, nil -} - - -// HELPER FUNCTIONS AND STRUCTURES - -type MyNodeDoMidArgs struct { - thrift.IRequest -} - -func NewMyNodeDoMidArgs() *MyNodeDoMidArgs { - return &MyNodeDoMidArgs{} -} - -type MyNodeDoMidArgsBuilder struct { - obj *MyNodeDoMidArgs -} - -func NewMyNodeDoMidArgsBuilder() *MyNodeDoMidArgsBuilder{ - return &MyNodeDoMidArgsBuilder{ - obj: NewMyNodeDoMidArgs(), - } -} - -func (p MyNodeDoMidArgsBuilder) Emit() *MyNodeDoMidArgs{ - return &MyNodeDoMidArgs{ - } -} - -func (p *MyNodeDoMidArgs) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyNodeDoMidArgs) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("do_mid_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyNodeDoMidArgs) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("MyNodeDoMidArgs({})") -} - -type MyNodeDoMidResult struct { - thrift.IResponse -} - -func NewMyNodeDoMidResult() *MyNodeDoMidResult { - return &MyNodeDoMidResult{} -} - -type MyNodeDoMidResultBuilder struct { - obj *MyNodeDoMidResult -} - -func NewMyNodeDoMidResultBuilder() *MyNodeDoMidResultBuilder{ - return &MyNodeDoMidResultBuilder{ - obj: NewMyNodeDoMidResult(), - } -} - -func (p MyNodeDoMidResultBuilder) Emit() *MyNodeDoMidResult{ - return &MyNodeDoMidResult{ - } -} - -func (p *MyNodeDoMidResult) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyNodeDoMidResult) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("do_mid_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyNodeDoMidResult) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("MyNodeDoMidResult({})") -} - - diff --git a/thrift/compiler/test/fixtures/inheritance/gen-go/module/myroot.go b/thrift/compiler/test/fixtures/inheritance/gen-go/module/myroot.go deleted file mode 100644 index b39ffaafb96..00000000000 --- a/thrift/compiler/test/fixtures/inheritance/gen-go/module/myroot.go +++ /dev/null @@ -1,380 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package module - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -type MyRoot interface { - DoRoot() (err error) -} - -type MyRootClientInterface interface { - thrift.ClientInterface - DoRoot() (err error) -} - -type MyRootClient struct { - MyRootClientInterface - CC thrift.ClientConn -} - -func(client *MyRootClient) Open() error { - return client.CC.Open() -} - -func(client *MyRootClient) Close() error { - return client.CC.Close() -} - -func(client *MyRootClient) IsOpen() bool { - return client.CC.IsOpen() -} - -func NewMyRootClientFactory(t thrift.Transport, f thrift.ProtocolFactory) *MyRootClient { - return &MyRootClient{ CC: thrift.NewClientConn(t, f) } -} - -func NewMyRootClient(t thrift.Transport, iprot thrift.Protocol, oprot thrift.Protocol) *MyRootClient { - return &MyRootClient{ CC: thrift.NewClientConnWithProtocols(t, iprot, oprot) } -} - -func NewMyRootClientProtocol(prot thrift.Protocol) *MyRootClient { - return NewMyRootClient(prot.Transport(), prot, prot) -} - -func (p *MyRootClient) DoRoot() (err error) { - var args MyRootDoRootArgs - err = p.CC.SendMsg("do_root", &args, thrift.CALL) - if err != nil { return } - return p.recvDoRoot() -} - - -func (p *MyRootClient) recvDoRoot() (err error) { - var __result MyRootDoRootResult - return p.CC.RecvMsg("do_root", &__result) -} - - -type MyRootThreadsafeClient struct { - MyRootClientInterface - CC thrift.ClientConn - Mu sync.Mutex -} - -func(client *MyRootThreadsafeClient) Open() error { - client.Mu.Lock() - defer client.Mu.Unlock() - return client.CC.Open() -} - -func(client *MyRootThreadsafeClient) Close() error { - client.Mu.Lock() - defer client.Mu.Unlock() - return client.CC.Close() -} - -func(client *MyRootThreadsafeClient) IsOpen() bool { - client.Mu.Lock() - defer client.Mu.Unlock() - return client.CC.IsOpen() -} - -func NewMyRootThreadsafeClientFactory(t thrift.Transport, f thrift.ProtocolFactory) *MyRootThreadsafeClient { - return &MyRootThreadsafeClient{ CC: thrift.NewClientConn(t, f) } -} - -func NewMyRootThreadsafeClient(t thrift.Transport, iprot thrift.Protocol, oprot thrift.Protocol) *MyRootThreadsafeClient { - return &MyRootThreadsafeClient{ CC: thrift.NewClientConnWithProtocols(t, iprot, oprot) } -} - -func NewMyRootThreadsafeClientProtocol(prot thrift.Protocol) *MyRootThreadsafeClient { - return NewMyRootThreadsafeClient(prot.Transport(), prot, prot) -} - -func (p *MyRootThreadsafeClient) DoRoot() (err error) { - p.Mu.Lock() - defer p.Mu.Unlock() - var args MyRootDoRootArgs - err = p.CC.SendMsg("do_root", &args, thrift.CALL) - if err != nil { return } - return p.recvDoRoot() -} - - -func (p *MyRootThreadsafeClient) recvDoRoot() (err error) { - var __result MyRootDoRootResult - return p.CC.RecvMsg("do_root", &__result) -} - - -type MyRootChannelClient struct { - RequestChannel thrift.RequestChannel -} - -func (c *MyRootChannelClient) Close() error { - return c.RequestChannel.Close() -} - -func (c *MyRootChannelClient) IsOpen() bool { - return c.RequestChannel.IsOpen() -} - -func (c *MyRootChannelClient) Open() error { - return c.RequestChannel.Open() -} - -func NewMyRootChannelClient(channel thrift.RequestChannel) *MyRootChannelClient { - return &MyRootChannelClient{RequestChannel: channel} -} - -func (p *MyRootChannelClient) DoRoot(ctx context.Context) (err error) { - args := MyRootDoRootArgs{ - } - var __result MyRootDoRootResult - err = p.RequestChannel.Call(ctx, "do_root", &args, &__result) - if err != nil { return } - - return nil -} - - -type MyRootProcessor struct { - processorMap map[string]thrift.ProcessorFunction - functionServiceMap map[string]string - handler MyRoot -} - -func (p *MyRootProcessor) AddToProcessorMap(key string, processor thrift.ProcessorFunction) { - p.processorMap[key] = processor -} - -func (p *MyRootProcessor) AddToFunctionServiceMap(key, service string) { - p.functionServiceMap[key] = service -} - -func (p *MyRootProcessor) GetProcessorFunction(key string) (processor thrift.ProcessorFunction, err error) { - if processor, ok := p.processorMap[key]; ok { - return processor, nil - } - return nil, nil // generic error message will be sent -} - -func (p *MyRootProcessor) ProcessorMap() map[string]thrift.ProcessorFunction { - return p.processorMap -} - -func (p *MyRootProcessor) FunctionServiceMap() map[string]string { - return p.functionServiceMap -} - -func NewMyRootProcessor(handler MyRoot) *MyRootProcessor { - self0 := &MyRootProcessor{handler:handler, processorMap:make(map[string]thrift.ProcessorFunction), functionServiceMap:make(map[string]string)} - self0.processorMap["do_root"] = &myRootProcessorDoRoot{handler:handler} - self0.functionServiceMap["do_root"] = "MyRoot" - return self0 -} - -type myRootProcessorDoRoot struct { - handler MyRoot -} - -func (p *MyRootDoRootResult) Exception() thrift.WritableException { - if p == nil { return nil } - return nil -} - -func (p *myRootProcessorDoRoot) Read(iprot thrift.Protocol) (thrift.Struct, thrift.Exception) { - args := MyRootDoRootArgs{} - if err := args.Read(iprot); err != nil { - return nil, err - } - iprot.ReadMessageEnd() - return &args, nil -} - -func (p *myRootProcessorDoRoot) Write(seqId int32, result thrift.WritableStruct, oprot thrift.Protocol) (err thrift.Exception) { - var err2 error - messageType := thrift.REPLY - switch result.(type) { - case thrift.ApplicationException: - messageType = thrift.EXCEPTION - } - if err2 = oprot.WriteMessageBegin("do_root", messageType, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - return err -} - -func (p *myRootProcessorDoRoot) Run(argStruct thrift.Struct) (thrift.WritableStruct, thrift.ApplicationException) { - var __result MyRootDoRootResult - if err := p.handler.DoRoot(); err != nil { - switch err.(type) { - default: - x := thrift.NewApplicationExceptionCause(thrift.INTERNAL_ERROR, "Internal error processing do_root: " + err.Error(), err) - return x, x - } - } - return &__result, nil -} - - -// HELPER FUNCTIONS AND STRUCTURES - -type MyRootDoRootArgs struct { - thrift.IRequest -} - -func NewMyRootDoRootArgs() *MyRootDoRootArgs { - return &MyRootDoRootArgs{} -} - -type MyRootDoRootArgsBuilder struct { - obj *MyRootDoRootArgs -} - -func NewMyRootDoRootArgsBuilder() *MyRootDoRootArgsBuilder{ - return &MyRootDoRootArgsBuilder{ - obj: NewMyRootDoRootArgs(), - } -} - -func (p MyRootDoRootArgsBuilder) Emit() *MyRootDoRootArgs{ - return &MyRootDoRootArgs{ - } -} - -func (p *MyRootDoRootArgs) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyRootDoRootArgs) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("do_root_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyRootDoRootArgs) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("MyRootDoRootArgs({})") -} - -type MyRootDoRootResult struct { - thrift.IResponse -} - -func NewMyRootDoRootResult() *MyRootDoRootResult { - return &MyRootDoRootResult{} -} - -type MyRootDoRootResultBuilder struct { - obj *MyRootDoRootResult -} - -func NewMyRootDoRootResultBuilder() *MyRootDoRootResultBuilder{ - return &MyRootDoRootResultBuilder{ - obj: NewMyRootDoRootResult(), - } -} - -func (p MyRootDoRootResultBuilder) Emit() *MyRootDoRootResult{ - return &MyRootDoRootResult{ - } -} - -func (p *MyRootDoRootResult) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyRootDoRootResult) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("do_root_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyRootDoRootResult) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("MyRootDoRootResult({})") -} - - diff --git a/thrift/compiler/test/fixtures/inheritance/gen-go/module/ttypes.go b/thrift/compiler/test/fixtures/inheritance/gen-go/module/ttypes.go deleted file mode 100644 index 75439abe961..00000000000 --- a/thrift/compiler/test/fixtures/inheritance/gen-go/module/ttypes.go +++ /dev/null @@ -1,23 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package module - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var GoUnusedProtection__ int; - diff --git a/thrift/compiler/test/fixtures/inject_metadata_fields/gen-go/foo/constants.go b/thrift/compiler/test/fixtures/inject_metadata_fields/gen-go/foo/constants.go deleted file mode 100644 index 70da2c13806..00000000000 --- a/thrift/compiler/test/fixtures/inject_metadata_fields/gen-go/foo/constants.go +++ /dev/null @@ -1,25 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package foo - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - - -func init() { -} - diff --git a/thrift/compiler/test/fixtures/inject_metadata_fields/gen-go/foo/ttypes.go b/thrift/compiler/test/fixtures/inject_metadata_fields/gen-go/foo/ttypes.go deleted file mode 100644 index 1d0b01aaced..00000000000 --- a/thrift/compiler/test/fixtures/inject_metadata_fields/gen-go/foo/ttypes.go +++ /dev/null @@ -1,247 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package foo - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var GoUnusedProtection__ int; - -// Attributes: -// - InjectedField -// - InjectedStructuredAnnotationField -// - InjectedUnstructuredAnnotationField -type Fields struct { - // unused fields # 1 to 99 - InjectedField string `thrift:"injected_field,100" db:"injected_field" json:"injected_field"` - InjectedStructuredAnnotationField *string `thrift:"injected_structured_annotation_field,101,optional" db:"injected_structured_annotation_field" json:"injected_structured_annotation_field,omitempty"` - InjectedUnstructuredAnnotationField *string `thrift:"injected_unstructured_annotation_field,102,optional" db:"injected_unstructured_annotation_field" json:"injected_unstructured_annotation_field,omitempty"` -} - -func NewFields() *Fields { - return &Fields{} -} - - -func (p *Fields) GetInjectedField() string { - return p.InjectedField -} -var Fields_InjectedStructuredAnnotationField_DEFAULT string -func (p *Fields) GetInjectedStructuredAnnotationField() string { - if !p.IsSetInjectedStructuredAnnotationField() { - return Fields_InjectedStructuredAnnotationField_DEFAULT - } - return *p.InjectedStructuredAnnotationField -} -var Fields_InjectedUnstructuredAnnotationField_DEFAULT string -func (p *Fields) GetInjectedUnstructuredAnnotationField() string { - if !p.IsSetInjectedUnstructuredAnnotationField() { - return Fields_InjectedUnstructuredAnnotationField_DEFAULT - } - return *p.InjectedUnstructuredAnnotationField -} -func (p *Fields) IsSetInjectedStructuredAnnotationField() bool { - return p != nil && p.InjectedStructuredAnnotationField != nil -} - -func (p *Fields) IsSetInjectedUnstructuredAnnotationField() bool { - return p != nil && p.InjectedUnstructuredAnnotationField != nil -} - -type FieldsBuilder struct { - obj *Fields -} - -func NewFieldsBuilder() *FieldsBuilder{ - return &FieldsBuilder{ - obj: NewFields(), - } -} - -func (p FieldsBuilder) Emit() *Fields{ - return &Fields{ - InjectedField: p.obj.InjectedField, - InjectedStructuredAnnotationField: p.obj.InjectedStructuredAnnotationField, - InjectedUnstructuredAnnotationField: p.obj.InjectedUnstructuredAnnotationField, - } -} - -func (f *FieldsBuilder) InjectedField(injectedField string) *FieldsBuilder { - f.obj.InjectedField = injectedField - return f -} - -func (f *FieldsBuilder) InjectedStructuredAnnotationField(injectedStructuredAnnotationField *string) *FieldsBuilder { - f.obj.InjectedStructuredAnnotationField = injectedStructuredAnnotationField - return f -} - -func (f *FieldsBuilder) InjectedUnstructuredAnnotationField(injectedUnstructuredAnnotationField *string) *FieldsBuilder { - f.obj.InjectedUnstructuredAnnotationField = injectedUnstructuredAnnotationField - return f -} - -func (f *Fields) SetInjectedField(injectedField string) *Fields { - f.InjectedField = injectedField - return f -} - -func (f *Fields) SetInjectedStructuredAnnotationField(injectedStructuredAnnotationField *string) *Fields { - f.InjectedStructuredAnnotationField = injectedStructuredAnnotationField - return f -} - -func (f *Fields) SetInjectedUnstructuredAnnotationField(injectedUnstructuredAnnotationField *string) *Fields { - f.InjectedUnstructuredAnnotationField = injectedUnstructuredAnnotationField - return f -} - -func (p *Fields) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 100: - if err := p.ReadField100(iprot); err != nil { - return err - } - case 101: - if err := p.ReadField101(iprot); err != nil { - return err - } - case 102: - if err := p.ReadField102(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Fields) ReadField100(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 100: ", err) - } else { - p.InjectedField = v - } - return nil -} - -func (p *Fields) ReadField101(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 101: ", err) - } else { - p.InjectedStructuredAnnotationField = &v - } - return nil -} - -func (p *Fields) ReadField102(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 102: ", err) - } else { - p.InjectedUnstructuredAnnotationField = &v - } - return nil -} - -func (p *Fields) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Fields"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField100(oprot); err != nil { return err } - if err := p.writeField101(oprot); err != nil { return err } - if err := p.writeField102(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Fields) writeField100(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("injected_field", thrift.STRING, 100); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 100:injected_field: ", p), err) } - if err := oprot.WriteString(string(p.InjectedField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.injected_field (100) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 100:injected_field: ", p), err) } - return err -} - -func (p *Fields) writeField101(oprot thrift.Protocol) (err error) { - if p.IsSetInjectedStructuredAnnotationField() { - if err := oprot.WriteFieldBegin("injected_structured_annotation_field", thrift.STRING, 101); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 101:injected_structured_annotation_field: ", p), err) } - if err := oprot.WriteString(string(*p.InjectedStructuredAnnotationField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.injected_structured_annotation_field (101) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 101:injected_structured_annotation_field: ", p), err) } - } - return err -} - -func (p *Fields) writeField102(oprot thrift.Protocol) (err error) { - if p.IsSetInjectedUnstructuredAnnotationField() { - if err := oprot.WriteFieldBegin("injected_unstructured_annotation_field", thrift.STRING, 102); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 102:injected_unstructured_annotation_field: ", p), err) } - if err := oprot.WriteString(string(*p.InjectedUnstructuredAnnotationField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.injected_unstructured_annotation_field (102) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 102:injected_unstructured_annotation_field: ", p), err) } - } - return err -} - -func (p *Fields) String() string { - if p == nil { - return "" - } - - injectedFieldVal := fmt.Sprintf("%v", p.InjectedField) - var injectedStructuredAnnotationFieldVal string - if p.InjectedStructuredAnnotationField == nil { - injectedStructuredAnnotationFieldVal = "" - } else { - injectedStructuredAnnotationFieldVal = fmt.Sprintf("%v", *p.InjectedStructuredAnnotationField) - } - var injectedUnstructuredAnnotationFieldVal string - if p.InjectedUnstructuredAnnotationField == nil { - injectedUnstructuredAnnotationFieldVal = "" - } else { - injectedUnstructuredAnnotationFieldVal = fmt.Sprintf("%v", *p.InjectedUnstructuredAnnotationField) - } - return fmt.Sprintf("Fields({InjectedField:%s InjectedStructuredAnnotationField:%s InjectedUnstructuredAnnotationField:%s})", injectedFieldVal, injectedStructuredAnnotationFieldVal, injectedUnstructuredAnnotationFieldVal) -} - diff --git a/thrift/compiler/test/fixtures/inject_metadata_fields/gen-go/module/constants.go b/thrift/compiler/test/fixtures/inject_metadata_fields/gen-go/module/constants.go deleted file mode 100644 index 78f312b96cc..00000000000 --- a/thrift/compiler/test/fixtures/inject_metadata_fields/gen-go/module/constants.go +++ /dev/null @@ -1,28 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package module - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" - foo0 "foo" - -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var _ = foo0.GoUnusedProtection__ - -func init() { -} - diff --git a/thrift/compiler/test/fixtures/inject_metadata_fields/gen-go/module/ttypes.go b/thrift/compiler/test/fixtures/inject_metadata_fields/gen-go/module/ttypes.go deleted file mode 100644 index 5904f5dcc68..00000000000 --- a/thrift/compiler/test/fixtures/inject_metadata_fields/gen-go/module/ttypes.go +++ /dev/null @@ -1,667 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package module - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" - foo0 "foo" - -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var _ = foo0.GoUnusedProtection__ -var GoUnusedProtection__ int; - -// Attributes: -// - InjectedField -type Fields struct { - // unused fields # 1 to 99 - InjectedField string `thrift:"injected_field,100" db:"injected_field" json:"injected_field"` -} - -func NewFields() *Fields { - return &Fields{} -} - - -func (p *Fields) GetInjectedField() string { - return p.InjectedField -} -type FieldsBuilder struct { - obj *Fields -} - -func NewFieldsBuilder() *FieldsBuilder{ - return &FieldsBuilder{ - obj: NewFields(), - } -} - -func (p FieldsBuilder) Emit() *Fields{ - return &Fields{ - InjectedField: p.obj.InjectedField, - } -} - -func (f *FieldsBuilder) InjectedField(injectedField string) *FieldsBuilder { - f.obj.InjectedField = injectedField - return f -} - -func (f *Fields) SetInjectedField(injectedField string) *Fields { - f.InjectedField = injectedField - return f -} - -func (p *Fields) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 100: - if err := p.ReadField100(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Fields) ReadField100(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 100: ", err) - } else { - p.InjectedField = v - } - return nil -} - -func (p *Fields) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Fields"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField100(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Fields) writeField100(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("injected_field", thrift.STRING, 100); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 100:injected_field: ", p), err) } - if err := oprot.WriteString(string(p.InjectedField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.injected_field (100) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 100:injected_field: ", p), err) } - return err -} - -func (p *Fields) String() string { - if p == nil { - return "" - } - - injectedFieldVal := fmt.Sprintf("%v", p.InjectedField) - return fmt.Sprintf("Fields({InjectedField:%s})", injectedFieldVal) -} - -// Attributes: -// - InjectedField -type FieldsInjectedToEmptyStruct struct { - InjectedField string -} - -func NewFieldsInjectedToEmptyStruct() *FieldsInjectedToEmptyStruct { - return &FieldsInjectedToEmptyStruct{} -} - - -func (p *FieldsInjectedToEmptyStruct) GetInjectedField() string { - return p.InjectedField -} -type FieldsInjectedToEmptyStructBuilder struct { - obj *FieldsInjectedToEmptyStruct -} - -func NewFieldsInjectedToEmptyStructBuilder() *FieldsInjectedToEmptyStructBuilder{ - return &FieldsInjectedToEmptyStructBuilder{ - obj: NewFieldsInjectedToEmptyStruct(), - } -} - -func (p FieldsInjectedToEmptyStructBuilder) Emit() *FieldsInjectedToEmptyStruct{ - return &FieldsInjectedToEmptyStruct{ - InjectedField: p.obj.InjectedField, - } -} - -func (f *FieldsInjectedToEmptyStructBuilder) InjectedField(injectedField string) *FieldsInjectedToEmptyStructBuilder { - f.obj.InjectedField = injectedField - return f -} - -func (f *FieldsInjectedToEmptyStruct) SetInjectedField(injectedField string) *FieldsInjectedToEmptyStruct { - f.InjectedField = injectedField - return f -} - -func (p *FieldsInjectedToEmptyStruct) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case -1100: - if err := p.ReadField_1100(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *FieldsInjectedToEmptyStruct) ReadField_1100(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field -1100: ", err) - } else { - p.InjectedField = v - } - return nil -} - -func (p *FieldsInjectedToEmptyStruct) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("FieldsInjectedToEmptyStruct"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField_1100(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *FieldsInjectedToEmptyStruct) writeField_1100(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("injected_field", thrift.STRING, -1100); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -1100:injected_field: ", p), err) } - if err := oprot.WriteString(string(p.InjectedField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.injected_field (-1100) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -1100:injected_field: ", p), err) } - return err -} - -func (p *FieldsInjectedToEmptyStruct) String() string { - if p == nil { - return "" - } - - injectedFieldVal := fmt.Sprintf("%v", p.InjectedField) - return fmt.Sprintf("FieldsInjectedToEmptyStruct({InjectedField:%s})", injectedFieldVal) -} - -// Attributes: -// - StringField -// - InjectedField -type FieldsInjectedToStruct struct { - StringField string - InjectedField string -} - -func NewFieldsInjectedToStruct() *FieldsInjectedToStruct { - return &FieldsInjectedToStruct{} -} - - -func (p *FieldsInjectedToStruct) GetStringField() string { - return p.StringField -} - -func (p *FieldsInjectedToStruct) GetInjectedField() string { - return p.InjectedField -} -type FieldsInjectedToStructBuilder struct { - obj *FieldsInjectedToStruct -} - -func NewFieldsInjectedToStructBuilder() *FieldsInjectedToStructBuilder{ - return &FieldsInjectedToStructBuilder{ - obj: NewFieldsInjectedToStruct(), - } -} - -func (p FieldsInjectedToStructBuilder) Emit() *FieldsInjectedToStruct{ - return &FieldsInjectedToStruct{ - StringField: p.obj.StringField, - InjectedField: p.obj.InjectedField, - } -} - -func (f *FieldsInjectedToStructBuilder) StringField(stringField string) *FieldsInjectedToStructBuilder { - f.obj.StringField = stringField - return f -} - -func (f *FieldsInjectedToStructBuilder) InjectedField(injectedField string) *FieldsInjectedToStructBuilder { - f.obj.InjectedField = injectedField - return f -} - -func (f *FieldsInjectedToStruct) SetStringField(stringField string) *FieldsInjectedToStruct { - f.StringField = stringField - return f -} - -func (f *FieldsInjectedToStruct) SetInjectedField(injectedField string) *FieldsInjectedToStruct { - f.InjectedField = injectedField - return f -} - -func (p *FieldsInjectedToStruct) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case -1100: - if err := p.ReadField_1100(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *FieldsInjectedToStruct) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.StringField = v - } - return nil -} - -func (p *FieldsInjectedToStruct) ReadField_1100(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field -1100: ", err) - } else { - p.InjectedField = v - } - return nil -} - -func (p *FieldsInjectedToStruct) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("FieldsInjectedToStruct"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField_1100(oprot); err != nil { return err } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *FieldsInjectedToStruct) writeField_1100(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("injected_field", thrift.STRING, -1100); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -1100:injected_field: ", p), err) } - if err := oprot.WriteString(string(p.InjectedField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.injected_field (-1100) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -1100:injected_field: ", p), err) } - return err -} - -func (p *FieldsInjectedToStruct) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("string_field", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:string_field: ", p), err) } - if err := oprot.WriteString(string(p.StringField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.string_field (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:string_field: ", p), err) } - return err -} - -func (p *FieldsInjectedToStruct) String() string { - if p == nil { - return "" - } - - injectedFieldVal := fmt.Sprintf("%v", p.InjectedField) - stringFieldVal := fmt.Sprintf("%v", p.StringField) - return fmt.Sprintf("FieldsInjectedToStruct({InjectedField:%s StringField:%s})", injectedFieldVal, stringFieldVal) -} - -// Attributes: -// - StringField -// - InjectedField -// - InjectedStructuredAnnotationField -// - InjectedUnstructuredAnnotationField -type FieldsInjectedWithIncludedStruct struct { - StringField string - InjectedField string - InjectedStructuredAnnotationField string - InjectedUnstructuredAnnotationField string -} - -func NewFieldsInjectedWithIncludedStruct() *FieldsInjectedWithIncludedStruct { - return &FieldsInjectedWithIncludedStruct{} -} - - -func (p *FieldsInjectedWithIncludedStruct) GetStringField() string { - return p.StringField -} - -func (p *FieldsInjectedWithIncludedStruct) GetInjectedField() string { - return p.InjectedField -} -var FieldsInjectedWithIncludedStruct_InjectedStructuredAnnotationField_DEFAULT string -func (p *FieldsInjectedWithIncludedStruct) GetInjectedStructuredAnnotationField() string { - if !p.IsSetInjectedStructuredAnnotationField() { - return FieldsInjectedWithIncludedStruct_InjectedStructuredAnnotationField_DEFAULT - } - return *p.InjectedStructuredAnnotationField -} -var FieldsInjectedWithIncludedStruct_InjectedUnstructuredAnnotationField_DEFAULT string -func (p *FieldsInjectedWithIncludedStruct) GetInjectedUnstructuredAnnotationField() string { - if !p.IsSetInjectedUnstructuredAnnotationField() { - return FieldsInjectedWithIncludedStruct_InjectedUnstructuredAnnotationField_DEFAULT - } - return *p.InjectedUnstructuredAnnotationField -} -func (p *FieldsInjectedWithIncludedStruct) IsSetInjectedStructuredAnnotationField() bool { - return p != nil && p.InjectedStructuredAnnotationField != nil -} - -func (p *FieldsInjectedWithIncludedStruct) IsSetInjectedUnstructuredAnnotationField() bool { - return p != nil && p.InjectedUnstructuredAnnotationField != nil -} - -type FieldsInjectedWithIncludedStructBuilder struct { - obj *FieldsInjectedWithIncludedStruct -} - -func NewFieldsInjectedWithIncludedStructBuilder() *FieldsInjectedWithIncludedStructBuilder{ - return &FieldsInjectedWithIncludedStructBuilder{ - obj: NewFieldsInjectedWithIncludedStruct(), - } -} - -func (p FieldsInjectedWithIncludedStructBuilder) Emit() *FieldsInjectedWithIncludedStruct{ - return &FieldsInjectedWithIncludedStruct{ - StringField: p.obj.StringField, - InjectedField: p.obj.InjectedField, - InjectedStructuredAnnotationField: p.obj.InjectedStructuredAnnotationField, - InjectedUnstructuredAnnotationField: p.obj.InjectedUnstructuredAnnotationField, - } -} - -func (f *FieldsInjectedWithIncludedStructBuilder) StringField(stringField string) *FieldsInjectedWithIncludedStructBuilder { - f.obj.StringField = stringField - return f -} - -func (f *FieldsInjectedWithIncludedStructBuilder) InjectedField(injectedField string) *FieldsInjectedWithIncludedStructBuilder { - f.obj.InjectedField = injectedField - return f -} - -func (f *FieldsInjectedWithIncludedStructBuilder) InjectedStructuredAnnotationField(injectedStructuredAnnotationField *string) *FieldsInjectedWithIncludedStructBuilder { - f.obj.InjectedStructuredAnnotationField = injectedStructuredAnnotationField - return f -} - -func (f *FieldsInjectedWithIncludedStructBuilder) InjectedUnstructuredAnnotationField(injectedUnstructuredAnnotationField *string) *FieldsInjectedWithIncludedStructBuilder { - f.obj.InjectedUnstructuredAnnotationField = injectedUnstructuredAnnotationField - return f -} - -func (f *FieldsInjectedWithIncludedStruct) SetStringField(stringField string) *FieldsInjectedWithIncludedStruct { - f.StringField = stringField - return f -} - -func (f *FieldsInjectedWithIncludedStruct) SetInjectedField(injectedField string) *FieldsInjectedWithIncludedStruct { - f.InjectedField = injectedField - return f -} - -func (f *FieldsInjectedWithIncludedStruct) SetInjectedStructuredAnnotationField(injectedStructuredAnnotationField *string) *FieldsInjectedWithIncludedStruct { - f.InjectedStructuredAnnotationField = injectedStructuredAnnotationField - return f -} - -func (f *FieldsInjectedWithIncludedStruct) SetInjectedUnstructuredAnnotationField(injectedUnstructuredAnnotationField *string) *FieldsInjectedWithIncludedStruct { - f.InjectedUnstructuredAnnotationField = injectedUnstructuredAnnotationField - return f -} - -func (p *FieldsInjectedWithIncludedStruct) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case -1100: - if err := p.ReadField_1100(iprot); err != nil { - return err - } - case -1101: - if err := p.ReadField_1101(iprot); err != nil { - return err - } - case -1102: - if err := p.ReadField_1102(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *FieldsInjectedWithIncludedStruct) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.StringField = v - } - return nil -} - -func (p *FieldsInjectedWithIncludedStruct) ReadField_1100(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field -1100: ", err) - } else { - p.InjectedField = v - } - return nil -} - -func (p *FieldsInjectedWithIncludedStruct) ReadField_1101(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field -1101: ", err) - } else { - p.InjectedStructuredAnnotationField = &v - } - return nil -} - -func (p *FieldsInjectedWithIncludedStruct) ReadField_1102(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field -1102: ", err) - } else { - p.InjectedUnstructuredAnnotationField = &v - } - return nil -} - -func (p *FieldsInjectedWithIncludedStruct) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("FieldsInjectedWithIncludedStruct"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField_1102(oprot); err != nil { return err } - if err := p.writeField_1101(oprot); err != nil { return err } - if err := p.writeField_1100(oprot); err != nil { return err } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *FieldsInjectedWithIncludedStruct) writeField_1102(oprot thrift.Protocol) (err error) { - if p.IsSetInjectedUnstructuredAnnotationField() { - if err := oprot.WriteFieldBegin("injected_unstructured_annotation_field", thrift.STRING, -1102); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -1102:injected_unstructured_annotation_field: ", p), err) } - if err := oprot.WriteString(string(*p.InjectedUnstructuredAnnotationField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.injected_unstructured_annotation_field (-1102) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -1102:injected_unstructured_annotation_field: ", p), err) } - } - return err -} - -func (p *FieldsInjectedWithIncludedStruct) writeField_1101(oprot thrift.Protocol) (err error) { - if p.IsSetInjectedStructuredAnnotationField() { - if err := oprot.WriteFieldBegin("injected_structured_annotation_field", thrift.STRING, -1101); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -1101:injected_structured_annotation_field: ", p), err) } - if err := oprot.WriteString(string(*p.InjectedStructuredAnnotationField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.injected_structured_annotation_field (-1101) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -1101:injected_structured_annotation_field: ", p), err) } - } - return err -} - -func (p *FieldsInjectedWithIncludedStruct) writeField_1100(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("injected_field", thrift.STRING, -1100); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -1100:injected_field: ", p), err) } - if err := oprot.WriteString(string(p.InjectedField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.injected_field (-1100) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -1100:injected_field: ", p), err) } - return err -} - -func (p *FieldsInjectedWithIncludedStruct) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("string_field", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:string_field: ", p), err) } - if err := oprot.WriteString(string(p.StringField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.string_field (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:string_field: ", p), err) } - return err -} - -func (p *FieldsInjectedWithIncludedStruct) String() string { - if p == nil { - return "" - } - - var injectedUnstructuredAnnotationFieldVal string - if p.InjectedUnstructuredAnnotationField == nil { - injectedUnstructuredAnnotationFieldVal = "" - } else { - injectedUnstructuredAnnotationFieldVal = fmt.Sprintf("%v", *p.InjectedUnstructuredAnnotationField) - } - var injectedStructuredAnnotationFieldVal string - if p.InjectedStructuredAnnotationField == nil { - injectedStructuredAnnotationFieldVal = "" - } else { - injectedStructuredAnnotationFieldVal = fmt.Sprintf("%v", *p.InjectedStructuredAnnotationField) - } - injectedFieldVal := fmt.Sprintf("%v", p.InjectedField) - stringFieldVal := fmt.Sprintf("%v", p.StringField) - return fmt.Sprintf("FieldsInjectedWithIncludedStruct({InjectedUnstructuredAnnotationField:%s InjectedStructuredAnnotationField:%s InjectedField:%s StringField:%s})", injectedUnstructuredAnnotationFieldVal, injectedStructuredAnnotationFieldVal, injectedFieldVal, stringFieldVal) -} - diff --git a/thrift/compiler/test/fixtures/inject_metadata_fields/gen-go/thrift/annotation/internals/constants.go b/thrift/compiler/test/fixtures/inject_metadata_fields/gen-go/thrift/annotation/internals/constants.go deleted file mode 100644 index 6a0afaf2a65..00000000000 --- a/thrift/compiler/test/fixtures/inject_metadata_fields/gen-go/thrift/annotation/internals/constants.go +++ /dev/null @@ -1,25 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package internals - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - - -func init() { -} - diff --git a/thrift/compiler/test/fixtures/inject_metadata_fields/gen-go/thrift/annotation/internals/ttypes.go b/thrift/compiler/test/fixtures/inject_metadata_fields/gen-go/thrift/annotation/internals/ttypes.go deleted file mode 100644 index ac734c0a26b..00000000000 --- a/thrift/compiler/test/fixtures/inject_metadata_fields/gen-go/thrift/annotation/internals/ttypes.go +++ /dev/null @@ -1,134 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package internals - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var GoUnusedProtection__ int; - -// Attributes: -// - Type -type InjectMetadataFields struct { - Type string `thrift:"type,1" db:"type" json:"type"` -} - -func NewInjectMetadataFields() *InjectMetadataFields { - return &InjectMetadataFields{} -} - - -func (p *InjectMetadataFields) GetType() string { - return p.Type -} -type InjectMetadataFieldsBuilder struct { - obj *InjectMetadataFields -} - -func NewInjectMetadataFieldsBuilder() *InjectMetadataFieldsBuilder{ - return &InjectMetadataFieldsBuilder{ - obj: NewInjectMetadataFields(), - } -} - -func (p InjectMetadataFieldsBuilder) Emit() *InjectMetadataFields{ - return &InjectMetadataFields{ - Type: p.obj.Type, - } -} - -func (i *InjectMetadataFieldsBuilder) Type(type_a1 string) *InjectMetadataFieldsBuilder { - i.obj.Type = type_a1 - return i -} - -func (i *InjectMetadataFields) SetType(type_a1 string) *InjectMetadataFields { - i.Type = type_a1 - return i -} - -func (p *InjectMetadataFields) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *InjectMetadataFields) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Type = v - } - return nil -} - -func (p *InjectMetadataFields) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("InjectMetadataFields"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *InjectMetadataFields) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("type", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:type: ", p), err) } - if err := oprot.WriteString(string(p.Type)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.type (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:type: ", p), err) } - return err -} - -func (p *InjectMetadataFields) String() string { - if p == nil { - return "" - } - - typeVal := fmt.Sprintf("%v", p.Type) - return fmt.Sprintf("InjectMetadataFields({Type:%s})", typeVal) -} - diff --git a/thrift/compiler/test/fixtures/inject_metadata_fields/gen-go/thrift/annotation/scope/constants.go b/thrift/compiler/test/fixtures/inject_metadata_fields/gen-go/thrift/annotation/scope/constants.go deleted file mode 100644 index 0c3448a7126..00000000000 --- a/thrift/compiler/test/fixtures/inject_metadata_fields/gen-go/thrift/annotation/scope/constants.go +++ /dev/null @@ -1,25 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package scope - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - - -func init() { -} - diff --git a/thrift/compiler/test/fixtures/inject_metadata_fields/gen-go/thrift/annotation/scope/ttypes.go b/thrift/compiler/test/fixtures/inject_metadata_fields/gen-go/thrift/annotation/scope/ttypes.go deleted file mode 100644 index 580c39e775c..00000000000 --- a/thrift/compiler/test/fixtures/inject_metadata_fields/gen-go/thrift/annotation/scope/ttypes.go +++ /dev/null @@ -1,1169 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package scope - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var GoUnusedProtection__ int; - -// Indicates that the scope of sibling annotations is transitive. -// -// For example: -// -// @scope.Struct -// @scope.Union -// @scope.Exception -// @scope.Transitive -// struct Structured {} -// -// Annotating a Thrift struct with @Structured automatically applies -// @scope.Struct, @scope.Union and @scope.Exception annotations, i.e. -// -// @Structured -// struct MyAnnotation {} -// -// is equivalent to -// -// @scope.Struct -// @scope.Union -// @scope.Exception -// struct MyAnnotation {} -// -type Transitive struct { -} - -func NewTransitive() *Transitive { - return &Transitive{} -} - -type TransitiveBuilder struct { - obj *Transitive -} - -func NewTransitiveBuilder() *TransitiveBuilder{ - return &TransitiveBuilder{ - obj: NewTransitive(), - } -} - -func (p TransitiveBuilder) Emit() *Transitive{ - return &Transitive{ - } -} - -func (p *Transitive) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Transitive) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Transitive"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Transitive) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Transitive({})") -} - -// The Program scope. -// -// This allows annotations on the `package` definition, which implies the -// annotaiton applies to the entire program. -type Program struct { -} - -func NewProgram() *Program { - return &Program{} -} - -type ProgramBuilder struct { - obj *Program -} - -func NewProgramBuilder() *ProgramBuilder{ - return &ProgramBuilder{ - obj: NewProgram(), - } -} - -func (p ProgramBuilder) Emit() *Program{ - return &Program{ - } -} - -func (p *Program) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Program) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Program"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Program) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Program({})") -} - -// The `struct` definition scope. -type Struct struct { -} - -func NewStruct() *Struct { - return &Struct{} -} - -type StructBuilder struct { - obj *Struct -} - -func NewStructBuilder() *StructBuilder{ - return &StructBuilder{ - obj: NewStruct(), - } -} - -func (p StructBuilder) Emit() *Struct{ - return &Struct{ - } -} - -func (p *Struct) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Struct) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Struct"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Struct) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Struct({})") -} - -// The `union` definition scope. -type Union struct { -} - -func NewUnion() *Union { - return &Union{} -} - -type UnionBuilder struct { - obj *Union -} - -func NewUnionBuilder() *UnionBuilder{ - return &UnionBuilder{ - obj: NewUnion(), - } -} - -func (p UnionBuilder) Emit() *Union{ - return &Union{ - } -} - -func (p *Union) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Union) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Union"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Union) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Union({})") -} - -// The `exception` definition scope. -type Exception struct { -} - -func NewException() *Exception { - return &Exception{} -} - -type ExceptionBuilder struct { - obj *Exception -} - -func NewExceptionBuilder() *ExceptionBuilder{ - return &ExceptionBuilder{ - obj: NewException(), - } -} - -func (p ExceptionBuilder) Emit() *Exception{ - return &Exception{ - } -} - -func (p *Exception) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Exception) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Exception"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Exception) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Exception({})") -} - -// Field declartaions, for example in `struct` or `function` declartions. -type Field struct { -} - -func NewField() *Field { - return &Field{} -} - -type FieldBuilder struct { - obj *Field -} - -func NewFieldBuilder() *FieldBuilder{ - return &FieldBuilder{ - obj: NewField(), - } -} - -func (p FieldBuilder) Emit() *Field{ - return &Field{ - } -} - -func (p *Field) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Field) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Field"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Field) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Field({})") -} - -// The `typedef` definition scope. -type Typedef struct { -} - -func NewTypedef() *Typedef { - return &Typedef{} -} - -type TypedefBuilder struct { - obj *Typedef -} - -func NewTypedefBuilder() *TypedefBuilder{ - return &TypedefBuilder{ - obj: NewTypedef(), - } -} - -func (p TypedefBuilder) Emit() *Typedef{ - return &Typedef{ - } -} - -func (p *Typedef) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Typedef) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Typedef"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Typedef) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Typedef({})") -} - -// The `service` definition scope. -type Service struct { -} - -func NewService() *Service { - return &Service{} -} - -type ServiceBuilder struct { - obj *Service -} - -func NewServiceBuilder() *ServiceBuilder{ - return &ServiceBuilder{ - obj: NewService(), - } -} - -func (p ServiceBuilder) Emit() *Service{ - return &Service{ - } -} - -func (p *Service) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Service) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Service"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Service) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Service({})") -} - -// The `interaction` definition scope. -type Interaction struct { -} - -func NewInteraction() *Interaction { - return &Interaction{} -} - -type InteractionBuilder struct { - obj *Interaction -} - -func NewInteractionBuilder() *InteractionBuilder{ - return &InteractionBuilder{ - obj: NewInteraction(), - } -} - -func (p InteractionBuilder) Emit() *Interaction{ - return &Interaction{ - } -} - -func (p *Interaction) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Interaction) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Interaction"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Interaction) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Interaction({})") -} - -// The `function` definition scope. -type Function struct { -} - -func NewFunction() *Function { - return &Function{} -} - -type FunctionBuilder struct { - obj *Function -} - -func NewFunctionBuilder() *FunctionBuilder{ - return &FunctionBuilder{ - obj: NewFunction(), - } -} - -func (p FunctionBuilder) Emit() *Function{ - return &Function{ - } -} - -func (p *Function) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Function) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Function"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Function) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Function({})") -} - -// The Enum value definition scope. -type EnumValue struct { -} - -func NewEnumValue() *EnumValue { - return &EnumValue{} -} - -type EnumValueBuilder struct { - obj *EnumValue -} - -func NewEnumValueBuilder() *EnumValueBuilder{ - return &EnumValueBuilder{ - obj: NewEnumValue(), - } -} - -func (p EnumValueBuilder) Emit() *EnumValue{ - return &EnumValue{ - } -} - -func (p *EnumValue) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *EnumValue) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("EnumValue"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *EnumValue) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("EnumValue({})") -} - -// The `const` definition scope. -type Const struct { -} - -func NewConst() *Const { - return &Const{} -} - -type ConstBuilder struct { - obj *Const -} - -func NewConstBuilder() *ConstBuilder{ - return &ConstBuilder{ - obj: NewConst(), - } -} - -func (p ConstBuilder) Emit() *Const{ - return &Const{ - } -} - -func (p *Const) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Const) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Const"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Const) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Const({})") -} - -type Enum struct { -} - -func NewEnum() *Enum { - return &Enum{} -} - -type EnumBuilder struct { - obj *Enum -} - -func NewEnumBuilder() *EnumBuilder{ - return &EnumBuilder{ - obj: NewEnum(), - } -} - -func (p EnumBuilder) Emit() *Enum{ - return &Enum{ - } -} - -func (p *Enum) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Enum) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Enum"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Enum) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Enum({})") -} - -// A scope that includes all 'structured' definitions. -type Structured struct { -} - -func NewStructured() *Structured { - return &Structured{} -} - -type StructuredBuilder struct { - obj *Structured -} - -func NewStructuredBuilder() *StructuredBuilder{ - return &StructuredBuilder{ - obj: NewStructured(), - } -} - -func (p StructuredBuilder) Emit() *Structured{ - return &Structured{ - } -} - -func (p *Structured) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Structured) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Structured"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Structured) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Structured({})") -} - -// A scope that includes all 'interface' definitions. -type Interface struct { -} - -func NewInterface() *Interface { - return &Interface{} -} - -type InterfaceBuilder struct { - obj *Interface -} - -func NewInterfaceBuilder() *InterfaceBuilder{ - return &InterfaceBuilder{ - obj: NewInterface(), - } -} - -func (p InterfaceBuilder) Emit() *Interface{ - return &Interface{ - } -} - -func (p *Interface) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Interface) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Interface"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Interface) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Interface({})") -} - -// A scope that includes all program-scoped definition. -type RootDefinition struct { -} - -func NewRootDefinition() *RootDefinition { - return &RootDefinition{} -} - -type RootDefinitionBuilder struct { - obj *RootDefinition -} - -func NewRootDefinitionBuilder() *RootDefinitionBuilder{ - return &RootDefinitionBuilder{ - obj: NewRootDefinition(), - } -} - -func (p RootDefinitionBuilder) Emit() *RootDefinition{ - return &RootDefinition{ - } -} - -func (p *RootDefinition) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *RootDefinition) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("RootDefinition"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *RootDefinition) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("RootDefinition({})") -} - -// A scope that includes all definitions. -type Definition struct { -} - -func NewDefinition() *Definition { - return &Definition{} -} - -type DefinitionBuilder struct { - obj *Definition -} - -func NewDefinitionBuilder() *DefinitionBuilder{ - return &DefinitionBuilder{ - obj: NewDefinition(), - } -} - -func (p DefinitionBuilder) Emit() *Definition{ - return &Definition{ - } -} - -func (p *Definition) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Definition) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Definition"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Definition) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Definition({})") -} - diff --git a/thrift/compiler/test/fixtures/inject_metadata_fields/gen-go/thrift/annotation/thrift/constants.go b/thrift/compiler/test/fixtures/inject_metadata_fields/gen-go/thrift/annotation/thrift/constants.go deleted file mode 100644 index 50d9b0fe3ee..00000000000 --- a/thrift/compiler/test/fixtures/inject_metadata_fields/gen-go/thrift/annotation/thrift/constants.go +++ /dev/null @@ -1,25 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package thrift - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - - -func init() { -} - diff --git a/thrift/compiler/test/fixtures/inject_metadata_fields/gen-go/thrift/annotation/thrift/ttypes.go b/thrift/compiler/test/fixtures/inject_metadata_fields/gen-go/thrift/annotation/thrift/ttypes.go deleted file mode 100644 index 35ea75e3dd0..00000000000 --- a/thrift/compiler/test/fixtures/inject_metadata_fields/gen-go/thrift/annotation/thrift/ttypes.go +++ /dev/null @@ -1,1545 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package thrift - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var GoUnusedProtection__ int; - -type RpcPriority int64 -const ( - RpcPriority_HIGH_IMPORTANT RpcPriority = 0 - RpcPriority_HIGH RpcPriority = 1 - RpcPriority_IMPORTANT RpcPriority = 2 - RpcPriority_NORMAL RpcPriority = 3 - RpcPriority_BEST_EFFORT RpcPriority = 4 -) - -var RpcPriorityToName = map[RpcPriority]string { - RpcPriority_HIGH_IMPORTANT: "HIGH_IMPORTANT", - RpcPriority_HIGH: "HIGH", - RpcPriority_IMPORTANT: "IMPORTANT", - RpcPriority_NORMAL: "NORMAL", - RpcPriority_BEST_EFFORT: "BEST_EFFORT", -} - -var RpcPriorityToValue = map[string]RpcPriority { - "HIGH_IMPORTANT": RpcPriority_HIGH_IMPORTANT, - "HIGH": RpcPriority_HIGH, - "IMPORTANT": RpcPriority_IMPORTANT, - "NORMAL": RpcPriority_NORMAL, - "BEST_EFFORT": RpcPriority_BEST_EFFORT, -} - -var RpcPriorityNames = []string { - "HIGH_IMPORTANT", - "HIGH", - "IMPORTANT", - "NORMAL", - "BEST_EFFORT", -} - -var RpcPriorityValues = []RpcPriority { - RpcPriority_HIGH_IMPORTANT, - RpcPriority_HIGH, - RpcPriority_IMPORTANT, - RpcPriority_NORMAL, - RpcPriority_BEST_EFFORT, -} - -func (p RpcPriority) String() string { - if v, ok := RpcPriorityToName[p]; ok { - return v - } - return "" -} - -func RpcPriorityFromString(s string) (RpcPriority, error) { - if v, ok := RpcPriorityToValue[s]; ok { - return v, nil - } - return RpcPriority(0), fmt.Errorf("not a valid RpcPriority string") -} - -func RpcPriorityPtr(v RpcPriority) *RpcPriority { return &v } - -// Indicates a definition/feature should only be used with permission, may -// only work in specific contexts, and may change in incompatible ways without -// notice. Note that this is primarily intended to annotate features by the Thrift Team -// and isn't recommended for general use. -type Experimental struct { -} - -func NewExperimental() *Experimental { - return &Experimental{} -} - -type ExperimentalBuilder struct { - obj *Experimental -} - -func NewExperimentalBuilder() *ExperimentalBuilder{ - return &ExperimentalBuilder{ - obj: NewExperimental(), - } -} - -func (p ExperimentalBuilder) Emit() *Experimental{ - return &Experimental{ - } -} - -func (p *Experimental) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Experimental) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Experimental"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Experimental) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Experimental({})") -} - -// Annotate a thrift structured or enum to indicate if ids or values should not -// be used. -// -// For example, you may want to mark ids as deprecated, or these ids -// might be reserved for other use cases or annotations. -// -// The resolved set of disallowed ids is the union of the values in `ids` and -// the range of values represented in `id_ranges`. Example: -// -// // These ids are not allowed: 3, 8, half-open ranges [10, 15), [20, 30) -// @thrift.ReserveIds{ids = [3, 8], id_ranges = {10: 15, 20: 30}} -// struct Foo { -// ... -// 3: i64 f; // Build failure: 3 cannot be used -// } -// -// Attributes: -// - Ids: Individual ids that cannot be used. -// - IdRanges: Represents ranges of ids that cannot be used. -// -// Each (key: value) pair represents the half-open range `[key, value)`, -// where `key` is included and `value` is not. For example, the map -// `{10: 15, 20: 30}` represents the union of id/value ranges `[10, 15)` and -// `[20, 30)`. -type ReserveIds struct { - Ids []int32 `thrift:"ids,1" db:"ids" json:"ids"` - IdRanges map[int32]int32 `thrift:"id_ranges,2" db:"id_ranges" json:"id_ranges"` -} - -func NewReserveIds() *ReserveIds { - return &ReserveIds{} -} - - -func (p *ReserveIds) GetIds() []int32 { - return p.Ids -} - -func (p *ReserveIds) GetIdRanges() map[int32]int32 { - return p.IdRanges -} -type ReserveIdsBuilder struct { - obj *ReserveIds -} - -func NewReserveIdsBuilder() *ReserveIdsBuilder{ - return &ReserveIdsBuilder{ - obj: NewReserveIds(), - } -} - -func (p ReserveIdsBuilder) Emit() *ReserveIds{ - return &ReserveIds{ - Ids: p.obj.Ids, - IdRanges: p.obj.IdRanges, - } -} - -func (r *ReserveIdsBuilder) Ids(ids []int32) *ReserveIdsBuilder { - r.obj.Ids = ids - return r -} - -func (r *ReserveIdsBuilder) IdRanges(idRanges map[int32]int32) *ReserveIdsBuilder { - r.obj.IdRanges = idRanges - return r -} - -func (r *ReserveIds) SetIds(ids []int32) *ReserveIds { - r.Ids = ids - return r -} - -func (r *ReserveIds) SetIdRanges(idRanges map[int32]int32) *ReserveIds { - r.IdRanges = idRanges - return r -} - -func (p *ReserveIds) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ReserveIds) ReadField1(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]int32, 0, size) - p.Ids = tSlice - for i := 0; i < size; i ++ { - var _elem0 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem0 = v - } - p.Ids = append(p.Ids, _elem0) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *ReserveIds) ReadField2(iprot thrift.Protocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[int32]int32, size) - p.IdRanges = tMap - for i := 0; i < size; i ++ { - var _key1 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key1 = v - } - var _val2 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _val2 = v - } - p.IdRanges[_key1] = _val2 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *ReserveIds) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("ReserveIds"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *ReserveIds) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("ids", thrift.LIST, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:ids: ", p), err) } - if err := oprot.WriteListBegin(thrift.I32, len(p.Ids)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.Ids { - if err := oprot.WriteI32(int32(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:ids: ", p), err) } - return err -} - -func (p *ReserveIds) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("id_ranges", thrift.MAP, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:id_ranges: ", p), err) } - if err := oprot.WriteMapBegin(thrift.I32, thrift.I32, len(p.IdRanges)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.IdRanges { - if err := oprot.WriteI32(int32(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := oprot.WriteI32(int32(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:id_ranges: ", p), err) } - return err -} - -func (p *ReserveIds) String() string { - if p == nil { - return "" - } - - idsVal := fmt.Sprintf("%v", p.Ids) - idRangesVal := fmt.Sprintf("%v", p.IdRanges) - return fmt.Sprintf("ReserveIds({Ids:%s IdRanges:%s})", idsVal, idRangesVal) -} - -// Indicates additional backward compatibility restrictions, beyond the -// standard Thrift required 'wire' compatibility. -// -// Attributes: -// - FieldName -type RequiresBackwardCompatibility struct { - FieldName bool `thrift:"field_name,1" db:"field_name" json:"field_name"` -} - -func NewRequiresBackwardCompatibility() *RequiresBackwardCompatibility { - return &RequiresBackwardCompatibility{} -} - - -func (p *RequiresBackwardCompatibility) GetFieldName() bool { - return p.FieldName -} -type RequiresBackwardCompatibilityBuilder struct { - obj *RequiresBackwardCompatibility -} - -func NewRequiresBackwardCompatibilityBuilder() *RequiresBackwardCompatibilityBuilder{ - return &RequiresBackwardCompatibilityBuilder{ - obj: NewRequiresBackwardCompatibility(), - } -} - -func (p RequiresBackwardCompatibilityBuilder) Emit() *RequiresBackwardCompatibility{ - return &RequiresBackwardCompatibility{ - FieldName: p.obj.FieldName, - } -} - -func (r *RequiresBackwardCompatibilityBuilder) FieldName(fieldName bool) *RequiresBackwardCompatibilityBuilder { - r.obj.FieldName = fieldName - return r -} - -func (r *RequiresBackwardCompatibility) SetFieldName(fieldName bool) *RequiresBackwardCompatibility { - r.FieldName = fieldName - return r -} - -func (p *RequiresBackwardCompatibility) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *RequiresBackwardCompatibility) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.FieldName = v - } - return nil -} - -func (p *RequiresBackwardCompatibility) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("RequiresBackwardCompatibility"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *RequiresBackwardCompatibility) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("field_name", thrift.BOOL, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:field_name: ", p), err) } - if err := oprot.WriteBool(bool(p.FieldName)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.field_name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:field_name: ", p), err) } - return err -} - -func (p *RequiresBackwardCompatibility) String() string { - if p == nil { - return "" - } - - fieldNameVal := fmt.Sprintf("%v", p.FieldName) - return fmt.Sprintf("RequiresBackwardCompatibility({FieldName:%s})", fieldNameVal) -} - -// An annotation that changes the field qualifier from 'none' to 'terse'. -// A terse field is eligible to skip serialization, when it equals to the -// intrinsic default value. It also clears to the intrinsic default value -// before deserialization to distinguish between if a terse field was skipped -// or missing during serialization. This is different from an unqualified -// field, as an unqualified field is always serialized regardless of its value, -// and it is not cleared before deserialization. -// -// The annotation can be only used to annotate an unqualified field, and when -// it is annotating a struct or exception, it changes all unqualified fields to -// terse fields. Note, the annotation can not be used for union. -type TerseWrite struct { -} - -func NewTerseWrite() *TerseWrite { - return &TerseWrite{} -} - -type TerseWriteBuilder struct { - obj *TerseWrite -} - -func NewTerseWriteBuilder() *TerseWriteBuilder{ - return &TerseWriteBuilder{ - obj: NewTerseWrite(), - } -} - -func (p TerseWriteBuilder) Emit() *TerseWrite{ - return &TerseWrite{ - } -} - -func (p *TerseWrite) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *TerseWrite) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("TerseWrite"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *TerseWrite) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("TerseWrite({})") -} - -// Indicates that an optional field's value should never be stored on the stack, -// i.e. the subobject should be allocated separately (e.g. because it is large and infrequently set). -// -// NOTE: The APIs and initialization behavior are same as normal field, but different from `@cpp.Ref`. e.g. -// -// ``` -// struct Foo { -// 1: optional i32 normal; -// @thrift.Box -// 2: optional i32 boxed; -// @cpp.Ref -// 3: optional i32 referred; -// } -// ``` -// in C++ -// -// ``` -// Foo foo; -// EXPECT_FALSE(foo.normal().has_value()); // okay -// EXPECT_FALSE(foo.boxed().has_value()); // okay -// EXPECT_FALSE(foo.referred().has_value()); // build failure: std::unique_ptr doesn't have has_value method -// -// EXPECT_EQ(*foo.normal(), 0); // throw bad_field_access exception -// EXPECT_EQ(*foo.boxed(), 0); // throw bad_field_access exception -// EXPECT_EQ(*foo.referred(), 0); // okay, field has value by default -// ``` -// -// Affects C++ and Rust. -// TODO: replace with @cpp.Box + @rust.Box -type Box struct { -} - -func NewBox() *Box { - return &Box{} -} - -type BoxBuilder struct { - obj *Box -} - -func NewBoxBuilder() *BoxBuilder{ - return &BoxBuilder{ - obj: NewBox(), - } -} - -func (p BoxBuilder) Emit() *Box{ - return &Box{ - } -} - -func (p *Box) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Box) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Box"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Box) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Box({})") -} - -// Indicates whether the nested fields are accessible directly. -// https://github.com/facebook/fbthrift/blob/v2023.11.20.00/thrift/doc/idl/mixins.md -type Mixin struct { -} - -func NewMixin() *Mixin { - return &Mixin{} -} - -type MixinBuilder struct { - obj *Mixin -} - -func NewMixinBuilder() *MixinBuilder{ - return &MixinBuilder{ - obj: NewMixin(), - } -} - -func (p MixinBuilder) Emit() *Mixin{ - return &Mixin{ - } -} - -func (p *Mixin) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Mixin) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Mixin"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Mixin) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Mixin({})") -} - -// Option to serialize thrift struct in ascending field id order instead of field declaration order. -// -// This can potentially make serialized data size smaller in compact protocol, -// since compact protocol can write deltas between subsequent field ids instead of full ids. -// -// NOTE: This annotation won't reduce payload size for other protocols. -type SerializeInFieldIdOrder struct { -} - -func NewSerializeInFieldIdOrder() *SerializeInFieldIdOrder { - return &SerializeInFieldIdOrder{} -} - -type SerializeInFieldIdOrderBuilder struct { - obj *SerializeInFieldIdOrder -} - -func NewSerializeInFieldIdOrderBuilder() *SerializeInFieldIdOrderBuilder{ - return &SerializeInFieldIdOrderBuilder{ - obj: NewSerializeInFieldIdOrder(), - } -} - -func (p SerializeInFieldIdOrderBuilder) Emit() *SerializeInFieldIdOrder{ - return &SerializeInFieldIdOrder{ - } -} - -func (p *SerializeInFieldIdOrder) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *SerializeInFieldIdOrder) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("SerializeInFieldIdOrder"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *SerializeInFieldIdOrder) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("SerializeInFieldIdOrder({})") -} - -// Indicates an enum is a bitmask and should support bit-wise operators. -// Currently generates additional code in C++ and Hack. -type BitmaskEnum struct { -} - -func NewBitmaskEnum() *BitmaskEnum { - return &BitmaskEnum{} -} - -type BitmaskEnumBuilder struct { - obj *BitmaskEnum -} - -func NewBitmaskEnumBuilder() *BitmaskEnumBuilder{ - return &BitmaskEnumBuilder{ - obj: NewBitmaskEnum(), - } -} - -func (p BitmaskEnumBuilder) Emit() *BitmaskEnum{ - return &BitmaskEnum{ - } -} - -func (p *BitmaskEnum) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *BitmaskEnum) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("BitmaskEnum"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *BitmaskEnum) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("BitmaskEnum({})") -} - -// Specifies the field where the exception message is stored. -type ExceptionMessage struct { -} - -func NewExceptionMessage() *ExceptionMessage { - return &ExceptionMessage{} -} - -type ExceptionMessageBuilder struct { - obj *ExceptionMessage -} - -func NewExceptionMessageBuilder() *ExceptionMessageBuilder{ - return &ExceptionMessageBuilder{ - obj: NewExceptionMessage(), - } -} - -func (p ExceptionMessageBuilder) Emit() *ExceptionMessage{ - return &ExceptionMessage{ - } -} - -func (p *ExceptionMessage) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ExceptionMessage) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("ExceptionMessage"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *ExceptionMessage) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("ExceptionMessage({})") -} - -// Generates a const of type schema. Struct containing the schema of the -// annotated type. Optionally specify name to override default -// schema. -// -// Attributes: -// - Name -type GenerateRuntimeSchema struct { - Name string `thrift:"name,1" db:"name" json:"name"` -} - -func NewGenerateRuntimeSchema() *GenerateRuntimeSchema { - return &GenerateRuntimeSchema{} -} - - -func (p *GenerateRuntimeSchema) GetName() string { - return p.Name -} -type GenerateRuntimeSchemaBuilder struct { - obj *GenerateRuntimeSchema -} - -func NewGenerateRuntimeSchemaBuilder() *GenerateRuntimeSchemaBuilder{ - return &GenerateRuntimeSchemaBuilder{ - obj: NewGenerateRuntimeSchema(), - } -} - -func (p GenerateRuntimeSchemaBuilder) Emit() *GenerateRuntimeSchema{ - return &GenerateRuntimeSchema{ - Name: p.obj.Name, - } -} - -func (g *GenerateRuntimeSchemaBuilder) Name(name string) *GenerateRuntimeSchemaBuilder { - g.obj.Name = name - return g -} - -func (g *GenerateRuntimeSchema) SetName(name string) *GenerateRuntimeSchema { - g.Name = name - return g -} - -func (p *GenerateRuntimeSchema) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *GenerateRuntimeSchema) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Name = v - } - return nil -} - -func (p *GenerateRuntimeSchema) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("GenerateRuntimeSchema"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *GenerateRuntimeSchema) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) } - if err := oprot.WriteString(string(p.Name)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) } - return err -} - -func (p *GenerateRuntimeSchema) String() string { - if p == nil { - return "" - } - - nameVal := fmt.Sprintf("%v", p.Name) - return fmt.Sprintf("GenerateRuntimeSchema({Name:%s})", nameVal) -} - -// Indicates that a field's value should never be stored on the stack, and that -// identical values can be shared in immutable contexts. -type InternBox struct { -} - -func NewInternBox() *InternBox { - return &InternBox{} -} - -type InternBoxBuilder struct { - obj *InternBox -} - -func NewInternBoxBuilder() *InternBoxBuilder{ - return &InternBoxBuilder{ - obj: NewInternBox(), - } -} - -func (p InternBoxBuilder) Emit() *InternBox{ - return &InternBox{ - } -} - -func (p *InternBox) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *InternBox) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("InternBox"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *InternBox) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("InternBox({})") -} - -// Indicates that an interaction's methods should be processed sequentially. -type Serial struct { -} - -func NewSerial() *Serial { - return &Serial{} -} - -type SerialBuilder struct { - obj *Serial -} - -func NewSerialBuilder() *SerialBuilder{ - return &SerialBuilder{ - obj: NewSerial(), - } -} - -func (p SerialBuilder) Emit() *Serial{ - return &Serial{ - } -} - -func (p *Serial) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Serial) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Serial"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Serial) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Serial({})") -} - -// Changes the URI of this definition away from the default-generated one. -// -// Attributes: -// - Value -type Uri struct { - Value string `thrift:"value,1" db:"value" json:"value"` -} - -func NewUri() *Uri { - return &Uri{} -} - - -func (p *Uri) GetValue() string { - return p.Value -} -type UriBuilder struct { - obj *Uri -} - -func NewUriBuilder() *UriBuilder{ - return &UriBuilder{ - obj: NewUri(), - } -} - -func (p UriBuilder) Emit() *Uri{ - return &Uri{ - Value: p.obj.Value, - } -} - -func (u *UriBuilder) Value(value string) *UriBuilder { - u.obj.Value = value - return u -} - -func (u *Uri) SetValue(value string) *Uri { - u.Value = value - return u -} - -func (p *Uri) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Uri) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Value = v - } - return nil -} - -func (p *Uri) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Uri"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Uri) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("value", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:value: ", p), err) } - if err := oprot.WriteString(string(p.Value)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.value (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:value: ", p), err) } - return err -} - -func (p *Uri) String() string { - if p == nil { - return "" - } - - valueVal := fmt.Sprintf("%v", p.Value) - return fmt.Sprintf("Uri({Value:%s})", valueVal) -} - -// Changes the priority of this function (default NORMAL). -// -// Attributes: -// - Level -type Priority struct { - Level RpcPriority `thrift:"level,1" db:"level" json:"level"` -} - -func NewPriority() *Priority { - return &Priority{} -} - - -func (p *Priority) GetLevel() RpcPriority { - return p.Level -} -type PriorityBuilder struct { - obj *Priority -} - -func NewPriorityBuilder() *PriorityBuilder{ - return &PriorityBuilder{ - obj: NewPriority(), - } -} - -func (p PriorityBuilder) Emit() *Priority{ - return &Priority{ - Level: p.obj.Level, - } -} - -func (p *PriorityBuilder) Level(level RpcPriority) *PriorityBuilder { - p.obj.Level = level - return p -} - -func (p *Priority) SetLevel(level RpcPriority) *Priority { - p.Level = level - return p -} - -func (p *Priority) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Priority) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - temp := RpcPriority(v) - p.Level = temp - } - return nil -} - -func (p *Priority) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Priority"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Priority) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("level", thrift.I32, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:level: ", p), err) } - if err := oprot.WriteI32(int32(p.Level)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.level (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:level: ", p), err) } - return err -} - -func (p *Priority) String() string { - if p == nil { - return "" - } - - levelVal := fmt.Sprintf("%v", p.Level) - return fmt.Sprintf("Priority({Level:%s})", levelVal) -} - -// Applies unstructured annotations to a definition. -// -// Attributes: -// - Items -type DeprecatedUnvalidatedAnnotations struct { - Items map[string]string `thrift:"items,1" db:"items" json:"items"` -} - -func NewDeprecatedUnvalidatedAnnotations() *DeprecatedUnvalidatedAnnotations { - return &DeprecatedUnvalidatedAnnotations{} -} - - -func (p *DeprecatedUnvalidatedAnnotations) GetItems() map[string]string { - return p.Items -} -type DeprecatedUnvalidatedAnnotationsBuilder struct { - obj *DeprecatedUnvalidatedAnnotations -} - -func NewDeprecatedUnvalidatedAnnotationsBuilder() *DeprecatedUnvalidatedAnnotationsBuilder{ - return &DeprecatedUnvalidatedAnnotationsBuilder{ - obj: NewDeprecatedUnvalidatedAnnotations(), - } -} - -func (p DeprecatedUnvalidatedAnnotationsBuilder) Emit() *DeprecatedUnvalidatedAnnotations{ - return &DeprecatedUnvalidatedAnnotations{ - Items: p.obj.Items, - } -} - -func (d *DeprecatedUnvalidatedAnnotationsBuilder) Items(items map[string]string) *DeprecatedUnvalidatedAnnotationsBuilder { - d.obj.Items = items - return d -} - -func (d *DeprecatedUnvalidatedAnnotations) SetItems(items map[string]string) *DeprecatedUnvalidatedAnnotations { - d.Items = items - return d -} - -func (p *DeprecatedUnvalidatedAnnotations) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *DeprecatedUnvalidatedAnnotations) ReadField1(iprot thrift.Protocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[string]string, size) - p.Items = tMap - for i := 0; i < size; i ++ { - var _key3 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key3 = v - } - var _val4 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _val4 = v - } - p.Items[_key3] = _val4 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *DeprecatedUnvalidatedAnnotations) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("DeprecatedUnvalidatedAnnotations"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *DeprecatedUnvalidatedAnnotations) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("items", thrift.MAP, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:items: ", p), err) } - if err := oprot.WriteMapBegin(thrift.STRING, thrift.STRING, len(p.Items)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.Items { - if err := oprot.WriteString(string(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := oprot.WriteString(string(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:items: ", p), err) } - return err -} - -func (p *DeprecatedUnvalidatedAnnotations) String() string { - if p == nil { - return "" - } - - itemsVal := fmt.Sprintf("%v", p.Items) - return fmt.Sprintf("DeprecatedUnvalidatedAnnotations({Items:%s})", itemsVal) -} - diff --git a/thrift/compiler/test/fixtures/namespace_from_package/gen-go/namespace_from_package/module/constants.go b/thrift/compiler/test/fixtures/namespace_from_package/gen-go/namespace_from_package/module/constants.go deleted file mode 100644 index 477cf91a64b..00000000000 --- a/thrift/compiler/test/fixtures/namespace_from_package/gen-go/namespace_from_package/module/constants.go +++ /dev/null @@ -1,25 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package module - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - - -func init() { -} - diff --git a/thrift/compiler/test/fixtures/namespace_from_package/gen-go/namespace_from_package/module/testservice.go b/thrift/compiler/test/fixtures/namespace_from_package/gen-go/namespace_from_package/module/testservice.go deleted file mode 100644 index 7086d3770e1..00000000000 --- a/thrift/compiler/test/fixtures/namespace_from_package/gen-go/namespace_from_package/module/testservice.go +++ /dev/null @@ -1,510 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package module - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -type TestService interface { - // Parameters: - // - Int1 - Init(int1 int64) (_r int64, err error) -} - -type TestServiceClientInterface interface { - thrift.ClientInterface - // Parameters: - // - Int1 - Init(int1 int64) (_r int64, err error) -} - -type TestServiceClient struct { - TestServiceClientInterface - CC thrift.ClientConn -} - -func(client *TestServiceClient) Open() error { - return client.CC.Open() -} - -func(client *TestServiceClient) Close() error { - return client.CC.Close() -} - -func(client *TestServiceClient) IsOpen() bool { - return client.CC.IsOpen() -} - -func NewTestServiceClientFactory(t thrift.Transport, f thrift.ProtocolFactory) *TestServiceClient { - return &TestServiceClient{ CC: thrift.NewClientConn(t, f) } -} - -func NewTestServiceClient(t thrift.Transport, iprot thrift.Protocol, oprot thrift.Protocol) *TestServiceClient { - return &TestServiceClient{ CC: thrift.NewClientConnWithProtocols(t, iprot, oprot) } -} - -func NewTestServiceClientProtocol(prot thrift.Protocol) *TestServiceClient { - return NewTestServiceClient(prot.Transport(), prot, prot) -} - -// Parameters: -// - Int1 -func (p *TestServiceClient) Init(int1 int64) (_r int64, err error) { - args := TestServiceInitArgs{ - Int1 : int1, - } - err = p.CC.SendMsg("init", &args, thrift.CALL) - if err != nil { return } - return p.recvInit() -} - - -func (p *TestServiceClient) recvInit() (value int64, err error) { - var __result TestServiceInitResult - err = p.CC.RecvMsg("init", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - - -type TestServiceThreadsafeClient struct { - TestServiceClientInterface - CC thrift.ClientConn - Mu sync.Mutex -} - -func(client *TestServiceThreadsafeClient) Open() error { - client.Mu.Lock() - defer client.Mu.Unlock() - return client.CC.Open() -} - -func(client *TestServiceThreadsafeClient) Close() error { - client.Mu.Lock() - defer client.Mu.Unlock() - return client.CC.Close() -} - -func(client *TestServiceThreadsafeClient) IsOpen() bool { - client.Mu.Lock() - defer client.Mu.Unlock() - return client.CC.IsOpen() -} - -func NewTestServiceThreadsafeClientFactory(t thrift.Transport, f thrift.ProtocolFactory) *TestServiceThreadsafeClient { - return &TestServiceThreadsafeClient{ CC: thrift.NewClientConn(t, f) } -} - -func NewTestServiceThreadsafeClient(t thrift.Transport, iprot thrift.Protocol, oprot thrift.Protocol) *TestServiceThreadsafeClient { - return &TestServiceThreadsafeClient{ CC: thrift.NewClientConnWithProtocols(t, iprot, oprot) } -} - -func NewTestServiceThreadsafeClientProtocol(prot thrift.Protocol) *TestServiceThreadsafeClient { - return NewTestServiceThreadsafeClient(prot.Transport(), prot, prot) -} - -// Parameters: -// - Int1 -func (p *TestServiceThreadsafeClient) Init(int1 int64) (_r int64, err error) { - p.Mu.Lock() - defer p.Mu.Unlock() - args := TestServiceInitArgs{ - Int1 : int1, - } - err = p.CC.SendMsg("init", &args, thrift.CALL) - if err != nil { return } - return p.recvInit() -} - - -func (p *TestServiceThreadsafeClient) recvInit() (value int64, err error) { - var __result TestServiceInitResult - err = p.CC.RecvMsg("init", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - - -type TestServiceChannelClient struct { - RequestChannel thrift.RequestChannel -} - -func (c *TestServiceChannelClient) Close() error { - return c.RequestChannel.Close() -} - -func (c *TestServiceChannelClient) IsOpen() bool { - return c.RequestChannel.IsOpen() -} - -func (c *TestServiceChannelClient) Open() error { - return c.RequestChannel.Open() -} - -func NewTestServiceChannelClient(channel thrift.RequestChannel) *TestServiceChannelClient { - return &TestServiceChannelClient{RequestChannel: channel} -} - -// Parameters: -// - Int1 -func (p *TestServiceChannelClient) Init(ctx context.Context, int1 int64) (_r int64, err error) { - args := TestServiceInitArgs{ - Int1 : int1, - } - var __result TestServiceInitResult - err = p.RequestChannel.Call(ctx, "init", &args, &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - - -type TestServiceProcessor struct { - processorMap map[string]thrift.ProcessorFunction - functionServiceMap map[string]string - handler TestService -} - -func (p *TestServiceProcessor) AddToProcessorMap(key string, processor thrift.ProcessorFunction) { - p.processorMap[key] = processor -} - -func (p *TestServiceProcessor) AddToFunctionServiceMap(key, service string) { - p.functionServiceMap[key] = service -} - -func (p *TestServiceProcessor) GetProcessorFunction(key string) (processor thrift.ProcessorFunction, err error) { - if processor, ok := p.processorMap[key]; ok { - return processor, nil - } - return nil, nil // generic error message will be sent -} - -func (p *TestServiceProcessor) ProcessorMap() map[string]thrift.ProcessorFunction { - return p.processorMap -} - -func (p *TestServiceProcessor) FunctionServiceMap() map[string]string { - return p.functionServiceMap -} - -func NewTestServiceProcessor(handler TestService) *TestServiceProcessor { - self0 := &TestServiceProcessor{handler:handler, processorMap:make(map[string]thrift.ProcessorFunction), functionServiceMap:make(map[string]string)} - self0.processorMap["init"] = &testServiceProcessorInit{handler:handler} - self0.functionServiceMap["init"] = "TestService" - return self0 -} - -type testServiceProcessorInit struct { - handler TestService -} - -func (p *TestServiceInitResult) Exception() thrift.WritableException { - if p == nil { return nil } - return nil -} - -func (p *testServiceProcessorInit) Read(iprot thrift.Protocol) (thrift.Struct, thrift.Exception) { - args := TestServiceInitArgs{} - if err := args.Read(iprot); err != nil { - return nil, err - } - iprot.ReadMessageEnd() - return &args, nil -} - -func (p *testServiceProcessorInit) Write(seqId int32, result thrift.WritableStruct, oprot thrift.Protocol) (err thrift.Exception) { - var err2 error - messageType := thrift.REPLY - switch result.(type) { - case thrift.ApplicationException: - messageType = thrift.EXCEPTION - } - if err2 = oprot.WriteMessageBegin("init", messageType, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - return err -} - -func (p *testServiceProcessorInit) Run(argStruct thrift.Struct) (thrift.WritableStruct, thrift.ApplicationException) { - args := argStruct.(*TestServiceInitArgs) - var __result TestServiceInitResult - if retval, err := p.handler.Init(args.Int1); err != nil { - switch err.(type) { - default: - x := thrift.NewApplicationExceptionCause(thrift.INTERNAL_ERROR, "Internal error processing init: " + err.Error(), err) - return x, x - } - } else { - __result.Success = &retval - } - return &__result, nil -} - - -// HELPER FUNCTIONS AND STRUCTURES - -// Attributes: -// - Int1 -type TestServiceInitArgs struct { - thrift.IRequest - Int1 int64 `thrift:"int1,1" db:"int1" json:"int1"` -} - -func NewTestServiceInitArgs() *TestServiceInitArgs { - return &TestServiceInitArgs{} -} - - -func (p *TestServiceInitArgs) GetInt1() int64 { - return p.Int1 -} -type TestServiceInitArgsBuilder struct { - obj *TestServiceInitArgs -} - -func NewTestServiceInitArgsBuilder() *TestServiceInitArgsBuilder{ - return &TestServiceInitArgsBuilder{ - obj: NewTestServiceInitArgs(), - } -} - -func (p TestServiceInitArgsBuilder) Emit() *TestServiceInitArgs{ - return &TestServiceInitArgs{ - Int1: p.obj.Int1, - } -} - -func (t *TestServiceInitArgsBuilder) Int1(int1 int64) *TestServiceInitArgsBuilder { - t.obj.Int1 = int1 - return t -} - -func (t *TestServiceInitArgs) SetInt1(int1 int64) *TestServiceInitArgs { - t.Int1 = int1 - return t -} - -func (p *TestServiceInitArgs) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *TestServiceInitArgs) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Int1 = v - } - return nil -} - -func (p *TestServiceInitArgs) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("init_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *TestServiceInitArgs) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("int1", thrift.I64, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:int1: ", p), err) } - if err := oprot.WriteI64(int64(p.Int1)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.int1 (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:int1: ", p), err) } - return err -} - -func (p *TestServiceInitArgs) String() string { - if p == nil { - return "" - } - - int1Val := fmt.Sprintf("%v", p.Int1) - return fmt.Sprintf("TestServiceInitArgs({Int1:%s})", int1Val) -} - -// Attributes: -// - Success -type TestServiceInitResult struct { - thrift.IResponse - Success *int64 `thrift:"success,0,optional" db:"success" json:"success,omitempty"` -} - -func NewTestServiceInitResult() *TestServiceInitResult { - return &TestServiceInitResult{} -} - -var TestServiceInitResult_Success_DEFAULT int64 -func (p *TestServiceInitResult) GetSuccess() int64 { - if !p.IsSetSuccess() { - return TestServiceInitResult_Success_DEFAULT - } - return *p.Success -} -func (p *TestServiceInitResult) IsSetSuccess() bool { - return p != nil && p.Success != nil -} - -type TestServiceInitResultBuilder struct { - obj *TestServiceInitResult -} - -func NewTestServiceInitResultBuilder() *TestServiceInitResultBuilder{ - return &TestServiceInitResultBuilder{ - obj: NewTestServiceInitResult(), - } -} - -func (p TestServiceInitResultBuilder) Emit() *TestServiceInitResult{ - return &TestServiceInitResult{ - Success: p.obj.Success, - } -} - -func (t *TestServiceInitResultBuilder) Success(success *int64) *TestServiceInitResultBuilder { - t.obj.Success = success - return t -} - -func (t *TestServiceInitResult) SetSuccess(success *int64) *TestServiceInitResult { - t.Success = success - return t -} - -func (p *TestServiceInitResult) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 0: - if err := p.ReadField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *TestServiceInitResult) ReadField0(iprot thrift.Protocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - p.Success = &v - } - return nil -} - -func (p *TestServiceInitResult) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("init_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField0(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *TestServiceInitResult) writeField0(oprot thrift.Protocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.I64, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := oprot.WriteI64(int64(*p.Success)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.success (0) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } - } - return err -} - -func (p *TestServiceInitResult) String() string { - if p == nil { - return "" - } - - var successVal string - if p.Success == nil { - successVal = "" - } else { - successVal = fmt.Sprintf("%v", *p.Success) - } - return fmt.Sprintf("TestServiceInitResult({Success:%s})", successVal) -} - - diff --git a/thrift/compiler/test/fixtures/namespace_from_package/gen-go/namespace_from_package/module/ttypes.go b/thrift/compiler/test/fixtures/namespace_from_package/gen-go/namespace_from_package/module/ttypes.go deleted file mode 100644 index 073b1ddf591..00000000000 --- a/thrift/compiler/test/fixtures/namespace_from_package/gen-go/namespace_from_package/module/ttypes.go +++ /dev/null @@ -1,134 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package module - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var GoUnusedProtection__ int; - -// Attributes: -// - MyInt -type Foo struct { - MyInt int64 `thrift:"MyInt,1" db:"MyInt" json:"MyInt"` -} - -func NewFoo() *Foo { - return &Foo{} -} - - -func (p *Foo) GetMyInt() int64 { - return p.MyInt -} -type FooBuilder struct { - obj *Foo -} - -func NewFooBuilder() *FooBuilder{ - return &FooBuilder{ - obj: NewFoo(), - } -} - -func (p FooBuilder) Emit() *Foo{ - return &Foo{ - MyInt: p.obj.MyInt, - } -} - -func (f *FooBuilder) MyInt(myInt int64) *FooBuilder { - f.obj.MyInt = myInt - return f -} - -func (f *Foo) SetMyInt(myInt int64) *Foo { - f.MyInt = myInt - return f -} - -func (p *Foo) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Foo) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.MyInt = v - } - return nil -} - -func (p *Foo) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Foo"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Foo) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("MyInt", thrift.I64, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:MyInt: ", p), err) } - if err := oprot.WriteI64(int64(p.MyInt)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.MyInt (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:MyInt: ", p), err) } - return err -} - -func (p *Foo) String() string { - if p == nil { - return "" - } - - myIntVal := fmt.Sprintf("%v", p.MyInt) - return fmt.Sprintf("Foo({MyInt:%s})", myIntVal) -} - diff --git a/thrift/compiler/test/fixtures/namespace_from_package_without_module_name/gen-go/namespace_from_package_without_module_name/module/constants.go b/thrift/compiler/test/fixtures/namespace_from_package_without_module_name/gen-go/namespace_from_package_without_module_name/module/constants.go deleted file mode 100644 index 477cf91a64b..00000000000 --- a/thrift/compiler/test/fixtures/namespace_from_package_without_module_name/gen-go/namespace_from_package_without_module_name/module/constants.go +++ /dev/null @@ -1,25 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package module - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - - -func init() { -} - diff --git a/thrift/compiler/test/fixtures/namespace_from_package_without_module_name/gen-go/namespace_from_package_without_module_name/module/testservice.go b/thrift/compiler/test/fixtures/namespace_from_package_without_module_name/gen-go/namespace_from_package_without_module_name/module/testservice.go deleted file mode 100644 index 7086d3770e1..00000000000 --- a/thrift/compiler/test/fixtures/namespace_from_package_without_module_name/gen-go/namespace_from_package_without_module_name/module/testservice.go +++ /dev/null @@ -1,510 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package module - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -type TestService interface { - // Parameters: - // - Int1 - Init(int1 int64) (_r int64, err error) -} - -type TestServiceClientInterface interface { - thrift.ClientInterface - // Parameters: - // - Int1 - Init(int1 int64) (_r int64, err error) -} - -type TestServiceClient struct { - TestServiceClientInterface - CC thrift.ClientConn -} - -func(client *TestServiceClient) Open() error { - return client.CC.Open() -} - -func(client *TestServiceClient) Close() error { - return client.CC.Close() -} - -func(client *TestServiceClient) IsOpen() bool { - return client.CC.IsOpen() -} - -func NewTestServiceClientFactory(t thrift.Transport, f thrift.ProtocolFactory) *TestServiceClient { - return &TestServiceClient{ CC: thrift.NewClientConn(t, f) } -} - -func NewTestServiceClient(t thrift.Transport, iprot thrift.Protocol, oprot thrift.Protocol) *TestServiceClient { - return &TestServiceClient{ CC: thrift.NewClientConnWithProtocols(t, iprot, oprot) } -} - -func NewTestServiceClientProtocol(prot thrift.Protocol) *TestServiceClient { - return NewTestServiceClient(prot.Transport(), prot, prot) -} - -// Parameters: -// - Int1 -func (p *TestServiceClient) Init(int1 int64) (_r int64, err error) { - args := TestServiceInitArgs{ - Int1 : int1, - } - err = p.CC.SendMsg("init", &args, thrift.CALL) - if err != nil { return } - return p.recvInit() -} - - -func (p *TestServiceClient) recvInit() (value int64, err error) { - var __result TestServiceInitResult - err = p.CC.RecvMsg("init", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - - -type TestServiceThreadsafeClient struct { - TestServiceClientInterface - CC thrift.ClientConn - Mu sync.Mutex -} - -func(client *TestServiceThreadsafeClient) Open() error { - client.Mu.Lock() - defer client.Mu.Unlock() - return client.CC.Open() -} - -func(client *TestServiceThreadsafeClient) Close() error { - client.Mu.Lock() - defer client.Mu.Unlock() - return client.CC.Close() -} - -func(client *TestServiceThreadsafeClient) IsOpen() bool { - client.Mu.Lock() - defer client.Mu.Unlock() - return client.CC.IsOpen() -} - -func NewTestServiceThreadsafeClientFactory(t thrift.Transport, f thrift.ProtocolFactory) *TestServiceThreadsafeClient { - return &TestServiceThreadsafeClient{ CC: thrift.NewClientConn(t, f) } -} - -func NewTestServiceThreadsafeClient(t thrift.Transport, iprot thrift.Protocol, oprot thrift.Protocol) *TestServiceThreadsafeClient { - return &TestServiceThreadsafeClient{ CC: thrift.NewClientConnWithProtocols(t, iprot, oprot) } -} - -func NewTestServiceThreadsafeClientProtocol(prot thrift.Protocol) *TestServiceThreadsafeClient { - return NewTestServiceThreadsafeClient(prot.Transport(), prot, prot) -} - -// Parameters: -// - Int1 -func (p *TestServiceThreadsafeClient) Init(int1 int64) (_r int64, err error) { - p.Mu.Lock() - defer p.Mu.Unlock() - args := TestServiceInitArgs{ - Int1 : int1, - } - err = p.CC.SendMsg("init", &args, thrift.CALL) - if err != nil { return } - return p.recvInit() -} - - -func (p *TestServiceThreadsafeClient) recvInit() (value int64, err error) { - var __result TestServiceInitResult - err = p.CC.RecvMsg("init", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - - -type TestServiceChannelClient struct { - RequestChannel thrift.RequestChannel -} - -func (c *TestServiceChannelClient) Close() error { - return c.RequestChannel.Close() -} - -func (c *TestServiceChannelClient) IsOpen() bool { - return c.RequestChannel.IsOpen() -} - -func (c *TestServiceChannelClient) Open() error { - return c.RequestChannel.Open() -} - -func NewTestServiceChannelClient(channel thrift.RequestChannel) *TestServiceChannelClient { - return &TestServiceChannelClient{RequestChannel: channel} -} - -// Parameters: -// - Int1 -func (p *TestServiceChannelClient) Init(ctx context.Context, int1 int64) (_r int64, err error) { - args := TestServiceInitArgs{ - Int1 : int1, - } - var __result TestServiceInitResult - err = p.RequestChannel.Call(ctx, "init", &args, &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - - -type TestServiceProcessor struct { - processorMap map[string]thrift.ProcessorFunction - functionServiceMap map[string]string - handler TestService -} - -func (p *TestServiceProcessor) AddToProcessorMap(key string, processor thrift.ProcessorFunction) { - p.processorMap[key] = processor -} - -func (p *TestServiceProcessor) AddToFunctionServiceMap(key, service string) { - p.functionServiceMap[key] = service -} - -func (p *TestServiceProcessor) GetProcessorFunction(key string) (processor thrift.ProcessorFunction, err error) { - if processor, ok := p.processorMap[key]; ok { - return processor, nil - } - return nil, nil // generic error message will be sent -} - -func (p *TestServiceProcessor) ProcessorMap() map[string]thrift.ProcessorFunction { - return p.processorMap -} - -func (p *TestServiceProcessor) FunctionServiceMap() map[string]string { - return p.functionServiceMap -} - -func NewTestServiceProcessor(handler TestService) *TestServiceProcessor { - self0 := &TestServiceProcessor{handler:handler, processorMap:make(map[string]thrift.ProcessorFunction), functionServiceMap:make(map[string]string)} - self0.processorMap["init"] = &testServiceProcessorInit{handler:handler} - self0.functionServiceMap["init"] = "TestService" - return self0 -} - -type testServiceProcessorInit struct { - handler TestService -} - -func (p *TestServiceInitResult) Exception() thrift.WritableException { - if p == nil { return nil } - return nil -} - -func (p *testServiceProcessorInit) Read(iprot thrift.Protocol) (thrift.Struct, thrift.Exception) { - args := TestServiceInitArgs{} - if err := args.Read(iprot); err != nil { - return nil, err - } - iprot.ReadMessageEnd() - return &args, nil -} - -func (p *testServiceProcessorInit) Write(seqId int32, result thrift.WritableStruct, oprot thrift.Protocol) (err thrift.Exception) { - var err2 error - messageType := thrift.REPLY - switch result.(type) { - case thrift.ApplicationException: - messageType = thrift.EXCEPTION - } - if err2 = oprot.WriteMessageBegin("init", messageType, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - return err -} - -func (p *testServiceProcessorInit) Run(argStruct thrift.Struct) (thrift.WritableStruct, thrift.ApplicationException) { - args := argStruct.(*TestServiceInitArgs) - var __result TestServiceInitResult - if retval, err := p.handler.Init(args.Int1); err != nil { - switch err.(type) { - default: - x := thrift.NewApplicationExceptionCause(thrift.INTERNAL_ERROR, "Internal error processing init: " + err.Error(), err) - return x, x - } - } else { - __result.Success = &retval - } - return &__result, nil -} - - -// HELPER FUNCTIONS AND STRUCTURES - -// Attributes: -// - Int1 -type TestServiceInitArgs struct { - thrift.IRequest - Int1 int64 `thrift:"int1,1" db:"int1" json:"int1"` -} - -func NewTestServiceInitArgs() *TestServiceInitArgs { - return &TestServiceInitArgs{} -} - - -func (p *TestServiceInitArgs) GetInt1() int64 { - return p.Int1 -} -type TestServiceInitArgsBuilder struct { - obj *TestServiceInitArgs -} - -func NewTestServiceInitArgsBuilder() *TestServiceInitArgsBuilder{ - return &TestServiceInitArgsBuilder{ - obj: NewTestServiceInitArgs(), - } -} - -func (p TestServiceInitArgsBuilder) Emit() *TestServiceInitArgs{ - return &TestServiceInitArgs{ - Int1: p.obj.Int1, - } -} - -func (t *TestServiceInitArgsBuilder) Int1(int1 int64) *TestServiceInitArgsBuilder { - t.obj.Int1 = int1 - return t -} - -func (t *TestServiceInitArgs) SetInt1(int1 int64) *TestServiceInitArgs { - t.Int1 = int1 - return t -} - -func (p *TestServiceInitArgs) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *TestServiceInitArgs) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Int1 = v - } - return nil -} - -func (p *TestServiceInitArgs) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("init_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *TestServiceInitArgs) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("int1", thrift.I64, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:int1: ", p), err) } - if err := oprot.WriteI64(int64(p.Int1)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.int1 (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:int1: ", p), err) } - return err -} - -func (p *TestServiceInitArgs) String() string { - if p == nil { - return "" - } - - int1Val := fmt.Sprintf("%v", p.Int1) - return fmt.Sprintf("TestServiceInitArgs({Int1:%s})", int1Val) -} - -// Attributes: -// - Success -type TestServiceInitResult struct { - thrift.IResponse - Success *int64 `thrift:"success,0,optional" db:"success" json:"success,omitempty"` -} - -func NewTestServiceInitResult() *TestServiceInitResult { - return &TestServiceInitResult{} -} - -var TestServiceInitResult_Success_DEFAULT int64 -func (p *TestServiceInitResult) GetSuccess() int64 { - if !p.IsSetSuccess() { - return TestServiceInitResult_Success_DEFAULT - } - return *p.Success -} -func (p *TestServiceInitResult) IsSetSuccess() bool { - return p != nil && p.Success != nil -} - -type TestServiceInitResultBuilder struct { - obj *TestServiceInitResult -} - -func NewTestServiceInitResultBuilder() *TestServiceInitResultBuilder{ - return &TestServiceInitResultBuilder{ - obj: NewTestServiceInitResult(), - } -} - -func (p TestServiceInitResultBuilder) Emit() *TestServiceInitResult{ - return &TestServiceInitResult{ - Success: p.obj.Success, - } -} - -func (t *TestServiceInitResultBuilder) Success(success *int64) *TestServiceInitResultBuilder { - t.obj.Success = success - return t -} - -func (t *TestServiceInitResult) SetSuccess(success *int64) *TestServiceInitResult { - t.Success = success - return t -} - -func (p *TestServiceInitResult) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 0: - if err := p.ReadField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *TestServiceInitResult) ReadField0(iprot thrift.Protocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - p.Success = &v - } - return nil -} - -func (p *TestServiceInitResult) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("init_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField0(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *TestServiceInitResult) writeField0(oprot thrift.Protocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.I64, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := oprot.WriteI64(int64(*p.Success)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.success (0) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } - } - return err -} - -func (p *TestServiceInitResult) String() string { - if p == nil { - return "" - } - - var successVal string - if p.Success == nil { - successVal = "" - } else { - successVal = fmt.Sprintf("%v", *p.Success) - } - return fmt.Sprintf("TestServiceInitResult({Success:%s})", successVal) -} - - diff --git a/thrift/compiler/test/fixtures/namespace_from_package_without_module_name/gen-go/namespace_from_package_without_module_name/module/ttypes.go b/thrift/compiler/test/fixtures/namespace_from_package_without_module_name/gen-go/namespace_from_package_without_module_name/module/ttypes.go deleted file mode 100644 index 073b1ddf591..00000000000 --- a/thrift/compiler/test/fixtures/namespace_from_package_without_module_name/gen-go/namespace_from_package_without_module_name/module/ttypes.go +++ /dev/null @@ -1,134 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package module - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var GoUnusedProtection__ int; - -// Attributes: -// - MyInt -type Foo struct { - MyInt int64 `thrift:"MyInt,1" db:"MyInt" json:"MyInt"` -} - -func NewFoo() *Foo { - return &Foo{} -} - - -func (p *Foo) GetMyInt() int64 { - return p.MyInt -} -type FooBuilder struct { - obj *Foo -} - -func NewFooBuilder() *FooBuilder{ - return &FooBuilder{ - obj: NewFoo(), - } -} - -func (p FooBuilder) Emit() *Foo{ - return &Foo{ - MyInt: p.obj.MyInt, - } -} - -func (f *FooBuilder) MyInt(myInt int64) *FooBuilder { - f.obj.MyInt = myInt - return f -} - -func (f *Foo) SetMyInt(myInt int64) *Foo { - f.MyInt = myInt - return f -} - -func (p *Foo) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Foo) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.MyInt = v - } - return nil -} - -func (p *Foo) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Foo"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Foo) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("MyInt", thrift.I64, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:MyInt: ", p), err) } - if err := oprot.WriteI64(int64(p.MyInt)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.MyInt (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:MyInt: ", p), err) } - return err -} - -func (p *Foo) String() string { - if p == nil { - return "" - } - - myIntVal := fmt.Sprintf("%v", p.MyInt) - return fmt.Sprintf("Foo({MyInt:%s})", myIntVal) -} - diff --git a/thrift/compiler/test/fixtures/optionals/gen-go/module/constants.go b/thrift/compiler/test/fixtures/optionals/gen-go/module/constants.go deleted file mode 100644 index 477cf91a64b..00000000000 --- a/thrift/compiler/test/fixtures/optionals/gen-go/module/constants.go +++ /dev/null @@ -1,25 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package module - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - - -func init() { -} - diff --git a/thrift/compiler/test/fixtures/optionals/gen-go/module/ttypes.go b/thrift/compiler/test/fixtures/optionals/gen-go/module/ttypes.go deleted file mode 100644 index dccf8721db3..00000000000 --- a/thrift/compiler/test/fixtures/optionals/gen-go/module/ttypes.go +++ /dev/null @@ -1,1327 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package module - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var GoUnusedProtection__ int; - -type Animal int64 -const ( - Animal_DOG Animal = 1 - Animal_CAT Animal = 2 - Animal_TARANTULA Animal = 3 -) - -var AnimalToName = map[Animal]string { - Animal_DOG: "DOG", - Animal_CAT: "CAT", - Animal_TARANTULA: "TARANTULA", -} - -var AnimalToValue = map[string]Animal { - "DOG": Animal_DOG, - "CAT": Animal_CAT, - "TARANTULA": Animal_TARANTULA, -} - -var AnimalNames = []string { - "DOG", - "CAT", - "TARANTULA", -} - -var AnimalValues = []Animal { - Animal_DOG, - Animal_CAT, - Animal_TARANTULA, -} - -func (p Animal) String() string { - if v, ok := AnimalToName[p]; ok { - return v - } - return "" -} - -func AnimalFromString(s string) (Animal, error) { - if v, ok := AnimalToValue[s]; ok { - return v, nil - } - return Animal(0), fmt.Errorf("not a valid Animal string") -} - -func AnimalPtr(v Animal) *Animal { return &v } - -type PersonID = int64 - -func PersonIDPtr(v PersonID) *PersonID { return &v } - -// Attributes: -// - Red -// - Green -// - Blue -// - Alpha -type Color struct { - Red float64 `thrift:"red,1" db:"red" json:"red"` - Green float64 `thrift:"green,2" db:"green" json:"green"` - Blue float64 `thrift:"blue,3" db:"blue" json:"blue"` - Alpha float64 `thrift:"alpha,4" db:"alpha" json:"alpha"` -} - -func NewColor() *Color { - return &Color{} -} - - -func (p *Color) GetRed() float64 { - return p.Red -} - -func (p *Color) GetGreen() float64 { - return p.Green -} - -func (p *Color) GetBlue() float64 { - return p.Blue -} - -func (p *Color) GetAlpha() float64 { - return p.Alpha -} -type ColorBuilder struct { - obj *Color -} - -func NewColorBuilder() *ColorBuilder{ - return &ColorBuilder{ - obj: NewColor(), - } -} - -func (p ColorBuilder) Emit() *Color{ - return &Color{ - Red: p.obj.Red, - Green: p.obj.Green, - Blue: p.obj.Blue, - Alpha: p.obj.Alpha, - } -} - -func (c *ColorBuilder) Red(red float64) *ColorBuilder { - c.obj.Red = red - return c -} - -func (c *ColorBuilder) Green(green float64) *ColorBuilder { - c.obj.Green = green - return c -} - -func (c *ColorBuilder) Blue(blue float64) *ColorBuilder { - c.obj.Blue = blue - return c -} - -func (c *ColorBuilder) Alpha(alpha float64) *ColorBuilder { - c.obj.Alpha = alpha - return c -} - -func (c *Color) SetRed(red float64) *Color { - c.Red = red - return c -} - -func (c *Color) SetGreen(green float64) *Color { - c.Green = green - return c -} - -func (c *Color) SetBlue(blue float64) *Color { - c.Blue = blue - return c -} - -func (c *Color) SetAlpha(alpha float64) *Color { - c.Alpha = alpha - return c -} - -func (p *Color) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 3: - if err := p.ReadField3(iprot); err != nil { - return err - } - case 4: - if err := p.ReadField4(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Color) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadDouble(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Red = v - } - return nil -} - -func (p *Color) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadDouble(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Green = v - } - return nil -} - -func (p *Color) ReadField3(iprot thrift.Protocol) error { - if v, err := iprot.ReadDouble(); err != nil { - return thrift.PrependError("error reading field 3: ", err) - } else { - p.Blue = v - } - return nil -} - -func (p *Color) ReadField4(iprot thrift.Protocol) error { - if v, err := iprot.ReadDouble(); err != nil { - return thrift.PrependError("error reading field 4: ", err) - } else { - p.Alpha = v - } - return nil -} - -func (p *Color) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Color"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := p.writeField4(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Color) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("red", thrift.DOUBLE, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:red: ", p), err) } - if err := oprot.WriteDouble(float64(p.Red)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.red (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:red: ", p), err) } - return err -} - -func (p *Color) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("green", thrift.DOUBLE, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:green: ", p), err) } - if err := oprot.WriteDouble(float64(p.Green)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.green (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:green: ", p), err) } - return err -} - -func (p *Color) writeField3(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("blue", thrift.DOUBLE, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:blue: ", p), err) } - if err := oprot.WriteDouble(float64(p.Blue)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.blue (3) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:blue: ", p), err) } - return err -} - -func (p *Color) writeField4(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("alpha", thrift.DOUBLE, 4); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:alpha: ", p), err) } - if err := oprot.WriteDouble(float64(p.Alpha)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.alpha (4) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 4:alpha: ", p), err) } - return err -} - -func (p *Color) String() string { - if p == nil { - return "" - } - - redVal := fmt.Sprintf("%v", p.Red) - greenVal := fmt.Sprintf("%v", p.Green) - blueVal := fmt.Sprintf("%v", p.Blue) - alphaVal := fmt.Sprintf("%v", p.Alpha) - return fmt.Sprintf("Color({Red:%s Green:%s Blue:%s Alpha:%s})", redVal, greenVal, blueVal, alphaVal) -} - -// Attributes: -// - Color -// - LicensePlate -// - Description -// - Name -// - HasAC -type Vehicle struct { - Color *Color `thrift:"color,1" db:"color" json:"color"` - LicensePlate *string `thrift:"licensePlate,2,optional" db:"licensePlate" json:"licensePlate,omitempty"` - Description *string `thrift:"description,3,optional" db:"description" json:"description,omitempty"` - Name *string `thrift:"name,4,optional" db:"name" json:"name,omitempty"` - HasAC bool `thrift:"hasAC,5,optional" db:"hasAC" json:"hasAC,omitempty"` -} - -func NewVehicle() *Vehicle { - return &Vehicle{ - Color: NewColor(), - } -} - -var Vehicle_Color_DEFAULT *Color -func (p *Vehicle) GetColor() *Color { - if !p.IsSetColor() { - return Vehicle_Color_DEFAULT - } - return p.Color -} -func (p *Vehicle) DefaultGetColor() *Color { - if !p.IsSetColor() { - return NewColor() - } - return p.Color -} -var Vehicle_LicensePlate_DEFAULT string -func (p *Vehicle) GetLicensePlate() string { - if !p.IsSetLicensePlate() { - return Vehicle_LicensePlate_DEFAULT - } - return *p.LicensePlate -} -var Vehicle_Description_DEFAULT string -func (p *Vehicle) GetDescription() string { - if !p.IsSetDescription() { - return Vehicle_Description_DEFAULT - } - return *p.Description -} -var Vehicle_Name_DEFAULT string -func (p *Vehicle) GetName() string { - if !p.IsSetName() { - return Vehicle_Name_DEFAULT - } - return *p.Name -} -var Vehicle_HasAC_DEFAULT bool = false - -func (p *Vehicle) GetHasAC() bool { - return p.HasAC -} -func (p *Vehicle) IsSetColor() bool { - return p != nil && p.Color != nil -} - -func (p *Vehicle) IsSetLicensePlate() bool { - return p != nil && p.LicensePlate != nil -} - -func (p *Vehicle) IsSetDescription() bool { - return p != nil && p.Description != nil -} - -func (p *Vehicle) IsSetName() bool { - return p != nil && p.Name != nil -} - -func (p *Vehicle) IsSetHasAC() bool { - return p != nil && p.HasAC != Vehicle_HasAC_DEFAULT -} - -type VehicleBuilder struct { - obj *Vehicle -} - -func NewVehicleBuilder() *VehicleBuilder{ - return &VehicleBuilder{ - obj: NewVehicle(), - } -} - -func (p VehicleBuilder) Emit() *Vehicle{ - return &Vehicle{ - Color: p.obj.Color, - LicensePlate: p.obj.LicensePlate, - Description: p.obj.Description, - Name: p.obj.Name, - HasAC: p.obj.HasAC, - } -} - -func (v *VehicleBuilder) Color(color *Color) *VehicleBuilder { - v.obj.Color = color - return v -} - -func (v *VehicleBuilder) LicensePlate(licensePlate *string) *VehicleBuilder { - v.obj.LicensePlate = licensePlate - return v -} - -func (v *VehicleBuilder) Description(description *string) *VehicleBuilder { - v.obj.Description = description - return v -} - -func (v *VehicleBuilder) Name(name *string) *VehicleBuilder { - v.obj.Name = name - return v -} - -func (v *VehicleBuilder) HasAC(hasAC bool) *VehicleBuilder { - v.obj.HasAC = hasAC - return v -} - -func (v *Vehicle) SetColor(color *Color) *Vehicle { - v.Color = color - return v -} - -func (v *Vehicle) SetLicensePlate(licensePlate *string) *Vehicle { - v.LicensePlate = licensePlate - return v -} - -func (v *Vehicle) SetDescription(description *string) *Vehicle { - v.Description = description - return v -} - -func (v *Vehicle) SetName(name *string) *Vehicle { - v.Name = name - return v -} - -func (v *Vehicle) SetHasAC(hasAC bool) *Vehicle { - v.HasAC = hasAC - return v -} - -func (p *Vehicle) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 3: - if err := p.ReadField3(iprot); err != nil { - return err - } - case 4: - if err := p.ReadField4(iprot); err != nil { - return err - } - case 5: - if err := p.ReadField5(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Vehicle) ReadField1(iprot thrift.Protocol) error { - p.Color = NewColor() - if err := p.Color.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Color), err) - } - return nil -} - -func (p *Vehicle) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.LicensePlate = &v - } - return nil -} - -func (p *Vehicle) ReadField3(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 3: ", err) - } else { - p.Description = &v - } - return nil -} - -func (p *Vehicle) ReadField4(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 4: ", err) - } else { - p.Name = &v - } - return nil -} - -func (p *Vehicle) ReadField5(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 5: ", err) - } else { - p.HasAC = v - } - return nil -} - -func (p *Vehicle) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Vehicle"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := p.writeField4(oprot); err != nil { return err } - if err := p.writeField5(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Vehicle) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("color", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:color: ", p), err) } - if err := p.Color.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Color), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:color: ", p), err) } - return err -} - -func (p *Vehicle) writeField2(oprot thrift.Protocol) (err error) { - if p.IsSetLicensePlate() { - if err := oprot.WriteFieldBegin("licensePlate", thrift.STRING, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:licensePlate: ", p), err) } - if err := oprot.WriteString(string(*p.LicensePlate)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.licensePlate (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:licensePlate: ", p), err) } - } - return err -} - -func (p *Vehicle) writeField3(oprot thrift.Protocol) (err error) { - if p.IsSetDescription() { - if err := oprot.WriteFieldBegin("description", thrift.STRING, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:description: ", p), err) } - if err := oprot.WriteString(string(*p.Description)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.description (3) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:description: ", p), err) } - } - return err -} - -func (p *Vehicle) writeField4(oprot thrift.Protocol) (err error) { - if p.IsSetName() { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 4); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:name: ", p), err) } - if err := oprot.WriteString(string(*p.Name)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.name (4) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 4:name: ", p), err) } - } - return err -} - -func (p *Vehicle) writeField5(oprot thrift.Protocol) (err error) { - if p.IsSetHasAC() { - if err := oprot.WriteFieldBegin("hasAC", thrift.BOOL, 5); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:hasAC: ", p), err) } - if err := oprot.WriteBool(bool(p.HasAC)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.hasAC (5) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 5:hasAC: ", p), err) } - } - return err -} - -func (p *Vehicle) String() string { - if p == nil { - return "" - } - - var colorVal string - if p.Color == nil { - colorVal = "" - } else { - colorVal = fmt.Sprintf("%v", p.Color) - } - var licensePlateVal string - if p.LicensePlate == nil { - licensePlateVal = "" - } else { - licensePlateVal = fmt.Sprintf("%v", *p.LicensePlate) - } - var descriptionVal string - if p.Description == nil { - descriptionVal = "" - } else { - descriptionVal = fmt.Sprintf("%v", *p.Description) - } - var nameVal string - if p.Name == nil { - nameVal = "" - } else { - nameVal = fmt.Sprintf("%v", *p.Name) - } - hasACVal := fmt.Sprintf("%v", p.HasAC) - return fmt.Sprintf("Vehicle({Color:%s LicensePlate:%s Description:%s Name:%s HasAC:%s})", colorVal, licensePlateVal, descriptionVal, nameVal, hasACVal) -} - -// Attributes: -// - Id -// - Name -// - Age -// - Address -// - FavoriteColor -// - Friends -// - BestFriend -// - PetNames -// - AfraidOfAnimal -// - Vehicles -type Person struct { - Id PersonID `thrift:"id,1" db:"id" json:"id"` - Name string `thrift:"name,2" db:"name" json:"name"` - Age *int16 `thrift:"age,3,optional" db:"age" json:"age,omitempty"` - Address *string `thrift:"address,4,optional" db:"address" json:"address,omitempty"` - FavoriteColor *Color `thrift:"favoriteColor,5,optional" db:"favoriteColor" json:"favoriteColor,omitempty"` - Friends []PersonID `thrift:"friends,6,optional" db:"friends" json:"friends,omitempty"` - BestFriend *PersonID `thrift:"bestFriend,7,optional" db:"bestFriend" json:"bestFriend,omitempty"` - PetNames map[Animal]string `thrift:"petNames,8,optional" db:"petNames" json:"petNames,omitempty"` - AfraidOfAnimal *Animal `thrift:"afraidOfAnimal,9,optional" db:"afraidOfAnimal" json:"afraidOfAnimal,omitempty"` - Vehicles []*Vehicle `thrift:"vehicles,10,optional" db:"vehicles" json:"vehicles,omitempty"` -} - -func NewPerson() *Person { - return &Person{} -} - - -func (p *Person) GetId() PersonID { - return p.Id -} - -func (p *Person) GetName() string { - return p.Name -} -var Person_Age_DEFAULT int16 -func (p *Person) GetAge() int16 { - if !p.IsSetAge() { - return Person_Age_DEFAULT - } - return *p.Age -} -var Person_Address_DEFAULT string -func (p *Person) GetAddress() string { - if !p.IsSetAddress() { - return Person_Address_DEFAULT - } - return *p.Address -} -var Person_FavoriteColor_DEFAULT *Color -func (p *Person) GetFavoriteColor() *Color { - if !p.IsSetFavoriteColor() { - return Person_FavoriteColor_DEFAULT - } - return p.FavoriteColor -} -func (p *Person) DefaultGetFavoriteColor() *Color { - if !p.IsSetFavoriteColor() { - return NewColor() - } - return p.FavoriteColor -} -var Person_Friends_DEFAULT []PersonID - -func (p *Person) GetFriends() []PersonID { - return p.Friends -} -var Person_BestFriend_DEFAULT PersonID -func (p *Person) GetBestFriend() PersonID { - if !p.IsSetBestFriend() { - return Person_BestFriend_DEFAULT - } - return *p.BestFriend -} -var Person_PetNames_DEFAULT map[Animal]string - -func (p *Person) GetPetNames() map[Animal]string { - return p.PetNames -} -var Person_AfraidOfAnimal_DEFAULT Animal -func (p *Person) GetAfraidOfAnimal() Animal { - if !p.IsSetAfraidOfAnimal() { - return Person_AfraidOfAnimal_DEFAULT - } - return *p.AfraidOfAnimal -} -var Person_Vehicles_DEFAULT []*Vehicle - -func (p *Person) GetVehicles() []*Vehicle { - return p.Vehicles -} -func (p *Person) IsSetAge() bool { - return p != nil && p.Age != nil -} - -func (p *Person) IsSetAddress() bool { - return p != nil && p.Address != nil -} - -func (p *Person) IsSetFavoriteColor() bool { - return p != nil && p.FavoriteColor != nil -} - -func (p *Person) IsSetFriends() bool { - return p != nil && p.Friends != nil -} - -func (p *Person) IsSetBestFriend() bool { - return p != nil && p.BestFriend != nil -} - -func (p *Person) IsSetPetNames() bool { - return p != nil && p.PetNames != nil -} - -func (p *Person) IsSetAfraidOfAnimal() bool { - return p != nil && p.AfraidOfAnimal != nil -} - -func (p *Person) IsSetVehicles() bool { - return p != nil && p.Vehicles != nil -} - -type PersonBuilder struct { - obj *Person -} - -func NewPersonBuilder() *PersonBuilder{ - return &PersonBuilder{ - obj: NewPerson(), - } -} - -func (p PersonBuilder) Emit() *Person{ - return &Person{ - Id: p.obj.Id, - Name: p.obj.Name, - Age: p.obj.Age, - Address: p.obj.Address, - FavoriteColor: p.obj.FavoriteColor, - Friends: p.obj.Friends, - BestFriend: p.obj.BestFriend, - PetNames: p.obj.PetNames, - AfraidOfAnimal: p.obj.AfraidOfAnimal, - Vehicles: p.obj.Vehicles, - } -} - -func (p *PersonBuilder) Id(id PersonID) *PersonBuilder { - p.obj.Id = id - return p -} - -func (p *PersonBuilder) Name(name string) *PersonBuilder { - p.obj.Name = name - return p -} - -func (p *PersonBuilder) Age(age *int16) *PersonBuilder { - p.obj.Age = age - return p -} - -func (p *PersonBuilder) Address(address *string) *PersonBuilder { - p.obj.Address = address - return p -} - -func (p *PersonBuilder) FavoriteColor(favoriteColor *Color) *PersonBuilder { - p.obj.FavoriteColor = favoriteColor - return p -} - -func (p *PersonBuilder) Friends(friends []PersonID) *PersonBuilder { - p.obj.Friends = friends - return p -} - -func (p *PersonBuilder) BestFriend(bestFriend *PersonID) *PersonBuilder { - p.obj.BestFriend = bestFriend - return p -} - -func (p *PersonBuilder) PetNames(petNames map[Animal]string) *PersonBuilder { - p.obj.PetNames = petNames - return p -} - -func (p *PersonBuilder) AfraidOfAnimal(afraidOfAnimal *Animal) *PersonBuilder { - p.obj.AfraidOfAnimal = afraidOfAnimal - return p -} - -func (p *PersonBuilder) Vehicles(vehicles []*Vehicle) *PersonBuilder { - p.obj.Vehicles = vehicles - return p -} - -func (p *Person) SetId(id PersonID) *Person { - p.Id = id - return p -} - -func (p *Person) SetName(name string) *Person { - p.Name = name - return p -} - -func (p *Person) SetAge(age *int16) *Person { - p.Age = age - return p -} - -func (p *Person) SetAddress(address *string) *Person { - p.Address = address - return p -} - -func (p *Person) SetFavoriteColor(favoriteColor *Color) *Person { - p.FavoriteColor = favoriteColor - return p -} - -func (p *Person) SetFriends(friends []PersonID) *Person { - p.Friends = friends - return p -} - -func (p *Person) SetBestFriend(bestFriend *PersonID) *Person { - p.BestFriend = bestFriend - return p -} - -func (p *Person) SetPetNames(petNames map[Animal]string) *Person { - p.PetNames = petNames - return p -} - -func (p *Person) SetAfraidOfAnimal(afraidOfAnimal *Animal) *Person { - p.AfraidOfAnimal = afraidOfAnimal - return p -} - -func (p *Person) SetVehicles(vehicles []*Vehicle) *Person { - p.Vehicles = vehicles - return p -} - -func (p *Person) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 3: - if err := p.ReadField3(iprot); err != nil { - return err - } - case 4: - if err := p.ReadField4(iprot); err != nil { - return err - } - case 5: - if err := p.ReadField5(iprot); err != nil { - return err - } - case 6: - if err := p.ReadField6(iprot); err != nil { - return err - } - case 7: - if err := p.ReadField7(iprot); err != nil { - return err - } - case 8: - if err := p.ReadField8(iprot); err != nil { - return err - } - case 9: - if err := p.ReadField9(iprot); err != nil { - return err - } - case 10: - if err := p.ReadField10(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Person) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - temp := PersonID(v) - p.Id = temp - } - return nil -} - -func (p *Person) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Name = v - } - return nil -} - -func (p *Person) ReadField3(iprot thrift.Protocol) error { - if v, err := iprot.ReadI16(); err != nil { - return thrift.PrependError("error reading field 3: ", err) - } else { - p.Age = &v - } - return nil -} - -func (p *Person) ReadField4(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 4: ", err) - } else { - p.Address = &v - } - return nil -} - -func (p *Person) ReadField5(iprot thrift.Protocol) error { - p.FavoriteColor = NewColor() - if err := p.FavoriteColor.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.FavoriteColor), err) - } - return nil -} - -func (p *Person) ReadField6(iprot thrift.Protocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return thrift.PrependError("error reading set begin: ", err) - } - tSet := make([]PersonID, 0, size) - p.Friends = tSet - for i := 0; i < size; i ++ { - var _elem0 PersonID - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - temp := PersonID(v) - _elem0 = temp - } - p.Friends = append(p.Friends, _elem0) - } - if err := iprot.ReadSetEnd(); err != nil { - return thrift.PrependError("error reading set end: ", err) - } - return nil -} - -func (p *Person) ReadField7(iprot thrift.Protocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 7: ", err) - } else { - temp := PersonID(v) - p.BestFriend = &temp - } - return nil -} - -func (p *Person) ReadField8(iprot thrift.Protocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[Animal]string, size) - p.PetNames = tMap - for i := 0; i < size; i ++ { - var _key1 Animal - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - temp := Animal(v) - _key1 = temp - } - var _val2 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _val2 = v - } - p.PetNames[_key1] = _val2 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *Person) ReadField9(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 9: ", err) - } else { - temp := Animal(v) - p.AfraidOfAnimal = &temp - } - return nil -} - -func (p *Person) ReadField10(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]*Vehicle, 0, size) - p.Vehicles = tSlice - for i := 0; i < size; i ++ { - _elem3 := NewVehicle() - if err := _elem3.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem3), err) - } - p.Vehicles = append(p.Vehicles, _elem3) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *Person) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Person"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := p.writeField4(oprot); err != nil { return err } - if err := p.writeField5(oprot); err != nil { return err } - if err := p.writeField6(oprot); err != nil { return err } - if err := p.writeField7(oprot); err != nil { return err } - if err := p.writeField8(oprot); err != nil { return err } - if err := p.writeField9(oprot); err != nil { return err } - if err := p.writeField10(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Person) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("id", thrift.I64, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:id: ", p), err) } - if err := oprot.WriteI64(int64(p.Id)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.id (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:id: ", p), err) } - return err -} - -func (p *Person) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:name: ", p), err) } - if err := oprot.WriteString(string(p.Name)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.name (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:name: ", p), err) } - return err -} - -func (p *Person) writeField3(oprot thrift.Protocol) (err error) { - if p.IsSetAge() { - if err := oprot.WriteFieldBegin("age", thrift.I16, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:age: ", p), err) } - if err := oprot.WriteI16(int16(*p.Age)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.age (3) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:age: ", p), err) } - } - return err -} - -func (p *Person) writeField4(oprot thrift.Protocol) (err error) { - if p.IsSetAddress() { - if err := oprot.WriteFieldBegin("address", thrift.STRING, 4); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:address: ", p), err) } - if err := oprot.WriteString(string(*p.Address)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.address (4) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 4:address: ", p), err) } - } - return err -} - -func (p *Person) writeField5(oprot thrift.Protocol) (err error) { - if p.IsSetFavoriteColor() { - if err := oprot.WriteFieldBegin("favoriteColor", thrift.STRUCT, 5); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:favoriteColor: ", p), err) } - if err := p.FavoriteColor.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.FavoriteColor), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 5:favoriteColor: ", p), err) } - } - return err -} - -func (p *Person) writeField6(oprot thrift.Protocol) (err error) { - if p.IsSetFriends() { - if err := oprot.WriteFieldBegin("friends", thrift.SET, 6); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 6:friends: ", p), err) } - if err := oprot.WriteSetBegin(thrift.I64, len(p.Friends)); err != nil { - return thrift.PrependError("error writing set begin: ", err) - } - set := make(map[PersonID]bool, len(p.Friends)) - for _, v := range p.Friends { - if ok := set[v]; ok { - return thrift.PrependError("", fmt.Errorf("%T error writing set field: slice is not unique", v)) - } - set[v] = true - } - for _, v := range p.Friends { - if err := oprot.WriteI64(int64(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteSetEnd(); err != nil { - return thrift.PrependError("error writing set end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 6:friends: ", p), err) } - } - return err -} - -func (p *Person) writeField7(oprot thrift.Protocol) (err error) { - if p.IsSetBestFriend() { - if err := oprot.WriteFieldBegin("bestFriend", thrift.I64, 7); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 7:bestFriend: ", p), err) } - if err := oprot.WriteI64(int64(*p.BestFriend)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.bestFriend (7) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 7:bestFriend: ", p), err) } - } - return err -} - -func (p *Person) writeField8(oprot thrift.Protocol) (err error) { - if p.IsSetPetNames() { - if err := oprot.WriteFieldBegin("petNames", thrift.MAP, 8); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 8:petNames: ", p), err) } - if err := oprot.WriteMapBegin(thrift.I32, thrift.STRING, len(p.PetNames)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.PetNames { - if err := oprot.WriteI32(int32(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := oprot.WriteString(string(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 8:petNames: ", p), err) } - } - return err -} - -func (p *Person) writeField9(oprot thrift.Protocol) (err error) { - if p.IsSetAfraidOfAnimal() { - if err := oprot.WriteFieldBegin("afraidOfAnimal", thrift.I32, 9); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 9:afraidOfAnimal: ", p), err) } - if err := oprot.WriteI32(int32(*p.AfraidOfAnimal)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.afraidOfAnimal (9) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 9:afraidOfAnimal: ", p), err) } - } - return err -} - -func (p *Person) writeField10(oprot thrift.Protocol) (err error) { - if p.IsSetVehicles() { - if err := oprot.WriteFieldBegin("vehicles", thrift.LIST, 10); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 10:vehicles: ", p), err) } - if err := oprot.WriteListBegin(thrift.STRUCT, len(p.Vehicles)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.Vehicles { - if err := v.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) - } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 10:vehicles: ", p), err) } - } - return err -} - -func (p *Person) String() string { - if p == nil { - return "" - } - - idVal := fmt.Sprintf("%v", p.Id) - nameVal := fmt.Sprintf("%v", p.Name) - var ageVal string - if p.Age == nil { - ageVal = "" - } else { - ageVal = fmt.Sprintf("%v", *p.Age) - } - var addressVal string - if p.Address == nil { - addressVal = "" - } else { - addressVal = fmt.Sprintf("%v", *p.Address) - } - var favoriteColorVal string - if p.FavoriteColor == nil { - favoriteColorVal = "" - } else { - favoriteColorVal = fmt.Sprintf("%v", p.FavoriteColor) - } - friendsVal := fmt.Sprintf("%v", p.Friends) - var bestFriendVal string - if p.BestFriend == nil { - bestFriendVal = "" - } else { - bestFriendVal = fmt.Sprintf("%v", *p.BestFriend) - } - petNamesVal := fmt.Sprintf("%v", p.PetNames) - var afraidOfAnimalVal string - if p.AfraidOfAnimal == nil { - afraidOfAnimalVal = "" - } else { - afraidOfAnimalVal = fmt.Sprintf("%v", *p.AfraidOfAnimal) - } - vehiclesVal := fmt.Sprintf("%v", p.Vehicles) - return fmt.Sprintf("Person({Id:%s Name:%s Age:%s Address:%s FavoriteColor:%s Friends:%s BestFriend:%s PetNames:%s AfraidOfAnimal:%s Vehicles:%s})", idVal, nameVal, ageVal, addressVal, favoriteColorVal, friendsVal, bestFriendVal, petNamesVal, afraidOfAnimalVal, vehiclesVal) -} - diff --git a/thrift/compiler/test/fixtures/params/gen-go/module/constants.go b/thrift/compiler/test/fixtures/params/gen-go/module/constants.go deleted file mode 100644 index 477cf91a64b..00000000000 --- a/thrift/compiler/test/fixtures/params/gen-go/module/constants.go +++ /dev/null @@ -1,25 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package module - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - - -func init() { -} - diff --git a/thrift/compiler/test/fixtures/params/gen-go/module/nestedcontainers.go b/thrift/compiler/test/fixtures/params/gen-go/module/nestedcontainers.go deleted file mode 100644 index 60a5bf9ba5a..00000000000 --- a/thrift/compiler/test/fixtures/params/gen-go/module/nestedcontainers.go +++ /dev/null @@ -1,1920 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package module - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -type NestedContainers interface { - // Parameters: - // - Foo - MapList(foo map[int32][]int32) (err error) - // Parameters: - // - Foo - MapSet(foo map[int32][]int32) (err error) - // Parameters: - // - Foo - ListMap(foo []map[int32]int32) (err error) - // Parameters: - // - Foo - ListSet(foo [][]int32) (err error) - // Parameters: - // - Foo - Turtles(foo [][]map[int32]map[int32][]int32) (err error) -} - -type NestedContainersClientInterface interface { - thrift.ClientInterface - // Parameters: - // - Foo - MapList(foo map[int32][]int32) (err error) - // Parameters: - // - Foo - MapSet(foo map[int32][]int32) (err error) - // Parameters: - // - Foo - ListMap(foo []map[int32]int32) (err error) - // Parameters: - // - Foo - ListSet(foo [][]int32) (err error) - // Parameters: - // - Foo - Turtles(foo [][]map[int32]map[int32][]int32) (err error) -} - -type NestedContainersClient struct { - NestedContainersClientInterface - CC thrift.ClientConn -} - -func(client *NestedContainersClient) Open() error { - return client.CC.Open() -} - -func(client *NestedContainersClient) Close() error { - return client.CC.Close() -} - -func(client *NestedContainersClient) IsOpen() bool { - return client.CC.IsOpen() -} - -func NewNestedContainersClientFactory(t thrift.Transport, f thrift.ProtocolFactory) *NestedContainersClient { - return &NestedContainersClient{ CC: thrift.NewClientConn(t, f) } -} - -func NewNestedContainersClient(t thrift.Transport, iprot thrift.Protocol, oprot thrift.Protocol) *NestedContainersClient { - return &NestedContainersClient{ CC: thrift.NewClientConnWithProtocols(t, iprot, oprot) } -} - -func NewNestedContainersClientProtocol(prot thrift.Protocol) *NestedContainersClient { - return NewNestedContainersClient(prot.Transport(), prot, prot) -} - -// Parameters: -// - Foo -func (p *NestedContainersClient) MapList(foo map[int32][]int32) (err error) { - args := NestedContainersMapListArgs{ - Foo : foo, - } - err = p.CC.SendMsg("mapList", &args, thrift.CALL) - if err != nil { return } - return p.recvMapList() -} - - -func (p *NestedContainersClient) recvMapList() (err error) { - var __result NestedContainersMapListResult - return p.CC.RecvMsg("mapList", &__result) -} - -// Parameters: -// - Foo -func (p *NestedContainersClient) MapSet(foo map[int32][]int32) (err error) { - args := NestedContainersMapSetArgs{ - Foo : foo, - } - err = p.CC.SendMsg("mapSet", &args, thrift.CALL) - if err != nil { return } - return p.recvMapSet() -} - - -func (p *NestedContainersClient) recvMapSet() (err error) { - var __result NestedContainersMapSetResult - return p.CC.RecvMsg("mapSet", &__result) -} - -// Parameters: -// - Foo -func (p *NestedContainersClient) ListMap(foo []map[int32]int32) (err error) { - args := NestedContainersListMapArgs{ - Foo : foo, - } - err = p.CC.SendMsg("listMap", &args, thrift.CALL) - if err != nil { return } - return p.recvListMap() -} - - -func (p *NestedContainersClient) recvListMap() (err error) { - var __result NestedContainersListMapResult - return p.CC.RecvMsg("listMap", &__result) -} - -// Parameters: -// - Foo -func (p *NestedContainersClient) ListSet(foo [][]int32) (err error) { - args := NestedContainersListSetArgs{ - Foo : foo, - } - err = p.CC.SendMsg("listSet", &args, thrift.CALL) - if err != nil { return } - return p.recvListSet() -} - - -func (p *NestedContainersClient) recvListSet() (err error) { - var __result NestedContainersListSetResult - return p.CC.RecvMsg("listSet", &__result) -} - -// Parameters: -// - Foo -func (p *NestedContainersClient) Turtles(foo [][]map[int32]map[int32][]int32) (err error) { - args := NestedContainersTurtlesArgs{ - Foo : foo, - } - err = p.CC.SendMsg("turtles", &args, thrift.CALL) - if err != nil { return } - return p.recvTurtles() -} - - -func (p *NestedContainersClient) recvTurtles() (err error) { - var __result NestedContainersTurtlesResult - return p.CC.RecvMsg("turtles", &__result) -} - - -type NestedContainersThreadsafeClient struct { - NestedContainersClientInterface - CC thrift.ClientConn - Mu sync.Mutex -} - -func(client *NestedContainersThreadsafeClient) Open() error { - client.Mu.Lock() - defer client.Mu.Unlock() - return client.CC.Open() -} - -func(client *NestedContainersThreadsafeClient) Close() error { - client.Mu.Lock() - defer client.Mu.Unlock() - return client.CC.Close() -} - -func(client *NestedContainersThreadsafeClient) IsOpen() bool { - client.Mu.Lock() - defer client.Mu.Unlock() - return client.CC.IsOpen() -} - -func NewNestedContainersThreadsafeClientFactory(t thrift.Transport, f thrift.ProtocolFactory) *NestedContainersThreadsafeClient { - return &NestedContainersThreadsafeClient{ CC: thrift.NewClientConn(t, f) } -} - -func NewNestedContainersThreadsafeClient(t thrift.Transport, iprot thrift.Protocol, oprot thrift.Protocol) *NestedContainersThreadsafeClient { - return &NestedContainersThreadsafeClient{ CC: thrift.NewClientConnWithProtocols(t, iprot, oprot) } -} - -func NewNestedContainersThreadsafeClientProtocol(prot thrift.Protocol) *NestedContainersThreadsafeClient { - return NewNestedContainersThreadsafeClient(prot.Transport(), prot, prot) -} - -// Parameters: -// - Foo -func (p *NestedContainersThreadsafeClient) MapList(foo map[int32][]int32) (err error) { - p.Mu.Lock() - defer p.Mu.Unlock() - args := NestedContainersMapListArgs{ - Foo : foo, - } - err = p.CC.SendMsg("mapList", &args, thrift.CALL) - if err != nil { return } - return p.recvMapList() -} - - -func (p *NestedContainersThreadsafeClient) recvMapList() (err error) { - var __result NestedContainersMapListResult - return p.CC.RecvMsg("mapList", &__result) -} - -// Parameters: -// - Foo -func (p *NestedContainersThreadsafeClient) MapSet(foo map[int32][]int32) (err error) { - p.Mu.Lock() - defer p.Mu.Unlock() - args := NestedContainersMapSetArgs{ - Foo : foo, - } - err = p.CC.SendMsg("mapSet", &args, thrift.CALL) - if err != nil { return } - return p.recvMapSet() -} - - -func (p *NestedContainersThreadsafeClient) recvMapSet() (err error) { - var __result NestedContainersMapSetResult - return p.CC.RecvMsg("mapSet", &__result) -} - -// Parameters: -// - Foo -func (p *NestedContainersThreadsafeClient) ListMap(foo []map[int32]int32) (err error) { - p.Mu.Lock() - defer p.Mu.Unlock() - args := NestedContainersListMapArgs{ - Foo : foo, - } - err = p.CC.SendMsg("listMap", &args, thrift.CALL) - if err != nil { return } - return p.recvListMap() -} - - -func (p *NestedContainersThreadsafeClient) recvListMap() (err error) { - var __result NestedContainersListMapResult - return p.CC.RecvMsg("listMap", &__result) -} - -// Parameters: -// - Foo -func (p *NestedContainersThreadsafeClient) ListSet(foo [][]int32) (err error) { - p.Mu.Lock() - defer p.Mu.Unlock() - args := NestedContainersListSetArgs{ - Foo : foo, - } - err = p.CC.SendMsg("listSet", &args, thrift.CALL) - if err != nil { return } - return p.recvListSet() -} - - -func (p *NestedContainersThreadsafeClient) recvListSet() (err error) { - var __result NestedContainersListSetResult - return p.CC.RecvMsg("listSet", &__result) -} - -// Parameters: -// - Foo -func (p *NestedContainersThreadsafeClient) Turtles(foo [][]map[int32]map[int32][]int32) (err error) { - p.Mu.Lock() - defer p.Mu.Unlock() - args := NestedContainersTurtlesArgs{ - Foo : foo, - } - err = p.CC.SendMsg("turtles", &args, thrift.CALL) - if err != nil { return } - return p.recvTurtles() -} - - -func (p *NestedContainersThreadsafeClient) recvTurtles() (err error) { - var __result NestedContainersTurtlesResult - return p.CC.RecvMsg("turtles", &__result) -} - - -type NestedContainersChannelClient struct { - RequestChannel thrift.RequestChannel -} - -func (c *NestedContainersChannelClient) Close() error { - return c.RequestChannel.Close() -} - -func (c *NestedContainersChannelClient) IsOpen() bool { - return c.RequestChannel.IsOpen() -} - -func (c *NestedContainersChannelClient) Open() error { - return c.RequestChannel.Open() -} - -func NewNestedContainersChannelClient(channel thrift.RequestChannel) *NestedContainersChannelClient { - return &NestedContainersChannelClient{RequestChannel: channel} -} - -// Parameters: -// - Foo -func (p *NestedContainersChannelClient) MapList(ctx context.Context, foo map[int32][]int32) (err error) { - args := NestedContainersMapListArgs{ - Foo : foo, - } - var __result NestedContainersMapListResult - err = p.RequestChannel.Call(ctx, "mapList", &args, &__result) - if err != nil { return } - - return nil -} - -// Parameters: -// - Foo -func (p *NestedContainersChannelClient) MapSet(ctx context.Context, foo map[int32][]int32) (err error) { - args := NestedContainersMapSetArgs{ - Foo : foo, - } - var __result NestedContainersMapSetResult - err = p.RequestChannel.Call(ctx, "mapSet", &args, &__result) - if err != nil { return } - - return nil -} - -// Parameters: -// - Foo -func (p *NestedContainersChannelClient) ListMap(ctx context.Context, foo []map[int32]int32) (err error) { - args := NestedContainersListMapArgs{ - Foo : foo, - } - var __result NestedContainersListMapResult - err = p.RequestChannel.Call(ctx, "listMap", &args, &__result) - if err != nil { return } - - return nil -} - -// Parameters: -// - Foo -func (p *NestedContainersChannelClient) ListSet(ctx context.Context, foo [][]int32) (err error) { - args := NestedContainersListSetArgs{ - Foo : foo, - } - var __result NestedContainersListSetResult - err = p.RequestChannel.Call(ctx, "listSet", &args, &__result) - if err != nil { return } - - return nil -} - -// Parameters: -// - Foo -func (p *NestedContainersChannelClient) Turtles(ctx context.Context, foo [][]map[int32]map[int32][]int32) (err error) { - args := NestedContainersTurtlesArgs{ - Foo : foo, - } - var __result NestedContainersTurtlesResult - err = p.RequestChannel.Call(ctx, "turtles", &args, &__result) - if err != nil { return } - - return nil -} - - -type NestedContainersProcessor struct { - processorMap map[string]thrift.ProcessorFunction - functionServiceMap map[string]string - handler NestedContainers -} - -func (p *NestedContainersProcessor) AddToProcessorMap(key string, processor thrift.ProcessorFunction) { - p.processorMap[key] = processor -} - -func (p *NestedContainersProcessor) AddToFunctionServiceMap(key, service string) { - p.functionServiceMap[key] = service -} - -func (p *NestedContainersProcessor) GetProcessorFunction(key string) (processor thrift.ProcessorFunction, err error) { - if processor, ok := p.processorMap[key]; ok { - return processor, nil - } - return nil, nil // generic error message will be sent -} - -func (p *NestedContainersProcessor) ProcessorMap() map[string]thrift.ProcessorFunction { - return p.processorMap -} - -func (p *NestedContainersProcessor) FunctionServiceMap() map[string]string { - return p.functionServiceMap -} - -func NewNestedContainersProcessor(handler NestedContainers) *NestedContainersProcessor { - self0 := &NestedContainersProcessor{handler:handler, processorMap:make(map[string]thrift.ProcessorFunction), functionServiceMap:make(map[string]string)} - self0.processorMap["mapList"] = &nestedContainersProcessorMapList{handler:handler} - self0.processorMap["mapSet"] = &nestedContainersProcessorMapSet{handler:handler} - self0.processorMap["listMap"] = &nestedContainersProcessorListMap{handler:handler} - self0.processorMap["listSet"] = &nestedContainersProcessorListSet{handler:handler} - self0.processorMap["turtles"] = &nestedContainersProcessorTurtles{handler:handler} - self0.functionServiceMap["mapList"] = "NestedContainers" - self0.functionServiceMap["mapSet"] = "NestedContainers" - self0.functionServiceMap["listMap"] = "NestedContainers" - self0.functionServiceMap["listSet"] = "NestedContainers" - self0.functionServiceMap["turtles"] = "NestedContainers" - return self0 -} - -type nestedContainersProcessorMapList struct { - handler NestedContainers -} - -func (p *NestedContainersMapListResult) Exception() thrift.WritableException { - if p == nil { return nil } - return nil -} - -func (p *nestedContainersProcessorMapList) Read(iprot thrift.Protocol) (thrift.Struct, thrift.Exception) { - args := NestedContainersMapListArgs{} - if err := args.Read(iprot); err != nil { - return nil, err - } - iprot.ReadMessageEnd() - return &args, nil -} - -func (p *nestedContainersProcessorMapList) Write(seqId int32, result thrift.WritableStruct, oprot thrift.Protocol) (err thrift.Exception) { - var err2 error - messageType := thrift.REPLY - switch result.(type) { - case thrift.ApplicationException: - messageType = thrift.EXCEPTION - } - if err2 = oprot.WriteMessageBegin("mapList", messageType, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - return err -} - -func (p *nestedContainersProcessorMapList) Run(argStruct thrift.Struct) (thrift.WritableStruct, thrift.ApplicationException) { - args := argStruct.(*NestedContainersMapListArgs) - var __result NestedContainersMapListResult - if err := p.handler.MapList(args.Foo); err != nil { - switch err.(type) { - default: - x := thrift.NewApplicationExceptionCause(thrift.INTERNAL_ERROR, "Internal error processing mapList: " + err.Error(), err) - return x, x - } - } - return &__result, nil -} - -type nestedContainersProcessorMapSet struct { - handler NestedContainers -} - -func (p *NestedContainersMapSetResult) Exception() thrift.WritableException { - if p == nil { return nil } - return nil -} - -func (p *nestedContainersProcessorMapSet) Read(iprot thrift.Protocol) (thrift.Struct, thrift.Exception) { - args := NestedContainersMapSetArgs{} - if err := args.Read(iprot); err != nil { - return nil, err - } - iprot.ReadMessageEnd() - return &args, nil -} - -func (p *nestedContainersProcessorMapSet) Write(seqId int32, result thrift.WritableStruct, oprot thrift.Protocol) (err thrift.Exception) { - var err2 error - messageType := thrift.REPLY - switch result.(type) { - case thrift.ApplicationException: - messageType = thrift.EXCEPTION - } - if err2 = oprot.WriteMessageBegin("mapSet", messageType, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - return err -} - -func (p *nestedContainersProcessorMapSet) Run(argStruct thrift.Struct) (thrift.WritableStruct, thrift.ApplicationException) { - args := argStruct.(*NestedContainersMapSetArgs) - var __result NestedContainersMapSetResult - if err := p.handler.MapSet(args.Foo); err != nil { - switch err.(type) { - default: - x := thrift.NewApplicationExceptionCause(thrift.INTERNAL_ERROR, "Internal error processing mapSet: " + err.Error(), err) - return x, x - } - } - return &__result, nil -} - -type nestedContainersProcessorListMap struct { - handler NestedContainers -} - -func (p *NestedContainersListMapResult) Exception() thrift.WritableException { - if p == nil { return nil } - return nil -} - -func (p *nestedContainersProcessorListMap) Read(iprot thrift.Protocol) (thrift.Struct, thrift.Exception) { - args := NestedContainersListMapArgs{} - if err := args.Read(iprot); err != nil { - return nil, err - } - iprot.ReadMessageEnd() - return &args, nil -} - -func (p *nestedContainersProcessorListMap) Write(seqId int32, result thrift.WritableStruct, oprot thrift.Protocol) (err thrift.Exception) { - var err2 error - messageType := thrift.REPLY - switch result.(type) { - case thrift.ApplicationException: - messageType = thrift.EXCEPTION - } - if err2 = oprot.WriteMessageBegin("listMap", messageType, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - return err -} - -func (p *nestedContainersProcessorListMap) Run(argStruct thrift.Struct) (thrift.WritableStruct, thrift.ApplicationException) { - args := argStruct.(*NestedContainersListMapArgs) - var __result NestedContainersListMapResult - if err := p.handler.ListMap(args.Foo); err != nil { - switch err.(type) { - default: - x := thrift.NewApplicationExceptionCause(thrift.INTERNAL_ERROR, "Internal error processing listMap: " + err.Error(), err) - return x, x - } - } - return &__result, nil -} - -type nestedContainersProcessorListSet struct { - handler NestedContainers -} - -func (p *NestedContainersListSetResult) Exception() thrift.WritableException { - if p == nil { return nil } - return nil -} - -func (p *nestedContainersProcessorListSet) Read(iprot thrift.Protocol) (thrift.Struct, thrift.Exception) { - args := NestedContainersListSetArgs{} - if err := args.Read(iprot); err != nil { - return nil, err - } - iprot.ReadMessageEnd() - return &args, nil -} - -func (p *nestedContainersProcessorListSet) Write(seqId int32, result thrift.WritableStruct, oprot thrift.Protocol) (err thrift.Exception) { - var err2 error - messageType := thrift.REPLY - switch result.(type) { - case thrift.ApplicationException: - messageType = thrift.EXCEPTION - } - if err2 = oprot.WriteMessageBegin("listSet", messageType, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - return err -} - -func (p *nestedContainersProcessorListSet) Run(argStruct thrift.Struct) (thrift.WritableStruct, thrift.ApplicationException) { - args := argStruct.(*NestedContainersListSetArgs) - var __result NestedContainersListSetResult - if err := p.handler.ListSet(args.Foo); err != nil { - switch err.(type) { - default: - x := thrift.NewApplicationExceptionCause(thrift.INTERNAL_ERROR, "Internal error processing listSet: " + err.Error(), err) - return x, x - } - } - return &__result, nil -} - -type nestedContainersProcessorTurtles struct { - handler NestedContainers -} - -func (p *NestedContainersTurtlesResult) Exception() thrift.WritableException { - if p == nil { return nil } - return nil -} - -func (p *nestedContainersProcessorTurtles) Read(iprot thrift.Protocol) (thrift.Struct, thrift.Exception) { - args := NestedContainersTurtlesArgs{} - if err := args.Read(iprot); err != nil { - return nil, err - } - iprot.ReadMessageEnd() - return &args, nil -} - -func (p *nestedContainersProcessorTurtles) Write(seqId int32, result thrift.WritableStruct, oprot thrift.Protocol) (err thrift.Exception) { - var err2 error - messageType := thrift.REPLY - switch result.(type) { - case thrift.ApplicationException: - messageType = thrift.EXCEPTION - } - if err2 = oprot.WriteMessageBegin("turtles", messageType, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - return err -} - -func (p *nestedContainersProcessorTurtles) Run(argStruct thrift.Struct) (thrift.WritableStruct, thrift.ApplicationException) { - args := argStruct.(*NestedContainersTurtlesArgs) - var __result NestedContainersTurtlesResult - if err := p.handler.Turtles(args.Foo); err != nil { - switch err.(type) { - default: - x := thrift.NewApplicationExceptionCause(thrift.INTERNAL_ERROR, "Internal error processing turtles: " + err.Error(), err) - return x, x - } - } - return &__result, nil -} - - -// HELPER FUNCTIONS AND STRUCTURES - -// Attributes: -// - Foo -type NestedContainersMapListArgs struct { - thrift.IRequest - Foo map[int32][]int32 `thrift:"foo,1" db:"foo" json:"foo"` -} - -func NewNestedContainersMapListArgs() *NestedContainersMapListArgs { - return &NestedContainersMapListArgs{} -} - - -func (p *NestedContainersMapListArgs) GetFoo() map[int32][]int32 { - return p.Foo -} -type NestedContainersMapListArgsBuilder struct { - obj *NestedContainersMapListArgs -} - -func NewNestedContainersMapListArgsBuilder() *NestedContainersMapListArgsBuilder{ - return &NestedContainersMapListArgsBuilder{ - obj: NewNestedContainersMapListArgs(), - } -} - -func (p NestedContainersMapListArgsBuilder) Emit() *NestedContainersMapListArgs{ - return &NestedContainersMapListArgs{ - Foo: p.obj.Foo, - } -} - -func (n *NestedContainersMapListArgsBuilder) Foo(foo map[int32][]int32) *NestedContainersMapListArgsBuilder { - n.obj.Foo = foo - return n -} - -func (n *NestedContainersMapListArgs) SetFoo(foo map[int32][]int32) *NestedContainersMapListArgs { - n.Foo = foo - return n -} - -func (p *NestedContainersMapListArgs) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *NestedContainersMapListArgs) ReadField1(iprot thrift.Protocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[int32][]int32, size) - p.Foo = tMap - for i := 0; i < size; i ++ { - var _key2 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key2 = v - } - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]int32, 0, size) - _val3 := tSlice - for i := 0; i < size; i ++ { - var _elem4 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem4 = v - } - _val3 = append(_val3, _elem4) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - p.Foo[_key2] = _val3 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *NestedContainersMapListArgs) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("mapList_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *NestedContainersMapListArgs) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("foo", thrift.MAP, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:foo: ", p), err) } - if err := oprot.WriteMapBegin(thrift.I32, thrift.LIST, len(p.Foo)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.Foo { - if err := oprot.WriteI32(int32(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := oprot.WriteListBegin(thrift.I32, len(v)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range v { - if err := oprot.WriteI32(int32(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:foo: ", p), err) } - return err -} - -func (p *NestedContainersMapListArgs) String() string { - if p == nil { - return "" - } - - fooVal := fmt.Sprintf("%v", p.Foo) - return fmt.Sprintf("NestedContainersMapListArgs({Foo:%s})", fooVal) -} - -type NestedContainersMapListResult struct { - thrift.IResponse -} - -func NewNestedContainersMapListResult() *NestedContainersMapListResult { - return &NestedContainersMapListResult{} -} - -type NestedContainersMapListResultBuilder struct { - obj *NestedContainersMapListResult -} - -func NewNestedContainersMapListResultBuilder() *NestedContainersMapListResultBuilder{ - return &NestedContainersMapListResultBuilder{ - obj: NewNestedContainersMapListResult(), - } -} - -func (p NestedContainersMapListResultBuilder) Emit() *NestedContainersMapListResult{ - return &NestedContainersMapListResult{ - } -} - -func (p *NestedContainersMapListResult) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *NestedContainersMapListResult) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("mapList_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *NestedContainersMapListResult) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("NestedContainersMapListResult({})") -} - -// Attributes: -// - Foo -type NestedContainersMapSetArgs struct { - thrift.IRequest - Foo map[int32][]int32 `thrift:"foo,1" db:"foo" json:"foo"` -} - -func NewNestedContainersMapSetArgs() *NestedContainersMapSetArgs { - return &NestedContainersMapSetArgs{} -} - - -func (p *NestedContainersMapSetArgs) GetFoo() map[int32][]int32 { - return p.Foo -} -type NestedContainersMapSetArgsBuilder struct { - obj *NestedContainersMapSetArgs -} - -func NewNestedContainersMapSetArgsBuilder() *NestedContainersMapSetArgsBuilder{ - return &NestedContainersMapSetArgsBuilder{ - obj: NewNestedContainersMapSetArgs(), - } -} - -func (p NestedContainersMapSetArgsBuilder) Emit() *NestedContainersMapSetArgs{ - return &NestedContainersMapSetArgs{ - Foo: p.obj.Foo, - } -} - -func (n *NestedContainersMapSetArgsBuilder) Foo(foo map[int32][]int32) *NestedContainersMapSetArgsBuilder { - n.obj.Foo = foo - return n -} - -func (n *NestedContainersMapSetArgs) SetFoo(foo map[int32][]int32) *NestedContainersMapSetArgs { - n.Foo = foo - return n -} - -func (p *NestedContainersMapSetArgs) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *NestedContainersMapSetArgs) ReadField1(iprot thrift.Protocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[int32][]int32, size) - p.Foo = tMap - for i := 0; i < size; i ++ { - var _key5 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key5 = v - } - _, size, err := iprot.ReadSetBegin() - if err != nil { - return thrift.PrependError("error reading set begin: ", err) - } - tSet := make([]int32, 0, size) - _val6 := tSet - for i := 0; i < size; i ++ { - var _elem7 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem7 = v - } - _val6 = append(_val6, _elem7) - } - if err := iprot.ReadSetEnd(); err != nil { - return thrift.PrependError("error reading set end: ", err) - } - p.Foo[_key5] = _val6 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *NestedContainersMapSetArgs) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("mapSet_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *NestedContainersMapSetArgs) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("foo", thrift.MAP, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:foo: ", p), err) } - if err := oprot.WriteMapBegin(thrift.I32, thrift.SET, len(p.Foo)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.Foo { - if err := oprot.WriteI32(int32(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := oprot.WriteSetBegin(thrift.I32, len(v)); err != nil { - return thrift.PrependError("error writing set begin: ", err) - } - set := make(map[int32]bool, len(v)) - for _, v := range v { - if ok := set[v]; ok { - return thrift.PrependError("", fmt.Errorf("%T error writing set field: slice is not unique", v)) - } - set[v] = true - } - for _, v := range v { - if err := oprot.WriteI32(int32(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteSetEnd(); err != nil { - return thrift.PrependError("error writing set end: ", err) - } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:foo: ", p), err) } - return err -} - -func (p *NestedContainersMapSetArgs) String() string { - if p == nil { - return "" - } - - fooVal := fmt.Sprintf("%v", p.Foo) - return fmt.Sprintf("NestedContainersMapSetArgs({Foo:%s})", fooVal) -} - -type NestedContainersMapSetResult struct { - thrift.IResponse -} - -func NewNestedContainersMapSetResult() *NestedContainersMapSetResult { - return &NestedContainersMapSetResult{} -} - -type NestedContainersMapSetResultBuilder struct { - obj *NestedContainersMapSetResult -} - -func NewNestedContainersMapSetResultBuilder() *NestedContainersMapSetResultBuilder{ - return &NestedContainersMapSetResultBuilder{ - obj: NewNestedContainersMapSetResult(), - } -} - -func (p NestedContainersMapSetResultBuilder) Emit() *NestedContainersMapSetResult{ - return &NestedContainersMapSetResult{ - } -} - -func (p *NestedContainersMapSetResult) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *NestedContainersMapSetResult) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("mapSet_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *NestedContainersMapSetResult) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("NestedContainersMapSetResult({})") -} - -// Attributes: -// - Foo -type NestedContainersListMapArgs struct { - thrift.IRequest - Foo []map[int32]int32 `thrift:"foo,1" db:"foo" json:"foo"` -} - -func NewNestedContainersListMapArgs() *NestedContainersListMapArgs { - return &NestedContainersListMapArgs{} -} - - -func (p *NestedContainersListMapArgs) GetFoo() []map[int32]int32 { - return p.Foo -} -type NestedContainersListMapArgsBuilder struct { - obj *NestedContainersListMapArgs -} - -func NewNestedContainersListMapArgsBuilder() *NestedContainersListMapArgsBuilder{ - return &NestedContainersListMapArgsBuilder{ - obj: NewNestedContainersListMapArgs(), - } -} - -func (p NestedContainersListMapArgsBuilder) Emit() *NestedContainersListMapArgs{ - return &NestedContainersListMapArgs{ - Foo: p.obj.Foo, - } -} - -func (n *NestedContainersListMapArgsBuilder) Foo(foo []map[int32]int32) *NestedContainersListMapArgsBuilder { - n.obj.Foo = foo - return n -} - -func (n *NestedContainersListMapArgs) SetFoo(foo []map[int32]int32) *NestedContainersListMapArgs { - n.Foo = foo - return n -} - -func (p *NestedContainersListMapArgs) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *NestedContainersListMapArgs) ReadField1(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]map[int32]int32, 0, size) - p.Foo = tSlice - for i := 0; i < size; i ++ { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[int32]int32, size) - _elem8 := tMap - for i := 0; i < size; i ++ { - var _key9 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key9 = v - } - var _val10 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _val10 = v - } - _elem8[_key9] = _val10 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - p.Foo = append(p.Foo, _elem8) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *NestedContainersListMapArgs) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("listMap_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *NestedContainersListMapArgs) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("foo", thrift.LIST, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:foo: ", p), err) } - if err := oprot.WriteListBegin(thrift.MAP, len(p.Foo)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.Foo { - if err := oprot.WriteMapBegin(thrift.I32, thrift.I32, len(v)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range v { - if err := oprot.WriteI32(int32(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := oprot.WriteI32(int32(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:foo: ", p), err) } - return err -} - -func (p *NestedContainersListMapArgs) String() string { - if p == nil { - return "" - } - - fooVal := fmt.Sprintf("%v", p.Foo) - return fmt.Sprintf("NestedContainersListMapArgs({Foo:%s})", fooVal) -} - -type NestedContainersListMapResult struct { - thrift.IResponse -} - -func NewNestedContainersListMapResult() *NestedContainersListMapResult { - return &NestedContainersListMapResult{} -} - -type NestedContainersListMapResultBuilder struct { - obj *NestedContainersListMapResult -} - -func NewNestedContainersListMapResultBuilder() *NestedContainersListMapResultBuilder{ - return &NestedContainersListMapResultBuilder{ - obj: NewNestedContainersListMapResult(), - } -} - -func (p NestedContainersListMapResultBuilder) Emit() *NestedContainersListMapResult{ - return &NestedContainersListMapResult{ - } -} - -func (p *NestedContainersListMapResult) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *NestedContainersListMapResult) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("listMap_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *NestedContainersListMapResult) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("NestedContainersListMapResult({})") -} - -// Attributes: -// - Foo -type NestedContainersListSetArgs struct { - thrift.IRequest - Foo [][]int32 `thrift:"foo,1" db:"foo" json:"foo"` -} - -func NewNestedContainersListSetArgs() *NestedContainersListSetArgs { - return &NestedContainersListSetArgs{} -} - - -func (p *NestedContainersListSetArgs) GetFoo() [][]int32 { - return p.Foo -} -type NestedContainersListSetArgsBuilder struct { - obj *NestedContainersListSetArgs -} - -func NewNestedContainersListSetArgsBuilder() *NestedContainersListSetArgsBuilder{ - return &NestedContainersListSetArgsBuilder{ - obj: NewNestedContainersListSetArgs(), - } -} - -func (p NestedContainersListSetArgsBuilder) Emit() *NestedContainersListSetArgs{ - return &NestedContainersListSetArgs{ - Foo: p.obj.Foo, - } -} - -func (n *NestedContainersListSetArgsBuilder) Foo(foo [][]int32) *NestedContainersListSetArgsBuilder { - n.obj.Foo = foo - return n -} - -func (n *NestedContainersListSetArgs) SetFoo(foo [][]int32) *NestedContainersListSetArgs { - n.Foo = foo - return n -} - -func (p *NestedContainersListSetArgs) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *NestedContainersListSetArgs) ReadField1(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([][]int32, 0, size) - p.Foo = tSlice - for i := 0; i < size; i ++ { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return thrift.PrependError("error reading set begin: ", err) - } - tSet := make([]int32, 0, size) - _elem11 := tSet - for i := 0; i < size; i ++ { - var _elem12 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem12 = v - } - _elem11 = append(_elem11, _elem12) - } - if err := iprot.ReadSetEnd(); err != nil { - return thrift.PrependError("error reading set end: ", err) - } - p.Foo = append(p.Foo, _elem11) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *NestedContainersListSetArgs) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("listSet_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *NestedContainersListSetArgs) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("foo", thrift.LIST, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:foo: ", p), err) } - if err := oprot.WriteListBegin(thrift.SET, len(p.Foo)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.Foo { - if err := oprot.WriteSetBegin(thrift.I32, len(v)); err != nil { - return thrift.PrependError("error writing set begin: ", err) - } - set := make(map[int32]bool, len(v)) - for _, v := range v { - if ok := set[v]; ok { - return thrift.PrependError("", fmt.Errorf("%T error writing set field: slice is not unique", v)) - } - set[v] = true - } - for _, v := range v { - if err := oprot.WriteI32(int32(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteSetEnd(); err != nil { - return thrift.PrependError("error writing set end: ", err) - } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:foo: ", p), err) } - return err -} - -func (p *NestedContainersListSetArgs) String() string { - if p == nil { - return "" - } - - fooVal := fmt.Sprintf("%v", p.Foo) - return fmt.Sprintf("NestedContainersListSetArgs({Foo:%s})", fooVal) -} - -type NestedContainersListSetResult struct { - thrift.IResponse -} - -func NewNestedContainersListSetResult() *NestedContainersListSetResult { - return &NestedContainersListSetResult{} -} - -type NestedContainersListSetResultBuilder struct { - obj *NestedContainersListSetResult -} - -func NewNestedContainersListSetResultBuilder() *NestedContainersListSetResultBuilder{ - return &NestedContainersListSetResultBuilder{ - obj: NewNestedContainersListSetResult(), - } -} - -func (p NestedContainersListSetResultBuilder) Emit() *NestedContainersListSetResult{ - return &NestedContainersListSetResult{ - } -} - -func (p *NestedContainersListSetResult) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *NestedContainersListSetResult) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("listSet_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *NestedContainersListSetResult) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("NestedContainersListSetResult({})") -} - -// Attributes: -// - Foo -type NestedContainersTurtlesArgs struct { - thrift.IRequest - Foo [][]map[int32]map[int32][]int32 `thrift:"foo,1" db:"foo" json:"foo"` -} - -func NewNestedContainersTurtlesArgs() *NestedContainersTurtlesArgs { - return &NestedContainersTurtlesArgs{} -} - - -func (p *NestedContainersTurtlesArgs) GetFoo() [][]map[int32]map[int32][]int32 { - return p.Foo -} -type NestedContainersTurtlesArgsBuilder struct { - obj *NestedContainersTurtlesArgs -} - -func NewNestedContainersTurtlesArgsBuilder() *NestedContainersTurtlesArgsBuilder{ - return &NestedContainersTurtlesArgsBuilder{ - obj: NewNestedContainersTurtlesArgs(), - } -} - -func (p NestedContainersTurtlesArgsBuilder) Emit() *NestedContainersTurtlesArgs{ - return &NestedContainersTurtlesArgs{ - Foo: p.obj.Foo, - } -} - -func (n *NestedContainersTurtlesArgsBuilder) Foo(foo [][]map[int32]map[int32][]int32) *NestedContainersTurtlesArgsBuilder { - n.obj.Foo = foo - return n -} - -func (n *NestedContainersTurtlesArgs) SetFoo(foo [][]map[int32]map[int32][]int32) *NestedContainersTurtlesArgs { - n.Foo = foo - return n -} - -func (p *NestedContainersTurtlesArgs) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *NestedContainersTurtlesArgs) ReadField1(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([][]map[int32]map[int32][]int32, 0, size) - p.Foo = tSlice - for i := 0; i < size; i ++ { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]map[int32]map[int32][]int32, 0, size) - _elem13 := tSlice - for i := 0; i < size; i ++ { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[int32]map[int32][]int32, size) - _elem14 := tMap - for i := 0; i < size; i ++ { - var _key15 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key15 = v - } - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[int32][]int32, size) - _val16 := tMap - for i := 0; i < size; i ++ { - var _key17 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key17 = v - } - _, size, err := iprot.ReadSetBegin() - if err != nil { - return thrift.PrependError("error reading set begin: ", err) - } - tSet := make([]int32, 0, size) - _val18 := tSet - for i := 0; i < size; i ++ { - var _elem19 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem19 = v - } - _val18 = append(_val18, _elem19) - } - if err := iprot.ReadSetEnd(); err != nil { - return thrift.PrependError("error reading set end: ", err) - } - _val16[_key17] = _val18 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - _elem14[_key15] = _val16 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - _elem13 = append(_elem13, _elem14) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - p.Foo = append(p.Foo, _elem13) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *NestedContainersTurtlesArgs) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("turtles_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *NestedContainersTurtlesArgs) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("foo", thrift.LIST, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:foo: ", p), err) } - if err := oprot.WriteListBegin(thrift.LIST, len(p.Foo)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.Foo { - if err := oprot.WriteListBegin(thrift.MAP, len(v)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range v { - if err := oprot.WriteMapBegin(thrift.I32, thrift.MAP, len(v)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range v { - if err := oprot.WriteI32(int32(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := oprot.WriteMapBegin(thrift.I32, thrift.SET, len(v)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range v { - if err := oprot.WriteI32(int32(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := oprot.WriteSetBegin(thrift.I32, len(v)); err != nil { - return thrift.PrependError("error writing set begin: ", err) - } - set := make(map[int32]bool, len(v)) - for _, v := range v { - if ok := set[v]; ok { - return thrift.PrependError("", fmt.Errorf("%T error writing set field: slice is not unique", v)) - } - set[v] = true - } - for _, v := range v { - if err := oprot.WriteI32(int32(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteSetEnd(); err != nil { - return thrift.PrependError("error writing set end: ", err) - } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:foo: ", p), err) } - return err -} - -func (p *NestedContainersTurtlesArgs) String() string { - if p == nil { - return "" - } - - fooVal := fmt.Sprintf("%v", p.Foo) - return fmt.Sprintf("NestedContainersTurtlesArgs({Foo:%s})", fooVal) -} - -type NestedContainersTurtlesResult struct { - thrift.IResponse -} - -func NewNestedContainersTurtlesResult() *NestedContainersTurtlesResult { - return &NestedContainersTurtlesResult{} -} - -type NestedContainersTurtlesResultBuilder struct { - obj *NestedContainersTurtlesResult -} - -func NewNestedContainersTurtlesResultBuilder() *NestedContainersTurtlesResultBuilder{ - return &NestedContainersTurtlesResultBuilder{ - obj: NewNestedContainersTurtlesResult(), - } -} - -func (p NestedContainersTurtlesResultBuilder) Emit() *NestedContainersTurtlesResult{ - return &NestedContainersTurtlesResult{ - } -} - -func (p *NestedContainersTurtlesResult) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *NestedContainersTurtlesResult) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("turtles_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *NestedContainersTurtlesResult) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("NestedContainersTurtlesResult({})") -} - - diff --git a/thrift/compiler/test/fixtures/params/gen-go/module/ttypes.go b/thrift/compiler/test/fixtures/params/gen-go/module/ttypes.go deleted file mode 100644 index 75439abe961..00000000000 --- a/thrift/compiler/test/fixtures/params/gen-go/module/ttypes.go +++ /dev/null @@ -1,23 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package module - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var GoUnusedProtection__ int; - diff --git a/thrift/compiler/test/fixtures/patch/gen-go/module/constants.go b/thrift/compiler/test/fixtures/patch/gen-go/module/constants.go deleted file mode 100644 index 1e56f5e4c98..00000000000 --- a/thrift/compiler/test/fixtures/patch/gen-go/module/constants.go +++ /dev/null @@ -1,30 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package module - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" - patch0 "thrift/lib/thrift/patch" - standard1 "thrift/lib/thrift/standard" - -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var _ = patch0.GoUnusedProtection__ -var _ = standard1.GoUnusedProtection__ - -func init() { -} - diff --git a/thrift/compiler/test/fixtures/patch/gen-go/module/ttypes.go b/thrift/compiler/test/fixtures/patch/gen-go/module/ttypes.go deleted file mode 100644 index 95f0336371e..00000000000 --- a/thrift/compiler/test/fixtures/patch/gen-go/module/ttypes.go +++ /dev/null @@ -1,15850 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package module - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" - patch0 "thrift/lib/thrift/patch" - standard1 "thrift/lib/thrift/standard" - -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var _ = patch0.GoUnusedProtection__ -var _ = standard1.GoUnusedProtection__ -var GoUnusedProtection__ int; - -type MyEnum int64 -const ( - MyEnum_MyValue0 MyEnum = 0 -) - -var MyEnumToName = map[MyEnum]string { - MyEnum_MyValue0: "MyValue0", -} - -var MyEnumToValue = map[string]MyEnum { - "MyValue0": MyEnum_MyValue0, -} - -var MyEnumNames = []string { - "MyValue0", -} - -var MyEnumValues = []MyEnum { - MyEnum_MyValue0, -} - -func (p MyEnum) String() string { - if v, ok := MyEnumToName[p]; ok { - return v - } - return "" -} - -func MyEnumFromString(s string) (MyEnum, error) { - if v, ok := MyEnumToValue[s]; ok { - return v, nil - } - return MyEnum(0), fmt.Errorf("not a valid MyEnum string") -} - -func MyEnumPtr(v MyEnum) *MyEnum { return &v } - -// Attributes: -// - Data1 -// - Data2 -type MyData struct { - Data1 string `thrift:"data1,1" db:"data1" json:"data1"` - Data2 int32 `thrift:"data2,2" db:"data2" json:"data2"` -} - -func NewMyData() *MyData { - return &MyData{} -} - - -func (p *MyData) GetData1() string { - return p.Data1 -} - -func (p *MyData) GetData2() int32 { - return p.Data2 -} -type MyDataBuilder struct { - obj *MyData -} - -func NewMyDataBuilder() *MyDataBuilder{ - return &MyDataBuilder{ - obj: NewMyData(), - } -} - -func (p MyDataBuilder) Emit() *MyData{ - return &MyData{ - Data1: p.obj.Data1, - Data2: p.obj.Data2, - } -} - -func (m *MyDataBuilder) Data1(data1 string) *MyDataBuilder { - m.obj.Data1 = data1 - return m -} - -func (m *MyDataBuilder) Data2(data2 int32) *MyDataBuilder { - m.obj.Data2 = data2 - return m -} - -func (m *MyData) SetData1(data1 string) *MyData { - m.Data1 = data1 - return m -} - -func (m *MyData) SetData2(data2 int32) *MyData { - m.Data2 = data2 - return m -} - -func (p *MyData) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyData) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Data1 = v - } - return nil -} - -func (p *MyData) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Data2 = v - } - return nil -} - -func (p *MyData) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("MyData"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyData) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("data1", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:data1: ", p), err) } - if err := oprot.WriteString(string(p.Data1)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.data1 (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:data1: ", p), err) } - return err -} - -func (p *MyData) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("data2", thrift.I32, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:data2: ", p), err) } - if err := oprot.WriteI32(int32(p.Data2)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.data2 (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:data2: ", p), err) } - return err -} - -func (p *MyData) String() string { - if p == nil { - return "" - } - - data1Val := fmt.Sprintf("%v", p.Data1) - data2Val := fmt.Sprintf("%v", p.Data2) - return fmt.Sprintf("MyData({Data1:%s Data2:%s})", data1Val, data2Val) -} - -// Attributes: -// - Data1 -// - Data2 -type MyDataWithCustomDefault struct { - Data1 string `thrift:"data1,1" db:"data1" json:"data1"` - Data2 int32 `thrift:"data2,2" db:"data2" json:"data2"` -} - -func NewMyDataWithCustomDefault() *MyDataWithCustomDefault { - return &MyDataWithCustomDefault{ - Data1: "1", - Data2: 2, - } -} - - -func (p *MyDataWithCustomDefault) GetData1() string { - return p.Data1 -} - -func (p *MyDataWithCustomDefault) GetData2() int32 { - return p.Data2 -} -type MyDataWithCustomDefaultBuilder struct { - obj *MyDataWithCustomDefault -} - -func NewMyDataWithCustomDefaultBuilder() *MyDataWithCustomDefaultBuilder{ - return &MyDataWithCustomDefaultBuilder{ - obj: NewMyDataWithCustomDefault(), - } -} - -func (p MyDataWithCustomDefaultBuilder) Emit() *MyDataWithCustomDefault{ - return &MyDataWithCustomDefault{ - Data1: p.obj.Data1, - Data2: p.obj.Data2, - } -} - -func (m *MyDataWithCustomDefaultBuilder) Data1(data1 string) *MyDataWithCustomDefaultBuilder { - m.obj.Data1 = data1 - return m -} - -func (m *MyDataWithCustomDefaultBuilder) Data2(data2 int32) *MyDataWithCustomDefaultBuilder { - m.obj.Data2 = data2 - return m -} - -func (m *MyDataWithCustomDefault) SetData1(data1 string) *MyDataWithCustomDefault { - m.Data1 = data1 - return m -} - -func (m *MyDataWithCustomDefault) SetData2(data2 int32) *MyDataWithCustomDefault { - m.Data2 = data2 - return m -} - -func (p *MyDataWithCustomDefault) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyDataWithCustomDefault) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Data1 = v - } - return nil -} - -func (p *MyDataWithCustomDefault) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Data2 = v - } - return nil -} - -func (p *MyDataWithCustomDefault) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("MyDataWithCustomDefault"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyDataWithCustomDefault) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("data1", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:data1: ", p), err) } - if err := oprot.WriteString(string(p.Data1)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.data1 (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:data1: ", p), err) } - return err -} - -func (p *MyDataWithCustomDefault) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("data2", thrift.I32, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:data2: ", p), err) } - if err := oprot.WriteI32(int32(p.Data2)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.data2 (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:data2: ", p), err) } - return err -} - -func (p *MyDataWithCustomDefault) String() string { - if p == nil { - return "" - } - - data1Val := fmt.Sprintf("%v", p.Data1) - data2Val := fmt.Sprintf("%v", p.Data2) - return fmt.Sprintf("MyDataWithCustomDefault({Data1:%s Data2:%s})", data1Val, data2Val) -} - -// Attributes: -// - InnerOption -type InnerUnion struct { - InnerOption []byte `thrift:"innerOption,1,optional" db:"innerOption" json:"innerOption,omitempty"` -} - -func NewInnerUnion() *InnerUnion { - return &InnerUnion{} -} - -var InnerUnion_InnerOption_DEFAULT []byte - -func (p *InnerUnion) GetInnerOption() []byte { - return p.InnerOption -} -func (p *InnerUnion) IsSetInnerOption() bool { - return p != nil && p.InnerOption != nil -} - -type InnerUnionBuilder struct { - obj *InnerUnion -} - -func NewInnerUnionBuilder() *InnerUnionBuilder{ - return &InnerUnionBuilder{ - obj: NewInnerUnion(), - } -} - -func (p InnerUnionBuilder) Emit() *InnerUnion{ - return &InnerUnion{ - InnerOption: p.obj.InnerOption, - } -} - -func (i *InnerUnionBuilder) InnerOption(innerOption []byte) *InnerUnionBuilder { - i.obj.InnerOption = innerOption - return i -} - -func (i *InnerUnion) SetInnerOption(innerOption []byte) *InnerUnion { - i.InnerOption = innerOption - return i -} - -func (p *InnerUnion) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *InnerUnion) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadBinary(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.InnerOption = v - } - return nil -} - -func (p *InnerUnion) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("InnerUnion"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *InnerUnion) writeField1(oprot thrift.Protocol) (err error) { - if p.IsSetInnerOption() { - if err := oprot.WriteFieldBegin("innerOption", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:innerOption: ", p), err) } - if err := oprot.WriteBinary(p.InnerOption); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.innerOption (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:innerOption: ", p), err) } - } - return err -} - -func (p *InnerUnion) String() string { - if p == nil { - return "" - } - - innerOptionVal := fmt.Sprintf("%v", p.InnerOption) - return fmt.Sprintf("InnerUnion({InnerOption:%s})", innerOptionVal) -} - -// Attributes: -// - Option1 -// - Option2 -// - Option3 -type MyUnion struct { - Option1 *string `thrift:"option1,1,optional" db:"option1" json:"option1,omitempty"` - Option2 *int32 `thrift:"option2,2,optional" db:"option2" json:"option2,omitempty"` - Option3 *InnerUnion `thrift:"option3,3,optional" db:"option3" json:"option3,omitempty"` -} - -func NewMyUnion() *MyUnion { - return &MyUnion{} -} - -var MyUnion_Option1_DEFAULT string -func (p *MyUnion) GetOption1() string { - if !p.IsSetOption1() { - return MyUnion_Option1_DEFAULT - } - return *p.Option1 -} -var MyUnion_Option2_DEFAULT int32 -func (p *MyUnion) GetOption2() int32 { - if !p.IsSetOption2() { - return MyUnion_Option2_DEFAULT - } - return *p.Option2 -} -var MyUnion_Option3_DEFAULT *InnerUnion -func (p *MyUnion) GetOption3() *InnerUnion { - if !p.IsSetOption3() { - return MyUnion_Option3_DEFAULT - } - return p.Option3 -} -func (p *MyUnion) DefaultGetOption3() *InnerUnion { - if !p.IsSetOption3() { - return NewInnerUnion() - } - return p.Option3 -} -func (p *MyUnion) CountSetFieldsMyUnion() int { - count := 0 - if (p.IsSetOption1()) { - count++ - } - if (p.IsSetOption2()) { - count++ - } - if (p.IsSetOption3()) { - count++ - } - return count - -} - -func (p *MyUnion) IsSetOption1() bool { - return p != nil && p.Option1 != nil -} - -func (p *MyUnion) IsSetOption2() bool { - return p != nil && p.Option2 != nil -} - -func (p *MyUnion) IsSetOption3() bool { - return p != nil && p.Option3 != nil -} - -type MyUnionBuilder struct { - obj *MyUnion -} - -func NewMyUnionBuilder() *MyUnionBuilder{ - return &MyUnionBuilder{ - obj: NewMyUnion(), - } -} - -func (p MyUnionBuilder) Emit() *MyUnion{ - return &MyUnion{ - Option1: p.obj.Option1, - Option2: p.obj.Option2, - Option3: p.obj.Option3, - } -} - -func (m *MyUnionBuilder) Option1(option1 *string) *MyUnionBuilder { - m.obj.Option1 = option1 - return m -} - -func (m *MyUnionBuilder) Option2(option2 *int32) *MyUnionBuilder { - m.obj.Option2 = option2 - return m -} - -func (m *MyUnionBuilder) Option3(option3 *InnerUnion) *MyUnionBuilder { - m.obj.Option3 = option3 - return m -} - -func (m *MyUnion) SetOption1(option1 *string) *MyUnion { - m.Option1 = option1 - return m -} - -func (m *MyUnion) SetOption2(option2 *int32) *MyUnion { - m.Option2 = option2 - return m -} - -func (m *MyUnion) SetOption3(option3 *InnerUnion) *MyUnion { - m.Option3 = option3 - return m -} - -func (p *MyUnion) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 3: - if err := p.ReadField3(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyUnion) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Option1 = &v - } - return nil -} - -func (p *MyUnion) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Option2 = &v - } - return nil -} - -func (p *MyUnion) ReadField3(iprot thrift.Protocol) error { - p.Option3 = NewInnerUnion() - if err := p.Option3.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Option3), err) - } - return nil -} - -func (p *MyUnion) Write(oprot thrift.Protocol) error { - if c := p.CountSetFieldsMyUnion(); c > 1 { - return fmt.Errorf("%T write union: no more than one field must be set (%d set).", p, c) - } - if err := oprot.WriteStructBegin("MyUnion"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyUnion) writeField1(oprot thrift.Protocol) (err error) { - if p.IsSetOption1() { - if err := oprot.WriteFieldBegin("option1", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:option1: ", p), err) } - if err := oprot.WriteString(string(*p.Option1)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.option1 (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:option1: ", p), err) } - } - return err -} - -func (p *MyUnion) writeField2(oprot thrift.Protocol) (err error) { - if p.IsSetOption2() { - if err := oprot.WriteFieldBegin("option2", thrift.I32, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:option2: ", p), err) } - if err := oprot.WriteI32(int32(*p.Option2)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.option2 (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:option2: ", p), err) } - } - return err -} - -func (p *MyUnion) writeField3(oprot thrift.Protocol) (err error) { - if p.IsSetOption3() { - if err := oprot.WriteFieldBegin("option3", thrift.STRUCT, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:option3: ", p), err) } - if err := p.Option3.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Option3), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:option3: ", p), err) } - } - return err -} - -func (p *MyUnion) String() string { - if p == nil { - return "" - } - - var option1Val string - if p.Option1 == nil { - option1Val = "" - } else { - option1Val = fmt.Sprintf("%v", *p.Option1) - } - var option2Val string - if p.Option2 == nil { - option2Val = "" - } else { - option2Val = fmt.Sprintf("%v", *p.Option2) - } - var option3Val string - if p.Option3 == nil { - option3Val = "" - } else { - option3Val = fmt.Sprintf("%v", p.Option3) - } - return fmt.Sprintf("MyUnion({Option1:%s Option2:%s Option3:%s})", option1Val, option2Val, option3Val) -} - -// Attributes: -// - BoolVal -// - ByteVal -// - I16Val -// - I32Val -// - I64Val -// - FloatVal -// - DoubleVal -// - StringVal -// - BinaryVal -// - EnumVal -// - StructVal -// - UnionVal -// - LateStructVal -// - OptBoolVal -// - OptByteVal -// - OptI16Val -// - OptI32Val -// - OptI64Val -// - OptFloatVal -// - OptDoubleVal -// - OptStringVal -// - OptBinaryVal -// - OptEnumVal -// - OptStructVal -// - OptLateStructVal -// - OptListVal -// - OptSetVal -// - OptMapVal -// - ListMap -// - MapMap -// - I32WithCustomDefault -// - StructWithCustomDefault -// - StructWithFieldCustomDefault -type MyStruct struct { - BoolVal bool - ByteVal int8 - I16Val int16 - I32Val int32 - I64Val int64 - FloatVal float32 - DoubleVal float64 - StringVal string - BinaryVal []byte - EnumVal MyEnum - StructVal *MyData - UnionVal *MyUnion - LateStructVal *LateDefStruct - OptBoolVal bool - OptByteVal int8 - OptI16Val int16 - OptI32Val int32 - OptI64Val int64 - OptFloatVal float32 - OptDoubleVal float64 - OptStringVal string - OptBinaryVal []byte - OptEnumVal MyEnum - OptStructVal *MyData - OptLateStructVal *LateDefStruct - OptListVal []int16 - OptSetVal []string - OptMapVal map[string]string - ListMap []map[string]int32 - MapMap map[string]map[string]int32 - I32WithCustomDefault int32 - StructWithCustomDefault *MyDataWithCustomDefault - StructWithFieldCustomDefault *MyData -} - -func NewMyStruct() *MyStruct { - return &MyStruct{ - StructVal: NewMyData(), - LateStructVal: NewLateDefStruct(), - I32WithCustomDefault: 1, - StructWithCustomDefault: NewMyDataWithCustomDefault(), - StructWithFieldCustomDefault: NewMyData(), - } -} - - -func (p *MyStruct) GetBoolVal() bool { - return p.BoolVal -} - -func (p *MyStruct) GetByteVal() int8 { - return p.ByteVal -} - -func (p *MyStruct) GetI16Val() int16 { - return p.I16Val -} - -func (p *MyStruct) GetI32Val() int32 { - return p.I32Val -} - -func (p *MyStruct) GetI64Val() int64 { - return p.I64Val -} - -func (p *MyStruct) GetFloatVal() float32 { - return p.FloatVal -} - -func (p *MyStruct) GetDoubleVal() float64 { - return p.DoubleVal -} - -func (p *MyStruct) GetStringVal() string { - return p.StringVal -} - -func (p *MyStruct) GetBinaryVal() []byte { - return p.BinaryVal -} - -func (p *MyStruct) GetEnumVal() MyEnum { - return p.EnumVal -} -var MyStruct_StructVal_DEFAULT *MyData -func (p *MyStruct) GetStructVal() *MyData { - if !p.IsSetStructVal() { - return MyStruct_StructVal_DEFAULT - } - return p.StructVal -} -func (p *MyStruct) DefaultGetStructVal() *MyData { - if !p.IsSetStructVal() { - return NewMyData() - } - return p.StructVal -} -var MyStruct_UnionVal_DEFAULT *MyUnion -func (p *MyStruct) GetUnionVal() *MyUnion { - if !p.IsSetUnionVal() { - return MyStruct_UnionVal_DEFAULT - } - return p.UnionVal -} -func (p *MyStruct) DefaultGetUnionVal() *MyUnion { - if !p.IsSetUnionVal() { - return NewMyUnion() - } - return p.UnionVal -} -var MyStruct_LateStructVal_DEFAULT *LateDefStruct -func (p *MyStruct) GetLateStructVal() *LateDefStruct { - if !p.IsSetLateStructVal() { - return MyStruct_LateStructVal_DEFAULT - } - return p.LateStructVal -} -var MyStruct_OptBoolVal_DEFAULT bool -func (p *MyStruct) GetOptBoolVal() bool { - if !p.IsSetOptBoolVal() { - return MyStruct_OptBoolVal_DEFAULT - } - return *p.OptBoolVal -} -var MyStruct_OptByteVal_DEFAULT int8 -func (p *MyStruct) GetOptByteVal() int8 { - if !p.IsSetOptByteVal() { - return MyStruct_OptByteVal_DEFAULT - } - return *p.OptByteVal -} -var MyStruct_OptI16Val_DEFAULT int16 -func (p *MyStruct) GetOptI16Val() int16 { - if !p.IsSetOptI16Val() { - return MyStruct_OptI16Val_DEFAULT - } - return *p.OptI16Val -} -var MyStruct_OptI32Val_DEFAULT int32 -func (p *MyStruct) GetOptI32Val() int32 { - if !p.IsSetOptI32Val() { - return MyStruct_OptI32Val_DEFAULT - } - return *p.OptI32Val -} -var MyStruct_OptI64Val_DEFAULT int64 -func (p *MyStruct) GetOptI64Val() int64 { - if !p.IsSetOptI64Val() { - return MyStruct_OptI64Val_DEFAULT - } - return *p.OptI64Val -} -var MyStruct_OptFloatVal_DEFAULT float32 -func (p *MyStruct) GetOptFloatVal() float32 { - if !p.IsSetOptFloatVal() { - return MyStruct_OptFloatVal_DEFAULT - } - return *p.OptFloatVal -} -var MyStruct_OptDoubleVal_DEFAULT float64 -func (p *MyStruct) GetOptDoubleVal() float64 { - if !p.IsSetOptDoubleVal() { - return MyStruct_OptDoubleVal_DEFAULT - } - return *p.OptDoubleVal -} -var MyStruct_OptStringVal_DEFAULT string -func (p *MyStruct) GetOptStringVal() string { - if !p.IsSetOptStringVal() { - return MyStruct_OptStringVal_DEFAULT - } - return *p.OptStringVal -} -var MyStruct_OptBinaryVal_DEFAULT []byte - -func (p *MyStruct) GetOptBinaryVal() []byte { - return p.OptBinaryVal -} -var MyStruct_OptEnumVal_DEFAULT MyEnum -func (p *MyStruct) GetOptEnumVal() MyEnum { - if !p.IsSetOptEnumVal() { - return MyStruct_OptEnumVal_DEFAULT - } - return *p.OptEnumVal -} -var MyStruct_OptStructVal_DEFAULT *MyData -func (p *MyStruct) GetOptStructVal() *MyData { - if !p.IsSetOptStructVal() { - return MyStruct_OptStructVal_DEFAULT - } - return p.OptStructVal -} -func (p *MyStruct) DefaultGetOptStructVal() *MyData { - if !p.IsSetOptStructVal() { - return NewMyData() - } - return p.OptStructVal -} -var MyStruct_OptLateStructVal_DEFAULT *LateDefStruct -func (p *MyStruct) GetOptLateStructVal() *LateDefStruct { - if !p.IsSetOptLateStructVal() { - return MyStruct_OptLateStructVal_DEFAULT - } - return p.OptLateStructVal -} -var MyStruct_OptListVal_DEFAULT []int16 - -func (p *MyStruct) GetOptListVal() []int16 { - return p.OptListVal -} -var MyStruct_OptSetVal_DEFAULT []string - -func (p *MyStruct) GetOptSetVal() []string { - return p.OptSetVal -} -var MyStruct_OptMapVal_DEFAULT map[string]string - -func (p *MyStruct) GetOptMapVal() map[string]string { - return p.OptMapVal -} - -func (p *MyStruct) GetListMap() []map[string]int32 { - return p.ListMap -} - -func (p *MyStruct) GetMapMap() map[string]map[string]int32 { - return p.MapMap -} - -func (p *MyStruct) GetI32WithCustomDefault() int32 { - return p.I32WithCustomDefault -} -var MyStruct_StructWithCustomDefault_DEFAULT *MyDataWithCustomDefault -func (p *MyStruct) GetStructWithCustomDefault() *MyDataWithCustomDefault { - if !p.IsSetStructWithCustomDefault() { - return MyStruct_StructWithCustomDefault_DEFAULT - } - return p.StructWithCustomDefault -} -func (p *MyStruct) DefaultGetStructWithCustomDefault() *MyDataWithCustomDefault { - if !p.IsSetStructWithCustomDefault() { - return NewMyDataWithCustomDefault() - } - return p.StructWithCustomDefault -} -var MyStruct_StructWithFieldCustomDefault_DEFAULT *MyData = &MyData{ - Data1: "1", - Data2: 2, -} -func (p *MyStruct) GetStructWithFieldCustomDefault() *MyData { - if !p.IsSetStructWithFieldCustomDefault() { - return MyStruct_StructWithFieldCustomDefault_DEFAULT - } - return p.StructWithFieldCustomDefault -} -func (p *MyStruct) DefaultGetStructWithFieldCustomDefault() *MyData { - if !p.IsSetStructWithFieldCustomDefault() { - return NewMyData() - } - return p.StructWithFieldCustomDefault -} -func (p *MyStruct) IsSetStructVal() bool { - return p != nil && p.StructVal != nil -} - -func (p *MyStruct) IsSetUnionVal() bool { - return p != nil && p.UnionVal != nil -} - -func (p *MyStruct) IsSetLateStructVal() bool { - return p != nil && p.LateStructVal != nil -} - -func (p *MyStruct) IsSetOptBoolVal() bool { - return p != nil && p.OptBoolVal != nil -} - -func (p *MyStruct) IsSetOptByteVal() bool { - return p != nil && p.OptByteVal != nil -} - -func (p *MyStruct) IsSetOptI16Val() bool { - return p != nil && p.OptI16Val != nil -} - -func (p *MyStruct) IsSetOptI32Val() bool { - return p != nil && p.OptI32Val != nil -} - -func (p *MyStruct) IsSetOptI64Val() bool { - return p != nil && p.OptI64Val != nil -} - -func (p *MyStruct) IsSetOptFloatVal() bool { - return p != nil && p.OptFloatVal != nil -} - -func (p *MyStruct) IsSetOptDoubleVal() bool { - return p != nil && p.OptDoubleVal != nil -} - -func (p *MyStruct) IsSetOptStringVal() bool { - return p != nil && p.OptStringVal != nil -} - -func (p *MyStruct) IsSetOptBinaryVal() bool { - return p != nil && p.OptBinaryVal != nil -} - -func (p *MyStruct) IsSetOptEnumVal() bool { - return p != nil && p.OptEnumVal != nil -} - -func (p *MyStruct) IsSetOptStructVal() bool { - return p != nil && p.OptStructVal != nil -} - -func (p *MyStruct) IsSetOptLateStructVal() bool { - return p != nil && p.OptLateStructVal != nil -} - -func (p *MyStruct) IsSetOptListVal() bool { - return p != nil && p.OptListVal != nil -} - -func (p *MyStruct) IsSetOptSetVal() bool { - return p != nil && p.OptSetVal != nil -} - -func (p *MyStruct) IsSetOptMapVal() bool { - return p != nil && p.OptMapVal != nil -} - -func (p *MyStruct) IsSetStructWithCustomDefault() bool { - return p != nil && p.StructWithCustomDefault != nil -} - -func (p *MyStruct) IsSetStructWithFieldCustomDefault() bool { - return p != nil && p.StructWithFieldCustomDefault != nil -} - -type MyStructBuilder struct { - obj *MyStruct -} - -func NewMyStructBuilder() *MyStructBuilder{ - return &MyStructBuilder{ - obj: NewMyStruct(), - } -} - -func (p MyStructBuilder) Emit() *MyStruct{ - return &MyStruct{ - BoolVal: p.obj.BoolVal, - ByteVal: p.obj.ByteVal, - I16Val: p.obj.I16Val, - I32Val: p.obj.I32Val, - I64Val: p.obj.I64Val, - FloatVal: p.obj.FloatVal, - DoubleVal: p.obj.DoubleVal, - StringVal: p.obj.StringVal, - BinaryVal: p.obj.BinaryVal, - EnumVal: p.obj.EnumVal, - StructVal: p.obj.StructVal, - UnionVal: p.obj.UnionVal, - LateStructVal: p.obj.LateStructVal, - OptBoolVal: p.obj.OptBoolVal, - OptByteVal: p.obj.OptByteVal, - OptI16Val: p.obj.OptI16Val, - OptI32Val: p.obj.OptI32Val, - OptI64Val: p.obj.OptI64Val, - OptFloatVal: p.obj.OptFloatVal, - OptDoubleVal: p.obj.OptDoubleVal, - OptStringVal: p.obj.OptStringVal, - OptBinaryVal: p.obj.OptBinaryVal, - OptEnumVal: p.obj.OptEnumVal, - OptStructVal: p.obj.OptStructVal, - OptLateStructVal: p.obj.OptLateStructVal, - OptListVal: p.obj.OptListVal, - OptSetVal: p.obj.OptSetVal, - OptMapVal: p.obj.OptMapVal, - ListMap: p.obj.ListMap, - MapMap: p.obj.MapMap, - I32WithCustomDefault: p.obj.I32WithCustomDefault, - StructWithCustomDefault: p.obj.StructWithCustomDefault, - StructWithFieldCustomDefault: p.obj.StructWithFieldCustomDefault, - } -} - -func (m *MyStructBuilder) BoolVal(boolVal bool) *MyStructBuilder { - m.obj.BoolVal = boolVal - return m -} - -func (m *MyStructBuilder) ByteVal(byteVal int8) *MyStructBuilder { - m.obj.ByteVal = byteVal - return m -} - -func (m *MyStructBuilder) I16Val(i16Val int16) *MyStructBuilder { - m.obj.I16Val = i16Val - return m -} - -func (m *MyStructBuilder) I32Val(i32Val int32) *MyStructBuilder { - m.obj.I32Val = i32Val - return m -} - -func (m *MyStructBuilder) I64Val(i64Val int64) *MyStructBuilder { - m.obj.I64Val = i64Val - return m -} - -func (m *MyStructBuilder) FloatVal(floatVal float32) *MyStructBuilder { - m.obj.FloatVal = floatVal - return m -} - -func (m *MyStructBuilder) DoubleVal(doubleVal float64) *MyStructBuilder { - m.obj.DoubleVal = doubleVal - return m -} - -func (m *MyStructBuilder) StringVal(stringVal string) *MyStructBuilder { - m.obj.StringVal = stringVal - return m -} - -func (m *MyStructBuilder) BinaryVal(binaryVal []byte) *MyStructBuilder { - m.obj.BinaryVal = binaryVal - return m -} - -func (m *MyStructBuilder) EnumVal(enumVal MyEnum) *MyStructBuilder { - m.obj.EnumVal = enumVal - return m -} - -func (m *MyStructBuilder) StructVal(structVal *MyData) *MyStructBuilder { - m.obj.StructVal = structVal - return m -} - -func (m *MyStructBuilder) UnionVal(unionVal *MyUnion) *MyStructBuilder { - m.obj.UnionVal = unionVal - return m -} - -func (m *MyStructBuilder) LateStructVal(lateStructVal *LateDefStruct) *MyStructBuilder { - m.obj.LateStructVal = lateStructVal - return m -} - -func (m *MyStructBuilder) OptBoolVal(optBoolVal *bool) *MyStructBuilder { - m.obj.OptBoolVal = optBoolVal - return m -} - -func (m *MyStructBuilder) OptByteVal(optByteVal *int8) *MyStructBuilder { - m.obj.OptByteVal = optByteVal - return m -} - -func (m *MyStructBuilder) OptI16Val(optI16Val *int16) *MyStructBuilder { - m.obj.OptI16Val = optI16Val - return m -} - -func (m *MyStructBuilder) OptI32Val(optI32Val *int32) *MyStructBuilder { - m.obj.OptI32Val = optI32Val - return m -} - -func (m *MyStructBuilder) OptI64Val(optI64Val *int64) *MyStructBuilder { - m.obj.OptI64Val = optI64Val - return m -} - -func (m *MyStructBuilder) OptFloatVal(optFloatVal *float32) *MyStructBuilder { - m.obj.OptFloatVal = optFloatVal - return m -} - -func (m *MyStructBuilder) OptDoubleVal(optDoubleVal *float64) *MyStructBuilder { - m.obj.OptDoubleVal = optDoubleVal - return m -} - -func (m *MyStructBuilder) OptStringVal(optStringVal *string) *MyStructBuilder { - m.obj.OptStringVal = optStringVal - return m -} - -func (m *MyStructBuilder) OptBinaryVal(optBinaryVal []byte) *MyStructBuilder { - m.obj.OptBinaryVal = optBinaryVal - return m -} - -func (m *MyStructBuilder) OptEnumVal(optEnumVal *MyEnum) *MyStructBuilder { - m.obj.OptEnumVal = optEnumVal - return m -} - -func (m *MyStructBuilder) OptStructVal(optStructVal *MyData) *MyStructBuilder { - m.obj.OptStructVal = optStructVal - return m -} - -func (m *MyStructBuilder) OptLateStructVal(optLateStructVal *LateDefStruct) *MyStructBuilder { - m.obj.OptLateStructVal = optLateStructVal - return m -} - -func (m *MyStructBuilder) OptListVal(optListVal []int16) *MyStructBuilder { - m.obj.OptListVal = optListVal - return m -} - -func (m *MyStructBuilder) OptSetVal(optSetVal []string) *MyStructBuilder { - m.obj.OptSetVal = optSetVal - return m -} - -func (m *MyStructBuilder) OptMapVal(optMapVal map[string]string) *MyStructBuilder { - m.obj.OptMapVal = optMapVal - return m -} - -func (m *MyStructBuilder) ListMap(listMap []map[string]int32) *MyStructBuilder { - m.obj.ListMap = listMap - return m -} - -func (m *MyStructBuilder) MapMap(mapMap map[string]map[string]int32) *MyStructBuilder { - m.obj.MapMap = mapMap - return m -} - -func (m *MyStructBuilder) I32WithCustomDefault(i32WithCustomDefault int32) *MyStructBuilder { - m.obj.I32WithCustomDefault = i32WithCustomDefault - return m -} - -func (m *MyStructBuilder) StructWithCustomDefault(structWithCustomDefault *MyDataWithCustomDefault) *MyStructBuilder { - m.obj.StructWithCustomDefault = structWithCustomDefault - return m -} - -func (m *MyStructBuilder) StructWithFieldCustomDefault(structWithFieldCustomDefault *MyData) *MyStructBuilder { - m.obj.StructWithFieldCustomDefault = structWithFieldCustomDefault - return m -} - -func (m *MyStruct) SetBoolVal(boolVal bool) *MyStruct { - m.BoolVal = boolVal - return m -} - -func (m *MyStruct) SetByteVal(byteVal int8) *MyStruct { - m.ByteVal = byteVal - return m -} - -func (m *MyStruct) SetI16Val(i16Val int16) *MyStruct { - m.I16Val = i16Val - return m -} - -func (m *MyStruct) SetI32Val(i32Val int32) *MyStruct { - m.I32Val = i32Val - return m -} - -func (m *MyStruct) SetI64Val(i64Val int64) *MyStruct { - m.I64Val = i64Val - return m -} - -func (m *MyStruct) SetFloatVal(floatVal float32) *MyStruct { - m.FloatVal = floatVal - return m -} - -func (m *MyStruct) SetDoubleVal(doubleVal float64) *MyStruct { - m.DoubleVal = doubleVal - return m -} - -func (m *MyStruct) SetStringVal(stringVal string) *MyStruct { - m.StringVal = stringVal - return m -} - -func (m *MyStruct) SetBinaryVal(binaryVal []byte) *MyStruct { - m.BinaryVal = binaryVal - return m -} - -func (m *MyStruct) SetEnumVal(enumVal MyEnum) *MyStruct { - m.EnumVal = enumVal - return m -} - -func (m *MyStruct) SetStructVal(structVal *MyData) *MyStruct { - m.StructVal = structVal - return m -} - -func (m *MyStruct) SetUnionVal(unionVal *MyUnion) *MyStruct { - m.UnionVal = unionVal - return m -} - -func (m *MyStruct) SetLateStructVal(lateStructVal *LateDefStruct) *MyStruct { - m.LateStructVal = lateStructVal - return m -} - -func (m *MyStruct) SetOptBoolVal(optBoolVal *bool) *MyStruct { - m.OptBoolVal = optBoolVal - return m -} - -func (m *MyStruct) SetOptByteVal(optByteVal *int8) *MyStruct { - m.OptByteVal = optByteVal - return m -} - -func (m *MyStruct) SetOptI16Val(optI16Val *int16) *MyStruct { - m.OptI16Val = optI16Val - return m -} - -func (m *MyStruct) SetOptI32Val(optI32Val *int32) *MyStruct { - m.OptI32Val = optI32Val - return m -} - -func (m *MyStruct) SetOptI64Val(optI64Val *int64) *MyStruct { - m.OptI64Val = optI64Val - return m -} - -func (m *MyStruct) SetOptFloatVal(optFloatVal *float32) *MyStruct { - m.OptFloatVal = optFloatVal - return m -} - -func (m *MyStruct) SetOptDoubleVal(optDoubleVal *float64) *MyStruct { - m.OptDoubleVal = optDoubleVal - return m -} - -func (m *MyStruct) SetOptStringVal(optStringVal *string) *MyStruct { - m.OptStringVal = optStringVal - return m -} - -func (m *MyStruct) SetOptBinaryVal(optBinaryVal []byte) *MyStruct { - m.OptBinaryVal = optBinaryVal - return m -} - -func (m *MyStruct) SetOptEnumVal(optEnumVal *MyEnum) *MyStruct { - m.OptEnumVal = optEnumVal - return m -} - -func (m *MyStruct) SetOptStructVal(optStructVal *MyData) *MyStruct { - m.OptStructVal = optStructVal - return m -} - -func (m *MyStruct) SetOptLateStructVal(optLateStructVal *LateDefStruct) *MyStruct { - m.OptLateStructVal = optLateStructVal - return m -} - -func (m *MyStruct) SetOptListVal(optListVal []int16) *MyStruct { - m.OptListVal = optListVal - return m -} - -func (m *MyStruct) SetOptSetVal(optSetVal []string) *MyStruct { - m.OptSetVal = optSetVal - return m -} - -func (m *MyStruct) SetOptMapVal(optMapVal map[string]string) *MyStruct { - m.OptMapVal = optMapVal - return m -} - -func (m *MyStruct) SetListMap(listMap []map[string]int32) *MyStruct { - m.ListMap = listMap - return m -} - -func (m *MyStruct) SetMapMap(mapMap map[string]map[string]int32) *MyStruct { - m.MapMap = mapMap - return m -} - -func (m *MyStruct) SetI32WithCustomDefault(i32WithCustomDefault int32) *MyStruct { - m.I32WithCustomDefault = i32WithCustomDefault - return m -} - -func (m *MyStruct) SetStructWithCustomDefault(structWithCustomDefault *MyDataWithCustomDefault) *MyStruct { - m.StructWithCustomDefault = structWithCustomDefault - return m -} - -func (m *MyStruct) SetStructWithFieldCustomDefault(structWithFieldCustomDefault *MyData) *MyStruct { - m.StructWithFieldCustomDefault = structWithFieldCustomDefault - return m -} - -func (p *MyStruct) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case -1: - if err := p.ReadField_1(iprot); err != nil { - return err - } - case -2: - if err := p.ReadField_2(iprot); err != nil { - return err - } - case -3: - if err := p.ReadField_3(iprot); err != nil { - return err - } - case -4: - if err := p.ReadField_4(iprot); err != nil { - return err - } - case -5: - if err := p.ReadField_5(iprot); err != nil { - return err - } - case -6: - if err := p.ReadField_6(iprot); err != nil { - return err - } - case -7: - if err := p.ReadField_7(iprot); err != nil { - return err - } - case -8: - if err := p.ReadField_8(iprot); err != nil { - return err - } - case -9: - if err := p.ReadField_9(iprot); err != nil { - return err - } - case -10: - if err := p.ReadField_10(iprot); err != nil { - return err - } - case -11: - if err := p.ReadField_11(iprot); err != nil { - return err - } - case -12: - if err := p.ReadField_12(iprot); err != nil { - return err - } - case -13: - if err := p.ReadField_13(iprot); err != nil { - return err - } - case -14: - if err := p.ReadField_14(iprot); err != nil { - return err - } - case -15: - if err := p.ReadField_15(iprot); err != nil { - return err - } - case -16: - if err := p.ReadField_16(iprot); err != nil { - return err - } - case -17: - if err := p.ReadField_17(iprot); err != nil { - return err - } - case -18: - if err := p.ReadField_18(iprot); err != nil { - return err - } - case -19: - if err := p.ReadField_19(iprot); err != nil { - return err - } - case -20: - if err := p.ReadField_20(iprot); err != nil { - return err - } - case -21: - if err := p.ReadField_21(iprot); err != nil { - return err - } - case -22: - if err := p.ReadField_22(iprot); err != nil { - return err - } - case -23: - if err := p.ReadField_23(iprot); err != nil { - return err - } - case -24: - if err := p.ReadField_24(iprot); err != nil { - return err - } - case -25: - if err := p.ReadField_25(iprot); err != nil { - return err - } - case -26: - if err := p.ReadField_26(iprot); err != nil { - return err - } - case -27: - if err := p.ReadField_27(iprot); err != nil { - return err - } - case -28: - if err := p.ReadField_28(iprot); err != nil { - return err - } - case -29: - if err := p.ReadField_29(iprot); err != nil { - return err - } - case -30: - if err := p.ReadField_30(iprot); err != nil { - return err - } - case -31: - if err := p.ReadField_31(iprot); err != nil { - return err - } - case -32: - if err := p.ReadField_32(iprot); err != nil { - return err - } - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyStruct) ReadField_1(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field -1: ", err) - } else { - p.BoolVal = v - } - return nil -} - -func (p *MyStruct) ReadField_2(iprot thrift.Protocol) error { - if v, err := iprot.ReadByte(); err != nil { - return thrift.PrependError("error reading field -2: ", err) - } else { - temp := int8(v) - p.ByteVal = temp - } - return nil -} - -func (p *MyStruct) ReadField_3(iprot thrift.Protocol) error { - if v, err := iprot.ReadI16(); err != nil { - return thrift.PrependError("error reading field -3: ", err) - } else { - p.I16Val = v - } - return nil -} - -func (p *MyStruct) ReadField_4(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field -4: ", err) - } else { - p.I32Val = v - } - return nil -} - -func (p *MyStruct) ReadField_5(iprot thrift.Protocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field -5: ", err) - } else { - p.I64Val = v - } - return nil -} - -func (p *MyStruct) ReadField_6(iprot thrift.Protocol) error { - if v, err := iprot.ReadFloat(); err != nil { - return thrift.PrependError("error reading field -6: ", err) - } else { - p.FloatVal = v - } - return nil -} - -func (p *MyStruct) ReadField_7(iprot thrift.Protocol) error { - if v, err := iprot.ReadDouble(); err != nil { - return thrift.PrependError("error reading field -7: ", err) - } else { - p.DoubleVal = v - } - return nil -} - -func (p *MyStruct) ReadField_8(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field -8: ", err) - } else { - p.StringVal = v - } - return nil -} - -func (p *MyStruct) ReadField_9(iprot thrift.Protocol) error { - if v, err := iprot.ReadBinary(); err != nil { - return thrift.PrependError("error reading field -9: ", err) - } else { - p.BinaryVal = v - } - return nil -} - -func (p *MyStruct) ReadField_10(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field -10: ", err) - } else { - temp := MyEnum(v) - p.EnumVal = temp - } - return nil -} - -func (p *MyStruct) ReadField_11(iprot thrift.Protocol) error { - p.StructVal = NewMyData() - if err := p.StructVal.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.StructVal), err) - } - return nil -} - -func (p *MyStruct) ReadField_12(iprot thrift.Protocol) error { - p.UnionVal = NewMyUnion() - if err := p.UnionVal.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.UnionVal), err) - } - return nil -} - -func (p *MyStruct) ReadField_13(iprot thrift.Protocol) error { - p.LateStructVal = NewLateDefStruct() - if err := p.LateStructVal.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.LateStructVal), err) - } - return nil -} - -func (p *MyStruct) ReadField_14(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field -14: ", err) - } else { - p.OptBoolVal = &v - } - return nil -} - -func (p *MyStruct) ReadField_15(iprot thrift.Protocol) error { - if v, err := iprot.ReadByte(); err != nil { - return thrift.PrependError("error reading field -15: ", err) - } else { - temp := int8(v) - p.OptByteVal = &temp - } - return nil -} - -func (p *MyStruct) ReadField_16(iprot thrift.Protocol) error { - if v, err := iprot.ReadI16(); err != nil { - return thrift.PrependError("error reading field -16: ", err) - } else { - p.OptI16Val = &v - } - return nil -} - -func (p *MyStruct) ReadField_17(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field -17: ", err) - } else { - p.OptI32Val = &v - } - return nil -} - -func (p *MyStruct) ReadField_18(iprot thrift.Protocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field -18: ", err) - } else { - p.OptI64Val = &v - } - return nil -} - -func (p *MyStruct) ReadField_19(iprot thrift.Protocol) error { - if v, err := iprot.ReadFloat(); err != nil { - return thrift.PrependError("error reading field -19: ", err) - } else { - p.OptFloatVal = &v - } - return nil -} - -func (p *MyStruct) ReadField_20(iprot thrift.Protocol) error { - if v, err := iprot.ReadDouble(); err != nil { - return thrift.PrependError("error reading field -20: ", err) - } else { - p.OptDoubleVal = &v - } - return nil -} - -func (p *MyStruct) ReadField_21(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field -21: ", err) - } else { - p.OptStringVal = &v - } - return nil -} - -func (p *MyStruct) ReadField_22(iprot thrift.Protocol) error { - if v, err := iprot.ReadBinary(); err != nil { - return thrift.PrependError("error reading field -22: ", err) - } else { - p.OptBinaryVal = v - } - return nil -} - -func (p *MyStruct) ReadField_23(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field -23: ", err) - } else { - temp := MyEnum(v) - p.OptEnumVal = &temp - } - return nil -} - -func (p *MyStruct) ReadField_24(iprot thrift.Protocol) error { - p.OptStructVal = NewMyData() - if err := p.OptStructVal.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.OptStructVal), err) - } - return nil -} - -func (p *MyStruct) ReadField_25(iprot thrift.Protocol) error { - p.OptLateStructVal = NewLateDefStruct() - if err := p.OptLateStructVal.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.OptLateStructVal), err) - } - return nil -} - -func (p *MyStruct) ReadField_26(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]int16, 0, size) - p.OptListVal = tSlice - for i := 0; i < size; i ++ { - var _elem2 int16 - if v, err := iprot.ReadI16(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem2 = v - } - p.OptListVal = append(p.OptListVal, _elem2) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *MyStruct) ReadField_27(iprot thrift.Protocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return thrift.PrependError("error reading set begin: ", err) - } - tSet := make([]string, 0, size) - p.OptSetVal = tSet - for i := 0; i < size; i ++ { - var _elem3 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem3 = v - } - p.OptSetVal = append(p.OptSetVal, _elem3) - } - if err := iprot.ReadSetEnd(); err != nil { - return thrift.PrependError("error reading set end: ", err) - } - return nil -} - -func (p *MyStruct) ReadField_28(iprot thrift.Protocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[string]string, size) - p.OptMapVal = tMap - for i := 0; i < size; i ++ { - var _key4 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key4 = v - } - var _val5 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _val5 = v - } - p.OptMapVal[_key4] = _val5 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *MyStruct) ReadField_29(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]map[string]int32, 0, size) - p.ListMap = tSlice - for i := 0; i < size; i ++ { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[string]int32, size) - _elem6 := tMap - for i := 0; i < size; i ++ { - var _key7 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key7 = v - } - var _val8 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _val8 = v - } - _elem6[_key7] = _val8 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - p.ListMap = append(p.ListMap, _elem6) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *MyStruct) ReadField_30(iprot thrift.Protocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[string]map[string]int32, size) - p.MapMap = tMap - for i := 0; i < size; i ++ { - var _key9 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key9 = v - } - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[string]int32, size) - _val10 := tMap - for i := 0; i < size; i ++ { - var _key11 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key11 = v - } - var _val12 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _val12 = v - } - _val10[_key11] = _val12 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - p.MapMap[_key9] = _val10 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *MyStruct) ReadField_31(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field -31: ", err) - } else { - p.I32WithCustomDefault = v - } - return nil -} - -func (p *MyStruct) ReadField_32(iprot thrift.Protocol) error { - p.StructWithCustomDefault = NewMyDataWithCustomDefault() - if err := p.StructWithCustomDefault.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.StructWithCustomDefault), err) - } - return nil -} - -func (p *MyStruct) ReadField1(iprot thrift.Protocol) error { - p.StructWithFieldCustomDefault = NewMyData() - if err := p.StructWithFieldCustomDefault.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.StructWithFieldCustomDefault), err) - } - return nil -} - -func (p *MyStruct) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("MyStruct"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField_32(oprot); err != nil { return err } - if err := p.writeField_31(oprot); err != nil { return err } - if err := p.writeField_30(oprot); err != nil { return err } - if err := p.writeField_29(oprot); err != nil { return err } - if err := p.writeField_28(oprot); err != nil { return err } - if err := p.writeField_27(oprot); err != nil { return err } - if err := p.writeField_26(oprot); err != nil { return err } - if err := p.writeField_25(oprot); err != nil { return err } - if err := p.writeField_24(oprot); err != nil { return err } - if err := p.writeField_23(oprot); err != nil { return err } - if err := p.writeField_22(oprot); err != nil { return err } - if err := p.writeField_21(oprot); err != nil { return err } - if err := p.writeField_20(oprot); err != nil { return err } - if err := p.writeField_19(oprot); err != nil { return err } - if err := p.writeField_18(oprot); err != nil { return err } - if err := p.writeField_17(oprot); err != nil { return err } - if err := p.writeField_16(oprot); err != nil { return err } - if err := p.writeField_15(oprot); err != nil { return err } - if err := p.writeField_14(oprot); err != nil { return err } - if err := p.writeField_13(oprot); err != nil { return err } - if err := p.writeField_12(oprot); err != nil { return err } - if err := p.writeField_11(oprot); err != nil { return err } - if err := p.writeField_10(oprot); err != nil { return err } - if err := p.writeField_9(oprot); err != nil { return err } - if err := p.writeField_8(oprot); err != nil { return err } - if err := p.writeField_7(oprot); err != nil { return err } - if err := p.writeField_6(oprot); err != nil { return err } - if err := p.writeField_5(oprot); err != nil { return err } - if err := p.writeField_4(oprot); err != nil { return err } - if err := p.writeField_3(oprot); err != nil { return err } - if err := p.writeField_2(oprot); err != nil { return err } - if err := p.writeField_1(oprot); err != nil { return err } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyStruct) writeField_32(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("structWithCustomDefault", thrift.STRUCT, -32); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -32:structWithCustomDefault: ", p), err) } - if err := p.StructWithCustomDefault.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.StructWithCustomDefault), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -32:structWithCustomDefault: ", p), err) } - return err -} - -func (p *MyStruct) writeField_31(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("i32WithCustomDefault", thrift.I32, -31); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -31:i32WithCustomDefault: ", p), err) } - if err := oprot.WriteI32(int32(p.I32WithCustomDefault)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.i32WithCustomDefault (-31) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -31:i32WithCustomDefault: ", p), err) } - return err -} - -func (p *MyStruct) writeField_30(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("mapMap", thrift.MAP, -30); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -30:mapMap: ", p), err) } - if err := oprot.WriteMapBegin(thrift.STRING, thrift.MAP, len(p.MapMap)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.MapMap { - if err := oprot.WriteString(string(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := oprot.WriteMapBegin(thrift.STRING, thrift.I32, len(v)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range v { - if err := oprot.WriteString(string(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := oprot.WriteI32(int32(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -30:mapMap: ", p), err) } - return err -} - -func (p *MyStruct) writeField_29(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("listMap", thrift.LIST, -29); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -29:listMap: ", p), err) } - if err := oprot.WriteListBegin(thrift.MAP, len(p.ListMap)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.ListMap { - if err := oprot.WriteMapBegin(thrift.STRING, thrift.I32, len(v)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range v { - if err := oprot.WriteString(string(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := oprot.WriteI32(int32(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -29:listMap: ", p), err) } - return err -} - -func (p *MyStruct) writeField_28(oprot thrift.Protocol) (err error) { - if p.IsSetOptMapVal() { - if err := oprot.WriteFieldBegin("optMapVal", thrift.MAP, -28); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -28:optMapVal: ", p), err) } - if err := oprot.WriteMapBegin(thrift.STRING, thrift.STRING, len(p.OptMapVal)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.OptMapVal { - if err := oprot.WriteString(string(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := oprot.WriteString(string(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -28:optMapVal: ", p), err) } - } - return err -} - -func (p *MyStruct) writeField_27(oprot thrift.Protocol) (err error) { - if p.IsSetOptSetVal() { - if err := oprot.WriteFieldBegin("optSetVal", thrift.SET, -27); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -27:optSetVal: ", p), err) } - if err := oprot.WriteSetBegin(thrift.STRING, len(p.OptSetVal)); err != nil { - return thrift.PrependError("error writing set begin: ", err) - } - set := make(map[string]bool, len(p.OptSetVal)) - for _, v := range p.OptSetVal { - if ok := set[v]; ok { - return thrift.PrependError("", fmt.Errorf("%T error writing set field: slice is not unique", v)) - } - set[v] = true - } - for _, v := range p.OptSetVal { - if err := oprot.WriteString(string(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteSetEnd(); err != nil { - return thrift.PrependError("error writing set end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -27:optSetVal: ", p), err) } - } - return err -} - -func (p *MyStruct) writeField_26(oprot thrift.Protocol) (err error) { - if p.IsSetOptListVal() { - if err := oprot.WriteFieldBegin("optListVal", thrift.LIST, -26); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -26:optListVal: ", p), err) } - if err := oprot.WriteListBegin(thrift.I16, len(p.OptListVal)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.OptListVal { - if err := oprot.WriteI16(int16(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -26:optListVal: ", p), err) } - } - return err -} - -func (p *MyStruct) writeField_25(oprot thrift.Protocol) (err error) { - if p.IsSetOptLateStructVal() { - if err := oprot.WriteFieldBegin("optLateStructVal", thrift.STRUCT, -25); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -25:optLateStructVal: ", p), err) } - if err := p.OptLateStructVal.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.OptLateStructVal), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -25:optLateStructVal: ", p), err) } - } - return err -} - -func (p *MyStruct) writeField_24(oprot thrift.Protocol) (err error) { - if p.IsSetOptStructVal() { - if err := oprot.WriteFieldBegin("optStructVal", thrift.STRUCT, -24); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -24:optStructVal: ", p), err) } - if err := p.OptStructVal.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.OptStructVal), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -24:optStructVal: ", p), err) } - } - return err -} - -func (p *MyStruct) writeField_23(oprot thrift.Protocol) (err error) { - if p.IsSetOptEnumVal() { - if err := oprot.WriteFieldBegin("optEnumVal", thrift.I32, -23); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -23:optEnumVal: ", p), err) } - if err := oprot.WriteI32(int32(*p.OptEnumVal)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.optEnumVal (-23) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -23:optEnumVal: ", p), err) } - } - return err -} - -func (p *MyStruct) writeField_22(oprot thrift.Protocol) (err error) { - if p.IsSetOptBinaryVal() { - if err := oprot.WriteFieldBegin("optBinaryVal", thrift.STRING, -22); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -22:optBinaryVal: ", p), err) } - if err := oprot.WriteBinary(p.OptBinaryVal); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.optBinaryVal (-22) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -22:optBinaryVal: ", p), err) } - } - return err -} - -func (p *MyStruct) writeField_21(oprot thrift.Protocol) (err error) { - if p.IsSetOptStringVal() { - if err := oprot.WriteFieldBegin("optStringVal", thrift.STRING, -21); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -21:optStringVal: ", p), err) } - if err := oprot.WriteString(string(*p.OptStringVal)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.optStringVal (-21) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -21:optStringVal: ", p), err) } - } - return err -} - -func (p *MyStruct) writeField_20(oprot thrift.Protocol) (err error) { - if p.IsSetOptDoubleVal() { - if err := oprot.WriteFieldBegin("optDoubleVal", thrift.DOUBLE, -20); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -20:optDoubleVal: ", p), err) } - if err := oprot.WriteDouble(float64(*p.OptDoubleVal)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.optDoubleVal (-20) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -20:optDoubleVal: ", p), err) } - } - return err -} - -func (p *MyStruct) writeField_19(oprot thrift.Protocol) (err error) { - if p.IsSetOptFloatVal() { - if err := oprot.WriteFieldBegin("optFloatVal", thrift.FLOAT, -19); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -19:optFloatVal: ", p), err) } - if err := oprot.WriteFloat(float32(*p.OptFloatVal)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.optFloatVal (-19) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -19:optFloatVal: ", p), err) } - } - return err -} - -func (p *MyStruct) writeField_18(oprot thrift.Protocol) (err error) { - if p.IsSetOptI64Val() { - if err := oprot.WriteFieldBegin("optI64Val", thrift.I64, -18); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -18:optI64Val: ", p), err) } - if err := oprot.WriteI64(int64(*p.OptI64Val)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.optI64Val (-18) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -18:optI64Val: ", p), err) } - } - return err -} - -func (p *MyStruct) writeField_17(oprot thrift.Protocol) (err error) { - if p.IsSetOptI32Val() { - if err := oprot.WriteFieldBegin("optI32Val", thrift.I32, -17); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -17:optI32Val: ", p), err) } - if err := oprot.WriteI32(int32(*p.OptI32Val)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.optI32Val (-17) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -17:optI32Val: ", p), err) } - } - return err -} - -func (p *MyStruct) writeField_16(oprot thrift.Protocol) (err error) { - if p.IsSetOptI16Val() { - if err := oprot.WriteFieldBegin("optI16Val", thrift.I16, -16); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -16:optI16Val: ", p), err) } - if err := oprot.WriteI16(int16(*p.OptI16Val)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.optI16Val (-16) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -16:optI16Val: ", p), err) } - } - return err -} - -func (p *MyStruct) writeField_15(oprot thrift.Protocol) (err error) { - if p.IsSetOptByteVal() { - if err := oprot.WriteFieldBegin("optByteVal", thrift.BYTE, -15); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -15:optByteVal: ", p), err) } - if err := oprot.WriteByte(byte(*p.OptByteVal)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.optByteVal (-15) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -15:optByteVal: ", p), err) } - } - return err -} - -func (p *MyStruct) writeField_14(oprot thrift.Protocol) (err error) { - if p.IsSetOptBoolVal() { - if err := oprot.WriteFieldBegin("optBoolVal", thrift.BOOL, -14); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -14:optBoolVal: ", p), err) } - if err := oprot.WriteBool(bool(*p.OptBoolVal)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.optBoolVal (-14) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -14:optBoolVal: ", p), err) } - } - return err -} - -func (p *MyStruct) writeField_13(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("lateStructVal", thrift.STRUCT, -13); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -13:lateStructVal: ", p), err) } - if err := p.LateStructVal.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.LateStructVal), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -13:lateStructVal: ", p), err) } - return err -} - -func (p *MyStruct) writeField_12(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("unionVal", thrift.STRUCT, -12); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -12:unionVal: ", p), err) } - if err := p.UnionVal.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.UnionVal), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -12:unionVal: ", p), err) } - return err -} - -func (p *MyStruct) writeField_11(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("structVal", thrift.STRUCT, -11); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -11:structVal: ", p), err) } - if err := p.StructVal.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.StructVal), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -11:structVal: ", p), err) } - return err -} - -func (p *MyStruct) writeField_10(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("enumVal", thrift.I32, -10); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -10:enumVal: ", p), err) } - if err := oprot.WriteI32(int32(p.EnumVal)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.enumVal (-10) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -10:enumVal: ", p), err) } - return err -} - -func (p *MyStruct) writeField_9(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("binaryVal", thrift.STRING, -9); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -9:binaryVal: ", p), err) } - if err := oprot.WriteBinary(p.BinaryVal); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.binaryVal (-9) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -9:binaryVal: ", p), err) } - return err -} - -func (p *MyStruct) writeField_8(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("stringVal", thrift.STRING, -8); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -8:stringVal: ", p), err) } - if err := oprot.WriteString(string(p.StringVal)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.stringVal (-8) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -8:stringVal: ", p), err) } - return err -} - -func (p *MyStruct) writeField_7(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("doubleVal", thrift.DOUBLE, -7); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -7:doubleVal: ", p), err) } - if err := oprot.WriteDouble(float64(p.DoubleVal)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.doubleVal (-7) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -7:doubleVal: ", p), err) } - return err -} - -func (p *MyStruct) writeField_6(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("floatVal", thrift.FLOAT, -6); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -6:floatVal: ", p), err) } - if err := oprot.WriteFloat(float32(p.FloatVal)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.floatVal (-6) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -6:floatVal: ", p), err) } - return err -} - -func (p *MyStruct) writeField_5(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("i64Val", thrift.I64, -5); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -5:i64Val: ", p), err) } - if err := oprot.WriteI64(int64(p.I64Val)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.i64Val (-5) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -5:i64Val: ", p), err) } - return err -} - -func (p *MyStruct) writeField_4(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("i32Val", thrift.I32, -4); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -4:i32Val: ", p), err) } - if err := oprot.WriteI32(int32(p.I32Val)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.i32Val (-4) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -4:i32Val: ", p), err) } - return err -} - -func (p *MyStruct) writeField_3(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("i16Val", thrift.I16, -3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -3:i16Val: ", p), err) } - if err := oprot.WriteI16(int16(p.I16Val)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.i16Val (-3) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -3:i16Val: ", p), err) } - return err -} - -func (p *MyStruct) writeField_2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("byteVal", thrift.BYTE, -2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -2:byteVal: ", p), err) } - if err := oprot.WriteByte(byte(p.ByteVal)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.byteVal (-2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -2:byteVal: ", p), err) } - return err -} - -func (p *MyStruct) writeField_1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("boolVal", thrift.BOOL, -1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -1:boolVal: ", p), err) } - if err := oprot.WriteBool(bool(p.BoolVal)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.boolVal (-1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -1:boolVal: ", p), err) } - return err -} - -func (p *MyStruct) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("structWithFieldCustomDefault", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:structWithFieldCustomDefault: ", p), err) } - if err := p.StructWithFieldCustomDefault.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.StructWithFieldCustomDefault), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:structWithFieldCustomDefault: ", p), err) } - return err -} - -func (p *MyStruct) String() string { - if p == nil { - return "" - } - - var structWithCustomDefaultVal string - if p.StructWithCustomDefault == nil { - structWithCustomDefaultVal = "" - } else { - structWithCustomDefaultVal = fmt.Sprintf("%v", p.StructWithCustomDefault) - } - i32WithCustomDefaultVal := fmt.Sprintf("%v", p.I32WithCustomDefault) - mapMapVal := fmt.Sprintf("%v", p.MapMap) - listMapVal := fmt.Sprintf("%v", p.ListMap) - optMapValVal := fmt.Sprintf("%v", p.OptMapVal) - optSetValVal := fmt.Sprintf("%v", p.OptSetVal) - optListValVal := fmt.Sprintf("%v", p.OptListVal) - var optLateStructValVal string - if p.OptLateStructVal == nil { - optLateStructValVal = "" - } else { - optLateStructValVal = fmt.Sprintf("%v", p.OptLateStructVal) - } - var optStructValVal string - if p.OptStructVal == nil { - optStructValVal = "" - } else { - optStructValVal = fmt.Sprintf("%v", p.OptStructVal) - } - var optEnumValVal string - if p.OptEnumVal == nil { - optEnumValVal = "" - } else { - optEnumValVal = fmt.Sprintf("%v", *p.OptEnumVal) - } - optBinaryValVal := fmt.Sprintf("%v", p.OptBinaryVal) - var optStringValVal string - if p.OptStringVal == nil { - optStringValVal = "" - } else { - optStringValVal = fmt.Sprintf("%v", *p.OptStringVal) - } - var optDoubleValVal string - if p.OptDoubleVal == nil { - optDoubleValVal = "" - } else { - optDoubleValVal = fmt.Sprintf("%v", *p.OptDoubleVal) - } - var optFloatValVal string - if p.OptFloatVal == nil { - optFloatValVal = "" - } else { - optFloatValVal = fmt.Sprintf("%v", *p.OptFloatVal) - } - var optI64ValVal string - if p.OptI64Val == nil { - optI64ValVal = "" - } else { - optI64ValVal = fmt.Sprintf("%v", *p.OptI64Val) - } - var optI32ValVal string - if p.OptI32Val == nil { - optI32ValVal = "" - } else { - optI32ValVal = fmt.Sprintf("%v", *p.OptI32Val) - } - var optI16ValVal string - if p.OptI16Val == nil { - optI16ValVal = "" - } else { - optI16ValVal = fmt.Sprintf("%v", *p.OptI16Val) - } - var optByteValVal string - if p.OptByteVal == nil { - optByteValVal = "" - } else { - optByteValVal = fmt.Sprintf("%v", *p.OptByteVal) - } - var optBoolValVal string - if p.OptBoolVal == nil { - optBoolValVal = "" - } else { - optBoolValVal = fmt.Sprintf("%v", *p.OptBoolVal) - } - var lateStructValVal string - if p.LateStructVal == nil { - lateStructValVal = "" - } else { - lateStructValVal = fmt.Sprintf("%v", p.LateStructVal) - } - var unionValVal string - if p.UnionVal == nil { - unionValVal = "" - } else { - unionValVal = fmt.Sprintf("%v", p.UnionVal) - } - var structValVal string - if p.StructVal == nil { - structValVal = "" - } else { - structValVal = fmt.Sprintf("%v", p.StructVal) - } - enumValVal := fmt.Sprintf("%v", p.EnumVal) - binaryValVal := fmt.Sprintf("%v", p.BinaryVal) - stringValVal := fmt.Sprintf("%v", p.StringVal) - doubleValVal := fmt.Sprintf("%v", p.DoubleVal) - floatValVal := fmt.Sprintf("%v", p.FloatVal) - i64ValVal := fmt.Sprintf("%v", p.I64Val) - i32ValVal := fmt.Sprintf("%v", p.I32Val) - i16ValVal := fmt.Sprintf("%v", p.I16Val) - byteValVal := fmt.Sprintf("%v", p.ByteVal) - boolValVal := fmt.Sprintf("%v", p.BoolVal) - var structWithFieldCustomDefaultVal string - if p.StructWithFieldCustomDefault == nil { - structWithFieldCustomDefaultVal = "" - } else { - structWithFieldCustomDefaultVal = fmt.Sprintf("%v", p.StructWithFieldCustomDefault) - } - return fmt.Sprintf("MyStruct({StructWithCustomDefault:%s I32WithCustomDefault:%s MapMap:%s ListMap:%s OptMapVal:%s OptSetVal:%s OptListVal:%s OptLateStructVal:%s OptStructVal:%s OptEnumVal:%s OptBinaryVal:%s OptStringVal:%s OptDoubleVal:%s OptFloatVal:%s OptI64Val:%s OptI32Val:%s OptI16Val:%s OptByteVal:%s OptBoolVal:%s LateStructVal:%s UnionVal:%s StructVal:%s EnumVal:%s BinaryVal:%s StringVal:%s DoubleVal:%s FloatVal:%s I64Val:%s I32Val:%s I16Val:%s ByteVal:%s BoolVal:%s StructWithFieldCustomDefault:%s})", structWithCustomDefaultVal, i32WithCustomDefaultVal, mapMapVal, listMapVal, optMapValVal, optSetValVal, optListValVal, optLateStructValVal, optStructValVal, optEnumValVal, optBinaryValVal, optStringValVal, optDoubleValVal, optFloatValVal, optI64ValVal, optI32ValVal, optI16ValVal, optByteValVal, optBoolValVal, lateStructValVal, unionValVal, structValVal, enumValVal, binaryValVal, stringValVal, doubleValVal, floatValVal, i64ValVal, i32ValVal, i16ValVal, byteValVal, boolValVal, structWithFieldCustomDefaultVal) -} - -type LateDefStruct struct { -} - -func NewLateDefStruct() *LateDefStruct { - return &LateDefStruct{} -} - -type LateDefStructBuilder struct { - obj *LateDefStruct -} - -func NewLateDefStructBuilder() *LateDefStructBuilder{ - return &LateDefStructBuilder{ - obj: NewLateDefStruct(), - } -} - -func (p LateDefStructBuilder) Emit() *LateDefStruct{ - return &LateDefStruct{ - } -} - -func (p *LateDefStruct) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *LateDefStruct) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("LateDefStruct"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *LateDefStruct) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("LateDefStruct({})") -} - -// Attributes: -// - Nodes -type Recursive struct { - Nodes map[string]*Recursive -} - -func NewRecursive() *Recursive { - return &Recursive{} -} - - -func (p *Recursive) GetNodes() map[string]*Recursive { - return p.Nodes -} -type RecursiveBuilder struct { - obj *Recursive -} - -func NewRecursiveBuilder() *RecursiveBuilder{ - return &RecursiveBuilder{ - obj: NewRecursive(), - } -} - -func (p RecursiveBuilder) Emit() *Recursive{ - return &Recursive{ - Nodes: p.obj.Nodes, - } -} - -func (r *RecursiveBuilder) Nodes(nodes map[string]*Recursive) *RecursiveBuilder { - r.obj.Nodes = nodes - return r -} - -func (r *Recursive) SetNodes(nodes map[string]*Recursive) *Recursive { - r.Nodes = nodes - return r -} - -func (p *Recursive) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case -1: - if err := p.ReadField_1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Recursive) ReadField_1(iprot thrift.Protocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[string]*Recursive, size) - p.Nodes = tMap - for i := 0; i < size; i ++ { - var _key13 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key13 = v - } - _val14 := NewRecursive() - if err := _val14.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _val14), err) - } - p.Nodes[_key13] = _val14 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *Recursive) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Recursive"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField_1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Recursive) writeField_1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("nodes", thrift.MAP, -1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -1:nodes: ", p), err) } - if err := oprot.WriteMapBegin(thrift.STRING, thrift.STRUCT, len(p.Nodes)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.Nodes { - if err := oprot.WriteString(string(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := v.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) - } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -1:nodes: ", p), err) } - return err -} - -func (p *Recursive) String() string { - if p == nil { - return "" - } - - nodesVal := fmt.Sprintf("%v", p.Nodes) - return fmt.Sprintf("Recursive({Nodes:%s})", nodesVal) -} - -// Attributes: -// - Loop -type Bar struct { - Loop *Loop -} - -func NewBar() *Bar { - return &Bar{ - Loop: NewLoop(), - } -} - -var Bar_Loop_DEFAULT *Loop -func (p *Bar) GetLoop() *Loop { - if !p.IsSetLoop() { - return Bar_Loop_DEFAULT - } - return p.Loop -} -func (p *Bar) IsSetLoop() bool { - return p != nil && p.Loop != nil -} - -type BarBuilder struct { - obj *Bar -} - -func NewBarBuilder() *BarBuilder{ - return &BarBuilder{ - obj: NewBar(), - } -} - -func (p BarBuilder) Emit() *Bar{ - return &Bar{ - Loop: p.obj.Loop, - } -} - -func (b *BarBuilder) Loop(loop *Loop) *BarBuilder { - b.obj.Loop = loop - return b -} - -func (b *Bar) SetLoop(loop *Loop) *Bar { - b.Loop = loop - return b -} - -func (p *Bar) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case -1: - if err := p.ReadField_1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Bar) ReadField_1(iprot thrift.Protocol) error { - p.Loop = NewLoop() - if err := p.Loop.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Loop), err) - } - return nil -} - -func (p *Bar) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Bar"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField_1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Bar) writeField_1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("loop", thrift.STRUCT, -1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -1:loop: ", p), err) } - if err := p.Loop.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Loop), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -1:loop: ", p), err) } - return err -} - -func (p *Bar) String() string { - if p == nil { - return "" - } - - var loopVal string - if p.Loop == nil { - loopVal = "" - } else { - loopVal = fmt.Sprintf("%v", p.Loop) - } - return fmt.Sprintf("Bar({Loop:%s})", loopVal) -} - -// Attributes: -// - Bar -type Loop struct { - Bar *Bar -} - -func NewLoop() *Loop { - return &Loop{ - Bar: NewBar(), - } -} - -var Loop_Bar_DEFAULT *Bar -func (p *Loop) GetBar() *Bar { - if !p.IsSetBar() { - return Loop_Bar_DEFAULT - } - return p.Bar -} -func (p *Loop) DefaultGetBar() *Bar { - if !p.IsSetBar() { - return NewBar() - } - return p.Bar -} -func (p *Loop) IsSetBar() bool { - return p != nil && p.Bar != nil -} - -type LoopBuilder struct { - obj *Loop -} - -func NewLoopBuilder() *LoopBuilder{ - return &LoopBuilder{ - obj: NewLoop(), - } -} - -func (p LoopBuilder) Emit() *Loop{ - return &Loop{ - Bar: p.obj.Bar, - } -} - -func (l *LoopBuilder) Bar(bar *Bar) *LoopBuilder { - l.obj.Bar = bar - return l -} - -func (l *Loop) SetBar(bar *Bar) *Loop { - l.Bar = bar - return l -} - -func (p *Loop) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case -1: - if err := p.ReadField_1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Loop) ReadField_1(iprot thrift.Protocol) error { - p.Bar = NewBar() - if err := p.Bar.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Bar), err) - } - return nil -} - -func (p *Loop) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Loop"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField_1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Loop) writeField_1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("bar", thrift.STRUCT, -1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -1:bar: ", p), err) } - if err := p.Bar.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Bar), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -1:bar: ", p), err) } - return err -} - -func (p *Loop) String() string { - if p == nil { - return "" - } - - var barVal string - if p.Bar == nil { - barVal = "" - } else { - barVal = fmt.Sprintf("%v", p.Bar) - } - return fmt.Sprintf("Loop({Bar:%s})", barVal) -} - -// Attributes: -// - Assign: Assigns to a (set) value. -// -// If set, all other operations are ignored. -// -// Note: Optional and union fields must be set before assigned. -// -// - Clear: Clears a value. Applies first. -// - PatchPrior: Patches any previously set values. Applies second. -// - Ensure: Initialize fields, using the given defaults. Applies third. -// - Patch: Patches any set value, including newly set values. Applies last. -// - Remove: Removes entries, if present. Applies third. -type MyDataPatch struct { - Assign *MyData `thrift:"assign,1,optional" db:"assign" json:"assign,omitempty"` - Clear bool `thrift:"clear,2" db:"clear" json:"clear"` - PatchPrior *MyDataFieldPatch `thrift:"patchPrior,3" db:"patchPrior" json:"patchPrior"` - // unused field # 4 - Ensure *MyDataEnsureStruct `thrift:"ensure,5" db:"ensure" json:"ensure"` - Patch *MyDataFieldPatch `thrift:"patch,6" db:"patch" json:"patch"` - Remove patch0.FieldIdList `thrift:"remove,7" db:"remove" json:"remove"` -} - -func NewMyDataPatch() *MyDataPatch { - return &MyDataPatch{ - PatchPrior: NewMyDataFieldPatch(), - Ensure: NewMyDataEnsureStruct(), - Patch: NewMyDataFieldPatch(), - } -} - -var MyDataPatch_Assign_DEFAULT *MyData -func (p *MyDataPatch) GetAssign() *MyData { - if !p.IsSetAssign() { - return MyDataPatch_Assign_DEFAULT - } - return p.Assign -} -func (p *MyDataPatch) DefaultGetAssign() *MyData { - if !p.IsSetAssign() { - return NewMyData() - } - return p.Assign -} - -func (p *MyDataPatch) GetClear() bool { - return p.Clear -} -var MyDataPatch_PatchPrior_DEFAULT *MyDataFieldPatch -func (p *MyDataPatch) GetPatchPrior() *MyDataFieldPatch { - if !p.IsSetPatchPrior() { - return MyDataPatch_PatchPrior_DEFAULT - } - return p.PatchPrior -} -func (p *MyDataPatch) DefaultGetPatchPrior() *MyDataFieldPatch { - if !p.IsSetPatchPrior() { - return NewMyDataFieldPatch() - } - return p.PatchPrior -} -var MyDataPatch_Ensure_DEFAULT *MyDataEnsureStruct -func (p *MyDataPatch) GetEnsure() *MyDataEnsureStruct { - if !p.IsSetEnsure() { - return MyDataPatch_Ensure_DEFAULT - } - return p.Ensure -} -func (p *MyDataPatch) DefaultGetEnsure() *MyDataEnsureStruct { - if !p.IsSetEnsure() { - return NewMyDataEnsureStruct() - } - return p.Ensure -} -var MyDataPatch_Patch_DEFAULT *MyDataFieldPatch -func (p *MyDataPatch) GetPatch() *MyDataFieldPatch { - if !p.IsSetPatch() { - return MyDataPatch_Patch_DEFAULT - } - return p.Patch -} -func (p *MyDataPatch) DefaultGetPatch() *MyDataFieldPatch { - if !p.IsSetPatch() { - return NewMyDataFieldPatch() - } - return p.Patch -} - -func (p *MyDataPatch) GetRemove() patch0.FieldIdList { - return p.Remove -} -func (p *MyDataPatch) IsSetAssign() bool { - return p != nil && p.Assign != nil -} - -func (p *MyDataPatch) IsSetPatchPrior() bool { - return p != nil && p.PatchPrior != nil -} - -func (p *MyDataPatch) IsSetEnsure() bool { - return p != nil && p.Ensure != nil -} - -func (p *MyDataPatch) IsSetPatch() bool { - return p != nil && p.Patch != nil -} - -type MyDataPatchBuilder struct { - obj *MyDataPatch -} - -func NewMyDataPatchBuilder() *MyDataPatchBuilder{ - return &MyDataPatchBuilder{ - obj: NewMyDataPatch(), - } -} - -func (p MyDataPatchBuilder) Emit() *MyDataPatch{ - return &MyDataPatch{ - Assign: p.obj.Assign, - Clear: p.obj.Clear, - PatchPrior: p.obj.PatchPrior, - Ensure: p.obj.Ensure, - Patch: p.obj.Patch, - Remove: p.obj.Remove, - } -} - -func (m *MyDataPatchBuilder) Assign(assign *MyData) *MyDataPatchBuilder { - m.obj.Assign = assign - return m -} - -func (m *MyDataPatchBuilder) Clear(clear bool) *MyDataPatchBuilder { - m.obj.Clear = clear - return m -} - -func (m *MyDataPatchBuilder) PatchPrior(patchPrior *MyDataFieldPatch) *MyDataPatchBuilder { - m.obj.PatchPrior = patchPrior - return m -} - -func (m *MyDataPatchBuilder) Ensure(ensure *MyDataEnsureStruct) *MyDataPatchBuilder { - m.obj.Ensure = ensure - return m -} - -func (m *MyDataPatchBuilder) Patch(patch *MyDataFieldPatch) *MyDataPatchBuilder { - m.obj.Patch = patch - return m -} - -func (m *MyDataPatchBuilder) Remove(remove patch0.FieldIdList) *MyDataPatchBuilder { - m.obj.Remove = remove - return m -} - -func (m *MyDataPatch) SetAssign(assign *MyData) *MyDataPatch { - m.Assign = assign - return m -} - -func (m *MyDataPatch) SetClear(clear bool) *MyDataPatch { - m.Clear = clear - return m -} - -func (m *MyDataPatch) SetPatchPrior(patchPrior *MyDataFieldPatch) *MyDataPatch { - m.PatchPrior = patchPrior - return m -} - -func (m *MyDataPatch) SetEnsure(ensure *MyDataEnsureStruct) *MyDataPatch { - m.Ensure = ensure - return m -} - -func (m *MyDataPatch) SetPatch(patch *MyDataFieldPatch) *MyDataPatch { - m.Patch = patch - return m -} - -func (m *MyDataPatch) SetRemove(remove patch0.FieldIdList) *MyDataPatch { - m.Remove = remove - return m -} - -func (p *MyDataPatch) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 3: - if err := p.ReadField3(iprot); err != nil { - return err - } - case 5: - if err := p.ReadField5(iprot); err != nil { - return err - } - case 6: - if err := p.ReadField6(iprot); err != nil { - return err - } - case 7: - if err := p.ReadField7(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyDataPatch) ReadField1(iprot thrift.Protocol) error { - p.Assign = NewMyData() - if err := p.Assign.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Assign), err) - } - return nil -} - -func (p *MyDataPatch) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Clear = v - } - return nil -} - -func (p *MyDataPatch) ReadField3(iprot thrift.Protocol) error { - p.PatchPrior = NewMyDataFieldPatch() - if err := p.PatchPrior.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.PatchPrior), err) - } - return nil -} - -func (p *MyDataPatch) ReadField5(iprot thrift.Protocol) error { - p.Ensure = NewMyDataEnsureStruct() - if err := p.Ensure.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Ensure), err) - } - return nil -} - -func (p *MyDataPatch) ReadField6(iprot thrift.Protocol) error { - p.Patch = NewMyDataFieldPatch() - if err := p.Patch.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Patch), err) - } - return nil -} - -func (p *MyDataPatch) ReadField7(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make(patch0.FieldIdList, 0, size) - p.Remove = tSlice - for i := 0; i < size; i ++ { - var _elem15 int16 - if v, err := iprot.ReadI16(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem15 = v - } - p.Remove = append(p.Remove, _elem15) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *MyDataPatch) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("MyDataPatch"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := p.writeField5(oprot); err != nil { return err } - if err := p.writeField6(oprot); err != nil { return err } - if err := p.writeField7(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyDataPatch) writeField1(oprot thrift.Protocol) (err error) { - if p.IsSetAssign() { - if err := oprot.WriteFieldBegin("assign", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:assign: ", p), err) } - if err := p.Assign.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Assign), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:assign: ", p), err) } - } - return err -} - -func (p *MyDataPatch) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("clear", thrift.BOOL, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:clear: ", p), err) } - if err := oprot.WriteBool(bool(p.Clear)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.clear (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:clear: ", p), err) } - return err -} - -func (p *MyDataPatch) writeField3(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("patchPrior", thrift.STRUCT, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:patchPrior: ", p), err) } - if err := p.PatchPrior.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.PatchPrior), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:patchPrior: ", p), err) } - return err -} - -func (p *MyDataPatch) writeField5(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("ensure", thrift.STRUCT, 5); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:ensure: ", p), err) } - if err := p.Ensure.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Ensure), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 5:ensure: ", p), err) } - return err -} - -func (p *MyDataPatch) writeField6(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("patch", thrift.STRUCT, 6); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 6:patch: ", p), err) } - if err := p.Patch.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Patch), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 6:patch: ", p), err) } - return err -} - -func (p *MyDataPatch) writeField7(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("remove", thrift.LIST, 7); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 7:remove: ", p), err) } - if err := oprot.WriteListBegin(thrift.I16, len(p.Remove)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.Remove { - if err := oprot.WriteI16(int16(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 7:remove: ", p), err) } - return err -} - -func (p *MyDataPatch) String() string { - if p == nil { - return "" - } - - var assignVal string - if p.Assign == nil { - assignVal = "" - } else { - assignVal = fmt.Sprintf("%v", p.Assign) - } - clearVal := fmt.Sprintf("%v", p.Clear) - var patchPriorVal string - if p.PatchPrior == nil { - patchPriorVal = "" - } else { - patchPriorVal = fmt.Sprintf("%v", p.PatchPrior) - } - var ensureVal string - if p.Ensure == nil { - ensureVal = "" - } else { - ensureVal = fmt.Sprintf("%v", p.Ensure) - } - var patchVal string - if p.Patch == nil { - patchVal = "" - } else { - patchVal = fmt.Sprintf("%v", p.Patch) - } - removeVal := fmt.Sprintf("%v", p.Remove) - return fmt.Sprintf("MyDataPatch({Assign:%s Clear:%s PatchPrior:%s Ensure:%s Patch:%s Remove:%s})", assignVal, clearVal, patchPriorVal, ensureVal, patchVal, removeVal) -} - -// Attributes: -// - Data1 -// - Data2 -type MyDataFieldPatch struct { - Data1 *patch0.StringPatch `thrift:"data1,1" db:"data1" json:"data1"` - Data2 *patch0.I32Patch `thrift:"data2,2" db:"data2" json:"data2"` -} - -func NewMyDataFieldPatch() *MyDataFieldPatch { - return &MyDataFieldPatch{ - Data1: patch0.NewStringPatch(), - Data2: patch0.NewI32Patch(), - } -} - -var MyDataFieldPatch_Data1_DEFAULT *patch0.StringPatch -func (p *MyDataFieldPatch) GetData1() *patch0.StringPatch { - if !p.IsSetData1() { - return MyDataFieldPatch_Data1_DEFAULT - } - return p.Data1 -} -func (p *MyDataFieldPatch) DefaultGetData1() *patch0.StringPatch { - if !p.IsSetData1() { - return patch0.NewStringPatch() - } - return p.Data1 -} -var MyDataFieldPatch_Data2_DEFAULT *patch0.I32Patch -func (p *MyDataFieldPatch) GetData2() *patch0.I32Patch { - if !p.IsSetData2() { - return MyDataFieldPatch_Data2_DEFAULT - } - return p.Data2 -} -func (p *MyDataFieldPatch) DefaultGetData2() *patch0.I32Patch { - if !p.IsSetData2() { - return patch0.NewI32Patch() - } - return p.Data2 -} -func (p *MyDataFieldPatch) IsSetData1() bool { - return p != nil && p.Data1 != nil -} - -func (p *MyDataFieldPatch) IsSetData2() bool { - return p != nil && p.Data2 != nil -} - -type MyDataFieldPatchBuilder struct { - obj *MyDataFieldPatch -} - -func NewMyDataFieldPatchBuilder() *MyDataFieldPatchBuilder{ - return &MyDataFieldPatchBuilder{ - obj: NewMyDataFieldPatch(), - } -} - -func (p MyDataFieldPatchBuilder) Emit() *MyDataFieldPatch{ - return &MyDataFieldPatch{ - Data1: p.obj.Data1, - Data2: p.obj.Data2, - } -} - -func (m *MyDataFieldPatchBuilder) Data1(data1 *patch0.StringPatch) *MyDataFieldPatchBuilder { - m.obj.Data1 = data1 - return m -} - -func (m *MyDataFieldPatchBuilder) Data2(data2 *patch0.I32Patch) *MyDataFieldPatchBuilder { - m.obj.Data2 = data2 - return m -} - -func (m *MyDataFieldPatch) SetData1(data1 *patch0.StringPatch) *MyDataFieldPatch { - m.Data1 = data1 - return m -} - -func (m *MyDataFieldPatch) SetData2(data2 *patch0.I32Patch) *MyDataFieldPatch { - m.Data2 = data2 - return m -} - -func (p *MyDataFieldPatch) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyDataFieldPatch) ReadField1(iprot thrift.Protocol) error { - p.Data1 = patch0.NewStringPatch() - if err := p.Data1.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Data1), err) - } - return nil -} - -func (p *MyDataFieldPatch) ReadField2(iprot thrift.Protocol) error { - p.Data2 = patch0.NewI32Patch() - if err := p.Data2.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Data2), err) - } - return nil -} - -func (p *MyDataFieldPatch) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("MyDataFieldPatch"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyDataFieldPatch) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("data1", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:data1: ", p), err) } - if err := p.Data1.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Data1), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:data1: ", p), err) } - return err -} - -func (p *MyDataFieldPatch) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("data2", thrift.STRUCT, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:data2: ", p), err) } - if err := p.Data2.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Data2), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:data2: ", p), err) } - return err -} - -func (p *MyDataFieldPatch) String() string { - if p == nil { - return "" - } - - var data1Val string - if p.Data1 == nil { - data1Val = "" - } else { - data1Val = fmt.Sprintf("%v", p.Data1) - } - var data2Val string - if p.Data2 == nil { - data2Val = "" - } else { - data2Val = fmt.Sprintf("%v", p.Data2) - } - return fmt.Sprintf("MyDataFieldPatch({Data1:%s Data2:%s})", data1Val, data2Val) -} - -// Attributes: -// - Data1 -// - Data2 -type MyDataEnsureStruct struct { - Data1 *string `thrift:"data1,1,optional" db:"data1" json:"data1,omitempty"` - Data2 *int32 `thrift:"data2,2,optional" db:"data2" json:"data2,omitempty"` -} - -func NewMyDataEnsureStruct() *MyDataEnsureStruct { - return &MyDataEnsureStruct{} -} - -var MyDataEnsureStruct_Data1_DEFAULT string -func (p *MyDataEnsureStruct) GetData1() string { - if !p.IsSetData1() { - return MyDataEnsureStruct_Data1_DEFAULT - } - return *p.Data1 -} -var MyDataEnsureStruct_Data2_DEFAULT int32 -func (p *MyDataEnsureStruct) GetData2() int32 { - if !p.IsSetData2() { - return MyDataEnsureStruct_Data2_DEFAULT - } - return *p.Data2 -} -func (p *MyDataEnsureStruct) IsSetData1() bool { - return p != nil && p.Data1 != nil -} - -func (p *MyDataEnsureStruct) IsSetData2() bool { - return p != nil && p.Data2 != nil -} - -type MyDataEnsureStructBuilder struct { - obj *MyDataEnsureStruct -} - -func NewMyDataEnsureStructBuilder() *MyDataEnsureStructBuilder{ - return &MyDataEnsureStructBuilder{ - obj: NewMyDataEnsureStruct(), - } -} - -func (p MyDataEnsureStructBuilder) Emit() *MyDataEnsureStruct{ - return &MyDataEnsureStruct{ - Data1: p.obj.Data1, - Data2: p.obj.Data2, - } -} - -func (m *MyDataEnsureStructBuilder) Data1(data1 *string) *MyDataEnsureStructBuilder { - m.obj.Data1 = data1 - return m -} - -func (m *MyDataEnsureStructBuilder) Data2(data2 *int32) *MyDataEnsureStructBuilder { - m.obj.Data2 = data2 - return m -} - -func (m *MyDataEnsureStruct) SetData1(data1 *string) *MyDataEnsureStruct { - m.Data1 = data1 - return m -} - -func (m *MyDataEnsureStruct) SetData2(data2 *int32) *MyDataEnsureStruct { - m.Data2 = data2 - return m -} - -func (p *MyDataEnsureStruct) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyDataEnsureStruct) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Data1 = &v - } - return nil -} - -func (p *MyDataEnsureStruct) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Data2 = &v - } - return nil -} - -func (p *MyDataEnsureStruct) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("MyDataEnsureStruct"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyDataEnsureStruct) writeField1(oprot thrift.Protocol) (err error) { - if p.IsSetData1() { - if err := oprot.WriteFieldBegin("data1", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:data1: ", p), err) } - if err := oprot.WriteString(string(*p.Data1)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.data1 (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:data1: ", p), err) } - } - return err -} - -func (p *MyDataEnsureStruct) writeField2(oprot thrift.Protocol) (err error) { - if p.IsSetData2() { - if err := oprot.WriteFieldBegin("data2", thrift.I32, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:data2: ", p), err) } - if err := oprot.WriteI32(int32(*p.Data2)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.data2 (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:data2: ", p), err) } - } - return err -} - -func (p *MyDataEnsureStruct) String() string { - if p == nil { - return "" - } - - var data1Val string - if p.Data1 == nil { - data1Val = "" - } else { - data1Val = fmt.Sprintf("%v", *p.Data1) - } - var data2Val string - if p.Data2 == nil { - data2Val = "" - } else { - data2Val = fmt.Sprintf("%v", *p.Data2) - } - return fmt.Sprintf("MyDataEnsureStruct({Data1:%s Data2:%s})", data1Val, data2Val) -} - -// Attributes: -// - Assign: Assigns to a (set) value. -// -// If set, all other operations are ignored. -// -// Note: Optional and union fields must be set before assigned. -// -// - Clear: Clears a value. Applies first. -// - PatchPrior: Patches any previously set values. Applies second. -// - Ensure: Initialize fields, using the given defaults. Applies third. -// - Patch: Patches any set value, including newly set values. Applies last. -// - Remove: Removes entries, if present. Applies third. -type MyDataWithCustomDefaultPatch struct { - Assign *MyDataWithCustomDefault `thrift:"assign,1,optional" db:"assign" json:"assign,omitempty"` - Clear bool `thrift:"clear,2" db:"clear" json:"clear"` - PatchPrior *MyDataWithCustomDefaultFieldPatch `thrift:"patchPrior,3" db:"patchPrior" json:"patchPrior"` - // unused field # 4 - Ensure *MyDataWithCustomDefaultEnsureStruct `thrift:"ensure,5" db:"ensure" json:"ensure"` - Patch *MyDataWithCustomDefaultFieldPatch `thrift:"patch,6" db:"patch" json:"patch"` - Remove patch0.FieldIdList `thrift:"remove,7" db:"remove" json:"remove"` -} - -func NewMyDataWithCustomDefaultPatch() *MyDataWithCustomDefaultPatch { - return &MyDataWithCustomDefaultPatch{ - PatchPrior: NewMyDataWithCustomDefaultFieldPatch(), - Ensure: NewMyDataWithCustomDefaultEnsureStruct(), - Patch: NewMyDataWithCustomDefaultFieldPatch(), - } -} - -var MyDataWithCustomDefaultPatch_Assign_DEFAULT *MyDataWithCustomDefault -func (p *MyDataWithCustomDefaultPatch) GetAssign() *MyDataWithCustomDefault { - if !p.IsSetAssign() { - return MyDataWithCustomDefaultPatch_Assign_DEFAULT - } - return p.Assign -} -func (p *MyDataWithCustomDefaultPatch) DefaultGetAssign() *MyDataWithCustomDefault { - if !p.IsSetAssign() { - return NewMyDataWithCustomDefault() - } - return p.Assign -} - -func (p *MyDataWithCustomDefaultPatch) GetClear() bool { - return p.Clear -} -var MyDataWithCustomDefaultPatch_PatchPrior_DEFAULT *MyDataWithCustomDefaultFieldPatch -func (p *MyDataWithCustomDefaultPatch) GetPatchPrior() *MyDataWithCustomDefaultFieldPatch { - if !p.IsSetPatchPrior() { - return MyDataWithCustomDefaultPatch_PatchPrior_DEFAULT - } - return p.PatchPrior -} -func (p *MyDataWithCustomDefaultPatch) DefaultGetPatchPrior() *MyDataWithCustomDefaultFieldPatch { - if !p.IsSetPatchPrior() { - return NewMyDataWithCustomDefaultFieldPatch() - } - return p.PatchPrior -} -var MyDataWithCustomDefaultPatch_Ensure_DEFAULT *MyDataWithCustomDefaultEnsureStruct -func (p *MyDataWithCustomDefaultPatch) GetEnsure() *MyDataWithCustomDefaultEnsureStruct { - if !p.IsSetEnsure() { - return MyDataWithCustomDefaultPatch_Ensure_DEFAULT - } - return p.Ensure -} -func (p *MyDataWithCustomDefaultPatch) DefaultGetEnsure() *MyDataWithCustomDefaultEnsureStruct { - if !p.IsSetEnsure() { - return NewMyDataWithCustomDefaultEnsureStruct() - } - return p.Ensure -} -var MyDataWithCustomDefaultPatch_Patch_DEFAULT *MyDataWithCustomDefaultFieldPatch -func (p *MyDataWithCustomDefaultPatch) GetPatch() *MyDataWithCustomDefaultFieldPatch { - if !p.IsSetPatch() { - return MyDataWithCustomDefaultPatch_Patch_DEFAULT - } - return p.Patch -} -func (p *MyDataWithCustomDefaultPatch) DefaultGetPatch() *MyDataWithCustomDefaultFieldPatch { - if !p.IsSetPatch() { - return NewMyDataWithCustomDefaultFieldPatch() - } - return p.Patch -} - -func (p *MyDataWithCustomDefaultPatch) GetRemove() patch0.FieldIdList { - return p.Remove -} -func (p *MyDataWithCustomDefaultPatch) IsSetAssign() bool { - return p != nil && p.Assign != nil -} - -func (p *MyDataWithCustomDefaultPatch) IsSetPatchPrior() bool { - return p != nil && p.PatchPrior != nil -} - -func (p *MyDataWithCustomDefaultPatch) IsSetEnsure() bool { - return p != nil && p.Ensure != nil -} - -func (p *MyDataWithCustomDefaultPatch) IsSetPatch() bool { - return p != nil && p.Patch != nil -} - -type MyDataWithCustomDefaultPatchBuilder struct { - obj *MyDataWithCustomDefaultPatch -} - -func NewMyDataWithCustomDefaultPatchBuilder() *MyDataWithCustomDefaultPatchBuilder{ - return &MyDataWithCustomDefaultPatchBuilder{ - obj: NewMyDataWithCustomDefaultPatch(), - } -} - -func (p MyDataWithCustomDefaultPatchBuilder) Emit() *MyDataWithCustomDefaultPatch{ - return &MyDataWithCustomDefaultPatch{ - Assign: p.obj.Assign, - Clear: p.obj.Clear, - PatchPrior: p.obj.PatchPrior, - Ensure: p.obj.Ensure, - Patch: p.obj.Patch, - Remove: p.obj.Remove, - } -} - -func (m *MyDataWithCustomDefaultPatchBuilder) Assign(assign *MyDataWithCustomDefault) *MyDataWithCustomDefaultPatchBuilder { - m.obj.Assign = assign - return m -} - -func (m *MyDataWithCustomDefaultPatchBuilder) Clear(clear bool) *MyDataWithCustomDefaultPatchBuilder { - m.obj.Clear = clear - return m -} - -func (m *MyDataWithCustomDefaultPatchBuilder) PatchPrior(patchPrior *MyDataWithCustomDefaultFieldPatch) *MyDataWithCustomDefaultPatchBuilder { - m.obj.PatchPrior = patchPrior - return m -} - -func (m *MyDataWithCustomDefaultPatchBuilder) Ensure(ensure *MyDataWithCustomDefaultEnsureStruct) *MyDataWithCustomDefaultPatchBuilder { - m.obj.Ensure = ensure - return m -} - -func (m *MyDataWithCustomDefaultPatchBuilder) Patch(patch *MyDataWithCustomDefaultFieldPatch) *MyDataWithCustomDefaultPatchBuilder { - m.obj.Patch = patch - return m -} - -func (m *MyDataWithCustomDefaultPatchBuilder) Remove(remove patch0.FieldIdList) *MyDataWithCustomDefaultPatchBuilder { - m.obj.Remove = remove - return m -} - -func (m *MyDataWithCustomDefaultPatch) SetAssign(assign *MyDataWithCustomDefault) *MyDataWithCustomDefaultPatch { - m.Assign = assign - return m -} - -func (m *MyDataWithCustomDefaultPatch) SetClear(clear bool) *MyDataWithCustomDefaultPatch { - m.Clear = clear - return m -} - -func (m *MyDataWithCustomDefaultPatch) SetPatchPrior(patchPrior *MyDataWithCustomDefaultFieldPatch) *MyDataWithCustomDefaultPatch { - m.PatchPrior = patchPrior - return m -} - -func (m *MyDataWithCustomDefaultPatch) SetEnsure(ensure *MyDataWithCustomDefaultEnsureStruct) *MyDataWithCustomDefaultPatch { - m.Ensure = ensure - return m -} - -func (m *MyDataWithCustomDefaultPatch) SetPatch(patch *MyDataWithCustomDefaultFieldPatch) *MyDataWithCustomDefaultPatch { - m.Patch = patch - return m -} - -func (m *MyDataWithCustomDefaultPatch) SetRemove(remove patch0.FieldIdList) *MyDataWithCustomDefaultPatch { - m.Remove = remove - return m -} - -func (p *MyDataWithCustomDefaultPatch) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 3: - if err := p.ReadField3(iprot); err != nil { - return err - } - case 5: - if err := p.ReadField5(iprot); err != nil { - return err - } - case 6: - if err := p.ReadField6(iprot); err != nil { - return err - } - case 7: - if err := p.ReadField7(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyDataWithCustomDefaultPatch) ReadField1(iprot thrift.Protocol) error { - p.Assign = NewMyDataWithCustomDefault() - if err := p.Assign.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Assign), err) - } - return nil -} - -func (p *MyDataWithCustomDefaultPatch) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Clear = v - } - return nil -} - -func (p *MyDataWithCustomDefaultPatch) ReadField3(iprot thrift.Protocol) error { - p.PatchPrior = NewMyDataWithCustomDefaultFieldPatch() - if err := p.PatchPrior.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.PatchPrior), err) - } - return nil -} - -func (p *MyDataWithCustomDefaultPatch) ReadField5(iprot thrift.Protocol) error { - p.Ensure = NewMyDataWithCustomDefaultEnsureStruct() - if err := p.Ensure.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Ensure), err) - } - return nil -} - -func (p *MyDataWithCustomDefaultPatch) ReadField6(iprot thrift.Protocol) error { - p.Patch = NewMyDataWithCustomDefaultFieldPatch() - if err := p.Patch.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Patch), err) - } - return nil -} - -func (p *MyDataWithCustomDefaultPatch) ReadField7(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make(patch0.FieldIdList, 0, size) - p.Remove = tSlice - for i := 0; i < size; i ++ { - var _elem16 int16 - if v, err := iprot.ReadI16(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem16 = v - } - p.Remove = append(p.Remove, _elem16) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *MyDataWithCustomDefaultPatch) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("MyDataWithCustomDefaultPatch"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := p.writeField5(oprot); err != nil { return err } - if err := p.writeField6(oprot); err != nil { return err } - if err := p.writeField7(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyDataWithCustomDefaultPatch) writeField1(oprot thrift.Protocol) (err error) { - if p.IsSetAssign() { - if err := oprot.WriteFieldBegin("assign", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:assign: ", p), err) } - if err := p.Assign.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Assign), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:assign: ", p), err) } - } - return err -} - -func (p *MyDataWithCustomDefaultPatch) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("clear", thrift.BOOL, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:clear: ", p), err) } - if err := oprot.WriteBool(bool(p.Clear)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.clear (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:clear: ", p), err) } - return err -} - -func (p *MyDataWithCustomDefaultPatch) writeField3(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("patchPrior", thrift.STRUCT, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:patchPrior: ", p), err) } - if err := p.PatchPrior.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.PatchPrior), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:patchPrior: ", p), err) } - return err -} - -func (p *MyDataWithCustomDefaultPatch) writeField5(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("ensure", thrift.STRUCT, 5); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:ensure: ", p), err) } - if err := p.Ensure.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Ensure), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 5:ensure: ", p), err) } - return err -} - -func (p *MyDataWithCustomDefaultPatch) writeField6(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("patch", thrift.STRUCT, 6); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 6:patch: ", p), err) } - if err := p.Patch.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Patch), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 6:patch: ", p), err) } - return err -} - -func (p *MyDataWithCustomDefaultPatch) writeField7(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("remove", thrift.LIST, 7); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 7:remove: ", p), err) } - if err := oprot.WriteListBegin(thrift.I16, len(p.Remove)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.Remove { - if err := oprot.WriteI16(int16(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 7:remove: ", p), err) } - return err -} - -func (p *MyDataWithCustomDefaultPatch) String() string { - if p == nil { - return "" - } - - var assignVal string - if p.Assign == nil { - assignVal = "" - } else { - assignVal = fmt.Sprintf("%v", p.Assign) - } - clearVal := fmt.Sprintf("%v", p.Clear) - var patchPriorVal string - if p.PatchPrior == nil { - patchPriorVal = "" - } else { - patchPriorVal = fmt.Sprintf("%v", p.PatchPrior) - } - var ensureVal string - if p.Ensure == nil { - ensureVal = "" - } else { - ensureVal = fmt.Sprintf("%v", p.Ensure) - } - var patchVal string - if p.Patch == nil { - patchVal = "" - } else { - patchVal = fmt.Sprintf("%v", p.Patch) - } - removeVal := fmt.Sprintf("%v", p.Remove) - return fmt.Sprintf("MyDataWithCustomDefaultPatch({Assign:%s Clear:%s PatchPrior:%s Ensure:%s Patch:%s Remove:%s})", assignVal, clearVal, patchPriorVal, ensureVal, patchVal, removeVal) -} - -// Attributes: -// - Data1 -// - Data2 -type MyDataWithCustomDefaultFieldPatch struct { - Data1 *patch0.StringPatch `thrift:"data1,1" db:"data1" json:"data1"` - Data2 *patch0.I32Patch `thrift:"data2,2" db:"data2" json:"data2"` -} - -func NewMyDataWithCustomDefaultFieldPatch() *MyDataWithCustomDefaultFieldPatch { - return &MyDataWithCustomDefaultFieldPatch{ - Data1: patch0.NewStringPatch(), - Data2: patch0.NewI32Patch(), - } -} - -var MyDataWithCustomDefaultFieldPatch_Data1_DEFAULT *patch0.StringPatch -func (p *MyDataWithCustomDefaultFieldPatch) GetData1() *patch0.StringPatch { - if !p.IsSetData1() { - return MyDataWithCustomDefaultFieldPatch_Data1_DEFAULT - } - return p.Data1 -} -func (p *MyDataWithCustomDefaultFieldPatch) DefaultGetData1() *patch0.StringPatch { - if !p.IsSetData1() { - return patch0.NewStringPatch() - } - return p.Data1 -} -var MyDataWithCustomDefaultFieldPatch_Data2_DEFAULT *patch0.I32Patch -func (p *MyDataWithCustomDefaultFieldPatch) GetData2() *patch0.I32Patch { - if !p.IsSetData2() { - return MyDataWithCustomDefaultFieldPatch_Data2_DEFAULT - } - return p.Data2 -} -func (p *MyDataWithCustomDefaultFieldPatch) DefaultGetData2() *patch0.I32Patch { - if !p.IsSetData2() { - return patch0.NewI32Patch() - } - return p.Data2 -} -func (p *MyDataWithCustomDefaultFieldPatch) IsSetData1() bool { - return p != nil && p.Data1 != nil -} - -func (p *MyDataWithCustomDefaultFieldPatch) IsSetData2() bool { - return p != nil && p.Data2 != nil -} - -type MyDataWithCustomDefaultFieldPatchBuilder struct { - obj *MyDataWithCustomDefaultFieldPatch -} - -func NewMyDataWithCustomDefaultFieldPatchBuilder() *MyDataWithCustomDefaultFieldPatchBuilder{ - return &MyDataWithCustomDefaultFieldPatchBuilder{ - obj: NewMyDataWithCustomDefaultFieldPatch(), - } -} - -func (p MyDataWithCustomDefaultFieldPatchBuilder) Emit() *MyDataWithCustomDefaultFieldPatch{ - return &MyDataWithCustomDefaultFieldPatch{ - Data1: p.obj.Data1, - Data2: p.obj.Data2, - } -} - -func (m *MyDataWithCustomDefaultFieldPatchBuilder) Data1(data1 *patch0.StringPatch) *MyDataWithCustomDefaultFieldPatchBuilder { - m.obj.Data1 = data1 - return m -} - -func (m *MyDataWithCustomDefaultFieldPatchBuilder) Data2(data2 *patch0.I32Patch) *MyDataWithCustomDefaultFieldPatchBuilder { - m.obj.Data2 = data2 - return m -} - -func (m *MyDataWithCustomDefaultFieldPatch) SetData1(data1 *patch0.StringPatch) *MyDataWithCustomDefaultFieldPatch { - m.Data1 = data1 - return m -} - -func (m *MyDataWithCustomDefaultFieldPatch) SetData2(data2 *patch0.I32Patch) *MyDataWithCustomDefaultFieldPatch { - m.Data2 = data2 - return m -} - -func (p *MyDataWithCustomDefaultFieldPatch) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyDataWithCustomDefaultFieldPatch) ReadField1(iprot thrift.Protocol) error { - p.Data1 = patch0.NewStringPatch() - if err := p.Data1.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Data1), err) - } - return nil -} - -func (p *MyDataWithCustomDefaultFieldPatch) ReadField2(iprot thrift.Protocol) error { - p.Data2 = patch0.NewI32Patch() - if err := p.Data2.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Data2), err) - } - return nil -} - -func (p *MyDataWithCustomDefaultFieldPatch) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("MyDataWithCustomDefaultFieldPatch"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyDataWithCustomDefaultFieldPatch) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("data1", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:data1: ", p), err) } - if err := p.Data1.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Data1), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:data1: ", p), err) } - return err -} - -func (p *MyDataWithCustomDefaultFieldPatch) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("data2", thrift.STRUCT, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:data2: ", p), err) } - if err := p.Data2.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Data2), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:data2: ", p), err) } - return err -} - -func (p *MyDataWithCustomDefaultFieldPatch) String() string { - if p == nil { - return "" - } - - var data1Val string - if p.Data1 == nil { - data1Val = "" - } else { - data1Val = fmt.Sprintf("%v", p.Data1) - } - var data2Val string - if p.Data2 == nil { - data2Val = "" - } else { - data2Val = fmt.Sprintf("%v", p.Data2) - } - return fmt.Sprintf("MyDataWithCustomDefaultFieldPatch({Data1:%s Data2:%s})", data1Val, data2Val) -} - -// Attributes: -// - Data1 -// - Data2 -type MyDataWithCustomDefaultEnsureStruct struct { - Data1 *string `thrift:"data1,1,optional" db:"data1" json:"data1,omitempty"` - Data2 *int32 `thrift:"data2,2,optional" db:"data2" json:"data2,omitempty"` -} - -func NewMyDataWithCustomDefaultEnsureStruct() *MyDataWithCustomDefaultEnsureStruct { - return &MyDataWithCustomDefaultEnsureStruct{} -} - -var MyDataWithCustomDefaultEnsureStruct_Data1_DEFAULT string -func (p *MyDataWithCustomDefaultEnsureStruct) GetData1() string { - if !p.IsSetData1() { - return MyDataWithCustomDefaultEnsureStruct_Data1_DEFAULT - } - return *p.Data1 -} -var MyDataWithCustomDefaultEnsureStruct_Data2_DEFAULT int32 -func (p *MyDataWithCustomDefaultEnsureStruct) GetData2() int32 { - if !p.IsSetData2() { - return MyDataWithCustomDefaultEnsureStruct_Data2_DEFAULT - } - return *p.Data2 -} -func (p *MyDataWithCustomDefaultEnsureStruct) IsSetData1() bool { - return p != nil && p.Data1 != nil -} - -func (p *MyDataWithCustomDefaultEnsureStruct) IsSetData2() bool { - return p != nil && p.Data2 != nil -} - -type MyDataWithCustomDefaultEnsureStructBuilder struct { - obj *MyDataWithCustomDefaultEnsureStruct -} - -func NewMyDataWithCustomDefaultEnsureStructBuilder() *MyDataWithCustomDefaultEnsureStructBuilder{ - return &MyDataWithCustomDefaultEnsureStructBuilder{ - obj: NewMyDataWithCustomDefaultEnsureStruct(), - } -} - -func (p MyDataWithCustomDefaultEnsureStructBuilder) Emit() *MyDataWithCustomDefaultEnsureStruct{ - return &MyDataWithCustomDefaultEnsureStruct{ - Data1: p.obj.Data1, - Data2: p.obj.Data2, - } -} - -func (m *MyDataWithCustomDefaultEnsureStructBuilder) Data1(data1 *string) *MyDataWithCustomDefaultEnsureStructBuilder { - m.obj.Data1 = data1 - return m -} - -func (m *MyDataWithCustomDefaultEnsureStructBuilder) Data2(data2 *int32) *MyDataWithCustomDefaultEnsureStructBuilder { - m.obj.Data2 = data2 - return m -} - -func (m *MyDataWithCustomDefaultEnsureStruct) SetData1(data1 *string) *MyDataWithCustomDefaultEnsureStruct { - m.Data1 = data1 - return m -} - -func (m *MyDataWithCustomDefaultEnsureStruct) SetData2(data2 *int32) *MyDataWithCustomDefaultEnsureStruct { - m.Data2 = data2 - return m -} - -func (p *MyDataWithCustomDefaultEnsureStruct) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyDataWithCustomDefaultEnsureStruct) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Data1 = &v - } - return nil -} - -func (p *MyDataWithCustomDefaultEnsureStruct) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Data2 = &v - } - return nil -} - -func (p *MyDataWithCustomDefaultEnsureStruct) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("MyDataWithCustomDefaultEnsureStruct"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyDataWithCustomDefaultEnsureStruct) writeField1(oprot thrift.Protocol) (err error) { - if p.IsSetData1() { - if err := oprot.WriteFieldBegin("data1", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:data1: ", p), err) } - if err := oprot.WriteString(string(*p.Data1)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.data1 (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:data1: ", p), err) } - } - return err -} - -func (p *MyDataWithCustomDefaultEnsureStruct) writeField2(oprot thrift.Protocol) (err error) { - if p.IsSetData2() { - if err := oprot.WriteFieldBegin("data2", thrift.I32, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:data2: ", p), err) } - if err := oprot.WriteI32(int32(*p.Data2)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.data2 (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:data2: ", p), err) } - } - return err -} - -func (p *MyDataWithCustomDefaultEnsureStruct) String() string { - if p == nil { - return "" - } - - var data1Val string - if p.Data1 == nil { - data1Val = "" - } else { - data1Val = fmt.Sprintf("%v", *p.Data1) - } - var data2Val string - if p.Data2 == nil { - data2Val = "" - } else { - data2Val = fmt.Sprintf("%v", *p.Data2) - } - return fmt.Sprintf("MyDataWithCustomDefaultEnsureStruct({Data1:%s Data2:%s})", data1Val, data2Val) -} - -// Attributes: -// - Assign: Assigns to a (set) value. -// -// If set, all other operations are ignored. -// -// Note: Optional and union fields must be set before assigned. -// -// - Clear: Clears any set value. Applies first. -// - PatchPrior: Patches any previously set values. Applies second. -// - Ensure: Assigns the value, if not already set to the same field. Applies third. -// - Patch: Patches any set value, including newly set values. Applies last. -type InnerUnionPatch struct { - Assign *InnerUnion `thrift:"assign,1,optional" db:"assign" json:"assign,omitempty"` - Clear bool `thrift:"clear,2" db:"clear" json:"clear"` - PatchPrior *InnerUnionFieldPatch `thrift:"patchPrior,3" db:"patchPrior" json:"patchPrior"` - Ensure *InnerUnion `thrift:"ensure,4" db:"ensure" json:"ensure"` - // unused field # 5 - Patch *InnerUnionFieldPatch `thrift:"patch,6" db:"patch" json:"patch"` -} - -func NewInnerUnionPatch() *InnerUnionPatch { - return &InnerUnionPatch{ - PatchPrior: NewInnerUnionFieldPatch(), - Patch: NewInnerUnionFieldPatch(), - } -} - -var InnerUnionPatch_Assign_DEFAULT *InnerUnion -func (p *InnerUnionPatch) GetAssign() *InnerUnion { - if !p.IsSetAssign() { - return InnerUnionPatch_Assign_DEFAULT - } - return p.Assign -} -func (p *InnerUnionPatch) DefaultGetAssign() *InnerUnion { - if !p.IsSetAssign() { - return NewInnerUnion() - } - return p.Assign -} - -func (p *InnerUnionPatch) GetClear() bool { - return p.Clear -} -var InnerUnionPatch_PatchPrior_DEFAULT *InnerUnionFieldPatch -func (p *InnerUnionPatch) GetPatchPrior() *InnerUnionFieldPatch { - if !p.IsSetPatchPrior() { - return InnerUnionPatch_PatchPrior_DEFAULT - } - return p.PatchPrior -} -func (p *InnerUnionPatch) DefaultGetPatchPrior() *InnerUnionFieldPatch { - if !p.IsSetPatchPrior() { - return NewInnerUnionFieldPatch() - } - return p.PatchPrior -} -var InnerUnionPatch_Ensure_DEFAULT *InnerUnion -func (p *InnerUnionPatch) GetEnsure() *InnerUnion { - if !p.IsSetEnsure() { - return InnerUnionPatch_Ensure_DEFAULT - } - return p.Ensure -} -func (p *InnerUnionPatch) DefaultGetEnsure() *InnerUnion { - if !p.IsSetEnsure() { - return NewInnerUnion() - } - return p.Ensure -} -var InnerUnionPatch_Patch_DEFAULT *InnerUnionFieldPatch -func (p *InnerUnionPatch) GetPatch() *InnerUnionFieldPatch { - if !p.IsSetPatch() { - return InnerUnionPatch_Patch_DEFAULT - } - return p.Patch -} -func (p *InnerUnionPatch) DefaultGetPatch() *InnerUnionFieldPatch { - if !p.IsSetPatch() { - return NewInnerUnionFieldPatch() - } - return p.Patch -} -func (p *InnerUnionPatch) IsSetAssign() bool { - return p != nil && p.Assign != nil -} - -func (p *InnerUnionPatch) IsSetPatchPrior() bool { - return p != nil && p.PatchPrior != nil -} - -func (p *InnerUnionPatch) IsSetEnsure() bool { - return p != nil && p.Ensure != nil -} - -func (p *InnerUnionPatch) IsSetPatch() bool { - return p != nil && p.Patch != nil -} - -type InnerUnionPatchBuilder struct { - obj *InnerUnionPatch -} - -func NewInnerUnionPatchBuilder() *InnerUnionPatchBuilder{ - return &InnerUnionPatchBuilder{ - obj: NewInnerUnionPatch(), - } -} - -func (p InnerUnionPatchBuilder) Emit() *InnerUnionPatch{ - return &InnerUnionPatch{ - Assign: p.obj.Assign, - Clear: p.obj.Clear, - PatchPrior: p.obj.PatchPrior, - Ensure: p.obj.Ensure, - Patch: p.obj.Patch, - } -} - -func (i *InnerUnionPatchBuilder) Assign(assign *InnerUnion) *InnerUnionPatchBuilder { - i.obj.Assign = assign - return i -} - -func (i *InnerUnionPatchBuilder) Clear(clear bool) *InnerUnionPatchBuilder { - i.obj.Clear = clear - return i -} - -func (i *InnerUnionPatchBuilder) PatchPrior(patchPrior *InnerUnionFieldPatch) *InnerUnionPatchBuilder { - i.obj.PatchPrior = patchPrior - return i -} - -func (i *InnerUnionPatchBuilder) Ensure(ensure *InnerUnion) *InnerUnionPatchBuilder { - i.obj.Ensure = ensure - return i -} - -func (i *InnerUnionPatchBuilder) Patch(patch *InnerUnionFieldPatch) *InnerUnionPatchBuilder { - i.obj.Patch = patch - return i -} - -func (i *InnerUnionPatch) SetAssign(assign *InnerUnion) *InnerUnionPatch { - i.Assign = assign - return i -} - -func (i *InnerUnionPatch) SetClear(clear bool) *InnerUnionPatch { - i.Clear = clear - return i -} - -func (i *InnerUnionPatch) SetPatchPrior(patchPrior *InnerUnionFieldPatch) *InnerUnionPatch { - i.PatchPrior = patchPrior - return i -} - -func (i *InnerUnionPatch) SetEnsure(ensure *InnerUnion) *InnerUnionPatch { - i.Ensure = ensure - return i -} - -func (i *InnerUnionPatch) SetPatch(patch *InnerUnionFieldPatch) *InnerUnionPatch { - i.Patch = patch - return i -} - -func (p *InnerUnionPatch) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 3: - if err := p.ReadField3(iprot); err != nil { - return err - } - case 4: - if err := p.ReadField4(iprot); err != nil { - return err - } - case 6: - if err := p.ReadField6(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *InnerUnionPatch) ReadField1(iprot thrift.Protocol) error { - p.Assign = NewInnerUnion() - if err := p.Assign.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Assign), err) - } - return nil -} - -func (p *InnerUnionPatch) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Clear = v - } - return nil -} - -func (p *InnerUnionPatch) ReadField3(iprot thrift.Protocol) error { - p.PatchPrior = NewInnerUnionFieldPatch() - if err := p.PatchPrior.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.PatchPrior), err) - } - return nil -} - -func (p *InnerUnionPatch) ReadField4(iprot thrift.Protocol) error { - p.Ensure = NewInnerUnion() - if err := p.Ensure.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Ensure), err) - } - return nil -} - -func (p *InnerUnionPatch) ReadField6(iprot thrift.Protocol) error { - p.Patch = NewInnerUnionFieldPatch() - if err := p.Patch.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Patch), err) - } - return nil -} - -func (p *InnerUnionPatch) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("InnerUnionPatch"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := p.writeField4(oprot); err != nil { return err } - if err := p.writeField6(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *InnerUnionPatch) writeField1(oprot thrift.Protocol) (err error) { - if p.IsSetAssign() { - if err := oprot.WriteFieldBegin("assign", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:assign: ", p), err) } - if err := p.Assign.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Assign), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:assign: ", p), err) } - } - return err -} - -func (p *InnerUnionPatch) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("clear", thrift.BOOL, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:clear: ", p), err) } - if err := oprot.WriteBool(bool(p.Clear)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.clear (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:clear: ", p), err) } - return err -} - -func (p *InnerUnionPatch) writeField3(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("patchPrior", thrift.STRUCT, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:patchPrior: ", p), err) } - if err := p.PatchPrior.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.PatchPrior), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:patchPrior: ", p), err) } - return err -} - -func (p *InnerUnionPatch) writeField4(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("ensure", thrift.STRUCT, 4); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:ensure: ", p), err) } - if err := p.Ensure.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Ensure), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 4:ensure: ", p), err) } - return err -} - -func (p *InnerUnionPatch) writeField6(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("patch", thrift.STRUCT, 6); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 6:patch: ", p), err) } - if err := p.Patch.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Patch), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 6:patch: ", p), err) } - return err -} - -func (p *InnerUnionPatch) String() string { - if p == nil { - return "" - } - - var assignVal string - if p.Assign == nil { - assignVal = "" - } else { - assignVal = fmt.Sprintf("%v", p.Assign) - } - clearVal := fmt.Sprintf("%v", p.Clear) - var patchPriorVal string - if p.PatchPrior == nil { - patchPriorVal = "" - } else { - patchPriorVal = fmt.Sprintf("%v", p.PatchPrior) - } - var ensureVal string - if p.Ensure == nil { - ensureVal = "" - } else { - ensureVal = fmt.Sprintf("%v", p.Ensure) - } - var patchVal string - if p.Patch == nil { - patchVal = "" - } else { - patchVal = fmt.Sprintf("%v", p.Patch) - } - return fmt.Sprintf("InnerUnionPatch({Assign:%s Clear:%s PatchPrior:%s Ensure:%s Patch:%s})", assignVal, clearVal, patchPriorVal, ensureVal, patchVal) -} - -// Attributes: -// - InnerOption -type InnerUnionFieldPatch struct { - InnerOption *patch0.BinaryPatch `thrift:"innerOption,1" db:"innerOption" json:"innerOption"` -} - -func NewInnerUnionFieldPatch() *InnerUnionFieldPatch { - return &InnerUnionFieldPatch{ - InnerOption: patch0.NewBinaryPatch(), - } -} - -var InnerUnionFieldPatch_InnerOption_DEFAULT *patch0.BinaryPatch -func (p *InnerUnionFieldPatch) GetInnerOption() *patch0.BinaryPatch { - if !p.IsSetInnerOption() { - return InnerUnionFieldPatch_InnerOption_DEFAULT - } - return p.InnerOption -} -func (p *InnerUnionFieldPatch) DefaultGetInnerOption() *patch0.BinaryPatch { - if !p.IsSetInnerOption() { - return patch0.NewBinaryPatch() - } - return p.InnerOption -} -func (p *InnerUnionFieldPatch) IsSetInnerOption() bool { - return p != nil && p.InnerOption != nil -} - -type InnerUnionFieldPatchBuilder struct { - obj *InnerUnionFieldPatch -} - -func NewInnerUnionFieldPatchBuilder() *InnerUnionFieldPatchBuilder{ - return &InnerUnionFieldPatchBuilder{ - obj: NewInnerUnionFieldPatch(), - } -} - -func (p InnerUnionFieldPatchBuilder) Emit() *InnerUnionFieldPatch{ - return &InnerUnionFieldPatch{ - InnerOption: p.obj.InnerOption, - } -} - -func (i *InnerUnionFieldPatchBuilder) InnerOption(innerOption *patch0.BinaryPatch) *InnerUnionFieldPatchBuilder { - i.obj.InnerOption = innerOption - return i -} - -func (i *InnerUnionFieldPatch) SetInnerOption(innerOption *patch0.BinaryPatch) *InnerUnionFieldPatch { - i.InnerOption = innerOption - return i -} - -func (p *InnerUnionFieldPatch) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *InnerUnionFieldPatch) ReadField1(iprot thrift.Protocol) error { - p.InnerOption = patch0.NewBinaryPatch() - if err := p.InnerOption.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.InnerOption), err) - } - return nil -} - -func (p *InnerUnionFieldPatch) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("InnerUnionFieldPatch"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *InnerUnionFieldPatch) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("innerOption", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:innerOption: ", p), err) } - if err := p.InnerOption.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.InnerOption), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:innerOption: ", p), err) } - return err -} - -func (p *InnerUnionFieldPatch) String() string { - if p == nil { - return "" - } - - var innerOptionVal string - if p.InnerOption == nil { - innerOptionVal = "" - } else { - innerOptionVal = fmt.Sprintf("%v", p.InnerOption) - } - return fmt.Sprintf("InnerUnionFieldPatch({InnerOption:%s})", innerOptionVal) -} - -// Attributes: -// - Assign: Assigns to a (set) value. -// -// If set, all other operations are ignored. -// -// Note: Optional and union fields must be set before assigned. -// -// - Clear: Clears any set value. Applies first. -// - PatchPrior: Patches any previously set values. Applies second. -// - Ensure: Assigns the value, if not already set to the same field. Applies third. -// - Patch: Patches any set value, including newly set values. Applies last. -type MyUnionPatch struct { - Assign *MyUnion `thrift:"assign,1,optional" db:"assign" json:"assign,omitempty"` - Clear bool `thrift:"clear,2" db:"clear" json:"clear"` - PatchPrior *MyUnionFieldPatch `thrift:"patchPrior,3" db:"patchPrior" json:"patchPrior"` - Ensure *MyUnion `thrift:"ensure,4" db:"ensure" json:"ensure"` - // unused field # 5 - Patch *MyUnionFieldPatch `thrift:"patch,6" db:"patch" json:"patch"` -} - -func NewMyUnionPatch() *MyUnionPatch { - return &MyUnionPatch{ - PatchPrior: NewMyUnionFieldPatch(), - Patch: NewMyUnionFieldPatch(), - } -} - -var MyUnionPatch_Assign_DEFAULT *MyUnion -func (p *MyUnionPatch) GetAssign() *MyUnion { - if !p.IsSetAssign() { - return MyUnionPatch_Assign_DEFAULT - } - return p.Assign -} -func (p *MyUnionPatch) DefaultGetAssign() *MyUnion { - if !p.IsSetAssign() { - return NewMyUnion() - } - return p.Assign -} - -func (p *MyUnionPatch) GetClear() bool { - return p.Clear -} -var MyUnionPatch_PatchPrior_DEFAULT *MyUnionFieldPatch -func (p *MyUnionPatch) GetPatchPrior() *MyUnionFieldPatch { - if !p.IsSetPatchPrior() { - return MyUnionPatch_PatchPrior_DEFAULT - } - return p.PatchPrior -} -func (p *MyUnionPatch) DefaultGetPatchPrior() *MyUnionFieldPatch { - if !p.IsSetPatchPrior() { - return NewMyUnionFieldPatch() - } - return p.PatchPrior -} -var MyUnionPatch_Ensure_DEFAULT *MyUnion -func (p *MyUnionPatch) GetEnsure() *MyUnion { - if !p.IsSetEnsure() { - return MyUnionPatch_Ensure_DEFAULT - } - return p.Ensure -} -func (p *MyUnionPatch) DefaultGetEnsure() *MyUnion { - if !p.IsSetEnsure() { - return NewMyUnion() - } - return p.Ensure -} -var MyUnionPatch_Patch_DEFAULT *MyUnionFieldPatch -func (p *MyUnionPatch) GetPatch() *MyUnionFieldPatch { - if !p.IsSetPatch() { - return MyUnionPatch_Patch_DEFAULT - } - return p.Patch -} -func (p *MyUnionPatch) DefaultGetPatch() *MyUnionFieldPatch { - if !p.IsSetPatch() { - return NewMyUnionFieldPatch() - } - return p.Patch -} -func (p *MyUnionPatch) IsSetAssign() bool { - return p != nil && p.Assign != nil -} - -func (p *MyUnionPatch) IsSetPatchPrior() bool { - return p != nil && p.PatchPrior != nil -} - -func (p *MyUnionPatch) IsSetEnsure() bool { - return p != nil && p.Ensure != nil -} - -func (p *MyUnionPatch) IsSetPatch() bool { - return p != nil && p.Patch != nil -} - -type MyUnionPatchBuilder struct { - obj *MyUnionPatch -} - -func NewMyUnionPatchBuilder() *MyUnionPatchBuilder{ - return &MyUnionPatchBuilder{ - obj: NewMyUnionPatch(), - } -} - -func (p MyUnionPatchBuilder) Emit() *MyUnionPatch{ - return &MyUnionPatch{ - Assign: p.obj.Assign, - Clear: p.obj.Clear, - PatchPrior: p.obj.PatchPrior, - Ensure: p.obj.Ensure, - Patch: p.obj.Patch, - } -} - -func (m *MyUnionPatchBuilder) Assign(assign *MyUnion) *MyUnionPatchBuilder { - m.obj.Assign = assign - return m -} - -func (m *MyUnionPatchBuilder) Clear(clear bool) *MyUnionPatchBuilder { - m.obj.Clear = clear - return m -} - -func (m *MyUnionPatchBuilder) PatchPrior(patchPrior *MyUnionFieldPatch) *MyUnionPatchBuilder { - m.obj.PatchPrior = patchPrior - return m -} - -func (m *MyUnionPatchBuilder) Ensure(ensure *MyUnion) *MyUnionPatchBuilder { - m.obj.Ensure = ensure - return m -} - -func (m *MyUnionPatchBuilder) Patch(patch *MyUnionFieldPatch) *MyUnionPatchBuilder { - m.obj.Patch = patch - return m -} - -func (m *MyUnionPatch) SetAssign(assign *MyUnion) *MyUnionPatch { - m.Assign = assign - return m -} - -func (m *MyUnionPatch) SetClear(clear bool) *MyUnionPatch { - m.Clear = clear - return m -} - -func (m *MyUnionPatch) SetPatchPrior(patchPrior *MyUnionFieldPatch) *MyUnionPatch { - m.PatchPrior = patchPrior - return m -} - -func (m *MyUnionPatch) SetEnsure(ensure *MyUnion) *MyUnionPatch { - m.Ensure = ensure - return m -} - -func (m *MyUnionPatch) SetPatch(patch *MyUnionFieldPatch) *MyUnionPatch { - m.Patch = patch - return m -} - -func (p *MyUnionPatch) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 3: - if err := p.ReadField3(iprot); err != nil { - return err - } - case 4: - if err := p.ReadField4(iprot); err != nil { - return err - } - case 6: - if err := p.ReadField6(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyUnionPatch) ReadField1(iprot thrift.Protocol) error { - p.Assign = NewMyUnion() - if err := p.Assign.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Assign), err) - } - return nil -} - -func (p *MyUnionPatch) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Clear = v - } - return nil -} - -func (p *MyUnionPatch) ReadField3(iprot thrift.Protocol) error { - p.PatchPrior = NewMyUnionFieldPatch() - if err := p.PatchPrior.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.PatchPrior), err) - } - return nil -} - -func (p *MyUnionPatch) ReadField4(iprot thrift.Protocol) error { - p.Ensure = NewMyUnion() - if err := p.Ensure.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Ensure), err) - } - return nil -} - -func (p *MyUnionPatch) ReadField6(iprot thrift.Protocol) error { - p.Patch = NewMyUnionFieldPatch() - if err := p.Patch.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Patch), err) - } - return nil -} - -func (p *MyUnionPatch) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("MyUnionPatch"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := p.writeField4(oprot); err != nil { return err } - if err := p.writeField6(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyUnionPatch) writeField1(oprot thrift.Protocol) (err error) { - if p.IsSetAssign() { - if err := oprot.WriteFieldBegin("assign", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:assign: ", p), err) } - if err := p.Assign.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Assign), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:assign: ", p), err) } - } - return err -} - -func (p *MyUnionPatch) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("clear", thrift.BOOL, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:clear: ", p), err) } - if err := oprot.WriteBool(bool(p.Clear)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.clear (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:clear: ", p), err) } - return err -} - -func (p *MyUnionPatch) writeField3(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("patchPrior", thrift.STRUCT, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:patchPrior: ", p), err) } - if err := p.PatchPrior.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.PatchPrior), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:patchPrior: ", p), err) } - return err -} - -func (p *MyUnionPatch) writeField4(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("ensure", thrift.STRUCT, 4); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:ensure: ", p), err) } - if err := p.Ensure.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Ensure), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 4:ensure: ", p), err) } - return err -} - -func (p *MyUnionPatch) writeField6(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("patch", thrift.STRUCT, 6); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 6:patch: ", p), err) } - if err := p.Patch.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Patch), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 6:patch: ", p), err) } - return err -} - -func (p *MyUnionPatch) String() string { - if p == nil { - return "" - } - - var assignVal string - if p.Assign == nil { - assignVal = "" - } else { - assignVal = fmt.Sprintf("%v", p.Assign) - } - clearVal := fmt.Sprintf("%v", p.Clear) - var patchPriorVal string - if p.PatchPrior == nil { - patchPriorVal = "" - } else { - patchPriorVal = fmt.Sprintf("%v", p.PatchPrior) - } - var ensureVal string - if p.Ensure == nil { - ensureVal = "" - } else { - ensureVal = fmt.Sprintf("%v", p.Ensure) - } - var patchVal string - if p.Patch == nil { - patchVal = "" - } else { - patchVal = fmt.Sprintf("%v", p.Patch) - } - return fmt.Sprintf("MyUnionPatch({Assign:%s Clear:%s PatchPrior:%s Ensure:%s Patch:%s})", assignVal, clearVal, patchPriorVal, ensureVal, patchVal) -} - -// Attributes: -// - Option1 -// - Option2 -// - Option3 -type MyUnionFieldPatch struct { - Option1 *patch0.StringPatch `thrift:"option1,1" db:"option1" json:"option1"` - Option2 *patch0.I32Patch `thrift:"option2,2" db:"option2" json:"option2"` - Option3 *InnerUnionPatch `thrift:"option3,3" db:"option3" json:"option3"` -} - -func NewMyUnionFieldPatch() *MyUnionFieldPatch { - return &MyUnionFieldPatch{ - Option1: patch0.NewStringPatch(), - Option2: patch0.NewI32Patch(), - Option3: NewInnerUnionPatch(), - } -} - -var MyUnionFieldPatch_Option1_DEFAULT *patch0.StringPatch -func (p *MyUnionFieldPatch) GetOption1() *patch0.StringPatch { - if !p.IsSetOption1() { - return MyUnionFieldPatch_Option1_DEFAULT - } - return p.Option1 -} -func (p *MyUnionFieldPatch) DefaultGetOption1() *patch0.StringPatch { - if !p.IsSetOption1() { - return patch0.NewStringPatch() - } - return p.Option1 -} -var MyUnionFieldPatch_Option2_DEFAULT *patch0.I32Patch -func (p *MyUnionFieldPatch) GetOption2() *patch0.I32Patch { - if !p.IsSetOption2() { - return MyUnionFieldPatch_Option2_DEFAULT - } - return p.Option2 -} -func (p *MyUnionFieldPatch) DefaultGetOption2() *patch0.I32Patch { - if !p.IsSetOption2() { - return patch0.NewI32Patch() - } - return p.Option2 -} -var MyUnionFieldPatch_Option3_DEFAULT *InnerUnionPatch -func (p *MyUnionFieldPatch) GetOption3() *InnerUnionPatch { - if !p.IsSetOption3() { - return MyUnionFieldPatch_Option3_DEFAULT - } - return p.Option3 -} -func (p *MyUnionFieldPatch) DefaultGetOption3() *InnerUnionPatch { - if !p.IsSetOption3() { - return NewInnerUnionPatch() - } - return p.Option3 -} -func (p *MyUnionFieldPatch) IsSetOption1() bool { - return p != nil && p.Option1 != nil -} - -func (p *MyUnionFieldPatch) IsSetOption2() bool { - return p != nil && p.Option2 != nil -} - -func (p *MyUnionFieldPatch) IsSetOption3() bool { - return p != nil && p.Option3 != nil -} - -type MyUnionFieldPatchBuilder struct { - obj *MyUnionFieldPatch -} - -func NewMyUnionFieldPatchBuilder() *MyUnionFieldPatchBuilder{ - return &MyUnionFieldPatchBuilder{ - obj: NewMyUnionFieldPatch(), - } -} - -func (p MyUnionFieldPatchBuilder) Emit() *MyUnionFieldPatch{ - return &MyUnionFieldPatch{ - Option1: p.obj.Option1, - Option2: p.obj.Option2, - Option3: p.obj.Option3, - } -} - -func (m *MyUnionFieldPatchBuilder) Option1(option1 *patch0.StringPatch) *MyUnionFieldPatchBuilder { - m.obj.Option1 = option1 - return m -} - -func (m *MyUnionFieldPatchBuilder) Option2(option2 *patch0.I32Patch) *MyUnionFieldPatchBuilder { - m.obj.Option2 = option2 - return m -} - -func (m *MyUnionFieldPatchBuilder) Option3(option3 *InnerUnionPatch) *MyUnionFieldPatchBuilder { - m.obj.Option3 = option3 - return m -} - -func (m *MyUnionFieldPatch) SetOption1(option1 *patch0.StringPatch) *MyUnionFieldPatch { - m.Option1 = option1 - return m -} - -func (m *MyUnionFieldPatch) SetOption2(option2 *patch0.I32Patch) *MyUnionFieldPatch { - m.Option2 = option2 - return m -} - -func (m *MyUnionFieldPatch) SetOption3(option3 *InnerUnionPatch) *MyUnionFieldPatch { - m.Option3 = option3 - return m -} - -func (p *MyUnionFieldPatch) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 3: - if err := p.ReadField3(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyUnionFieldPatch) ReadField1(iprot thrift.Protocol) error { - p.Option1 = patch0.NewStringPatch() - if err := p.Option1.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Option1), err) - } - return nil -} - -func (p *MyUnionFieldPatch) ReadField2(iprot thrift.Protocol) error { - p.Option2 = patch0.NewI32Patch() - if err := p.Option2.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Option2), err) - } - return nil -} - -func (p *MyUnionFieldPatch) ReadField3(iprot thrift.Protocol) error { - p.Option3 = NewInnerUnionPatch() - if err := p.Option3.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Option3), err) - } - return nil -} - -func (p *MyUnionFieldPatch) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("MyUnionFieldPatch"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyUnionFieldPatch) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("option1", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:option1: ", p), err) } - if err := p.Option1.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Option1), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:option1: ", p), err) } - return err -} - -func (p *MyUnionFieldPatch) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("option2", thrift.STRUCT, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:option2: ", p), err) } - if err := p.Option2.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Option2), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:option2: ", p), err) } - return err -} - -func (p *MyUnionFieldPatch) writeField3(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("option3", thrift.STRUCT, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:option3: ", p), err) } - if err := p.Option3.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Option3), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:option3: ", p), err) } - return err -} - -func (p *MyUnionFieldPatch) String() string { - if p == nil { - return "" - } - - var option1Val string - if p.Option1 == nil { - option1Val = "" - } else { - option1Val = fmt.Sprintf("%v", p.Option1) - } - var option2Val string - if p.Option2 == nil { - option2Val = "" - } else { - option2Val = fmt.Sprintf("%v", p.Option2) - } - var option3Val string - if p.Option3 == nil { - option3Val = "" - } else { - option3Val = fmt.Sprintf("%v", p.Option3) - } - return fmt.Sprintf("MyUnionFieldPatch({Option1:%s Option2:%s Option3:%s})", option1Val, option2Val, option3Val) -} - -// Attributes: -// - Assign: Assigns to a (set) value. -// -// If set, all other operations are ignored. -// -// Note: Optional and union fields must be set before assigned. -// -// - Clear: Clears a value. Applies first. -// - PatchPrior: Patches any previously set values. Applies second. -// - Ensure: Initialize fields, using the given defaults. Applies third. -// - Patch: Patches any set value, including newly set values. Applies last. -// - Remove: Removes entries, if present. Applies third. -type MyStructPatch struct { - Assign *MyStruct `thrift:"assign,1,optional" db:"assign" json:"assign,omitempty"` - Clear bool `thrift:"clear,2" db:"clear" json:"clear"` - PatchPrior *MyStructFieldPatch `thrift:"patchPrior,3" db:"patchPrior" json:"patchPrior"` - // unused field # 4 - Ensure *MyStructEnsureStruct `thrift:"ensure,5" db:"ensure" json:"ensure"` - Patch *MyStructFieldPatch `thrift:"patch,6" db:"patch" json:"patch"` - Remove patch0.FieldIdList `thrift:"remove,7" db:"remove" json:"remove"` -} - -func NewMyStructPatch() *MyStructPatch { - return &MyStructPatch{ - PatchPrior: NewMyStructFieldPatch(), - Ensure: NewMyStructEnsureStruct(), - Patch: NewMyStructFieldPatch(), - } -} - -var MyStructPatch_Assign_DEFAULT *MyStruct -func (p *MyStructPatch) GetAssign() *MyStruct { - if !p.IsSetAssign() { - return MyStructPatch_Assign_DEFAULT - } - return p.Assign -} -func (p *MyStructPatch) DefaultGetAssign() *MyStruct { - if !p.IsSetAssign() { - return NewMyStruct() - } - return p.Assign -} - -func (p *MyStructPatch) GetClear() bool { - return p.Clear -} -var MyStructPatch_PatchPrior_DEFAULT *MyStructFieldPatch -func (p *MyStructPatch) GetPatchPrior() *MyStructFieldPatch { - if !p.IsSetPatchPrior() { - return MyStructPatch_PatchPrior_DEFAULT - } - return p.PatchPrior -} -func (p *MyStructPatch) DefaultGetPatchPrior() *MyStructFieldPatch { - if !p.IsSetPatchPrior() { - return NewMyStructFieldPatch() - } - return p.PatchPrior -} -var MyStructPatch_Ensure_DEFAULT *MyStructEnsureStruct -func (p *MyStructPatch) GetEnsure() *MyStructEnsureStruct { - if !p.IsSetEnsure() { - return MyStructPatch_Ensure_DEFAULT - } - return p.Ensure -} -func (p *MyStructPatch) DefaultGetEnsure() *MyStructEnsureStruct { - if !p.IsSetEnsure() { - return NewMyStructEnsureStruct() - } - return p.Ensure -} -var MyStructPatch_Patch_DEFAULT *MyStructFieldPatch -func (p *MyStructPatch) GetPatch() *MyStructFieldPatch { - if !p.IsSetPatch() { - return MyStructPatch_Patch_DEFAULT - } - return p.Patch -} -func (p *MyStructPatch) DefaultGetPatch() *MyStructFieldPatch { - if !p.IsSetPatch() { - return NewMyStructFieldPatch() - } - return p.Patch -} - -func (p *MyStructPatch) GetRemove() patch0.FieldIdList { - return p.Remove -} -func (p *MyStructPatch) IsSetAssign() bool { - return p != nil && p.Assign != nil -} - -func (p *MyStructPatch) IsSetPatchPrior() bool { - return p != nil && p.PatchPrior != nil -} - -func (p *MyStructPatch) IsSetEnsure() bool { - return p != nil && p.Ensure != nil -} - -func (p *MyStructPatch) IsSetPatch() bool { - return p != nil && p.Patch != nil -} - -type MyStructPatchBuilder struct { - obj *MyStructPatch -} - -func NewMyStructPatchBuilder() *MyStructPatchBuilder{ - return &MyStructPatchBuilder{ - obj: NewMyStructPatch(), - } -} - -func (p MyStructPatchBuilder) Emit() *MyStructPatch{ - return &MyStructPatch{ - Assign: p.obj.Assign, - Clear: p.obj.Clear, - PatchPrior: p.obj.PatchPrior, - Ensure: p.obj.Ensure, - Patch: p.obj.Patch, - Remove: p.obj.Remove, - } -} - -func (m *MyStructPatchBuilder) Assign(assign *MyStruct) *MyStructPatchBuilder { - m.obj.Assign = assign - return m -} - -func (m *MyStructPatchBuilder) Clear(clear bool) *MyStructPatchBuilder { - m.obj.Clear = clear - return m -} - -func (m *MyStructPatchBuilder) PatchPrior(patchPrior *MyStructFieldPatch) *MyStructPatchBuilder { - m.obj.PatchPrior = patchPrior - return m -} - -func (m *MyStructPatchBuilder) Ensure(ensure *MyStructEnsureStruct) *MyStructPatchBuilder { - m.obj.Ensure = ensure - return m -} - -func (m *MyStructPatchBuilder) Patch(patch *MyStructFieldPatch) *MyStructPatchBuilder { - m.obj.Patch = patch - return m -} - -func (m *MyStructPatchBuilder) Remove(remove patch0.FieldIdList) *MyStructPatchBuilder { - m.obj.Remove = remove - return m -} - -func (m *MyStructPatch) SetAssign(assign *MyStruct) *MyStructPatch { - m.Assign = assign - return m -} - -func (m *MyStructPatch) SetClear(clear bool) *MyStructPatch { - m.Clear = clear - return m -} - -func (m *MyStructPatch) SetPatchPrior(patchPrior *MyStructFieldPatch) *MyStructPatch { - m.PatchPrior = patchPrior - return m -} - -func (m *MyStructPatch) SetEnsure(ensure *MyStructEnsureStruct) *MyStructPatch { - m.Ensure = ensure - return m -} - -func (m *MyStructPatch) SetPatch(patch *MyStructFieldPatch) *MyStructPatch { - m.Patch = patch - return m -} - -func (m *MyStructPatch) SetRemove(remove patch0.FieldIdList) *MyStructPatch { - m.Remove = remove - return m -} - -func (p *MyStructPatch) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 3: - if err := p.ReadField3(iprot); err != nil { - return err - } - case 5: - if err := p.ReadField5(iprot); err != nil { - return err - } - case 6: - if err := p.ReadField6(iprot); err != nil { - return err - } - case 7: - if err := p.ReadField7(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyStructPatch) ReadField1(iprot thrift.Protocol) error { - p.Assign = NewMyStruct() - if err := p.Assign.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Assign), err) - } - return nil -} - -func (p *MyStructPatch) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Clear = v - } - return nil -} - -func (p *MyStructPatch) ReadField3(iprot thrift.Protocol) error { - p.PatchPrior = NewMyStructFieldPatch() - if err := p.PatchPrior.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.PatchPrior), err) - } - return nil -} - -func (p *MyStructPatch) ReadField5(iprot thrift.Protocol) error { - p.Ensure = NewMyStructEnsureStruct() - if err := p.Ensure.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Ensure), err) - } - return nil -} - -func (p *MyStructPatch) ReadField6(iprot thrift.Protocol) error { - p.Patch = NewMyStructFieldPatch() - if err := p.Patch.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Patch), err) - } - return nil -} - -func (p *MyStructPatch) ReadField7(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make(patch0.FieldIdList, 0, size) - p.Remove = tSlice - for i := 0; i < size; i ++ { - var _elem17 int16 - if v, err := iprot.ReadI16(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem17 = v - } - p.Remove = append(p.Remove, _elem17) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *MyStructPatch) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("MyStructPatch"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := p.writeField5(oprot); err != nil { return err } - if err := p.writeField6(oprot); err != nil { return err } - if err := p.writeField7(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyStructPatch) writeField1(oprot thrift.Protocol) (err error) { - if p.IsSetAssign() { - if err := oprot.WriteFieldBegin("assign", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:assign: ", p), err) } - if err := p.Assign.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Assign), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:assign: ", p), err) } - } - return err -} - -func (p *MyStructPatch) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("clear", thrift.BOOL, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:clear: ", p), err) } - if err := oprot.WriteBool(bool(p.Clear)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.clear (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:clear: ", p), err) } - return err -} - -func (p *MyStructPatch) writeField3(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("patchPrior", thrift.STRUCT, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:patchPrior: ", p), err) } - if err := p.PatchPrior.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.PatchPrior), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:patchPrior: ", p), err) } - return err -} - -func (p *MyStructPatch) writeField5(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("ensure", thrift.STRUCT, 5); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:ensure: ", p), err) } - if err := p.Ensure.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Ensure), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 5:ensure: ", p), err) } - return err -} - -func (p *MyStructPatch) writeField6(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("patch", thrift.STRUCT, 6); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 6:patch: ", p), err) } - if err := p.Patch.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Patch), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 6:patch: ", p), err) } - return err -} - -func (p *MyStructPatch) writeField7(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("remove", thrift.LIST, 7); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 7:remove: ", p), err) } - if err := oprot.WriteListBegin(thrift.I16, len(p.Remove)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.Remove { - if err := oprot.WriteI16(int16(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 7:remove: ", p), err) } - return err -} - -func (p *MyStructPatch) String() string { - if p == nil { - return "" - } - - var assignVal string - if p.Assign == nil { - assignVal = "" - } else { - assignVal = fmt.Sprintf("%v", p.Assign) - } - clearVal := fmt.Sprintf("%v", p.Clear) - var patchPriorVal string - if p.PatchPrior == nil { - patchPriorVal = "" - } else { - patchPriorVal = fmt.Sprintf("%v", p.PatchPrior) - } - var ensureVal string - if p.Ensure == nil { - ensureVal = "" - } else { - ensureVal = fmt.Sprintf("%v", p.Ensure) - } - var patchVal string - if p.Patch == nil { - patchVal = "" - } else { - patchVal = fmt.Sprintf("%v", p.Patch) - } - removeVal := fmt.Sprintf("%v", p.Remove) - return fmt.Sprintf("MyStructPatch({Assign:%s Clear:%s PatchPrior:%s Ensure:%s Patch:%s Remove:%s})", assignVal, clearVal, patchPriorVal, ensureVal, patchVal, removeVal) -} - -// Attributes: -// - Assign: Assigns to a (set) value. -// -// If set, all other operations are ignored. -// -// Note: Optional and union fields must be set before assigned. -// -// - Clear: Clears a value. Applies first. -type MyStructField10Patch struct { - Assign *MyEnum `thrift:"assign,1,optional" db:"assign" json:"assign,omitempty"` - Clear bool `thrift:"clear,2" db:"clear" json:"clear"` -} - -func NewMyStructField10Patch() *MyStructField10Patch { - return &MyStructField10Patch{} -} - -var MyStructField10Patch_Assign_DEFAULT MyEnum -func (p *MyStructField10Patch) GetAssign() MyEnum { - if !p.IsSetAssign() { - return MyStructField10Patch_Assign_DEFAULT - } - return *p.Assign -} - -func (p *MyStructField10Patch) GetClear() bool { - return p.Clear -} -func (p *MyStructField10Patch) IsSetAssign() bool { - return p != nil && p.Assign != nil -} - -type MyStructField10PatchBuilder struct { - obj *MyStructField10Patch -} - -func NewMyStructField10PatchBuilder() *MyStructField10PatchBuilder{ - return &MyStructField10PatchBuilder{ - obj: NewMyStructField10Patch(), - } -} - -func (p MyStructField10PatchBuilder) Emit() *MyStructField10Patch{ - return &MyStructField10Patch{ - Assign: p.obj.Assign, - Clear: p.obj.Clear, - } -} - -func (m *MyStructField10PatchBuilder) Assign(assign *MyEnum) *MyStructField10PatchBuilder { - m.obj.Assign = assign - return m -} - -func (m *MyStructField10PatchBuilder) Clear(clear bool) *MyStructField10PatchBuilder { - m.obj.Clear = clear - return m -} - -func (m *MyStructField10Patch) SetAssign(assign *MyEnum) *MyStructField10Patch { - m.Assign = assign - return m -} - -func (m *MyStructField10Patch) SetClear(clear bool) *MyStructField10Patch { - m.Clear = clear - return m -} - -func (p *MyStructField10Patch) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyStructField10Patch) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - temp := MyEnum(v) - p.Assign = &temp - } - return nil -} - -func (p *MyStructField10Patch) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Clear = v - } - return nil -} - -func (p *MyStructField10Patch) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("MyStructField10Patch"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyStructField10Patch) writeField1(oprot thrift.Protocol) (err error) { - if p.IsSetAssign() { - if err := oprot.WriteFieldBegin("assign", thrift.I32, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:assign: ", p), err) } - if err := oprot.WriteI32(int32(*p.Assign)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.assign (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:assign: ", p), err) } - } - return err -} - -func (p *MyStructField10Patch) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("clear", thrift.BOOL, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:clear: ", p), err) } - if err := oprot.WriteBool(bool(p.Clear)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.clear (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:clear: ", p), err) } - return err -} - -func (p *MyStructField10Patch) String() string { - if p == nil { - return "" - } - - var assignVal string - if p.Assign == nil { - assignVal = "" - } else { - assignVal = fmt.Sprintf("%v", *p.Assign) - } - clearVal := fmt.Sprintf("%v", p.Clear) - return fmt.Sprintf("MyStructField10Patch({Assign:%s Clear:%s})", assignVal, clearVal) -} - -// Attributes: -// - Assign: Assigns to a (set) value. -// -// If set, all other operations are ignored. -// -// Note: Optional and union fields must be set before assigned. -// -// - Clear: Clears a value. Applies first. -type MyStructField23Patch struct { - Assign *MyEnum `thrift:"assign,1,optional" db:"assign" json:"assign,omitempty"` - Clear bool `thrift:"clear,2" db:"clear" json:"clear"` -} - -func NewMyStructField23Patch() *MyStructField23Patch { - return &MyStructField23Patch{} -} - -var MyStructField23Patch_Assign_DEFAULT MyEnum -func (p *MyStructField23Patch) GetAssign() MyEnum { - if !p.IsSetAssign() { - return MyStructField23Patch_Assign_DEFAULT - } - return *p.Assign -} - -func (p *MyStructField23Patch) GetClear() bool { - return p.Clear -} -func (p *MyStructField23Patch) IsSetAssign() bool { - return p != nil && p.Assign != nil -} - -type MyStructField23PatchBuilder struct { - obj *MyStructField23Patch -} - -func NewMyStructField23PatchBuilder() *MyStructField23PatchBuilder{ - return &MyStructField23PatchBuilder{ - obj: NewMyStructField23Patch(), - } -} - -func (p MyStructField23PatchBuilder) Emit() *MyStructField23Patch{ - return &MyStructField23Patch{ - Assign: p.obj.Assign, - Clear: p.obj.Clear, - } -} - -func (m *MyStructField23PatchBuilder) Assign(assign *MyEnum) *MyStructField23PatchBuilder { - m.obj.Assign = assign - return m -} - -func (m *MyStructField23PatchBuilder) Clear(clear bool) *MyStructField23PatchBuilder { - m.obj.Clear = clear - return m -} - -func (m *MyStructField23Patch) SetAssign(assign *MyEnum) *MyStructField23Patch { - m.Assign = assign - return m -} - -func (m *MyStructField23Patch) SetClear(clear bool) *MyStructField23Patch { - m.Clear = clear - return m -} - -func (p *MyStructField23Patch) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyStructField23Patch) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - temp := MyEnum(v) - p.Assign = &temp - } - return nil -} - -func (p *MyStructField23Patch) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Clear = v - } - return nil -} - -func (p *MyStructField23Patch) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("MyStructField23Patch"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyStructField23Patch) writeField1(oprot thrift.Protocol) (err error) { - if p.IsSetAssign() { - if err := oprot.WriteFieldBegin("assign", thrift.I32, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:assign: ", p), err) } - if err := oprot.WriteI32(int32(*p.Assign)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.assign (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:assign: ", p), err) } - } - return err -} - -func (p *MyStructField23Patch) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("clear", thrift.BOOL, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:clear: ", p), err) } - if err := oprot.WriteBool(bool(p.Clear)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.clear (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:clear: ", p), err) } - return err -} - -func (p *MyStructField23Patch) String() string { - if p == nil { - return "" - } - - var assignVal string - if p.Assign == nil { - assignVal = "" - } else { - assignVal = fmt.Sprintf("%v", *p.Assign) - } - clearVal := fmt.Sprintf("%v", p.Clear) - return fmt.Sprintf("MyStructField23Patch({Assign:%s Clear:%s})", assignVal, clearVal) -} - -// Attributes: -// - Assign: Assigns to a (set) value. -// -// If set, all other operations are ignored. -// -// Note: Optional and union fields must be set before assigned. -// -// - Clear: Clears a value. Applies first. -// - Prepend: Prepends to the front of a given list. -// - Append: Appends to the back of a given list. -type MyStructField26Patch struct { - Assign []int16 `thrift:"assign,1,optional" db:"assign" json:"assign,omitempty"` - Clear bool `thrift:"clear,2" db:"clear" json:"clear"` - // unused fields # 3 to 7 - Prepend []int16 `thrift:"prepend,8" db:"prepend" json:"prepend"` - Append []int16 `thrift:"append,9" db:"append" json:"append"` -} - -func NewMyStructField26Patch() *MyStructField26Patch { - return &MyStructField26Patch{} -} - -var MyStructField26Patch_Assign_DEFAULT []int16 - -func (p *MyStructField26Patch) GetAssign() []int16 { - return p.Assign -} - -func (p *MyStructField26Patch) GetClear() bool { - return p.Clear -} - -func (p *MyStructField26Patch) GetPrepend() []int16 { - return p.Prepend -} - -func (p *MyStructField26Patch) GetAppend() []int16 { - return p.Append -} -func (p *MyStructField26Patch) IsSetAssign() bool { - return p != nil && p.Assign != nil -} - -type MyStructField26PatchBuilder struct { - obj *MyStructField26Patch -} - -func NewMyStructField26PatchBuilder() *MyStructField26PatchBuilder{ - return &MyStructField26PatchBuilder{ - obj: NewMyStructField26Patch(), - } -} - -func (p MyStructField26PatchBuilder) Emit() *MyStructField26Patch{ - return &MyStructField26Patch{ - Assign: p.obj.Assign, - Clear: p.obj.Clear, - Prepend: p.obj.Prepend, - Append: p.obj.Append, - } -} - -func (m *MyStructField26PatchBuilder) Assign(assign []int16) *MyStructField26PatchBuilder { - m.obj.Assign = assign - return m -} - -func (m *MyStructField26PatchBuilder) Clear(clear bool) *MyStructField26PatchBuilder { - m.obj.Clear = clear - return m -} - -func (m *MyStructField26PatchBuilder) Prepend(prepend []int16) *MyStructField26PatchBuilder { - m.obj.Prepend = prepend - return m -} - -func (m *MyStructField26PatchBuilder) Append(append []int16) *MyStructField26PatchBuilder { - m.obj.Append = append - return m -} - -func (m *MyStructField26Patch) SetAssign(assign []int16) *MyStructField26Patch { - m.Assign = assign - return m -} - -func (m *MyStructField26Patch) SetClear(clear bool) *MyStructField26Patch { - m.Clear = clear - return m -} - -func (m *MyStructField26Patch) SetPrepend(prepend []int16) *MyStructField26Patch { - m.Prepend = prepend - return m -} - -func (m *MyStructField26Patch) SetAppend(append []int16) *MyStructField26Patch { - m.Append = append - return m -} - -func (p *MyStructField26Patch) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 8: - if err := p.ReadField8(iprot); err != nil { - return err - } - case 9: - if err := p.ReadField9(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyStructField26Patch) ReadField1(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]int16, 0, size) - p.Assign = tSlice - for i := 0; i < size; i ++ { - var _elem18 int16 - if v, err := iprot.ReadI16(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem18 = v - } - p.Assign = append(p.Assign, _elem18) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *MyStructField26Patch) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Clear = v - } - return nil -} - -func (p *MyStructField26Patch) ReadField8(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]int16, 0, size) - p.Prepend = tSlice - for i := 0; i < size; i ++ { - var _elem19 int16 - if v, err := iprot.ReadI16(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem19 = v - } - p.Prepend = append(p.Prepend, _elem19) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *MyStructField26Patch) ReadField9(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]int16, 0, size) - p.Append = tSlice - for i := 0; i < size; i ++ { - var _elem20 int16 - if v, err := iprot.ReadI16(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem20 = v - } - p.Append = append(p.Append, _elem20) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *MyStructField26Patch) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("MyStructField26Patch"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField8(oprot); err != nil { return err } - if err := p.writeField9(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyStructField26Patch) writeField1(oprot thrift.Protocol) (err error) { - if p.IsSetAssign() { - if err := oprot.WriteFieldBegin("assign", thrift.LIST, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:assign: ", p), err) } - if err := oprot.WriteListBegin(thrift.I16, len(p.Assign)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.Assign { - if err := oprot.WriteI16(int16(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:assign: ", p), err) } - } - return err -} - -func (p *MyStructField26Patch) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("clear", thrift.BOOL, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:clear: ", p), err) } - if err := oprot.WriteBool(bool(p.Clear)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.clear (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:clear: ", p), err) } - return err -} - -func (p *MyStructField26Patch) writeField8(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("prepend", thrift.LIST, 8); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 8:prepend: ", p), err) } - if err := oprot.WriteListBegin(thrift.I16, len(p.Prepend)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.Prepend { - if err := oprot.WriteI16(int16(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 8:prepend: ", p), err) } - return err -} - -func (p *MyStructField26Patch) writeField9(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("append", thrift.LIST, 9); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 9:append: ", p), err) } - if err := oprot.WriteListBegin(thrift.I16, len(p.Append)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.Append { - if err := oprot.WriteI16(int16(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 9:append: ", p), err) } - return err -} - -func (p *MyStructField26Patch) String() string { - if p == nil { - return "" - } - - assignVal := fmt.Sprintf("%v", p.Assign) - clearVal := fmt.Sprintf("%v", p.Clear) - prependVal := fmt.Sprintf("%v", p.Prepend) - appendVal := fmt.Sprintf("%v", p.Append) - return fmt.Sprintf("MyStructField26Patch({Assign:%s Clear:%s Prepend:%s Append:%s})", assignVal, clearVal, prependVal, appendVal) -} - -// Attributes: -// - Assign: Assigns to a (set) value. -// -// If set, all other operations are ignored. -// -// Note: Optional and union fields must be set before assigned. -// -// - Clear: Clears a value. Applies first. -// - Remove: Removes entries, if present. Applies third. -// - Add: Adds entries, if not already present. Applies fourth. -type MyStructField27Patch struct { - Assign []string `thrift:"assign,1,optional" db:"assign" json:"assign,omitempty"` - Clear bool `thrift:"clear,2" db:"clear" json:"clear"` - // unused fields # 3 to 6 - Remove []string `thrift:"remove,7" db:"remove" json:"remove"` - Add []string `thrift:"add,8" db:"add" json:"add"` -} - -func NewMyStructField27Patch() *MyStructField27Patch { - return &MyStructField27Patch{} -} - -var MyStructField27Patch_Assign_DEFAULT []string - -func (p *MyStructField27Patch) GetAssign() []string { - return p.Assign -} - -func (p *MyStructField27Patch) GetClear() bool { - return p.Clear -} - -func (p *MyStructField27Patch) GetRemove() []string { - return p.Remove -} - -func (p *MyStructField27Patch) GetAdd() []string { - return p.Add -} -func (p *MyStructField27Patch) IsSetAssign() bool { - return p != nil && p.Assign != nil -} - -type MyStructField27PatchBuilder struct { - obj *MyStructField27Patch -} - -func NewMyStructField27PatchBuilder() *MyStructField27PatchBuilder{ - return &MyStructField27PatchBuilder{ - obj: NewMyStructField27Patch(), - } -} - -func (p MyStructField27PatchBuilder) Emit() *MyStructField27Patch{ - return &MyStructField27Patch{ - Assign: p.obj.Assign, - Clear: p.obj.Clear, - Remove: p.obj.Remove, - Add: p.obj.Add, - } -} - -func (m *MyStructField27PatchBuilder) Assign(assign []string) *MyStructField27PatchBuilder { - m.obj.Assign = assign - return m -} - -func (m *MyStructField27PatchBuilder) Clear(clear bool) *MyStructField27PatchBuilder { - m.obj.Clear = clear - return m -} - -func (m *MyStructField27PatchBuilder) Remove(remove []string) *MyStructField27PatchBuilder { - m.obj.Remove = remove - return m -} - -func (m *MyStructField27PatchBuilder) Add(add []string) *MyStructField27PatchBuilder { - m.obj.Add = add - return m -} - -func (m *MyStructField27Patch) SetAssign(assign []string) *MyStructField27Patch { - m.Assign = assign - return m -} - -func (m *MyStructField27Patch) SetClear(clear bool) *MyStructField27Patch { - m.Clear = clear - return m -} - -func (m *MyStructField27Patch) SetRemove(remove []string) *MyStructField27Patch { - m.Remove = remove - return m -} - -func (m *MyStructField27Patch) SetAdd(add []string) *MyStructField27Patch { - m.Add = add - return m -} - -func (p *MyStructField27Patch) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 7: - if err := p.ReadField7(iprot); err != nil { - return err - } - case 8: - if err := p.ReadField8(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyStructField27Patch) ReadField1(iprot thrift.Protocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return thrift.PrependError("error reading set begin: ", err) - } - tSet := make([]string, 0, size) - p.Assign = tSet - for i := 0; i < size; i ++ { - var _elem21 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem21 = v - } - p.Assign = append(p.Assign, _elem21) - } - if err := iprot.ReadSetEnd(); err != nil { - return thrift.PrependError("error reading set end: ", err) - } - return nil -} - -func (p *MyStructField27Patch) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Clear = v - } - return nil -} - -func (p *MyStructField27Patch) ReadField7(iprot thrift.Protocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return thrift.PrependError("error reading set begin: ", err) - } - tSet := make([]string, 0, size) - p.Remove = tSet - for i := 0; i < size; i ++ { - var _elem22 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem22 = v - } - p.Remove = append(p.Remove, _elem22) - } - if err := iprot.ReadSetEnd(); err != nil { - return thrift.PrependError("error reading set end: ", err) - } - return nil -} - -func (p *MyStructField27Patch) ReadField8(iprot thrift.Protocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return thrift.PrependError("error reading set begin: ", err) - } - tSet := make([]string, 0, size) - p.Add = tSet - for i := 0; i < size; i ++ { - var _elem23 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem23 = v - } - p.Add = append(p.Add, _elem23) - } - if err := iprot.ReadSetEnd(); err != nil { - return thrift.PrependError("error reading set end: ", err) - } - return nil -} - -func (p *MyStructField27Patch) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("MyStructField27Patch"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField7(oprot); err != nil { return err } - if err := p.writeField8(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyStructField27Patch) writeField1(oprot thrift.Protocol) (err error) { - if p.IsSetAssign() { - if err := oprot.WriteFieldBegin("assign", thrift.SET, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:assign: ", p), err) } - if err := oprot.WriteSetBegin(thrift.STRING, len(p.Assign)); err != nil { - return thrift.PrependError("error writing set begin: ", err) - } - set := make(map[string]bool, len(p.Assign)) - for _, v := range p.Assign { - if ok := set[v]; ok { - return thrift.PrependError("", fmt.Errorf("%T error writing set field: slice is not unique", v)) - } - set[v] = true - } - for _, v := range p.Assign { - if err := oprot.WriteString(string(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteSetEnd(); err != nil { - return thrift.PrependError("error writing set end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:assign: ", p), err) } - } - return err -} - -func (p *MyStructField27Patch) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("clear", thrift.BOOL, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:clear: ", p), err) } - if err := oprot.WriteBool(bool(p.Clear)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.clear (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:clear: ", p), err) } - return err -} - -func (p *MyStructField27Patch) writeField7(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("remove", thrift.SET, 7); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 7:remove: ", p), err) } - if err := oprot.WriteSetBegin(thrift.STRING, len(p.Remove)); err != nil { - return thrift.PrependError("error writing set begin: ", err) - } - set := make(map[string]bool, len(p.Remove)) - for _, v := range p.Remove { - if ok := set[v]; ok { - return thrift.PrependError("", fmt.Errorf("%T error writing set field: slice is not unique", v)) - } - set[v] = true - } - for _, v := range p.Remove { - if err := oprot.WriteString(string(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteSetEnd(); err != nil { - return thrift.PrependError("error writing set end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 7:remove: ", p), err) } - return err -} - -func (p *MyStructField27Patch) writeField8(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("add", thrift.SET, 8); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 8:add: ", p), err) } - if err := oprot.WriteSetBegin(thrift.STRING, len(p.Add)); err != nil { - return thrift.PrependError("error writing set begin: ", err) - } - set := make(map[string]bool, len(p.Add)) - for _, v := range p.Add { - if ok := set[v]; ok { - return thrift.PrependError("", fmt.Errorf("%T error writing set field: slice is not unique", v)) - } - set[v] = true - } - for _, v := range p.Add { - if err := oprot.WriteString(string(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteSetEnd(); err != nil { - return thrift.PrependError("error writing set end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 8:add: ", p), err) } - return err -} - -func (p *MyStructField27Patch) String() string { - if p == nil { - return "" - } - - assignVal := fmt.Sprintf("%v", p.Assign) - clearVal := fmt.Sprintf("%v", p.Clear) - removeVal := fmt.Sprintf("%v", p.Remove) - addVal := fmt.Sprintf("%v", p.Add) - return fmt.Sprintf("MyStructField27Patch({Assign:%s Clear:%s Remove:%s Add:%s})", assignVal, clearVal, removeVal, addVal) -} - -// Attributes: -// - Assign: Assigns to a (set) value. -// -// If set, all other operations are ignored. -// -// Note: Optional and union fields must be set before assigned. -// -// - Clear: Clears a value. Applies first. -// - PatchPrior: Patches any previously set values. Applies second. -// - Add: Add the given values, if the keys are not already present. Applies forth. -// - Patch: Patches any set value, including newly set values. Applies last. -// - Remove: Removes entries, if present. Applies third. -// - Put: Adds or replaces the given key/value pairs. Applies fifth. -type MyStructField28Patch struct { - Assign map[string]string `thrift:"assign,1,optional" db:"assign" json:"assign,omitempty"` - Clear bool `thrift:"clear,2" db:"clear" json:"clear"` - PatchPrior map[string]*patch0.StringPatch `thrift:"patchPrior,3" db:"patchPrior" json:"patchPrior"` - // unused field # 4 - Add map[string]string `thrift:"add,5" db:"add" json:"add"` - Patch map[string]*patch0.StringPatch `thrift:"patch,6" db:"patch" json:"patch"` - Remove []string `thrift:"remove,7" db:"remove" json:"remove"` - // unused field # 8 - Put map[string]string `thrift:"put,9" db:"put" json:"put"` -} - -func NewMyStructField28Patch() *MyStructField28Patch { - return &MyStructField28Patch{} -} - -var MyStructField28Patch_Assign_DEFAULT map[string]string - -func (p *MyStructField28Patch) GetAssign() map[string]string { - return p.Assign -} - -func (p *MyStructField28Patch) GetClear() bool { - return p.Clear -} - -func (p *MyStructField28Patch) GetPatchPrior() map[string]*patch0.StringPatch { - return p.PatchPrior -} - -func (p *MyStructField28Patch) GetAdd() map[string]string { - return p.Add -} - -func (p *MyStructField28Patch) GetPatch() map[string]*patch0.StringPatch { - return p.Patch -} - -func (p *MyStructField28Patch) GetRemove() []string { - return p.Remove -} - -func (p *MyStructField28Patch) GetPut() map[string]string { - return p.Put -} -func (p *MyStructField28Patch) IsSetAssign() bool { - return p != nil && p.Assign != nil -} - -type MyStructField28PatchBuilder struct { - obj *MyStructField28Patch -} - -func NewMyStructField28PatchBuilder() *MyStructField28PatchBuilder{ - return &MyStructField28PatchBuilder{ - obj: NewMyStructField28Patch(), - } -} - -func (p MyStructField28PatchBuilder) Emit() *MyStructField28Patch{ - return &MyStructField28Patch{ - Assign: p.obj.Assign, - Clear: p.obj.Clear, - PatchPrior: p.obj.PatchPrior, - Add: p.obj.Add, - Patch: p.obj.Patch, - Remove: p.obj.Remove, - Put: p.obj.Put, - } -} - -func (m *MyStructField28PatchBuilder) Assign(assign map[string]string) *MyStructField28PatchBuilder { - m.obj.Assign = assign - return m -} - -func (m *MyStructField28PatchBuilder) Clear(clear bool) *MyStructField28PatchBuilder { - m.obj.Clear = clear - return m -} - -func (m *MyStructField28PatchBuilder) PatchPrior(patchPrior map[string]*patch0.StringPatch) *MyStructField28PatchBuilder { - m.obj.PatchPrior = patchPrior - return m -} - -func (m *MyStructField28PatchBuilder) Add(add map[string]string) *MyStructField28PatchBuilder { - m.obj.Add = add - return m -} - -func (m *MyStructField28PatchBuilder) Patch(patch map[string]*patch0.StringPatch) *MyStructField28PatchBuilder { - m.obj.Patch = patch - return m -} - -func (m *MyStructField28PatchBuilder) Remove(remove []string) *MyStructField28PatchBuilder { - m.obj.Remove = remove - return m -} - -func (m *MyStructField28PatchBuilder) Put(put map[string]string) *MyStructField28PatchBuilder { - m.obj.Put = put - return m -} - -func (m *MyStructField28Patch) SetAssign(assign map[string]string) *MyStructField28Patch { - m.Assign = assign - return m -} - -func (m *MyStructField28Patch) SetClear(clear bool) *MyStructField28Patch { - m.Clear = clear - return m -} - -func (m *MyStructField28Patch) SetPatchPrior(patchPrior map[string]*patch0.StringPatch) *MyStructField28Patch { - m.PatchPrior = patchPrior - return m -} - -func (m *MyStructField28Patch) SetAdd(add map[string]string) *MyStructField28Patch { - m.Add = add - return m -} - -func (m *MyStructField28Patch) SetPatch(patch map[string]*patch0.StringPatch) *MyStructField28Patch { - m.Patch = patch - return m -} - -func (m *MyStructField28Patch) SetRemove(remove []string) *MyStructField28Patch { - m.Remove = remove - return m -} - -func (m *MyStructField28Patch) SetPut(put map[string]string) *MyStructField28Patch { - m.Put = put - return m -} - -func (p *MyStructField28Patch) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 3: - if err := p.ReadField3(iprot); err != nil { - return err - } - case 5: - if err := p.ReadField5(iprot); err != nil { - return err - } - case 6: - if err := p.ReadField6(iprot); err != nil { - return err - } - case 7: - if err := p.ReadField7(iprot); err != nil { - return err - } - case 9: - if err := p.ReadField9(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyStructField28Patch) ReadField1(iprot thrift.Protocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[string]string, size) - p.Assign = tMap - for i := 0; i < size; i ++ { - var _key24 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key24 = v - } - var _val25 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _val25 = v - } - p.Assign[_key24] = _val25 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *MyStructField28Patch) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Clear = v - } - return nil -} - -func (p *MyStructField28Patch) ReadField3(iprot thrift.Protocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[string]*patch0.StringPatch, size) - p.PatchPrior = tMap - for i := 0; i < size; i ++ { - var _key26 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key26 = v - } - _val27 := patch0.NewStringPatch() - if err := _val27.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _val27), err) - } - p.PatchPrior[_key26] = _val27 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *MyStructField28Patch) ReadField5(iprot thrift.Protocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[string]string, size) - p.Add = tMap - for i := 0; i < size; i ++ { - var _key28 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key28 = v - } - var _val29 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _val29 = v - } - p.Add[_key28] = _val29 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *MyStructField28Patch) ReadField6(iprot thrift.Protocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[string]*patch0.StringPatch, size) - p.Patch = tMap - for i := 0; i < size; i ++ { - var _key30 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key30 = v - } - _val31 := patch0.NewStringPatch() - if err := _val31.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _val31), err) - } - p.Patch[_key30] = _val31 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *MyStructField28Patch) ReadField7(iprot thrift.Protocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return thrift.PrependError("error reading set begin: ", err) - } - tSet := make([]string, 0, size) - p.Remove = tSet - for i := 0; i < size; i ++ { - var _elem32 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem32 = v - } - p.Remove = append(p.Remove, _elem32) - } - if err := iprot.ReadSetEnd(); err != nil { - return thrift.PrependError("error reading set end: ", err) - } - return nil -} - -func (p *MyStructField28Patch) ReadField9(iprot thrift.Protocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[string]string, size) - p.Put = tMap - for i := 0; i < size; i ++ { - var _key33 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key33 = v - } - var _val34 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _val34 = v - } - p.Put[_key33] = _val34 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *MyStructField28Patch) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("MyStructField28Patch"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := p.writeField5(oprot); err != nil { return err } - if err := p.writeField6(oprot); err != nil { return err } - if err := p.writeField7(oprot); err != nil { return err } - if err := p.writeField9(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyStructField28Patch) writeField1(oprot thrift.Protocol) (err error) { - if p.IsSetAssign() { - if err := oprot.WriteFieldBegin("assign", thrift.MAP, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:assign: ", p), err) } - if err := oprot.WriteMapBegin(thrift.STRING, thrift.STRING, len(p.Assign)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.Assign { - if err := oprot.WriteString(string(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := oprot.WriteString(string(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:assign: ", p), err) } - } - return err -} - -func (p *MyStructField28Patch) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("clear", thrift.BOOL, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:clear: ", p), err) } - if err := oprot.WriteBool(bool(p.Clear)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.clear (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:clear: ", p), err) } - return err -} - -func (p *MyStructField28Patch) writeField3(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("patchPrior", thrift.MAP, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:patchPrior: ", p), err) } - if err := oprot.WriteMapBegin(thrift.STRING, thrift.STRUCT, len(p.PatchPrior)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.PatchPrior { - if err := oprot.WriteString(string(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := v.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) - } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:patchPrior: ", p), err) } - return err -} - -func (p *MyStructField28Patch) writeField5(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("add", thrift.MAP, 5); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:add: ", p), err) } - if err := oprot.WriteMapBegin(thrift.STRING, thrift.STRING, len(p.Add)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.Add { - if err := oprot.WriteString(string(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := oprot.WriteString(string(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 5:add: ", p), err) } - return err -} - -func (p *MyStructField28Patch) writeField6(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("patch", thrift.MAP, 6); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 6:patch: ", p), err) } - if err := oprot.WriteMapBegin(thrift.STRING, thrift.STRUCT, len(p.Patch)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.Patch { - if err := oprot.WriteString(string(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := v.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) - } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 6:patch: ", p), err) } - return err -} - -func (p *MyStructField28Patch) writeField7(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("remove", thrift.SET, 7); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 7:remove: ", p), err) } - if err := oprot.WriteSetBegin(thrift.STRING, len(p.Remove)); err != nil { - return thrift.PrependError("error writing set begin: ", err) - } - set := make(map[string]bool, len(p.Remove)) - for _, v := range p.Remove { - if ok := set[v]; ok { - return thrift.PrependError("", fmt.Errorf("%T error writing set field: slice is not unique", v)) - } - set[v] = true - } - for _, v := range p.Remove { - if err := oprot.WriteString(string(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteSetEnd(); err != nil { - return thrift.PrependError("error writing set end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 7:remove: ", p), err) } - return err -} - -func (p *MyStructField28Patch) writeField9(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("put", thrift.MAP, 9); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 9:put: ", p), err) } - if err := oprot.WriteMapBegin(thrift.STRING, thrift.STRING, len(p.Put)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.Put { - if err := oprot.WriteString(string(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := oprot.WriteString(string(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 9:put: ", p), err) } - return err -} - -func (p *MyStructField28Patch) String() string { - if p == nil { - return "" - } - - assignVal := fmt.Sprintf("%v", p.Assign) - clearVal := fmt.Sprintf("%v", p.Clear) - patchPriorVal := fmt.Sprintf("%v", p.PatchPrior) - addVal := fmt.Sprintf("%v", p.Add) - patchVal := fmt.Sprintf("%v", p.Patch) - removeVal := fmt.Sprintf("%v", p.Remove) - putVal := fmt.Sprintf("%v", p.Put) - return fmt.Sprintf("MyStructField28Patch({Assign:%s Clear:%s PatchPrior:%s Add:%s Patch:%s Remove:%s Put:%s})", assignVal, clearVal, patchPriorVal, addVal, patchVal, removeVal, putVal) -} - -// Attributes: -// - Assign: Assigns to a (set) value. -// -// If set, all other operations are ignored. -// -// Note: Optional and union fields must be set before assigned. -// -// - Clear: Clears a value. Applies first. -// - Prepend: Prepends to the front of a given list. -// - Append: Appends to the back of a given list. -type MyStructField29Patch struct { - Assign []map[string]int32 `thrift:"assign,1,optional" db:"assign" json:"assign,omitempty"` - Clear bool `thrift:"clear,2" db:"clear" json:"clear"` - // unused fields # 3 to 7 - Prepend []map[string]int32 `thrift:"prepend,8" db:"prepend" json:"prepend"` - Append []map[string]int32 `thrift:"append,9" db:"append" json:"append"` -} - -func NewMyStructField29Patch() *MyStructField29Patch { - return &MyStructField29Patch{} -} - -var MyStructField29Patch_Assign_DEFAULT []map[string]int32 - -func (p *MyStructField29Patch) GetAssign() []map[string]int32 { - return p.Assign -} - -func (p *MyStructField29Patch) GetClear() bool { - return p.Clear -} - -func (p *MyStructField29Patch) GetPrepend() []map[string]int32 { - return p.Prepend -} - -func (p *MyStructField29Patch) GetAppend() []map[string]int32 { - return p.Append -} -func (p *MyStructField29Patch) IsSetAssign() bool { - return p != nil && p.Assign != nil -} - -type MyStructField29PatchBuilder struct { - obj *MyStructField29Patch -} - -func NewMyStructField29PatchBuilder() *MyStructField29PatchBuilder{ - return &MyStructField29PatchBuilder{ - obj: NewMyStructField29Patch(), - } -} - -func (p MyStructField29PatchBuilder) Emit() *MyStructField29Patch{ - return &MyStructField29Patch{ - Assign: p.obj.Assign, - Clear: p.obj.Clear, - Prepend: p.obj.Prepend, - Append: p.obj.Append, - } -} - -func (m *MyStructField29PatchBuilder) Assign(assign []map[string]int32) *MyStructField29PatchBuilder { - m.obj.Assign = assign - return m -} - -func (m *MyStructField29PatchBuilder) Clear(clear bool) *MyStructField29PatchBuilder { - m.obj.Clear = clear - return m -} - -func (m *MyStructField29PatchBuilder) Prepend(prepend []map[string]int32) *MyStructField29PatchBuilder { - m.obj.Prepend = prepend - return m -} - -func (m *MyStructField29PatchBuilder) Append(append []map[string]int32) *MyStructField29PatchBuilder { - m.obj.Append = append - return m -} - -func (m *MyStructField29Patch) SetAssign(assign []map[string]int32) *MyStructField29Patch { - m.Assign = assign - return m -} - -func (m *MyStructField29Patch) SetClear(clear bool) *MyStructField29Patch { - m.Clear = clear - return m -} - -func (m *MyStructField29Patch) SetPrepend(prepend []map[string]int32) *MyStructField29Patch { - m.Prepend = prepend - return m -} - -func (m *MyStructField29Patch) SetAppend(append []map[string]int32) *MyStructField29Patch { - m.Append = append - return m -} - -func (p *MyStructField29Patch) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 8: - if err := p.ReadField8(iprot); err != nil { - return err - } - case 9: - if err := p.ReadField9(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyStructField29Patch) ReadField1(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]map[string]int32, 0, size) - p.Assign = tSlice - for i := 0; i < size; i ++ { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[string]int32, size) - _elem35 := tMap - for i := 0; i < size; i ++ { - var _key36 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key36 = v - } - var _val37 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _val37 = v - } - _elem35[_key36] = _val37 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - p.Assign = append(p.Assign, _elem35) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *MyStructField29Patch) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Clear = v - } - return nil -} - -func (p *MyStructField29Patch) ReadField8(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]map[string]int32, 0, size) - p.Prepend = tSlice - for i := 0; i < size; i ++ { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[string]int32, size) - _elem38 := tMap - for i := 0; i < size; i ++ { - var _key39 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key39 = v - } - var _val40 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _val40 = v - } - _elem38[_key39] = _val40 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - p.Prepend = append(p.Prepend, _elem38) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *MyStructField29Patch) ReadField9(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]map[string]int32, 0, size) - p.Append = tSlice - for i := 0; i < size; i ++ { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[string]int32, size) - _elem41 := tMap - for i := 0; i < size; i ++ { - var _key42 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key42 = v - } - var _val43 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _val43 = v - } - _elem41[_key42] = _val43 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - p.Append = append(p.Append, _elem41) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *MyStructField29Patch) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("MyStructField29Patch"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField8(oprot); err != nil { return err } - if err := p.writeField9(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyStructField29Patch) writeField1(oprot thrift.Protocol) (err error) { - if p.IsSetAssign() { - if err := oprot.WriteFieldBegin("assign", thrift.LIST, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:assign: ", p), err) } - if err := oprot.WriteListBegin(thrift.MAP, len(p.Assign)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.Assign { - if err := oprot.WriteMapBegin(thrift.STRING, thrift.I32, len(v)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range v { - if err := oprot.WriteString(string(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := oprot.WriteI32(int32(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:assign: ", p), err) } - } - return err -} - -func (p *MyStructField29Patch) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("clear", thrift.BOOL, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:clear: ", p), err) } - if err := oprot.WriteBool(bool(p.Clear)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.clear (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:clear: ", p), err) } - return err -} - -func (p *MyStructField29Patch) writeField8(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("prepend", thrift.LIST, 8); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 8:prepend: ", p), err) } - if err := oprot.WriteListBegin(thrift.MAP, len(p.Prepend)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.Prepend { - if err := oprot.WriteMapBegin(thrift.STRING, thrift.I32, len(v)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range v { - if err := oprot.WriteString(string(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := oprot.WriteI32(int32(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 8:prepend: ", p), err) } - return err -} - -func (p *MyStructField29Patch) writeField9(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("append", thrift.LIST, 9); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 9:append: ", p), err) } - if err := oprot.WriteListBegin(thrift.MAP, len(p.Append)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.Append { - if err := oprot.WriteMapBegin(thrift.STRING, thrift.I32, len(v)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range v { - if err := oprot.WriteString(string(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := oprot.WriteI32(int32(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 9:append: ", p), err) } - return err -} - -func (p *MyStructField29Patch) String() string { - if p == nil { - return "" - } - - assignVal := fmt.Sprintf("%v", p.Assign) - clearVal := fmt.Sprintf("%v", p.Clear) - prependVal := fmt.Sprintf("%v", p.Prepend) - appendVal := fmt.Sprintf("%v", p.Append) - return fmt.Sprintf("MyStructField29Patch({Assign:%s Clear:%s Prepend:%s Append:%s})", assignVal, clearVal, prependVal, appendVal) -} - -// Attributes: -// - Assign: Assigns to a (set) value. -// -// If set, all other operations are ignored. -// -// Note: Optional and union fields must be set before assigned. -// -// - Clear: Clears a value. Applies first. -// - PatchPrior: Patches any previously set values. Applies second. -// - Add: Add the given values, if the keys are not already present. Applies forth. -// - Patch: Patches any set value, including newly set values. Applies last. -// - Remove: Removes entries, if present. Applies third. -// - Put: Adds or replaces the given key/value pairs. Applies fifth. -type MyStructField30Patch struct { - Assign map[string]map[string]int32 `thrift:"assign,1,optional" db:"assign" json:"assign,omitempty"` - Clear bool `thrift:"clear,2" db:"clear" json:"clear"` - PatchPrior map[string]*MyStructField30Patch1 `thrift:"patchPrior,3" db:"patchPrior" json:"patchPrior"` - // unused field # 4 - Add map[string]map[string]int32 `thrift:"add,5" db:"add" json:"add"` - Patch map[string]*MyStructField30Patch1 `thrift:"patch,6" db:"patch" json:"patch"` - Remove []string `thrift:"remove,7" db:"remove" json:"remove"` - // unused field # 8 - Put map[string]map[string]int32 `thrift:"put,9" db:"put" json:"put"` -} - -func NewMyStructField30Patch() *MyStructField30Patch { - return &MyStructField30Patch{} -} - -var MyStructField30Patch_Assign_DEFAULT map[string]map[string]int32 - -func (p *MyStructField30Patch) GetAssign() map[string]map[string]int32 { - return p.Assign -} - -func (p *MyStructField30Patch) GetClear() bool { - return p.Clear -} - -func (p *MyStructField30Patch) GetPatchPrior() map[string]*MyStructField30Patch1 { - return p.PatchPrior -} - -func (p *MyStructField30Patch) GetAdd() map[string]map[string]int32 { - return p.Add -} - -func (p *MyStructField30Patch) GetPatch() map[string]*MyStructField30Patch1 { - return p.Patch -} - -func (p *MyStructField30Patch) GetRemove() []string { - return p.Remove -} - -func (p *MyStructField30Patch) GetPut() map[string]map[string]int32 { - return p.Put -} -func (p *MyStructField30Patch) IsSetAssign() bool { - return p != nil && p.Assign != nil -} - -type MyStructField30PatchBuilder struct { - obj *MyStructField30Patch -} - -func NewMyStructField30PatchBuilder() *MyStructField30PatchBuilder{ - return &MyStructField30PatchBuilder{ - obj: NewMyStructField30Patch(), - } -} - -func (p MyStructField30PatchBuilder) Emit() *MyStructField30Patch{ - return &MyStructField30Patch{ - Assign: p.obj.Assign, - Clear: p.obj.Clear, - PatchPrior: p.obj.PatchPrior, - Add: p.obj.Add, - Patch: p.obj.Patch, - Remove: p.obj.Remove, - Put: p.obj.Put, - } -} - -func (m *MyStructField30PatchBuilder) Assign(assign map[string]map[string]int32) *MyStructField30PatchBuilder { - m.obj.Assign = assign - return m -} - -func (m *MyStructField30PatchBuilder) Clear(clear bool) *MyStructField30PatchBuilder { - m.obj.Clear = clear - return m -} - -func (m *MyStructField30PatchBuilder) PatchPrior(patchPrior map[string]*MyStructField30Patch1) *MyStructField30PatchBuilder { - m.obj.PatchPrior = patchPrior - return m -} - -func (m *MyStructField30PatchBuilder) Add(add map[string]map[string]int32) *MyStructField30PatchBuilder { - m.obj.Add = add - return m -} - -func (m *MyStructField30PatchBuilder) Patch(patch map[string]*MyStructField30Patch1) *MyStructField30PatchBuilder { - m.obj.Patch = patch - return m -} - -func (m *MyStructField30PatchBuilder) Remove(remove []string) *MyStructField30PatchBuilder { - m.obj.Remove = remove - return m -} - -func (m *MyStructField30PatchBuilder) Put(put map[string]map[string]int32) *MyStructField30PatchBuilder { - m.obj.Put = put - return m -} - -func (m *MyStructField30Patch) SetAssign(assign map[string]map[string]int32) *MyStructField30Patch { - m.Assign = assign - return m -} - -func (m *MyStructField30Patch) SetClear(clear bool) *MyStructField30Patch { - m.Clear = clear - return m -} - -func (m *MyStructField30Patch) SetPatchPrior(patchPrior map[string]*MyStructField30Patch1) *MyStructField30Patch { - m.PatchPrior = patchPrior - return m -} - -func (m *MyStructField30Patch) SetAdd(add map[string]map[string]int32) *MyStructField30Patch { - m.Add = add - return m -} - -func (m *MyStructField30Patch) SetPatch(patch map[string]*MyStructField30Patch1) *MyStructField30Patch { - m.Patch = patch - return m -} - -func (m *MyStructField30Patch) SetRemove(remove []string) *MyStructField30Patch { - m.Remove = remove - return m -} - -func (m *MyStructField30Patch) SetPut(put map[string]map[string]int32) *MyStructField30Patch { - m.Put = put - return m -} - -func (p *MyStructField30Patch) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 3: - if err := p.ReadField3(iprot); err != nil { - return err - } - case 5: - if err := p.ReadField5(iprot); err != nil { - return err - } - case 6: - if err := p.ReadField6(iprot); err != nil { - return err - } - case 7: - if err := p.ReadField7(iprot); err != nil { - return err - } - case 9: - if err := p.ReadField9(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyStructField30Patch) ReadField1(iprot thrift.Protocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[string]map[string]int32, size) - p.Assign = tMap - for i := 0; i < size; i ++ { - var _key44 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key44 = v - } - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[string]int32, size) - _val45 := tMap - for i := 0; i < size; i ++ { - var _key46 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key46 = v - } - var _val47 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _val47 = v - } - _val45[_key46] = _val47 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - p.Assign[_key44] = _val45 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *MyStructField30Patch) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Clear = v - } - return nil -} - -func (p *MyStructField30Patch) ReadField3(iprot thrift.Protocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[string]*MyStructField30Patch1, size) - p.PatchPrior = tMap - for i := 0; i < size; i ++ { - var _key48 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key48 = v - } - _val49 := NewMyStructField30Patch1() - if err := _val49.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _val49), err) - } - p.PatchPrior[_key48] = _val49 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *MyStructField30Patch) ReadField5(iprot thrift.Protocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[string]map[string]int32, size) - p.Add = tMap - for i := 0; i < size; i ++ { - var _key50 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key50 = v - } - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[string]int32, size) - _val51 := tMap - for i := 0; i < size; i ++ { - var _key52 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key52 = v - } - var _val53 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _val53 = v - } - _val51[_key52] = _val53 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - p.Add[_key50] = _val51 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *MyStructField30Patch) ReadField6(iprot thrift.Protocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[string]*MyStructField30Patch1, size) - p.Patch = tMap - for i := 0; i < size; i ++ { - var _key54 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key54 = v - } - _val55 := NewMyStructField30Patch1() - if err := _val55.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _val55), err) - } - p.Patch[_key54] = _val55 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *MyStructField30Patch) ReadField7(iprot thrift.Protocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return thrift.PrependError("error reading set begin: ", err) - } - tSet := make([]string, 0, size) - p.Remove = tSet - for i := 0; i < size; i ++ { - var _elem56 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem56 = v - } - p.Remove = append(p.Remove, _elem56) - } - if err := iprot.ReadSetEnd(); err != nil { - return thrift.PrependError("error reading set end: ", err) - } - return nil -} - -func (p *MyStructField30Patch) ReadField9(iprot thrift.Protocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[string]map[string]int32, size) - p.Put = tMap - for i := 0; i < size; i ++ { - var _key57 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key57 = v - } - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[string]int32, size) - _val58 := tMap - for i := 0; i < size; i ++ { - var _key59 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key59 = v - } - var _val60 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _val60 = v - } - _val58[_key59] = _val60 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - p.Put[_key57] = _val58 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *MyStructField30Patch) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("MyStructField30Patch"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := p.writeField5(oprot); err != nil { return err } - if err := p.writeField6(oprot); err != nil { return err } - if err := p.writeField7(oprot); err != nil { return err } - if err := p.writeField9(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyStructField30Patch) writeField1(oprot thrift.Protocol) (err error) { - if p.IsSetAssign() { - if err := oprot.WriteFieldBegin("assign", thrift.MAP, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:assign: ", p), err) } - if err := oprot.WriteMapBegin(thrift.STRING, thrift.MAP, len(p.Assign)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.Assign { - if err := oprot.WriteString(string(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := oprot.WriteMapBegin(thrift.STRING, thrift.I32, len(v)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range v { - if err := oprot.WriteString(string(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := oprot.WriteI32(int32(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:assign: ", p), err) } - } - return err -} - -func (p *MyStructField30Patch) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("clear", thrift.BOOL, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:clear: ", p), err) } - if err := oprot.WriteBool(bool(p.Clear)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.clear (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:clear: ", p), err) } - return err -} - -func (p *MyStructField30Patch) writeField3(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("patchPrior", thrift.MAP, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:patchPrior: ", p), err) } - if err := oprot.WriteMapBegin(thrift.STRING, thrift.STRUCT, len(p.PatchPrior)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.PatchPrior { - if err := oprot.WriteString(string(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := v.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) - } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:patchPrior: ", p), err) } - return err -} - -func (p *MyStructField30Patch) writeField5(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("add", thrift.MAP, 5); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:add: ", p), err) } - if err := oprot.WriteMapBegin(thrift.STRING, thrift.MAP, len(p.Add)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.Add { - if err := oprot.WriteString(string(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := oprot.WriteMapBegin(thrift.STRING, thrift.I32, len(v)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range v { - if err := oprot.WriteString(string(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := oprot.WriteI32(int32(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 5:add: ", p), err) } - return err -} - -func (p *MyStructField30Patch) writeField6(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("patch", thrift.MAP, 6); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 6:patch: ", p), err) } - if err := oprot.WriteMapBegin(thrift.STRING, thrift.STRUCT, len(p.Patch)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.Patch { - if err := oprot.WriteString(string(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := v.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) - } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 6:patch: ", p), err) } - return err -} - -func (p *MyStructField30Patch) writeField7(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("remove", thrift.SET, 7); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 7:remove: ", p), err) } - if err := oprot.WriteSetBegin(thrift.STRING, len(p.Remove)); err != nil { - return thrift.PrependError("error writing set begin: ", err) - } - set := make(map[string]bool, len(p.Remove)) - for _, v := range p.Remove { - if ok := set[v]; ok { - return thrift.PrependError("", fmt.Errorf("%T error writing set field: slice is not unique", v)) - } - set[v] = true - } - for _, v := range p.Remove { - if err := oprot.WriteString(string(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteSetEnd(); err != nil { - return thrift.PrependError("error writing set end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 7:remove: ", p), err) } - return err -} - -func (p *MyStructField30Patch) writeField9(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("put", thrift.MAP, 9); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 9:put: ", p), err) } - if err := oprot.WriteMapBegin(thrift.STRING, thrift.MAP, len(p.Put)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.Put { - if err := oprot.WriteString(string(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := oprot.WriteMapBegin(thrift.STRING, thrift.I32, len(v)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range v { - if err := oprot.WriteString(string(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := oprot.WriteI32(int32(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 9:put: ", p), err) } - return err -} - -func (p *MyStructField30Patch) String() string { - if p == nil { - return "" - } - - assignVal := fmt.Sprintf("%v", p.Assign) - clearVal := fmt.Sprintf("%v", p.Clear) - patchPriorVal := fmt.Sprintf("%v", p.PatchPrior) - addVal := fmt.Sprintf("%v", p.Add) - patchVal := fmt.Sprintf("%v", p.Patch) - removeVal := fmt.Sprintf("%v", p.Remove) - putVal := fmt.Sprintf("%v", p.Put) - return fmt.Sprintf("MyStructField30Patch({Assign:%s Clear:%s PatchPrior:%s Add:%s Patch:%s Remove:%s Put:%s})", assignVal, clearVal, patchPriorVal, addVal, patchVal, removeVal, putVal) -} - -// Attributes: -// - Assign: Assigns to a (set) value. -// -// If set, all other operations are ignored. -// -// Note: Optional and union fields must be set before assigned. -// -// - Clear: Clears a value. Applies first. -// - PatchPrior: Patches any previously set values. Applies second. -// - Add: Add the given values, if the keys are not already present. Applies forth. -// - Patch: Patches any set value, including newly set values. Applies last. -// - Remove: Removes entries, if present. Applies third. -// - Put: Adds or replaces the given key/value pairs. Applies fifth. -type MyStructField30Patch1 struct { - Assign map[string]int32 `thrift:"assign,1,optional" db:"assign" json:"assign,omitempty"` - Clear bool `thrift:"clear,2" db:"clear" json:"clear"` - PatchPrior map[string]*patch0.I32Patch `thrift:"patchPrior,3" db:"patchPrior" json:"patchPrior"` - // unused field # 4 - Add map[string]int32 `thrift:"add,5" db:"add" json:"add"` - Patch map[string]*patch0.I32Patch `thrift:"patch,6" db:"patch" json:"patch"` - Remove []string `thrift:"remove,7" db:"remove" json:"remove"` - // unused field # 8 - Put map[string]int32 `thrift:"put,9" db:"put" json:"put"` -} - -func NewMyStructField30Patch1() *MyStructField30Patch1 { - return &MyStructField30Patch1{} -} - -var MyStructField30Patch1_Assign_DEFAULT map[string]int32 - -func (p *MyStructField30Patch1) GetAssign() map[string]int32 { - return p.Assign -} - -func (p *MyStructField30Patch1) GetClear() bool { - return p.Clear -} - -func (p *MyStructField30Patch1) GetPatchPrior() map[string]*patch0.I32Patch { - return p.PatchPrior -} - -func (p *MyStructField30Patch1) GetAdd() map[string]int32 { - return p.Add -} - -func (p *MyStructField30Patch1) GetPatch() map[string]*patch0.I32Patch { - return p.Patch -} - -func (p *MyStructField30Patch1) GetRemove() []string { - return p.Remove -} - -func (p *MyStructField30Patch1) GetPut() map[string]int32 { - return p.Put -} -func (p *MyStructField30Patch1) IsSetAssign() bool { - return p != nil && p.Assign != nil -} - -type MyStructField30Patch1Builder struct { - obj *MyStructField30Patch1 -} - -func NewMyStructField30Patch1Builder() *MyStructField30Patch1Builder{ - return &MyStructField30Patch1Builder{ - obj: NewMyStructField30Patch1(), - } -} - -func (p MyStructField30Patch1Builder) Emit() *MyStructField30Patch1{ - return &MyStructField30Patch1{ - Assign: p.obj.Assign, - Clear: p.obj.Clear, - PatchPrior: p.obj.PatchPrior, - Add: p.obj.Add, - Patch: p.obj.Patch, - Remove: p.obj.Remove, - Put: p.obj.Put, - } -} - -func (m *MyStructField30Patch1Builder) Assign(assign map[string]int32) *MyStructField30Patch1Builder { - m.obj.Assign = assign - return m -} - -func (m *MyStructField30Patch1Builder) Clear(clear bool) *MyStructField30Patch1Builder { - m.obj.Clear = clear - return m -} - -func (m *MyStructField30Patch1Builder) PatchPrior(patchPrior map[string]*patch0.I32Patch) *MyStructField30Patch1Builder { - m.obj.PatchPrior = patchPrior - return m -} - -func (m *MyStructField30Patch1Builder) Add(add map[string]int32) *MyStructField30Patch1Builder { - m.obj.Add = add - return m -} - -func (m *MyStructField30Patch1Builder) Patch(patch map[string]*patch0.I32Patch) *MyStructField30Patch1Builder { - m.obj.Patch = patch - return m -} - -func (m *MyStructField30Patch1Builder) Remove(remove []string) *MyStructField30Patch1Builder { - m.obj.Remove = remove - return m -} - -func (m *MyStructField30Patch1Builder) Put(put map[string]int32) *MyStructField30Patch1Builder { - m.obj.Put = put - return m -} - -func (m *MyStructField30Patch1) SetAssign(assign map[string]int32) *MyStructField30Patch1 { - m.Assign = assign - return m -} - -func (m *MyStructField30Patch1) SetClear(clear bool) *MyStructField30Patch1 { - m.Clear = clear - return m -} - -func (m *MyStructField30Patch1) SetPatchPrior(patchPrior map[string]*patch0.I32Patch) *MyStructField30Patch1 { - m.PatchPrior = patchPrior - return m -} - -func (m *MyStructField30Patch1) SetAdd(add map[string]int32) *MyStructField30Patch1 { - m.Add = add - return m -} - -func (m *MyStructField30Patch1) SetPatch(patch map[string]*patch0.I32Patch) *MyStructField30Patch1 { - m.Patch = patch - return m -} - -func (m *MyStructField30Patch1) SetRemove(remove []string) *MyStructField30Patch1 { - m.Remove = remove - return m -} - -func (m *MyStructField30Patch1) SetPut(put map[string]int32) *MyStructField30Patch1 { - m.Put = put - return m -} - -func (p *MyStructField30Patch1) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 3: - if err := p.ReadField3(iprot); err != nil { - return err - } - case 5: - if err := p.ReadField5(iprot); err != nil { - return err - } - case 6: - if err := p.ReadField6(iprot); err != nil { - return err - } - case 7: - if err := p.ReadField7(iprot); err != nil { - return err - } - case 9: - if err := p.ReadField9(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyStructField30Patch1) ReadField1(iprot thrift.Protocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[string]int32, size) - p.Assign = tMap - for i := 0; i < size; i ++ { - var _key61 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key61 = v - } - var _val62 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _val62 = v - } - p.Assign[_key61] = _val62 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *MyStructField30Patch1) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Clear = v - } - return nil -} - -func (p *MyStructField30Patch1) ReadField3(iprot thrift.Protocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[string]*patch0.I32Patch, size) - p.PatchPrior = tMap - for i := 0; i < size; i ++ { - var _key63 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key63 = v - } - _val64 := patch0.NewI32Patch() - if err := _val64.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _val64), err) - } - p.PatchPrior[_key63] = _val64 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *MyStructField30Patch1) ReadField5(iprot thrift.Protocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[string]int32, size) - p.Add = tMap - for i := 0; i < size; i ++ { - var _key65 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key65 = v - } - var _val66 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _val66 = v - } - p.Add[_key65] = _val66 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *MyStructField30Patch1) ReadField6(iprot thrift.Protocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[string]*patch0.I32Patch, size) - p.Patch = tMap - for i := 0; i < size; i ++ { - var _key67 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key67 = v - } - _val68 := patch0.NewI32Patch() - if err := _val68.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _val68), err) - } - p.Patch[_key67] = _val68 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *MyStructField30Patch1) ReadField7(iprot thrift.Protocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return thrift.PrependError("error reading set begin: ", err) - } - tSet := make([]string, 0, size) - p.Remove = tSet - for i := 0; i < size; i ++ { - var _elem69 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem69 = v - } - p.Remove = append(p.Remove, _elem69) - } - if err := iprot.ReadSetEnd(); err != nil { - return thrift.PrependError("error reading set end: ", err) - } - return nil -} - -func (p *MyStructField30Patch1) ReadField9(iprot thrift.Protocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[string]int32, size) - p.Put = tMap - for i := 0; i < size; i ++ { - var _key70 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key70 = v - } - var _val71 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _val71 = v - } - p.Put[_key70] = _val71 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *MyStructField30Patch1) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("MyStructField30Patch1"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := p.writeField5(oprot); err != nil { return err } - if err := p.writeField6(oprot); err != nil { return err } - if err := p.writeField7(oprot); err != nil { return err } - if err := p.writeField9(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyStructField30Patch1) writeField1(oprot thrift.Protocol) (err error) { - if p.IsSetAssign() { - if err := oprot.WriteFieldBegin("assign", thrift.MAP, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:assign: ", p), err) } - if err := oprot.WriteMapBegin(thrift.STRING, thrift.I32, len(p.Assign)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.Assign { - if err := oprot.WriteString(string(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := oprot.WriteI32(int32(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:assign: ", p), err) } - } - return err -} - -func (p *MyStructField30Patch1) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("clear", thrift.BOOL, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:clear: ", p), err) } - if err := oprot.WriteBool(bool(p.Clear)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.clear (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:clear: ", p), err) } - return err -} - -func (p *MyStructField30Patch1) writeField3(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("patchPrior", thrift.MAP, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:patchPrior: ", p), err) } - if err := oprot.WriteMapBegin(thrift.STRING, thrift.STRUCT, len(p.PatchPrior)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.PatchPrior { - if err := oprot.WriteString(string(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := v.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) - } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:patchPrior: ", p), err) } - return err -} - -func (p *MyStructField30Patch1) writeField5(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("add", thrift.MAP, 5); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:add: ", p), err) } - if err := oprot.WriteMapBegin(thrift.STRING, thrift.I32, len(p.Add)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.Add { - if err := oprot.WriteString(string(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := oprot.WriteI32(int32(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 5:add: ", p), err) } - return err -} - -func (p *MyStructField30Patch1) writeField6(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("patch", thrift.MAP, 6); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 6:patch: ", p), err) } - if err := oprot.WriteMapBegin(thrift.STRING, thrift.STRUCT, len(p.Patch)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.Patch { - if err := oprot.WriteString(string(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := v.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) - } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 6:patch: ", p), err) } - return err -} - -func (p *MyStructField30Patch1) writeField7(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("remove", thrift.SET, 7); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 7:remove: ", p), err) } - if err := oprot.WriteSetBegin(thrift.STRING, len(p.Remove)); err != nil { - return thrift.PrependError("error writing set begin: ", err) - } - set := make(map[string]bool, len(p.Remove)) - for _, v := range p.Remove { - if ok := set[v]; ok { - return thrift.PrependError("", fmt.Errorf("%T error writing set field: slice is not unique", v)) - } - set[v] = true - } - for _, v := range p.Remove { - if err := oprot.WriteString(string(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteSetEnd(); err != nil { - return thrift.PrependError("error writing set end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 7:remove: ", p), err) } - return err -} - -func (p *MyStructField30Patch1) writeField9(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("put", thrift.MAP, 9); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 9:put: ", p), err) } - if err := oprot.WriteMapBegin(thrift.STRING, thrift.I32, len(p.Put)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.Put { - if err := oprot.WriteString(string(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := oprot.WriteI32(int32(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 9:put: ", p), err) } - return err -} - -func (p *MyStructField30Patch1) String() string { - if p == nil { - return "" - } - - assignVal := fmt.Sprintf("%v", p.Assign) - clearVal := fmt.Sprintf("%v", p.Clear) - patchPriorVal := fmt.Sprintf("%v", p.PatchPrior) - addVal := fmt.Sprintf("%v", p.Add) - patchVal := fmt.Sprintf("%v", p.Patch) - removeVal := fmt.Sprintf("%v", p.Remove) - putVal := fmt.Sprintf("%v", p.Put) - return fmt.Sprintf("MyStructField30Patch1({Assign:%s Clear:%s PatchPrior:%s Add:%s Patch:%s Remove:%s Put:%s})", assignVal, clearVal, patchPriorVal, addVal, patchVal, removeVal, putVal) -} - -// Attributes: -// - StructWithCustomDefault -// - I32WithCustomDefault -// - MapMap -// - ListMap -// - OptMapVal -// - OptSetVal -// - OptListVal -// - OptLateStructVal -// - OptStructVal -// - OptEnumVal -// - OptBinaryVal -// - OptStringVal -// - OptDoubleVal -// - OptFloatVal -// - OptI64Val -// - OptI32Val -// - OptI16Val -// - OptByteVal -// - OptBoolVal -// - LateStructVal -// - UnionVal -// - StructVal -// - EnumVal -// - BinaryVal -// - StringVal -// - DoubleVal -// - FloatVal -// - I64Val -// - I32Val -// - I16Val -// - ByteVal -// - BoolVal -// - StructWithFieldCustomDefault -type MyStructFieldPatch struct { - StructWithCustomDefault *MyDataWithCustomDefaultPatch - I32WithCustomDefault *patch0.I32Patch - MapMap *MyStructField30Patch - ListMap *MyStructField29Patch - OptMapVal *MyStructField28Patch - OptSetVal *MyStructField27Patch - OptListVal *MyStructField26Patch - OptLateStructVal *LateDefStructPatch - OptStructVal *MyDataPatch - OptEnumVal *MyStructField23Patch - OptBinaryVal *patch0.BinaryPatch - OptStringVal *patch0.StringPatch - OptDoubleVal *patch0.DoublePatch - OptFloatVal *patch0.FloatPatch - OptI64Val *patch0.I64Patch - OptI32Val *patch0.I32Patch - OptI16Val *patch0.I16Patch - OptByteVal *patch0.BytePatch - OptBoolVal *patch0.BoolPatch - LateStructVal *LateDefStructPatch - UnionVal *MyUnionPatch - StructVal *MyDataPatch - EnumVal *MyStructField10Patch - BinaryVal *patch0.BinaryPatch - StringVal *patch0.StringPatch - DoubleVal *patch0.DoublePatch - FloatVal *patch0.FloatPatch - I64Val *patch0.I64Patch - I32Val *patch0.I32Patch - I16Val *patch0.I16Patch - ByteVal *patch0.BytePatch - BoolVal *patch0.BoolPatch - StructWithFieldCustomDefault *MyDataPatch -} - -func NewMyStructFieldPatch() *MyStructFieldPatch { - return &MyStructFieldPatch{ - StructWithCustomDefault: NewMyDataWithCustomDefaultPatch(), - I32WithCustomDefault: patch0.NewI32Patch(), - MapMap: NewMyStructField30Patch(), - ListMap: NewMyStructField29Patch(), - OptMapVal: NewMyStructField28Patch(), - OptSetVal: NewMyStructField27Patch(), - OptListVal: NewMyStructField26Patch(), - OptLateStructVal: NewLateDefStructPatch(), - OptStructVal: NewMyDataPatch(), - OptEnumVal: NewMyStructField23Patch(), - OptBinaryVal: patch0.NewBinaryPatch(), - OptStringVal: patch0.NewStringPatch(), - OptDoubleVal: patch0.NewDoublePatch(), - OptFloatVal: patch0.NewFloatPatch(), - OptI64Val: patch0.NewI64Patch(), - OptI32Val: patch0.NewI32Patch(), - OptI16Val: patch0.NewI16Patch(), - OptByteVal: patch0.NewBytePatch(), - OptBoolVal: patch0.NewBoolPatch(), - LateStructVal: NewLateDefStructPatch(), - UnionVal: NewMyUnionPatch(), - StructVal: NewMyDataPatch(), - EnumVal: NewMyStructField10Patch(), - BinaryVal: patch0.NewBinaryPatch(), - StringVal: patch0.NewStringPatch(), - DoubleVal: patch0.NewDoublePatch(), - FloatVal: patch0.NewFloatPatch(), - I64Val: patch0.NewI64Patch(), - I32Val: patch0.NewI32Patch(), - I16Val: patch0.NewI16Patch(), - ByteVal: patch0.NewBytePatch(), - BoolVal: patch0.NewBoolPatch(), - StructWithFieldCustomDefault: NewMyDataPatch(), - } -} - -var MyStructFieldPatch_StructWithCustomDefault_DEFAULT *MyDataWithCustomDefaultPatch -func (p *MyStructFieldPatch) GetStructWithCustomDefault() *MyDataWithCustomDefaultPatch { - if !p.IsSetStructWithCustomDefault() { - return MyStructFieldPatch_StructWithCustomDefault_DEFAULT - } - return p.StructWithCustomDefault -} -func (p *MyStructFieldPatch) DefaultGetStructWithCustomDefault() *MyDataWithCustomDefaultPatch { - if !p.IsSetStructWithCustomDefault() { - return NewMyDataWithCustomDefaultPatch() - } - return p.StructWithCustomDefault -} -var MyStructFieldPatch_I32WithCustomDefault_DEFAULT *patch0.I32Patch -func (p *MyStructFieldPatch) GetI32WithCustomDefault() *patch0.I32Patch { - if !p.IsSetI32WithCustomDefault() { - return MyStructFieldPatch_I32WithCustomDefault_DEFAULT - } - return p.I32WithCustomDefault -} -func (p *MyStructFieldPatch) DefaultGetI32WithCustomDefault() *patch0.I32Patch { - if !p.IsSetI32WithCustomDefault() { - return patch0.NewI32Patch() - } - return p.I32WithCustomDefault -} -var MyStructFieldPatch_MapMap_DEFAULT *MyStructField30Patch -func (p *MyStructFieldPatch) GetMapMap() *MyStructField30Patch { - if !p.IsSetMapMap() { - return MyStructFieldPatch_MapMap_DEFAULT - } - return p.MapMap -} -func (p *MyStructFieldPatch) DefaultGetMapMap() *MyStructField30Patch { - if !p.IsSetMapMap() { - return NewMyStructField30Patch() - } - return p.MapMap -} -var MyStructFieldPatch_ListMap_DEFAULT *MyStructField29Patch -func (p *MyStructFieldPatch) GetListMap() *MyStructField29Patch { - if !p.IsSetListMap() { - return MyStructFieldPatch_ListMap_DEFAULT - } - return p.ListMap -} -func (p *MyStructFieldPatch) DefaultGetListMap() *MyStructField29Patch { - if !p.IsSetListMap() { - return NewMyStructField29Patch() - } - return p.ListMap -} -var MyStructFieldPatch_OptMapVal_DEFAULT *MyStructField28Patch -func (p *MyStructFieldPatch) GetOptMapVal() *MyStructField28Patch { - if !p.IsSetOptMapVal() { - return MyStructFieldPatch_OptMapVal_DEFAULT - } - return p.OptMapVal -} -func (p *MyStructFieldPatch) DefaultGetOptMapVal() *MyStructField28Patch { - if !p.IsSetOptMapVal() { - return NewMyStructField28Patch() - } - return p.OptMapVal -} -var MyStructFieldPatch_OptSetVal_DEFAULT *MyStructField27Patch -func (p *MyStructFieldPatch) GetOptSetVal() *MyStructField27Patch { - if !p.IsSetOptSetVal() { - return MyStructFieldPatch_OptSetVal_DEFAULT - } - return p.OptSetVal -} -func (p *MyStructFieldPatch) DefaultGetOptSetVal() *MyStructField27Patch { - if !p.IsSetOptSetVal() { - return NewMyStructField27Patch() - } - return p.OptSetVal -} -var MyStructFieldPatch_OptListVal_DEFAULT *MyStructField26Patch -func (p *MyStructFieldPatch) GetOptListVal() *MyStructField26Patch { - if !p.IsSetOptListVal() { - return MyStructFieldPatch_OptListVal_DEFAULT - } - return p.OptListVal -} -func (p *MyStructFieldPatch) DefaultGetOptListVal() *MyStructField26Patch { - if !p.IsSetOptListVal() { - return NewMyStructField26Patch() - } - return p.OptListVal -} -var MyStructFieldPatch_OptLateStructVal_DEFAULT *LateDefStructPatch -func (p *MyStructFieldPatch) GetOptLateStructVal() *LateDefStructPatch { - if !p.IsSetOptLateStructVal() { - return MyStructFieldPatch_OptLateStructVal_DEFAULT - } - return p.OptLateStructVal -} -var MyStructFieldPatch_OptStructVal_DEFAULT *MyDataPatch -func (p *MyStructFieldPatch) GetOptStructVal() *MyDataPatch { - if !p.IsSetOptStructVal() { - return MyStructFieldPatch_OptStructVal_DEFAULT - } - return p.OptStructVal -} -func (p *MyStructFieldPatch) DefaultGetOptStructVal() *MyDataPatch { - if !p.IsSetOptStructVal() { - return NewMyDataPatch() - } - return p.OptStructVal -} -var MyStructFieldPatch_OptEnumVal_DEFAULT *MyStructField23Patch -func (p *MyStructFieldPatch) GetOptEnumVal() *MyStructField23Patch { - if !p.IsSetOptEnumVal() { - return MyStructFieldPatch_OptEnumVal_DEFAULT - } - return p.OptEnumVal -} -func (p *MyStructFieldPatch) DefaultGetOptEnumVal() *MyStructField23Patch { - if !p.IsSetOptEnumVal() { - return NewMyStructField23Patch() - } - return p.OptEnumVal -} -var MyStructFieldPatch_OptBinaryVal_DEFAULT *patch0.BinaryPatch -func (p *MyStructFieldPatch) GetOptBinaryVal() *patch0.BinaryPatch { - if !p.IsSetOptBinaryVal() { - return MyStructFieldPatch_OptBinaryVal_DEFAULT - } - return p.OptBinaryVal -} -func (p *MyStructFieldPatch) DefaultGetOptBinaryVal() *patch0.BinaryPatch { - if !p.IsSetOptBinaryVal() { - return patch0.NewBinaryPatch() - } - return p.OptBinaryVal -} -var MyStructFieldPatch_OptStringVal_DEFAULT *patch0.StringPatch -func (p *MyStructFieldPatch) GetOptStringVal() *patch0.StringPatch { - if !p.IsSetOptStringVal() { - return MyStructFieldPatch_OptStringVal_DEFAULT - } - return p.OptStringVal -} -func (p *MyStructFieldPatch) DefaultGetOptStringVal() *patch0.StringPatch { - if !p.IsSetOptStringVal() { - return patch0.NewStringPatch() - } - return p.OptStringVal -} -var MyStructFieldPatch_OptDoubleVal_DEFAULT *patch0.DoublePatch -func (p *MyStructFieldPatch) GetOptDoubleVal() *patch0.DoublePatch { - if !p.IsSetOptDoubleVal() { - return MyStructFieldPatch_OptDoubleVal_DEFAULT - } - return p.OptDoubleVal -} -func (p *MyStructFieldPatch) DefaultGetOptDoubleVal() *patch0.DoublePatch { - if !p.IsSetOptDoubleVal() { - return patch0.NewDoublePatch() - } - return p.OptDoubleVal -} -var MyStructFieldPatch_OptFloatVal_DEFAULT *patch0.FloatPatch -func (p *MyStructFieldPatch) GetOptFloatVal() *patch0.FloatPatch { - if !p.IsSetOptFloatVal() { - return MyStructFieldPatch_OptFloatVal_DEFAULT - } - return p.OptFloatVal -} -func (p *MyStructFieldPatch) DefaultGetOptFloatVal() *patch0.FloatPatch { - if !p.IsSetOptFloatVal() { - return patch0.NewFloatPatch() - } - return p.OptFloatVal -} -var MyStructFieldPatch_OptI64Val_DEFAULT *patch0.I64Patch -func (p *MyStructFieldPatch) GetOptI64Val() *patch0.I64Patch { - if !p.IsSetOptI64Val() { - return MyStructFieldPatch_OptI64Val_DEFAULT - } - return p.OptI64Val -} -func (p *MyStructFieldPatch) DefaultGetOptI64Val() *patch0.I64Patch { - if !p.IsSetOptI64Val() { - return patch0.NewI64Patch() - } - return p.OptI64Val -} -var MyStructFieldPatch_OptI32Val_DEFAULT *patch0.I32Patch -func (p *MyStructFieldPatch) GetOptI32Val() *patch0.I32Patch { - if !p.IsSetOptI32Val() { - return MyStructFieldPatch_OptI32Val_DEFAULT - } - return p.OptI32Val -} -func (p *MyStructFieldPatch) DefaultGetOptI32Val() *patch0.I32Patch { - if !p.IsSetOptI32Val() { - return patch0.NewI32Patch() - } - return p.OptI32Val -} -var MyStructFieldPatch_OptI16Val_DEFAULT *patch0.I16Patch -func (p *MyStructFieldPatch) GetOptI16Val() *patch0.I16Patch { - if !p.IsSetOptI16Val() { - return MyStructFieldPatch_OptI16Val_DEFAULT - } - return p.OptI16Val -} -func (p *MyStructFieldPatch) DefaultGetOptI16Val() *patch0.I16Patch { - if !p.IsSetOptI16Val() { - return patch0.NewI16Patch() - } - return p.OptI16Val -} -var MyStructFieldPatch_OptByteVal_DEFAULT *patch0.BytePatch -func (p *MyStructFieldPatch) GetOptByteVal() *patch0.BytePatch { - if !p.IsSetOptByteVal() { - return MyStructFieldPatch_OptByteVal_DEFAULT - } - return p.OptByteVal -} -func (p *MyStructFieldPatch) DefaultGetOptByteVal() *patch0.BytePatch { - if !p.IsSetOptByteVal() { - return patch0.NewBytePatch() - } - return p.OptByteVal -} -var MyStructFieldPatch_OptBoolVal_DEFAULT *patch0.BoolPatch -func (p *MyStructFieldPatch) GetOptBoolVal() *patch0.BoolPatch { - if !p.IsSetOptBoolVal() { - return MyStructFieldPatch_OptBoolVal_DEFAULT - } - return p.OptBoolVal -} -func (p *MyStructFieldPatch) DefaultGetOptBoolVal() *patch0.BoolPatch { - if !p.IsSetOptBoolVal() { - return patch0.NewBoolPatch() - } - return p.OptBoolVal -} -var MyStructFieldPatch_LateStructVal_DEFAULT *LateDefStructPatch -func (p *MyStructFieldPatch) GetLateStructVal() *LateDefStructPatch { - if !p.IsSetLateStructVal() { - return MyStructFieldPatch_LateStructVal_DEFAULT - } - return p.LateStructVal -} -var MyStructFieldPatch_UnionVal_DEFAULT *MyUnionPatch -func (p *MyStructFieldPatch) GetUnionVal() *MyUnionPatch { - if !p.IsSetUnionVal() { - return MyStructFieldPatch_UnionVal_DEFAULT - } - return p.UnionVal -} -func (p *MyStructFieldPatch) DefaultGetUnionVal() *MyUnionPatch { - if !p.IsSetUnionVal() { - return NewMyUnionPatch() - } - return p.UnionVal -} -var MyStructFieldPatch_StructVal_DEFAULT *MyDataPatch -func (p *MyStructFieldPatch) GetStructVal() *MyDataPatch { - if !p.IsSetStructVal() { - return MyStructFieldPatch_StructVal_DEFAULT - } - return p.StructVal -} -func (p *MyStructFieldPatch) DefaultGetStructVal() *MyDataPatch { - if !p.IsSetStructVal() { - return NewMyDataPatch() - } - return p.StructVal -} -var MyStructFieldPatch_EnumVal_DEFAULT *MyStructField10Patch -func (p *MyStructFieldPatch) GetEnumVal() *MyStructField10Patch { - if !p.IsSetEnumVal() { - return MyStructFieldPatch_EnumVal_DEFAULT - } - return p.EnumVal -} -func (p *MyStructFieldPatch) DefaultGetEnumVal() *MyStructField10Patch { - if !p.IsSetEnumVal() { - return NewMyStructField10Patch() - } - return p.EnumVal -} -var MyStructFieldPatch_BinaryVal_DEFAULT *patch0.BinaryPatch -func (p *MyStructFieldPatch) GetBinaryVal() *patch0.BinaryPatch { - if !p.IsSetBinaryVal() { - return MyStructFieldPatch_BinaryVal_DEFAULT - } - return p.BinaryVal -} -func (p *MyStructFieldPatch) DefaultGetBinaryVal() *patch0.BinaryPatch { - if !p.IsSetBinaryVal() { - return patch0.NewBinaryPatch() - } - return p.BinaryVal -} -var MyStructFieldPatch_StringVal_DEFAULT *patch0.StringPatch -func (p *MyStructFieldPatch) GetStringVal() *patch0.StringPatch { - if !p.IsSetStringVal() { - return MyStructFieldPatch_StringVal_DEFAULT - } - return p.StringVal -} -func (p *MyStructFieldPatch) DefaultGetStringVal() *patch0.StringPatch { - if !p.IsSetStringVal() { - return patch0.NewStringPatch() - } - return p.StringVal -} -var MyStructFieldPatch_DoubleVal_DEFAULT *patch0.DoublePatch -func (p *MyStructFieldPatch) GetDoubleVal() *patch0.DoublePatch { - if !p.IsSetDoubleVal() { - return MyStructFieldPatch_DoubleVal_DEFAULT - } - return p.DoubleVal -} -func (p *MyStructFieldPatch) DefaultGetDoubleVal() *patch0.DoublePatch { - if !p.IsSetDoubleVal() { - return patch0.NewDoublePatch() - } - return p.DoubleVal -} -var MyStructFieldPatch_FloatVal_DEFAULT *patch0.FloatPatch -func (p *MyStructFieldPatch) GetFloatVal() *patch0.FloatPatch { - if !p.IsSetFloatVal() { - return MyStructFieldPatch_FloatVal_DEFAULT - } - return p.FloatVal -} -func (p *MyStructFieldPatch) DefaultGetFloatVal() *patch0.FloatPatch { - if !p.IsSetFloatVal() { - return patch0.NewFloatPatch() - } - return p.FloatVal -} -var MyStructFieldPatch_I64Val_DEFAULT *patch0.I64Patch -func (p *MyStructFieldPatch) GetI64Val() *patch0.I64Patch { - if !p.IsSetI64Val() { - return MyStructFieldPatch_I64Val_DEFAULT - } - return p.I64Val -} -func (p *MyStructFieldPatch) DefaultGetI64Val() *patch0.I64Patch { - if !p.IsSetI64Val() { - return patch0.NewI64Patch() - } - return p.I64Val -} -var MyStructFieldPatch_I32Val_DEFAULT *patch0.I32Patch -func (p *MyStructFieldPatch) GetI32Val() *patch0.I32Patch { - if !p.IsSetI32Val() { - return MyStructFieldPatch_I32Val_DEFAULT - } - return p.I32Val -} -func (p *MyStructFieldPatch) DefaultGetI32Val() *patch0.I32Patch { - if !p.IsSetI32Val() { - return patch0.NewI32Patch() - } - return p.I32Val -} -var MyStructFieldPatch_I16Val_DEFAULT *patch0.I16Patch -func (p *MyStructFieldPatch) GetI16Val() *patch0.I16Patch { - if !p.IsSetI16Val() { - return MyStructFieldPatch_I16Val_DEFAULT - } - return p.I16Val -} -func (p *MyStructFieldPatch) DefaultGetI16Val() *patch0.I16Patch { - if !p.IsSetI16Val() { - return patch0.NewI16Patch() - } - return p.I16Val -} -var MyStructFieldPatch_ByteVal_DEFAULT *patch0.BytePatch -func (p *MyStructFieldPatch) GetByteVal() *patch0.BytePatch { - if !p.IsSetByteVal() { - return MyStructFieldPatch_ByteVal_DEFAULT - } - return p.ByteVal -} -func (p *MyStructFieldPatch) DefaultGetByteVal() *patch0.BytePatch { - if !p.IsSetByteVal() { - return patch0.NewBytePatch() - } - return p.ByteVal -} -var MyStructFieldPatch_BoolVal_DEFAULT *patch0.BoolPatch -func (p *MyStructFieldPatch) GetBoolVal() *patch0.BoolPatch { - if !p.IsSetBoolVal() { - return MyStructFieldPatch_BoolVal_DEFAULT - } - return p.BoolVal -} -func (p *MyStructFieldPatch) DefaultGetBoolVal() *patch0.BoolPatch { - if !p.IsSetBoolVal() { - return patch0.NewBoolPatch() - } - return p.BoolVal -} -var MyStructFieldPatch_StructWithFieldCustomDefault_DEFAULT *MyDataPatch -func (p *MyStructFieldPatch) GetStructWithFieldCustomDefault() *MyDataPatch { - if !p.IsSetStructWithFieldCustomDefault() { - return MyStructFieldPatch_StructWithFieldCustomDefault_DEFAULT - } - return p.StructWithFieldCustomDefault -} -func (p *MyStructFieldPatch) DefaultGetStructWithFieldCustomDefault() *MyDataPatch { - if !p.IsSetStructWithFieldCustomDefault() { - return NewMyDataPatch() - } - return p.StructWithFieldCustomDefault -} -func (p *MyStructFieldPatch) IsSetStructWithCustomDefault() bool { - return p != nil && p.StructWithCustomDefault != nil -} - -func (p *MyStructFieldPatch) IsSetI32WithCustomDefault() bool { - return p != nil && p.I32WithCustomDefault != nil -} - -func (p *MyStructFieldPatch) IsSetMapMap() bool { - return p != nil && p.MapMap != nil -} - -func (p *MyStructFieldPatch) IsSetListMap() bool { - return p != nil && p.ListMap != nil -} - -func (p *MyStructFieldPatch) IsSetOptMapVal() bool { - return p != nil && p.OptMapVal != nil -} - -func (p *MyStructFieldPatch) IsSetOptSetVal() bool { - return p != nil && p.OptSetVal != nil -} - -func (p *MyStructFieldPatch) IsSetOptListVal() bool { - return p != nil && p.OptListVal != nil -} - -func (p *MyStructFieldPatch) IsSetOptLateStructVal() bool { - return p != nil && p.OptLateStructVal != nil -} - -func (p *MyStructFieldPatch) IsSetOptStructVal() bool { - return p != nil && p.OptStructVal != nil -} - -func (p *MyStructFieldPatch) IsSetOptEnumVal() bool { - return p != nil && p.OptEnumVal != nil -} - -func (p *MyStructFieldPatch) IsSetOptBinaryVal() bool { - return p != nil && p.OptBinaryVal != nil -} - -func (p *MyStructFieldPatch) IsSetOptStringVal() bool { - return p != nil && p.OptStringVal != nil -} - -func (p *MyStructFieldPatch) IsSetOptDoubleVal() bool { - return p != nil && p.OptDoubleVal != nil -} - -func (p *MyStructFieldPatch) IsSetOptFloatVal() bool { - return p != nil && p.OptFloatVal != nil -} - -func (p *MyStructFieldPatch) IsSetOptI64Val() bool { - return p != nil && p.OptI64Val != nil -} - -func (p *MyStructFieldPatch) IsSetOptI32Val() bool { - return p != nil && p.OptI32Val != nil -} - -func (p *MyStructFieldPatch) IsSetOptI16Val() bool { - return p != nil && p.OptI16Val != nil -} - -func (p *MyStructFieldPatch) IsSetOptByteVal() bool { - return p != nil && p.OptByteVal != nil -} - -func (p *MyStructFieldPatch) IsSetOptBoolVal() bool { - return p != nil && p.OptBoolVal != nil -} - -func (p *MyStructFieldPatch) IsSetLateStructVal() bool { - return p != nil && p.LateStructVal != nil -} - -func (p *MyStructFieldPatch) IsSetUnionVal() bool { - return p != nil && p.UnionVal != nil -} - -func (p *MyStructFieldPatch) IsSetStructVal() bool { - return p != nil && p.StructVal != nil -} - -func (p *MyStructFieldPatch) IsSetEnumVal() bool { - return p != nil && p.EnumVal != nil -} - -func (p *MyStructFieldPatch) IsSetBinaryVal() bool { - return p != nil && p.BinaryVal != nil -} - -func (p *MyStructFieldPatch) IsSetStringVal() bool { - return p != nil && p.StringVal != nil -} - -func (p *MyStructFieldPatch) IsSetDoubleVal() bool { - return p != nil && p.DoubleVal != nil -} - -func (p *MyStructFieldPatch) IsSetFloatVal() bool { - return p != nil && p.FloatVal != nil -} - -func (p *MyStructFieldPatch) IsSetI64Val() bool { - return p != nil && p.I64Val != nil -} - -func (p *MyStructFieldPatch) IsSetI32Val() bool { - return p != nil && p.I32Val != nil -} - -func (p *MyStructFieldPatch) IsSetI16Val() bool { - return p != nil && p.I16Val != nil -} - -func (p *MyStructFieldPatch) IsSetByteVal() bool { - return p != nil && p.ByteVal != nil -} - -func (p *MyStructFieldPatch) IsSetBoolVal() bool { - return p != nil && p.BoolVal != nil -} - -func (p *MyStructFieldPatch) IsSetStructWithFieldCustomDefault() bool { - return p != nil && p.StructWithFieldCustomDefault != nil -} - -type MyStructFieldPatchBuilder struct { - obj *MyStructFieldPatch -} - -func NewMyStructFieldPatchBuilder() *MyStructFieldPatchBuilder{ - return &MyStructFieldPatchBuilder{ - obj: NewMyStructFieldPatch(), - } -} - -func (p MyStructFieldPatchBuilder) Emit() *MyStructFieldPatch{ - return &MyStructFieldPatch{ - StructWithCustomDefault: p.obj.StructWithCustomDefault, - I32WithCustomDefault: p.obj.I32WithCustomDefault, - MapMap: p.obj.MapMap, - ListMap: p.obj.ListMap, - OptMapVal: p.obj.OptMapVal, - OptSetVal: p.obj.OptSetVal, - OptListVal: p.obj.OptListVal, - OptLateStructVal: p.obj.OptLateStructVal, - OptStructVal: p.obj.OptStructVal, - OptEnumVal: p.obj.OptEnumVal, - OptBinaryVal: p.obj.OptBinaryVal, - OptStringVal: p.obj.OptStringVal, - OptDoubleVal: p.obj.OptDoubleVal, - OptFloatVal: p.obj.OptFloatVal, - OptI64Val: p.obj.OptI64Val, - OptI32Val: p.obj.OptI32Val, - OptI16Val: p.obj.OptI16Val, - OptByteVal: p.obj.OptByteVal, - OptBoolVal: p.obj.OptBoolVal, - LateStructVal: p.obj.LateStructVal, - UnionVal: p.obj.UnionVal, - StructVal: p.obj.StructVal, - EnumVal: p.obj.EnumVal, - BinaryVal: p.obj.BinaryVal, - StringVal: p.obj.StringVal, - DoubleVal: p.obj.DoubleVal, - FloatVal: p.obj.FloatVal, - I64Val: p.obj.I64Val, - I32Val: p.obj.I32Val, - I16Val: p.obj.I16Val, - ByteVal: p.obj.ByteVal, - BoolVal: p.obj.BoolVal, - StructWithFieldCustomDefault: p.obj.StructWithFieldCustomDefault, - } -} - -func (m *MyStructFieldPatchBuilder) StructWithCustomDefault(structWithCustomDefault *MyDataWithCustomDefaultPatch) *MyStructFieldPatchBuilder { - m.obj.StructWithCustomDefault = structWithCustomDefault - return m -} - -func (m *MyStructFieldPatchBuilder) I32WithCustomDefault(i32WithCustomDefault *patch0.I32Patch) *MyStructFieldPatchBuilder { - m.obj.I32WithCustomDefault = i32WithCustomDefault - return m -} - -func (m *MyStructFieldPatchBuilder) MapMap(mapMap *MyStructField30Patch) *MyStructFieldPatchBuilder { - m.obj.MapMap = mapMap - return m -} - -func (m *MyStructFieldPatchBuilder) ListMap(listMap *MyStructField29Patch) *MyStructFieldPatchBuilder { - m.obj.ListMap = listMap - return m -} - -func (m *MyStructFieldPatchBuilder) OptMapVal(optMapVal *MyStructField28Patch) *MyStructFieldPatchBuilder { - m.obj.OptMapVal = optMapVal - return m -} - -func (m *MyStructFieldPatchBuilder) OptSetVal(optSetVal *MyStructField27Patch) *MyStructFieldPatchBuilder { - m.obj.OptSetVal = optSetVal - return m -} - -func (m *MyStructFieldPatchBuilder) OptListVal(optListVal *MyStructField26Patch) *MyStructFieldPatchBuilder { - m.obj.OptListVal = optListVal - return m -} - -func (m *MyStructFieldPatchBuilder) OptLateStructVal(optLateStructVal *LateDefStructPatch) *MyStructFieldPatchBuilder { - m.obj.OptLateStructVal = optLateStructVal - return m -} - -func (m *MyStructFieldPatchBuilder) OptStructVal(optStructVal *MyDataPatch) *MyStructFieldPatchBuilder { - m.obj.OptStructVal = optStructVal - return m -} - -func (m *MyStructFieldPatchBuilder) OptEnumVal(optEnumVal *MyStructField23Patch) *MyStructFieldPatchBuilder { - m.obj.OptEnumVal = optEnumVal - return m -} - -func (m *MyStructFieldPatchBuilder) OptBinaryVal(optBinaryVal *patch0.BinaryPatch) *MyStructFieldPatchBuilder { - m.obj.OptBinaryVal = optBinaryVal - return m -} - -func (m *MyStructFieldPatchBuilder) OptStringVal(optStringVal *patch0.StringPatch) *MyStructFieldPatchBuilder { - m.obj.OptStringVal = optStringVal - return m -} - -func (m *MyStructFieldPatchBuilder) OptDoubleVal(optDoubleVal *patch0.DoublePatch) *MyStructFieldPatchBuilder { - m.obj.OptDoubleVal = optDoubleVal - return m -} - -func (m *MyStructFieldPatchBuilder) OptFloatVal(optFloatVal *patch0.FloatPatch) *MyStructFieldPatchBuilder { - m.obj.OptFloatVal = optFloatVal - return m -} - -func (m *MyStructFieldPatchBuilder) OptI64Val(optI64Val *patch0.I64Patch) *MyStructFieldPatchBuilder { - m.obj.OptI64Val = optI64Val - return m -} - -func (m *MyStructFieldPatchBuilder) OptI32Val(optI32Val *patch0.I32Patch) *MyStructFieldPatchBuilder { - m.obj.OptI32Val = optI32Val - return m -} - -func (m *MyStructFieldPatchBuilder) OptI16Val(optI16Val *patch0.I16Patch) *MyStructFieldPatchBuilder { - m.obj.OptI16Val = optI16Val - return m -} - -func (m *MyStructFieldPatchBuilder) OptByteVal(optByteVal *patch0.BytePatch) *MyStructFieldPatchBuilder { - m.obj.OptByteVal = optByteVal - return m -} - -func (m *MyStructFieldPatchBuilder) OptBoolVal(optBoolVal *patch0.BoolPatch) *MyStructFieldPatchBuilder { - m.obj.OptBoolVal = optBoolVal - return m -} - -func (m *MyStructFieldPatchBuilder) LateStructVal(lateStructVal *LateDefStructPatch) *MyStructFieldPatchBuilder { - m.obj.LateStructVal = lateStructVal - return m -} - -func (m *MyStructFieldPatchBuilder) UnionVal(unionVal *MyUnionPatch) *MyStructFieldPatchBuilder { - m.obj.UnionVal = unionVal - return m -} - -func (m *MyStructFieldPatchBuilder) StructVal(structVal *MyDataPatch) *MyStructFieldPatchBuilder { - m.obj.StructVal = structVal - return m -} - -func (m *MyStructFieldPatchBuilder) EnumVal(enumVal *MyStructField10Patch) *MyStructFieldPatchBuilder { - m.obj.EnumVal = enumVal - return m -} - -func (m *MyStructFieldPatchBuilder) BinaryVal(binaryVal *patch0.BinaryPatch) *MyStructFieldPatchBuilder { - m.obj.BinaryVal = binaryVal - return m -} - -func (m *MyStructFieldPatchBuilder) StringVal(stringVal *patch0.StringPatch) *MyStructFieldPatchBuilder { - m.obj.StringVal = stringVal - return m -} - -func (m *MyStructFieldPatchBuilder) DoubleVal(doubleVal *patch0.DoublePatch) *MyStructFieldPatchBuilder { - m.obj.DoubleVal = doubleVal - return m -} - -func (m *MyStructFieldPatchBuilder) FloatVal(floatVal *patch0.FloatPatch) *MyStructFieldPatchBuilder { - m.obj.FloatVal = floatVal - return m -} - -func (m *MyStructFieldPatchBuilder) I64Val(i64Val *patch0.I64Patch) *MyStructFieldPatchBuilder { - m.obj.I64Val = i64Val - return m -} - -func (m *MyStructFieldPatchBuilder) I32Val(i32Val *patch0.I32Patch) *MyStructFieldPatchBuilder { - m.obj.I32Val = i32Val - return m -} - -func (m *MyStructFieldPatchBuilder) I16Val(i16Val *patch0.I16Patch) *MyStructFieldPatchBuilder { - m.obj.I16Val = i16Val - return m -} - -func (m *MyStructFieldPatchBuilder) ByteVal(byteVal *patch0.BytePatch) *MyStructFieldPatchBuilder { - m.obj.ByteVal = byteVal - return m -} - -func (m *MyStructFieldPatchBuilder) BoolVal(boolVal *patch0.BoolPatch) *MyStructFieldPatchBuilder { - m.obj.BoolVal = boolVal - return m -} - -func (m *MyStructFieldPatchBuilder) StructWithFieldCustomDefault(structWithFieldCustomDefault *MyDataPatch) *MyStructFieldPatchBuilder { - m.obj.StructWithFieldCustomDefault = structWithFieldCustomDefault - return m -} - -func (m *MyStructFieldPatch) SetStructWithCustomDefault(structWithCustomDefault *MyDataWithCustomDefaultPatch) *MyStructFieldPatch { - m.StructWithCustomDefault = structWithCustomDefault - return m -} - -func (m *MyStructFieldPatch) SetI32WithCustomDefault(i32WithCustomDefault *patch0.I32Patch) *MyStructFieldPatch { - m.I32WithCustomDefault = i32WithCustomDefault - return m -} - -func (m *MyStructFieldPatch) SetMapMap(mapMap *MyStructField30Patch) *MyStructFieldPatch { - m.MapMap = mapMap - return m -} - -func (m *MyStructFieldPatch) SetListMap(listMap *MyStructField29Patch) *MyStructFieldPatch { - m.ListMap = listMap - return m -} - -func (m *MyStructFieldPatch) SetOptMapVal(optMapVal *MyStructField28Patch) *MyStructFieldPatch { - m.OptMapVal = optMapVal - return m -} - -func (m *MyStructFieldPatch) SetOptSetVal(optSetVal *MyStructField27Patch) *MyStructFieldPatch { - m.OptSetVal = optSetVal - return m -} - -func (m *MyStructFieldPatch) SetOptListVal(optListVal *MyStructField26Patch) *MyStructFieldPatch { - m.OptListVal = optListVal - return m -} - -func (m *MyStructFieldPatch) SetOptLateStructVal(optLateStructVal *LateDefStructPatch) *MyStructFieldPatch { - m.OptLateStructVal = optLateStructVal - return m -} - -func (m *MyStructFieldPatch) SetOptStructVal(optStructVal *MyDataPatch) *MyStructFieldPatch { - m.OptStructVal = optStructVal - return m -} - -func (m *MyStructFieldPatch) SetOptEnumVal(optEnumVal *MyStructField23Patch) *MyStructFieldPatch { - m.OptEnumVal = optEnumVal - return m -} - -func (m *MyStructFieldPatch) SetOptBinaryVal(optBinaryVal *patch0.BinaryPatch) *MyStructFieldPatch { - m.OptBinaryVal = optBinaryVal - return m -} - -func (m *MyStructFieldPatch) SetOptStringVal(optStringVal *patch0.StringPatch) *MyStructFieldPatch { - m.OptStringVal = optStringVal - return m -} - -func (m *MyStructFieldPatch) SetOptDoubleVal(optDoubleVal *patch0.DoublePatch) *MyStructFieldPatch { - m.OptDoubleVal = optDoubleVal - return m -} - -func (m *MyStructFieldPatch) SetOptFloatVal(optFloatVal *patch0.FloatPatch) *MyStructFieldPatch { - m.OptFloatVal = optFloatVal - return m -} - -func (m *MyStructFieldPatch) SetOptI64Val(optI64Val *patch0.I64Patch) *MyStructFieldPatch { - m.OptI64Val = optI64Val - return m -} - -func (m *MyStructFieldPatch) SetOptI32Val(optI32Val *patch0.I32Patch) *MyStructFieldPatch { - m.OptI32Val = optI32Val - return m -} - -func (m *MyStructFieldPatch) SetOptI16Val(optI16Val *patch0.I16Patch) *MyStructFieldPatch { - m.OptI16Val = optI16Val - return m -} - -func (m *MyStructFieldPatch) SetOptByteVal(optByteVal *patch0.BytePatch) *MyStructFieldPatch { - m.OptByteVal = optByteVal - return m -} - -func (m *MyStructFieldPatch) SetOptBoolVal(optBoolVal *patch0.BoolPatch) *MyStructFieldPatch { - m.OptBoolVal = optBoolVal - return m -} - -func (m *MyStructFieldPatch) SetLateStructVal(lateStructVal *LateDefStructPatch) *MyStructFieldPatch { - m.LateStructVal = lateStructVal - return m -} - -func (m *MyStructFieldPatch) SetUnionVal(unionVal *MyUnionPatch) *MyStructFieldPatch { - m.UnionVal = unionVal - return m -} - -func (m *MyStructFieldPatch) SetStructVal(structVal *MyDataPatch) *MyStructFieldPatch { - m.StructVal = structVal - return m -} - -func (m *MyStructFieldPatch) SetEnumVal(enumVal *MyStructField10Patch) *MyStructFieldPatch { - m.EnumVal = enumVal - return m -} - -func (m *MyStructFieldPatch) SetBinaryVal(binaryVal *patch0.BinaryPatch) *MyStructFieldPatch { - m.BinaryVal = binaryVal - return m -} - -func (m *MyStructFieldPatch) SetStringVal(stringVal *patch0.StringPatch) *MyStructFieldPatch { - m.StringVal = stringVal - return m -} - -func (m *MyStructFieldPatch) SetDoubleVal(doubleVal *patch0.DoublePatch) *MyStructFieldPatch { - m.DoubleVal = doubleVal - return m -} - -func (m *MyStructFieldPatch) SetFloatVal(floatVal *patch0.FloatPatch) *MyStructFieldPatch { - m.FloatVal = floatVal - return m -} - -func (m *MyStructFieldPatch) SetI64Val(i64Val *patch0.I64Patch) *MyStructFieldPatch { - m.I64Val = i64Val - return m -} - -func (m *MyStructFieldPatch) SetI32Val(i32Val *patch0.I32Patch) *MyStructFieldPatch { - m.I32Val = i32Val - return m -} - -func (m *MyStructFieldPatch) SetI16Val(i16Val *patch0.I16Patch) *MyStructFieldPatch { - m.I16Val = i16Val - return m -} - -func (m *MyStructFieldPatch) SetByteVal(byteVal *patch0.BytePatch) *MyStructFieldPatch { - m.ByteVal = byteVal - return m -} - -func (m *MyStructFieldPatch) SetBoolVal(boolVal *patch0.BoolPatch) *MyStructFieldPatch { - m.BoolVal = boolVal - return m -} - -func (m *MyStructFieldPatch) SetStructWithFieldCustomDefault(structWithFieldCustomDefault *MyDataPatch) *MyStructFieldPatch { - m.StructWithFieldCustomDefault = structWithFieldCustomDefault - return m -} - -func (p *MyStructFieldPatch) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case -32: - if err := p.ReadField_32(iprot); err != nil { - return err - } - case -31: - if err := p.ReadField_31(iprot); err != nil { - return err - } - case -30: - if err := p.ReadField_30(iprot); err != nil { - return err - } - case -29: - if err := p.ReadField_29(iprot); err != nil { - return err - } - case -28: - if err := p.ReadField_28(iprot); err != nil { - return err - } - case -27: - if err := p.ReadField_27(iprot); err != nil { - return err - } - case -26: - if err := p.ReadField_26(iprot); err != nil { - return err - } - case -25: - if err := p.ReadField_25(iprot); err != nil { - return err - } - case -24: - if err := p.ReadField_24(iprot); err != nil { - return err - } - case -23: - if err := p.ReadField_23(iprot); err != nil { - return err - } - case -22: - if err := p.ReadField_22(iprot); err != nil { - return err - } - case -21: - if err := p.ReadField_21(iprot); err != nil { - return err - } - case -20: - if err := p.ReadField_20(iprot); err != nil { - return err - } - case -19: - if err := p.ReadField_19(iprot); err != nil { - return err - } - case -18: - if err := p.ReadField_18(iprot); err != nil { - return err - } - case -17: - if err := p.ReadField_17(iprot); err != nil { - return err - } - case -16: - if err := p.ReadField_16(iprot); err != nil { - return err - } - case -15: - if err := p.ReadField_15(iprot); err != nil { - return err - } - case -14: - if err := p.ReadField_14(iprot); err != nil { - return err - } - case -13: - if err := p.ReadField_13(iprot); err != nil { - return err - } - case -12: - if err := p.ReadField_12(iprot); err != nil { - return err - } - case -11: - if err := p.ReadField_11(iprot); err != nil { - return err - } - case -10: - if err := p.ReadField_10(iprot); err != nil { - return err - } - case -9: - if err := p.ReadField_9(iprot); err != nil { - return err - } - case -8: - if err := p.ReadField_8(iprot); err != nil { - return err - } - case -7: - if err := p.ReadField_7(iprot); err != nil { - return err - } - case -6: - if err := p.ReadField_6(iprot); err != nil { - return err - } - case -5: - if err := p.ReadField_5(iprot); err != nil { - return err - } - case -4: - if err := p.ReadField_4(iprot); err != nil { - return err - } - case -3: - if err := p.ReadField_3(iprot); err != nil { - return err - } - case -2: - if err := p.ReadField_2(iprot); err != nil { - return err - } - case -1: - if err := p.ReadField_1(iprot); err != nil { - return err - } - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyStructFieldPatch) ReadField_32(iprot thrift.Protocol) error { - p.StructWithCustomDefault = NewMyDataWithCustomDefaultPatch() - if err := p.StructWithCustomDefault.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.StructWithCustomDefault), err) - } - return nil -} - -func (p *MyStructFieldPatch) ReadField_31(iprot thrift.Protocol) error { - p.I32WithCustomDefault = patch0.NewI32Patch() - if err := p.I32WithCustomDefault.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.I32WithCustomDefault), err) - } - return nil -} - -func (p *MyStructFieldPatch) ReadField_30(iprot thrift.Protocol) error { - p.MapMap = NewMyStructField30Patch() - if err := p.MapMap.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.MapMap), err) - } - return nil -} - -func (p *MyStructFieldPatch) ReadField_29(iprot thrift.Protocol) error { - p.ListMap = NewMyStructField29Patch() - if err := p.ListMap.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.ListMap), err) - } - return nil -} - -func (p *MyStructFieldPatch) ReadField_28(iprot thrift.Protocol) error { - p.OptMapVal = NewMyStructField28Patch() - if err := p.OptMapVal.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.OptMapVal), err) - } - return nil -} - -func (p *MyStructFieldPatch) ReadField_27(iprot thrift.Protocol) error { - p.OptSetVal = NewMyStructField27Patch() - if err := p.OptSetVal.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.OptSetVal), err) - } - return nil -} - -func (p *MyStructFieldPatch) ReadField_26(iprot thrift.Protocol) error { - p.OptListVal = NewMyStructField26Patch() - if err := p.OptListVal.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.OptListVal), err) - } - return nil -} - -func (p *MyStructFieldPatch) ReadField_25(iprot thrift.Protocol) error { - p.OptLateStructVal = NewLateDefStructPatch() - if err := p.OptLateStructVal.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.OptLateStructVal), err) - } - return nil -} - -func (p *MyStructFieldPatch) ReadField_24(iprot thrift.Protocol) error { - p.OptStructVal = NewMyDataPatch() - if err := p.OptStructVal.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.OptStructVal), err) - } - return nil -} - -func (p *MyStructFieldPatch) ReadField_23(iprot thrift.Protocol) error { - p.OptEnumVal = NewMyStructField23Patch() - if err := p.OptEnumVal.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.OptEnumVal), err) - } - return nil -} - -func (p *MyStructFieldPatch) ReadField_22(iprot thrift.Protocol) error { - p.OptBinaryVal = patch0.NewBinaryPatch() - if err := p.OptBinaryVal.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.OptBinaryVal), err) - } - return nil -} - -func (p *MyStructFieldPatch) ReadField_21(iprot thrift.Protocol) error { - p.OptStringVal = patch0.NewStringPatch() - if err := p.OptStringVal.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.OptStringVal), err) - } - return nil -} - -func (p *MyStructFieldPatch) ReadField_20(iprot thrift.Protocol) error { - p.OptDoubleVal = patch0.NewDoublePatch() - if err := p.OptDoubleVal.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.OptDoubleVal), err) - } - return nil -} - -func (p *MyStructFieldPatch) ReadField_19(iprot thrift.Protocol) error { - p.OptFloatVal = patch0.NewFloatPatch() - if err := p.OptFloatVal.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.OptFloatVal), err) - } - return nil -} - -func (p *MyStructFieldPatch) ReadField_18(iprot thrift.Protocol) error { - p.OptI64Val = patch0.NewI64Patch() - if err := p.OptI64Val.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.OptI64Val), err) - } - return nil -} - -func (p *MyStructFieldPatch) ReadField_17(iprot thrift.Protocol) error { - p.OptI32Val = patch0.NewI32Patch() - if err := p.OptI32Val.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.OptI32Val), err) - } - return nil -} - -func (p *MyStructFieldPatch) ReadField_16(iprot thrift.Protocol) error { - p.OptI16Val = patch0.NewI16Patch() - if err := p.OptI16Val.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.OptI16Val), err) - } - return nil -} - -func (p *MyStructFieldPatch) ReadField_15(iprot thrift.Protocol) error { - p.OptByteVal = patch0.NewBytePatch() - if err := p.OptByteVal.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.OptByteVal), err) - } - return nil -} - -func (p *MyStructFieldPatch) ReadField_14(iprot thrift.Protocol) error { - p.OptBoolVal = patch0.NewBoolPatch() - if err := p.OptBoolVal.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.OptBoolVal), err) - } - return nil -} - -func (p *MyStructFieldPatch) ReadField_13(iprot thrift.Protocol) error { - p.LateStructVal = NewLateDefStructPatch() - if err := p.LateStructVal.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.LateStructVal), err) - } - return nil -} - -func (p *MyStructFieldPatch) ReadField_12(iprot thrift.Protocol) error { - p.UnionVal = NewMyUnionPatch() - if err := p.UnionVal.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.UnionVal), err) - } - return nil -} - -func (p *MyStructFieldPatch) ReadField_11(iprot thrift.Protocol) error { - p.StructVal = NewMyDataPatch() - if err := p.StructVal.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.StructVal), err) - } - return nil -} - -func (p *MyStructFieldPatch) ReadField_10(iprot thrift.Protocol) error { - p.EnumVal = NewMyStructField10Patch() - if err := p.EnumVal.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.EnumVal), err) - } - return nil -} - -func (p *MyStructFieldPatch) ReadField_9(iprot thrift.Protocol) error { - p.BinaryVal = patch0.NewBinaryPatch() - if err := p.BinaryVal.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.BinaryVal), err) - } - return nil -} - -func (p *MyStructFieldPatch) ReadField_8(iprot thrift.Protocol) error { - p.StringVal = patch0.NewStringPatch() - if err := p.StringVal.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.StringVal), err) - } - return nil -} - -func (p *MyStructFieldPatch) ReadField_7(iprot thrift.Protocol) error { - p.DoubleVal = patch0.NewDoublePatch() - if err := p.DoubleVal.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.DoubleVal), err) - } - return nil -} - -func (p *MyStructFieldPatch) ReadField_6(iprot thrift.Protocol) error { - p.FloatVal = patch0.NewFloatPatch() - if err := p.FloatVal.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.FloatVal), err) - } - return nil -} - -func (p *MyStructFieldPatch) ReadField_5(iprot thrift.Protocol) error { - p.I64Val = patch0.NewI64Patch() - if err := p.I64Val.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.I64Val), err) - } - return nil -} - -func (p *MyStructFieldPatch) ReadField_4(iprot thrift.Protocol) error { - p.I32Val = patch0.NewI32Patch() - if err := p.I32Val.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.I32Val), err) - } - return nil -} - -func (p *MyStructFieldPatch) ReadField_3(iprot thrift.Protocol) error { - p.I16Val = patch0.NewI16Patch() - if err := p.I16Val.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.I16Val), err) - } - return nil -} - -func (p *MyStructFieldPatch) ReadField_2(iprot thrift.Protocol) error { - p.ByteVal = patch0.NewBytePatch() - if err := p.ByteVal.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.ByteVal), err) - } - return nil -} - -func (p *MyStructFieldPatch) ReadField_1(iprot thrift.Protocol) error { - p.BoolVal = patch0.NewBoolPatch() - if err := p.BoolVal.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.BoolVal), err) - } - return nil -} - -func (p *MyStructFieldPatch) ReadField1(iprot thrift.Protocol) error { - p.StructWithFieldCustomDefault = NewMyDataPatch() - if err := p.StructWithFieldCustomDefault.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.StructWithFieldCustomDefault), err) - } - return nil -} - -func (p *MyStructFieldPatch) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("MyStructFieldPatch"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField_32(oprot); err != nil { return err } - if err := p.writeField_31(oprot); err != nil { return err } - if err := p.writeField_30(oprot); err != nil { return err } - if err := p.writeField_29(oprot); err != nil { return err } - if err := p.writeField_28(oprot); err != nil { return err } - if err := p.writeField_27(oprot); err != nil { return err } - if err := p.writeField_26(oprot); err != nil { return err } - if err := p.writeField_25(oprot); err != nil { return err } - if err := p.writeField_24(oprot); err != nil { return err } - if err := p.writeField_23(oprot); err != nil { return err } - if err := p.writeField_22(oprot); err != nil { return err } - if err := p.writeField_21(oprot); err != nil { return err } - if err := p.writeField_20(oprot); err != nil { return err } - if err := p.writeField_19(oprot); err != nil { return err } - if err := p.writeField_18(oprot); err != nil { return err } - if err := p.writeField_17(oprot); err != nil { return err } - if err := p.writeField_16(oprot); err != nil { return err } - if err := p.writeField_15(oprot); err != nil { return err } - if err := p.writeField_14(oprot); err != nil { return err } - if err := p.writeField_13(oprot); err != nil { return err } - if err := p.writeField_12(oprot); err != nil { return err } - if err := p.writeField_11(oprot); err != nil { return err } - if err := p.writeField_10(oprot); err != nil { return err } - if err := p.writeField_9(oprot); err != nil { return err } - if err := p.writeField_8(oprot); err != nil { return err } - if err := p.writeField_7(oprot); err != nil { return err } - if err := p.writeField_6(oprot); err != nil { return err } - if err := p.writeField_5(oprot); err != nil { return err } - if err := p.writeField_4(oprot); err != nil { return err } - if err := p.writeField_3(oprot); err != nil { return err } - if err := p.writeField_2(oprot); err != nil { return err } - if err := p.writeField_1(oprot); err != nil { return err } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyStructFieldPatch) writeField_32(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("structWithCustomDefault", thrift.STRUCT, -32); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -32:structWithCustomDefault: ", p), err) } - if err := p.StructWithCustomDefault.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.StructWithCustomDefault), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -32:structWithCustomDefault: ", p), err) } - return err -} - -func (p *MyStructFieldPatch) writeField_31(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("i32WithCustomDefault", thrift.STRUCT, -31); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -31:i32WithCustomDefault: ", p), err) } - if err := p.I32WithCustomDefault.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.I32WithCustomDefault), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -31:i32WithCustomDefault: ", p), err) } - return err -} - -func (p *MyStructFieldPatch) writeField_30(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("mapMap", thrift.STRUCT, -30); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -30:mapMap: ", p), err) } - if err := p.MapMap.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.MapMap), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -30:mapMap: ", p), err) } - return err -} - -func (p *MyStructFieldPatch) writeField_29(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("listMap", thrift.STRUCT, -29); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -29:listMap: ", p), err) } - if err := p.ListMap.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.ListMap), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -29:listMap: ", p), err) } - return err -} - -func (p *MyStructFieldPatch) writeField_28(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("optMapVal", thrift.STRUCT, -28); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -28:optMapVal: ", p), err) } - if err := p.OptMapVal.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.OptMapVal), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -28:optMapVal: ", p), err) } - return err -} - -func (p *MyStructFieldPatch) writeField_27(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("optSetVal", thrift.STRUCT, -27); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -27:optSetVal: ", p), err) } - if err := p.OptSetVal.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.OptSetVal), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -27:optSetVal: ", p), err) } - return err -} - -func (p *MyStructFieldPatch) writeField_26(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("optListVal", thrift.STRUCT, -26); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -26:optListVal: ", p), err) } - if err := p.OptListVal.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.OptListVal), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -26:optListVal: ", p), err) } - return err -} - -func (p *MyStructFieldPatch) writeField_25(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("optLateStructVal", thrift.STRUCT, -25); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -25:optLateStructVal: ", p), err) } - if err := p.OptLateStructVal.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.OptLateStructVal), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -25:optLateStructVal: ", p), err) } - return err -} - -func (p *MyStructFieldPatch) writeField_24(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("optStructVal", thrift.STRUCT, -24); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -24:optStructVal: ", p), err) } - if err := p.OptStructVal.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.OptStructVal), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -24:optStructVal: ", p), err) } - return err -} - -func (p *MyStructFieldPatch) writeField_23(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("optEnumVal", thrift.STRUCT, -23); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -23:optEnumVal: ", p), err) } - if err := p.OptEnumVal.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.OptEnumVal), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -23:optEnumVal: ", p), err) } - return err -} - -func (p *MyStructFieldPatch) writeField_22(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("optBinaryVal", thrift.STRUCT, -22); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -22:optBinaryVal: ", p), err) } - if err := p.OptBinaryVal.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.OptBinaryVal), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -22:optBinaryVal: ", p), err) } - return err -} - -func (p *MyStructFieldPatch) writeField_21(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("optStringVal", thrift.STRUCT, -21); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -21:optStringVal: ", p), err) } - if err := p.OptStringVal.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.OptStringVal), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -21:optStringVal: ", p), err) } - return err -} - -func (p *MyStructFieldPatch) writeField_20(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("optDoubleVal", thrift.STRUCT, -20); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -20:optDoubleVal: ", p), err) } - if err := p.OptDoubleVal.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.OptDoubleVal), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -20:optDoubleVal: ", p), err) } - return err -} - -func (p *MyStructFieldPatch) writeField_19(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("optFloatVal", thrift.STRUCT, -19); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -19:optFloatVal: ", p), err) } - if err := p.OptFloatVal.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.OptFloatVal), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -19:optFloatVal: ", p), err) } - return err -} - -func (p *MyStructFieldPatch) writeField_18(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("optI64Val", thrift.STRUCT, -18); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -18:optI64Val: ", p), err) } - if err := p.OptI64Val.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.OptI64Val), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -18:optI64Val: ", p), err) } - return err -} - -func (p *MyStructFieldPatch) writeField_17(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("optI32Val", thrift.STRUCT, -17); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -17:optI32Val: ", p), err) } - if err := p.OptI32Val.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.OptI32Val), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -17:optI32Val: ", p), err) } - return err -} - -func (p *MyStructFieldPatch) writeField_16(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("optI16Val", thrift.STRUCT, -16); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -16:optI16Val: ", p), err) } - if err := p.OptI16Val.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.OptI16Val), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -16:optI16Val: ", p), err) } - return err -} - -func (p *MyStructFieldPatch) writeField_15(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("optByteVal", thrift.STRUCT, -15); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -15:optByteVal: ", p), err) } - if err := p.OptByteVal.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.OptByteVal), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -15:optByteVal: ", p), err) } - return err -} - -func (p *MyStructFieldPatch) writeField_14(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("optBoolVal", thrift.STRUCT, -14); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -14:optBoolVal: ", p), err) } - if err := p.OptBoolVal.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.OptBoolVal), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -14:optBoolVal: ", p), err) } - return err -} - -func (p *MyStructFieldPatch) writeField_13(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("lateStructVal", thrift.STRUCT, -13); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -13:lateStructVal: ", p), err) } - if err := p.LateStructVal.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.LateStructVal), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -13:lateStructVal: ", p), err) } - return err -} - -func (p *MyStructFieldPatch) writeField_12(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("unionVal", thrift.STRUCT, -12); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -12:unionVal: ", p), err) } - if err := p.UnionVal.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.UnionVal), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -12:unionVal: ", p), err) } - return err -} - -func (p *MyStructFieldPatch) writeField_11(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("structVal", thrift.STRUCT, -11); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -11:structVal: ", p), err) } - if err := p.StructVal.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.StructVal), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -11:structVal: ", p), err) } - return err -} - -func (p *MyStructFieldPatch) writeField_10(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("enumVal", thrift.STRUCT, -10); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -10:enumVal: ", p), err) } - if err := p.EnumVal.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.EnumVal), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -10:enumVal: ", p), err) } - return err -} - -func (p *MyStructFieldPatch) writeField_9(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("binaryVal", thrift.STRUCT, -9); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -9:binaryVal: ", p), err) } - if err := p.BinaryVal.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.BinaryVal), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -9:binaryVal: ", p), err) } - return err -} - -func (p *MyStructFieldPatch) writeField_8(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("stringVal", thrift.STRUCT, -8); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -8:stringVal: ", p), err) } - if err := p.StringVal.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.StringVal), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -8:stringVal: ", p), err) } - return err -} - -func (p *MyStructFieldPatch) writeField_7(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("doubleVal", thrift.STRUCT, -7); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -7:doubleVal: ", p), err) } - if err := p.DoubleVal.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.DoubleVal), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -7:doubleVal: ", p), err) } - return err -} - -func (p *MyStructFieldPatch) writeField_6(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("floatVal", thrift.STRUCT, -6); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -6:floatVal: ", p), err) } - if err := p.FloatVal.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.FloatVal), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -6:floatVal: ", p), err) } - return err -} - -func (p *MyStructFieldPatch) writeField_5(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("i64Val", thrift.STRUCT, -5); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -5:i64Val: ", p), err) } - if err := p.I64Val.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.I64Val), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -5:i64Val: ", p), err) } - return err -} - -func (p *MyStructFieldPatch) writeField_4(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("i32Val", thrift.STRUCT, -4); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -4:i32Val: ", p), err) } - if err := p.I32Val.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.I32Val), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -4:i32Val: ", p), err) } - return err -} - -func (p *MyStructFieldPatch) writeField_3(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("i16Val", thrift.STRUCT, -3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -3:i16Val: ", p), err) } - if err := p.I16Val.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.I16Val), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -3:i16Val: ", p), err) } - return err -} - -func (p *MyStructFieldPatch) writeField_2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("byteVal", thrift.STRUCT, -2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -2:byteVal: ", p), err) } - if err := p.ByteVal.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.ByteVal), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -2:byteVal: ", p), err) } - return err -} - -func (p *MyStructFieldPatch) writeField_1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("boolVal", thrift.STRUCT, -1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -1:boolVal: ", p), err) } - if err := p.BoolVal.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.BoolVal), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -1:boolVal: ", p), err) } - return err -} - -func (p *MyStructFieldPatch) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("structWithFieldCustomDefault", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:structWithFieldCustomDefault: ", p), err) } - if err := p.StructWithFieldCustomDefault.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.StructWithFieldCustomDefault), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:structWithFieldCustomDefault: ", p), err) } - return err -} - -func (p *MyStructFieldPatch) String() string { - if p == nil { - return "" - } - - var structWithCustomDefaultVal string - if p.StructWithCustomDefault == nil { - structWithCustomDefaultVal = "" - } else { - structWithCustomDefaultVal = fmt.Sprintf("%v", p.StructWithCustomDefault) - } - var i32WithCustomDefaultVal string - if p.I32WithCustomDefault == nil { - i32WithCustomDefaultVal = "" - } else { - i32WithCustomDefaultVal = fmt.Sprintf("%v", p.I32WithCustomDefault) - } - var mapMapVal string - if p.MapMap == nil { - mapMapVal = "" - } else { - mapMapVal = fmt.Sprintf("%v", p.MapMap) - } - var listMapVal string - if p.ListMap == nil { - listMapVal = "" - } else { - listMapVal = fmt.Sprintf("%v", p.ListMap) - } - var optMapValVal string - if p.OptMapVal == nil { - optMapValVal = "" - } else { - optMapValVal = fmt.Sprintf("%v", p.OptMapVal) - } - var optSetValVal string - if p.OptSetVal == nil { - optSetValVal = "" - } else { - optSetValVal = fmt.Sprintf("%v", p.OptSetVal) - } - var optListValVal string - if p.OptListVal == nil { - optListValVal = "" - } else { - optListValVal = fmt.Sprintf("%v", p.OptListVal) - } - var optLateStructValVal string - if p.OptLateStructVal == nil { - optLateStructValVal = "" - } else { - optLateStructValVal = fmt.Sprintf("%v", p.OptLateStructVal) - } - var optStructValVal string - if p.OptStructVal == nil { - optStructValVal = "" - } else { - optStructValVal = fmt.Sprintf("%v", p.OptStructVal) - } - var optEnumValVal string - if p.OptEnumVal == nil { - optEnumValVal = "" - } else { - optEnumValVal = fmt.Sprintf("%v", p.OptEnumVal) - } - var optBinaryValVal string - if p.OptBinaryVal == nil { - optBinaryValVal = "" - } else { - optBinaryValVal = fmt.Sprintf("%v", p.OptBinaryVal) - } - var optStringValVal string - if p.OptStringVal == nil { - optStringValVal = "" - } else { - optStringValVal = fmt.Sprintf("%v", p.OptStringVal) - } - var optDoubleValVal string - if p.OptDoubleVal == nil { - optDoubleValVal = "" - } else { - optDoubleValVal = fmt.Sprintf("%v", p.OptDoubleVal) - } - var optFloatValVal string - if p.OptFloatVal == nil { - optFloatValVal = "" - } else { - optFloatValVal = fmt.Sprintf("%v", p.OptFloatVal) - } - var optI64ValVal string - if p.OptI64Val == nil { - optI64ValVal = "" - } else { - optI64ValVal = fmt.Sprintf("%v", p.OptI64Val) - } - var optI32ValVal string - if p.OptI32Val == nil { - optI32ValVal = "" - } else { - optI32ValVal = fmt.Sprintf("%v", p.OptI32Val) - } - var optI16ValVal string - if p.OptI16Val == nil { - optI16ValVal = "" - } else { - optI16ValVal = fmt.Sprintf("%v", p.OptI16Val) - } - var optByteValVal string - if p.OptByteVal == nil { - optByteValVal = "" - } else { - optByteValVal = fmt.Sprintf("%v", p.OptByteVal) - } - var optBoolValVal string - if p.OptBoolVal == nil { - optBoolValVal = "" - } else { - optBoolValVal = fmt.Sprintf("%v", p.OptBoolVal) - } - var lateStructValVal string - if p.LateStructVal == nil { - lateStructValVal = "" - } else { - lateStructValVal = fmt.Sprintf("%v", p.LateStructVal) - } - var unionValVal string - if p.UnionVal == nil { - unionValVal = "" - } else { - unionValVal = fmt.Sprintf("%v", p.UnionVal) - } - var structValVal string - if p.StructVal == nil { - structValVal = "" - } else { - structValVal = fmt.Sprintf("%v", p.StructVal) - } - var enumValVal string - if p.EnumVal == nil { - enumValVal = "" - } else { - enumValVal = fmt.Sprintf("%v", p.EnumVal) - } - var binaryValVal string - if p.BinaryVal == nil { - binaryValVal = "" - } else { - binaryValVal = fmt.Sprintf("%v", p.BinaryVal) - } - var stringValVal string - if p.StringVal == nil { - stringValVal = "" - } else { - stringValVal = fmt.Sprintf("%v", p.StringVal) - } - var doubleValVal string - if p.DoubleVal == nil { - doubleValVal = "" - } else { - doubleValVal = fmt.Sprintf("%v", p.DoubleVal) - } - var floatValVal string - if p.FloatVal == nil { - floatValVal = "" - } else { - floatValVal = fmt.Sprintf("%v", p.FloatVal) - } - var i64ValVal string - if p.I64Val == nil { - i64ValVal = "" - } else { - i64ValVal = fmt.Sprintf("%v", p.I64Val) - } - var i32ValVal string - if p.I32Val == nil { - i32ValVal = "" - } else { - i32ValVal = fmt.Sprintf("%v", p.I32Val) - } - var i16ValVal string - if p.I16Val == nil { - i16ValVal = "" - } else { - i16ValVal = fmt.Sprintf("%v", p.I16Val) - } - var byteValVal string - if p.ByteVal == nil { - byteValVal = "" - } else { - byteValVal = fmt.Sprintf("%v", p.ByteVal) - } - var boolValVal string - if p.BoolVal == nil { - boolValVal = "" - } else { - boolValVal = fmt.Sprintf("%v", p.BoolVal) - } - var structWithFieldCustomDefaultVal string - if p.StructWithFieldCustomDefault == nil { - structWithFieldCustomDefaultVal = "" - } else { - structWithFieldCustomDefaultVal = fmt.Sprintf("%v", p.StructWithFieldCustomDefault) - } - return fmt.Sprintf("MyStructFieldPatch({StructWithCustomDefault:%s I32WithCustomDefault:%s MapMap:%s ListMap:%s OptMapVal:%s OptSetVal:%s OptListVal:%s OptLateStructVal:%s OptStructVal:%s OptEnumVal:%s OptBinaryVal:%s OptStringVal:%s OptDoubleVal:%s OptFloatVal:%s OptI64Val:%s OptI32Val:%s OptI16Val:%s OptByteVal:%s OptBoolVal:%s LateStructVal:%s UnionVal:%s StructVal:%s EnumVal:%s BinaryVal:%s StringVal:%s DoubleVal:%s FloatVal:%s I64Val:%s I32Val:%s I16Val:%s ByteVal:%s BoolVal:%s StructWithFieldCustomDefault:%s})", structWithCustomDefaultVal, i32WithCustomDefaultVal, mapMapVal, listMapVal, optMapValVal, optSetValVal, optListValVal, optLateStructValVal, optStructValVal, optEnumValVal, optBinaryValVal, optStringValVal, optDoubleValVal, optFloatValVal, optI64ValVal, optI32ValVal, optI16ValVal, optByteValVal, optBoolValVal, lateStructValVal, unionValVal, structValVal, enumValVal, binaryValVal, stringValVal, doubleValVal, floatValVal, i64ValVal, i32ValVal, i16ValVal, byteValVal, boolValVal, structWithFieldCustomDefaultVal) -} - -// Attributes: -// - StructWithCustomDefault -// - I32WithCustomDefault -// - MapMap -// - ListMap -// - OptMapVal -// - OptSetVal -// - OptListVal -// - OptLateStructVal -// - OptStructVal -// - OptEnumVal -// - OptBinaryVal -// - OptStringVal -// - OptDoubleVal -// - OptFloatVal -// - OptI64Val -// - OptI32Val -// - OptI16Val -// - OptByteVal -// - OptBoolVal -// - LateStructVal -// - UnionVal -// - StructVal -// - EnumVal -// - BinaryVal -// - StringVal -// - DoubleVal -// - FloatVal -// - I64Val -// - I32Val -// - I16Val -// - ByteVal -// - BoolVal -// - StructWithFieldCustomDefault -type MyStructEnsureStruct struct { - StructWithCustomDefault *MyDataWithCustomDefault - I32WithCustomDefault int32 - MapMap map[string]map[string]int32 - ListMap []map[string]int32 - OptMapVal map[string]string - OptSetVal []string - OptListVal []int16 - OptLateStructVal *LateDefStruct - OptStructVal *MyData - OptEnumVal MyEnum - OptBinaryVal []byte - OptStringVal string - OptDoubleVal float64 - OptFloatVal float32 - OptI64Val int64 - OptI32Val int32 - OptI16Val int16 - OptByteVal int8 - OptBoolVal bool - LateStructVal *LateDefStruct - UnionVal *MyUnion - StructVal *MyData - EnumVal MyEnum - BinaryVal []byte - StringVal string - DoubleVal float64 - FloatVal float32 - I64Val int64 - I32Val int32 - I16Val int16 - ByteVal int8 - BoolVal bool - StructWithFieldCustomDefault *MyData -} - -func NewMyStructEnsureStruct() *MyStructEnsureStruct { - return &MyStructEnsureStruct{} -} - -var MyStructEnsureStruct_StructWithCustomDefault_DEFAULT *MyDataWithCustomDefault -func (p *MyStructEnsureStruct) GetStructWithCustomDefault() *MyDataWithCustomDefault { - if !p.IsSetStructWithCustomDefault() { - return MyStructEnsureStruct_StructWithCustomDefault_DEFAULT - } - return p.StructWithCustomDefault -} -func (p *MyStructEnsureStruct) DefaultGetStructWithCustomDefault() *MyDataWithCustomDefault { - if !p.IsSetStructWithCustomDefault() { - return NewMyDataWithCustomDefault() - } - return p.StructWithCustomDefault -} -var MyStructEnsureStruct_I32WithCustomDefault_DEFAULT int32 -func (p *MyStructEnsureStruct) GetI32WithCustomDefault() int32 { - if !p.IsSetI32WithCustomDefault() { - return MyStructEnsureStruct_I32WithCustomDefault_DEFAULT - } - return *p.I32WithCustomDefault -} -var MyStructEnsureStruct_MapMap_DEFAULT map[string]map[string]int32 - -func (p *MyStructEnsureStruct) GetMapMap() map[string]map[string]int32 { - return p.MapMap -} -var MyStructEnsureStruct_ListMap_DEFAULT []map[string]int32 - -func (p *MyStructEnsureStruct) GetListMap() []map[string]int32 { - return p.ListMap -} -var MyStructEnsureStruct_OptMapVal_DEFAULT map[string]string - -func (p *MyStructEnsureStruct) GetOptMapVal() map[string]string { - return p.OptMapVal -} -var MyStructEnsureStruct_OptSetVal_DEFAULT []string - -func (p *MyStructEnsureStruct) GetOptSetVal() []string { - return p.OptSetVal -} -var MyStructEnsureStruct_OptListVal_DEFAULT []int16 - -func (p *MyStructEnsureStruct) GetOptListVal() []int16 { - return p.OptListVal -} -var MyStructEnsureStruct_OptLateStructVal_DEFAULT *LateDefStruct -func (p *MyStructEnsureStruct) GetOptLateStructVal() *LateDefStruct { - if !p.IsSetOptLateStructVal() { - return MyStructEnsureStruct_OptLateStructVal_DEFAULT - } - return p.OptLateStructVal -} -var MyStructEnsureStruct_OptStructVal_DEFAULT *MyData -func (p *MyStructEnsureStruct) GetOptStructVal() *MyData { - if !p.IsSetOptStructVal() { - return MyStructEnsureStruct_OptStructVal_DEFAULT - } - return p.OptStructVal -} -func (p *MyStructEnsureStruct) DefaultGetOptStructVal() *MyData { - if !p.IsSetOptStructVal() { - return NewMyData() - } - return p.OptStructVal -} -var MyStructEnsureStruct_OptEnumVal_DEFAULT MyEnum -func (p *MyStructEnsureStruct) GetOptEnumVal() MyEnum { - if !p.IsSetOptEnumVal() { - return MyStructEnsureStruct_OptEnumVal_DEFAULT - } - return *p.OptEnumVal -} -var MyStructEnsureStruct_OptBinaryVal_DEFAULT []byte - -func (p *MyStructEnsureStruct) GetOptBinaryVal() []byte { - return p.OptBinaryVal -} -var MyStructEnsureStruct_OptStringVal_DEFAULT string -func (p *MyStructEnsureStruct) GetOptStringVal() string { - if !p.IsSetOptStringVal() { - return MyStructEnsureStruct_OptStringVal_DEFAULT - } - return *p.OptStringVal -} -var MyStructEnsureStruct_OptDoubleVal_DEFAULT float64 -func (p *MyStructEnsureStruct) GetOptDoubleVal() float64 { - if !p.IsSetOptDoubleVal() { - return MyStructEnsureStruct_OptDoubleVal_DEFAULT - } - return *p.OptDoubleVal -} -var MyStructEnsureStruct_OptFloatVal_DEFAULT float32 -func (p *MyStructEnsureStruct) GetOptFloatVal() float32 { - if !p.IsSetOptFloatVal() { - return MyStructEnsureStruct_OptFloatVal_DEFAULT - } - return *p.OptFloatVal -} -var MyStructEnsureStruct_OptI64Val_DEFAULT int64 -func (p *MyStructEnsureStruct) GetOptI64Val() int64 { - if !p.IsSetOptI64Val() { - return MyStructEnsureStruct_OptI64Val_DEFAULT - } - return *p.OptI64Val -} -var MyStructEnsureStruct_OptI32Val_DEFAULT int32 -func (p *MyStructEnsureStruct) GetOptI32Val() int32 { - if !p.IsSetOptI32Val() { - return MyStructEnsureStruct_OptI32Val_DEFAULT - } - return *p.OptI32Val -} -var MyStructEnsureStruct_OptI16Val_DEFAULT int16 -func (p *MyStructEnsureStruct) GetOptI16Val() int16 { - if !p.IsSetOptI16Val() { - return MyStructEnsureStruct_OptI16Val_DEFAULT - } - return *p.OptI16Val -} -var MyStructEnsureStruct_OptByteVal_DEFAULT int8 -func (p *MyStructEnsureStruct) GetOptByteVal() int8 { - if !p.IsSetOptByteVal() { - return MyStructEnsureStruct_OptByteVal_DEFAULT - } - return *p.OptByteVal -} -var MyStructEnsureStruct_OptBoolVal_DEFAULT bool -func (p *MyStructEnsureStruct) GetOptBoolVal() bool { - if !p.IsSetOptBoolVal() { - return MyStructEnsureStruct_OptBoolVal_DEFAULT - } - return *p.OptBoolVal -} -var MyStructEnsureStruct_LateStructVal_DEFAULT *LateDefStruct -func (p *MyStructEnsureStruct) GetLateStructVal() *LateDefStruct { - if !p.IsSetLateStructVal() { - return MyStructEnsureStruct_LateStructVal_DEFAULT - } - return p.LateStructVal -} -var MyStructEnsureStruct_UnionVal_DEFAULT *MyUnion -func (p *MyStructEnsureStruct) GetUnionVal() *MyUnion { - if !p.IsSetUnionVal() { - return MyStructEnsureStruct_UnionVal_DEFAULT - } - return p.UnionVal -} -func (p *MyStructEnsureStruct) DefaultGetUnionVal() *MyUnion { - if !p.IsSetUnionVal() { - return NewMyUnion() - } - return p.UnionVal -} -var MyStructEnsureStruct_StructVal_DEFAULT *MyData -func (p *MyStructEnsureStruct) GetStructVal() *MyData { - if !p.IsSetStructVal() { - return MyStructEnsureStruct_StructVal_DEFAULT - } - return p.StructVal -} -func (p *MyStructEnsureStruct) DefaultGetStructVal() *MyData { - if !p.IsSetStructVal() { - return NewMyData() - } - return p.StructVal -} -var MyStructEnsureStruct_EnumVal_DEFAULT MyEnum -func (p *MyStructEnsureStruct) GetEnumVal() MyEnum { - if !p.IsSetEnumVal() { - return MyStructEnsureStruct_EnumVal_DEFAULT - } - return *p.EnumVal -} -var MyStructEnsureStruct_BinaryVal_DEFAULT []byte - -func (p *MyStructEnsureStruct) GetBinaryVal() []byte { - return p.BinaryVal -} -var MyStructEnsureStruct_StringVal_DEFAULT string -func (p *MyStructEnsureStruct) GetStringVal() string { - if !p.IsSetStringVal() { - return MyStructEnsureStruct_StringVal_DEFAULT - } - return *p.StringVal -} -var MyStructEnsureStruct_DoubleVal_DEFAULT float64 -func (p *MyStructEnsureStruct) GetDoubleVal() float64 { - if !p.IsSetDoubleVal() { - return MyStructEnsureStruct_DoubleVal_DEFAULT - } - return *p.DoubleVal -} -var MyStructEnsureStruct_FloatVal_DEFAULT float32 -func (p *MyStructEnsureStruct) GetFloatVal() float32 { - if !p.IsSetFloatVal() { - return MyStructEnsureStruct_FloatVal_DEFAULT - } - return *p.FloatVal -} -var MyStructEnsureStruct_I64Val_DEFAULT int64 -func (p *MyStructEnsureStruct) GetI64Val() int64 { - if !p.IsSetI64Val() { - return MyStructEnsureStruct_I64Val_DEFAULT - } - return *p.I64Val -} -var MyStructEnsureStruct_I32Val_DEFAULT int32 -func (p *MyStructEnsureStruct) GetI32Val() int32 { - if !p.IsSetI32Val() { - return MyStructEnsureStruct_I32Val_DEFAULT - } - return *p.I32Val -} -var MyStructEnsureStruct_I16Val_DEFAULT int16 -func (p *MyStructEnsureStruct) GetI16Val() int16 { - if !p.IsSetI16Val() { - return MyStructEnsureStruct_I16Val_DEFAULT - } - return *p.I16Val -} -var MyStructEnsureStruct_ByteVal_DEFAULT int8 -func (p *MyStructEnsureStruct) GetByteVal() int8 { - if !p.IsSetByteVal() { - return MyStructEnsureStruct_ByteVal_DEFAULT - } - return *p.ByteVal -} -var MyStructEnsureStruct_BoolVal_DEFAULT bool -func (p *MyStructEnsureStruct) GetBoolVal() bool { - if !p.IsSetBoolVal() { - return MyStructEnsureStruct_BoolVal_DEFAULT - } - return *p.BoolVal -} -var MyStructEnsureStruct_StructWithFieldCustomDefault_DEFAULT *MyData -func (p *MyStructEnsureStruct) GetStructWithFieldCustomDefault() *MyData { - if !p.IsSetStructWithFieldCustomDefault() { - return MyStructEnsureStruct_StructWithFieldCustomDefault_DEFAULT - } - return p.StructWithFieldCustomDefault -} -func (p *MyStructEnsureStruct) DefaultGetStructWithFieldCustomDefault() *MyData { - if !p.IsSetStructWithFieldCustomDefault() { - return NewMyData() - } - return p.StructWithFieldCustomDefault -} -func (p *MyStructEnsureStruct) IsSetStructWithCustomDefault() bool { - return p != nil && p.StructWithCustomDefault != nil -} - -func (p *MyStructEnsureStruct) IsSetI32WithCustomDefault() bool { - return p != nil && p.I32WithCustomDefault != nil -} - -func (p *MyStructEnsureStruct) IsSetMapMap() bool { - return p != nil && p.MapMap != nil -} - -func (p *MyStructEnsureStruct) IsSetListMap() bool { - return p != nil && p.ListMap != nil -} - -func (p *MyStructEnsureStruct) IsSetOptMapVal() bool { - return p != nil && p.OptMapVal != nil -} - -func (p *MyStructEnsureStruct) IsSetOptSetVal() bool { - return p != nil && p.OptSetVal != nil -} - -func (p *MyStructEnsureStruct) IsSetOptListVal() bool { - return p != nil && p.OptListVal != nil -} - -func (p *MyStructEnsureStruct) IsSetOptLateStructVal() bool { - return p != nil && p.OptLateStructVal != nil -} - -func (p *MyStructEnsureStruct) IsSetOptStructVal() bool { - return p != nil && p.OptStructVal != nil -} - -func (p *MyStructEnsureStruct) IsSetOptEnumVal() bool { - return p != nil && p.OptEnumVal != nil -} - -func (p *MyStructEnsureStruct) IsSetOptBinaryVal() bool { - return p != nil && p.OptBinaryVal != nil -} - -func (p *MyStructEnsureStruct) IsSetOptStringVal() bool { - return p != nil && p.OptStringVal != nil -} - -func (p *MyStructEnsureStruct) IsSetOptDoubleVal() bool { - return p != nil && p.OptDoubleVal != nil -} - -func (p *MyStructEnsureStruct) IsSetOptFloatVal() bool { - return p != nil && p.OptFloatVal != nil -} - -func (p *MyStructEnsureStruct) IsSetOptI64Val() bool { - return p != nil && p.OptI64Val != nil -} - -func (p *MyStructEnsureStruct) IsSetOptI32Val() bool { - return p != nil && p.OptI32Val != nil -} - -func (p *MyStructEnsureStruct) IsSetOptI16Val() bool { - return p != nil && p.OptI16Val != nil -} - -func (p *MyStructEnsureStruct) IsSetOptByteVal() bool { - return p != nil && p.OptByteVal != nil -} - -func (p *MyStructEnsureStruct) IsSetOptBoolVal() bool { - return p != nil && p.OptBoolVal != nil -} - -func (p *MyStructEnsureStruct) IsSetLateStructVal() bool { - return p != nil && p.LateStructVal != nil -} - -func (p *MyStructEnsureStruct) IsSetUnionVal() bool { - return p != nil && p.UnionVal != nil -} - -func (p *MyStructEnsureStruct) IsSetStructVal() bool { - return p != nil && p.StructVal != nil -} - -func (p *MyStructEnsureStruct) IsSetEnumVal() bool { - return p != nil && p.EnumVal != nil -} - -func (p *MyStructEnsureStruct) IsSetBinaryVal() bool { - return p != nil && p.BinaryVal != nil -} - -func (p *MyStructEnsureStruct) IsSetStringVal() bool { - return p != nil && p.StringVal != nil -} - -func (p *MyStructEnsureStruct) IsSetDoubleVal() bool { - return p != nil && p.DoubleVal != nil -} - -func (p *MyStructEnsureStruct) IsSetFloatVal() bool { - return p != nil && p.FloatVal != nil -} - -func (p *MyStructEnsureStruct) IsSetI64Val() bool { - return p != nil && p.I64Val != nil -} - -func (p *MyStructEnsureStruct) IsSetI32Val() bool { - return p != nil && p.I32Val != nil -} - -func (p *MyStructEnsureStruct) IsSetI16Val() bool { - return p != nil && p.I16Val != nil -} - -func (p *MyStructEnsureStruct) IsSetByteVal() bool { - return p != nil && p.ByteVal != nil -} - -func (p *MyStructEnsureStruct) IsSetBoolVal() bool { - return p != nil && p.BoolVal != nil -} - -func (p *MyStructEnsureStruct) IsSetStructWithFieldCustomDefault() bool { - return p != nil && p.StructWithFieldCustomDefault != nil -} - -type MyStructEnsureStructBuilder struct { - obj *MyStructEnsureStruct -} - -func NewMyStructEnsureStructBuilder() *MyStructEnsureStructBuilder{ - return &MyStructEnsureStructBuilder{ - obj: NewMyStructEnsureStruct(), - } -} - -func (p MyStructEnsureStructBuilder) Emit() *MyStructEnsureStruct{ - return &MyStructEnsureStruct{ - StructWithCustomDefault: p.obj.StructWithCustomDefault, - I32WithCustomDefault: p.obj.I32WithCustomDefault, - MapMap: p.obj.MapMap, - ListMap: p.obj.ListMap, - OptMapVal: p.obj.OptMapVal, - OptSetVal: p.obj.OptSetVal, - OptListVal: p.obj.OptListVal, - OptLateStructVal: p.obj.OptLateStructVal, - OptStructVal: p.obj.OptStructVal, - OptEnumVal: p.obj.OptEnumVal, - OptBinaryVal: p.obj.OptBinaryVal, - OptStringVal: p.obj.OptStringVal, - OptDoubleVal: p.obj.OptDoubleVal, - OptFloatVal: p.obj.OptFloatVal, - OptI64Val: p.obj.OptI64Val, - OptI32Val: p.obj.OptI32Val, - OptI16Val: p.obj.OptI16Val, - OptByteVal: p.obj.OptByteVal, - OptBoolVal: p.obj.OptBoolVal, - LateStructVal: p.obj.LateStructVal, - UnionVal: p.obj.UnionVal, - StructVal: p.obj.StructVal, - EnumVal: p.obj.EnumVal, - BinaryVal: p.obj.BinaryVal, - StringVal: p.obj.StringVal, - DoubleVal: p.obj.DoubleVal, - FloatVal: p.obj.FloatVal, - I64Val: p.obj.I64Val, - I32Val: p.obj.I32Val, - I16Val: p.obj.I16Val, - ByteVal: p.obj.ByteVal, - BoolVal: p.obj.BoolVal, - StructWithFieldCustomDefault: p.obj.StructWithFieldCustomDefault, - } -} - -func (m *MyStructEnsureStructBuilder) StructWithCustomDefault(structWithCustomDefault *MyDataWithCustomDefault) *MyStructEnsureStructBuilder { - m.obj.StructWithCustomDefault = structWithCustomDefault - return m -} - -func (m *MyStructEnsureStructBuilder) I32WithCustomDefault(i32WithCustomDefault *int32) *MyStructEnsureStructBuilder { - m.obj.I32WithCustomDefault = i32WithCustomDefault - return m -} - -func (m *MyStructEnsureStructBuilder) MapMap(mapMap map[string]map[string]int32) *MyStructEnsureStructBuilder { - m.obj.MapMap = mapMap - return m -} - -func (m *MyStructEnsureStructBuilder) ListMap(listMap []map[string]int32) *MyStructEnsureStructBuilder { - m.obj.ListMap = listMap - return m -} - -func (m *MyStructEnsureStructBuilder) OptMapVal(optMapVal map[string]string) *MyStructEnsureStructBuilder { - m.obj.OptMapVal = optMapVal - return m -} - -func (m *MyStructEnsureStructBuilder) OptSetVal(optSetVal []string) *MyStructEnsureStructBuilder { - m.obj.OptSetVal = optSetVal - return m -} - -func (m *MyStructEnsureStructBuilder) OptListVal(optListVal []int16) *MyStructEnsureStructBuilder { - m.obj.OptListVal = optListVal - return m -} - -func (m *MyStructEnsureStructBuilder) OptLateStructVal(optLateStructVal *LateDefStruct) *MyStructEnsureStructBuilder { - m.obj.OptLateStructVal = optLateStructVal - return m -} - -func (m *MyStructEnsureStructBuilder) OptStructVal(optStructVal *MyData) *MyStructEnsureStructBuilder { - m.obj.OptStructVal = optStructVal - return m -} - -func (m *MyStructEnsureStructBuilder) OptEnumVal(optEnumVal *MyEnum) *MyStructEnsureStructBuilder { - m.obj.OptEnumVal = optEnumVal - return m -} - -func (m *MyStructEnsureStructBuilder) OptBinaryVal(optBinaryVal []byte) *MyStructEnsureStructBuilder { - m.obj.OptBinaryVal = optBinaryVal - return m -} - -func (m *MyStructEnsureStructBuilder) OptStringVal(optStringVal *string) *MyStructEnsureStructBuilder { - m.obj.OptStringVal = optStringVal - return m -} - -func (m *MyStructEnsureStructBuilder) OptDoubleVal(optDoubleVal *float64) *MyStructEnsureStructBuilder { - m.obj.OptDoubleVal = optDoubleVal - return m -} - -func (m *MyStructEnsureStructBuilder) OptFloatVal(optFloatVal *float32) *MyStructEnsureStructBuilder { - m.obj.OptFloatVal = optFloatVal - return m -} - -func (m *MyStructEnsureStructBuilder) OptI64Val(optI64Val *int64) *MyStructEnsureStructBuilder { - m.obj.OptI64Val = optI64Val - return m -} - -func (m *MyStructEnsureStructBuilder) OptI32Val(optI32Val *int32) *MyStructEnsureStructBuilder { - m.obj.OptI32Val = optI32Val - return m -} - -func (m *MyStructEnsureStructBuilder) OptI16Val(optI16Val *int16) *MyStructEnsureStructBuilder { - m.obj.OptI16Val = optI16Val - return m -} - -func (m *MyStructEnsureStructBuilder) OptByteVal(optByteVal *int8) *MyStructEnsureStructBuilder { - m.obj.OptByteVal = optByteVal - return m -} - -func (m *MyStructEnsureStructBuilder) OptBoolVal(optBoolVal *bool) *MyStructEnsureStructBuilder { - m.obj.OptBoolVal = optBoolVal - return m -} - -func (m *MyStructEnsureStructBuilder) LateStructVal(lateStructVal *LateDefStruct) *MyStructEnsureStructBuilder { - m.obj.LateStructVal = lateStructVal - return m -} - -func (m *MyStructEnsureStructBuilder) UnionVal(unionVal *MyUnion) *MyStructEnsureStructBuilder { - m.obj.UnionVal = unionVal - return m -} - -func (m *MyStructEnsureStructBuilder) StructVal(structVal *MyData) *MyStructEnsureStructBuilder { - m.obj.StructVal = structVal - return m -} - -func (m *MyStructEnsureStructBuilder) EnumVal(enumVal *MyEnum) *MyStructEnsureStructBuilder { - m.obj.EnumVal = enumVal - return m -} - -func (m *MyStructEnsureStructBuilder) BinaryVal(binaryVal []byte) *MyStructEnsureStructBuilder { - m.obj.BinaryVal = binaryVal - return m -} - -func (m *MyStructEnsureStructBuilder) StringVal(stringVal *string) *MyStructEnsureStructBuilder { - m.obj.StringVal = stringVal - return m -} - -func (m *MyStructEnsureStructBuilder) DoubleVal(doubleVal *float64) *MyStructEnsureStructBuilder { - m.obj.DoubleVal = doubleVal - return m -} - -func (m *MyStructEnsureStructBuilder) FloatVal(floatVal *float32) *MyStructEnsureStructBuilder { - m.obj.FloatVal = floatVal - return m -} - -func (m *MyStructEnsureStructBuilder) I64Val(i64Val *int64) *MyStructEnsureStructBuilder { - m.obj.I64Val = i64Val - return m -} - -func (m *MyStructEnsureStructBuilder) I32Val(i32Val *int32) *MyStructEnsureStructBuilder { - m.obj.I32Val = i32Val - return m -} - -func (m *MyStructEnsureStructBuilder) I16Val(i16Val *int16) *MyStructEnsureStructBuilder { - m.obj.I16Val = i16Val - return m -} - -func (m *MyStructEnsureStructBuilder) ByteVal(byteVal *int8) *MyStructEnsureStructBuilder { - m.obj.ByteVal = byteVal - return m -} - -func (m *MyStructEnsureStructBuilder) BoolVal(boolVal *bool) *MyStructEnsureStructBuilder { - m.obj.BoolVal = boolVal - return m -} - -func (m *MyStructEnsureStructBuilder) StructWithFieldCustomDefault(structWithFieldCustomDefault *MyData) *MyStructEnsureStructBuilder { - m.obj.StructWithFieldCustomDefault = structWithFieldCustomDefault - return m -} - -func (m *MyStructEnsureStruct) SetStructWithCustomDefault(structWithCustomDefault *MyDataWithCustomDefault) *MyStructEnsureStruct { - m.StructWithCustomDefault = structWithCustomDefault - return m -} - -func (m *MyStructEnsureStruct) SetI32WithCustomDefault(i32WithCustomDefault *int32) *MyStructEnsureStruct { - m.I32WithCustomDefault = i32WithCustomDefault - return m -} - -func (m *MyStructEnsureStruct) SetMapMap(mapMap map[string]map[string]int32) *MyStructEnsureStruct { - m.MapMap = mapMap - return m -} - -func (m *MyStructEnsureStruct) SetListMap(listMap []map[string]int32) *MyStructEnsureStruct { - m.ListMap = listMap - return m -} - -func (m *MyStructEnsureStruct) SetOptMapVal(optMapVal map[string]string) *MyStructEnsureStruct { - m.OptMapVal = optMapVal - return m -} - -func (m *MyStructEnsureStruct) SetOptSetVal(optSetVal []string) *MyStructEnsureStruct { - m.OptSetVal = optSetVal - return m -} - -func (m *MyStructEnsureStruct) SetOptListVal(optListVal []int16) *MyStructEnsureStruct { - m.OptListVal = optListVal - return m -} - -func (m *MyStructEnsureStruct) SetOptLateStructVal(optLateStructVal *LateDefStruct) *MyStructEnsureStruct { - m.OptLateStructVal = optLateStructVal - return m -} - -func (m *MyStructEnsureStruct) SetOptStructVal(optStructVal *MyData) *MyStructEnsureStruct { - m.OptStructVal = optStructVal - return m -} - -func (m *MyStructEnsureStruct) SetOptEnumVal(optEnumVal *MyEnum) *MyStructEnsureStruct { - m.OptEnumVal = optEnumVal - return m -} - -func (m *MyStructEnsureStruct) SetOptBinaryVal(optBinaryVal []byte) *MyStructEnsureStruct { - m.OptBinaryVal = optBinaryVal - return m -} - -func (m *MyStructEnsureStruct) SetOptStringVal(optStringVal *string) *MyStructEnsureStruct { - m.OptStringVal = optStringVal - return m -} - -func (m *MyStructEnsureStruct) SetOptDoubleVal(optDoubleVal *float64) *MyStructEnsureStruct { - m.OptDoubleVal = optDoubleVal - return m -} - -func (m *MyStructEnsureStruct) SetOptFloatVal(optFloatVal *float32) *MyStructEnsureStruct { - m.OptFloatVal = optFloatVal - return m -} - -func (m *MyStructEnsureStruct) SetOptI64Val(optI64Val *int64) *MyStructEnsureStruct { - m.OptI64Val = optI64Val - return m -} - -func (m *MyStructEnsureStruct) SetOptI32Val(optI32Val *int32) *MyStructEnsureStruct { - m.OptI32Val = optI32Val - return m -} - -func (m *MyStructEnsureStruct) SetOptI16Val(optI16Val *int16) *MyStructEnsureStruct { - m.OptI16Val = optI16Val - return m -} - -func (m *MyStructEnsureStruct) SetOptByteVal(optByteVal *int8) *MyStructEnsureStruct { - m.OptByteVal = optByteVal - return m -} - -func (m *MyStructEnsureStruct) SetOptBoolVal(optBoolVal *bool) *MyStructEnsureStruct { - m.OptBoolVal = optBoolVal - return m -} - -func (m *MyStructEnsureStruct) SetLateStructVal(lateStructVal *LateDefStruct) *MyStructEnsureStruct { - m.LateStructVal = lateStructVal - return m -} - -func (m *MyStructEnsureStruct) SetUnionVal(unionVal *MyUnion) *MyStructEnsureStruct { - m.UnionVal = unionVal - return m -} - -func (m *MyStructEnsureStruct) SetStructVal(structVal *MyData) *MyStructEnsureStruct { - m.StructVal = structVal - return m -} - -func (m *MyStructEnsureStruct) SetEnumVal(enumVal *MyEnum) *MyStructEnsureStruct { - m.EnumVal = enumVal - return m -} - -func (m *MyStructEnsureStruct) SetBinaryVal(binaryVal []byte) *MyStructEnsureStruct { - m.BinaryVal = binaryVal - return m -} - -func (m *MyStructEnsureStruct) SetStringVal(stringVal *string) *MyStructEnsureStruct { - m.StringVal = stringVal - return m -} - -func (m *MyStructEnsureStruct) SetDoubleVal(doubleVal *float64) *MyStructEnsureStruct { - m.DoubleVal = doubleVal - return m -} - -func (m *MyStructEnsureStruct) SetFloatVal(floatVal *float32) *MyStructEnsureStruct { - m.FloatVal = floatVal - return m -} - -func (m *MyStructEnsureStruct) SetI64Val(i64Val *int64) *MyStructEnsureStruct { - m.I64Val = i64Val - return m -} - -func (m *MyStructEnsureStruct) SetI32Val(i32Val *int32) *MyStructEnsureStruct { - m.I32Val = i32Val - return m -} - -func (m *MyStructEnsureStruct) SetI16Val(i16Val *int16) *MyStructEnsureStruct { - m.I16Val = i16Val - return m -} - -func (m *MyStructEnsureStruct) SetByteVal(byteVal *int8) *MyStructEnsureStruct { - m.ByteVal = byteVal - return m -} - -func (m *MyStructEnsureStruct) SetBoolVal(boolVal *bool) *MyStructEnsureStruct { - m.BoolVal = boolVal - return m -} - -func (m *MyStructEnsureStruct) SetStructWithFieldCustomDefault(structWithFieldCustomDefault *MyData) *MyStructEnsureStruct { - m.StructWithFieldCustomDefault = structWithFieldCustomDefault - return m -} - -func (p *MyStructEnsureStruct) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case -32: - if err := p.ReadField_32(iprot); err != nil { - return err - } - case -31: - if err := p.ReadField_31(iprot); err != nil { - return err - } - case -30: - if err := p.ReadField_30(iprot); err != nil { - return err - } - case -29: - if err := p.ReadField_29(iprot); err != nil { - return err - } - case -28: - if err := p.ReadField_28(iprot); err != nil { - return err - } - case -27: - if err := p.ReadField_27(iprot); err != nil { - return err - } - case -26: - if err := p.ReadField_26(iprot); err != nil { - return err - } - case -25: - if err := p.ReadField_25(iprot); err != nil { - return err - } - case -24: - if err := p.ReadField_24(iprot); err != nil { - return err - } - case -23: - if err := p.ReadField_23(iprot); err != nil { - return err - } - case -22: - if err := p.ReadField_22(iprot); err != nil { - return err - } - case -21: - if err := p.ReadField_21(iprot); err != nil { - return err - } - case -20: - if err := p.ReadField_20(iprot); err != nil { - return err - } - case -19: - if err := p.ReadField_19(iprot); err != nil { - return err - } - case -18: - if err := p.ReadField_18(iprot); err != nil { - return err - } - case -17: - if err := p.ReadField_17(iprot); err != nil { - return err - } - case -16: - if err := p.ReadField_16(iprot); err != nil { - return err - } - case -15: - if err := p.ReadField_15(iprot); err != nil { - return err - } - case -14: - if err := p.ReadField_14(iprot); err != nil { - return err - } - case -13: - if err := p.ReadField_13(iprot); err != nil { - return err - } - case -12: - if err := p.ReadField_12(iprot); err != nil { - return err - } - case -11: - if err := p.ReadField_11(iprot); err != nil { - return err - } - case -10: - if err := p.ReadField_10(iprot); err != nil { - return err - } - case -9: - if err := p.ReadField_9(iprot); err != nil { - return err - } - case -8: - if err := p.ReadField_8(iprot); err != nil { - return err - } - case -7: - if err := p.ReadField_7(iprot); err != nil { - return err - } - case -6: - if err := p.ReadField_6(iprot); err != nil { - return err - } - case -5: - if err := p.ReadField_5(iprot); err != nil { - return err - } - case -4: - if err := p.ReadField_4(iprot); err != nil { - return err - } - case -3: - if err := p.ReadField_3(iprot); err != nil { - return err - } - case -2: - if err := p.ReadField_2(iprot); err != nil { - return err - } - case -1: - if err := p.ReadField_1(iprot); err != nil { - return err - } - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyStructEnsureStruct) ReadField_32(iprot thrift.Protocol) error { - p.StructWithCustomDefault = NewMyDataWithCustomDefault() - if err := p.StructWithCustomDefault.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.StructWithCustomDefault), err) - } - return nil -} - -func (p *MyStructEnsureStruct) ReadField_31(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field -31: ", err) - } else { - p.I32WithCustomDefault = &v - } - return nil -} - -func (p *MyStructEnsureStruct) ReadField_30(iprot thrift.Protocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[string]map[string]int32, size) - p.MapMap = tMap - for i := 0; i < size; i ++ { - var _key72 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key72 = v - } - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[string]int32, size) - _val73 := tMap - for i := 0; i < size; i ++ { - var _key74 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key74 = v - } - var _val75 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _val75 = v - } - _val73[_key74] = _val75 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - p.MapMap[_key72] = _val73 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *MyStructEnsureStruct) ReadField_29(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]map[string]int32, 0, size) - p.ListMap = tSlice - for i := 0; i < size; i ++ { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[string]int32, size) - _elem76 := tMap - for i := 0; i < size; i ++ { - var _key77 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key77 = v - } - var _val78 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _val78 = v - } - _elem76[_key77] = _val78 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - p.ListMap = append(p.ListMap, _elem76) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *MyStructEnsureStruct) ReadField_28(iprot thrift.Protocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[string]string, size) - p.OptMapVal = tMap - for i := 0; i < size; i ++ { - var _key79 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key79 = v - } - var _val80 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _val80 = v - } - p.OptMapVal[_key79] = _val80 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *MyStructEnsureStruct) ReadField_27(iprot thrift.Protocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return thrift.PrependError("error reading set begin: ", err) - } - tSet := make([]string, 0, size) - p.OptSetVal = tSet - for i := 0; i < size; i ++ { - var _elem81 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem81 = v - } - p.OptSetVal = append(p.OptSetVal, _elem81) - } - if err := iprot.ReadSetEnd(); err != nil { - return thrift.PrependError("error reading set end: ", err) - } - return nil -} - -func (p *MyStructEnsureStruct) ReadField_26(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]int16, 0, size) - p.OptListVal = tSlice - for i := 0; i < size; i ++ { - var _elem82 int16 - if v, err := iprot.ReadI16(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem82 = v - } - p.OptListVal = append(p.OptListVal, _elem82) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *MyStructEnsureStruct) ReadField_25(iprot thrift.Protocol) error { - p.OptLateStructVal = NewLateDefStruct() - if err := p.OptLateStructVal.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.OptLateStructVal), err) - } - return nil -} - -func (p *MyStructEnsureStruct) ReadField_24(iprot thrift.Protocol) error { - p.OptStructVal = NewMyData() - if err := p.OptStructVal.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.OptStructVal), err) - } - return nil -} - -func (p *MyStructEnsureStruct) ReadField_23(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field -23: ", err) - } else { - temp := MyEnum(v) - p.OptEnumVal = &temp - } - return nil -} - -func (p *MyStructEnsureStruct) ReadField_22(iprot thrift.Protocol) error { - if v, err := iprot.ReadBinary(); err != nil { - return thrift.PrependError("error reading field -22: ", err) - } else { - p.OptBinaryVal = v - } - return nil -} - -func (p *MyStructEnsureStruct) ReadField_21(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field -21: ", err) - } else { - p.OptStringVal = &v - } - return nil -} - -func (p *MyStructEnsureStruct) ReadField_20(iprot thrift.Protocol) error { - if v, err := iprot.ReadDouble(); err != nil { - return thrift.PrependError("error reading field -20: ", err) - } else { - p.OptDoubleVal = &v - } - return nil -} - -func (p *MyStructEnsureStruct) ReadField_19(iprot thrift.Protocol) error { - if v, err := iprot.ReadFloat(); err != nil { - return thrift.PrependError("error reading field -19: ", err) - } else { - p.OptFloatVal = &v - } - return nil -} - -func (p *MyStructEnsureStruct) ReadField_18(iprot thrift.Protocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field -18: ", err) - } else { - p.OptI64Val = &v - } - return nil -} - -func (p *MyStructEnsureStruct) ReadField_17(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field -17: ", err) - } else { - p.OptI32Val = &v - } - return nil -} - -func (p *MyStructEnsureStruct) ReadField_16(iprot thrift.Protocol) error { - if v, err := iprot.ReadI16(); err != nil { - return thrift.PrependError("error reading field -16: ", err) - } else { - p.OptI16Val = &v - } - return nil -} - -func (p *MyStructEnsureStruct) ReadField_15(iprot thrift.Protocol) error { - if v, err := iprot.ReadByte(); err != nil { - return thrift.PrependError("error reading field -15: ", err) - } else { - temp := int8(v) - p.OptByteVal = &temp - } - return nil -} - -func (p *MyStructEnsureStruct) ReadField_14(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field -14: ", err) - } else { - p.OptBoolVal = &v - } - return nil -} - -func (p *MyStructEnsureStruct) ReadField_13(iprot thrift.Protocol) error { - p.LateStructVal = NewLateDefStruct() - if err := p.LateStructVal.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.LateStructVal), err) - } - return nil -} - -func (p *MyStructEnsureStruct) ReadField_12(iprot thrift.Protocol) error { - p.UnionVal = NewMyUnion() - if err := p.UnionVal.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.UnionVal), err) - } - return nil -} - -func (p *MyStructEnsureStruct) ReadField_11(iprot thrift.Protocol) error { - p.StructVal = NewMyData() - if err := p.StructVal.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.StructVal), err) - } - return nil -} - -func (p *MyStructEnsureStruct) ReadField_10(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field -10: ", err) - } else { - temp := MyEnum(v) - p.EnumVal = &temp - } - return nil -} - -func (p *MyStructEnsureStruct) ReadField_9(iprot thrift.Protocol) error { - if v, err := iprot.ReadBinary(); err != nil { - return thrift.PrependError("error reading field -9: ", err) - } else { - p.BinaryVal = v - } - return nil -} - -func (p *MyStructEnsureStruct) ReadField_8(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field -8: ", err) - } else { - p.StringVal = &v - } - return nil -} - -func (p *MyStructEnsureStruct) ReadField_7(iprot thrift.Protocol) error { - if v, err := iprot.ReadDouble(); err != nil { - return thrift.PrependError("error reading field -7: ", err) - } else { - p.DoubleVal = &v - } - return nil -} - -func (p *MyStructEnsureStruct) ReadField_6(iprot thrift.Protocol) error { - if v, err := iprot.ReadFloat(); err != nil { - return thrift.PrependError("error reading field -6: ", err) - } else { - p.FloatVal = &v - } - return nil -} - -func (p *MyStructEnsureStruct) ReadField_5(iprot thrift.Protocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field -5: ", err) - } else { - p.I64Val = &v - } - return nil -} - -func (p *MyStructEnsureStruct) ReadField_4(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field -4: ", err) - } else { - p.I32Val = &v - } - return nil -} - -func (p *MyStructEnsureStruct) ReadField_3(iprot thrift.Protocol) error { - if v, err := iprot.ReadI16(); err != nil { - return thrift.PrependError("error reading field -3: ", err) - } else { - p.I16Val = &v - } - return nil -} - -func (p *MyStructEnsureStruct) ReadField_2(iprot thrift.Protocol) error { - if v, err := iprot.ReadByte(); err != nil { - return thrift.PrependError("error reading field -2: ", err) - } else { - temp := int8(v) - p.ByteVal = &temp - } - return nil -} - -func (p *MyStructEnsureStruct) ReadField_1(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field -1: ", err) - } else { - p.BoolVal = &v - } - return nil -} - -func (p *MyStructEnsureStruct) ReadField1(iprot thrift.Protocol) error { - p.StructWithFieldCustomDefault = NewMyData() - if err := p.StructWithFieldCustomDefault.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.StructWithFieldCustomDefault), err) - } - return nil -} - -func (p *MyStructEnsureStruct) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("MyStructEnsureStruct"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField_32(oprot); err != nil { return err } - if err := p.writeField_31(oprot); err != nil { return err } - if err := p.writeField_30(oprot); err != nil { return err } - if err := p.writeField_29(oprot); err != nil { return err } - if err := p.writeField_28(oprot); err != nil { return err } - if err := p.writeField_27(oprot); err != nil { return err } - if err := p.writeField_26(oprot); err != nil { return err } - if err := p.writeField_25(oprot); err != nil { return err } - if err := p.writeField_24(oprot); err != nil { return err } - if err := p.writeField_23(oprot); err != nil { return err } - if err := p.writeField_22(oprot); err != nil { return err } - if err := p.writeField_21(oprot); err != nil { return err } - if err := p.writeField_20(oprot); err != nil { return err } - if err := p.writeField_19(oprot); err != nil { return err } - if err := p.writeField_18(oprot); err != nil { return err } - if err := p.writeField_17(oprot); err != nil { return err } - if err := p.writeField_16(oprot); err != nil { return err } - if err := p.writeField_15(oprot); err != nil { return err } - if err := p.writeField_14(oprot); err != nil { return err } - if err := p.writeField_13(oprot); err != nil { return err } - if err := p.writeField_12(oprot); err != nil { return err } - if err := p.writeField_11(oprot); err != nil { return err } - if err := p.writeField_10(oprot); err != nil { return err } - if err := p.writeField_9(oprot); err != nil { return err } - if err := p.writeField_8(oprot); err != nil { return err } - if err := p.writeField_7(oprot); err != nil { return err } - if err := p.writeField_6(oprot); err != nil { return err } - if err := p.writeField_5(oprot); err != nil { return err } - if err := p.writeField_4(oprot); err != nil { return err } - if err := p.writeField_3(oprot); err != nil { return err } - if err := p.writeField_2(oprot); err != nil { return err } - if err := p.writeField_1(oprot); err != nil { return err } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyStructEnsureStruct) writeField_32(oprot thrift.Protocol) (err error) { - if p.IsSetStructWithCustomDefault() { - if err := oprot.WriteFieldBegin("structWithCustomDefault", thrift.STRUCT, -32); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -32:structWithCustomDefault: ", p), err) } - if err := p.StructWithCustomDefault.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.StructWithCustomDefault), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -32:structWithCustomDefault: ", p), err) } - } - return err -} - -func (p *MyStructEnsureStruct) writeField_31(oprot thrift.Protocol) (err error) { - if p.IsSetI32WithCustomDefault() { - if err := oprot.WriteFieldBegin("i32WithCustomDefault", thrift.I32, -31); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -31:i32WithCustomDefault: ", p), err) } - if err := oprot.WriteI32(int32(*p.I32WithCustomDefault)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.i32WithCustomDefault (-31) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -31:i32WithCustomDefault: ", p), err) } - } - return err -} - -func (p *MyStructEnsureStruct) writeField_30(oprot thrift.Protocol) (err error) { - if p.IsSetMapMap() { - if err := oprot.WriteFieldBegin("mapMap", thrift.MAP, -30); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -30:mapMap: ", p), err) } - if err := oprot.WriteMapBegin(thrift.STRING, thrift.MAP, len(p.MapMap)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.MapMap { - if err := oprot.WriteString(string(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := oprot.WriteMapBegin(thrift.STRING, thrift.I32, len(v)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range v { - if err := oprot.WriteString(string(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := oprot.WriteI32(int32(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -30:mapMap: ", p), err) } - } - return err -} - -func (p *MyStructEnsureStruct) writeField_29(oprot thrift.Protocol) (err error) { - if p.IsSetListMap() { - if err := oprot.WriteFieldBegin("listMap", thrift.LIST, -29); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -29:listMap: ", p), err) } - if err := oprot.WriteListBegin(thrift.MAP, len(p.ListMap)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.ListMap { - if err := oprot.WriteMapBegin(thrift.STRING, thrift.I32, len(v)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range v { - if err := oprot.WriteString(string(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := oprot.WriteI32(int32(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -29:listMap: ", p), err) } - } - return err -} - -func (p *MyStructEnsureStruct) writeField_28(oprot thrift.Protocol) (err error) { - if p.IsSetOptMapVal() { - if err := oprot.WriteFieldBegin("optMapVal", thrift.MAP, -28); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -28:optMapVal: ", p), err) } - if err := oprot.WriteMapBegin(thrift.STRING, thrift.STRING, len(p.OptMapVal)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.OptMapVal { - if err := oprot.WriteString(string(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := oprot.WriteString(string(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -28:optMapVal: ", p), err) } - } - return err -} - -func (p *MyStructEnsureStruct) writeField_27(oprot thrift.Protocol) (err error) { - if p.IsSetOptSetVal() { - if err := oprot.WriteFieldBegin("optSetVal", thrift.SET, -27); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -27:optSetVal: ", p), err) } - if err := oprot.WriteSetBegin(thrift.STRING, len(p.OptSetVal)); err != nil { - return thrift.PrependError("error writing set begin: ", err) - } - set := make(map[string]bool, len(p.OptSetVal)) - for _, v := range p.OptSetVal { - if ok := set[v]; ok { - return thrift.PrependError("", fmt.Errorf("%T error writing set field: slice is not unique", v)) - } - set[v] = true - } - for _, v := range p.OptSetVal { - if err := oprot.WriteString(string(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteSetEnd(); err != nil { - return thrift.PrependError("error writing set end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -27:optSetVal: ", p), err) } - } - return err -} - -func (p *MyStructEnsureStruct) writeField_26(oprot thrift.Protocol) (err error) { - if p.IsSetOptListVal() { - if err := oprot.WriteFieldBegin("optListVal", thrift.LIST, -26); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -26:optListVal: ", p), err) } - if err := oprot.WriteListBegin(thrift.I16, len(p.OptListVal)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.OptListVal { - if err := oprot.WriteI16(int16(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -26:optListVal: ", p), err) } - } - return err -} - -func (p *MyStructEnsureStruct) writeField_25(oprot thrift.Protocol) (err error) { - if p.IsSetOptLateStructVal() { - if err := oprot.WriteFieldBegin("optLateStructVal", thrift.STRUCT, -25); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -25:optLateStructVal: ", p), err) } - if err := p.OptLateStructVal.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.OptLateStructVal), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -25:optLateStructVal: ", p), err) } - } - return err -} - -func (p *MyStructEnsureStruct) writeField_24(oprot thrift.Protocol) (err error) { - if p.IsSetOptStructVal() { - if err := oprot.WriteFieldBegin("optStructVal", thrift.STRUCT, -24); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -24:optStructVal: ", p), err) } - if err := p.OptStructVal.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.OptStructVal), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -24:optStructVal: ", p), err) } - } - return err -} - -func (p *MyStructEnsureStruct) writeField_23(oprot thrift.Protocol) (err error) { - if p.IsSetOptEnumVal() { - if err := oprot.WriteFieldBegin("optEnumVal", thrift.I32, -23); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -23:optEnumVal: ", p), err) } - if err := oprot.WriteI32(int32(*p.OptEnumVal)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.optEnumVal (-23) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -23:optEnumVal: ", p), err) } - } - return err -} - -func (p *MyStructEnsureStruct) writeField_22(oprot thrift.Protocol) (err error) { - if p.IsSetOptBinaryVal() { - if err := oprot.WriteFieldBegin("optBinaryVal", thrift.STRING, -22); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -22:optBinaryVal: ", p), err) } - if err := oprot.WriteBinary(p.OptBinaryVal); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.optBinaryVal (-22) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -22:optBinaryVal: ", p), err) } - } - return err -} - -func (p *MyStructEnsureStruct) writeField_21(oprot thrift.Protocol) (err error) { - if p.IsSetOptStringVal() { - if err := oprot.WriteFieldBegin("optStringVal", thrift.STRING, -21); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -21:optStringVal: ", p), err) } - if err := oprot.WriteString(string(*p.OptStringVal)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.optStringVal (-21) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -21:optStringVal: ", p), err) } - } - return err -} - -func (p *MyStructEnsureStruct) writeField_20(oprot thrift.Protocol) (err error) { - if p.IsSetOptDoubleVal() { - if err := oprot.WriteFieldBegin("optDoubleVal", thrift.DOUBLE, -20); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -20:optDoubleVal: ", p), err) } - if err := oprot.WriteDouble(float64(*p.OptDoubleVal)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.optDoubleVal (-20) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -20:optDoubleVal: ", p), err) } - } - return err -} - -func (p *MyStructEnsureStruct) writeField_19(oprot thrift.Protocol) (err error) { - if p.IsSetOptFloatVal() { - if err := oprot.WriteFieldBegin("optFloatVal", thrift.FLOAT, -19); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -19:optFloatVal: ", p), err) } - if err := oprot.WriteFloat(float32(*p.OptFloatVal)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.optFloatVal (-19) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -19:optFloatVal: ", p), err) } - } - return err -} - -func (p *MyStructEnsureStruct) writeField_18(oprot thrift.Protocol) (err error) { - if p.IsSetOptI64Val() { - if err := oprot.WriteFieldBegin("optI64Val", thrift.I64, -18); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -18:optI64Val: ", p), err) } - if err := oprot.WriteI64(int64(*p.OptI64Val)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.optI64Val (-18) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -18:optI64Val: ", p), err) } - } - return err -} - -func (p *MyStructEnsureStruct) writeField_17(oprot thrift.Protocol) (err error) { - if p.IsSetOptI32Val() { - if err := oprot.WriteFieldBegin("optI32Val", thrift.I32, -17); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -17:optI32Val: ", p), err) } - if err := oprot.WriteI32(int32(*p.OptI32Val)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.optI32Val (-17) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -17:optI32Val: ", p), err) } - } - return err -} - -func (p *MyStructEnsureStruct) writeField_16(oprot thrift.Protocol) (err error) { - if p.IsSetOptI16Val() { - if err := oprot.WriteFieldBegin("optI16Val", thrift.I16, -16); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -16:optI16Val: ", p), err) } - if err := oprot.WriteI16(int16(*p.OptI16Val)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.optI16Val (-16) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -16:optI16Val: ", p), err) } - } - return err -} - -func (p *MyStructEnsureStruct) writeField_15(oprot thrift.Protocol) (err error) { - if p.IsSetOptByteVal() { - if err := oprot.WriteFieldBegin("optByteVal", thrift.BYTE, -15); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -15:optByteVal: ", p), err) } - if err := oprot.WriteByte(byte(*p.OptByteVal)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.optByteVal (-15) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -15:optByteVal: ", p), err) } - } - return err -} - -func (p *MyStructEnsureStruct) writeField_14(oprot thrift.Protocol) (err error) { - if p.IsSetOptBoolVal() { - if err := oprot.WriteFieldBegin("optBoolVal", thrift.BOOL, -14); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -14:optBoolVal: ", p), err) } - if err := oprot.WriteBool(bool(*p.OptBoolVal)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.optBoolVal (-14) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -14:optBoolVal: ", p), err) } - } - return err -} - -func (p *MyStructEnsureStruct) writeField_13(oprot thrift.Protocol) (err error) { - if p.IsSetLateStructVal() { - if err := oprot.WriteFieldBegin("lateStructVal", thrift.STRUCT, -13); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -13:lateStructVal: ", p), err) } - if err := p.LateStructVal.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.LateStructVal), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -13:lateStructVal: ", p), err) } - } - return err -} - -func (p *MyStructEnsureStruct) writeField_12(oprot thrift.Protocol) (err error) { - if p.IsSetUnionVal() { - if err := oprot.WriteFieldBegin("unionVal", thrift.STRUCT, -12); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -12:unionVal: ", p), err) } - if err := p.UnionVal.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.UnionVal), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -12:unionVal: ", p), err) } - } - return err -} - -func (p *MyStructEnsureStruct) writeField_11(oprot thrift.Protocol) (err error) { - if p.IsSetStructVal() { - if err := oprot.WriteFieldBegin("structVal", thrift.STRUCT, -11); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -11:structVal: ", p), err) } - if err := p.StructVal.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.StructVal), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -11:structVal: ", p), err) } - } - return err -} - -func (p *MyStructEnsureStruct) writeField_10(oprot thrift.Protocol) (err error) { - if p.IsSetEnumVal() { - if err := oprot.WriteFieldBegin("enumVal", thrift.I32, -10); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -10:enumVal: ", p), err) } - if err := oprot.WriteI32(int32(*p.EnumVal)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.enumVal (-10) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -10:enumVal: ", p), err) } - } - return err -} - -func (p *MyStructEnsureStruct) writeField_9(oprot thrift.Protocol) (err error) { - if p.IsSetBinaryVal() { - if err := oprot.WriteFieldBegin("binaryVal", thrift.STRING, -9); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -9:binaryVal: ", p), err) } - if err := oprot.WriteBinary(p.BinaryVal); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.binaryVal (-9) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -9:binaryVal: ", p), err) } - } - return err -} - -func (p *MyStructEnsureStruct) writeField_8(oprot thrift.Protocol) (err error) { - if p.IsSetStringVal() { - if err := oprot.WriteFieldBegin("stringVal", thrift.STRING, -8); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -8:stringVal: ", p), err) } - if err := oprot.WriteString(string(*p.StringVal)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.stringVal (-8) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -8:stringVal: ", p), err) } - } - return err -} - -func (p *MyStructEnsureStruct) writeField_7(oprot thrift.Protocol) (err error) { - if p.IsSetDoubleVal() { - if err := oprot.WriteFieldBegin("doubleVal", thrift.DOUBLE, -7); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -7:doubleVal: ", p), err) } - if err := oprot.WriteDouble(float64(*p.DoubleVal)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.doubleVal (-7) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -7:doubleVal: ", p), err) } - } - return err -} - -func (p *MyStructEnsureStruct) writeField_6(oprot thrift.Protocol) (err error) { - if p.IsSetFloatVal() { - if err := oprot.WriteFieldBegin("floatVal", thrift.FLOAT, -6); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -6:floatVal: ", p), err) } - if err := oprot.WriteFloat(float32(*p.FloatVal)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.floatVal (-6) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -6:floatVal: ", p), err) } - } - return err -} - -func (p *MyStructEnsureStruct) writeField_5(oprot thrift.Protocol) (err error) { - if p.IsSetI64Val() { - if err := oprot.WriteFieldBegin("i64Val", thrift.I64, -5); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -5:i64Val: ", p), err) } - if err := oprot.WriteI64(int64(*p.I64Val)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.i64Val (-5) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -5:i64Val: ", p), err) } - } - return err -} - -func (p *MyStructEnsureStruct) writeField_4(oprot thrift.Protocol) (err error) { - if p.IsSetI32Val() { - if err := oprot.WriteFieldBegin("i32Val", thrift.I32, -4); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -4:i32Val: ", p), err) } - if err := oprot.WriteI32(int32(*p.I32Val)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.i32Val (-4) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -4:i32Val: ", p), err) } - } - return err -} - -func (p *MyStructEnsureStruct) writeField_3(oprot thrift.Protocol) (err error) { - if p.IsSetI16Val() { - if err := oprot.WriteFieldBegin("i16Val", thrift.I16, -3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -3:i16Val: ", p), err) } - if err := oprot.WriteI16(int16(*p.I16Val)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.i16Val (-3) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -3:i16Val: ", p), err) } - } - return err -} - -func (p *MyStructEnsureStruct) writeField_2(oprot thrift.Protocol) (err error) { - if p.IsSetByteVal() { - if err := oprot.WriteFieldBegin("byteVal", thrift.BYTE, -2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -2:byteVal: ", p), err) } - if err := oprot.WriteByte(byte(*p.ByteVal)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.byteVal (-2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -2:byteVal: ", p), err) } - } - return err -} - -func (p *MyStructEnsureStruct) writeField_1(oprot thrift.Protocol) (err error) { - if p.IsSetBoolVal() { - if err := oprot.WriteFieldBegin("boolVal", thrift.BOOL, -1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -1:boolVal: ", p), err) } - if err := oprot.WriteBool(bool(*p.BoolVal)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.boolVal (-1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -1:boolVal: ", p), err) } - } - return err -} - -func (p *MyStructEnsureStruct) writeField1(oprot thrift.Protocol) (err error) { - if p.IsSetStructWithFieldCustomDefault() { - if err := oprot.WriteFieldBegin("structWithFieldCustomDefault", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:structWithFieldCustomDefault: ", p), err) } - if err := p.StructWithFieldCustomDefault.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.StructWithFieldCustomDefault), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:structWithFieldCustomDefault: ", p), err) } - } - return err -} - -func (p *MyStructEnsureStruct) String() string { - if p == nil { - return "" - } - - var structWithCustomDefaultVal string - if p.StructWithCustomDefault == nil { - structWithCustomDefaultVal = "" - } else { - structWithCustomDefaultVal = fmt.Sprintf("%v", p.StructWithCustomDefault) - } - var i32WithCustomDefaultVal string - if p.I32WithCustomDefault == nil { - i32WithCustomDefaultVal = "" - } else { - i32WithCustomDefaultVal = fmt.Sprintf("%v", *p.I32WithCustomDefault) - } - mapMapVal := fmt.Sprintf("%v", p.MapMap) - listMapVal := fmt.Sprintf("%v", p.ListMap) - optMapValVal := fmt.Sprintf("%v", p.OptMapVal) - optSetValVal := fmt.Sprintf("%v", p.OptSetVal) - optListValVal := fmt.Sprintf("%v", p.OptListVal) - var optLateStructValVal string - if p.OptLateStructVal == nil { - optLateStructValVal = "" - } else { - optLateStructValVal = fmt.Sprintf("%v", p.OptLateStructVal) - } - var optStructValVal string - if p.OptStructVal == nil { - optStructValVal = "" - } else { - optStructValVal = fmt.Sprintf("%v", p.OptStructVal) - } - var optEnumValVal string - if p.OptEnumVal == nil { - optEnumValVal = "" - } else { - optEnumValVal = fmt.Sprintf("%v", *p.OptEnumVal) - } - optBinaryValVal := fmt.Sprintf("%v", p.OptBinaryVal) - var optStringValVal string - if p.OptStringVal == nil { - optStringValVal = "" - } else { - optStringValVal = fmt.Sprintf("%v", *p.OptStringVal) - } - var optDoubleValVal string - if p.OptDoubleVal == nil { - optDoubleValVal = "" - } else { - optDoubleValVal = fmt.Sprintf("%v", *p.OptDoubleVal) - } - var optFloatValVal string - if p.OptFloatVal == nil { - optFloatValVal = "" - } else { - optFloatValVal = fmt.Sprintf("%v", *p.OptFloatVal) - } - var optI64ValVal string - if p.OptI64Val == nil { - optI64ValVal = "" - } else { - optI64ValVal = fmt.Sprintf("%v", *p.OptI64Val) - } - var optI32ValVal string - if p.OptI32Val == nil { - optI32ValVal = "" - } else { - optI32ValVal = fmt.Sprintf("%v", *p.OptI32Val) - } - var optI16ValVal string - if p.OptI16Val == nil { - optI16ValVal = "" - } else { - optI16ValVal = fmt.Sprintf("%v", *p.OptI16Val) - } - var optByteValVal string - if p.OptByteVal == nil { - optByteValVal = "" - } else { - optByteValVal = fmt.Sprintf("%v", *p.OptByteVal) - } - var optBoolValVal string - if p.OptBoolVal == nil { - optBoolValVal = "" - } else { - optBoolValVal = fmt.Sprintf("%v", *p.OptBoolVal) - } - var lateStructValVal string - if p.LateStructVal == nil { - lateStructValVal = "" - } else { - lateStructValVal = fmt.Sprintf("%v", p.LateStructVal) - } - var unionValVal string - if p.UnionVal == nil { - unionValVal = "" - } else { - unionValVal = fmt.Sprintf("%v", p.UnionVal) - } - var structValVal string - if p.StructVal == nil { - structValVal = "" - } else { - structValVal = fmt.Sprintf("%v", p.StructVal) - } - var enumValVal string - if p.EnumVal == nil { - enumValVal = "" - } else { - enumValVal = fmt.Sprintf("%v", *p.EnumVal) - } - binaryValVal := fmt.Sprintf("%v", p.BinaryVal) - var stringValVal string - if p.StringVal == nil { - stringValVal = "" - } else { - stringValVal = fmt.Sprintf("%v", *p.StringVal) - } - var doubleValVal string - if p.DoubleVal == nil { - doubleValVal = "" - } else { - doubleValVal = fmt.Sprintf("%v", *p.DoubleVal) - } - var floatValVal string - if p.FloatVal == nil { - floatValVal = "" - } else { - floatValVal = fmt.Sprintf("%v", *p.FloatVal) - } - var i64ValVal string - if p.I64Val == nil { - i64ValVal = "" - } else { - i64ValVal = fmt.Sprintf("%v", *p.I64Val) - } - var i32ValVal string - if p.I32Val == nil { - i32ValVal = "" - } else { - i32ValVal = fmt.Sprintf("%v", *p.I32Val) - } - var i16ValVal string - if p.I16Val == nil { - i16ValVal = "" - } else { - i16ValVal = fmt.Sprintf("%v", *p.I16Val) - } - var byteValVal string - if p.ByteVal == nil { - byteValVal = "" - } else { - byteValVal = fmt.Sprintf("%v", *p.ByteVal) - } - var boolValVal string - if p.BoolVal == nil { - boolValVal = "" - } else { - boolValVal = fmt.Sprintf("%v", *p.BoolVal) - } - var structWithFieldCustomDefaultVal string - if p.StructWithFieldCustomDefault == nil { - structWithFieldCustomDefaultVal = "" - } else { - structWithFieldCustomDefaultVal = fmt.Sprintf("%v", p.StructWithFieldCustomDefault) - } - return fmt.Sprintf("MyStructEnsureStruct({StructWithCustomDefault:%s I32WithCustomDefault:%s MapMap:%s ListMap:%s OptMapVal:%s OptSetVal:%s OptListVal:%s OptLateStructVal:%s OptStructVal:%s OptEnumVal:%s OptBinaryVal:%s OptStringVal:%s OptDoubleVal:%s OptFloatVal:%s OptI64Val:%s OptI32Val:%s OptI16Val:%s OptByteVal:%s OptBoolVal:%s LateStructVal:%s UnionVal:%s StructVal:%s EnumVal:%s BinaryVal:%s StringVal:%s DoubleVal:%s FloatVal:%s I64Val:%s I32Val:%s I16Val:%s ByteVal:%s BoolVal:%s StructWithFieldCustomDefault:%s})", structWithCustomDefaultVal, i32WithCustomDefaultVal, mapMapVal, listMapVal, optMapValVal, optSetValVal, optListValVal, optLateStructValVal, optStructValVal, optEnumValVal, optBinaryValVal, optStringValVal, optDoubleValVal, optFloatValVal, optI64ValVal, optI32ValVal, optI16ValVal, optByteValVal, optBoolValVal, lateStructValVal, unionValVal, structValVal, enumValVal, binaryValVal, stringValVal, doubleValVal, floatValVal, i64ValVal, i32ValVal, i16ValVal, byteValVal, boolValVal, structWithFieldCustomDefaultVal) -} - -// Attributes: -// - Assign: Assigns to a (set) value. -// -// If set, all other operations are ignored. -// -// Note: Optional and union fields must be set before assigned. -// -// - Clear: Clears a value. Applies first. -// - PatchPrior: Patches any previously set values. Applies second. -// - Ensure: Initialize fields, using the given defaults. Applies third. -// - Patch: Patches any set value, including newly set values. Applies last. -// - Remove: Removes entries, if present. Applies third. -type LateDefStructPatch struct { - Assign *LateDefStruct `thrift:"assign,1,optional" db:"assign" json:"assign,omitempty"` - Clear bool `thrift:"clear,2" db:"clear" json:"clear"` - PatchPrior *LateDefStructFieldPatch `thrift:"patchPrior,3" db:"patchPrior" json:"patchPrior"` - // unused field # 4 - Ensure *LateDefStructEnsureStruct `thrift:"ensure,5" db:"ensure" json:"ensure"` - Patch *LateDefStructFieldPatch `thrift:"patch,6" db:"patch" json:"patch"` - Remove patch0.FieldIdList `thrift:"remove,7" db:"remove" json:"remove"` -} - -func NewLateDefStructPatch() *LateDefStructPatch { - return &LateDefStructPatch{ - PatchPrior: NewLateDefStructFieldPatch(), - Ensure: NewLateDefStructEnsureStruct(), - Patch: NewLateDefStructFieldPatch(), - } -} - -var LateDefStructPatch_Assign_DEFAULT *LateDefStruct -func (p *LateDefStructPatch) GetAssign() *LateDefStruct { - if !p.IsSetAssign() { - return LateDefStructPatch_Assign_DEFAULT - } - return p.Assign -} -func (p *LateDefStructPatch) DefaultGetAssign() *LateDefStruct { - if !p.IsSetAssign() { - return NewLateDefStruct() - } - return p.Assign -} - -func (p *LateDefStructPatch) GetClear() bool { - return p.Clear -} -var LateDefStructPatch_PatchPrior_DEFAULT *LateDefStructFieldPatch -func (p *LateDefStructPatch) GetPatchPrior() *LateDefStructFieldPatch { - if !p.IsSetPatchPrior() { - return LateDefStructPatch_PatchPrior_DEFAULT - } - return p.PatchPrior -} -func (p *LateDefStructPatch) DefaultGetPatchPrior() *LateDefStructFieldPatch { - if !p.IsSetPatchPrior() { - return NewLateDefStructFieldPatch() - } - return p.PatchPrior -} -var LateDefStructPatch_Ensure_DEFAULT *LateDefStructEnsureStruct -func (p *LateDefStructPatch) GetEnsure() *LateDefStructEnsureStruct { - if !p.IsSetEnsure() { - return LateDefStructPatch_Ensure_DEFAULT - } - return p.Ensure -} -func (p *LateDefStructPatch) DefaultGetEnsure() *LateDefStructEnsureStruct { - if !p.IsSetEnsure() { - return NewLateDefStructEnsureStruct() - } - return p.Ensure -} -var LateDefStructPatch_Patch_DEFAULT *LateDefStructFieldPatch -func (p *LateDefStructPatch) GetPatch() *LateDefStructFieldPatch { - if !p.IsSetPatch() { - return LateDefStructPatch_Patch_DEFAULT - } - return p.Patch -} -func (p *LateDefStructPatch) DefaultGetPatch() *LateDefStructFieldPatch { - if !p.IsSetPatch() { - return NewLateDefStructFieldPatch() - } - return p.Patch -} - -func (p *LateDefStructPatch) GetRemove() patch0.FieldIdList { - return p.Remove -} -func (p *LateDefStructPatch) IsSetAssign() bool { - return p != nil && p.Assign != nil -} - -func (p *LateDefStructPatch) IsSetPatchPrior() bool { - return p != nil && p.PatchPrior != nil -} - -func (p *LateDefStructPatch) IsSetEnsure() bool { - return p != nil && p.Ensure != nil -} - -func (p *LateDefStructPatch) IsSetPatch() bool { - return p != nil && p.Patch != nil -} - -type LateDefStructPatchBuilder struct { - obj *LateDefStructPatch -} - -func NewLateDefStructPatchBuilder() *LateDefStructPatchBuilder{ - return &LateDefStructPatchBuilder{ - obj: NewLateDefStructPatch(), - } -} - -func (p LateDefStructPatchBuilder) Emit() *LateDefStructPatch{ - return &LateDefStructPatch{ - Assign: p.obj.Assign, - Clear: p.obj.Clear, - PatchPrior: p.obj.PatchPrior, - Ensure: p.obj.Ensure, - Patch: p.obj.Patch, - Remove: p.obj.Remove, - } -} - -func (l *LateDefStructPatchBuilder) Assign(assign *LateDefStruct) *LateDefStructPatchBuilder { - l.obj.Assign = assign - return l -} - -func (l *LateDefStructPatchBuilder) Clear(clear bool) *LateDefStructPatchBuilder { - l.obj.Clear = clear - return l -} - -func (l *LateDefStructPatchBuilder) PatchPrior(patchPrior *LateDefStructFieldPatch) *LateDefStructPatchBuilder { - l.obj.PatchPrior = patchPrior - return l -} - -func (l *LateDefStructPatchBuilder) Ensure(ensure *LateDefStructEnsureStruct) *LateDefStructPatchBuilder { - l.obj.Ensure = ensure - return l -} - -func (l *LateDefStructPatchBuilder) Patch(patch *LateDefStructFieldPatch) *LateDefStructPatchBuilder { - l.obj.Patch = patch - return l -} - -func (l *LateDefStructPatchBuilder) Remove(remove patch0.FieldIdList) *LateDefStructPatchBuilder { - l.obj.Remove = remove - return l -} - -func (l *LateDefStructPatch) SetAssign(assign *LateDefStruct) *LateDefStructPatch { - l.Assign = assign - return l -} - -func (l *LateDefStructPatch) SetClear(clear bool) *LateDefStructPatch { - l.Clear = clear - return l -} - -func (l *LateDefStructPatch) SetPatchPrior(patchPrior *LateDefStructFieldPatch) *LateDefStructPatch { - l.PatchPrior = patchPrior - return l -} - -func (l *LateDefStructPatch) SetEnsure(ensure *LateDefStructEnsureStruct) *LateDefStructPatch { - l.Ensure = ensure - return l -} - -func (l *LateDefStructPatch) SetPatch(patch *LateDefStructFieldPatch) *LateDefStructPatch { - l.Patch = patch - return l -} - -func (l *LateDefStructPatch) SetRemove(remove patch0.FieldIdList) *LateDefStructPatch { - l.Remove = remove - return l -} - -func (p *LateDefStructPatch) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 3: - if err := p.ReadField3(iprot); err != nil { - return err - } - case 5: - if err := p.ReadField5(iprot); err != nil { - return err - } - case 6: - if err := p.ReadField6(iprot); err != nil { - return err - } - case 7: - if err := p.ReadField7(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *LateDefStructPatch) ReadField1(iprot thrift.Protocol) error { - p.Assign = NewLateDefStruct() - if err := p.Assign.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Assign), err) - } - return nil -} - -func (p *LateDefStructPatch) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Clear = v - } - return nil -} - -func (p *LateDefStructPatch) ReadField3(iprot thrift.Protocol) error { - p.PatchPrior = NewLateDefStructFieldPatch() - if err := p.PatchPrior.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.PatchPrior), err) - } - return nil -} - -func (p *LateDefStructPatch) ReadField5(iprot thrift.Protocol) error { - p.Ensure = NewLateDefStructEnsureStruct() - if err := p.Ensure.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Ensure), err) - } - return nil -} - -func (p *LateDefStructPatch) ReadField6(iprot thrift.Protocol) error { - p.Patch = NewLateDefStructFieldPatch() - if err := p.Patch.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Patch), err) - } - return nil -} - -func (p *LateDefStructPatch) ReadField7(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make(patch0.FieldIdList, 0, size) - p.Remove = tSlice - for i := 0; i < size; i ++ { - var _elem83 int16 - if v, err := iprot.ReadI16(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem83 = v - } - p.Remove = append(p.Remove, _elem83) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *LateDefStructPatch) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("LateDefStructPatch"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := p.writeField5(oprot); err != nil { return err } - if err := p.writeField6(oprot); err != nil { return err } - if err := p.writeField7(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *LateDefStructPatch) writeField1(oprot thrift.Protocol) (err error) { - if p.IsSetAssign() { - if err := oprot.WriteFieldBegin("assign", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:assign: ", p), err) } - if err := p.Assign.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Assign), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:assign: ", p), err) } - } - return err -} - -func (p *LateDefStructPatch) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("clear", thrift.BOOL, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:clear: ", p), err) } - if err := oprot.WriteBool(bool(p.Clear)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.clear (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:clear: ", p), err) } - return err -} - -func (p *LateDefStructPatch) writeField3(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("patchPrior", thrift.STRUCT, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:patchPrior: ", p), err) } - if err := p.PatchPrior.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.PatchPrior), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:patchPrior: ", p), err) } - return err -} - -func (p *LateDefStructPatch) writeField5(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("ensure", thrift.STRUCT, 5); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:ensure: ", p), err) } - if err := p.Ensure.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Ensure), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 5:ensure: ", p), err) } - return err -} - -func (p *LateDefStructPatch) writeField6(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("patch", thrift.STRUCT, 6); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 6:patch: ", p), err) } - if err := p.Patch.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Patch), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 6:patch: ", p), err) } - return err -} - -func (p *LateDefStructPatch) writeField7(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("remove", thrift.LIST, 7); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 7:remove: ", p), err) } - if err := oprot.WriteListBegin(thrift.I16, len(p.Remove)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.Remove { - if err := oprot.WriteI16(int16(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 7:remove: ", p), err) } - return err -} - -func (p *LateDefStructPatch) String() string { - if p == nil { - return "" - } - - var assignVal string - if p.Assign == nil { - assignVal = "" - } else { - assignVal = fmt.Sprintf("%v", p.Assign) - } - clearVal := fmt.Sprintf("%v", p.Clear) - var patchPriorVal string - if p.PatchPrior == nil { - patchPriorVal = "" - } else { - patchPriorVal = fmt.Sprintf("%v", p.PatchPrior) - } - var ensureVal string - if p.Ensure == nil { - ensureVal = "" - } else { - ensureVal = fmt.Sprintf("%v", p.Ensure) - } - var patchVal string - if p.Patch == nil { - patchVal = "" - } else { - patchVal = fmt.Sprintf("%v", p.Patch) - } - removeVal := fmt.Sprintf("%v", p.Remove) - return fmt.Sprintf("LateDefStructPatch({Assign:%s Clear:%s PatchPrior:%s Ensure:%s Patch:%s Remove:%s})", assignVal, clearVal, patchPriorVal, ensureVal, patchVal, removeVal) -} - -type LateDefStructFieldPatch struct { -} - -func NewLateDefStructFieldPatch() *LateDefStructFieldPatch { - return &LateDefStructFieldPatch{} -} - -type LateDefStructFieldPatchBuilder struct { - obj *LateDefStructFieldPatch -} - -func NewLateDefStructFieldPatchBuilder() *LateDefStructFieldPatchBuilder{ - return &LateDefStructFieldPatchBuilder{ - obj: NewLateDefStructFieldPatch(), - } -} - -func (p LateDefStructFieldPatchBuilder) Emit() *LateDefStructFieldPatch{ - return &LateDefStructFieldPatch{ - } -} - -func (p *LateDefStructFieldPatch) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *LateDefStructFieldPatch) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("LateDefStructFieldPatch"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *LateDefStructFieldPatch) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("LateDefStructFieldPatch({})") -} - -type LateDefStructEnsureStruct struct { -} - -func NewLateDefStructEnsureStruct() *LateDefStructEnsureStruct { - return &LateDefStructEnsureStruct{} -} - -type LateDefStructEnsureStructBuilder struct { - obj *LateDefStructEnsureStruct -} - -func NewLateDefStructEnsureStructBuilder() *LateDefStructEnsureStructBuilder{ - return &LateDefStructEnsureStructBuilder{ - obj: NewLateDefStructEnsureStruct(), - } -} - -func (p LateDefStructEnsureStructBuilder) Emit() *LateDefStructEnsureStruct{ - return &LateDefStructEnsureStruct{ - } -} - -func (p *LateDefStructEnsureStruct) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *LateDefStructEnsureStruct) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("LateDefStructEnsureStruct"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *LateDefStructEnsureStruct) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("LateDefStructEnsureStruct({})") -} - -// Attributes: -// - Assign: Assigns to a (set) value. -// -// If set, all other operations are ignored. -// -// Note: Optional and union fields must be set before assigned. -// -// - Clear: Clears a value. Applies first. -// - PatchPrior: Patches any previously set values. Applies second. -// - Ensure: Initialize fields, using the given defaults. Applies third. -// - Patch: Patches any set value, including newly set values. Applies last. -// - Remove: Removes entries, if present. Applies third. -type RecursivePatch struct { - Assign *Recursive `thrift:"assign,1,optional" db:"assign" json:"assign,omitempty"` - Clear bool `thrift:"clear,2" db:"clear" json:"clear"` - PatchPrior *RecursiveFieldPatch `thrift:"patchPrior,3" db:"patchPrior" json:"patchPrior"` - // unused field # 4 - Ensure *RecursiveEnsureStruct `thrift:"ensure,5" db:"ensure" json:"ensure"` - Patch *RecursiveFieldPatch `thrift:"patch,6" db:"patch" json:"patch"` - Remove patch0.FieldIdList `thrift:"remove,7" db:"remove" json:"remove"` -} - -func NewRecursivePatch() *RecursivePatch { - return &RecursivePatch{ - PatchPrior: NewRecursiveFieldPatch(), - Ensure: NewRecursiveEnsureStruct(), - Patch: NewRecursiveFieldPatch(), - } -} - -var RecursivePatch_Assign_DEFAULT *Recursive -func (p *RecursivePatch) GetAssign() *Recursive { - if !p.IsSetAssign() { - return RecursivePatch_Assign_DEFAULT - } - return p.Assign -} -func (p *RecursivePatch) DefaultGetAssign() *Recursive { - if !p.IsSetAssign() { - return NewRecursive() - } - return p.Assign -} - -func (p *RecursivePatch) GetClear() bool { - return p.Clear -} -var RecursivePatch_PatchPrior_DEFAULT *RecursiveFieldPatch -func (p *RecursivePatch) GetPatchPrior() *RecursiveFieldPatch { - if !p.IsSetPatchPrior() { - return RecursivePatch_PatchPrior_DEFAULT - } - return p.PatchPrior -} -func (p *RecursivePatch) DefaultGetPatchPrior() *RecursiveFieldPatch { - if !p.IsSetPatchPrior() { - return NewRecursiveFieldPatch() - } - return p.PatchPrior -} -var RecursivePatch_Ensure_DEFAULT *RecursiveEnsureStruct -func (p *RecursivePatch) GetEnsure() *RecursiveEnsureStruct { - if !p.IsSetEnsure() { - return RecursivePatch_Ensure_DEFAULT - } - return p.Ensure -} -func (p *RecursivePatch) DefaultGetEnsure() *RecursiveEnsureStruct { - if !p.IsSetEnsure() { - return NewRecursiveEnsureStruct() - } - return p.Ensure -} -var RecursivePatch_Patch_DEFAULT *RecursiveFieldPatch -func (p *RecursivePatch) GetPatch() *RecursiveFieldPatch { - if !p.IsSetPatch() { - return RecursivePatch_Patch_DEFAULT - } - return p.Patch -} -func (p *RecursivePatch) DefaultGetPatch() *RecursiveFieldPatch { - if !p.IsSetPatch() { - return NewRecursiveFieldPatch() - } - return p.Patch -} - -func (p *RecursivePatch) GetRemove() patch0.FieldIdList { - return p.Remove -} -func (p *RecursivePatch) IsSetAssign() bool { - return p != nil && p.Assign != nil -} - -func (p *RecursivePatch) IsSetPatchPrior() bool { - return p != nil && p.PatchPrior != nil -} - -func (p *RecursivePatch) IsSetEnsure() bool { - return p != nil && p.Ensure != nil -} - -func (p *RecursivePatch) IsSetPatch() bool { - return p != nil && p.Patch != nil -} - -type RecursivePatchBuilder struct { - obj *RecursivePatch -} - -func NewRecursivePatchBuilder() *RecursivePatchBuilder{ - return &RecursivePatchBuilder{ - obj: NewRecursivePatch(), - } -} - -func (p RecursivePatchBuilder) Emit() *RecursivePatch{ - return &RecursivePatch{ - Assign: p.obj.Assign, - Clear: p.obj.Clear, - PatchPrior: p.obj.PatchPrior, - Ensure: p.obj.Ensure, - Patch: p.obj.Patch, - Remove: p.obj.Remove, - } -} - -func (r *RecursivePatchBuilder) Assign(assign *Recursive) *RecursivePatchBuilder { - r.obj.Assign = assign - return r -} - -func (r *RecursivePatchBuilder) Clear(clear bool) *RecursivePatchBuilder { - r.obj.Clear = clear - return r -} - -func (r *RecursivePatchBuilder) PatchPrior(patchPrior *RecursiveFieldPatch) *RecursivePatchBuilder { - r.obj.PatchPrior = patchPrior - return r -} - -func (r *RecursivePatchBuilder) Ensure(ensure *RecursiveEnsureStruct) *RecursivePatchBuilder { - r.obj.Ensure = ensure - return r -} - -func (r *RecursivePatchBuilder) Patch(patch *RecursiveFieldPatch) *RecursivePatchBuilder { - r.obj.Patch = patch - return r -} - -func (r *RecursivePatchBuilder) Remove(remove patch0.FieldIdList) *RecursivePatchBuilder { - r.obj.Remove = remove - return r -} - -func (r *RecursivePatch) SetAssign(assign *Recursive) *RecursivePatch { - r.Assign = assign - return r -} - -func (r *RecursivePatch) SetClear(clear bool) *RecursivePatch { - r.Clear = clear - return r -} - -func (r *RecursivePatch) SetPatchPrior(patchPrior *RecursiveFieldPatch) *RecursivePatch { - r.PatchPrior = patchPrior - return r -} - -func (r *RecursivePatch) SetEnsure(ensure *RecursiveEnsureStruct) *RecursivePatch { - r.Ensure = ensure - return r -} - -func (r *RecursivePatch) SetPatch(patch *RecursiveFieldPatch) *RecursivePatch { - r.Patch = patch - return r -} - -func (r *RecursivePatch) SetRemove(remove patch0.FieldIdList) *RecursivePatch { - r.Remove = remove - return r -} - -func (p *RecursivePatch) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 3: - if err := p.ReadField3(iprot); err != nil { - return err - } - case 5: - if err := p.ReadField5(iprot); err != nil { - return err - } - case 6: - if err := p.ReadField6(iprot); err != nil { - return err - } - case 7: - if err := p.ReadField7(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *RecursivePatch) ReadField1(iprot thrift.Protocol) error { - p.Assign = NewRecursive() - if err := p.Assign.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Assign), err) - } - return nil -} - -func (p *RecursivePatch) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Clear = v - } - return nil -} - -func (p *RecursivePatch) ReadField3(iprot thrift.Protocol) error { - p.PatchPrior = NewRecursiveFieldPatch() - if err := p.PatchPrior.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.PatchPrior), err) - } - return nil -} - -func (p *RecursivePatch) ReadField5(iprot thrift.Protocol) error { - p.Ensure = NewRecursiveEnsureStruct() - if err := p.Ensure.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Ensure), err) - } - return nil -} - -func (p *RecursivePatch) ReadField6(iprot thrift.Protocol) error { - p.Patch = NewRecursiveFieldPatch() - if err := p.Patch.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Patch), err) - } - return nil -} - -func (p *RecursivePatch) ReadField7(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make(patch0.FieldIdList, 0, size) - p.Remove = tSlice - for i := 0; i < size; i ++ { - var _elem84 int16 - if v, err := iprot.ReadI16(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem84 = v - } - p.Remove = append(p.Remove, _elem84) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *RecursivePatch) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("RecursivePatch"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := p.writeField5(oprot); err != nil { return err } - if err := p.writeField6(oprot); err != nil { return err } - if err := p.writeField7(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *RecursivePatch) writeField1(oprot thrift.Protocol) (err error) { - if p.IsSetAssign() { - if err := oprot.WriteFieldBegin("assign", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:assign: ", p), err) } - if err := p.Assign.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Assign), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:assign: ", p), err) } - } - return err -} - -func (p *RecursivePatch) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("clear", thrift.BOOL, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:clear: ", p), err) } - if err := oprot.WriteBool(bool(p.Clear)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.clear (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:clear: ", p), err) } - return err -} - -func (p *RecursivePatch) writeField3(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("patchPrior", thrift.STRUCT, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:patchPrior: ", p), err) } - if err := p.PatchPrior.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.PatchPrior), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:patchPrior: ", p), err) } - return err -} - -func (p *RecursivePatch) writeField5(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("ensure", thrift.STRUCT, 5); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:ensure: ", p), err) } - if err := p.Ensure.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Ensure), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 5:ensure: ", p), err) } - return err -} - -func (p *RecursivePatch) writeField6(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("patch", thrift.STRUCT, 6); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 6:patch: ", p), err) } - if err := p.Patch.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Patch), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 6:patch: ", p), err) } - return err -} - -func (p *RecursivePatch) writeField7(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("remove", thrift.LIST, 7); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 7:remove: ", p), err) } - if err := oprot.WriteListBegin(thrift.I16, len(p.Remove)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.Remove { - if err := oprot.WriteI16(int16(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 7:remove: ", p), err) } - return err -} - -func (p *RecursivePatch) String() string { - if p == nil { - return "" - } - - var assignVal string - if p.Assign == nil { - assignVal = "" - } else { - assignVal = fmt.Sprintf("%v", p.Assign) - } - clearVal := fmt.Sprintf("%v", p.Clear) - var patchPriorVal string - if p.PatchPrior == nil { - patchPriorVal = "" - } else { - patchPriorVal = fmt.Sprintf("%v", p.PatchPrior) - } - var ensureVal string - if p.Ensure == nil { - ensureVal = "" - } else { - ensureVal = fmt.Sprintf("%v", p.Ensure) - } - var patchVal string - if p.Patch == nil { - patchVal = "" - } else { - patchVal = fmt.Sprintf("%v", p.Patch) - } - removeVal := fmt.Sprintf("%v", p.Remove) - return fmt.Sprintf("RecursivePatch({Assign:%s Clear:%s PatchPrior:%s Ensure:%s Patch:%s Remove:%s})", assignVal, clearVal, patchPriorVal, ensureVal, patchVal, removeVal) -} - -// Attributes: -// - Assign: Assigns to a (set) value. -// -// If set, all other operations are ignored. -// -// Note: Optional and union fields must be set before assigned. -// -// - Clear: Clears a value. Applies first. -type RecursiveField1Patch struct { - Assign map[string]*Recursive `thrift:"assign,1,optional" db:"assign" json:"assign,omitempty"` - Clear bool `thrift:"clear,2" db:"clear" json:"clear"` -} - -func NewRecursiveField1Patch() *RecursiveField1Patch { - return &RecursiveField1Patch{} -} - -var RecursiveField1Patch_Assign_DEFAULT map[string]*Recursive - -func (p *RecursiveField1Patch) GetAssign() map[string]*Recursive { - return p.Assign -} - -func (p *RecursiveField1Patch) GetClear() bool { - return p.Clear -} -func (p *RecursiveField1Patch) IsSetAssign() bool { - return p != nil && p.Assign != nil -} - -type RecursiveField1PatchBuilder struct { - obj *RecursiveField1Patch -} - -func NewRecursiveField1PatchBuilder() *RecursiveField1PatchBuilder{ - return &RecursiveField1PatchBuilder{ - obj: NewRecursiveField1Patch(), - } -} - -func (p RecursiveField1PatchBuilder) Emit() *RecursiveField1Patch{ - return &RecursiveField1Patch{ - Assign: p.obj.Assign, - Clear: p.obj.Clear, - } -} - -func (r *RecursiveField1PatchBuilder) Assign(assign map[string]*Recursive) *RecursiveField1PatchBuilder { - r.obj.Assign = assign - return r -} - -func (r *RecursiveField1PatchBuilder) Clear(clear bool) *RecursiveField1PatchBuilder { - r.obj.Clear = clear - return r -} - -func (r *RecursiveField1Patch) SetAssign(assign map[string]*Recursive) *RecursiveField1Patch { - r.Assign = assign - return r -} - -func (r *RecursiveField1Patch) SetClear(clear bool) *RecursiveField1Patch { - r.Clear = clear - return r -} - -func (p *RecursiveField1Patch) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *RecursiveField1Patch) ReadField1(iprot thrift.Protocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[string]*Recursive, size) - p.Assign = tMap - for i := 0; i < size; i ++ { - var _key85 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key85 = v - } - _val86 := NewRecursive() - if err := _val86.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _val86), err) - } - p.Assign[_key85] = _val86 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *RecursiveField1Patch) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Clear = v - } - return nil -} - -func (p *RecursiveField1Patch) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("RecursiveField1Patch"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *RecursiveField1Patch) writeField1(oprot thrift.Protocol) (err error) { - if p.IsSetAssign() { - if err := oprot.WriteFieldBegin("assign", thrift.MAP, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:assign: ", p), err) } - if err := oprot.WriteMapBegin(thrift.STRING, thrift.STRUCT, len(p.Assign)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.Assign { - if err := oprot.WriteString(string(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := v.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) - } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:assign: ", p), err) } - } - return err -} - -func (p *RecursiveField1Patch) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("clear", thrift.BOOL, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:clear: ", p), err) } - if err := oprot.WriteBool(bool(p.Clear)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.clear (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:clear: ", p), err) } - return err -} - -func (p *RecursiveField1Patch) String() string { - if p == nil { - return "" - } - - assignVal := fmt.Sprintf("%v", p.Assign) - clearVal := fmt.Sprintf("%v", p.Clear) - return fmt.Sprintf("RecursiveField1Patch({Assign:%s Clear:%s})", assignVal, clearVal) -} - -// Attributes: -// - Nodes -type RecursiveFieldPatch struct { - Nodes *RecursiveField1Patch -} - -func NewRecursiveFieldPatch() *RecursiveFieldPatch { - return &RecursiveFieldPatch{ - Nodes: NewRecursiveField1Patch(), - } -} - -var RecursiveFieldPatch_Nodes_DEFAULT *RecursiveField1Patch -func (p *RecursiveFieldPatch) GetNodes() *RecursiveField1Patch { - if !p.IsSetNodes() { - return RecursiveFieldPatch_Nodes_DEFAULT - } - return p.Nodes -} -func (p *RecursiveFieldPatch) DefaultGetNodes() *RecursiveField1Patch { - if !p.IsSetNodes() { - return NewRecursiveField1Patch() - } - return p.Nodes -} -func (p *RecursiveFieldPatch) IsSetNodes() bool { - return p != nil && p.Nodes != nil -} - -type RecursiveFieldPatchBuilder struct { - obj *RecursiveFieldPatch -} - -func NewRecursiveFieldPatchBuilder() *RecursiveFieldPatchBuilder{ - return &RecursiveFieldPatchBuilder{ - obj: NewRecursiveFieldPatch(), - } -} - -func (p RecursiveFieldPatchBuilder) Emit() *RecursiveFieldPatch{ - return &RecursiveFieldPatch{ - Nodes: p.obj.Nodes, - } -} - -func (r *RecursiveFieldPatchBuilder) Nodes(nodes *RecursiveField1Patch) *RecursiveFieldPatchBuilder { - r.obj.Nodes = nodes - return r -} - -func (r *RecursiveFieldPatch) SetNodes(nodes *RecursiveField1Patch) *RecursiveFieldPatch { - r.Nodes = nodes - return r -} - -func (p *RecursiveFieldPatch) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case -1: - if err := p.ReadField_1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *RecursiveFieldPatch) ReadField_1(iprot thrift.Protocol) error { - p.Nodes = NewRecursiveField1Patch() - if err := p.Nodes.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Nodes), err) - } - return nil -} - -func (p *RecursiveFieldPatch) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("RecursiveFieldPatch"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField_1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *RecursiveFieldPatch) writeField_1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("nodes", thrift.STRUCT, -1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -1:nodes: ", p), err) } - if err := p.Nodes.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Nodes), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -1:nodes: ", p), err) } - return err -} - -func (p *RecursiveFieldPatch) String() string { - if p == nil { - return "" - } - - var nodesVal string - if p.Nodes == nil { - nodesVal = "" - } else { - nodesVal = fmt.Sprintf("%v", p.Nodes) - } - return fmt.Sprintf("RecursiveFieldPatch({Nodes:%s})", nodesVal) -} - -// Attributes: -// - Nodes -type RecursiveEnsureStruct struct { - Nodes map[string]*Recursive -} - -func NewRecursiveEnsureStruct() *RecursiveEnsureStruct { - return &RecursiveEnsureStruct{} -} - -var RecursiveEnsureStruct_Nodes_DEFAULT map[string]*Recursive - -func (p *RecursiveEnsureStruct) GetNodes() map[string]*Recursive { - return p.Nodes -} -func (p *RecursiveEnsureStruct) IsSetNodes() bool { - return p != nil && p.Nodes != nil -} - -type RecursiveEnsureStructBuilder struct { - obj *RecursiveEnsureStruct -} - -func NewRecursiveEnsureStructBuilder() *RecursiveEnsureStructBuilder{ - return &RecursiveEnsureStructBuilder{ - obj: NewRecursiveEnsureStruct(), - } -} - -func (p RecursiveEnsureStructBuilder) Emit() *RecursiveEnsureStruct{ - return &RecursiveEnsureStruct{ - Nodes: p.obj.Nodes, - } -} - -func (r *RecursiveEnsureStructBuilder) Nodes(nodes map[string]*Recursive) *RecursiveEnsureStructBuilder { - r.obj.Nodes = nodes - return r -} - -func (r *RecursiveEnsureStruct) SetNodes(nodes map[string]*Recursive) *RecursiveEnsureStruct { - r.Nodes = nodes - return r -} - -func (p *RecursiveEnsureStruct) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case -1: - if err := p.ReadField_1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *RecursiveEnsureStruct) ReadField_1(iprot thrift.Protocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[string]*Recursive, size) - p.Nodes = tMap - for i := 0; i < size; i ++ { - var _key87 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key87 = v - } - _val88 := NewRecursive() - if err := _val88.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _val88), err) - } - p.Nodes[_key87] = _val88 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *RecursiveEnsureStruct) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("RecursiveEnsureStruct"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField_1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *RecursiveEnsureStruct) writeField_1(oprot thrift.Protocol) (err error) { - if p.IsSetNodes() { - if err := oprot.WriteFieldBegin("nodes", thrift.MAP, -1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -1:nodes: ", p), err) } - if err := oprot.WriteMapBegin(thrift.STRING, thrift.STRUCT, len(p.Nodes)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.Nodes { - if err := oprot.WriteString(string(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := v.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) - } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -1:nodes: ", p), err) } - } - return err -} - -func (p *RecursiveEnsureStruct) String() string { - if p == nil { - return "" - } - - nodesVal := fmt.Sprintf("%v", p.Nodes) - return fmt.Sprintf("RecursiveEnsureStruct({Nodes:%s})", nodesVal) -} - -// Attributes: -// - Assign: Assigns to a (set) value. -// -// If set, all other operations are ignored. -// -// Note: Optional and union fields must be set before assigned. -// -// - Clear: Clears a value. Applies first. -// - PatchPrior: Patches any previously set values. Applies second. -// - Ensure: Initialize fields, using the given defaults. Applies third. -// - Patch: Patches any set value, including newly set values. Applies last. -// - Remove: Removes entries, if present. Applies third. -type BarPatch struct { - Assign *Bar `thrift:"assign,1,optional" db:"assign" json:"assign,omitempty"` - Clear bool `thrift:"clear,2" db:"clear" json:"clear"` - PatchPrior *BarFieldPatch `thrift:"patchPrior,3" db:"patchPrior" json:"patchPrior"` - // unused field # 4 - Ensure *BarEnsureStruct `thrift:"ensure,5" db:"ensure" json:"ensure"` - Patch *BarFieldPatch `thrift:"patch,6" db:"patch" json:"patch"` - Remove patch0.FieldIdList `thrift:"remove,7" db:"remove" json:"remove"` -} - -func NewBarPatch() *BarPatch { - return &BarPatch{ - PatchPrior: NewBarFieldPatch(), - Ensure: NewBarEnsureStruct(), - Patch: NewBarFieldPatch(), - } -} - -var BarPatch_Assign_DEFAULT *Bar -func (p *BarPatch) GetAssign() *Bar { - if !p.IsSetAssign() { - return BarPatch_Assign_DEFAULT - } - return p.Assign -} -func (p *BarPatch) DefaultGetAssign() *Bar { - if !p.IsSetAssign() { - return NewBar() - } - return p.Assign -} - -func (p *BarPatch) GetClear() bool { - return p.Clear -} -var BarPatch_PatchPrior_DEFAULT *BarFieldPatch -func (p *BarPatch) GetPatchPrior() *BarFieldPatch { - if !p.IsSetPatchPrior() { - return BarPatch_PatchPrior_DEFAULT - } - return p.PatchPrior -} -func (p *BarPatch) DefaultGetPatchPrior() *BarFieldPatch { - if !p.IsSetPatchPrior() { - return NewBarFieldPatch() - } - return p.PatchPrior -} -var BarPatch_Ensure_DEFAULT *BarEnsureStruct -func (p *BarPatch) GetEnsure() *BarEnsureStruct { - if !p.IsSetEnsure() { - return BarPatch_Ensure_DEFAULT - } - return p.Ensure -} -func (p *BarPatch) DefaultGetEnsure() *BarEnsureStruct { - if !p.IsSetEnsure() { - return NewBarEnsureStruct() - } - return p.Ensure -} -var BarPatch_Patch_DEFAULT *BarFieldPatch -func (p *BarPatch) GetPatch() *BarFieldPatch { - if !p.IsSetPatch() { - return BarPatch_Patch_DEFAULT - } - return p.Patch -} -func (p *BarPatch) DefaultGetPatch() *BarFieldPatch { - if !p.IsSetPatch() { - return NewBarFieldPatch() - } - return p.Patch -} - -func (p *BarPatch) GetRemove() patch0.FieldIdList { - return p.Remove -} -func (p *BarPatch) IsSetAssign() bool { - return p != nil && p.Assign != nil -} - -func (p *BarPatch) IsSetPatchPrior() bool { - return p != nil && p.PatchPrior != nil -} - -func (p *BarPatch) IsSetEnsure() bool { - return p != nil && p.Ensure != nil -} - -func (p *BarPatch) IsSetPatch() bool { - return p != nil && p.Patch != nil -} - -type BarPatchBuilder struct { - obj *BarPatch -} - -func NewBarPatchBuilder() *BarPatchBuilder{ - return &BarPatchBuilder{ - obj: NewBarPatch(), - } -} - -func (p BarPatchBuilder) Emit() *BarPatch{ - return &BarPatch{ - Assign: p.obj.Assign, - Clear: p.obj.Clear, - PatchPrior: p.obj.PatchPrior, - Ensure: p.obj.Ensure, - Patch: p.obj.Patch, - Remove: p.obj.Remove, - } -} - -func (b *BarPatchBuilder) Assign(assign *Bar) *BarPatchBuilder { - b.obj.Assign = assign - return b -} - -func (b *BarPatchBuilder) Clear(clear bool) *BarPatchBuilder { - b.obj.Clear = clear - return b -} - -func (b *BarPatchBuilder) PatchPrior(patchPrior *BarFieldPatch) *BarPatchBuilder { - b.obj.PatchPrior = patchPrior - return b -} - -func (b *BarPatchBuilder) Ensure(ensure *BarEnsureStruct) *BarPatchBuilder { - b.obj.Ensure = ensure - return b -} - -func (b *BarPatchBuilder) Patch(patch *BarFieldPatch) *BarPatchBuilder { - b.obj.Patch = patch - return b -} - -func (b *BarPatchBuilder) Remove(remove patch0.FieldIdList) *BarPatchBuilder { - b.obj.Remove = remove - return b -} - -func (b *BarPatch) SetAssign(assign *Bar) *BarPatch { - b.Assign = assign - return b -} - -func (b *BarPatch) SetClear(clear bool) *BarPatch { - b.Clear = clear - return b -} - -func (b *BarPatch) SetPatchPrior(patchPrior *BarFieldPatch) *BarPatch { - b.PatchPrior = patchPrior - return b -} - -func (b *BarPatch) SetEnsure(ensure *BarEnsureStruct) *BarPatch { - b.Ensure = ensure - return b -} - -func (b *BarPatch) SetPatch(patch *BarFieldPatch) *BarPatch { - b.Patch = patch - return b -} - -func (b *BarPatch) SetRemove(remove patch0.FieldIdList) *BarPatch { - b.Remove = remove - return b -} - -func (p *BarPatch) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 3: - if err := p.ReadField3(iprot); err != nil { - return err - } - case 5: - if err := p.ReadField5(iprot); err != nil { - return err - } - case 6: - if err := p.ReadField6(iprot); err != nil { - return err - } - case 7: - if err := p.ReadField7(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *BarPatch) ReadField1(iprot thrift.Protocol) error { - p.Assign = NewBar() - if err := p.Assign.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Assign), err) - } - return nil -} - -func (p *BarPatch) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Clear = v - } - return nil -} - -func (p *BarPatch) ReadField3(iprot thrift.Protocol) error { - p.PatchPrior = NewBarFieldPatch() - if err := p.PatchPrior.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.PatchPrior), err) - } - return nil -} - -func (p *BarPatch) ReadField5(iprot thrift.Protocol) error { - p.Ensure = NewBarEnsureStruct() - if err := p.Ensure.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Ensure), err) - } - return nil -} - -func (p *BarPatch) ReadField6(iprot thrift.Protocol) error { - p.Patch = NewBarFieldPatch() - if err := p.Patch.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Patch), err) - } - return nil -} - -func (p *BarPatch) ReadField7(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make(patch0.FieldIdList, 0, size) - p.Remove = tSlice - for i := 0; i < size; i ++ { - var _elem89 int16 - if v, err := iprot.ReadI16(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem89 = v - } - p.Remove = append(p.Remove, _elem89) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *BarPatch) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("BarPatch"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := p.writeField5(oprot); err != nil { return err } - if err := p.writeField6(oprot); err != nil { return err } - if err := p.writeField7(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *BarPatch) writeField1(oprot thrift.Protocol) (err error) { - if p.IsSetAssign() { - if err := oprot.WriteFieldBegin("assign", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:assign: ", p), err) } - if err := p.Assign.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Assign), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:assign: ", p), err) } - } - return err -} - -func (p *BarPatch) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("clear", thrift.BOOL, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:clear: ", p), err) } - if err := oprot.WriteBool(bool(p.Clear)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.clear (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:clear: ", p), err) } - return err -} - -func (p *BarPatch) writeField3(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("patchPrior", thrift.STRUCT, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:patchPrior: ", p), err) } - if err := p.PatchPrior.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.PatchPrior), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:patchPrior: ", p), err) } - return err -} - -func (p *BarPatch) writeField5(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("ensure", thrift.STRUCT, 5); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:ensure: ", p), err) } - if err := p.Ensure.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Ensure), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 5:ensure: ", p), err) } - return err -} - -func (p *BarPatch) writeField6(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("patch", thrift.STRUCT, 6); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 6:patch: ", p), err) } - if err := p.Patch.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Patch), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 6:patch: ", p), err) } - return err -} - -func (p *BarPatch) writeField7(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("remove", thrift.LIST, 7); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 7:remove: ", p), err) } - if err := oprot.WriteListBegin(thrift.I16, len(p.Remove)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.Remove { - if err := oprot.WriteI16(int16(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 7:remove: ", p), err) } - return err -} - -func (p *BarPatch) String() string { - if p == nil { - return "" - } - - var assignVal string - if p.Assign == nil { - assignVal = "" - } else { - assignVal = fmt.Sprintf("%v", p.Assign) - } - clearVal := fmt.Sprintf("%v", p.Clear) - var patchPriorVal string - if p.PatchPrior == nil { - patchPriorVal = "" - } else { - patchPriorVal = fmt.Sprintf("%v", p.PatchPrior) - } - var ensureVal string - if p.Ensure == nil { - ensureVal = "" - } else { - ensureVal = fmt.Sprintf("%v", p.Ensure) - } - var patchVal string - if p.Patch == nil { - patchVal = "" - } else { - patchVal = fmt.Sprintf("%v", p.Patch) - } - removeVal := fmt.Sprintf("%v", p.Remove) - return fmt.Sprintf("BarPatch({Assign:%s Clear:%s PatchPrior:%s Ensure:%s Patch:%s Remove:%s})", assignVal, clearVal, patchPriorVal, ensureVal, patchVal, removeVal) -} - -// Attributes: -// - Loop -type BarFieldPatch struct { - Loop *LoopPatch -} - -func NewBarFieldPatch() *BarFieldPatch { - return &BarFieldPatch{ - Loop: NewLoopPatch(), - } -} - -var BarFieldPatch_Loop_DEFAULT *LoopPatch -func (p *BarFieldPatch) GetLoop() *LoopPatch { - if !p.IsSetLoop() { - return BarFieldPatch_Loop_DEFAULT - } - return p.Loop -} -func (p *BarFieldPatch) IsSetLoop() bool { - return p != nil && p.Loop != nil -} - -type BarFieldPatchBuilder struct { - obj *BarFieldPatch -} - -func NewBarFieldPatchBuilder() *BarFieldPatchBuilder{ - return &BarFieldPatchBuilder{ - obj: NewBarFieldPatch(), - } -} - -func (p BarFieldPatchBuilder) Emit() *BarFieldPatch{ - return &BarFieldPatch{ - Loop: p.obj.Loop, - } -} - -func (b *BarFieldPatchBuilder) Loop(loop *LoopPatch) *BarFieldPatchBuilder { - b.obj.Loop = loop - return b -} - -func (b *BarFieldPatch) SetLoop(loop *LoopPatch) *BarFieldPatch { - b.Loop = loop - return b -} - -func (p *BarFieldPatch) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case -1: - if err := p.ReadField_1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *BarFieldPatch) ReadField_1(iprot thrift.Protocol) error { - p.Loop = NewLoopPatch() - if err := p.Loop.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Loop), err) - } - return nil -} - -func (p *BarFieldPatch) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("BarFieldPatch"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField_1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *BarFieldPatch) writeField_1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("loop", thrift.STRUCT, -1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -1:loop: ", p), err) } - if err := p.Loop.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Loop), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -1:loop: ", p), err) } - return err -} - -func (p *BarFieldPatch) String() string { - if p == nil { - return "" - } - - var loopVal string - if p.Loop == nil { - loopVal = "" - } else { - loopVal = fmt.Sprintf("%v", p.Loop) - } - return fmt.Sprintf("BarFieldPatch({Loop:%s})", loopVal) -} - -// Attributes: -// - Loop -type BarEnsureStruct struct { - Loop *Loop -} - -func NewBarEnsureStruct() *BarEnsureStruct { - return &BarEnsureStruct{} -} - -var BarEnsureStruct_Loop_DEFAULT *Loop -func (p *BarEnsureStruct) GetLoop() *Loop { - if !p.IsSetLoop() { - return BarEnsureStruct_Loop_DEFAULT - } - return p.Loop -} -func (p *BarEnsureStruct) IsSetLoop() bool { - return p != nil && p.Loop != nil -} - -type BarEnsureStructBuilder struct { - obj *BarEnsureStruct -} - -func NewBarEnsureStructBuilder() *BarEnsureStructBuilder{ - return &BarEnsureStructBuilder{ - obj: NewBarEnsureStruct(), - } -} - -func (p BarEnsureStructBuilder) Emit() *BarEnsureStruct{ - return &BarEnsureStruct{ - Loop: p.obj.Loop, - } -} - -func (b *BarEnsureStructBuilder) Loop(loop *Loop) *BarEnsureStructBuilder { - b.obj.Loop = loop - return b -} - -func (b *BarEnsureStruct) SetLoop(loop *Loop) *BarEnsureStruct { - b.Loop = loop - return b -} - -func (p *BarEnsureStruct) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case -1: - if err := p.ReadField_1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *BarEnsureStruct) ReadField_1(iprot thrift.Protocol) error { - p.Loop = NewLoop() - if err := p.Loop.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Loop), err) - } - return nil -} - -func (p *BarEnsureStruct) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("BarEnsureStruct"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField_1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *BarEnsureStruct) writeField_1(oprot thrift.Protocol) (err error) { - if p.IsSetLoop() { - if err := oprot.WriteFieldBegin("loop", thrift.STRUCT, -1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error -1:loop: ", p), err) } - if err := p.Loop.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Loop), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error -1:loop: ", p), err) } - } - return err -} - -func (p *BarEnsureStruct) String() string { - if p == nil { - return "" - } - - var loopVal string - if p.Loop == nil { - loopVal = "" - } else { - loopVal = fmt.Sprintf("%v", p.Loop) - } - return fmt.Sprintf("BarEnsureStruct({Loop:%s})", loopVal) -} - -// Attributes: -// - Assign: Assigns to a (set) value. -// -// If set, all other operations are ignored. -// -// Note: Optional and union fields must be set before assigned. -// -// - Clear: Clears a value. Applies first. -type LoopPatch struct { - Assign *Loop `thrift:"assign,1,optional" db:"assign" json:"assign,omitempty"` - Clear bool `thrift:"clear,2" db:"clear" json:"clear"` -} - -func NewLoopPatch() *LoopPatch { - return &LoopPatch{} -} - -var LoopPatch_Assign_DEFAULT *Loop -func (p *LoopPatch) GetAssign() *Loop { - if !p.IsSetAssign() { - return LoopPatch_Assign_DEFAULT - } - return p.Assign -} -func (p *LoopPatch) DefaultGetAssign() *Loop { - if !p.IsSetAssign() { - return NewLoop() - } - return p.Assign -} - -func (p *LoopPatch) GetClear() bool { - return p.Clear -} -func (p *LoopPatch) IsSetAssign() bool { - return p != nil && p.Assign != nil -} - -type LoopPatchBuilder struct { - obj *LoopPatch -} - -func NewLoopPatchBuilder() *LoopPatchBuilder{ - return &LoopPatchBuilder{ - obj: NewLoopPatch(), - } -} - -func (p LoopPatchBuilder) Emit() *LoopPatch{ - return &LoopPatch{ - Assign: p.obj.Assign, - Clear: p.obj.Clear, - } -} - -func (l *LoopPatchBuilder) Assign(assign *Loop) *LoopPatchBuilder { - l.obj.Assign = assign - return l -} - -func (l *LoopPatchBuilder) Clear(clear bool) *LoopPatchBuilder { - l.obj.Clear = clear - return l -} - -func (l *LoopPatch) SetAssign(assign *Loop) *LoopPatch { - l.Assign = assign - return l -} - -func (l *LoopPatch) SetClear(clear bool) *LoopPatch { - l.Clear = clear - return l -} - -func (p *LoopPatch) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *LoopPatch) ReadField1(iprot thrift.Protocol) error { - p.Assign = NewLoop() - if err := p.Assign.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Assign), err) - } - return nil -} - -func (p *LoopPatch) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Clear = v - } - return nil -} - -func (p *LoopPatch) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("LoopPatch"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *LoopPatch) writeField1(oprot thrift.Protocol) (err error) { - if p.IsSetAssign() { - if err := oprot.WriteFieldBegin("assign", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:assign: ", p), err) } - if err := p.Assign.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Assign), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:assign: ", p), err) } - } - return err -} - -func (p *LoopPatch) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("clear", thrift.BOOL, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:clear: ", p), err) } - if err := oprot.WriteBool(bool(p.Clear)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.clear (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:clear: ", p), err) } - return err -} - -func (p *LoopPatch) String() string { - if p == nil { - return "" - } - - var assignVal string - if p.Assign == nil { - assignVal = "" - } else { - assignVal = fmt.Sprintf("%v", p.Assign) - } - clearVal := fmt.Sprintf("%v", p.Clear) - return fmt.Sprintf("LoopPatch({Assign:%s Clear:%s})", assignVal, clearVal) -} - diff --git a/thrift/compiler/test/fixtures/patch/gen-go/thrift/annotation/cpp/constants.go b/thrift/compiler/test/fixtures/patch/gen-go/thrift/annotation/cpp/constants.go deleted file mode 100644 index 966e368e2dd..00000000000 --- a/thrift/compiler/test/fixtures/patch/gen-go/thrift/annotation/cpp/constants.go +++ /dev/null @@ -1,25 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package cpp - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - - -func init() { -} - diff --git a/thrift/compiler/test/fixtures/patch/gen-go/thrift/annotation/cpp/ttypes.go b/thrift/compiler/test/fixtures/patch/gen-go/thrift/annotation/cpp/ttypes.go deleted file mode 100644 index 209f29e21fd..00000000000 --- a/thrift/compiler/test/fixtures/patch/gen-go/thrift/annotation/cpp/ttypes.go +++ /dev/null @@ -1,2188 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package cpp - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var GoUnusedProtection__ int; - -//Optional, defaults to Unique -type RefType int64 -const ( - RefType_Unique RefType = 0 - RefType_Shared RefType = 1 - RefType_SharedMutable RefType = 2 -) - -var RefTypeToName = map[RefType]string { - RefType_Unique: "Unique", - RefType_Shared: "Shared", - RefType_SharedMutable: "SharedMutable", -} - -var RefTypeToValue = map[string]RefType { - "Unique": RefType_Unique, - "Shared": RefType_Shared, - "SharedMutable": RefType_SharedMutable, -} - -var RefTypeNames = []string { - "Unique", - "Shared", - "SharedMutable", -} - -var RefTypeValues = []RefType { - RefType_Unique, - RefType_Shared, - RefType_SharedMutable, -} - -func (p RefType) String() string { - if v, ok := RefTypeToName[p]; ok { - return v - } - return "" -} - -func RefTypeFromString(s string) (RefType, error) { - if v, ok := RefTypeToValue[s]; ok { - return v, nil - } - return RefType(0), fmt.Errorf("not a valid RefType string") -} - -func RefTypePtr(v RefType) *RefType { return &v } - -//Enum in C++ by default uses signed 32 bit integer. There is no need to specify -//underlying type for signed 32 bit integer. -//64-bit is not supported to avoid truncation since enums are sent as 32-bit integers over the wire. -type EnumUnderlyingType int64 -const ( - EnumUnderlyingType_I8 EnumUnderlyingType = 0 - EnumUnderlyingType_U8 EnumUnderlyingType = 1 - EnumUnderlyingType_I16 EnumUnderlyingType = 2 - EnumUnderlyingType_U16 EnumUnderlyingType = 3 - EnumUnderlyingType_U32 EnumUnderlyingType = 4 -) - -var EnumUnderlyingTypeToName = map[EnumUnderlyingType]string { - EnumUnderlyingType_I8: "I8", - EnumUnderlyingType_U8: "U8", - EnumUnderlyingType_I16: "I16", - EnumUnderlyingType_U16: "U16", - EnumUnderlyingType_U32: "U32", -} - -var EnumUnderlyingTypeToValue = map[string]EnumUnderlyingType { - "I8": EnumUnderlyingType_I8, - "U8": EnumUnderlyingType_U8, - "I16": EnumUnderlyingType_I16, - "U16": EnumUnderlyingType_U16, - "U32": EnumUnderlyingType_U32, -} - -var EnumUnderlyingTypeNames = []string { - "I8", - "U8", - "I16", - "U16", - "U32", -} - -var EnumUnderlyingTypeValues = []EnumUnderlyingType { - EnumUnderlyingType_I8, - EnumUnderlyingType_U8, - EnumUnderlyingType_I16, - EnumUnderlyingType_U16, - EnumUnderlyingType_U32, -} - -func (p EnumUnderlyingType) String() string { - if v, ok := EnumUnderlyingTypeToName[p]; ok { - return v - } - return "" -} - -func EnumUnderlyingTypeFromString(s string) (EnumUnderlyingType, error) { - if v, ok := EnumUnderlyingTypeToValue[s]; ok { - return v, nil - } - return EnumUnderlyingType(0), fmt.Errorf("not a valid EnumUnderlyingType string") -} - -func EnumUnderlyingTypePtr(v EnumUnderlyingType) *EnumUnderlyingType { return &v } - -// Changes the native type of a Thrift object (the C++ type used in codegen) to the value of the `name` field. -// Container types may instead provide the `template` field, in which case template parameters will be filled in by thrift. -// (e.g. `template = "folly::sorted_vector_set"` is equivalent to `type = "folly::sorted_vector_set"` on `set`) -// -// It is also possible to add `cpp_include` to bring in additional data structures and use them here. -// It is required that the custom type matches the specified Thrift type even for internal container types. -// Prefer types that can leverage `reserve(size_t)` as Thrift makes uses these optimizations. -// *Special Case*: This annotation can be used to define a string/binary type as `IOBuf` or `unique_ptr` so that you can leverage Thrift's support for zero-copy buffer manipulation through `IOBuf`. -// During deserialization, thrift receives a buffer that is used to allocate the appropriate fields in the struct. When using smart pointers, instead of making a copy of the data, it only modifies the pointer to point to the address that is used by the buffer. -// -// The custom type must provide the following methods -// * `list`: `push_back(T)` -// * `map`: `insert(std::pair)` -// * `set`: `insert(T)` -// -// Attributes: -// - Name -// - Template -type Type struct { - Name string `thrift:"name,1" db:"name" json:"name"` - Template string `thrift:"template,2" db:"template" json:"template"` -} - -func NewType() *Type { - return &Type{} -} - - -func (p *Type) GetName() string { - return p.Name -} - -func (p *Type) GetTemplate() string { - return p.Template -} -type TypeBuilder struct { - obj *Type -} - -func NewTypeBuilder() *TypeBuilder{ - return &TypeBuilder{ - obj: NewType(), - } -} - -func (p TypeBuilder) Emit() *Type{ - return &Type{ - Name: p.obj.Name, - Template: p.obj.Template, - } -} - -func (t *TypeBuilder) Name(name string) *TypeBuilder { - t.obj.Name = name - return t -} - -func (t *TypeBuilder) Template(template string) *TypeBuilder { - t.obj.Template = template - return t -} - -func (t *Type) SetName(name string) *Type { - t.Name = name - return t -} - -func (t *Type) SetTemplate(template string) *Type { - t.Template = template - return t -} - -func (p *Type) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Type) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Name = v - } - return nil -} - -func (p *Type) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Template = v - } - return nil -} - -func (p *Type) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Type"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Type) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) } - if err := oprot.WriteString(string(p.Name)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) } - return err -} - -func (p *Type) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("template", thrift.STRING, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:template: ", p), err) } - if err := oprot.WriteString(string(p.Template)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.template (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:template: ", p), err) } - return err -} - -func (p *Type) String() string { - if p == nil { - return "" - } - - nameVal := fmt.Sprintf("%v", p.Name) - templateVal := fmt.Sprintf("%v", p.Template) - return fmt.Sprintf("Type({Name:%s Template:%s})", nameVal, templateVal) -} - -// Allocates a field on the heap instead of inline. -// This annotation is added to support recursive types. However, you can also use it to turn a field from a value to a smart pointer. -// `@cpp.Ref` is equivalent having type`@cpp.RefType.Unique`. -// -// NOTE: A struct may transitively contain itself as a field only if at least one of the fields in the inclusion chain is either an optional Ref field or a container. Otherwise the struct would have infinite size. -// -// Attributes: -// - Type -type Ref struct { - Type RefType `thrift:"type,1" db:"type" json:"type"` -} - -func NewRef() *Ref { - return &Ref{} -} - - -func (p *Ref) GetType() RefType { - return p.Type -} -type RefBuilder struct { - obj *Ref -} - -func NewRefBuilder() *RefBuilder{ - return &RefBuilder{ - obj: NewRef(), - } -} - -func (p RefBuilder) Emit() *Ref{ - return &Ref{ - Type: p.obj.Type, - } -} - -func (r *RefBuilder) Type(type_a1 RefType) *RefBuilder { - r.obj.Type = type_a1 - return r -} - -func (r *Ref) SetType(type_a1 RefType) *Ref { - r.Type = type_a1 - return r -} - -func (p *Ref) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Ref) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - temp := RefType(v) - p.Type = temp - } - return nil -} - -func (p *Ref) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Ref"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Ref) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("type", thrift.I32, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:type: ", p), err) } - if err := oprot.WriteI32(int32(p.Type)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.type (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:type: ", p), err) } - return err -} - -func (p *Ref) String() string { - if p == nil { - return "" - } - - typeVal := fmt.Sprintf("%v", p.Type) - return fmt.Sprintf("Ref({Type:%s})", typeVal) -} - -// Changes the name of the definition in generated C++ code. -// In most cases a much better solution is to rename the problematic Thrift field itself. Only use the `cpp.name` annotation if such renaming is problematic, -// e.g. when the field name appears in code as a string, particularly when using JSON serialization, and it is hard to change all usage sites. -// -// Attributes: -// - Value -type Name struct { - Value string `thrift:"value,1" db:"value" json:"value"` -} - -func NewName() *Name { - return &Name{} -} - - -func (p *Name) GetValue() string { - return p.Value -} -type NameBuilder struct { - obj *Name -} - -func NewNameBuilder() *NameBuilder{ - return &NameBuilder{ - obj: NewName(), - } -} - -func (p NameBuilder) Emit() *Name{ - return &Name{ - Value: p.obj.Value, - } -} - -func (n *NameBuilder) Value(value string) *NameBuilder { - n.obj.Value = value - return n -} - -func (n *Name) SetValue(value string) *Name { - n.Value = value - return n -} - -func (p *Name) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Name) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Value = v - } - return nil -} - -func (p *Name) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Name"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Name) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("value", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:value: ", p), err) } - if err := oprot.WriteString(string(p.Value)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.value (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:value: ", p), err) } - return err -} - -func (p *Name) String() string { - if p == nil { - return "" - } - - valueVal := fmt.Sprintf("%v", p.Value) - return fmt.Sprintf("Name({Value:%s})", valueVal) -} - -// Lazily deserialize large field on first access. -// -// ``` -// FooWithLazyField foo; -// apache::thrift::CompactSerializer::deserialize(serializedData, foo); -// -// // large_field is lazy field, it will be deserialized on first access -// // The data will be deserialized in method call large_field_ref() -// LOG(INFO) << foo.large_field_ref()->size(); -// -// // Result will be cached, we won't deserialize again -// LOG(INFO) << foo.large_field_ref()->size(); -// ``` -// -// Read more: /doc/fb/languages/cpp/lazy.md -// -// Attributes: -// - Ref -type Lazy struct { - Ref bool `thrift:"ref,1" db:"ref" json:"ref"` -} - -func NewLazy() *Lazy { - return &Lazy{} -} - - -func (p *Lazy) GetRef() bool { - return p.Ref -} -type LazyBuilder struct { - obj *Lazy -} - -func NewLazyBuilder() *LazyBuilder{ - return &LazyBuilder{ - obj: NewLazy(), - } -} - -func (p LazyBuilder) Emit() *Lazy{ - return &Lazy{ - Ref: p.obj.Ref, - } -} - -func (l *LazyBuilder) Ref(ref bool) *LazyBuilder { - l.obj.Ref = ref - return l -} - -func (l *Lazy) SetRef(ref bool) *Lazy { - l.Ref = ref - return l -} - -func (p *Lazy) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Lazy) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Ref = v - } - return nil -} - -func (p *Lazy) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Lazy"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Lazy) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("ref", thrift.BOOL, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:ref: ", p), err) } - if err := oprot.WriteBool(bool(p.Ref)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.ref (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:ref: ", p), err) } - return err -} - -func (p *Lazy) String() string { - if p == nil { - return "" - } - - refVal := fmt.Sprintf("%v", p.Ref) - return fmt.Sprintf("Lazy({Ref:%s})", refVal) -} - -type DisableLazyChecksum struct { -} - -func NewDisableLazyChecksum() *DisableLazyChecksum { - return &DisableLazyChecksum{} -} - -type DisableLazyChecksumBuilder struct { - obj *DisableLazyChecksum -} - -func NewDisableLazyChecksumBuilder() *DisableLazyChecksumBuilder{ - return &DisableLazyChecksumBuilder{ - obj: NewDisableLazyChecksum(), - } -} - -func (p DisableLazyChecksumBuilder) Emit() *DisableLazyChecksum{ - return &DisableLazyChecksum{ - } -} - -func (p *DisableLazyChecksum) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *DisableLazyChecksum) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("DisableLazyChecksum"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *DisableLazyChecksum) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("DisableLazyChecksum({})") -} - -// An annotation that applies a C++ adapter to typedef, field, or struct. -// -// For example: -// -// @cpp.Adapter{name = "::ns::IdAdapter"} -// typedef i64 MyI64; -// -// Here the type `MyI64` has the C++ adapter `IdAdapter`. -// -// struct User { -// @cpp.Adapter{name = "::ns::IdAdapter"} -// 1: i64 id; -// } -// -// Here the field `id` has the C++ adapter `IdAdapter`. -// -// Attributes: -// - Name: The name of a C++ adapter type used to convert between Thrift and native -// C++ representation. -// -// The adapter can be either a Type or Field adapter, providing either of the following APIs: -// -// struct ThriftTypeAdapter { -// static AdaptedType fromThrift(ThriftType thrift); -// static {const ThriftType& | ThriftType} toThrift(const AdaptedType& native); -// }; -// -// struct ThriftFieldAdapter { -// // Context is an instantiation of apache::thrift::FieldContext -// template -// static void construct(AdaptedType& field, Context ctx); -// -// template -// static AdaptedType fromThriftField(ThriftType value, Context ctx); -// -// template -// static {const ThriftType& | ThriftType} toThrift(const AdaptedType& adapted, Context ctx); -// }; -// - AdaptedType: It is sometimes necessary to specify AdaptedType here (in case the codegen would -// have a circular depdenceny, which will cause the C++ build to fail). -// - UnderlyingName: The name and/or extra namespace to use when directly adapting a type -// (as opposed a typedef). -// -// In this case, the IDL name of the type will refer to the adapted type in -// C++ and the underlying thrift type will be generated in a nested -// namespace and/or with a different name. -// -// If neither `underlyingName` or `extraNamespace` is provided, the -// underlying type will be generated in a nested 'detail' namespace with -// the same name. -// - ExtraNamespace -// - MoveOnly: Must set to true when adapted type is not copyable. -type Adapter struct { - Name string `thrift:"name,1" db:"name" json:"name"` - AdaptedType string `thrift:"adaptedType,2" db:"adaptedType" json:"adaptedType"` - UnderlyingName string `thrift:"underlyingName,3" db:"underlyingName" json:"underlyingName"` - ExtraNamespace string `thrift:"extraNamespace,4" db:"extraNamespace" json:"extraNamespace"` - MoveOnly bool `thrift:"moveOnly,5" db:"moveOnly" json:"moveOnly"` -} - -func NewAdapter() *Adapter { - return &Adapter{} -} - - -func (p *Adapter) GetName() string { - return p.Name -} - -func (p *Adapter) GetAdaptedType() string { - return p.AdaptedType -} - -func (p *Adapter) GetUnderlyingName() string { - return p.UnderlyingName -} - -func (p *Adapter) GetExtraNamespace() string { - return p.ExtraNamespace -} - -func (p *Adapter) GetMoveOnly() bool { - return p.MoveOnly -} -type AdapterBuilder struct { - obj *Adapter -} - -func NewAdapterBuilder() *AdapterBuilder{ - return &AdapterBuilder{ - obj: NewAdapter(), - } -} - -func (p AdapterBuilder) Emit() *Adapter{ - return &Adapter{ - Name: p.obj.Name, - AdaptedType: p.obj.AdaptedType, - UnderlyingName: p.obj.UnderlyingName, - ExtraNamespace: p.obj.ExtraNamespace, - MoveOnly: p.obj.MoveOnly, - } -} - -func (a *AdapterBuilder) Name(name string) *AdapterBuilder { - a.obj.Name = name - return a -} - -func (a *AdapterBuilder) AdaptedType(adaptedType string) *AdapterBuilder { - a.obj.AdaptedType = adaptedType - return a -} - -func (a *AdapterBuilder) UnderlyingName(underlyingName string) *AdapterBuilder { - a.obj.UnderlyingName = underlyingName - return a -} - -func (a *AdapterBuilder) ExtraNamespace(extraNamespace string) *AdapterBuilder { - a.obj.ExtraNamespace = extraNamespace - return a -} - -func (a *AdapterBuilder) MoveOnly(moveOnly bool) *AdapterBuilder { - a.obj.MoveOnly = moveOnly - return a -} - -func (a *Adapter) SetName(name string) *Adapter { - a.Name = name - return a -} - -func (a *Adapter) SetAdaptedType(adaptedType string) *Adapter { - a.AdaptedType = adaptedType - return a -} - -func (a *Adapter) SetUnderlyingName(underlyingName string) *Adapter { - a.UnderlyingName = underlyingName - return a -} - -func (a *Adapter) SetExtraNamespace(extraNamespace string) *Adapter { - a.ExtraNamespace = extraNamespace - return a -} - -func (a *Adapter) SetMoveOnly(moveOnly bool) *Adapter { - a.MoveOnly = moveOnly - return a -} - -func (p *Adapter) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 3: - if err := p.ReadField3(iprot); err != nil { - return err - } - case 4: - if err := p.ReadField4(iprot); err != nil { - return err - } - case 5: - if err := p.ReadField5(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Adapter) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Name = v - } - return nil -} - -func (p *Adapter) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.AdaptedType = v - } - return nil -} - -func (p *Adapter) ReadField3(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 3: ", err) - } else { - p.UnderlyingName = v - } - return nil -} - -func (p *Adapter) ReadField4(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 4: ", err) - } else { - p.ExtraNamespace = v - } - return nil -} - -func (p *Adapter) ReadField5(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 5: ", err) - } else { - p.MoveOnly = v - } - return nil -} - -func (p *Adapter) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Adapter"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := p.writeField4(oprot); err != nil { return err } - if err := p.writeField5(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Adapter) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) } - if err := oprot.WriteString(string(p.Name)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) } - return err -} - -func (p *Adapter) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("adaptedType", thrift.STRING, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:adaptedType: ", p), err) } - if err := oprot.WriteString(string(p.AdaptedType)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.adaptedType (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:adaptedType: ", p), err) } - return err -} - -func (p *Adapter) writeField3(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("underlyingName", thrift.STRING, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:underlyingName: ", p), err) } - if err := oprot.WriteString(string(p.UnderlyingName)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.underlyingName (3) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:underlyingName: ", p), err) } - return err -} - -func (p *Adapter) writeField4(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("extraNamespace", thrift.STRING, 4); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:extraNamespace: ", p), err) } - if err := oprot.WriteString(string(p.ExtraNamespace)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.extraNamespace (4) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 4:extraNamespace: ", p), err) } - return err -} - -func (p *Adapter) writeField5(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("moveOnly", thrift.BOOL, 5); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:moveOnly: ", p), err) } - if err := oprot.WriteBool(bool(p.MoveOnly)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.moveOnly (5) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 5:moveOnly: ", p), err) } - return err -} - -func (p *Adapter) String() string { - if p == nil { - return "" - } - - nameVal := fmt.Sprintf("%v", p.Name) - adaptedTypeVal := fmt.Sprintf("%v", p.AdaptedType) - underlyingNameVal := fmt.Sprintf("%v", p.UnderlyingName) - extraNamespaceVal := fmt.Sprintf("%v", p.ExtraNamespace) - moveOnlyVal := fmt.Sprintf("%v", p.MoveOnly) - return fmt.Sprintf("Adapter({Name:%s AdaptedType:%s UnderlyingName:%s ExtraNamespace:%s MoveOnly:%s})", nameVal, adaptedTypeVal, underlyingNameVal, extraNamespaceVal, moveOnlyVal) -} - -// Packs isset bits into fewer bytes to save space at the cost of making access more expensive. -// Passing `atomic = false` reduces the access cost while making concurrent writes UB. -// Read more: /doc/fb/languages/cpp/isset-bitpacking.md -// -// Attributes: -// - Atomic -type PackIsset struct { - Atomic bool `thrift:"atomic,1" db:"atomic" json:"atomic"` -} - -func NewPackIsset() *PackIsset { - return &PackIsset{ - Atomic: true, - } -} - - -func (p *PackIsset) GetAtomic() bool { - return p.Atomic -} -type PackIssetBuilder struct { - obj *PackIsset -} - -func NewPackIssetBuilder() *PackIssetBuilder{ - return &PackIssetBuilder{ - obj: NewPackIsset(), - } -} - -func (p PackIssetBuilder) Emit() *PackIsset{ - return &PackIsset{ - Atomic: p.obj.Atomic, - } -} - -func (p *PackIssetBuilder) Atomic(atomic bool) *PackIssetBuilder { - p.obj.Atomic = atomic - return p -} - -func (p *PackIsset) SetAtomic(atomic bool) *PackIsset { - p.Atomic = atomic - return p -} - -func (p *PackIsset) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *PackIsset) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Atomic = v - } - return nil -} - -func (p *PackIsset) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("PackIsset"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *PackIsset) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("atomic", thrift.BOOL, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:atomic: ", p), err) } - if err := oprot.WriteBool(bool(p.Atomic)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.atomic (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:atomic: ", p), err) } - return err -} - -func (p *PackIsset) String() string { - if p == nil { - return "" - } - - atomicVal := fmt.Sprintf("%v", p.Atomic) - return fmt.Sprintf("PackIsset({Atomic:%s})", atomicVal) -} - -// This annotation enables reordering of fields in the generated C++ struct to minimize padding. -// This is achieved by placing the fields in the order of decreasing alignments. The order of fields with the same alignment is preserved. -// -// ``` -// @cpp.MinimizePadding -// struct Padded { -// 1: byte small -// 2: i64 big -// 3: i16 medium -// 4: i32 biggish -// 5: byte tiny -// } -// ``` -// -// For example, the C++ fields for the `Padded` Thrift struct above will be generated in the following order: -// -// ``` -// int64_t big; -// int32_t biggish; -// int16_t medium; -// int8_t small; -// int8_t tiny; -// ``` -// -// which gives the size of 16 bytes compared to 32 bytes if `cpp.MinimizePadding` was not specified. -type MinimizePadding struct { -} - -func NewMinimizePadding() *MinimizePadding { - return &MinimizePadding{} -} - -type MinimizePaddingBuilder struct { - obj *MinimizePadding -} - -func NewMinimizePaddingBuilder() *MinimizePaddingBuilder{ - return &MinimizePaddingBuilder{ - obj: NewMinimizePadding(), - } -} - -func (p MinimizePaddingBuilder) Emit() *MinimizePadding{ - return &MinimizePadding{ - } -} - -func (p *MinimizePadding) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MinimizePadding) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("MinimizePadding"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MinimizePadding) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("MinimizePadding({})") -} - -type TriviallyRelocatable struct { -} - -func NewTriviallyRelocatable() *TriviallyRelocatable { - return &TriviallyRelocatable{} -} - -type TriviallyRelocatableBuilder struct { - obj *TriviallyRelocatable -} - -func NewTriviallyRelocatableBuilder() *TriviallyRelocatableBuilder{ - return &TriviallyRelocatableBuilder{ - obj: NewTriviallyRelocatable(), - } -} - -func (p TriviallyRelocatableBuilder) Emit() *TriviallyRelocatable{ - return &TriviallyRelocatable{ - } -} - -func (p *TriviallyRelocatable) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *TriviallyRelocatable) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("TriviallyRelocatable"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *TriviallyRelocatable) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("TriviallyRelocatable({})") -} - -type ScopedEnumAsUnionType struct { -} - -func NewScopedEnumAsUnionType() *ScopedEnumAsUnionType { - return &ScopedEnumAsUnionType{} -} - -type ScopedEnumAsUnionTypeBuilder struct { - obj *ScopedEnumAsUnionType -} - -func NewScopedEnumAsUnionTypeBuilder() *ScopedEnumAsUnionTypeBuilder{ - return &ScopedEnumAsUnionTypeBuilder{ - obj: NewScopedEnumAsUnionType(), - } -} - -func (p ScopedEnumAsUnionTypeBuilder) Emit() *ScopedEnumAsUnionType{ - return &ScopedEnumAsUnionType{ - } -} - -func (p *ScopedEnumAsUnionType) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ScopedEnumAsUnionType) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("ScopedEnumAsUnionType"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *ScopedEnumAsUnionType) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("ScopedEnumAsUnionType({})") -} - -// Indicates a typedef should be 'strong', and require an explicit cast to -// the underlying type. -// -// Currently only works for integer typedefs, for example: -// -// @cpp.StrongType -// typedef i32 MyId; -// -// Will cause an enum class to be used instead of a typedef in the genearte code, for example: -// -// enum class MyId : ::std::int32_t {}; -// -type StrongType struct { -} - -func NewStrongType() *StrongType { - return &StrongType{} -} - -type StrongTypeBuilder struct { - obj *StrongType -} - -func NewStrongTypeBuilder() *StrongTypeBuilder{ - return &StrongTypeBuilder{ - obj: NewStrongType(), - } -} - -func (p StrongTypeBuilder) Emit() *StrongType{ - return &StrongType{ - } -} - -func (p *StrongType) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *StrongType) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("StrongType"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *StrongType) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("StrongType({})") -} - -// An annotation that intercepts field access with C++ field interceptor. -// Use with *caution* since this may introduce substantial performance overhead on each field access. -// -// For example: -// -// struct Foo { -// @cpp.FieldInterceptor{name = "MyFieldInterceptor"} -// 1: i64 id; -// } -// -// The field interceptor `MyFieldInterceptor` will intercept with `interceptThriftFieldAccess` -// when the field `id` is accessed. -// -// Attributes: -// - Name: The name of a field interceptor. -// -// The field interceptor provides the following API: -// -// struct ThriftFieldInterceptor { -// template -// static void interceptThriftFieldAccess(T&& field, -// apache::thrift::FieldContext&& ctx); -// }; -// -// The field interceptor intercepts with the field value and the field context. -// It enforces an easily searchable function name `interceptThriftFieldAccess`. -// - Noinline: Setting to true makes compiler not inline and erase function signature for -// the intercepting field accessor. -type FieldInterceptor struct { - Name string `thrift:"name,1" db:"name" json:"name"` - Noinline bool `thrift:"noinline,2" db:"noinline" json:"noinline"` -} - -func NewFieldInterceptor() *FieldInterceptor { - return &FieldInterceptor{} -} - - -func (p *FieldInterceptor) GetName() string { - return p.Name -} - -func (p *FieldInterceptor) GetNoinline() bool { - return p.Noinline -} -type FieldInterceptorBuilder struct { - obj *FieldInterceptor -} - -func NewFieldInterceptorBuilder() *FieldInterceptorBuilder{ - return &FieldInterceptorBuilder{ - obj: NewFieldInterceptor(), - } -} - -func (p FieldInterceptorBuilder) Emit() *FieldInterceptor{ - return &FieldInterceptor{ - Name: p.obj.Name, - Noinline: p.obj.Noinline, - } -} - -func (f *FieldInterceptorBuilder) Name(name string) *FieldInterceptorBuilder { - f.obj.Name = name - return f -} - -func (f *FieldInterceptorBuilder) Noinline(noinline bool) *FieldInterceptorBuilder { - f.obj.Noinline = noinline - return f -} - -func (f *FieldInterceptor) SetName(name string) *FieldInterceptor { - f.Name = name - return f -} - -func (f *FieldInterceptor) SetNoinline(noinline bool) *FieldInterceptor { - f.Noinline = noinline - return f -} - -func (p *FieldInterceptor) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *FieldInterceptor) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Name = v - } - return nil -} - -func (p *FieldInterceptor) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Noinline = v - } - return nil -} - -func (p *FieldInterceptor) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("FieldInterceptor"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *FieldInterceptor) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) } - if err := oprot.WriteString(string(p.Name)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) } - return err -} - -func (p *FieldInterceptor) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("noinline", thrift.BOOL, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:noinline: ", p), err) } - if err := oprot.WriteBool(bool(p.Noinline)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.noinline (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:noinline: ", p), err) } - return err -} - -func (p *FieldInterceptor) String() string { - if p == nil { - return "" - } - - nameVal := fmt.Sprintf("%v", p.Name) - noinlineVal := fmt.Sprintf("%v", p.Noinline) - return fmt.Sprintf("FieldInterceptor({Name:%s Noinline:%s})", nameVal, noinlineVal) -} - -type UseOpEncode struct { -} - -func NewUseOpEncode() *UseOpEncode { - return &UseOpEncode{} -} - -type UseOpEncodeBuilder struct { - obj *UseOpEncode -} - -func NewUseOpEncodeBuilder() *UseOpEncodeBuilder{ - return &UseOpEncodeBuilder{ - obj: NewUseOpEncode(), - } -} - -func (p UseOpEncodeBuilder) Emit() *UseOpEncode{ - return &UseOpEncode{ - } -} - -func (p *UseOpEncode) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *UseOpEncode) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("UseOpEncode"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *UseOpEncode) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("UseOpEncode({})") -} - -// Indicates an integer type for C++ to use as the underlying type of enum, for example: -// -// @cpp.EnumType{type = cpp.EnumUnderlyingType.I8} -// enum Fruit { -// Apple = 0, -// Banana = 1, -// } -// -// will be generated into the following: -// -// enum class Fruit : ::std::int8_t { -// Apple = 0, -// Banana = 1, -// }; -// -// -// Attributes: -// - Type -type EnumType struct { - Type EnumUnderlyingType `thrift:"type,1" db:"type" json:"type"` -} - -func NewEnumType() *EnumType { - return &EnumType{} -} - - -func (p *EnumType) GetType() EnumUnderlyingType { - return p.Type -} -type EnumTypeBuilder struct { - obj *EnumType -} - -func NewEnumTypeBuilder() *EnumTypeBuilder{ - return &EnumTypeBuilder{ - obj: NewEnumType(), - } -} - -func (p EnumTypeBuilder) Emit() *EnumType{ - return &EnumType{ - Type: p.obj.Type, - } -} - -func (e *EnumTypeBuilder) Type(type_a1 EnumUnderlyingType) *EnumTypeBuilder { - e.obj.Type = type_a1 - return e -} - -func (e *EnumType) SetType(type_a1 EnumUnderlyingType) *EnumType { - e.Type = type_a1 - return e -} - -func (p *EnumType) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *EnumType) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - temp := EnumUnderlyingType(v) - p.Type = temp - } - return nil -} - -func (p *EnumType) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("EnumType"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *EnumType) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("type", thrift.I32, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:type: ", p), err) } - if err := oprot.WriteI32(int32(p.Type)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.type (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:type: ", p), err) } - return err -} - -func (p *EnumType) String() string { - if p == nil { - return "" - } - - typeVal := fmt.Sprintf("%v", p.Type) - return fmt.Sprintf("EnumType({Type:%s})", typeVal) -} - -// Indicates that frozen types should not be generated for a given struct. -type Frozen2Exclude struct { -} - -func NewFrozen2Exclude() *Frozen2Exclude { - return &Frozen2Exclude{} -} - -type Frozen2ExcludeBuilder struct { - obj *Frozen2Exclude -} - -func NewFrozen2ExcludeBuilder() *Frozen2ExcludeBuilder{ - return &Frozen2ExcludeBuilder{ - obj: NewFrozen2Exclude(), - } -} - -func (p Frozen2ExcludeBuilder) Emit() *Frozen2Exclude{ - return &Frozen2Exclude{ - } -} - -func (p *Frozen2Exclude) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Frozen2Exclude) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Frozen2Exclude"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Frozen2Exclude) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Frozen2Exclude({})") -} - -// Indicates that the container params must be complete at the time this type is instantiated. -// Only required in rare cases where the build fails with a frozen-related assert failure. -type Frozen2RequiresCompleteContainerParams struct { -} - -func NewFrozen2RequiresCompleteContainerParams() *Frozen2RequiresCompleteContainerParams { - return &Frozen2RequiresCompleteContainerParams{} -} - -type Frozen2RequiresCompleteContainerParamsBuilder struct { - obj *Frozen2RequiresCompleteContainerParams -} - -func NewFrozen2RequiresCompleteContainerParamsBuilder() *Frozen2RequiresCompleteContainerParamsBuilder{ - return &Frozen2RequiresCompleteContainerParamsBuilder{ - obj: NewFrozen2RequiresCompleteContainerParams(), - } -} - -func (p Frozen2RequiresCompleteContainerParamsBuilder) Emit() *Frozen2RequiresCompleteContainerParams{ - return &Frozen2RequiresCompleteContainerParams{ - } -} - -func (p *Frozen2RequiresCompleteContainerParams) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Frozen2RequiresCompleteContainerParams) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Frozen2RequiresCompleteContainerParams"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Frozen2RequiresCompleteContainerParams) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Frozen2RequiresCompleteContainerParams({})") -} - -// Generates typed interceptor stubs that can be overriden by user, -// and adorn the handler methods. This can be used on individual functions -// or on services (equivalent to adding it to all functions). -// -// service MyService { -// @cpp.GenerateTypedInterceptor -// void ping(); -// } -// -// This will generate the following interface: -// -// class TypedInterceptor { -// TypeErasedStorage before_ping(); -// TypeErasedStorage after_ping(); -// } -// -type GenerateTypedInterceptor struct { -} - -func NewGenerateTypedInterceptor() *GenerateTypedInterceptor { - return &GenerateTypedInterceptor{} -} - -type GenerateTypedInterceptorBuilder struct { - obj *GenerateTypedInterceptor -} - -func NewGenerateTypedInterceptorBuilder() *GenerateTypedInterceptorBuilder{ - return &GenerateTypedInterceptorBuilder{ - obj: NewGenerateTypedInterceptor(), - } -} - -func (p GenerateTypedInterceptorBuilder) Emit() *GenerateTypedInterceptor{ - return &GenerateTypedInterceptor{ - } -} - -func (p *GenerateTypedInterceptor) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *GenerateTypedInterceptor) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("GenerateTypedInterceptor"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *GenerateTypedInterceptor) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("GenerateTypedInterceptor({})") -} - -// Causes C++ handler code to run inline on the EventBase thread. -// Disables overload protection, use with caution. -// Cannot be applied to individual functions in interactions. -// -// Causes the request to be executed on the event base thread directly instead of rescheduling onto a thread manager thread, provided the async_eb_ handler method is implemented. -// You should only execute the request on the event base thread if it is very fast and you have measured that rescheduling is a substantial chunk of your service's CPU usage. -// If a request executing on the event base thread blocks or takes a long time, all other requests sharing the same event base are affected and latency will increase significantly. -// We strongly discourage the use of this annotation unless strictly necessary. You will have to implement the harder-to-use async_eb_ handler method. -// This also disables queue timeouts, an important form of overload protection. -type ProcessInEbThreadUnsafe struct { -} - -func NewProcessInEbThreadUnsafe() *ProcessInEbThreadUnsafe { - return &ProcessInEbThreadUnsafe{} -} - -type ProcessInEbThreadUnsafeBuilder struct { - obj *ProcessInEbThreadUnsafe -} - -func NewProcessInEbThreadUnsafeBuilder() *ProcessInEbThreadUnsafeBuilder{ - return &ProcessInEbThreadUnsafeBuilder{ - obj: NewProcessInEbThreadUnsafe(), - } -} - -func (p ProcessInEbThreadUnsafeBuilder) Emit() *ProcessInEbThreadUnsafe{ - return &ProcessInEbThreadUnsafe{ - } -} - -func (p *ProcessInEbThreadUnsafe) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ProcessInEbThreadUnsafe) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("ProcessInEbThreadUnsafe"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *ProcessInEbThreadUnsafe) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("ProcessInEbThreadUnsafe({})") -} - -// Applies to structured annotation that need to be accessed in Runtime. -type RuntimeAnnotation struct { -} - -func NewRuntimeAnnotation() *RuntimeAnnotation { - return &RuntimeAnnotation{} -} - -type RuntimeAnnotationBuilder struct { - obj *RuntimeAnnotation -} - -func NewRuntimeAnnotationBuilder() *RuntimeAnnotationBuilder{ - return &RuntimeAnnotationBuilder{ - obj: NewRuntimeAnnotation(), - } -} - -func (p RuntimeAnnotationBuilder) Emit() *RuntimeAnnotation{ - return &RuntimeAnnotation{ - } -} - -func (p *RuntimeAnnotation) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *RuntimeAnnotation) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("RuntimeAnnotation"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *RuntimeAnnotation) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("RuntimeAnnotation({})") -} - diff --git a/thrift/compiler/test/fixtures/patch/gen-go/thrift/annotation/java/constants.go b/thrift/compiler/test/fixtures/patch/gen-go/thrift/annotation/java/constants.go deleted file mode 100644 index 45e413c5f06..00000000000 --- a/thrift/compiler/test/fixtures/patch/gen-go/thrift/annotation/java/constants.go +++ /dev/null @@ -1,25 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package java - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - - -func init() { -} - diff --git a/thrift/compiler/test/fixtures/patch/gen-go/thrift/annotation/java/ttypes.go b/thrift/compiler/test/fixtures/patch/gen-go/thrift/annotation/java/ttypes.go deleted file mode 100644 index bc8476eda18..00000000000 --- a/thrift/compiler/test/fixtures/patch/gen-go/thrift/annotation/java/ttypes.go +++ /dev/null @@ -1,635 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package java - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var GoUnusedProtection__ int; - -type Mutable struct { -} - -func NewMutable() *Mutable { - return &Mutable{} -} - -type MutableBuilder struct { - obj *Mutable -} - -func NewMutableBuilder() *MutableBuilder{ - return &MutableBuilder{ - obj: NewMutable(), - } -} - -func (p MutableBuilder) Emit() *Mutable{ - return &Mutable{ - } -} - -func (p *Mutable) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Mutable) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Mutable"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Mutable) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Mutable({})") -} - -// Attributes: -// - JavaAnnotation -type Annotation struct { - JavaAnnotation string `thrift:"java_annotation,1" db:"java_annotation" json:"java_annotation"` -} - -func NewAnnotation() *Annotation { - return &Annotation{} -} - - -func (p *Annotation) GetJavaAnnotation() string { - return p.JavaAnnotation -} -type AnnotationBuilder struct { - obj *Annotation -} - -func NewAnnotationBuilder() *AnnotationBuilder{ - return &AnnotationBuilder{ - obj: NewAnnotation(), - } -} - -func (p AnnotationBuilder) Emit() *Annotation{ - return &Annotation{ - JavaAnnotation: p.obj.JavaAnnotation, - } -} - -func (a *AnnotationBuilder) JavaAnnotation(javaAnnotation string) *AnnotationBuilder { - a.obj.JavaAnnotation = javaAnnotation - return a -} - -func (a *Annotation) SetJavaAnnotation(javaAnnotation string) *Annotation { - a.JavaAnnotation = javaAnnotation - return a -} - -func (p *Annotation) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Annotation) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.JavaAnnotation = v - } - return nil -} - -func (p *Annotation) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Annotation"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Annotation) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("java_annotation", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:java_annotation: ", p), err) } - if err := oprot.WriteString(string(p.JavaAnnotation)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.java_annotation (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:java_annotation: ", p), err) } - return err -} - -func (p *Annotation) String() string { - if p == nil { - return "" - } - - javaAnnotationVal := fmt.Sprintf("%v", p.JavaAnnotation) - return fmt.Sprintf("Annotation({JavaAnnotation:%s})", javaAnnotationVal) -} - -type BinaryString struct { -} - -func NewBinaryString() *BinaryString { - return &BinaryString{} -} - -type BinaryStringBuilder struct { - obj *BinaryString -} - -func NewBinaryStringBuilder() *BinaryStringBuilder{ - return &BinaryStringBuilder{ - obj: NewBinaryString(), - } -} - -func (p BinaryStringBuilder) Emit() *BinaryString{ - return &BinaryString{ - } -} - -func (p *BinaryString) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *BinaryString) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("BinaryString"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *BinaryString) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("BinaryString({})") -} - -// Attributes: -// - AdapterClassName -// - TypeClassName -type Adapter struct { - AdapterClassName string `thrift:"adapterClassName,1" db:"adapterClassName" json:"adapterClassName"` - TypeClassName string `thrift:"typeClassName,2" db:"typeClassName" json:"typeClassName"` -} - -func NewAdapter() *Adapter { - return &Adapter{} -} - - -func (p *Adapter) GetAdapterClassName() string { - return p.AdapterClassName -} - -func (p *Adapter) GetTypeClassName() string { - return p.TypeClassName -} -type AdapterBuilder struct { - obj *Adapter -} - -func NewAdapterBuilder() *AdapterBuilder{ - return &AdapterBuilder{ - obj: NewAdapter(), - } -} - -func (p AdapterBuilder) Emit() *Adapter{ - return &Adapter{ - AdapterClassName: p.obj.AdapterClassName, - TypeClassName: p.obj.TypeClassName, - } -} - -func (a *AdapterBuilder) AdapterClassName(adapterClassName string) *AdapterBuilder { - a.obj.AdapterClassName = adapterClassName - return a -} - -func (a *AdapterBuilder) TypeClassName(typeClassName string) *AdapterBuilder { - a.obj.TypeClassName = typeClassName - return a -} - -func (a *Adapter) SetAdapterClassName(adapterClassName string) *Adapter { - a.AdapterClassName = adapterClassName - return a -} - -func (a *Adapter) SetTypeClassName(typeClassName string) *Adapter { - a.TypeClassName = typeClassName - return a -} - -func (p *Adapter) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Adapter) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.AdapterClassName = v - } - return nil -} - -func (p *Adapter) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.TypeClassName = v - } - return nil -} - -func (p *Adapter) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Adapter"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Adapter) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("adapterClassName", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:adapterClassName: ", p), err) } - if err := oprot.WriteString(string(p.AdapterClassName)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.adapterClassName (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:adapterClassName: ", p), err) } - return err -} - -func (p *Adapter) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("typeClassName", thrift.STRING, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:typeClassName: ", p), err) } - if err := oprot.WriteString(string(p.TypeClassName)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.typeClassName (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:typeClassName: ", p), err) } - return err -} - -func (p *Adapter) String() string { - if p == nil { - return "" - } - - adapterClassNameVal := fmt.Sprintf("%v", p.AdapterClassName) - typeClassNameVal := fmt.Sprintf("%v", p.TypeClassName) - return fmt.Sprintf("Adapter({AdapterClassName:%s TypeClassName:%s})", adapterClassNameVal, typeClassNameVal) -} - -// Attributes: -// - WrapperClassName -// - TypeClassName -type Wrapper struct { - WrapperClassName string `thrift:"wrapperClassName,1" db:"wrapperClassName" json:"wrapperClassName"` - TypeClassName string `thrift:"typeClassName,2" db:"typeClassName" json:"typeClassName"` -} - -func NewWrapper() *Wrapper { - return &Wrapper{} -} - - -func (p *Wrapper) GetWrapperClassName() string { - return p.WrapperClassName -} - -func (p *Wrapper) GetTypeClassName() string { - return p.TypeClassName -} -type WrapperBuilder struct { - obj *Wrapper -} - -func NewWrapperBuilder() *WrapperBuilder{ - return &WrapperBuilder{ - obj: NewWrapper(), - } -} - -func (p WrapperBuilder) Emit() *Wrapper{ - return &Wrapper{ - WrapperClassName: p.obj.WrapperClassName, - TypeClassName: p.obj.TypeClassName, - } -} - -func (w *WrapperBuilder) WrapperClassName(wrapperClassName string) *WrapperBuilder { - w.obj.WrapperClassName = wrapperClassName - return w -} - -func (w *WrapperBuilder) TypeClassName(typeClassName string) *WrapperBuilder { - w.obj.TypeClassName = typeClassName - return w -} - -func (w *Wrapper) SetWrapperClassName(wrapperClassName string) *Wrapper { - w.WrapperClassName = wrapperClassName - return w -} - -func (w *Wrapper) SetTypeClassName(typeClassName string) *Wrapper { - w.TypeClassName = typeClassName - return w -} - -func (p *Wrapper) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Wrapper) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.WrapperClassName = v - } - return nil -} - -func (p *Wrapper) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.TypeClassName = v - } - return nil -} - -func (p *Wrapper) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Wrapper"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Wrapper) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("wrapperClassName", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:wrapperClassName: ", p), err) } - if err := oprot.WriteString(string(p.WrapperClassName)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.wrapperClassName (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:wrapperClassName: ", p), err) } - return err -} - -func (p *Wrapper) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("typeClassName", thrift.STRING, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:typeClassName: ", p), err) } - if err := oprot.WriteString(string(p.TypeClassName)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.typeClassName (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:typeClassName: ", p), err) } - return err -} - -func (p *Wrapper) String() string { - if p == nil { - return "" - } - - wrapperClassNameVal := fmt.Sprintf("%v", p.WrapperClassName) - typeClassNameVal := fmt.Sprintf("%v", p.TypeClassName) - return fmt.Sprintf("Wrapper({WrapperClassName:%s TypeClassName:%s})", wrapperClassNameVal, typeClassNameVal) -} - -type Recursive struct { -} - -func NewRecursive() *Recursive { - return &Recursive{} -} - -type RecursiveBuilder struct { - obj *Recursive -} - -func NewRecursiveBuilder() *RecursiveBuilder{ - return &RecursiveBuilder{ - obj: NewRecursive(), - } -} - -func (p RecursiveBuilder) Emit() *Recursive{ - return &Recursive{ - } -} - -func (p *Recursive) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Recursive) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Recursive"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Recursive) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Recursive({})") -} - diff --git a/thrift/compiler/test/fixtures/patch/gen-go/thrift/annotation/scope/constants.go b/thrift/compiler/test/fixtures/patch/gen-go/thrift/annotation/scope/constants.go deleted file mode 100644 index 0c3448a7126..00000000000 --- a/thrift/compiler/test/fixtures/patch/gen-go/thrift/annotation/scope/constants.go +++ /dev/null @@ -1,25 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package scope - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - - -func init() { -} - diff --git a/thrift/compiler/test/fixtures/patch/gen-go/thrift/annotation/scope/ttypes.go b/thrift/compiler/test/fixtures/patch/gen-go/thrift/annotation/scope/ttypes.go deleted file mode 100644 index 580c39e775c..00000000000 --- a/thrift/compiler/test/fixtures/patch/gen-go/thrift/annotation/scope/ttypes.go +++ /dev/null @@ -1,1169 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package scope - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var GoUnusedProtection__ int; - -// Indicates that the scope of sibling annotations is transitive. -// -// For example: -// -// @scope.Struct -// @scope.Union -// @scope.Exception -// @scope.Transitive -// struct Structured {} -// -// Annotating a Thrift struct with @Structured automatically applies -// @scope.Struct, @scope.Union and @scope.Exception annotations, i.e. -// -// @Structured -// struct MyAnnotation {} -// -// is equivalent to -// -// @scope.Struct -// @scope.Union -// @scope.Exception -// struct MyAnnotation {} -// -type Transitive struct { -} - -func NewTransitive() *Transitive { - return &Transitive{} -} - -type TransitiveBuilder struct { - obj *Transitive -} - -func NewTransitiveBuilder() *TransitiveBuilder{ - return &TransitiveBuilder{ - obj: NewTransitive(), - } -} - -func (p TransitiveBuilder) Emit() *Transitive{ - return &Transitive{ - } -} - -func (p *Transitive) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Transitive) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Transitive"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Transitive) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Transitive({})") -} - -// The Program scope. -// -// This allows annotations on the `package` definition, which implies the -// annotaiton applies to the entire program. -type Program struct { -} - -func NewProgram() *Program { - return &Program{} -} - -type ProgramBuilder struct { - obj *Program -} - -func NewProgramBuilder() *ProgramBuilder{ - return &ProgramBuilder{ - obj: NewProgram(), - } -} - -func (p ProgramBuilder) Emit() *Program{ - return &Program{ - } -} - -func (p *Program) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Program) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Program"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Program) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Program({})") -} - -// The `struct` definition scope. -type Struct struct { -} - -func NewStruct() *Struct { - return &Struct{} -} - -type StructBuilder struct { - obj *Struct -} - -func NewStructBuilder() *StructBuilder{ - return &StructBuilder{ - obj: NewStruct(), - } -} - -func (p StructBuilder) Emit() *Struct{ - return &Struct{ - } -} - -func (p *Struct) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Struct) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Struct"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Struct) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Struct({})") -} - -// The `union` definition scope. -type Union struct { -} - -func NewUnion() *Union { - return &Union{} -} - -type UnionBuilder struct { - obj *Union -} - -func NewUnionBuilder() *UnionBuilder{ - return &UnionBuilder{ - obj: NewUnion(), - } -} - -func (p UnionBuilder) Emit() *Union{ - return &Union{ - } -} - -func (p *Union) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Union) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Union"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Union) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Union({})") -} - -// The `exception` definition scope. -type Exception struct { -} - -func NewException() *Exception { - return &Exception{} -} - -type ExceptionBuilder struct { - obj *Exception -} - -func NewExceptionBuilder() *ExceptionBuilder{ - return &ExceptionBuilder{ - obj: NewException(), - } -} - -func (p ExceptionBuilder) Emit() *Exception{ - return &Exception{ - } -} - -func (p *Exception) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Exception) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Exception"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Exception) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Exception({})") -} - -// Field declartaions, for example in `struct` or `function` declartions. -type Field struct { -} - -func NewField() *Field { - return &Field{} -} - -type FieldBuilder struct { - obj *Field -} - -func NewFieldBuilder() *FieldBuilder{ - return &FieldBuilder{ - obj: NewField(), - } -} - -func (p FieldBuilder) Emit() *Field{ - return &Field{ - } -} - -func (p *Field) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Field) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Field"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Field) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Field({})") -} - -// The `typedef` definition scope. -type Typedef struct { -} - -func NewTypedef() *Typedef { - return &Typedef{} -} - -type TypedefBuilder struct { - obj *Typedef -} - -func NewTypedefBuilder() *TypedefBuilder{ - return &TypedefBuilder{ - obj: NewTypedef(), - } -} - -func (p TypedefBuilder) Emit() *Typedef{ - return &Typedef{ - } -} - -func (p *Typedef) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Typedef) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Typedef"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Typedef) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Typedef({})") -} - -// The `service` definition scope. -type Service struct { -} - -func NewService() *Service { - return &Service{} -} - -type ServiceBuilder struct { - obj *Service -} - -func NewServiceBuilder() *ServiceBuilder{ - return &ServiceBuilder{ - obj: NewService(), - } -} - -func (p ServiceBuilder) Emit() *Service{ - return &Service{ - } -} - -func (p *Service) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Service) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Service"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Service) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Service({})") -} - -// The `interaction` definition scope. -type Interaction struct { -} - -func NewInteraction() *Interaction { - return &Interaction{} -} - -type InteractionBuilder struct { - obj *Interaction -} - -func NewInteractionBuilder() *InteractionBuilder{ - return &InteractionBuilder{ - obj: NewInteraction(), - } -} - -func (p InteractionBuilder) Emit() *Interaction{ - return &Interaction{ - } -} - -func (p *Interaction) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Interaction) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Interaction"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Interaction) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Interaction({})") -} - -// The `function` definition scope. -type Function struct { -} - -func NewFunction() *Function { - return &Function{} -} - -type FunctionBuilder struct { - obj *Function -} - -func NewFunctionBuilder() *FunctionBuilder{ - return &FunctionBuilder{ - obj: NewFunction(), - } -} - -func (p FunctionBuilder) Emit() *Function{ - return &Function{ - } -} - -func (p *Function) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Function) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Function"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Function) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Function({})") -} - -// The Enum value definition scope. -type EnumValue struct { -} - -func NewEnumValue() *EnumValue { - return &EnumValue{} -} - -type EnumValueBuilder struct { - obj *EnumValue -} - -func NewEnumValueBuilder() *EnumValueBuilder{ - return &EnumValueBuilder{ - obj: NewEnumValue(), - } -} - -func (p EnumValueBuilder) Emit() *EnumValue{ - return &EnumValue{ - } -} - -func (p *EnumValue) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *EnumValue) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("EnumValue"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *EnumValue) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("EnumValue({})") -} - -// The `const` definition scope. -type Const struct { -} - -func NewConst() *Const { - return &Const{} -} - -type ConstBuilder struct { - obj *Const -} - -func NewConstBuilder() *ConstBuilder{ - return &ConstBuilder{ - obj: NewConst(), - } -} - -func (p ConstBuilder) Emit() *Const{ - return &Const{ - } -} - -func (p *Const) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Const) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Const"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Const) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Const({})") -} - -type Enum struct { -} - -func NewEnum() *Enum { - return &Enum{} -} - -type EnumBuilder struct { - obj *Enum -} - -func NewEnumBuilder() *EnumBuilder{ - return &EnumBuilder{ - obj: NewEnum(), - } -} - -func (p EnumBuilder) Emit() *Enum{ - return &Enum{ - } -} - -func (p *Enum) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Enum) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Enum"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Enum) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Enum({})") -} - -// A scope that includes all 'structured' definitions. -type Structured struct { -} - -func NewStructured() *Structured { - return &Structured{} -} - -type StructuredBuilder struct { - obj *Structured -} - -func NewStructuredBuilder() *StructuredBuilder{ - return &StructuredBuilder{ - obj: NewStructured(), - } -} - -func (p StructuredBuilder) Emit() *Structured{ - return &Structured{ - } -} - -func (p *Structured) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Structured) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Structured"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Structured) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Structured({})") -} - -// A scope that includes all 'interface' definitions. -type Interface struct { -} - -func NewInterface() *Interface { - return &Interface{} -} - -type InterfaceBuilder struct { - obj *Interface -} - -func NewInterfaceBuilder() *InterfaceBuilder{ - return &InterfaceBuilder{ - obj: NewInterface(), - } -} - -func (p InterfaceBuilder) Emit() *Interface{ - return &Interface{ - } -} - -func (p *Interface) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Interface) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Interface"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Interface) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Interface({})") -} - -// A scope that includes all program-scoped definition. -type RootDefinition struct { -} - -func NewRootDefinition() *RootDefinition { - return &RootDefinition{} -} - -type RootDefinitionBuilder struct { - obj *RootDefinition -} - -func NewRootDefinitionBuilder() *RootDefinitionBuilder{ - return &RootDefinitionBuilder{ - obj: NewRootDefinition(), - } -} - -func (p RootDefinitionBuilder) Emit() *RootDefinition{ - return &RootDefinition{ - } -} - -func (p *RootDefinition) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *RootDefinition) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("RootDefinition"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *RootDefinition) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("RootDefinition({})") -} - -// A scope that includes all definitions. -type Definition struct { -} - -func NewDefinition() *Definition { - return &Definition{} -} - -type DefinitionBuilder struct { - obj *Definition -} - -func NewDefinitionBuilder() *DefinitionBuilder{ - return &DefinitionBuilder{ - obj: NewDefinition(), - } -} - -func (p DefinitionBuilder) Emit() *Definition{ - return &Definition{ - } -} - -func (p *Definition) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Definition) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Definition"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Definition) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Definition({})") -} - diff --git a/thrift/compiler/test/fixtures/patch/gen-go/thrift/annotation/thrift/constants.go b/thrift/compiler/test/fixtures/patch/gen-go/thrift/annotation/thrift/constants.go deleted file mode 100644 index 50d9b0fe3ee..00000000000 --- a/thrift/compiler/test/fixtures/patch/gen-go/thrift/annotation/thrift/constants.go +++ /dev/null @@ -1,25 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package thrift - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - - -func init() { -} - diff --git a/thrift/compiler/test/fixtures/patch/gen-go/thrift/annotation/thrift/ttypes.go b/thrift/compiler/test/fixtures/patch/gen-go/thrift/annotation/thrift/ttypes.go deleted file mode 100644 index 35ea75e3dd0..00000000000 --- a/thrift/compiler/test/fixtures/patch/gen-go/thrift/annotation/thrift/ttypes.go +++ /dev/null @@ -1,1545 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package thrift - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var GoUnusedProtection__ int; - -type RpcPriority int64 -const ( - RpcPriority_HIGH_IMPORTANT RpcPriority = 0 - RpcPriority_HIGH RpcPriority = 1 - RpcPriority_IMPORTANT RpcPriority = 2 - RpcPriority_NORMAL RpcPriority = 3 - RpcPriority_BEST_EFFORT RpcPriority = 4 -) - -var RpcPriorityToName = map[RpcPriority]string { - RpcPriority_HIGH_IMPORTANT: "HIGH_IMPORTANT", - RpcPriority_HIGH: "HIGH", - RpcPriority_IMPORTANT: "IMPORTANT", - RpcPriority_NORMAL: "NORMAL", - RpcPriority_BEST_EFFORT: "BEST_EFFORT", -} - -var RpcPriorityToValue = map[string]RpcPriority { - "HIGH_IMPORTANT": RpcPriority_HIGH_IMPORTANT, - "HIGH": RpcPriority_HIGH, - "IMPORTANT": RpcPriority_IMPORTANT, - "NORMAL": RpcPriority_NORMAL, - "BEST_EFFORT": RpcPriority_BEST_EFFORT, -} - -var RpcPriorityNames = []string { - "HIGH_IMPORTANT", - "HIGH", - "IMPORTANT", - "NORMAL", - "BEST_EFFORT", -} - -var RpcPriorityValues = []RpcPriority { - RpcPriority_HIGH_IMPORTANT, - RpcPriority_HIGH, - RpcPriority_IMPORTANT, - RpcPriority_NORMAL, - RpcPriority_BEST_EFFORT, -} - -func (p RpcPriority) String() string { - if v, ok := RpcPriorityToName[p]; ok { - return v - } - return "" -} - -func RpcPriorityFromString(s string) (RpcPriority, error) { - if v, ok := RpcPriorityToValue[s]; ok { - return v, nil - } - return RpcPriority(0), fmt.Errorf("not a valid RpcPriority string") -} - -func RpcPriorityPtr(v RpcPriority) *RpcPriority { return &v } - -// Indicates a definition/feature should only be used with permission, may -// only work in specific contexts, and may change in incompatible ways without -// notice. Note that this is primarily intended to annotate features by the Thrift Team -// and isn't recommended for general use. -type Experimental struct { -} - -func NewExperimental() *Experimental { - return &Experimental{} -} - -type ExperimentalBuilder struct { - obj *Experimental -} - -func NewExperimentalBuilder() *ExperimentalBuilder{ - return &ExperimentalBuilder{ - obj: NewExperimental(), - } -} - -func (p ExperimentalBuilder) Emit() *Experimental{ - return &Experimental{ - } -} - -func (p *Experimental) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Experimental) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Experimental"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Experimental) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Experimental({})") -} - -// Annotate a thrift structured or enum to indicate if ids or values should not -// be used. -// -// For example, you may want to mark ids as deprecated, or these ids -// might be reserved for other use cases or annotations. -// -// The resolved set of disallowed ids is the union of the values in `ids` and -// the range of values represented in `id_ranges`. Example: -// -// // These ids are not allowed: 3, 8, half-open ranges [10, 15), [20, 30) -// @thrift.ReserveIds{ids = [3, 8], id_ranges = {10: 15, 20: 30}} -// struct Foo { -// ... -// 3: i64 f; // Build failure: 3 cannot be used -// } -// -// Attributes: -// - Ids: Individual ids that cannot be used. -// - IdRanges: Represents ranges of ids that cannot be used. -// -// Each (key: value) pair represents the half-open range `[key, value)`, -// where `key` is included and `value` is not. For example, the map -// `{10: 15, 20: 30}` represents the union of id/value ranges `[10, 15)` and -// `[20, 30)`. -type ReserveIds struct { - Ids []int32 `thrift:"ids,1" db:"ids" json:"ids"` - IdRanges map[int32]int32 `thrift:"id_ranges,2" db:"id_ranges" json:"id_ranges"` -} - -func NewReserveIds() *ReserveIds { - return &ReserveIds{} -} - - -func (p *ReserveIds) GetIds() []int32 { - return p.Ids -} - -func (p *ReserveIds) GetIdRanges() map[int32]int32 { - return p.IdRanges -} -type ReserveIdsBuilder struct { - obj *ReserveIds -} - -func NewReserveIdsBuilder() *ReserveIdsBuilder{ - return &ReserveIdsBuilder{ - obj: NewReserveIds(), - } -} - -func (p ReserveIdsBuilder) Emit() *ReserveIds{ - return &ReserveIds{ - Ids: p.obj.Ids, - IdRanges: p.obj.IdRanges, - } -} - -func (r *ReserveIdsBuilder) Ids(ids []int32) *ReserveIdsBuilder { - r.obj.Ids = ids - return r -} - -func (r *ReserveIdsBuilder) IdRanges(idRanges map[int32]int32) *ReserveIdsBuilder { - r.obj.IdRanges = idRanges - return r -} - -func (r *ReserveIds) SetIds(ids []int32) *ReserveIds { - r.Ids = ids - return r -} - -func (r *ReserveIds) SetIdRanges(idRanges map[int32]int32) *ReserveIds { - r.IdRanges = idRanges - return r -} - -func (p *ReserveIds) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ReserveIds) ReadField1(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]int32, 0, size) - p.Ids = tSlice - for i := 0; i < size; i ++ { - var _elem0 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem0 = v - } - p.Ids = append(p.Ids, _elem0) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *ReserveIds) ReadField2(iprot thrift.Protocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[int32]int32, size) - p.IdRanges = tMap - for i := 0; i < size; i ++ { - var _key1 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key1 = v - } - var _val2 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _val2 = v - } - p.IdRanges[_key1] = _val2 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *ReserveIds) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("ReserveIds"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *ReserveIds) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("ids", thrift.LIST, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:ids: ", p), err) } - if err := oprot.WriteListBegin(thrift.I32, len(p.Ids)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.Ids { - if err := oprot.WriteI32(int32(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:ids: ", p), err) } - return err -} - -func (p *ReserveIds) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("id_ranges", thrift.MAP, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:id_ranges: ", p), err) } - if err := oprot.WriteMapBegin(thrift.I32, thrift.I32, len(p.IdRanges)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.IdRanges { - if err := oprot.WriteI32(int32(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := oprot.WriteI32(int32(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:id_ranges: ", p), err) } - return err -} - -func (p *ReserveIds) String() string { - if p == nil { - return "" - } - - idsVal := fmt.Sprintf("%v", p.Ids) - idRangesVal := fmt.Sprintf("%v", p.IdRanges) - return fmt.Sprintf("ReserveIds({Ids:%s IdRanges:%s})", idsVal, idRangesVal) -} - -// Indicates additional backward compatibility restrictions, beyond the -// standard Thrift required 'wire' compatibility. -// -// Attributes: -// - FieldName -type RequiresBackwardCompatibility struct { - FieldName bool `thrift:"field_name,1" db:"field_name" json:"field_name"` -} - -func NewRequiresBackwardCompatibility() *RequiresBackwardCompatibility { - return &RequiresBackwardCompatibility{} -} - - -func (p *RequiresBackwardCompatibility) GetFieldName() bool { - return p.FieldName -} -type RequiresBackwardCompatibilityBuilder struct { - obj *RequiresBackwardCompatibility -} - -func NewRequiresBackwardCompatibilityBuilder() *RequiresBackwardCompatibilityBuilder{ - return &RequiresBackwardCompatibilityBuilder{ - obj: NewRequiresBackwardCompatibility(), - } -} - -func (p RequiresBackwardCompatibilityBuilder) Emit() *RequiresBackwardCompatibility{ - return &RequiresBackwardCompatibility{ - FieldName: p.obj.FieldName, - } -} - -func (r *RequiresBackwardCompatibilityBuilder) FieldName(fieldName bool) *RequiresBackwardCompatibilityBuilder { - r.obj.FieldName = fieldName - return r -} - -func (r *RequiresBackwardCompatibility) SetFieldName(fieldName bool) *RequiresBackwardCompatibility { - r.FieldName = fieldName - return r -} - -func (p *RequiresBackwardCompatibility) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *RequiresBackwardCompatibility) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.FieldName = v - } - return nil -} - -func (p *RequiresBackwardCompatibility) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("RequiresBackwardCompatibility"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *RequiresBackwardCompatibility) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("field_name", thrift.BOOL, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:field_name: ", p), err) } - if err := oprot.WriteBool(bool(p.FieldName)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.field_name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:field_name: ", p), err) } - return err -} - -func (p *RequiresBackwardCompatibility) String() string { - if p == nil { - return "" - } - - fieldNameVal := fmt.Sprintf("%v", p.FieldName) - return fmt.Sprintf("RequiresBackwardCompatibility({FieldName:%s})", fieldNameVal) -} - -// An annotation that changes the field qualifier from 'none' to 'terse'. -// A terse field is eligible to skip serialization, when it equals to the -// intrinsic default value. It also clears to the intrinsic default value -// before deserialization to distinguish between if a terse field was skipped -// or missing during serialization. This is different from an unqualified -// field, as an unqualified field is always serialized regardless of its value, -// and it is not cleared before deserialization. -// -// The annotation can be only used to annotate an unqualified field, and when -// it is annotating a struct or exception, it changes all unqualified fields to -// terse fields. Note, the annotation can not be used for union. -type TerseWrite struct { -} - -func NewTerseWrite() *TerseWrite { - return &TerseWrite{} -} - -type TerseWriteBuilder struct { - obj *TerseWrite -} - -func NewTerseWriteBuilder() *TerseWriteBuilder{ - return &TerseWriteBuilder{ - obj: NewTerseWrite(), - } -} - -func (p TerseWriteBuilder) Emit() *TerseWrite{ - return &TerseWrite{ - } -} - -func (p *TerseWrite) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *TerseWrite) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("TerseWrite"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *TerseWrite) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("TerseWrite({})") -} - -// Indicates that an optional field's value should never be stored on the stack, -// i.e. the subobject should be allocated separately (e.g. because it is large and infrequently set). -// -// NOTE: The APIs and initialization behavior are same as normal field, but different from `@cpp.Ref`. e.g. -// -// ``` -// struct Foo { -// 1: optional i32 normal; -// @thrift.Box -// 2: optional i32 boxed; -// @cpp.Ref -// 3: optional i32 referred; -// } -// ``` -// in C++ -// -// ``` -// Foo foo; -// EXPECT_FALSE(foo.normal().has_value()); // okay -// EXPECT_FALSE(foo.boxed().has_value()); // okay -// EXPECT_FALSE(foo.referred().has_value()); // build failure: std::unique_ptr doesn't have has_value method -// -// EXPECT_EQ(*foo.normal(), 0); // throw bad_field_access exception -// EXPECT_EQ(*foo.boxed(), 0); // throw bad_field_access exception -// EXPECT_EQ(*foo.referred(), 0); // okay, field has value by default -// ``` -// -// Affects C++ and Rust. -// TODO: replace with @cpp.Box + @rust.Box -type Box struct { -} - -func NewBox() *Box { - return &Box{} -} - -type BoxBuilder struct { - obj *Box -} - -func NewBoxBuilder() *BoxBuilder{ - return &BoxBuilder{ - obj: NewBox(), - } -} - -func (p BoxBuilder) Emit() *Box{ - return &Box{ - } -} - -func (p *Box) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Box) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Box"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Box) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Box({})") -} - -// Indicates whether the nested fields are accessible directly. -// https://github.com/facebook/fbthrift/blob/v2023.11.20.00/thrift/doc/idl/mixins.md -type Mixin struct { -} - -func NewMixin() *Mixin { - return &Mixin{} -} - -type MixinBuilder struct { - obj *Mixin -} - -func NewMixinBuilder() *MixinBuilder{ - return &MixinBuilder{ - obj: NewMixin(), - } -} - -func (p MixinBuilder) Emit() *Mixin{ - return &Mixin{ - } -} - -func (p *Mixin) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Mixin) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Mixin"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Mixin) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Mixin({})") -} - -// Option to serialize thrift struct in ascending field id order instead of field declaration order. -// -// This can potentially make serialized data size smaller in compact protocol, -// since compact protocol can write deltas between subsequent field ids instead of full ids. -// -// NOTE: This annotation won't reduce payload size for other protocols. -type SerializeInFieldIdOrder struct { -} - -func NewSerializeInFieldIdOrder() *SerializeInFieldIdOrder { - return &SerializeInFieldIdOrder{} -} - -type SerializeInFieldIdOrderBuilder struct { - obj *SerializeInFieldIdOrder -} - -func NewSerializeInFieldIdOrderBuilder() *SerializeInFieldIdOrderBuilder{ - return &SerializeInFieldIdOrderBuilder{ - obj: NewSerializeInFieldIdOrder(), - } -} - -func (p SerializeInFieldIdOrderBuilder) Emit() *SerializeInFieldIdOrder{ - return &SerializeInFieldIdOrder{ - } -} - -func (p *SerializeInFieldIdOrder) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *SerializeInFieldIdOrder) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("SerializeInFieldIdOrder"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *SerializeInFieldIdOrder) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("SerializeInFieldIdOrder({})") -} - -// Indicates an enum is a bitmask and should support bit-wise operators. -// Currently generates additional code in C++ and Hack. -type BitmaskEnum struct { -} - -func NewBitmaskEnum() *BitmaskEnum { - return &BitmaskEnum{} -} - -type BitmaskEnumBuilder struct { - obj *BitmaskEnum -} - -func NewBitmaskEnumBuilder() *BitmaskEnumBuilder{ - return &BitmaskEnumBuilder{ - obj: NewBitmaskEnum(), - } -} - -func (p BitmaskEnumBuilder) Emit() *BitmaskEnum{ - return &BitmaskEnum{ - } -} - -func (p *BitmaskEnum) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *BitmaskEnum) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("BitmaskEnum"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *BitmaskEnum) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("BitmaskEnum({})") -} - -// Specifies the field where the exception message is stored. -type ExceptionMessage struct { -} - -func NewExceptionMessage() *ExceptionMessage { - return &ExceptionMessage{} -} - -type ExceptionMessageBuilder struct { - obj *ExceptionMessage -} - -func NewExceptionMessageBuilder() *ExceptionMessageBuilder{ - return &ExceptionMessageBuilder{ - obj: NewExceptionMessage(), - } -} - -func (p ExceptionMessageBuilder) Emit() *ExceptionMessage{ - return &ExceptionMessage{ - } -} - -func (p *ExceptionMessage) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ExceptionMessage) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("ExceptionMessage"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *ExceptionMessage) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("ExceptionMessage({})") -} - -// Generates a const of type schema. Struct containing the schema of the -// annotated type. Optionally specify name to override default -// schema. -// -// Attributes: -// - Name -type GenerateRuntimeSchema struct { - Name string `thrift:"name,1" db:"name" json:"name"` -} - -func NewGenerateRuntimeSchema() *GenerateRuntimeSchema { - return &GenerateRuntimeSchema{} -} - - -func (p *GenerateRuntimeSchema) GetName() string { - return p.Name -} -type GenerateRuntimeSchemaBuilder struct { - obj *GenerateRuntimeSchema -} - -func NewGenerateRuntimeSchemaBuilder() *GenerateRuntimeSchemaBuilder{ - return &GenerateRuntimeSchemaBuilder{ - obj: NewGenerateRuntimeSchema(), - } -} - -func (p GenerateRuntimeSchemaBuilder) Emit() *GenerateRuntimeSchema{ - return &GenerateRuntimeSchema{ - Name: p.obj.Name, - } -} - -func (g *GenerateRuntimeSchemaBuilder) Name(name string) *GenerateRuntimeSchemaBuilder { - g.obj.Name = name - return g -} - -func (g *GenerateRuntimeSchema) SetName(name string) *GenerateRuntimeSchema { - g.Name = name - return g -} - -func (p *GenerateRuntimeSchema) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *GenerateRuntimeSchema) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Name = v - } - return nil -} - -func (p *GenerateRuntimeSchema) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("GenerateRuntimeSchema"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *GenerateRuntimeSchema) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) } - if err := oprot.WriteString(string(p.Name)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) } - return err -} - -func (p *GenerateRuntimeSchema) String() string { - if p == nil { - return "" - } - - nameVal := fmt.Sprintf("%v", p.Name) - return fmt.Sprintf("GenerateRuntimeSchema({Name:%s})", nameVal) -} - -// Indicates that a field's value should never be stored on the stack, and that -// identical values can be shared in immutable contexts. -type InternBox struct { -} - -func NewInternBox() *InternBox { - return &InternBox{} -} - -type InternBoxBuilder struct { - obj *InternBox -} - -func NewInternBoxBuilder() *InternBoxBuilder{ - return &InternBoxBuilder{ - obj: NewInternBox(), - } -} - -func (p InternBoxBuilder) Emit() *InternBox{ - return &InternBox{ - } -} - -func (p *InternBox) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *InternBox) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("InternBox"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *InternBox) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("InternBox({})") -} - -// Indicates that an interaction's methods should be processed sequentially. -type Serial struct { -} - -func NewSerial() *Serial { - return &Serial{} -} - -type SerialBuilder struct { - obj *Serial -} - -func NewSerialBuilder() *SerialBuilder{ - return &SerialBuilder{ - obj: NewSerial(), - } -} - -func (p SerialBuilder) Emit() *Serial{ - return &Serial{ - } -} - -func (p *Serial) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Serial) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Serial"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Serial) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Serial({})") -} - -// Changes the URI of this definition away from the default-generated one. -// -// Attributes: -// - Value -type Uri struct { - Value string `thrift:"value,1" db:"value" json:"value"` -} - -func NewUri() *Uri { - return &Uri{} -} - - -func (p *Uri) GetValue() string { - return p.Value -} -type UriBuilder struct { - obj *Uri -} - -func NewUriBuilder() *UriBuilder{ - return &UriBuilder{ - obj: NewUri(), - } -} - -func (p UriBuilder) Emit() *Uri{ - return &Uri{ - Value: p.obj.Value, - } -} - -func (u *UriBuilder) Value(value string) *UriBuilder { - u.obj.Value = value - return u -} - -func (u *Uri) SetValue(value string) *Uri { - u.Value = value - return u -} - -func (p *Uri) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Uri) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Value = v - } - return nil -} - -func (p *Uri) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Uri"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Uri) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("value", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:value: ", p), err) } - if err := oprot.WriteString(string(p.Value)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.value (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:value: ", p), err) } - return err -} - -func (p *Uri) String() string { - if p == nil { - return "" - } - - valueVal := fmt.Sprintf("%v", p.Value) - return fmt.Sprintf("Uri({Value:%s})", valueVal) -} - -// Changes the priority of this function (default NORMAL). -// -// Attributes: -// - Level -type Priority struct { - Level RpcPriority `thrift:"level,1" db:"level" json:"level"` -} - -func NewPriority() *Priority { - return &Priority{} -} - - -func (p *Priority) GetLevel() RpcPriority { - return p.Level -} -type PriorityBuilder struct { - obj *Priority -} - -func NewPriorityBuilder() *PriorityBuilder{ - return &PriorityBuilder{ - obj: NewPriority(), - } -} - -func (p PriorityBuilder) Emit() *Priority{ - return &Priority{ - Level: p.obj.Level, - } -} - -func (p *PriorityBuilder) Level(level RpcPriority) *PriorityBuilder { - p.obj.Level = level - return p -} - -func (p *Priority) SetLevel(level RpcPriority) *Priority { - p.Level = level - return p -} - -func (p *Priority) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Priority) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - temp := RpcPriority(v) - p.Level = temp - } - return nil -} - -func (p *Priority) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Priority"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Priority) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("level", thrift.I32, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:level: ", p), err) } - if err := oprot.WriteI32(int32(p.Level)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.level (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:level: ", p), err) } - return err -} - -func (p *Priority) String() string { - if p == nil { - return "" - } - - levelVal := fmt.Sprintf("%v", p.Level) - return fmt.Sprintf("Priority({Level:%s})", levelVal) -} - -// Applies unstructured annotations to a definition. -// -// Attributes: -// - Items -type DeprecatedUnvalidatedAnnotations struct { - Items map[string]string `thrift:"items,1" db:"items" json:"items"` -} - -func NewDeprecatedUnvalidatedAnnotations() *DeprecatedUnvalidatedAnnotations { - return &DeprecatedUnvalidatedAnnotations{} -} - - -func (p *DeprecatedUnvalidatedAnnotations) GetItems() map[string]string { - return p.Items -} -type DeprecatedUnvalidatedAnnotationsBuilder struct { - obj *DeprecatedUnvalidatedAnnotations -} - -func NewDeprecatedUnvalidatedAnnotationsBuilder() *DeprecatedUnvalidatedAnnotationsBuilder{ - return &DeprecatedUnvalidatedAnnotationsBuilder{ - obj: NewDeprecatedUnvalidatedAnnotations(), - } -} - -func (p DeprecatedUnvalidatedAnnotationsBuilder) Emit() *DeprecatedUnvalidatedAnnotations{ - return &DeprecatedUnvalidatedAnnotations{ - Items: p.obj.Items, - } -} - -func (d *DeprecatedUnvalidatedAnnotationsBuilder) Items(items map[string]string) *DeprecatedUnvalidatedAnnotationsBuilder { - d.obj.Items = items - return d -} - -func (d *DeprecatedUnvalidatedAnnotations) SetItems(items map[string]string) *DeprecatedUnvalidatedAnnotations { - d.Items = items - return d -} - -func (p *DeprecatedUnvalidatedAnnotations) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *DeprecatedUnvalidatedAnnotations) ReadField1(iprot thrift.Protocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[string]string, size) - p.Items = tMap - for i := 0; i < size; i ++ { - var _key3 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key3 = v - } - var _val4 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _val4 = v - } - p.Items[_key3] = _val4 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *DeprecatedUnvalidatedAnnotations) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("DeprecatedUnvalidatedAnnotations"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *DeprecatedUnvalidatedAnnotations) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("items", thrift.MAP, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:items: ", p), err) } - if err := oprot.WriteMapBegin(thrift.STRING, thrift.STRING, len(p.Items)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.Items { - if err := oprot.WriteString(string(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := oprot.WriteString(string(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:items: ", p), err) } - return err -} - -func (p *DeprecatedUnvalidatedAnnotations) String() string { - if p == nil { - return "" - } - - itemsVal := fmt.Sprintf("%v", p.Items) - return fmt.Sprintf("DeprecatedUnvalidatedAnnotations({Items:%s})", itemsVal) -} - diff --git a/thrift/compiler/test/fixtures/patch/gen-go/thrift/lib/thrift/id/constants.go b/thrift/compiler/test/fixtures/patch/gen-go/thrift/lib/thrift/id/constants.go deleted file mode 100644 index 54ef7c47fec..00000000000 --- a/thrift/compiler/test/fixtures/patch/gen-go/thrift/lib/thrift/id/constants.go +++ /dev/null @@ -1,28 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package id - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var NoId ExternId - -func init() { -NoId = 0 - -} - diff --git a/thrift/compiler/test/fixtures/patch/gen-go/thrift/lib/thrift/id/ttypes.go b/thrift/compiler/test/fixtures/patch/gen-go/thrift/lib/thrift/id/ttypes.go deleted file mode 100644 index a98f08ff1ac..00000000000 --- a/thrift/compiler/test/fixtures/patch/gen-go/thrift/lib/thrift/id/ttypes.go +++ /dev/null @@ -1,56 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package id - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var GoUnusedProtection__ int; - -//A field id is a signed 16-bit integer. -type FieldId = int16 - -func FieldIdPtr(v FieldId) *FieldId { return &v } - -type ExternId = int64 - -func ExternIdPtr(v ExternId) *ExternId { return &v } - -type ValueId = ExternId - -func ValueIdPtr(v ValueId) *ValueId { return &v } - -type ProtocolId = ExternId - -func ProtocolIdPtr(v ProtocolId) *ProtocolId { return &v } - -type TypeId = ExternId - -func TypeIdPtr(v TypeId) *TypeId { return &v } - -type DefinitionId = ExternId - -func DefinitionIdPtr(v DefinitionId) *DefinitionId { return &v } - -type ProgramId = ExternId - -func ProgramIdPtr(v ProgramId) *ProgramId { return &v } - -type SourceId = ExternId - -func SourceIdPtr(v SourceId) *SourceId { return &v } - diff --git a/thrift/compiler/test/fixtures/patch/gen-go/thrift/lib/thrift/patch/constants.go b/thrift/compiler/test/fixtures/patch/gen-go/thrift/lib/thrift/patch/constants.go deleted file mode 100644 index 585cddc20a3..00000000000 --- a/thrift/compiler/test/fixtures/patch/gen-go/thrift/lib/thrift/patch/constants.go +++ /dev/null @@ -1,30 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package patch - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" - standard0 "thrift/lib/thrift/standard" - id1 "thrift/lib/thrift/id" - -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var _ = standard0.GoUnusedProtection__ -var _ = id1.GoUnusedProtection__ - -func init() { -} - diff --git a/thrift/compiler/test/fixtures/patch/gen-go/thrift/lib/thrift/patch/ttypes.go b/thrift/compiler/test/fixtures/patch/gen-go/thrift/lib/thrift/patch/ttypes.go deleted file mode 100644 index 2adc0c5b67f..00000000000 --- a/thrift/compiler/test/fixtures/patch/gen-go/thrift/lib/thrift/patch/ttypes.go +++ /dev/null @@ -1,2194 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package patch - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" - standard0 "thrift/lib/thrift/standard" - id1 "thrift/lib/thrift/id" - -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var _ = standard0.GoUnusedProtection__ -var _ = id1.GoUnusedProtection__ -var GoUnusedProtection__ int; - -type FieldId = id1.FieldId - -func FieldIdPtr(v FieldId) *FieldId { return &v } - -type FieldIdList = []int16 - -func FieldIdListPtr(v FieldIdList) *FieldIdList { return &v } - -// An annotation that indicates a patch representation should be generated for -// the associated definition. -type GeneratePatch struct { -} - -func NewGeneratePatch() *GeneratePatch { - return &GeneratePatch{} -} - -type GeneratePatchBuilder struct { - obj *GeneratePatch -} - -func NewGeneratePatchBuilder() *GeneratePatchBuilder{ - return &GeneratePatchBuilder{ - obj: NewGeneratePatch(), - } -} - -func (p GeneratePatchBuilder) Emit() *GeneratePatch{ - return &GeneratePatch{ - } -} - -func (p *GeneratePatch) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *GeneratePatch) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("GeneratePatch"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *GeneratePatch) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("GeneratePatch({})") -} - -type AssignOnlyPatch struct { -} - -func NewAssignOnlyPatch() *AssignOnlyPatch { - return &AssignOnlyPatch{} -} - -type AssignOnlyPatchBuilder struct { - obj *AssignOnlyPatch -} - -func NewAssignOnlyPatchBuilder() *AssignOnlyPatchBuilder{ - return &AssignOnlyPatchBuilder{ - obj: NewAssignOnlyPatch(), - } -} - -func (p AssignOnlyPatchBuilder) Emit() *AssignOnlyPatch{ - return &AssignOnlyPatch{ - } -} - -func (p *AssignOnlyPatch) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AssignOnlyPatch) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("AssignOnlyPatch"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *AssignOnlyPatch) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("AssignOnlyPatch({})") -} - -// A patch for a boolean value. -// -// Attributes: -// - Assign: Assigns to a (set) value. -// -// If set, all other patch operations are ignored. -// -// Note: Only modifies set field values. -// - Clear: Clear any set value. -// - Invert: If the bool value should be inverted. -type BoolPatch struct { - Assign *bool `thrift:"assign,1,optional" db:"assign" json:"assign,omitempty"` - Clear bool `thrift:"clear,2" db:"clear" json:"clear"` - // unused fields # 3 to 8 - Invert bool `thrift:"invert,9" db:"invert" json:"invert"` -} - -func NewBoolPatch() *BoolPatch { - return &BoolPatch{} -} - -var BoolPatch_Assign_DEFAULT bool -func (p *BoolPatch) GetAssign() bool { - if !p.IsSetAssign() { - return BoolPatch_Assign_DEFAULT - } - return *p.Assign -} - -func (p *BoolPatch) GetClear() bool { - return p.Clear -} - -func (p *BoolPatch) GetInvert() bool { - return p.Invert -} -func (p *BoolPatch) IsSetAssign() bool { - return p != nil && p.Assign != nil -} - -type BoolPatchBuilder struct { - obj *BoolPatch -} - -func NewBoolPatchBuilder() *BoolPatchBuilder{ - return &BoolPatchBuilder{ - obj: NewBoolPatch(), - } -} - -func (p BoolPatchBuilder) Emit() *BoolPatch{ - return &BoolPatch{ - Assign: p.obj.Assign, - Clear: p.obj.Clear, - Invert: p.obj.Invert, - } -} - -func (b *BoolPatchBuilder) Assign(assign *bool) *BoolPatchBuilder { - b.obj.Assign = assign - return b -} - -func (b *BoolPatchBuilder) Clear(clear bool) *BoolPatchBuilder { - b.obj.Clear = clear - return b -} - -func (b *BoolPatchBuilder) Invert(invert bool) *BoolPatchBuilder { - b.obj.Invert = invert - return b -} - -func (b *BoolPatch) SetAssign(assign *bool) *BoolPatch { - b.Assign = assign - return b -} - -func (b *BoolPatch) SetClear(clear bool) *BoolPatch { - b.Clear = clear - return b -} - -func (b *BoolPatch) SetInvert(invert bool) *BoolPatch { - b.Invert = invert - return b -} - -func (p *BoolPatch) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 9: - if err := p.ReadField9(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *BoolPatch) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Assign = &v - } - return nil -} - -func (p *BoolPatch) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Clear = v - } - return nil -} - -func (p *BoolPatch) ReadField9(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 9: ", err) - } else { - p.Invert = v - } - return nil -} - -func (p *BoolPatch) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("BoolPatch"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField9(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *BoolPatch) writeField1(oprot thrift.Protocol) (err error) { - if p.IsSetAssign() { - if err := oprot.WriteFieldBegin("assign", thrift.BOOL, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:assign: ", p), err) } - if err := oprot.WriteBool(bool(*p.Assign)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.assign (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:assign: ", p), err) } - } - return err -} - -func (p *BoolPatch) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("clear", thrift.BOOL, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:clear: ", p), err) } - if err := oprot.WriteBool(bool(p.Clear)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.clear (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:clear: ", p), err) } - return err -} - -func (p *BoolPatch) writeField9(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("invert", thrift.BOOL, 9); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 9:invert: ", p), err) } - if err := oprot.WriteBool(bool(p.Invert)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.invert (9) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 9:invert: ", p), err) } - return err -} - -func (p *BoolPatch) String() string { - if p == nil { - return "" - } - - var assignVal string - if p.Assign == nil { - assignVal = "" - } else { - assignVal = fmt.Sprintf("%v", *p.Assign) - } - clearVal := fmt.Sprintf("%v", p.Clear) - invertVal := fmt.Sprintf("%v", p.Invert) - return fmt.Sprintf("BoolPatch({Assign:%s Clear:%s Invert:%s})", assignVal, clearVal, invertVal) -} - -// A patch for an 8-bit integer value. -// -// Attributes: -// - Assign: Assigns to a (set) value. -// -// If set, all other patch operations are ignored. -// -// Note: Only modifies set field values. -// - Clear: Clear any set value. -// - Add: Add to a given value. -type BytePatch struct { - Assign *int8 `thrift:"assign,1,optional" db:"assign" json:"assign,omitempty"` - Clear bool `thrift:"clear,2" db:"clear" json:"clear"` - // unused fields # 3 to 7 - Add int8 `thrift:"add,8" db:"add" json:"add"` -} - -func NewBytePatch() *BytePatch { - return &BytePatch{} -} - -var BytePatch_Assign_DEFAULT int8 -func (p *BytePatch) GetAssign() int8 { - if !p.IsSetAssign() { - return BytePatch_Assign_DEFAULT - } - return *p.Assign -} - -func (p *BytePatch) GetClear() bool { - return p.Clear -} - -func (p *BytePatch) GetAdd() int8 { - return p.Add -} -func (p *BytePatch) IsSetAssign() bool { - return p != nil && p.Assign != nil -} - -type BytePatchBuilder struct { - obj *BytePatch -} - -func NewBytePatchBuilder() *BytePatchBuilder{ - return &BytePatchBuilder{ - obj: NewBytePatch(), - } -} - -func (p BytePatchBuilder) Emit() *BytePatch{ - return &BytePatch{ - Assign: p.obj.Assign, - Clear: p.obj.Clear, - Add: p.obj.Add, - } -} - -func (b *BytePatchBuilder) Assign(assign *int8) *BytePatchBuilder { - b.obj.Assign = assign - return b -} - -func (b *BytePatchBuilder) Clear(clear bool) *BytePatchBuilder { - b.obj.Clear = clear - return b -} - -func (b *BytePatchBuilder) Add(add int8) *BytePatchBuilder { - b.obj.Add = add - return b -} - -func (b *BytePatch) SetAssign(assign *int8) *BytePatch { - b.Assign = assign - return b -} - -func (b *BytePatch) SetClear(clear bool) *BytePatch { - b.Clear = clear - return b -} - -func (b *BytePatch) SetAdd(add int8) *BytePatch { - b.Add = add - return b -} - -func (p *BytePatch) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 8: - if err := p.ReadField8(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *BytePatch) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadByte(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - temp := int8(v) - p.Assign = &temp - } - return nil -} - -func (p *BytePatch) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Clear = v - } - return nil -} - -func (p *BytePatch) ReadField8(iprot thrift.Protocol) error { - if v, err := iprot.ReadByte(); err != nil { - return thrift.PrependError("error reading field 8: ", err) - } else { - temp := int8(v) - p.Add = temp - } - return nil -} - -func (p *BytePatch) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("BytePatch"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField8(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *BytePatch) writeField1(oprot thrift.Protocol) (err error) { - if p.IsSetAssign() { - if err := oprot.WriteFieldBegin("assign", thrift.BYTE, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:assign: ", p), err) } - if err := oprot.WriteByte(byte(*p.Assign)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.assign (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:assign: ", p), err) } - } - return err -} - -func (p *BytePatch) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("clear", thrift.BOOL, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:clear: ", p), err) } - if err := oprot.WriteBool(bool(p.Clear)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.clear (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:clear: ", p), err) } - return err -} - -func (p *BytePatch) writeField8(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("add", thrift.BYTE, 8); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 8:add: ", p), err) } - if err := oprot.WriteByte(byte(p.Add)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.add (8) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 8:add: ", p), err) } - return err -} - -func (p *BytePatch) String() string { - if p == nil { - return "" - } - - var assignVal string - if p.Assign == nil { - assignVal = "" - } else { - assignVal = fmt.Sprintf("%v", *p.Assign) - } - clearVal := fmt.Sprintf("%v", p.Clear) - addVal := fmt.Sprintf("%v", p.Add) - return fmt.Sprintf("BytePatch({Assign:%s Clear:%s Add:%s})", assignVal, clearVal, addVal) -} - -// A patch for a 16-bit integer value. -// -// Attributes: -// - Assign: Assigns to a (set) value. -// -// If set, all other patch operations are ignored. -// -// Note: Only modifies set field values. -// - Clear: Clear any set value. -// - Add: Add to a given value. -type I16Patch struct { - Assign *int16 `thrift:"assign,1,optional" db:"assign" json:"assign,omitempty"` - Clear bool `thrift:"clear,2" db:"clear" json:"clear"` - // unused fields # 3 to 7 - Add int16 `thrift:"add,8" db:"add" json:"add"` -} - -func NewI16Patch() *I16Patch { - return &I16Patch{} -} - -var I16Patch_Assign_DEFAULT int16 -func (p *I16Patch) GetAssign() int16 { - if !p.IsSetAssign() { - return I16Patch_Assign_DEFAULT - } - return *p.Assign -} - -func (p *I16Patch) GetClear() bool { - return p.Clear -} - -func (p *I16Patch) GetAdd() int16 { - return p.Add -} -func (p *I16Patch) IsSetAssign() bool { - return p != nil && p.Assign != nil -} - -type I16PatchBuilder struct { - obj *I16Patch -} - -func NewI16PatchBuilder() *I16PatchBuilder{ - return &I16PatchBuilder{ - obj: NewI16Patch(), - } -} - -func (p I16PatchBuilder) Emit() *I16Patch{ - return &I16Patch{ - Assign: p.obj.Assign, - Clear: p.obj.Clear, - Add: p.obj.Add, - } -} - -func (i *I16PatchBuilder) Assign(assign *int16) *I16PatchBuilder { - i.obj.Assign = assign - return i -} - -func (i *I16PatchBuilder) Clear(clear bool) *I16PatchBuilder { - i.obj.Clear = clear - return i -} - -func (i *I16PatchBuilder) Add(add int16) *I16PatchBuilder { - i.obj.Add = add - return i -} - -func (i *I16Patch) SetAssign(assign *int16) *I16Patch { - i.Assign = assign - return i -} - -func (i *I16Patch) SetClear(clear bool) *I16Patch { - i.Clear = clear - return i -} - -func (i *I16Patch) SetAdd(add int16) *I16Patch { - i.Add = add - return i -} - -func (p *I16Patch) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 8: - if err := p.ReadField8(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *I16Patch) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI16(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Assign = &v - } - return nil -} - -func (p *I16Patch) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Clear = v - } - return nil -} - -func (p *I16Patch) ReadField8(iprot thrift.Protocol) error { - if v, err := iprot.ReadI16(); err != nil { - return thrift.PrependError("error reading field 8: ", err) - } else { - p.Add = v - } - return nil -} - -func (p *I16Patch) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("I16Patch"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField8(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *I16Patch) writeField1(oprot thrift.Protocol) (err error) { - if p.IsSetAssign() { - if err := oprot.WriteFieldBegin("assign", thrift.I16, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:assign: ", p), err) } - if err := oprot.WriteI16(int16(*p.Assign)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.assign (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:assign: ", p), err) } - } - return err -} - -func (p *I16Patch) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("clear", thrift.BOOL, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:clear: ", p), err) } - if err := oprot.WriteBool(bool(p.Clear)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.clear (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:clear: ", p), err) } - return err -} - -func (p *I16Patch) writeField8(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("add", thrift.I16, 8); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 8:add: ", p), err) } - if err := oprot.WriteI16(int16(p.Add)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.add (8) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 8:add: ", p), err) } - return err -} - -func (p *I16Patch) String() string { - if p == nil { - return "" - } - - var assignVal string - if p.Assign == nil { - assignVal = "" - } else { - assignVal = fmt.Sprintf("%v", *p.Assign) - } - clearVal := fmt.Sprintf("%v", p.Clear) - addVal := fmt.Sprintf("%v", p.Add) - return fmt.Sprintf("I16Patch({Assign:%s Clear:%s Add:%s})", assignVal, clearVal, addVal) -} - -// A patch for a 32-bit integer value. -// -// Attributes: -// - Assign: Assigns to a (set) value. -// -// If set, all other patch operations are ignored. -// -// Note: Only modifies set field values. -// - Clear: Clears any set value. -// - Add: Add to a given value. -type I32Patch struct { - Assign *int32 `thrift:"assign,1,optional" db:"assign" json:"assign,omitempty"` - Clear bool `thrift:"clear,2" db:"clear" json:"clear"` - // unused fields # 3 to 7 - Add int32 `thrift:"add,8" db:"add" json:"add"` -} - -func NewI32Patch() *I32Patch { - return &I32Patch{} -} - -var I32Patch_Assign_DEFAULT int32 -func (p *I32Patch) GetAssign() int32 { - if !p.IsSetAssign() { - return I32Patch_Assign_DEFAULT - } - return *p.Assign -} - -func (p *I32Patch) GetClear() bool { - return p.Clear -} - -func (p *I32Patch) GetAdd() int32 { - return p.Add -} -func (p *I32Patch) IsSetAssign() bool { - return p != nil && p.Assign != nil -} - -type I32PatchBuilder struct { - obj *I32Patch -} - -func NewI32PatchBuilder() *I32PatchBuilder{ - return &I32PatchBuilder{ - obj: NewI32Patch(), - } -} - -func (p I32PatchBuilder) Emit() *I32Patch{ - return &I32Patch{ - Assign: p.obj.Assign, - Clear: p.obj.Clear, - Add: p.obj.Add, - } -} - -func (i *I32PatchBuilder) Assign(assign *int32) *I32PatchBuilder { - i.obj.Assign = assign - return i -} - -func (i *I32PatchBuilder) Clear(clear bool) *I32PatchBuilder { - i.obj.Clear = clear - return i -} - -func (i *I32PatchBuilder) Add(add int32) *I32PatchBuilder { - i.obj.Add = add - return i -} - -func (i *I32Patch) SetAssign(assign *int32) *I32Patch { - i.Assign = assign - return i -} - -func (i *I32Patch) SetClear(clear bool) *I32Patch { - i.Clear = clear - return i -} - -func (i *I32Patch) SetAdd(add int32) *I32Patch { - i.Add = add - return i -} - -func (p *I32Patch) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 8: - if err := p.ReadField8(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *I32Patch) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Assign = &v - } - return nil -} - -func (p *I32Patch) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Clear = v - } - return nil -} - -func (p *I32Patch) ReadField8(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 8: ", err) - } else { - p.Add = v - } - return nil -} - -func (p *I32Patch) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("I32Patch"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField8(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *I32Patch) writeField1(oprot thrift.Protocol) (err error) { - if p.IsSetAssign() { - if err := oprot.WriteFieldBegin("assign", thrift.I32, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:assign: ", p), err) } - if err := oprot.WriteI32(int32(*p.Assign)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.assign (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:assign: ", p), err) } - } - return err -} - -func (p *I32Patch) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("clear", thrift.BOOL, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:clear: ", p), err) } - if err := oprot.WriteBool(bool(p.Clear)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.clear (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:clear: ", p), err) } - return err -} - -func (p *I32Patch) writeField8(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("add", thrift.I32, 8); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 8:add: ", p), err) } - if err := oprot.WriteI32(int32(p.Add)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.add (8) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 8:add: ", p), err) } - return err -} - -func (p *I32Patch) String() string { - if p == nil { - return "" - } - - var assignVal string - if p.Assign == nil { - assignVal = "" - } else { - assignVal = fmt.Sprintf("%v", *p.Assign) - } - clearVal := fmt.Sprintf("%v", p.Clear) - addVal := fmt.Sprintf("%v", p.Add) - return fmt.Sprintf("I32Patch({Assign:%s Clear:%s Add:%s})", assignVal, clearVal, addVal) -} - -// A patch for a 64-bit integer value. -// -// Attributes: -// - Assign: Assigns to a (set) value. -// -// If set, all other patch operations are ignored. -// -// Note: Only modifies set field values. -// - Clear: Clear any set value. -// - Add: Add to a given value. -type I64Patch struct { - Assign *int64 `thrift:"assign,1,optional" db:"assign" json:"assign,omitempty"` - Clear bool `thrift:"clear,2" db:"clear" json:"clear"` - // unused fields # 3 to 7 - Add int64 `thrift:"add,8" db:"add" json:"add"` -} - -func NewI64Patch() *I64Patch { - return &I64Patch{} -} - -var I64Patch_Assign_DEFAULT int64 -func (p *I64Patch) GetAssign() int64 { - if !p.IsSetAssign() { - return I64Patch_Assign_DEFAULT - } - return *p.Assign -} - -func (p *I64Patch) GetClear() bool { - return p.Clear -} - -func (p *I64Patch) GetAdd() int64 { - return p.Add -} -func (p *I64Patch) IsSetAssign() bool { - return p != nil && p.Assign != nil -} - -type I64PatchBuilder struct { - obj *I64Patch -} - -func NewI64PatchBuilder() *I64PatchBuilder{ - return &I64PatchBuilder{ - obj: NewI64Patch(), - } -} - -func (p I64PatchBuilder) Emit() *I64Patch{ - return &I64Patch{ - Assign: p.obj.Assign, - Clear: p.obj.Clear, - Add: p.obj.Add, - } -} - -func (i *I64PatchBuilder) Assign(assign *int64) *I64PatchBuilder { - i.obj.Assign = assign - return i -} - -func (i *I64PatchBuilder) Clear(clear bool) *I64PatchBuilder { - i.obj.Clear = clear - return i -} - -func (i *I64PatchBuilder) Add(add int64) *I64PatchBuilder { - i.obj.Add = add - return i -} - -func (i *I64Patch) SetAssign(assign *int64) *I64Patch { - i.Assign = assign - return i -} - -func (i *I64Patch) SetClear(clear bool) *I64Patch { - i.Clear = clear - return i -} - -func (i *I64Patch) SetAdd(add int64) *I64Patch { - i.Add = add - return i -} - -func (p *I64Patch) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 8: - if err := p.ReadField8(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *I64Patch) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Assign = &v - } - return nil -} - -func (p *I64Patch) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Clear = v - } - return nil -} - -func (p *I64Patch) ReadField8(iprot thrift.Protocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 8: ", err) - } else { - p.Add = v - } - return nil -} - -func (p *I64Patch) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("I64Patch"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField8(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *I64Patch) writeField1(oprot thrift.Protocol) (err error) { - if p.IsSetAssign() { - if err := oprot.WriteFieldBegin("assign", thrift.I64, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:assign: ", p), err) } - if err := oprot.WriteI64(int64(*p.Assign)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.assign (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:assign: ", p), err) } - } - return err -} - -func (p *I64Patch) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("clear", thrift.BOOL, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:clear: ", p), err) } - if err := oprot.WriteBool(bool(p.Clear)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.clear (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:clear: ", p), err) } - return err -} - -func (p *I64Patch) writeField8(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("add", thrift.I64, 8); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 8:add: ", p), err) } - if err := oprot.WriteI64(int64(p.Add)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.add (8) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 8:add: ", p), err) } - return err -} - -func (p *I64Patch) String() string { - if p == nil { - return "" - } - - var assignVal string - if p.Assign == nil { - assignVal = "" - } else { - assignVal = fmt.Sprintf("%v", *p.Assign) - } - clearVal := fmt.Sprintf("%v", p.Clear) - addVal := fmt.Sprintf("%v", p.Add) - return fmt.Sprintf("I64Patch({Assign:%s Clear:%s Add:%s})", assignVal, clearVal, addVal) -} - -// A patch for a 32-bit floating point value. -// -// Attributes: -// - Assign: Assigns to a (set) value. -// -// If set, all other patch operations are ignored. -// -// Note: Only modifies set field values. -// - Clear: Clear any set value. -// - Add: Add to a given value. -type FloatPatch struct { - Assign *float32 `thrift:"assign,1,optional" db:"assign" json:"assign,omitempty"` - Clear bool `thrift:"clear,2" db:"clear" json:"clear"` - // unused fields # 3 to 7 - Add float32 `thrift:"add,8" db:"add" json:"add"` -} - -func NewFloatPatch() *FloatPatch { - return &FloatPatch{} -} - -var FloatPatch_Assign_DEFAULT float32 -func (p *FloatPatch) GetAssign() float32 { - if !p.IsSetAssign() { - return FloatPatch_Assign_DEFAULT - } - return *p.Assign -} - -func (p *FloatPatch) GetClear() bool { - return p.Clear -} - -func (p *FloatPatch) GetAdd() float32 { - return p.Add -} -func (p *FloatPatch) IsSetAssign() bool { - return p != nil && p.Assign != nil -} - -type FloatPatchBuilder struct { - obj *FloatPatch -} - -func NewFloatPatchBuilder() *FloatPatchBuilder{ - return &FloatPatchBuilder{ - obj: NewFloatPatch(), - } -} - -func (p FloatPatchBuilder) Emit() *FloatPatch{ - return &FloatPatch{ - Assign: p.obj.Assign, - Clear: p.obj.Clear, - Add: p.obj.Add, - } -} - -func (f *FloatPatchBuilder) Assign(assign *float32) *FloatPatchBuilder { - f.obj.Assign = assign - return f -} - -func (f *FloatPatchBuilder) Clear(clear bool) *FloatPatchBuilder { - f.obj.Clear = clear - return f -} - -func (f *FloatPatchBuilder) Add(add float32) *FloatPatchBuilder { - f.obj.Add = add - return f -} - -func (f *FloatPatch) SetAssign(assign *float32) *FloatPatch { - f.Assign = assign - return f -} - -func (f *FloatPatch) SetClear(clear bool) *FloatPatch { - f.Clear = clear - return f -} - -func (f *FloatPatch) SetAdd(add float32) *FloatPatch { - f.Add = add - return f -} - -func (p *FloatPatch) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 8: - if err := p.ReadField8(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *FloatPatch) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadFloat(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Assign = &v - } - return nil -} - -func (p *FloatPatch) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Clear = v - } - return nil -} - -func (p *FloatPatch) ReadField8(iprot thrift.Protocol) error { - if v, err := iprot.ReadFloat(); err != nil { - return thrift.PrependError("error reading field 8: ", err) - } else { - p.Add = v - } - return nil -} - -func (p *FloatPatch) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("FloatPatch"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField8(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *FloatPatch) writeField1(oprot thrift.Protocol) (err error) { - if p.IsSetAssign() { - if err := oprot.WriteFieldBegin("assign", thrift.FLOAT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:assign: ", p), err) } - if err := oprot.WriteFloat(float32(*p.Assign)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.assign (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:assign: ", p), err) } - } - return err -} - -func (p *FloatPatch) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("clear", thrift.BOOL, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:clear: ", p), err) } - if err := oprot.WriteBool(bool(p.Clear)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.clear (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:clear: ", p), err) } - return err -} - -func (p *FloatPatch) writeField8(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("add", thrift.FLOAT, 8); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 8:add: ", p), err) } - if err := oprot.WriteFloat(float32(p.Add)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.add (8) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 8:add: ", p), err) } - return err -} - -func (p *FloatPatch) String() string { - if p == nil { - return "" - } - - var assignVal string - if p.Assign == nil { - assignVal = "" - } else { - assignVal = fmt.Sprintf("%v", *p.Assign) - } - clearVal := fmt.Sprintf("%v", p.Clear) - addVal := fmt.Sprintf("%v", p.Add) - return fmt.Sprintf("FloatPatch({Assign:%s Clear:%s Add:%s})", assignVal, clearVal, addVal) -} - -// A patch for an 64-bit floating point value. -// -// Attributes: -// - Assign: Assigns to a (set) value. -// -// If set, all other patch operations are ignored. -// -// Note: Only modifies set field values. -// - Clear: Clear any set value. -// - Add: Add to a given value. -type DoublePatch struct { - Assign *float64 `thrift:"assign,1,optional" db:"assign" json:"assign,omitempty"` - Clear bool `thrift:"clear,2" db:"clear" json:"clear"` - // unused fields # 3 to 7 - Add float64 `thrift:"add,8" db:"add" json:"add"` -} - -func NewDoublePatch() *DoublePatch { - return &DoublePatch{} -} - -var DoublePatch_Assign_DEFAULT float64 -func (p *DoublePatch) GetAssign() float64 { - if !p.IsSetAssign() { - return DoublePatch_Assign_DEFAULT - } - return *p.Assign -} - -func (p *DoublePatch) GetClear() bool { - return p.Clear -} - -func (p *DoublePatch) GetAdd() float64 { - return p.Add -} -func (p *DoublePatch) IsSetAssign() bool { - return p != nil && p.Assign != nil -} - -type DoublePatchBuilder struct { - obj *DoublePatch -} - -func NewDoublePatchBuilder() *DoublePatchBuilder{ - return &DoublePatchBuilder{ - obj: NewDoublePatch(), - } -} - -func (p DoublePatchBuilder) Emit() *DoublePatch{ - return &DoublePatch{ - Assign: p.obj.Assign, - Clear: p.obj.Clear, - Add: p.obj.Add, - } -} - -func (d *DoublePatchBuilder) Assign(assign *float64) *DoublePatchBuilder { - d.obj.Assign = assign - return d -} - -func (d *DoublePatchBuilder) Clear(clear bool) *DoublePatchBuilder { - d.obj.Clear = clear - return d -} - -func (d *DoublePatchBuilder) Add(add float64) *DoublePatchBuilder { - d.obj.Add = add - return d -} - -func (d *DoublePatch) SetAssign(assign *float64) *DoublePatch { - d.Assign = assign - return d -} - -func (d *DoublePatch) SetClear(clear bool) *DoublePatch { - d.Clear = clear - return d -} - -func (d *DoublePatch) SetAdd(add float64) *DoublePatch { - d.Add = add - return d -} - -func (p *DoublePatch) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 8: - if err := p.ReadField8(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *DoublePatch) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadDouble(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Assign = &v - } - return nil -} - -func (p *DoublePatch) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Clear = v - } - return nil -} - -func (p *DoublePatch) ReadField8(iprot thrift.Protocol) error { - if v, err := iprot.ReadDouble(); err != nil { - return thrift.PrependError("error reading field 8: ", err) - } else { - p.Add = v - } - return nil -} - -func (p *DoublePatch) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("DoublePatch"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField8(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *DoublePatch) writeField1(oprot thrift.Protocol) (err error) { - if p.IsSetAssign() { - if err := oprot.WriteFieldBegin("assign", thrift.DOUBLE, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:assign: ", p), err) } - if err := oprot.WriteDouble(float64(*p.Assign)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.assign (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:assign: ", p), err) } - } - return err -} - -func (p *DoublePatch) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("clear", thrift.BOOL, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:clear: ", p), err) } - if err := oprot.WriteBool(bool(p.Clear)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.clear (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:clear: ", p), err) } - return err -} - -func (p *DoublePatch) writeField8(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("add", thrift.DOUBLE, 8); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 8:add: ", p), err) } - if err := oprot.WriteDouble(float64(p.Add)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.add (8) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 8:add: ", p), err) } - return err -} - -func (p *DoublePatch) String() string { - if p == nil { - return "" - } - - var assignVal string - if p.Assign == nil { - assignVal = "" - } else { - assignVal = fmt.Sprintf("%v", *p.Assign) - } - clearVal := fmt.Sprintf("%v", p.Clear) - addVal := fmt.Sprintf("%v", p.Add) - return fmt.Sprintf("DoublePatch({Assign:%s Clear:%s Add:%s})", assignVal, clearVal, addVal) -} - -// A patch for a string value. -// -// Attributes: -// - Assign: Assigns to a (set) value. -// -// If set, all other patch operations are ignored. -// -// Note: Only modifies set field values. -// - Clear: Clear a given string. -// - Prepend: Prepend to a given value. -// - Append: Append to a given value. -type StringPatch struct { - Assign *string `thrift:"assign,1,optional" db:"assign" json:"assign,omitempty"` - Clear bool `thrift:"clear,2" db:"clear" json:"clear"` - // unused fields # 3 to 7 - Prepend string `thrift:"prepend,8" db:"prepend" json:"prepend"` - Append string `thrift:"append,9" db:"append" json:"append"` -} - -func NewStringPatch() *StringPatch { - return &StringPatch{} -} - -var StringPatch_Assign_DEFAULT string -func (p *StringPatch) GetAssign() string { - if !p.IsSetAssign() { - return StringPatch_Assign_DEFAULT - } - return *p.Assign -} - -func (p *StringPatch) GetClear() bool { - return p.Clear -} - -func (p *StringPatch) GetPrepend() string { - return p.Prepend -} - -func (p *StringPatch) GetAppend() string { - return p.Append -} -func (p *StringPatch) IsSetAssign() bool { - return p != nil && p.Assign != nil -} - -type StringPatchBuilder struct { - obj *StringPatch -} - -func NewStringPatchBuilder() *StringPatchBuilder{ - return &StringPatchBuilder{ - obj: NewStringPatch(), - } -} - -func (p StringPatchBuilder) Emit() *StringPatch{ - return &StringPatch{ - Assign: p.obj.Assign, - Clear: p.obj.Clear, - Prepend: p.obj.Prepend, - Append: p.obj.Append, - } -} - -func (s *StringPatchBuilder) Assign(assign *string) *StringPatchBuilder { - s.obj.Assign = assign - return s -} - -func (s *StringPatchBuilder) Clear(clear bool) *StringPatchBuilder { - s.obj.Clear = clear - return s -} - -func (s *StringPatchBuilder) Prepend(prepend string) *StringPatchBuilder { - s.obj.Prepend = prepend - return s -} - -func (s *StringPatchBuilder) Append(append string) *StringPatchBuilder { - s.obj.Append = append - return s -} - -func (s *StringPatch) SetAssign(assign *string) *StringPatch { - s.Assign = assign - return s -} - -func (s *StringPatch) SetClear(clear bool) *StringPatch { - s.Clear = clear - return s -} - -func (s *StringPatch) SetPrepend(prepend string) *StringPatch { - s.Prepend = prepend - return s -} - -func (s *StringPatch) SetAppend(append string) *StringPatch { - s.Append = append - return s -} - -func (p *StringPatch) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 8: - if err := p.ReadField8(iprot); err != nil { - return err - } - case 9: - if err := p.ReadField9(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *StringPatch) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Assign = &v - } - return nil -} - -func (p *StringPatch) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Clear = v - } - return nil -} - -func (p *StringPatch) ReadField8(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 8: ", err) - } else { - p.Prepend = v - } - return nil -} - -func (p *StringPatch) ReadField9(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 9: ", err) - } else { - p.Append = v - } - return nil -} - -func (p *StringPatch) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("StringPatch"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField8(oprot); err != nil { return err } - if err := p.writeField9(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *StringPatch) writeField1(oprot thrift.Protocol) (err error) { - if p.IsSetAssign() { - if err := oprot.WriteFieldBegin("assign", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:assign: ", p), err) } - if err := oprot.WriteString(string(*p.Assign)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.assign (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:assign: ", p), err) } - } - return err -} - -func (p *StringPatch) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("clear", thrift.BOOL, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:clear: ", p), err) } - if err := oprot.WriteBool(bool(p.Clear)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.clear (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:clear: ", p), err) } - return err -} - -func (p *StringPatch) writeField8(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("prepend", thrift.STRING, 8); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 8:prepend: ", p), err) } - if err := oprot.WriteString(string(p.Prepend)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.prepend (8) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 8:prepend: ", p), err) } - return err -} - -func (p *StringPatch) writeField9(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("append", thrift.STRING, 9); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 9:append: ", p), err) } - if err := oprot.WriteString(string(p.Append)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.append (9) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 9:append: ", p), err) } - return err -} - -func (p *StringPatch) String() string { - if p == nil { - return "" - } - - var assignVal string - if p.Assign == nil { - assignVal = "" - } else { - assignVal = fmt.Sprintf("%v", *p.Assign) - } - clearVal := fmt.Sprintf("%v", p.Clear) - prependVal := fmt.Sprintf("%v", p.Prepend) - appendVal := fmt.Sprintf("%v", p.Append) - return fmt.Sprintf("StringPatch({Assign:%s Clear:%s Prepend:%s Append:%s})", assignVal, clearVal, prependVal, appendVal) -} - -// A patch for a binary value. -// -// Attributes: -// - Assign: Assigns to a (set) value. -// -// If set, all other patch operations are ignored. -// -// Note: Only modifies set field values. -// - Clear: Clear a given binary. -// - Prepend: Prepend to a given value. -// - Append: Append to a given value. -type BinaryPatch struct { - Assign standard0.ByteBuffer `thrift:"assign,1,optional" db:"assign" json:"assign,omitempty"` - Clear bool `thrift:"clear,2" db:"clear" json:"clear"` - // unused fields # 3 to 7 - Prepend standard0.ByteBuffer `thrift:"prepend,8" db:"prepend" json:"prepend"` - Append standard0.ByteBuffer `thrift:"append,9" db:"append" json:"append"` -} - -func NewBinaryPatch() *BinaryPatch { - return &BinaryPatch{} -} - -var BinaryPatch_Assign_DEFAULT standard0.ByteBuffer - -func (p *BinaryPatch) GetAssign() standard0.ByteBuffer { - return p.Assign -} - -func (p *BinaryPatch) GetClear() bool { - return p.Clear -} - -func (p *BinaryPatch) GetPrepend() standard0.ByteBuffer { - return p.Prepend -} - -func (p *BinaryPatch) GetAppend() standard0.ByteBuffer { - return p.Append -} -func (p *BinaryPatch) IsSetAssign() bool { - return p != nil && p.Assign != nil -} - -type BinaryPatchBuilder struct { - obj *BinaryPatch -} - -func NewBinaryPatchBuilder() *BinaryPatchBuilder{ - return &BinaryPatchBuilder{ - obj: NewBinaryPatch(), - } -} - -func (p BinaryPatchBuilder) Emit() *BinaryPatch{ - return &BinaryPatch{ - Assign: p.obj.Assign, - Clear: p.obj.Clear, - Prepend: p.obj.Prepend, - Append: p.obj.Append, - } -} - -func (b *BinaryPatchBuilder) Assign(assign standard0.ByteBuffer) *BinaryPatchBuilder { - b.obj.Assign = assign - return b -} - -func (b *BinaryPatchBuilder) Clear(clear bool) *BinaryPatchBuilder { - b.obj.Clear = clear - return b -} - -func (b *BinaryPatchBuilder) Prepend(prepend standard0.ByteBuffer) *BinaryPatchBuilder { - b.obj.Prepend = prepend - return b -} - -func (b *BinaryPatchBuilder) Append(append standard0.ByteBuffer) *BinaryPatchBuilder { - b.obj.Append = append - return b -} - -func (b *BinaryPatch) SetAssign(assign standard0.ByteBuffer) *BinaryPatch { - b.Assign = assign - return b -} - -func (b *BinaryPatch) SetClear(clear bool) *BinaryPatch { - b.Clear = clear - return b -} - -func (b *BinaryPatch) SetPrepend(prepend standard0.ByteBuffer) *BinaryPatch { - b.Prepend = prepend - return b -} - -func (b *BinaryPatch) SetAppend(append standard0.ByteBuffer) *BinaryPatch { - b.Append = append - return b -} - -func (p *BinaryPatch) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 8: - if err := p.ReadField8(iprot); err != nil { - return err - } - case 9: - if err := p.ReadField9(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *BinaryPatch) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadBinary(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - temp := standard0.ByteBuffer(v) - p.Assign = temp - } - return nil -} - -func (p *BinaryPatch) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Clear = v - } - return nil -} - -func (p *BinaryPatch) ReadField8(iprot thrift.Protocol) error { - if v, err := iprot.ReadBinary(); err != nil { - return thrift.PrependError("error reading field 8: ", err) - } else { - temp := standard0.ByteBuffer(v) - p.Prepend = temp - } - return nil -} - -func (p *BinaryPatch) ReadField9(iprot thrift.Protocol) error { - if v, err := iprot.ReadBinary(); err != nil { - return thrift.PrependError("error reading field 9: ", err) - } else { - temp := standard0.ByteBuffer(v) - p.Append = temp - } - return nil -} - -func (p *BinaryPatch) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("BinaryPatch"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField8(oprot); err != nil { return err } - if err := p.writeField9(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *BinaryPatch) writeField1(oprot thrift.Protocol) (err error) { - if p.IsSetAssign() { - if err := oprot.WriteFieldBegin("assign", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:assign: ", p), err) } - if err := oprot.WriteBinary(p.Assign); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.assign (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:assign: ", p), err) } - } - return err -} - -func (p *BinaryPatch) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("clear", thrift.BOOL, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:clear: ", p), err) } - if err := oprot.WriteBool(bool(p.Clear)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.clear (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:clear: ", p), err) } - return err -} - -func (p *BinaryPatch) writeField8(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("prepend", thrift.STRING, 8); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 8:prepend: ", p), err) } - if err := oprot.WriteBinary(p.Prepend); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.prepend (8) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 8:prepend: ", p), err) } - return err -} - -func (p *BinaryPatch) writeField9(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("append", thrift.STRING, 9); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 9:append: ", p), err) } - if err := oprot.WriteBinary(p.Append); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.append (9) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 9:append: ", p), err) } - return err -} - -func (p *BinaryPatch) String() string { - if p == nil { - return "" - } - - assignVal := fmt.Sprintf("%v", p.Assign) - clearVal := fmt.Sprintf("%v", p.Clear) - prependVal := fmt.Sprintf("%v", p.Prepend) - appendVal := fmt.Sprintf("%v", p.Append) - return fmt.Sprintf("BinaryPatch({Assign:%s Clear:%s Prepend:%s Append:%s})", assignVal, clearVal, prependVal, appendVal) -} - diff --git a/thrift/compiler/test/fixtures/patch/gen-go/thrift/lib/thrift/standard/constants.go b/thrift/compiler/test/fixtures/patch/gen-go/thrift/lib/thrift/standard/constants.go deleted file mode 100644 index 847f7f5f41f..00000000000 --- a/thrift/compiler/test/fixtures/patch/gen-go/thrift/lib/thrift/standard/constants.go +++ /dev/null @@ -1,25 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package standard - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - - -func init() { -} - diff --git a/thrift/compiler/test/fixtures/patch/gen-go/thrift/lib/thrift/standard/ttypes.go b/thrift/compiler/test/fixtures/patch/gen-go/thrift/lib/thrift/standard/ttypes.go deleted file mode 100644 index 85d87432ccf..00000000000 --- a/thrift/compiler/test/fixtures/patch/gen-go/thrift/lib/thrift/standard/ttypes.go +++ /dev/null @@ -1,1522 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package standard - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var GoUnusedProtection__ int; - -type Void int64 -const ( - Void_Unused Void = 0 -) - -var VoidToName = map[Void]string { - Void_Unused: "Unused", -} - -var VoidToValue = map[string]Void { - "Unused": Void_Unused, -} - -var VoidNames = []string { - "Unused", -} - -var VoidValues = []Void { - Void_Unused, -} - -func (p Void) String() string { - if v, ok := VoidToName[p]; ok { - return v - } - return "" -} - -func VoidFromString(s string) (Void, error) { - if v, ok := VoidToValue[s]; ok { - return v, nil - } - return Void(0), fmt.Errorf("not a valid Void string") -} - -func VoidPtr(v Void) *Void { return &v } - -//The standard Thrift protocols. -type StandardProtocol int64 -const ( - StandardProtocol_Custom StandardProtocol = 0 - StandardProtocol_Binary StandardProtocol = 1 - StandardProtocol_Compact StandardProtocol = 2 - StandardProtocol_Json StandardProtocol = 3 - StandardProtocol_SimpleJson StandardProtocol = 4 -) - -var StandardProtocolToName = map[StandardProtocol]string { - StandardProtocol_Custom: "Custom", - StandardProtocol_Binary: "Binary", - StandardProtocol_Compact: "Compact", - StandardProtocol_Json: "Json", - StandardProtocol_SimpleJson: "SimpleJson", -} - -var StandardProtocolToValue = map[string]StandardProtocol { - "Custom": StandardProtocol_Custom, - "Binary": StandardProtocol_Binary, - "Compact": StandardProtocol_Compact, - "Json": StandardProtocol_Json, - "SimpleJson": StandardProtocol_SimpleJson, -} - -var StandardProtocolNames = []string { - "Custom", - "Binary", - "Compact", - "Json", - "SimpleJson", -} - -var StandardProtocolValues = []StandardProtocol { - StandardProtocol_Custom, - StandardProtocol_Binary, - StandardProtocol_Compact, - StandardProtocol_Json, - StandardProtocol_SimpleJson, -} - -func (p StandardProtocol) String() string { - if v, ok := StandardProtocolToName[p]; ok { - return v - } - return "" -} - -func StandardProtocolFromString(s string) (StandardProtocol, error) { - if v, ok := StandardProtocolToValue[s]; ok { - return v, nil - } - return StandardProtocol(0), fmt.Errorf("not a valid StandardProtocol string") -} - -func StandardProtocolPtr(v StandardProtocol) *StandardProtocol { return &v } - -//Typedef for binary data which can be represented as a string of 8-bit bytes. -// -//Each language can map this type into a customized memory efficient object. -type ByteString = []byte - -func ByteStringPtr(v ByteString) *ByteString { return &v } - -//Typedef for binary data. -// -//Each language can map this type into a customized memory efficient object. -//May be used for zero-copy slice of data. -type ByteBuffer = []byte - -func ByteBufferPtr(v ByteBuffer) *ByteBuffer { return &v } - -//A (scheme-less) URI. -// -//Of the form described in RFC 3986, but with every component optional. -// -//See rfc3986 -type Uri = string - -func UriPtr(v Uri) *Uri { return &v } - -// The uri of an IDL defined type. -// -// Attributes: -// - Uri: The unique Thrift URI for this type. -// - TypeHashPrefixSha2_256: A prefix of the SHA2-256 hash of the URI. -// - ScopedName: The (potentially not unique) scoped name of this type. -// Format is `filename.typename`, e.g. `standard.TypeUri`. -// This is a fallback for types that do not have URIs yet. -// Must be prepared for the active field to switch to `uri` as package statements are rolled out! -type TypeUri struct { - Uri *Uri `thrift:"uri,1,optional" db:"uri" json:"uri,omitempty"` - TypeHashPrefixSha2_256 ByteString `thrift:"typeHashPrefixSha2_256,2,optional" db:"typeHashPrefixSha2_256" json:"typeHashPrefixSha2_256,omitempty"` - ScopedName *string `thrift:"scopedName,3,optional" db:"scopedName" json:"scopedName,omitempty"` -} - -func NewTypeUri() *TypeUri { - return &TypeUri{} -} - -var TypeUri_Uri_DEFAULT Uri -func (p *TypeUri) GetUri() Uri { - if !p.IsSetUri() { - return TypeUri_Uri_DEFAULT - } - return *p.Uri -} -var TypeUri_TypeHashPrefixSha2_256_DEFAULT ByteString - -func (p *TypeUri) GetTypeHashPrefixSha2_256() ByteString { - return p.TypeHashPrefixSha2_256 -} -var TypeUri_ScopedName_DEFAULT string -func (p *TypeUri) GetScopedName() string { - if !p.IsSetScopedName() { - return TypeUri_ScopedName_DEFAULT - } - return *p.ScopedName -} -func (p *TypeUri) CountSetFieldsTypeUri() int { - count := 0 - if (p.IsSetUri()) { - count++ - } - if (p.IsSetTypeHashPrefixSha2_256()) { - count++ - } - if (p.IsSetScopedName()) { - count++ - } - return count - -} - -func (p *TypeUri) IsSetUri() bool { - return p != nil && p.Uri != nil -} - -func (p *TypeUri) IsSetTypeHashPrefixSha2_256() bool { - return p != nil && p.TypeHashPrefixSha2_256 != nil -} - -func (p *TypeUri) IsSetScopedName() bool { - return p != nil && p.ScopedName != nil -} - -type TypeUriBuilder struct { - obj *TypeUri -} - -func NewTypeUriBuilder() *TypeUriBuilder{ - return &TypeUriBuilder{ - obj: NewTypeUri(), - } -} - -func (p TypeUriBuilder) Emit() *TypeUri{ - return &TypeUri{ - Uri: p.obj.Uri, - TypeHashPrefixSha2_256: p.obj.TypeHashPrefixSha2_256, - ScopedName: p.obj.ScopedName, - } -} - -func (t *TypeUriBuilder) Uri(uri *Uri) *TypeUriBuilder { - t.obj.Uri = uri - return t -} - -func (t *TypeUriBuilder) TypeHashPrefixSha2_256(typeHashPrefixSha2_256 ByteString) *TypeUriBuilder { - t.obj.TypeHashPrefixSha2_256 = typeHashPrefixSha2_256 - return t -} - -func (t *TypeUriBuilder) ScopedName(scopedName *string) *TypeUriBuilder { - t.obj.ScopedName = scopedName - return t -} - -func (t *TypeUri) SetUri(uri *Uri) *TypeUri { - t.Uri = uri - return t -} - -func (t *TypeUri) SetTypeHashPrefixSha2_256(typeHashPrefixSha2_256 ByteString) *TypeUri { - t.TypeHashPrefixSha2_256 = typeHashPrefixSha2_256 - return t -} - -func (t *TypeUri) SetScopedName(scopedName *string) *TypeUri { - t.ScopedName = scopedName - return t -} - -func (p *TypeUri) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 3: - if err := p.ReadField3(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *TypeUri) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - temp := Uri(v) - p.Uri = &temp - } - return nil -} - -func (p *TypeUri) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadBinary(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - temp := ByteString(v) - p.TypeHashPrefixSha2_256 = temp - } - return nil -} - -func (p *TypeUri) ReadField3(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 3: ", err) - } else { - p.ScopedName = &v - } - return nil -} - -func (p *TypeUri) Write(oprot thrift.Protocol) error { - if c := p.CountSetFieldsTypeUri(); c > 1 { - return fmt.Errorf("%T write union: no more than one field must be set (%d set).", p, c) - } - if err := oprot.WriteStructBegin("TypeUri"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *TypeUri) writeField1(oprot thrift.Protocol) (err error) { - if p.IsSetUri() { - if err := oprot.WriteFieldBegin("uri", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:uri: ", p), err) } - if err := oprot.WriteString(string(*p.Uri)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.uri (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:uri: ", p), err) } - } - return err -} - -func (p *TypeUri) writeField2(oprot thrift.Protocol) (err error) { - if p.IsSetTypeHashPrefixSha2_256() { - if err := oprot.WriteFieldBegin("typeHashPrefixSha2_256", thrift.STRING, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:typeHashPrefixSha2_256: ", p), err) } - if err := oprot.WriteBinary(p.TypeHashPrefixSha2_256); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.typeHashPrefixSha2_256 (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:typeHashPrefixSha2_256: ", p), err) } - } - return err -} - -func (p *TypeUri) writeField3(oprot thrift.Protocol) (err error) { - if p.IsSetScopedName() { - if err := oprot.WriteFieldBegin("scopedName", thrift.STRING, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:scopedName: ", p), err) } - if err := oprot.WriteString(string(*p.ScopedName)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.scopedName (3) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:scopedName: ", p), err) } - } - return err -} - -func (p *TypeUri) String() string { - if p == nil { - return "" - } - - var uriVal string - if p.Uri == nil { - uriVal = "" - } else { - uriVal = fmt.Sprintf("%v", *p.Uri) - } - typeHashPrefixSha2_256Val := fmt.Sprintf("%v", p.TypeHashPrefixSha2_256) - var scopedNameVal string - if p.ScopedName == nil { - scopedNameVal = "" - } else { - scopedNameVal = fmt.Sprintf("%v", *p.ScopedName) - } - return fmt.Sprintf("TypeUri({Uri:%s TypeHashPrefixSha2_256:%s ScopedName:%s})", uriVal, typeHashPrefixSha2_256Val, scopedNameVal) -} - -// Uniquely identifies a Thrift type. -// -// Attributes: -// - BoolType: True(1) or False(0) -// - ByteType: 8-bit signed integer -// - I16Type: 16-bit signed integer -// - I32Type: 32-bit signed integer -// - I64Type: 64-bit signed integer -// - FloatType: 32-bit floating point -// - DoubleType: 64-bit floating point -// - StringType: UTF-8 encoded string -// - BinaryType: Arbitrary byte string -// - EnumType: 32-bit signed integer, with named values. -// - TypedefType: `typedef` definition -// - StructType: `struct` definition -// - UnionType: `union` definition -// - ExceptionType: `exception` definition -// - ListType: `list` definition -// - SetType: `set` definition -// - MapType: `map` definition -type TypeName struct { - BoolType *Void `thrift:"boolType,1,optional" db:"boolType" json:"boolType,omitempty"` - ByteType *Void `thrift:"byteType,2,optional" db:"byteType" json:"byteType,omitempty"` - I16Type *Void `thrift:"i16Type,3,optional" db:"i16Type" json:"i16Type,omitempty"` - I32Type *Void `thrift:"i32Type,4,optional" db:"i32Type" json:"i32Type,omitempty"` - I64Type *Void `thrift:"i64Type,5,optional" db:"i64Type" json:"i64Type,omitempty"` - FloatType *Void `thrift:"floatType,6,optional" db:"floatType" json:"floatType,omitempty"` - DoubleType *Void `thrift:"doubleType,7,optional" db:"doubleType" json:"doubleType,omitempty"` - StringType *Void `thrift:"stringType,8,optional" db:"stringType" json:"stringType,omitempty"` - BinaryType *Void `thrift:"binaryType,9,optional" db:"binaryType" json:"binaryType,omitempty"` - EnumType *TypeUri `thrift:"enumType,10,optional" db:"enumType" json:"enumType,omitempty"` - StructType *TypeUri `thrift:"structType,11,optional" db:"structType" json:"structType,omitempty"` - UnionType *TypeUri `thrift:"unionType,12,optional" db:"unionType" json:"unionType,omitempty"` - ExceptionType *TypeUri `thrift:"exceptionType,13,optional" db:"exceptionType" json:"exceptionType,omitempty"` - ListType *Void `thrift:"listType,14,optional" db:"listType" json:"listType,omitempty"` - SetType *Void `thrift:"setType,15,optional" db:"setType" json:"setType,omitempty"` - MapType *Void `thrift:"mapType,16,optional" db:"mapType" json:"mapType,omitempty"` - TypedefType *TypeUri `thrift:"typedefType,17,optional" db:"typedefType" json:"typedefType,omitempty"` -} - -func NewTypeName() *TypeName { - return &TypeName{} -} - -var TypeName_BoolType_DEFAULT Void -func (p *TypeName) GetBoolType() Void { - if !p.IsSetBoolType() { - return TypeName_BoolType_DEFAULT - } - return *p.BoolType -} -var TypeName_ByteType_DEFAULT Void -func (p *TypeName) GetByteType() Void { - if !p.IsSetByteType() { - return TypeName_ByteType_DEFAULT - } - return *p.ByteType -} -var TypeName_I16Type_DEFAULT Void -func (p *TypeName) GetI16Type() Void { - if !p.IsSetI16Type() { - return TypeName_I16Type_DEFAULT - } - return *p.I16Type -} -var TypeName_I32Type_DEFAULT Void -func (p *TypeName) GetI32Type() Void { - if !p.IsSetI32Type() { - return TypeName_I32Type_DEFAULT - } - return *p.I32Type -} -var TypeName_I64Type_DEFAULT Void -func (p *TypeName) GetI64Type() Void { - if !p.IsSetI64Type() { - return TypeName_I64Type_DEFAULT - } - return *p.I64Type -} -var TypeName_FloatType_DEFAULT Void -func (p *TypeName) GetFloatType() Void { - if !p.IsSetFloatType() { - return TypeName_FloatType_DEFAULT - } - return *p.FloatType -} -var TypeName_DoubleType_DEFAULT Void -func (p *TypeName) GetDoubleType() Void { - if !p.IsSetDoubleType() { - return TypeName_DoubleType_DEFAULT - } - return *p.DoubleType -} -var TypeName_StringType_DEFAULT Void -func (p *TypeName) GetStringType() Void { - if !p.IsSetStringType() { - return TypeName_StringType_DEFAULT - } - return *p.StringType -} -var TypeName_BinaryType_DEFAULT Void -func (p *TypeName) GetBinaryType() Void { - if !p.IsSetBinaryType() { - return TypeName_BinaryType_DEFAULT - } - return *p.BinaryType -} -var TypeName_EnumType_DEFAULT *TypeUri -func (p *TypeName) GetEnumType() *TypeUri { - if !p.IsSetEnumType() { - return TypeName_EnumType_DEFAULT - } - return p.EnumType -} -func (p *TypeName) DefaultGetEnumType() *TypeUri { - if !p.IsSetEnumType() { - return NewTypeUri() - } - return p.EnumType -} -var TypeName_TypedefType_DEFAULT *TypeUri -func (p *TypeName) GetTypedefType() *TypeUri { - if !p.IsSetTypedefType() { - return TypeName_TypedefType_DEFAULT - } - return p.TypedefType -} -func (p *TypeName) DefaultGetTypedefType() *TypeUri { - if !p.IsSetTypedefType() { - return NewTypeUri() - } - return p.TypedefType -} -var TypeName_StructType_DEFAULT *TypeUri -func (p *TypeName) GetStructType() *TypeUri { - if !p.IsSetStructType() { - return TypeName_StructType_DEFAULT - } - return p.StructType -} -func (p *TypeName) DefaultGetStructType() *TypeUri { - if !p.IsSetStructType() { - return NewTypeUri() - } - return p.StructType -} -var TypeName_UnionType_DEFAULT *TypeUri -func (p *TypeName) GetUnionType() *TypeUri { - if !p.IsSetUnionType() { - return TypeName_UnionType_DEFAULT - } - return p.UnionType -} -func (p *TypeName) DefaultGetUnionType() *TypeUri { - if !p.IsSetUnionType() { - return NewTypeUri() - } - return p.UnionType -} -var TypeName_ExceptionType_DEFAULT *TypeUri -func (p *TypeName) GetExceptionType() *TypeUri { - if !p.IsSetExceptionType() { - return TypeName_ExceptionType_DEFAULT - } - return p.ExceptionType -} -func (p *TypeName) DefaultGetExceptionType() *TypeUri { - if !p.IsSetExceptionType() { - return NewTypeUri() - } - return p.ExceptionType -} -var TypeName_ListType_DEFAULT Void -func (p *TypeName) GetListType() Void { - if !p.IsSetListType() { - return TypeName_ListType_DEFAULT - } - return *p.ListType -} -var TypeName_SetType_DEFAULT Void -func (p *TypeName) GetSetType() Void { - if !p.IsSetSetType() { - return TypeName_SetType_DEFAULT - } - return *p.SetType -} -var TypeName_MapType_DEFAULT Void -func (p *TypeName) GetMapType() Void { - if !p.IsSetMapType() { - return TypeName_MapType_DEFAULT - } - return *p.MapType -} -func (p *TypeName) CountSetFieldsTypeName() int { - count := 0 - if (p.IsSetBoolType()) { - count++ - } - if (p.IsSetByteType()) { - count++ - } - if (p.IsSetI16Type()) { - count++ - } - if (p.IsSetI32Type()) { - count++ - } - if (p.IsSetI64Type()) { - count++ - } - if (p.IsSetFloatType()) { - count++ - } - if (p.IsSetDoubleType()) { - count++ - } - if (p.IsSetStringType()) { - count++ - } - if (p.IsSetBinaryType()) { - count++ - } - if (p.IsSetEnumType()) { - count++ - } - if (p.IsSetTypedefType()) { - count++ - } - if (p.IsSetStructType()) { - count++ - } - if (p.IsSetUnionType()) { - count++ - } - if (p.IsSetExceptionType()) { - count++ - } - if (p.IsSetListType()) { - count++ - } - if (p.IsSetSetType()) { - count++ - } - if (p.IsSetMapType()) { - count++ - } - return count - -} - -func (p *TypeName) IsSetBoolType() bool { - return p != nil && p.BoolType != nil -} - -func (p *TypeName) IsSetByteType() bool { - return p != nil && p.ByteType != nil -} - -func (p *TypeName) IsSetI16Type() bool { - return p != nil && p.I16Type != nil -} - -func (p *TypeName) IsSetI32Type() bool { - return p != nil && p.I32Type != nil -} - -func (p *TypeName) IsSetI64Type() bool { - return p != nil && p.I64Type != nil -} - -func (p *TypeName) IsSetFloatType() bool { - return p != nil && p.FloatType != nil -} - -func (p *TypeName) IsSetDoubleType() bool { - return p != nil && p.DoubleType != nil -} - -func (p *TypeName) IsSetStringType() bool { - return p != nil && p.StringType != nil -} - -func (p *TypeName) IsSetBinaryType() bool { - return p != nil && p.BinaryType != nil -} - -func (p *TypeName) IsSetEnumType() bool { - return p != nil && p.EnumType != nil -} - -func (p *TypeName) IsSetTypedefType() bool { - return p != nil && p.TypedefType != nil -} - -func (p *TypeName) IsSetStructType() bool { - return p != nil && p.StructType != nil -} - -func (p *TypeName) IsSetUnionType() bool { - return p != nil && p.UnionType != nil -} - -func (p *TypeName) IsSetExceptionType() bool { - return p != nil && p.ExceptionType != nil -} - -func (p *TypeName) IsSetListType() bool { - return p != nil && p.ListType != nil -} - -func (p *TypeName) IsSetSetType() bool { - return p != nil && p.SetType != nil -} - -func (p *TypeName) IsSetMapType() bool { - return p != nil && p.MapType != nil -} - -type TypeNameBuilder struct { - obj *TypeName -} - -func NewTypeNameBuilder() *TypeNameBuilder{ - return &TypeNameBuilder{ - obj: NewTypeName(), - } -} - -func (p TypeNameBuilder) Emit() *TypeName{ - return &TypeName{ - BoolType: p.obj.BoolType, - ByteType: p.obj.ByteType, - I16Type: p.obj.I16Type, - I32Type: p.obj.I32Type, - I64Type: p.obj.I64Type, - FloatType: p.obj.FloatType, - DoubleType: p.obj.DoubleType, - StringType: p.obj.StringType, - BinaryType: p.obj.BinaryType, - EnumType: p.obj.EnumType, - TypedefType: p.obj.TypedefType, - StructType: p.obj.StructType, - UnionType: p.obj.UnionType, - ExceptionType: p.obj.ExceptionType, - ListType: p.obj.ListType, - SetType: p.obj.SetType, - MapType: p.obj.MapType, - } -} - -func (t *TypeNameBuilder) BoolType(boolType *Void) *TypeNameBuilder { - t.obj.BoolType = boolType - return t -} - -func (t *TypeNameBuilder) ByteType(byteType *Void) *TypeNameBuilder { - t.obj.ByteType = byteType - return t -} - -func (t *TypeNameBuilder) I16Type(i16Type *Void) *TypeNameBuilder { - t.obj.I16Type = i16Type - return t -} - -func (t *TypeNameBuilder) I32Type(i32Type *Void) *TypeNameBuilder { - t.obj.I32Type = i32Type - return t -} - -func (t *TypeNameBuilder) I64Type(i64Type *Void) *TypeNameBuilder { - t.obj.I64Type = i64Type - return t -} - -func (t *TypeNameBuilder) FloatType(floatType *Void) *TypeNameBuilder { - t.obj.FloatType = floatType - return t -} - -func (t *TypeNameBuilder) DoubleType(doubleType *Void) *TypeNameBuilder { - t.obj.DoubleType = doubleType - return t -} - -func (t *TypeNameBuilder) StringType(stringType *Void) *TypeNameBuilder { - t.obj.StringType = stringType - return t -} - -func (t *TypeNameBuilder) BinaryType(binaryType *Void) *TypeNameBuilder { - t.obj.BinaryType = binaryType - return t -} - -func (t *TypeNameBuilder) EnumType(enumType *TypeUri) *TypeNameBuilder { - t.obj.EnumType = enumType - return t -} - -func (t *TypeNameBuilder) TypedefType(typedefType *TypeUri) *TypeNameBuilder { - t.obj.TypedefType = typedefType - return t -} - -func (t *TypeNameBuilder) StructType(structType *TypeUri) *TypeNameBuilder { - t.obj.StructType = structType - return t -} - -func (t *TypeNameBuilder) UnionType(unionType *TypeUri) *TypeNameBuilder { - t.obj.UnionType = unionType - return t -} - -func (t *TypeNameBuilder) ExceptionType(exceptionType *TypeUri) *TypeNameBuilder { - t.obj.ExceptionType = exceptionType - return t -} - -func (t *TypeNameBuilder) ListType(listType *Void) *TypeNameBuilder { - t.obj.ListType = listType - return t -} - -func (t *TypeNameBuilder) SetType(setType *Void) *TypeNameBuilder { - t.obj.SetType = setType - return t -} - -func (t *TypeNameBuilder) MapType(mapType *Void) *TypeNameBuilder { - t.obj.MapType = mapType - return t -} - -func (t *TypeName) SetBoolType(boolType *Void) *TypeName { - t.BoolType = boolType - return t -} - -func (t *TypeName) SetByteType(byteType *Void) *TypeName { - t.ByteType = byteType - return t -} - -func (t *TypeName) SetI16Type(i16Type *Void) *TypeName { - t.I16Type = i16Type - return t -} - -func (t *TypeName) SetI32Type(i32Type *Void) *TypeName { - t.I32Type = i32Type - return t -} - -func (t *TypeName) SetI64Type(i64Type *Void) *TypeName { - t.I64Type = i64Type - return t -} - -func (t *TypeName) SetFloatType(floatType *Void) *TypeName { - t.FloatType = floatType - return t -} - -func (t *TypeName) SetDoubleType(doubleType *Void) *TypeName { - t.DoubleType = doubleType - return t -} - -func (t *TypeName) SetStringType(stringType *Void) *TypeName { - t.StringType = stringType - return t -} - -func (t *TypeName) SetBinaryType(binaryType *Void) *TypeName { - t.BinaryType = binaryType - return t -} - -func (t *TypeName) SetEnumType(enumType *TypeUri) *TypeName { - t.EnumType = enumType - return t -} - -func (t *TypeName) SetTypedefType(typedefType *TypeUri) *TypeName { - t.TypedefType = typedefType - return t -} - -func (t *TypeName) SetStructType(structType *TypeUri) *TypeName { - t.StructType = structType - return t -} - -func (t *TypeName) SetUnionType(unionType *TypeUri) *TypeName { - t.UnionType = unionType - return t -} - -func (t *TypeName) SetExceptionType(exceptionType *TypeUri) *TypeName { - t.ExceptionType = exceptionType - return t -} - -func (t *TypeName) SetListType(listType *Void) *TypeName { - t.ListType = listType - return t -} - -func (t *TypeName) SetSetType(setType *Void) *TypeName { - t.SetType = setType - return t -} - -func (t *TypeName) SetMapType(mapType *Void) *TypeName { - t.MapType = mapType - return t -} - -func (p *TypeName) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 3: - if err := p.ReadField3(iprot); err != nil { - return err - } - case 4: - if err := p.ReadField4(iprot); err != nil { - return err - } - case 5: - if err := p.ReadField5(iprot); err != nil { - return err - } - case 6: - if err := p.ReadField6(iprot); err != nil { - return err - } - case 7: - if err := p.ReadField7(iprot); err != nil { - return err - } - case 8: - if err := p.ReadField8(iprot); err != nil { - return err - } - case 9: - if err := p.ReadField9(iprot); err != nil { - return err - } - case 10: - if err := p.ReadField10(iprot); err != nil { - return err - } - case 17: - if err := p.ReadField17(iprot); err != nil { - return err - } - case 11: - if err := p.ReadField11(iprot); err != nil { - return err - } - case 12: - if err := p.ReadField12(iprot); err != nil { - return err - } - case 13: - if err := p.ReadField13(iprot); err != nil { - return err - } - case 14: - if err := p.ReadField14(iprot); err != nil { - return err - } - case 15: - if err := p.ReadField15(iprot); err != nil { - return err - } - case 16: - if err := p.ReadField16(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *TypeName) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - temp := Void(v) - p.BoolType = &temp - } - return nil -} - -func (p *TypeName) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - temp := Void(v) - p.ByteType = &temp - } - return nil -} - -func (p *TypeName) ReadField3(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 3: ", err) - } else { - temp := Void(v) - p.I16Type = &temp - } - return nil -} - -func (p *TypeName) ReadField4(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 4: ", err) - } else { - temp := Void(v) - p.I32Type = &temp - } - return nil -} - -func (p *TypeName) ReadField5(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 5: ", err) - } else { - temp := Void(v) - p.I64Type = &temp - } - return nil -} - -func (p *TypeName) ReadField6(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 6: ", err) - } else { - temp := Void(v) - p.FloatType = &temp - } - return nil -} - -func (p *TypeName) ReadField7(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 7: ", err) - } else { - temp := Void(v) - p.DoubleType = &temp - } - return nil -} - -func (p *TypeName) ReadField8(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 8: ", err) - } else { - temp := Void(v) - p.StringType = &temp - } - return nil -} - -func (p *TypeName) ReadField9(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 9: ", err) - } else { - temp := Void(v) - p.BinaryType = &temp - } - return nil -} - -func (p *TypeName) ReadField10(iprot thrift.Protocol) error { - p.EnumType = NewTypeUri() - if err := p.EnumType.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.EnumType), err) - } - return nil -} - -func (p *TypeName) ReadField17(iprot thrift.Protocol) error { - p.TypedefType = NewTypeUri() - if err := p.TypedefType.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.TypedefType), err) - } - return nil -} - -func (p *TypeName) ReadField11(iprot thrift.Protocol) error { - p.StructType = NewTypeUri() - if err := p.StructType.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.StructType), err) - } - return nil -} - -func (p *TypeName) ReadField12(iprot thrift.Protocol) error { - p.UnionType = NewTypeUri() - if err := p.UnionType.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.UnionType), err) - } - return nil -} - -func (p *TypeName) ReadField13(iprot thrift.Protocol) error { - p.ExceptionType = NewTypeUri() - if err := p.ExceptionType.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.ExceptionType), err) - } - return nil -} - -func (p *TypeName) ReadField14(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 14: ", err) - } else { - temp := Void(v) - p.ListType = &temp - } - return nil -} - -func (p *TypeName) ReadField15(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 15: ", err) - } else { - temp := Void(v) - p.SetType = &temp - } - return nil -} - -func (p *TypeName) ReadField16(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 16: ", err) - } else { - temp := Void(v) - p.MapType = &temp - } - return nil -} - -func (p *TypeName) Write(oprot thrift.Protocol) error { - if c := p.CountSetFieldsTypeName(); c > 1 { - return fmt.Errorf("%T write union: no more than one field must be set (%d set).", p, c) - } - if err := oprot.WriteStructBegin("TypeName"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := p.writeField4(oprot); err != nil { return err } - if err := p.writeField5(oprot); err != nil { return err } - if err := p.writeField6(oprot); err != nil { return err } - if err := p.writeField7(oprot); err != nil { return err } - if err := p.writeField8(oprot); err != nil { return err } - if err := p.writeField9(oprot); err != nil { return err } - if err := p.writeField10(oprot); err != nil { return err } - if err := p.writeField11(oprot); err != nil { return err } - if err := p.writeField12(oprot); err != nil { return err } - if err := p.writeField13(oprot); err != nil { return err } - if err := p.writeField14(oprot); err != nil { return err } - if err := p.writeField15(oprot); err != nil { return err } - if err := p.writeField16(oprot); err != nil { return err } - if err := p.writeField17(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *TypeName) writeField1(oprot thrift.Protocol) (err error) { - if p.IsSetBoolType() { - if err := oprot.WriteFieldBegin("boolType", thrift.I32, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:boolType: ", p), err) } - if err := oprot.WriteI32(int32(*p.BoolType)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.boolType (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:boolType: ", p), err) } - } - return err -} - -func (p *TypeName) writeField2(oprot thrift.Protocol) (err error) { - if p.IsSetByteType() { - if err := oprot.WriteFieldBegin("byteType", thrift.I32, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:byteType: ", p), err) } - if err := oprot.WriteI32(int32(*p.ByteType)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.byteType (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:byteType: ", p), err) } - } - return err -} - -func (p *TypeName) writeField3(oprot thrift.Protocol) (err error) { - if p.IsSetI16Type() { - if err := oprot.WriteFieldBegin("i16Type", thrift.I32, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:i16Type: ", p), err) } - if err := oprot.WriteI32(int32(*p.I16Type)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.i16Type (3) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:i16Type: ", p), err) } - } - return err -} - -func (p *TypeName) writeField4(oprot thrift.Protocol) (err error) { - if p.IsSetI32Type() { - if err := oprot.WriteFieldBegin("i32Type", thrift.I32, 4); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:i32Type: ", p), err) } - if err := oprot.WriteI32(int32(*p.I32Type)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.i32Type (4) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 4:i32Type: ", p), err) } - } - return err -} - -func (p *TypeName) writeField5(oprot thrift.Protocol) (err error) { - if p.IsSetI64Type() { - if err := oprot.WriteFieldBegin("i64Type", thrift.I32, 5); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:i64Type: ", p), err) } - if err := oprot.WriteI32(int32(*p.I64Type)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.i64Type (5) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 5:i64Type: ", p), err) } - } - return err -} - -func (p *TypeName) writeField6(oprot thrift.Protocol) (err error) { - if p.IsSetFloatType() { - if err := oprot.WriteFieldBegin("floatType", thrift.I32, 6); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 6:floatType: ", p), err) } - if err := oprot.WriteI32(int32(*p.FloatType)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.floatType (6) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 6:floatType: ", p), err) } - } - return err -} - -func (p *TypeName) writeField7(oprot thrift.Protocol) (err error) { - if p.IsSetDoubleType() { - if err := oprot.WriteFieldBegin("doubleType", thrift.I32, 7); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 7:doubleType: ", p), err) } - if err := oprot.WriteI32(int32(*p.DoubleType)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.doubleType (7) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 7:doubleType: ", p), err) } - } - return err -} - -func (p *TypeName) writeField8(oprot thrift.Protocol) (err error) { - if p.IsSetStringType() { - if err := oprot.WriteFieldBegin("stringType", thrift.I32, 8); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 8:stringType: ", p), err) } - if err := oprot.WriteI32(int32(*p.StringType)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.stringType (8) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 8:stringType: ", p), err) } - } - return err -} - -func (p *TypeName) writeField9(oprot thrift.Protocol) (err error) { - if p.IsSetBinaryType() { - if err := oprot.WriteFieldBegin("binaryType", thrift.I32, 9); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 9:binaryType: ", p), err) } - if err := oprot.WriteI32(int32(*p.BinaryType)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.binaryType (9) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 9:binaryType: ", p), err) } - } - return err -} - -func (p *TypeName) writeField10(oprot thrift.Protocol) (err error) { - if p.IsSetEnumType() { - if err := oprot.WriteFieldBegin("enumType", thrift.STRUCT, 10); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 10:enumType: ", p), err) } - if err := p.EnumType.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.EnumType), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 10:enumType: ", p), err) } - } - return err -} - -func (p *TypeName) writeField11(oprot thrift.Protocol) (err error) { - if p.IsSetStructType() { - if err := oprot.WriteFieldBegin("structType", thrift.STRUCT, 11); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 11:structType: ", p), err) } - if err := p.StructType.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.StructType), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 11:structType: ", p), err) } - } - return err -} - -func (p *TypeName) writeField12(oprot thrift.Protocol) (err error) { - if p.IsSetUnionType() { - if err := oprot.WriteFieldBegin("unionType", thrift.STRUCT, 12); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 12:unionType: ", p), err) } - if err := p.UnionType.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.UnionType), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 12:unionType: ", p), err) } - } - return err -} - -func (p *TypeName) writeField13(oprot thrift.Protocol) (err error) { - if p.IsSetExceptionType() { - if err := oprot.WriteFieldBegin("exceptionType", thrift.STRUCT, 13); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 13:exceptionType: ", p), err) } - if err := p.ExceptionType.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.ExceptionType), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 13:exceptionType: ", p), err) } - } - return err -} - -func (p *TypeName) writeField14(oprot thrift.Protocol) (err error) { - if p.IsSetListType() { - if err := oprot.WriteFieldBegin("listType", thrift.I32, 14); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 14:listType: ", p), err) } - if err := oprot.WriteI32(int32(*p.ListType)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.listType (14) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 14:listType: ", p), err) } - } - return err -} - -func (p *TypeName) writeField15(oprot thrift.Protocol) (err error) { - if p.IsSetSetType() { - if err := oprot.WriteFieldBegin("setType", thrift.I32, 15); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 15:setType: ", p), err) } - if err := oprot.WriteI32(int32(*p.SetType)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.setType (15) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 15:setType: ", p), err) } - } - return err -} - -func (p *TypeName) writeField16(oprot thrift.Protocol) (err error) { - if p.IsSetMapType() { - if err := oprot.WriteFieldBegin("mapType", thrift.I32, 16); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 16:mapType: ", p), err) } - if err := oprot.WriteI32(int32(*p.MapType)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.mapType (16) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 16:mapType: ", p), err) } - } - return err -} - -func (p *TypeName) writeField17(oprot thrift.Protocol) (err error) { - if p.IsSetTypedefType() { - if err := oprot.WriteFieldBegin("typedefType", thrift.STRUCT, 17); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 17:typedefType: ", p), err) } - if err := p.TypedefType.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.TypedefType), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 17:typedefType: ", p), err) } - } - return err -} - -func (p *TypeName) String() string { - if p == nil { - return "" - } - - var boolTypeVal string - if p.BoolType == nil { - boolTypeVal = "" - } else { - boolTypeVal = fmt.Sprintf("%v", *p.BoolType) - } - var byteTypeVal string - if p.ByteType == nil { - byteTypeVal = "" - } else { - byteTypeVal = fmt.Sprintf("%v", *p.ByteType) - } - var i16TypeVal string - if p.I16Type == nil { - i16TypeVal = "" - } else { - i16TypeVal = fmt.Sprintf("%v", *p.I16Type) - } - var i32TypeVal string - if p.I32Type == nil { - i32TypeVal = "" - } else { - i32TypeVal = fmt.Sprintf("%v", *p.I32Type) - } - var i64TypeVal string - if p.I64Type == nil { - i64TypeVal = "" - } else { - i64TypeVal = fmt.Sprintf("%v", *p.I64Type) - } - var floatTypeVal string - if p.FloatType == nil { - floatTypeVal = "" - } else { - floatTypeVal = fmt.Sprintf("%v", *p.FloatType) - } - var doubleTypeVal string - if p.DoubleType == nil { - doubleTypeVal = "" - } else { - doubleTypeVal = fmt.Sprintf("%v", *p.DoubleType) - } - var stringTypeVal string - if p.StringType == nil { - stringTypeVal = "" - } else { - stringTypeVal = fmt.Sprintf("%v", *p.StringType) - } - var binaryTypeVal string - if p.BinaryType == nil { - binaryTypeVal = "" - } else { - binaryTypeVal = fmt.Sprintf("%v", *p.BinaryType) - } - var enumTypeVal string - if p.EnumType == nil { - enumTypeVal = "" - } else { - enumTypeVal = fmt.Sprintf("%v", p.EnumType) - } - var structTypeVal string - if p.StructType == nil { - structTypeVal = "" - } else { - structTypeVal = fmt.Sprintf("%v", p.StructType) - } - var unionTypeVal string - if p.UnionType == nil { - unionTypeVal = "" - } else { - unionTypeVal = fmt.Sprintf("%v", p.UnionType) - } - var exceptionTypeVal string - if p.ExceptionType == nil { - exceptionTypeVal = "" - } else { - exceptionTypeVal = fmt.Sprintf("%v", p.ExceptionType) - } - var listTypeVal string - if p.ListType == nil { - listTypeVal = "" - } else { - listTypeVal = fmt.Sprintf("%v", *p.ListType) - } - var setTypeVal string - if p.SetType == nil { - setTypeVal = "" - } else { - setTypeVal = fmt.Sprintf("%v", *p.SetType) - } - var mapTypeVal string - if p.MapType == nil { - mapTypeVal = "" - } else { - mapTypeVal = fmt.Sprintf("%v", *p.MapType) - } - var typedefTypeVal string - if p.TypedefType == nil { - typedefTypeVal = "" - } else { - typedefTypeVal = fmt.Sprintf("%v", p.TypedefType) - } - return fmt.Sprintf("TypeName({BoolType:%s ByteType:%s I16Type:%s I32Type:%s I64Type:%s FloatType:%s DoubleType:%s StringType:%s BinaryType:%s EnumType:%s StructType:%s UnionType:%s ExceptionType:%s ListType:%s SetType:%s MapType:%s TypedefType:%s})", boolTypeVal, byteTypeVal, i16TypeVal, i32TypeVal, i64TypeVal, floatTypeVal, doubleTypeVal, stringTypeVal, binaryTypeVal, enumTypeVal, structTypeVal, unionTypeVal, exceptionTypeVal, listTypeVal, setTypeVal, mapTypeVal, typedefTypeVal) -} - diff --git a/thrift/compiler/test/fixtures/serialization_field_order/gen-go/module/constants.go b/thrift/compiler/test/fixtures/serialization_field_order/gen-go/module/constants.go deleted file mode 100644 index 477cf91a64b..00000000000 --- a/thrift/compiler/test/fixtures/serialization_field_order/gen-go/module/constants.go +++ /dev/null @@ -1,25 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package module - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - - -func init() { -} - diff --git a/thrift/compiler/test/fixtures/serialization_field_order/gen-go/module/ttypes.go b/thrift/compiler/test/fixtures/serialization_field_order/gen-go/module/ttypes.go deleted file mode 100644 index 0732285ab25..00000000000 --- a/thrift/compiler/test/fixtures/serialization_field_order/gen-go/module/ttypes.go +++ /dev/null @@ -1,413 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package module - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var GoUnusedProtection__ int; - -// Attributes: -// - Field1 -// - Field2 -// - Field3 -type Foo struct { - Field2 int32 `thrift:"field2,1" db:"field2" json:"field2"` - Field3 int32 `thrift:"field3,2" db:"field3" json:"field3"` - Field1 int32 `thrift:"field1,3" db:"field1" json:"field1"` -} - -func NewFoo() *Foo { - return &Foo{} -} - - -func (p *Foo) GetField1() int32 { - return p.Field1 -} - -func (p *Foo) GetField2() int32 { - return p.Field2 -} - -func (p *Foo) GetField3() int32 { - return p.Field3 -} -type FooBuilder struct { - obj *Foo -} - -func NewFooBuilder() *FooBuilder{ - return &FooBuilder{ - obj: NewFoo(), - } -} - -func (p FooBuilder) Emit() *Foo{ - return &Foo{ - Field1: p.obj.Field1, - Field2: p.obj.Field2, - Field3: p.obj.Field3, - } -} - -func (f *FooBuilder) Field1(field1 int32) *FooBuilder { - f.obj.Field1 = field1 - return f -} - -func (f *FooBuilder) Field2(field2 int32) *FooBuilder { - f.obj.Field2 = field2 - return f -} - -func (f *FooBuilder) Field3(field3 int32) *FooBuilder { - f.obj.Field3 = field3 - return f -} - -func (f *Foo) SetField1(field1 int32) *Foo { - f.Field1 = field1 - return f -} - -func (f *Foo) SetField2(field2 int32) *Foo { - f.Field2 = field2 - return f -} - -func (f *Foo) SetField3(field3 int32) *Foo { - f.Field3 = field3 - return f -} - -func (p *Foo) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 3: - if err := p.ReadField3(iprot); err != nil { - return err - } - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Foo) ReadField3(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 3: ", err) - } else { - p.Field1 = v - } - return nil -} - -func (p *Foo) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Field2 = v - } - return nil -} - -func (p *Foo) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Field3 = v - } - return nil -} - -func (p *Foo) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Foo"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Foo) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("field2", thrift.I32, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:field2: ", p), err) } - if err := oprot.WriteI32(int32(p.Field2)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.field2 (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:field2: ", p), err) } - return err -} - -func (p *Foo) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("field3", thrift.I32, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:field3: ", p), err) } - if err := oprot.WriteI32(int32(p.Field3)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.field3 (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:field3: ", p), err) } - return err -} - -func (p *Foo) writeField3(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("field1", thrift.I32, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:field1: ", p), err) } - if err := oprot.WriteI32(int32(p.Field1)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.field1 (3) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:field1: ", p), err) } - return err -} - -func (p *Foo) String() string { - if p == nil { - return "" - } - - field2Val := fmt.Sprintf("%v", p.Field2) - field3Val := fmt.Sprintf("%v", p.Field3) - field1Val := fmt.Sprintf("%v", p.Field1) - return fmt.Sprintf("Foo({Field2:%s Field3:%s Field1:%s})", field2Val, field3Val, field1Val) -} - -// Attributes: -// - Field1 -// - Field2 -// - Field3 -type Foo2 struct { - Field2 int32 `thrift:"field2,1" db:"field2" json:"field2"` - Field3 int32 `thrift:"field3,2" db:"field3" json:"field3"` - Field1 int32 `thrift:"field1,3" db:"field1" json:"field1"` -} - -func NewFoo2() *Foo2 { - return &Foo2{} -} - - -func (p *Foo2) GetField1() int32 { - return p.Field1 -} - -func (p *Foo2) GetField2() int32 { - return p.Field2 -} - -func (p *Foo2) GetField3() int32 { - return p.Field3 -} -type Foo2Builder struct { - obj *Foo2 -} - -func NewFoo2Builder() *Foo2Builder{ - return &Foo2Builder{ - obj: NewFoo2(), - } -} - -func (p Foo2Builder) Emit() *Foo2{ - return &Foo2{ - Field1: p.obj.Field1, - Field2: p.obj.Field2, - Field3: p.obj.Field3, - } -} - -func (f *Foo2Builder) Field1(field1 int32) *Foo2Builder { - f.obj.Field1 = field1 - return f -} - -func (f *Foo2Builder) Field2(field2 int32) *Foo2Builder { - f.obj.Field2 = field2 - return f -} - -func (f *Foo2Builder) Field3(field3 int32) *Foo2Builder { - f.obj.Field3 = field3 - return f -} - -func (f *Foo2) SetField1(field1 int32) *Foo2 { - f.Field1 = field1 - return f -} - -func (f *Foo2) SetField2(field2 int32) *Foo2 { - f.Field2 = field2 - return f -} - -func (f *Foo2) SetField3(field3 int32) *Foo2 { - f.Field3 = field3 - return f -} - -func (p *Foo2) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 3: - if err := p.ReadField3(iprot); err != nil { - return err - } - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Foo2) ReadField3(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 3: ", err) - } else { - p.Field1 = v - } - return nil -} - -func (p *Foo2) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Field2 = v - } - return nil -} - -func (p *Foo2) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Field3 = v - } - return nil -} - -func (p *Foo2) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Foo2"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Foo2) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("field2", thrift.I32, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:field2: ", p), err) } - if err := oprot.WriteI32(int32(p.Field2)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.field2 (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:field2: ", p), err) } - return err -} - -func (p *Foo2) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("field3", thrift.I32, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:field3: ", p), err) } - if err := oprot.WriteI32(int32(p.Field3)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.field3 (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:field3: ", p), err) } - return err -} - -func (p *Foo2) writeField3(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("field1", thrift.I32, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:field1: ", p), err) } - if err := oprot.WriteI32(int32(p.Field1)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.field1 (3) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:field1: ", p), err) } - return err -} - -func (p *Foo2) String() string { - if p == nil { - return "" - } - - field2Val := fmt.Sprintf("%v", p.Field2) - field3Val := fmt.Sprintf("%v", p.Field3) - field1Val := fmt.Sprintf("%v", p.Field1) - return fmt.Sprintf("Foo2({Field2:%s Field3:%s Field1:%s})", field2Val, field3Val, field1Val) -} - diff --git a/thrift/compiler/test/fixtures/serialization_field_order/gen-go/thrift/annotation/scope/constants.go b/thrift/compiler/test/fixtures/serialization_field_order/gen-go/thrift/annotation/scope/constants.go deleted file mode 100644 index 0c3448a7126..00000000000 --- a/thrift/compiler/test/fixtures/serialization_field_order/gen-go/thrift/annotation/scope/constants.go +++ /dev/null @@ -1,25 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package scope - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - - -func init() { -} - diff --git a/thrift/compiler/test/fixtures/serialization_field_order/gen-go/thrift/annotation/scope/ttypes.go b/thrift/compiler/test/fixtures/serialization_field_order/gen-go/thrift/annotation/scope/ttypes.go deleted file mode 100644 index 580c39e775c..00000000000 --- a/thrift/compiler/test/fixtures/serialization_field_order/gen-go/thrift/annotation/scope/ttypes.go +++ /dev/null @@ -1,1169 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package scope - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var GoUnusedProtection__ int; - -// Indicates that the scope of sibling annotations is transitive. -// -// For example: -// -// @scope.Struct -// @scope.Union -// @scope.Exception -// @scope.Transitive -// struct Structured {} -// -// Annotating a Thrift struct with @Structured automatically applies -// @scope.Struct, @scope.Union and @scope.Exception annotations, i.e. -// -// @Structured -// struct MyAnnotation {} -// -// is equivalent to -// -// @scope.Struct -// @scope.Union -// @scope.Exception -// struct MyAnnotation {} -// -type Transitive struct { -} - -func NewTransitive() *Transitive { - return &Transitive{} -} - -type TransitiveBuilder struct { - obj *Transitive -} - -func NewTransitiveBuilder() *TransitiveBuilder{ - return &TransitiveBuilder{ - obj: NewTransitive(), - } -} - -func (p TransitiveBuilder) Emit() *Transitive{ - return &Transitive{ - } -} - -func (p *Transitive) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Transitive) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Transitive"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Transitive) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Transitive({})") -} - -// The Program scope. -// -// This allows annotations on the `package` definition, which implies the -// annotaiton applies to the entire program. -type Program struct { -} - -func NewProgram() *Program { - return &Program{} -} - -type ProgramBuilder struct { - obj *Program -} - -func NewProgramBuilder() *ProgramBuilder{ - return &ProgramBuilder{ - obj: NewProgram(), - } -} - -func (p ProgramBuilder) Emit() *Program{ - return &Program{ - } -} - -func (p *Program) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Program) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Program"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Program) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Program({})") -} - -// The `struct` definition scope. -type Struct struct { -} - -func NewStruct() *Struct { - return &Struct{} -} - -type StructBuilder struct { - obj *Struct -} - -func NewStructBuilder() *StructBuilder{ - return &StructBuilder{ - obj: NewStruct(), - } -} - -func (p StructBuilder) Emit() *Struct{ - return &Struct{ - } -} - -func (p *Struct) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Struct) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Struct"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Struct) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Struct({})") -} - -// The `union` definition scope. -type Union struct { -} - -func NewUnion() *Union { - return &Union{} -} - -type UnionBuilder struct { - obj *Union -} - -func NewUnionBuilder() *UnionBuilder{ - return &UnionBuilder{ - obj: NewUnion(), - } -} - -func (p UnionBuilder) Emit() *Union{ - return &Union{ - } -} - -func (p *Union) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Union) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Union"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Union) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Union({})") -} - -// The `exception` definition scope. -type Exception struct { -} - -func NewException() *Exception { - return &Exception{} -} - -type ExceptionBuilder struct { - obj *Exception -} - -func NewExceptionBuilder() *ExceptionBuilder{ - return &ExceptionBuilder{ - obj: NewException(), - } -} - -func (p ExceptionBuilder) Emit() *Exception{ - return &Exception{ - } -} - -func (p *Exception) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Exception) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Exception"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Exception) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Exception({})") -} - -// Field declartaions, for example in `struct` or `function` declartions. -type Field struct { -} - -func NewField() *Field { - return &Field{} -} - -type FieldBuilder struct { - obj *Field -} - -func NewFieldBuilder() *FieldBuilder{ - return &FieldBuilder{ - obj: NewField(), - } -} - -func (p FieldBuilder) Emit() *Field{ - return &Field{ - } -} - -func (p *Field) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Field) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Field"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Field) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Field({})") -} - -// The `typedef` definition scope. -type Typedef struct { -} - -func NewTypedef() *Typedef { - return &Typedef{} -} - -type TypedefBuilder struct { - obj *Typedef -} - -func NewTypedefBuilder() *TypedefBuilder{ - return &TypedefBuilder{ - obj: NewTypedef(), - } -} - -func (p TypedefBuilder) Emit() *Typedef{ - return &Typedef{ - } -} - -func (p *Typedef) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Typedef) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Typedef"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Typedef) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Typedef({})") -} - -// The `service` definition scope. -type Service struct { -} - -func NewService() *Service { - return &Service{} -} - -type ServiceBuilder struct { - obj *Service -} - -func NewServiceBuilder() *ServiceBuilder{ - return &ServiceBuilder{ - obj: NewService(), - } -} - -func (p ServiceBuilder) Emit() *Service{ - return &Service{ - } -} - -func (p *Service) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Service) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Service"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Service) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Service({})") -} - -// The `interaction` definition scope. -type Interaction struct { -} - -func NewInteraction() *Interaction { - return &Interaction{} -} - -type InteractionBuilder struct { - obj *Interaction -} - -func NewInteractionBuilder() *InteractionBuilder{ - return &InteractionBuilder{ - obj: NewInteraction(), - } -} - -func (p InteractionBuilder) Emit() *Interaction{ - return &Interaction{ - } -} - -func (p *Interaction) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Interaction) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Interaction"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Interaction) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Interaction({})") -} - -// The `function` definition scope. -type Function struct { -} - -func NewFunction() *Function { - return &Function{} -} - -type FunctionBuilder struct { - obj *Function -} - -func NewFunctionBuilder() *FunctionBuilder{ - return &FunctionBuilder{ - obj: NewFunction(), - } -} - -func (p FunctionBuilder) Emit() *Function{ - return &Function{ - } -} - -func (p *Function) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Function) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Function"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Function) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Function({})") -} - -// The Enum value definition scope. -type EnumValue struct { -} - -func NewEnumValue() *EnumValue { - return &EnumValue{} -} - -type EnumValueBuilder struct { - obj *EnumValue -} - -func NewEnumValueBuilder() *EnumValueBuilder{ - return &EnumValueBuilder{ - obj: NewEnumValue(), - } -} - -func (p EnumValueBuilder) Emit() *EnumValue{ - return &EnumValue{ - } -} - -func (p *EnumValue) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *EnumValue) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("EnumValue"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *EnumValue) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("EnumValue({})") -} - -// The `const` definition scope. -type Const struct { -} - -func NewConst() *Const { - return &Const{} -} - -type ConstBuilder struct { - obj *Const -} - -func NewConstBuilder() *ConstBuilder{ - return &ConstBuilder{ - obj: NewConst(), - } -} - -func (p ConstBuilder) Emit() *Const{ - return &Const{ - } -} - -func (p *Const) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Const) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Const"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Const) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Const({})") -} - -type Enum struct { -} - -func NewEnum() *Enum { - return &Enum{} -} - -type EnumBuilder struct { - obj *Enum -} - -func NewEnumBuilder() *EnumBuilder{ - return &EnumBuilder{ - obj: NewEnum(), - } -} - -func (p EnumBuilder) Emit() *Enum{ - return &Enum{ - } -} - -func (p *Enum) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Enum) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Enum"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Enum) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Enum({})") -} - -// A scope that includes all 'structured' definitions. -type Structured struct { -} - -func NewStructured() *Structured { - return &Structured{} -} - -type StructuredBuilder struct { - obj *Structured -} - -func NewStructuredBuilder() *StructuredBuilder{ - return &StructuredBuilder{ - obj: NewStructured(), - } -} - -func (p StructuredBuilder) Emit() *Structured{ - return &Structured{ - } -} - -func (p *Structured) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Structured) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Structured"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Structured) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Structured({})") -} - -// A scope that includes all 'interface' definitions. -type Interface struct { -} - -func NewInterface() *Interface { - return &Interface{} -} - -type InterfaceBuilder struct { - obj *Interface -} - -func NewInterfaceBuilder() *InterfaceBuilder{ - return &InterfaceBuilder{ - obj: NewInterface(), - } -} - -func (p InterfaceBuilder) Emit() *Interface{ - return &Interface{ - } -} - -func (p *Interface) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Interface) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Interface"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Interface) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Interface({})") -} - -// A scope that includes all program-scoped definition. -type RootDefinition struct { -} - -func NewRootDefinition() *RootDefinition { - return &RootDefinition{} -} - -type RootDefinitionBuilder struct { - obj *RootDefinition -} - -func NewRootDefinitionBuilder() *RootDefinitionBuilder{ - return &RootDefinitionBuilder{ - obj: NewRootDefinition(), - } -} - -func (p RootDefinitionBuilder) Emit() *RootDefinition{ - return &RootDefinition{ - } -} - -func (p *RootDefinition) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *RootDefinition) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("RootDefinition"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *RootDefinition) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("RootDefinition({})") -} - -// A scope that includes all definitions. -type Definition struct { -} - -func NewDefinition() *Definition { - return &Definition{} -} - -type DefinitionBuilder struct { - obj *Definition -} - -func NewDefinitionBuilder() *DefinitionBuilder{ - return &DefinitionBuilder{ - obj: NewDefinition(), - } -} - -func (p DefinitionBuilder) Emit() *Definition{ - return &Definition{ - } -} - -func (p *Definition) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Definition) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Definition"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Definition) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Definition({})") -} - diff --git a/thrift/compiler/test/fixtures/serialization_field_order/gen-go/thrift/annotation/thrift/constants.go b/thrift/compiler/test/fixtures/serialization_field_order/gen-go/thrift/annotation/thrift/constants.go deleted file mode 100644 index 50d9b0fe3ee..00000000000 --- a/thrift/compiler/test/fixtures/serialization_field_order/gen-go/thrift/annotation/thrift/constants.go +++ /dev/null @@ -1,25 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package thrift - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - - -func init() { -} - diff --git a/thrift/compiler/test/fixtures/serialization_field_order/gen-go/thrift/annotation/thrift/ttypes.go b/thrift/compiler/test/fixtures/serialization_field_order/gen-go/thrift/annotation/thrift/ttypes.go deleted file mode 100644 index 35ea75e3dd0..00000000000 --- a/thrift/compiler/test/fixtures/serialization_field_order/gen-go/thrift/annotation/thrift/ttypes.go +++ /dev/null @@ -1,1545 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package thrift - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var GoUnusedProtection__ int; - -type RpcPriority int64 -const ( - RpcPriority_HIGH_IMPORTANT RpcPriority = 0 - RpcPriority_HIGH RpcPriority = 1 - RpcPriority_IMPORTANT RpcPriority = 2 - RpcPriority_NORMAL RpcPriority = 3 - RpcPriority_BEST_EFFORT RpcPriority = 4 -) - -var RpcPriorityToName = map[RpcPriority]string { - RpcPriority_HIGH_IMPORTANT: "HIGH_IMPORTANT", - RpcPriority_HIGH: "HIGH", - RpcPriority_IMPORTANT: "IMPORTANT", - RpcPriority_NORMAL: "NORMAL", - RpcPriority_BEST_EFFORT: "BEST_EFFORT", -} - -var RpcPriorityToValue = map[string]RpcPriority { - "HIGH_IMPORTANT": RpcPriority_HIGH_IMPORTANT, - "HIGH": RpcPriority_HIGH, - "IMPORTANT": RpcPriority_IMPORTANT, - "NORMAL": RpcPriority_NORMAL, - "BEST_EFFORT": RpcPriority_BEST_EFFORT, -} - -var RpcPriorityNames = []string { - "HIGH_IMPORTANT", - "HIGH", - "IMPORTANT", - "NORMAL", - "BEST_EFFORT", -} - -var RpcPriorityValues = []RpcPriority { - RpcPriority_HIGH_IMPORTANT, - RpcPriority_HIGH, - RpcPriority_IMPORTANT, - RpcPriority_NORMAL, - RpcPriority_BEST_EFFORT, -} - -func (p RpcPriority) String() string { - if v, ok := RpcPriorityToName[p]; ok { - return v - } - return "" -} - -func RpcPriorityFromString(s string) (RpcPriority, error) { - if v, ok := RpcPriorityToValue[s]; ok { - return v, nil - } - return RpcPriority(0), fmt.Errorf("not a valid RpcPriority string") -} - -func RpcPriorityPtr(v RpcPriority) *RpcPriority { return &v } - -// Indicates a definition/feature should only be used with permission, may -// only work in specific contexts, and may change in incompatible ways without -// notice. Note that this is primarily intended to annotate features by the Thrift Team -// and isn't recommended for general use. -type Experimental struct { -} - -func NewExperimental() *Experimental { - return &Experimental{} -} - -type ExperimentalBuilder struct { - obj *Experimental -} - -func NewExperimentalBuilder() *ExperimentalBuilder{ - return &ExperimentalBuilder{ - obj: NewExperimental(), - } -} - -func (p ExperimentalBuilder) Emit() *Experimental{ - return &Experimental{ - } -} - -func (p *Experimental) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Experimental) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Experimental"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Experimental) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Experimental({})") -} - -// Annotate a thrift structured or enum to indicate if ids or values should not -// be used. -// -// For example, you may want to mark ids as deprecated, or these ids -// might be reserved for other use cases or annotations. -// -// The resolved set of disallowed ids is the union of the values in `ids` and -// the range of values represented in `id_ranges`. Example: -// -// // These ids are not allowed: 3, 8, half-open ranges [10, 15), [20, 30) -// @thrift.ReserveIds{ids = [3, 8], id_ranges = {10: 15, 20: 30}} -// struct Foo { -// ... -// 3: i64 f; // Build failure: 3 cannot be used -// } -// -// Attributes: -// - Ids: Individual ids that cannot be used. -// - IdRanges: Represents ranges of ids that cannot be used. -// -// Each (key: value) pair represents the half-open range `[key, value)`, -// where `key` is included and `value` is not. For example, the map -// `{10: 15, 20: 30}` represents the union of id/value ranges `[10, 15)` and -// `[20, 30)`. -type ReserveIds struct { - Ids []int32 `thrift:"ids,1" db:"ids" json:"ids"` - IdRanges map[int32]int32 `thrift:"id_ranges,2" db:"id_ranges" json:"id_ranges"` -} - -func NewReserveIds() *ReserveIds { - return &ReserveIds{} -} - - -func (p *ReserveIds) GetIds() []int32 { - return p.Ids -} - -func (p *ReserveIds) GetIdRanges() map[int32]int32 { - return p.IdRanges -} -type ReserveIdsBuilder struct { - obj *ReserveIds -} - -func NewReserveIdsBuilder() *ReserveIdsBuilder{ - return &ReserveIdsBuilder{ - obj: NewReserveIds(), - } -} - -func (p ReserveIdsBuilder) Emit() *ReserveIds{ - return &ReserveIds{ - Ids: p.obj.Ids, - IdRanges: p.obj.IdRanges, - } -} - -func (r *ReserveIdsBuilder) Ids(ids []int32) *ReserveIdsBuilder { - r.obj.Ids = ids - return r -} - -func (r *ReserveIdsBuilder) IdRanges(idRanges map[int32]int32) *ReserveIdsBuilder { - r.obj.IdRanges = idRanges - return r -} - -func (r *ReserveIds) SetIds(ids []int32) *ReserveIds { - r.Ids = ids - return r -} - -func (r *ReserveIds) SetIdRanges(idRanges map[int32]int32) *ReserveIds { - r.IdRanges = idRanges - return r -} - -func (p *ReserveIds) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ReserveIds) ReadField1(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]int32, 0, size) - p.Ids = tSlice - for i := 0; i < size; i ++ { - var _elem0 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem0 = v - } - p.Ids = append(p.Ids, _elem0) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *ReserveIds) ReadField2(iprot thrift.Protocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[int32]int32, size) - p.IdRanges = tMap - for i := 0; i < size; i ++ { - var _key1 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key1 = v - } - var _val2 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _val2 = v - } - p.IdRanges[_key1] = _val2 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *ReserveIds) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("ReserveIds"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *ReserveIds) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("ids", thrift.LIST, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:ids: ", p), err) } - if err := oprot.WriteListBegin(thrift.I32, len(p.Ids)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.Ids { - if err := oprot.WriteI32(int32(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:ids: ", p), err) } - return err -} - -func (p *ReserveIds) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("id_ranges", thrift.MAP, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:id_ranges: ", p), err) } - if err := oprot.WriteMapBegin(thrift.I32, thrift.I32, len(p.IdRanges)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.IdRanges { - if err := oprot.WriteI32(int32(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := oprot.WriteI32(int32(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:id_ranges: ", p), err) } - return err -} - -func (p *ReserveIds) String() string { - if p == nil { - return "" - } - - idsVal := fmt.Sprintf("%v", p.Ids) - idRangesVal := fmt.Sprintf("%v", p.IdRanges) - return fmt.Sprintf("ReserveIds({Ids:%s IdRanges:%s})", idsVal, idRangesVal) -} - -// Indicates additional backward compatibility restrictions, beyond the -// standard Thrift required 'wire' compatibility. -// -// Attributes: -// - FieldName -type RequiresBackwardCompatibility struct { - FieldName bool `thrift:"field_name,1" db:"field_name" json:"field_name"` -} - -func NewRequiresBackwardCompatibility() *RequiresBackwardCompatibility { - return &RequiresBackwardCompatibility{} -} - - -func (p *RequiresBackwardCompatibility) GetFieldName() bool { - return p.FieldName -} -type RequiresBackwardCompatibilityBuilder struct { - obj *RequiresBackwardCompatibility -} - -func NewRequiresBackwardCompatibilityBuilder() *RequiresBackwardCompatibilityBuilder{ - return &RequiresBackwardCompatibilityBuilder{ - obj: NewRequiresBackwardCompatibility(), - } -} - -func (p RequiresBackwardCompatibilityBuilder) Emit() *RequiresBackwardCompatibility{ - return &RequiresBackwardCompatibility{ - FieldName: p.obj.FieldName, - } -} - -func (r *RequiresBackwardCompatibilityBuilder) FieldName(fieldName bool) *RequiresBackwardCompatibilityBuilder { - r.obj.FieldName = fieldName - return r -} - -func (r *RequiresBackwardCompatibility) SetFieldName(fieldName bool) *RequiresBackwardCompatibility { - r.FieldName = fieldName - return r -} - -func (p *RequiresBackwardCompatibility) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *RequiresBackwardCompatibility) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.FieldName = v - } - return nil -} - -func (p *RequiresBackwardCompatibility) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("RequiresBackwardCompatibility"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *RequiresBackwardCompatibility) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("field_name", thrift.BOOL, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:field_name: ", p), err) } - if err := oprot.WriteBool(bool(p.FieldName)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.field_name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:field_name: ", p), err) } - return err -} - -func (p *RequiresBackwardCompatibility) String() string { - if p == nil { - return "" - } - - fieldNameVal := fmt.Sprintf("%v", p.FieldName) - return fmt.Sprintf("RequiresBackwardCompatibility({FieldName:%s})", fieldNameVal) -} - -// An annotation that changes the field qualifier from 'none' to 'terse'. -// A terse field is eligible to skip serialization, when it equals to the -// intrinsic default value. It also clears to the intrinsic default value -// before deserialization to distinguish between if a terse field was skipped -// or missing during serialization. This is different from an unqualified -// field, as an unqualified field is always serialized regardless of its value, -// and it is not cleared before deserialization. -// -// The annotation can be only used to annotate an unqualified field, and when -// it is annotating a struct or exception, it changes all unqualified fields to -// terse fields. Note, the annotation can not be used for union. -type TerseWrite struct { -} - -func NewTerseWrite() *TerseWrite { - return &TerseWrite{} -} - -type TerseWriteBuilder struct { - obj *TerseWrite -} - -func NewTerseWriteBuilder() *TerseWriteBuilder{ - return &TerseWriteBuilder{ - obj: NewTerseWrite(), - } -} - -func (p TerseWriteBuilder) Emit() *TerseWrite{ - return &TerseWrite{ - } -} - -func (p *TerseWrite) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *TerseWrite) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("TerseWrite"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *TerseWrite) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("TerseWrite({})") -} - -// Indicates that an optional field's value should never be stored on the stack, -// i.e. the subobject should be allocated separately (e.g. because it is large and infrequently set). -// -// NOTE: The APIs and initialization behavior are same as normal field, but different from `@cpp.Ref`. e.g. -// -// ``` -// struct Foo { -// 1: optional i32 normal; -// @thrift.Box -// 2: optional i32 boxed; -// @cpp.Ref -// 3: optional i32 referred; -// } -// ``` -// in C++ -// -// ``` -// Foo foo; -// EXPECT_FALSE(foo.normal().has_value()); // okay -// EXPECT_FALSE(foo.boxed().has_value()); // okay -// EXPECT_FALSE(foo.referred().has_value()); // build failure: std::unique_ptr doesn't have has_value method -// -// EXPECT_EQ(*foo.normal(), 0); // throw bad_field_access exception -// EXPECT_EQ(*foo.boxed(), 0); // throw bad_field_access exception -// EXPECT_EQ(*foo.referred(), 0); // okay, field has value by default -// ``` -// -// Affects C++ and Rust. -// TODO: replace with @cpp.Box + @rust.Box -type Box struct { -} - -func NewBox() *Box { - return &Box{} -} - -type BoxBuilder struct { - obj *Box -} - -func NewBoxBuilder() *BoxBuilder{ - return &BoxBuilder{ - obj: NewBox(), - } -} - -func (p BoxBuilder) Emit() *Box{ - return &Box{ - } -} - -func (p *Box) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Box) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Box"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Box) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Box({})") -} - -// Indicates whether the nested fields are accessible directly. -// https://github.com/facebook/fbthrift/blob/v2023.11.20.00/thrift/doc/idl/mixins.md -type Mixin struct { -} - -func NewMixin() *Mixin { - return &Mixin{} -} - -type MixinBuilder struct { - obj *Mixin -} - -func NewMixinBuilder() *MixinBuilder{ - return &MixinBuilder{ - obj: NewMixin(), - } -} - -func (p MixinBuilder) Emit() *Mixin{ - return &Mixin{ - } -} - -func (p *Mixin) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Mixin) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Mixin"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Mixin) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Mixin({})") -} - -// Option to serialize thrift struct in ascending field id order instead of field declaration order. -// -// This can potentially make serialized data size smaller in compact protocol, -// since compact protocol can write deltas between subsequent field ids instead of full ids. -// -// NOTE: This annotation won't reduce payload size for other protocols. -type SerializeInFieldIdOrder struct { -} - -func NewSerializeInFieldIdOrder() *SerializeInFieldIdOrder { - return &SerializeInFieldIdOrder{} -} - -type SerializeInFieldIdOrderBuilder struct { - obj *SerializeInFieldIdOrder -} - -func NewSerializeInFieldIdOrderBuilder() *SerializeInFieldIdOrderBuilder{ - return &SerializeInFieldIdOrderBuilder{ - obj: NewSerializeInFieldIdOrder(), - } -} - -func (p SerializeInFieldIdOrderBuilder) Emit() *SerializeInFieldIdOrder{ - return &SerializeInFieldIdOrder{ - } -} - -func (p *SerializeInFieldIdOrder) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *SerializeInFieldIdOrder) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("SerializeInFieldIdOrder"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *SerializeInFieldIdOrder) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("SerializeInFieldIdOrder({})") -} - -// Indicates an enum is a bitmask and should support bit-wise operators. -// Currently generates additional code in C++ and Hack. -type BitmaskEnum struct { -} - -func NewBitmaskEnum() *BitmaskEnum { - return &BitmaskEnum{} -} - -type BitmaskEnumBuilder struct { - obj *BitmaskEnum -} - -func NewBitmaskEnumBuilder() *BitmaskEnumBuilder{ - return &BitmaskEnumBuilder{ - obj: NewBitmaskEnum(), - } -} - -func (p BitmaskEnumBuilder) Emit() *BitmaskEnum{ - return &BitmaskEnum{ - } -} - -func (p *BitmaskEnum) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *BitmaskEnum) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("BitmaskEnum"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *BitmaskEnum) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("BitmaskEnum({})") -} - -// Specifies the field where the exception message is stored. -type ExceptionMessage struct { -} - -func NewExceptionMessage() *ExceptionMessage { - return &ExceptionMessage{} -} - -type ExceptionMessageBuilder struct { - obj *ExceptionMessage -} - -func NewExceptionMessageBuilder() *ExceptionMessageBuilder{ - return &ExceptionMessageBuilder{ - obj: NewExceptionMessage(), - } -} - -func (p ExceptionMessageBuilder) Emit() *ExceptionMessage{ - return &ExceptionMessage{ - } -} - -func (p *ExceptionMessage) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ExceptionMessage) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("ExceptionMessage"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *ExceptionMessage) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("ExceptionMessage({})") -} - -// Generates a const of type schema. Struct containing the schema of the -// annotated type. Optionally specify name to override default -// schema. -// -// Attributes: -// - Name -type GenerateRuntimeSchema struct { - Name string `thrift:"name,1" db:"name" json:"name"` -} - -func NewGenerateRuntimeSchema() *GenerateRuntimeSchema { - return &GenerateRuntimeSchema{} -} - - -func (p *GenerateRuntimeSchema) GetName() string { - return p.Name -} -type GenerateRuntimeSchemaBuilder struct { - obj *GenerateRuntimeSchema -} - -func NewGenerateRuntimeSchemaBuilder() *GenerateRuntimeSchemaBuilder{ - return &GenerateRuntimeSchemaBuilder{ - obj: NewGenerateRuntimeSchema(), - } -} - -func (p GenerateRuntimeSchemaBuilder) Emit() *GenerateRuntimeSchema{ - return &GenerateRuntimeSchema{ - Name: p.obj.Name, - } -} - -func (g *GenerateRuntimeSchemaBuilder) Name(name string) *GenerateRuntimeSchemaBuilder { - g.obj.Name = name - return g -} - -func (g *GenerateRuntimeSchema) SetName(name string) *GenerateRuntimeSchema { - g.Name = name - return g -} - -func (p *GenerateRuntimeSchema) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *GenerateRuntimeSchema) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Name = v - } - return nil -} - -func (p *GenerateRuntimeSchema) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("GenerateRuntimeSchema"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *GenerateRuntimeSchema) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) } - if err := oprot.WriteString(string(p.Name)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) } - return err -} - -func (p *GenerateRuntimeSchema) String() string { - if p == nil { - return "" - } - - nameVal := fmt.Sprintf("%v", p.Name) - return fmt.Sprintf("GenerateRuntimeSchema({Name:%s})", nameVal) -} - -// Indicates that a field's value should never be stored on the stack, and that -// identical values can be shared in immutable contexts. -type InternBox struct { -} - -func NewInternBox() *InternBox { - return &InternBox{} -} - -type InternBoxBuilder struct { - obj *InternBox -} - -func NewInternBoxBuilder() *InternBoxBuilder{ - return &InternBoxBuilder{ - obj: NewInternBox(), - } -} - -func (p InternBoxBuilder) Emit() *InternBox{ - return &InternBox{ - } -} - -func (p *InternBox) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *InternBox) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("InternBox"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *InternBox) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("InternBox({})") -} - -// Indicates that an interaction's methods should be processed sequentially. -type Serial struct { -} - -func NewSerial() *Serial { - return &Serial{} -} - -type SerialBuilder struct { - obj *Serial -} - -func NewSerialBuilder() *SerialBuilder{ - return &SerialBuilder{ - obj: NewSerial(), - } -} - -func (p SerialBuilder) Emit() *Serial{ - return &Serial{ - } -} - -func (p *Serial) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Serial) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Serial"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Serial) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Serial({})") -} - -// Changes the URI of this definition away from the default-generated one. -// -// Attributes: -// - Value -type Uri struct { - Value string `thrift:"value,1" db:"value" json:"value"` -} - -func NewUri() *Uri { - return &Uri{} -} - - -func (p *Uri) GetValue() string { - return p.Value -} -type UriBuilder struct { - obj *Uri -} - -func NewUriBuilder() *UriBuilder{ - return &UriBuilder{ - obj: NewUri(), - } -} - -func (p UriBuilder) Emit() *Uri{ - return &Uri{ - Value: p.obj.Value, - } -} - -func (u *UriBuilder) Value(value string) *UriBuilder { - u.obj.Value = value - return u -} - -func (u *Uri) SetValue(value string) *Uri { - u.Value = value - return u -} - -func (p *Uri) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Uri) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Value = v - } - return nil -} - -func (p *Uri) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Uri"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Uri) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("value", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:value: ", p), err) } - if err := oprot.WriteString(string(p.Value)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.value (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:value: ", p), err) } - return err -} - -func (p *Uri) String() string { - if p == nil { - return "" - } - - valueVal := fmt.Sprintf("%v", p.Value) - return fmt.Sprintf("Uri({Value:%s})", valueVal) -} - -// Changes the priority of this function (default NORMAL). -// -// Attributes: -// - Level -type Priority struct { - Level RpcPriority `thrift:"level,1" db:"level" json:"level"` -} - -func NewPriority() *Priority { - return &Priority{} -} - - -func (p *Priority) GetLevel() RpcPriority { - return p.Level -} -type PriorityBuilder struct { - obj *Priority -} - -func NewPriorityBuilder() *PriorityBuilder{ - return &PriorityBuilder{ - obj: NewPriority(), - } -} - -func (p PriorityBuilder) Emit() *Priority{ - return &Priority{ - Level: p.obj.Level, - } -} - -func (p *PriorityBuilder) Level(level RpcPriority) *PriorityBuilder { - p.obj.Level = level - return p -} - -func (p *Priority) SetLevel(level RpcPriority) *Priority { - p.Level = level - return p -} - -func (p *Priority) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Priority) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - temp := RpcPriority(v) - p.Level = temp - } - return nil -} - -func (p *Priority) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Priority"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Priority) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("level", thrift.I32, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:level: ", p), err) } - if err := oprot.WriteI32(int32(p.Level)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.level (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:level: ", p), err) } - return err -} - -func (p *Priority) String() string { - if p == nil { - return "" - } - - levelVal := fmt.Sprintf("%v", p.Level) - return fmt.Sprintf("Priority({Level:%s})", levelVal) -} - -// Applies unstructured annotations to a definition. -// -// Attributes: -// - Items -type DeprecatedUnvalidatedAnnotations struct { - Items map[string]string `thrift:"items,1" db:"items" json:"items"` -} - -func NewDeprecatedUnvalidatedAnnotations() *DeprecatedUnvalidatedAnnotations { - return &DeprecatedUnvalidatedAnnotations{} -} - - -func (p *DeprecatedUnvalidatedAnnotations) GetItems() map[string]string { - return p.Items -} -type DeprecatedUnvalidatedAnnotationsBuilder struct { - obj *DeprecatedUnvalidatedAnnotations -} - -func NewDeprecatedUnvalidatedAnnotationsBuilder() *DeprecatedUnvalidatedAnnotationsBuilder{ - return &DeprecatedUnvalidatedAnnotationsBuilder{ - obj: NewDeprecatedUnvalidatedAnnotations(), - } -} - -func (p DeprecatedUnvalidatedAnnotationsBuilder) Emit() *DeprecatedUnvalidatedAnnotations{ - return &DeprecatedUnvalidatedAnnotations{ - Items: p.obj.Items, - } -} - -func (d *DeprecatedUnvalidatedAnnotationsBuilder) Items(items map[string]string) *DeprecatedUnvalidatedAnnotationsBuilder { - d.obj.Items = items - return d -} - -func (d *DeprecatedUnvalidatedAnnotations) SetItems(items map[string]string) *DeprecatedUnvalidatedAnnotations { - d.Items = items - return d -} - -func (p *DeprecatedUnvalidatedAnnotations) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *DeprecatedUnvalidatedAnnotations) ReadField1(iprot thrift.Protocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[string]string, size) - p.Items = tMap - for i := 0; i < size; i ++ { - var _key3 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key3 = v - } - var _val4 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _val4 = v - } - p.Items[_key3] = _val4 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *DeprecatedUnvalidatedAnnotations) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("DeprecatedUnvalidatedAnnotations"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *DeprecatedUnvalidatedAnnotations) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("items", thrift.MAP, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:items: ", p), err) } - if err := oprot.WriteMapBegin(thrift.STRING, thrift.STRING, len(p.Items)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.Items { - if err := oprot.WriteString(string(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := oprot.WriteString(string(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:items: ", p), err) } - return err -} - -func (p *DeprecatedUnvalidatedAnnotations) String() string { - if p == nil { - return "" - } - - itemsVal := fmt.Sprintf("%v", p.Items) - return fmt.Sprintf("DeprecatedUnvalidatedAnnotations({Items:%s})", itemsVal) -} - diff --git a/thrift/compiler/test/fixtures/terse_write/gen-go/terse_write/constants.go b/thrift/compiler/test/fixtures/terse_write/gen-go/terse_write/constants.go deleted file mode 100644 index 029c6dcfa5f..00000000000 --- a/thrift/compiler/test/fixtures/terse_write/gen-go/terse_write/constants.go +++ /dev/null @@ -1,25 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package terse_write - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - - -func init() { -} - diff --git a/thrift/compiler/test/fixtures/terse_write/gen-go/terse_write/ttypes.go b/thrift/compiler/test/fixtures/terse_write/gen-go/terse_write/ttypes.go deleted file mode 100644 index f7dfc5ef1ff..00000000000 --- a/thrift/compiler/test/fixtures/terse_write/gen-go/terse_write/ttypes.go +++ /dev/null @@ -1,4790 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package terse_write - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var GoUnusedProtection__ int; - -type MyEnum int64 -const ( - MyEnum_ME0 MyEnum = 0 - MyEnum_ME1 MyEnum = 1 -) - -var MyEnumToName = map[MyEnum]string { - MyEnum_ME0: "ME0", - MyEnum_ME1: "ME1", -} - -var MyEnumToValue = map[string]MyEnum { - "ME0": MyEnum_ME0, - "ME1": MyEnum_ME1, -} - -var MyEnumNames = []string { - "ME0", - "ME1", -} - -var MyEnumValues = []MyEnum { - MyEnum_ME0, - MyEnum_ME1, -} - -func (p MyEnum) String() string { - if v, ok := MyEnumToName[p]; ok { - return v - } - return "" -} - -func MyEnumFromString(s string) (MyEnum, error) { - if v, ok := MyEnumToValue[s]; ok { - return v, nil - } - return MyEnum(0), fmt.Errorf("not a valid MyEnum string") -} - -func MyEnumPtr(v MyEnum) *MyEnum { return &v } - -type MyInteger = int32 - -func MyIntegerPtr(v MyInteger) *MyInteger { return &v } - -type MyStruct struct { -} - -func NewMyStruct() *MyStruct { - return &MyStruct{} -} - -type MyStructBuilder struct { - obj *MyStruct -} - -func NewMyStructBuilder() *MyStructBuilder{ - return &MyStructBuilder{ - obj: NewMyStruct(), - } -} - -func (p MyStructBuilder) Emit() *MyStruct{ - return &MyStruct{ - } -} - -func (p *MyStruct) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyStruct) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("MyStruct"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyStruct) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("MyStruct({})") -} - -// Attributes: -// - BoolField -// - ByteField -// - ShortField -// - IntField -// - LongField -// - FloatField -// - DoubleField -// - StringField -// - BinaryField -// - EnumField -// - ListField -// - SetField -// - MapField -// - StructField -type MyUnion struct { - BoolField *bool `thrift:"bool_field,1,optional" db:"bool_field" json:"bool_field,omitempty"` - ByteField *int8 `thrift:"byte_field,2,optional" db:"byte_field" json:"byte_field,omitempty"` - ShortField *int16 `thrift:"short_field,3,optional" db:"short_field" json:"short_field,omitempty"` - IntField *int32 `thrift:"int_field,4,optional" db:"int_field" json:"int_field,omitempty"` - LongField *int64 `thrift:"long_field,5,optional" db:"long_field" json:"long_field,omitempty"` - FloatField *float32 `thrift:"float_field,6,optional" db:"float_field" json:"float_field,omitempty"` - DoubleField *float64 `thrift:"double_field,7,optional" db:"double_field" json:"double_field,omitempty"` - StringField *string `thrift:"string_field,8,optional" db:"string_field" json:"string_field,omitempty"` - BinaryField []byte `thrift:"binary_field,9,optional" db:"binary_field" json:"binary_field,omitempty"` - EnumField *MyEnum `thrift:"enum_field,10,optional" db:"enum_field" json:"enum_field,omitempty"` - ListField []int16 `thrift:"list_field,11,optional" db:"list_field" json:"list_field,omitempty"` - SetField []int16 `thrift:"set_field,12,optional" db:"set_field" json:"set_field,omitempty"` - MapField map[int16]int16 `thrift:"map_field,13,optional" db:"map_field" json:"map_field,omitempty"` - StructField *MyStruct `thrift:"struct_field,14,optional" db:"struct_field" json:"struct_field,omitempty"` -} - -func NewMyUnion() *MyUnion { - return &MyUnion{} -} - -var MyUnion_BoolField_DEFAULT bool -func (p *MyUnion) GetBoolField() bool { - if !p.IsSetBoolField() { - return MyUnion_BoolField_DEFAULT - } - return *p.BoolField -} -var MyUnion_ByteField_DEFAULT int8 -func (p *MyUnion) GetByteField() int8 { - if !p.IsSetByteField() { - return MyUnion_ByteField_DEFAULT - } - return *p.ByteField -} -var MyUnion_ShortField_DEFAULT int16 -func (p *MyUnion) GetShortField() int16 { - if !p.IsSetShortField() { - return MyUnion_ShortField_DEFAULT - } - return *p.ShortField -} -var MyUnion_IntField_DEFAULT int32 -func (p *MyUnion) GetIntField() int32 { - if !p.IsSetIntField() { - return MyUnion_IntField_DEFAULT - } - return *p.IntField -} -var MyUnion_LongField_DEFAULT int64 -func (p *MyUnion) GetLongField() int64 { - if !p.IsSetLongField() { - return MyUnion_LongField_DEFAULT - } - return *p.LongField -} -var MyUnion_FloatField_DEFAULT float32 -func (p *MyUnion) GetFloatField() float32 { - if !p.IsSetFloatField() { - return MyUnion_FloatField_DEFAULT - } - return *p.FloatField -} -var MyUnion_DoubleField_DEFAULT float64 -func (p *MyUnion) GetDoubleField() float64 { - if !p.IsSetDoubleField() { - return MyUnion_DoubleField_DEFAULT - } - return *p.DoubleField -} -var MyUnion_StringField_DEFAULT string -func (p *MyUnion) GetStringField() string { - if !p.IsSetStringField() { - return MyUnion_StringField_DEFAULT - } - return *p.StringField -} -var MyUnion_BinaryField_DEFAULT []byte - -func (p *MyUnion) GetBinaryField() []byte { - return p.BinaryField -} -var MyUnion_EnumField_DEFAULT MyEnum -func (p *MyUnion) GetEnumField() MyEnum { - if !p.IsSetEnumField() { - return MyUnion_EnumField_DEFAULT - } - return *p.EnumField -} -var MyUnion_ListField_DEFAULT []int16 - -func (p *MyUnion) GetListField() []int16 { - return p.ListField -} -var MyUnion_SetField_DEFAULT []int16 - -func (p *MyUnion) GetSetField() []int16 { - return p.SetField -} -var MyUnion_MapField_DEFAULT map[int16]int16 - -func (p *MyUnion) GetMapField() map[int16]int16 { - return p.MapField -} -var MyUnion_StructField_DEFAULT *MyStruct -func (p *MyUnion) GetStructField() *MyStruct { - if !p.IsSetStructField() { - return MyUnion_StructField_DEFAULT - } - return p.StructField -} -func (p *MyUnion) DefaultGetStructField() *MyStruct { - if !p.IsSetStructField() { - return NewMyStruct() - } - return p.StructField -} -func (p *MyUnion) CountSetFieldsMyUnion() int { - count := 0 - if (p.IsSetBoolField()) { - count++ - } - if (p.IsSetByteField()) { - count++ - } - if (p.IsSetShortField()) { - count++ - } - if (p.IsSetIntField()) { - count++ - } - if (p.IsSetLongField()) { - count++ - } - if (p.IsSetFloatField()) { - count++ - } - if (p.IsSetDoubleField()) { - count++ - } - if (p.IsSetStringField()) { - count++ - } - if (p.IsSetBinaryField()) { - count++ - } - if (p.IsSetEnumField()) { - count++ - } - if (p.IsSetListField()) { - count++ - } - if (p.IsSetSetField()) { - count++ - } - if (p.IsSetMapField()) { - count++ - } - if (p.IsSetStructField()) { - count++ - } - return count - -} - -func (p *MyUnion) IsSetBoolField() bool { - return p != nil && p.BoolField != nil -} - -func (p *MyUnion) IsSetByteField() bool { - return p != nil && p.ByteField != nil -} - -func (p *MyUnion) IsSetShortField() bool { - return p != nil && p.ShortField != nil -} - -func (p *MyUnion) IsSetIntField() bool { - return p != nil && p.IntField != nil -} - -func (p *MyUnion) IsSetLongField() bool { - return p != nil && p.LongField != nil -} - -func (p *MyUnion) IsSetFloatField() bool { - return p != nil && p.FloatField != nil -} - -func (p *MyUnion) IsSetDoubleField() bool { - return p != nil && p.DoubleField != nil -} - -func (p *MyUnion) IsSetStringField() bool { - return p != nil && p.StringField != nil -} - -func (p *MyUnion) IsSetBinaryField() bool { - return p != nil && p.BinaryField != nil -} - -func (p *MyUnion) IsSetEnumField() bool { - return p != nil && p.EnumField != nil -} - -func (p *MyUnion) IsSetListField() bool { - return p != nil && p.ListField != nil -} - -func (p *MyUnion) IsSetSetField() bool { - return p != nil && p.SetField != nil -} - -func (p *MyUnion) IsSetMapField() bool { - return p != nil && p.MapField != nil -} - -func (p *MyUnion) IsSetStructField() bool { - return p != nil && p.StructField != nil -} - -type MyUnionBuilder struct { - obj *MyUnion -} - -func NewMyUnionBuilder() *MyUnionBuilder{ - return &MyUnionBuilder{ - obj: NewMyUnion(), - } -} - -func (p MyUnionBuilder) Emit() *MyUnion{ - return &MyUnion{ - BoolField: p.obj.BoolField, - ByteField: p.obj.ByteField, - ShortField: p.obj.ShortField, - IntField: p.obj.IntField, - LongField: p.obj.LongField, - FloatField: p.obj.FloatField, - DoubleField: p.obj.DoubleField, - StringField: p.obj.StringField, - BinaryField: p.obj.BinaryField, - EnumField: p.obj.EnumField, - ListField: p.obj.ListField, - SetField: p.obj.SetField, - MapField: p.obj.MapField, - StructField: p.obj.StructField, - } -} - -func (m *MyUnionBuilder) BoolField(boolField *bool) *MyUnionBuilder { - m.obj.BoolField = boolField - return m -} - -func (m *MyUnionBuilder) ByteField(byteField *int8) *MyUnionBuilder { - m.obj.ByteField = byteField - return m -} - -func (m *MyUnionBuilder) ShortField(shortField *int16) *MyUnionBuilder { - m.obj.ShortField = shortField - return m -} - -func (m *MyUnionBuilder) IntField(intField *int32) *MyUnionBuilder { - m.obj.IntField = intField - return m -} - -func (m *MyUnionBuilder) LongField(longField *int64) *MyUnionBuilder { - m.obj.LongField = longField - return m -} - -func (m *MyUnionBuilder) FloatField(floatField *float32) *MyUnionBuilder { - m.obj.FloatField = floatField - return m -} - -func (m *MyUnionBuilder) DoubleField(doubleField *float64) *MyUnionBuilder { - m.obj.DoubleField = doubleField - return m -} - -func (m *MyUnionBuilder) StringField(stringField *string) *MyUnionBuilder { - m.obj.StringField = stringField - return m -} - -func (m *MyUnionBuilder) BinaryField(binaryField []byte) *MyUnionBuilder { - m.obj.BinaryField = binaryField - return m -} - -func (m *MyUnionBuilder) EnumField(enumField *MyEnum) *MyUnionBuilder { - m.obj.EnumField = enumField - return m -} - -func (m *MyUnionBuilder) ListField(listField []int16) *MyUnionBuilder { - m.obj.ListField = listField - return m -} - -func (m *MyUnionBuilder) SetField(setField []int16) *MyUnionBuilder { - m.obj.SetField = setField - return m -} - -func (m *MyUnionBuilder) MapField(mapField map[int16]int16) *MyUnionBuilder { - m.obj.MapField = mapField - return m -} - -func (m *MyUnionBuilder) StructField(structField *MyStruct) *MyUnionBuilder { - m.obj.StructField = structField - return m -} - -func (m *MyUnion) SetBoolField(boolField *bool) *MyUnion { - m.BoolField = boolField - return m -} - -func (m *MyUnion) SetByteField(byteField *int8) *MyUnion { - m.ByteField = byteField - return m -} - -func (m *MyUnion) SetShortField(shortField *int16) *MyUnion { - m.ShortField = shortField - return m -} - -func (m *MyUnion) SetIntField(intField *int32) *MyUnion { - m.IntField = intField - return m -} - -func (m *MyUnion) SetLongField(longField *int64) *MyUnion { - m.LongField = longField - return m -} - -func (m *MyUnion) SetFloatField(floatField *float32) *MyUnion { - m.FloatField = floatField - return m -} - -func (m *MyUnion) SetDoubleField(doubleField *float64) *MyUnion { - m.DoubleField = doubleField - return m -} - -func (m *MyUnion) SetStringField(stringField *string) *MyUnion { - m.StringField = stringField - return m -} - -func (m *MyUnion) SetBinaryField(binaryField []byte) *MyUnion { - m.BinaryField = binaryField - return m -} - -func (m *MyUnion) SetEnumField(enumField *MyEnum) *MyUnion { - m.EnumField = enumField - return m -} - -func (m *MyUnion) SetListField(listField []int16) *MyUnion { - m.ListField = listField - return m -} - -func (m *MyUnion) SetSetField(setField []int16) *MyUnion { - m.SetField = setField - return m -} - -func (m *MyUnion) SetMapField(mapField map[int16]int16) *MyUnion { - m.MapField = mapField - return m -} - -func (m *MyUnion) SetStructField(structField *MyStruct) *MyUnion { - m.StructField = structField - return m -} - -func (p *MyUnion) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 3: - if err := p.ReadField3(iprot); err != nil { - return err - } - case 4: - if err := p.ReadField4(iprot); err != nil { - return err - } - case 5: - if err := p.ReadField5(iprot); err != nil { - return err - } - case 6: - if err := p.ReadField6(iprot); err != nil { - return err - } - case 7: - if err := p.ReadField7(iprot); err != nil { - return err - } - case 8: - if err := p.ReadField8(iprot); err != nil { - return err - } - case 9: - if err := p.ReadField9(iprot); err != nil { - return err - } - case 10: - if err := p.ReadField10(iprot); err != nil { - return err - } - case 11: - if err := p.ReadField11(iprot); err != nil { - return err - } - case 12: - if err := p.ReadField12(iprot); err != nil { - return err - } - case 13: - if err := p.ReadField13(iprot); err != nil { - return err - } - case 14: - if err := p.ReadField14(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyUnion) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.BoolField = &v - } - return nil -} - -func (p *MyUnion) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadByte(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - temp := int8(v) - p.ByteField = &temp - } - return nil -} - -func (p *MyUnion) ReadField3(iprot thrift.Protocol) error { - if v, err := iprot.ReadI16(); err != nil { - return thrift.PrependError("error reading field 3: ", err) - } else { - p.ShortField = &v - } - return nil -} - -func (p *MyUnion) ReadField4(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 4: ", err) - } else { - p.IntField = &v - } - return nil -} - -func (p *MyUnion) ReadField5(iprot thrift.Protocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 5: ", err) - } else { - p.LongField = &v - } - return nil -} - -func (p *MyUnion) ReadField6(iprot thrift.Protocol) error { - if v, err := iprot.ReadFloat(); err != nil { - return thrift.PrependError("error reading field 6: ", err) - } else { - p.FloatField = &v - } - return nil -} - -func (p *MyUnion) ReadField7(iprot thrift.Protocol) error { - if v, err := iprot.ReadDouble(); err != nil { - return thrift.PrependError("error reading field 7: ", err) - } else { - p.DoubleField = &v - } - return nil -} - -func (p *MyUnion) ReadField8(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 8: ", err) - } else { - p.StringField = &v - } - return nil -} - -func (p *MyUnion) ReadField9(iprot thrift.Protocol) error { - if v, err := iprot.ReadBinary(); err != nil { - return thrift.PrependError("error reading field 9: ", err) - } else { - p.BinaryField = v - } - return nil -} - -func (p *MyUnion) ReadField10(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 10: ", err) - } else { - temp := MyEnum(v) - p.EnumField = &temp - } - return nil -} - -func (p *MyUnion) ReadField11(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]int16, 0, size) - p.ListField = tSlice - for i := 0; i < size; i ++ { - var _elem0 int16 - if v, err := iprot.ReadI16(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem0 = v - } - p.ListField = append(p.ListField, _elem0) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *MyUnion) ReadField12(iprot thrift.Protocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return thrift.PrependError("error reading set begin: ", err) - } - tSet := make([]int16, 0, size) - p.SetField = tSet - for i := 0; i < size; i ++ { - var _elem1 int16 - if v, err := iprot.ReadI16(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem1 = v - } - p.SetField = append(p.SetField, _elem1) - } - if err := iprot.ReadSetEnd(); err != nil { - return thrift.PrependError("error reading set end: ", err) - } - return nil -} - -func (p *MyUnion) ReadField13(iprot thrift.Protocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[int16]int16, size) - p.MapField = tMap - for i := 0; i < size; i ++ { - var _key2 int16 - if v, err := iprot.ReadI16(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key2 = v - } - var _val3 int16 - if v, err := iprot.ReadI16(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _val3 = v - } - p.MapField[_key2] = _val3 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *MyUnion) ReadField14(iprot thrift.Protocol) error { - p.StructField = NewMyStruct() - if err := p.StructField.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.StructField), err) - } - return nil -} - -func (p *MyUnion) Write(oprot thrift.Protocol) error { - if c := p.CountSetFieldsMyUnion(); c > 1 { - return fmt.Errorf("%T write union: no more than one field must be set (%d set).", p, c) - } - if err := oprot.WriteStructBegin("MyUnion"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := p.writeField4(oprot); err != nil { return err } - if err := p.writeField5(oprot); err != nil { return err } - if err := p.writeField6(oprot); err != nil { return err } - if err := p.writeField7(oprot); err != nil { return err } - if err := p.writeField8(oprot); err != nil { return err } - if err := p.writeField9(oprot); err != nil { return err } - if err := p.writeField10(oprot); err != nil { return err } - if err := p.writeField11(oprot); err != nil { return err } - if err := p.writeField12(oprot); err != nil { return err } - if err := p.writeField13(oprot); err != nil { return err } - if err := p.writeField14(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyUnion) writeField1(oprot thrift.Protocol) (err error) { - if p.IsSetBoolField() { - if err := oprot.WriteFieldBegin("bool_field", thrift.BOOL, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:bool_field: ", p), err) } - if err := oprot.WriteBool(bool(*p.BoolField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.bool_field (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:bool_field: ", p), err) } - } - return err -} - -func (p *MyUnion) writeField2(oprot thrift.Protocol) (err error) { - if p.IsSetByteField() { - if err := oprot.WriteFieldBegin("byte_field", thrift.BYTE, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:byte_field: ", p), err) } - if err := oprot.WriteByte(byte(*p.ByteField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.byte_field (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:byte_field: ", p), err) } - } - return err -} - -func (p *MyUnion) writeField3(oprot thrift.Protocol) (err error) { - if p.IsSetShortField() { - if err := oprot.WriteFieldBegin("short_field", thrift.I16, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:short_field: ", p), err) } - if err := oprot.WriteI16(int16(*p.ShortField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.short_field (3) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:short_field: ", p), err) } - } - return err -} - -func (p *MyUnion) writeField4(oprot thrift.Protocol) (err error) { - if p.IsSetIntField() { - if err := oprot.WriteFieldBegin("int_field", thrift.I32, 4); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:int_field: ", p), err) } - if err := oprot.WriteI32(int32(*p.IntField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.int_field (4) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 4:int_field: ", p), err) } - } - return err -} - -func (p *MyUnion) writeField5(oprot thrift.Protocol) (err error) { - if p.IsSetLongField() { - if err := oprot.WriteFieldBegin("long_field", thrift.I64, 5); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:long_field: ", p), err) } - if err := oprot.WriteI64(int64(*p.LongField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.long_field (5) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 5:long_field: ", p), err) } - } - return err -} - -func (p *MyUnion) writeField6(oprot thrift.Protocol) (err error) { - if p.IsSetFloatField() { - if err := oprot.WriteFieldBegin("float_field", thrift.FLOAT, 6); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 6:float_field: ", p), err) } - if err := oprot.WriteFloat(float32(*p.FloatField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.float_field (6) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 6:float_field: ", p), err) } - } - return err -} - -func (p *MyUnion) writeField7(oprot thrift.Protocol) (err error) { - if p.IsSetDoubleField() { - if err := oprot.WriteFieldBegin("double_field", thrift.DOUBLE, 7); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 7:double_field: ", p), err) } - if err := oprot.WriteDouble(float64(*p.DoubleField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.double_field (7) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 7:double_field: ", p), err) } - } - return err -} - -func (p *MyUnion) writeField8(oprot thrift.Protocol) (err error) { - if p.IsSetStringField() { - if err := oprot.WriteFieldBegin("string_field", thrift.STRING, 8); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 8:string_field: ", p), err) } - if err := oprot.WriteString(string(*p.StringField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.string_field (8) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 8:string_field: ", p), err) } - } - return err -} - -func (p *MyUnion) writeField9(oprot thrift.Protocol) (err error) { - if p.IsSetBinaryField() { - if err := oprot.WriteFieldBegin("binary_field", thrift.STRING, 9); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 9:binary_field: ", p), err) } - if err := oprot.WriteBinary(p.BinaryField); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.binary_field (9) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 9:binary_field: ", p), err) } - } - return err -} - -func (p *MyUnion) writeField10(oprot thrift.Protocol) (err error) { - if p.IsSetEnumField() { - if err := oprot.WriteFieldBegin("enum_field", thrift.I32, 10); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 10:enum_field: ", p), err) } - if err := oprot.WriteI32(int32(*p.EnumField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.enum_field (10) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 10:enum_field: ", p), err) } - } - return err -} - -func (p *MyUnion) writeField11(oprot thrift.Protocol) (err error) { - if p.IsSetListField() { - if err := oprot.WriteFieldBegin("list_field", thrift.LIST, 11); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 11:list_field: ", p), err) } - if err := oprot.WriteListBegin(thrift.I16, len(p.ListField)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.ListField { - if err := oprot.WriteI16(int16(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 11:list_field: ", p), err) } - } - return err -} - -func (p *MyUnion) writeField12(oprot thrift.Protocol) (err error) { - if p.IsSetSetField() { - if err := oprot.WriteFieldBegin("set_field", thrift.SET, 12); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 12:set_field: ", p), err) } - if err := oprot.WriteSetBegin(thrift.I16, len(p.SetField)); err != nil { - return thrift.PrependError("error writing set begin: ", err) - } - set := make(map[int16]bool, len(p.SetField)) - for _, v := range p.SetField { - if ok := set[v]; ok { - return thrift.PrependError("", fmt.Errorf("%T error writing set field: slice is not unique", v)) - } - set[v] = true - } - for _, v := range p.SetField { - if err := oprot.WriteI16(int16(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteSetEnd(); err != nil { - return thrift.PrependError("error writing set end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 12:set_field: ", p), err) } - } - return err -} - -func (p *MyUnion) writeField13(oprot thrift.Protocol) (err error) { - if p.IsSetMapField() { - if err := oprot.WriteFieldBegin("map_field", thrift.MAP, 13); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 13:map_field: ", p), err) } - if err := oprot.WriteMapBegin(thrift.I16, thrift.I16, len(p.MapField)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.MapField { - if err := oprot.WriteI16(int16(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := oprot.WriteI16(int16(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 13:map_field: ", p), err) } - } - return err -} - -func (p *MyUnion) writeField14(oprot thrift.Protocol) (err error) { - if p.IsSetStructField() { - if err := oprot.WriteFieldBegin("struct_field", thrift.STRUCT, 14); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 14:struct_field: ", p), err) } - if err := p.StructField.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.StructField), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 14:struct_field: ", p), err) } - } - return err -} - -func (p *MyUnion) String() string { - if p == nil { - return "" - } - - var boolFieldVal string - if p.BoolField == nil { - boolFieldVal = "" - } else { - boolFieldVal = fmt.Sprintf("%v", *p.BoolField) - } - var byteFieldVal string - if p.ByteField == nil { - byteFieldVal = "" - } else { - byteFieldVal = fmt.Sprintf("%v", *p.ByteField) - } - var shortFieldVal string - if p.ShortField == nil { - shortFieldVal = "" - } else { - shortFieldVal = fmt.Sprintf("%v", *p.ShortField) - } - var intFieldVal string - if p.IntField == nil { - intFieldVal = "" - } else { - intFieldVal = fmt.Sprintf("%v", *p.IntField) - } - var longFieldVal string - if p.LongField == nil { - longFieldVal = "" - } else { - longFieldVal = fmt.Sprintf("%v", *p.LongField) - } - var floatFieldVal string - if p.FloatField == nil { - floatFieldVal = "" - } else { - floatFieldVal = fmt.Sprintf("%v", *p.FloatField) - } - var doubleFieldVal string - if p.DoubleField == nil { - doubleFieldVal = "" - } else { - doubleFieldVal = fmt.Sprintf("%v", *p.DoubleField) - } - var stringFieldVal string - if p.StringField == nil { - stringFieldVal = "" - } else { - stringFieldVal = fmt.Sprintf("%v", *p.StringField) - } - binaryFieldVal := fmt.Sprintf("%v", p.BinaryField) - var enumFieldVal string - if p.EnumField == nil { - enumFieldVal = "" - } else { - enumFieldVal = fmt.Sprintf("%v", *p.EnumField) - } - listFieldVal := fmt.Sprintf("%v", p.ListField) - setFieldVal := fmt.Sprintf("%v", p.SetField) - mapFieldVal := fmt.Sprintf("%v", p.MapField) - var structFieldVal string - if p.StructField == nil { - structFieldVal = "" - } else { - structFieldVal = fmt.Sprintf("%v", p.StructField) - } - return fmt.Sprintf("MyUnion({BoolField:%s ByteField:%s ShortField:%s IntField:%s LongField:%s FloatField:%s DoubleField:%s StringField:%s BinaryField:%s EnumField:%s ListField:%s SetField:%s MapField:%s StructField:%s})", boolFieldVal, byteFieldVal, shortFieldVal, intFieldVal, longFieldVal, floatFieldVal, doubleFieldVal, stringFieldVal, binaryFieldVal, enumFieldVal, listFieldVal, setFieldVal, mapFieldVal, structFieldVal) -} - -// Attributes: -// - Field1 -type MyStructWithCustomDefault struct { - Field1 int64 `thrift:"field1,1" db:"field1" json:"field1"` -} - -func NewMyStructWithCustomDefault() *MyStructWithCustomDefault { - return &MyStructWithCustomDefault{ - Field1: 1, - } -} - - -func (p *MyStructWithCustomDefault) GetField1() int64 { - return p.Field1 -} -type MyStructWithCustomDefaultBuilder struct { - obj *MyStructWithCustomDefault -} - -func NewMyStructWithCustomDefaultBuilder() *MyStructWithCustomDefaultBuilder{ - return &MyStructWithCustomDefaultBuilder{ - obj: NewMyStructWithCustomDefault(), - } -} - -func (p MyStructWithCustomDefaultBuilder) Emit() *MyStructWithCustomDefault{ - return &MyStructWithCustomDefault{ - Field1: p.obj.Field1, - } -} - -func (m *MyStructWithCustomDefaultBuilder) Field1(field1 int64) *MyStructWithCustomDefaultBuilder { - m.obj.Field1 = field1 - return m -} - -func (m *MyStructWithCustomDefault) SetField1(field1 int64) *MyStructWithCustomDefault { - m.Field1 = field1 - return m -} - -func (p *MyStructWithCustomDefault) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyStructWithCustomDefault) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Field1 = v - } - return nil -} - -func (p *MyStructWithCustomDefault) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("MyStructWithCustomDefault"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyStructWithCustomDefault) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("field1", thrift.I64, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:field1: ", p), err) } - if err := oprot.WriteI64(int64(p.Field1)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.field1 (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:field1: ", p), err) } - return err -} - -func (p *MyStructWithCustomDefault) String() string { - if p == nil { - return "" - } - - field1Val := fmt.Sprintf("%v", p.Field1) - return fmt.Sprintf("MyStructWithCustomDefault({Field1:%s})", field1Val) -} - -// Attributes: -// - BoolField -// - ByteField -// - ShortField -// - IntField -// - LongField -// - FloatField -// - DoubleField -// - StringField -// - BinaryField -// - EnumField -// - ListField -// - SetField -// - MapField -// - StructField -// - UnionField -type StructLevelTerseStruct struct { - BoolField bool `thrift:"bool_field,1" db:"bool_field" json:"bool_field"` - ByteField int8 `thrift:"byte_field,2" db:"byte_field" json:"byte_field"` - ShortField int16 `thrift:"short_field,3" db:"short_field" json:"short_field"` - IntField int32 `thrift:"int_field,4" db:"int_field" json:"int_field"` - LongField int64 `thrift:"long_field,5" db:"long_field" json:"long_field"` - FloatField float32 `thrift:"float_field,6" db:"float_field" json:"float_field"` - DoubleField float64 `thrift:"double_field,7" db:"double_field" json:"double_field"` - StringField string `thrift:"string_field,8" db:"string_field" json:"string_field"` - BinaryField []byte `thrift:"binary_field,9" db:"binary_field" json:"binary_field"` - EnumField MyEnum `thrift:"enum_field,10" db:"enum_field" json:"enum_field"` - ListField []int16 `thrift:"list_field,11" db:"list_field" json:"list_field"` - SetField []int16 `thrift:"set_field,12" db:"set_field" json:"set_field"` - MapField map[int16]int16 `thrift:"map_field,13" db:"map_field" json:"map_field"` - StructField *MyStruct `thrift:"struct_field,14" db:"struct_field" json:"struct_field"` - UnionField *MyUnion `thrift:"union_field,15" db:"union_field" json:"union_field"` -} - -func NewStructLevelTerseStruct() *StructLevelTerseStruct { - return &StructLevelTerseStruct{ - StructField: NewMyStruct(), - } -} - - -func (p *StructLevelTerseStruct) GetBoolField() bool { - return p.BoolField -} - -func (p *StructLevelTerseStruct) GetByteField() int8 { - return p.ByteField -} - -func (p *StructLevelTerseStruct) GetShortField() int16 { - return p.ShortField -} - -func (p *StructLevelTerseStruct) GetIntField() int32 { - return p.IntField -} - -func (p *StructLevelTerseStruct) GetLongField() int64 { - return p.LongField -} - -func (p *StructLevelTerseStruct) GetFloatField() float32 { - return p.FloatField -} - -func (p *StructLevelTerseStruct) GetDoubleField() float64 { - return p.DoubleField -} - -func (p *StructLevelTerseStruct) GetStringField() string { - return p.StringField -} - -func (p *StructLevelTerseStruct) GetBinaryField() []byte { - return p.BinaryField -} - -func (p *StructLevelTerseStruct) GetEnumField() MyEnum { - return p.EnumField -} - -func (p *StructLevelTerseStruct) GetListField() []int16 { - return p.ListField -} - -func (p *StructLevelTerseStruct) GetSetField() []int16 { - return p.SetField -} - -func (p *StructLevelTerseStruct) GetMapField() map[int16]int16 { - return p.MapField -} -var StructLevelTerseStruct_StructField_DEFAULT *MyStruct -func (p *StructLevelTerseStruct) GetStructField() *MyStruct { - if !p.IsSetStructField() { - return StructLevelTerseStruct_StructField_DEFAULT - } - return p.StructField -} -func (p *StructLevelTerseStruct) DefaultGetStructField() *MyStruct { - if !p.IsSetStructField() { - return NewMyStruct() - } - return p.StructField -} -var StructLevelTerseStruct_UnionField_DEFAULT *MyUnion -func (p *StructLevelTerseStruct) GetUnionField() *MyUnion { - if !p.IsSetUnionField() { - return StructLevelTerseStruct_UnionField_DEFAULT - } - return p.UnionField -} -func (p *StructLevelTerseStruct) DefaultGetUnionField() *MyUnion { - if !p.IsSetUnionField() { - return NewMyUnion() - } - return p.UnionField -} -func (p *StructLevelTerseStruct) IsSetStructField() bool { - return p != nil && p.StructField != nil -} - -func (p *StructLevelTerseStruct) IsSetUnionField() bool { - return p != nil && p.UnionField != nil -} - -type StructLevelTerseStructBuilder struct { - obj *StructLevelTerseStruct -} - -func NewStructLevelTerseStructBuilder() *StructLevelTerseStructBuilder{ - return &StructLevelTerseStructBuilder{ - obj: NewStructLevelTerseStruct(), - } -} - -func (p StructLevelTerseStructBuilder) Emit() *StructLevelTerseStruct{ - return &StructLevelTerseStruct{ - BoolField: p.obj.BoolField, - ByteField: p.obj.ByteField, - ShortField: p.obj.ShortField, - IntField: p.obj.IntField, - LongField: p.obj.LongField, - FloatField: p.obj.FloatField, - DoubleField: p.obj.DoubleField, - StringField: p.obj.StringField, - BinaryField: p.obj.BinaryField, - EnumField: p.obj.EnumField, - ListField: p.obj.ListField, - SetField: p.obj.SetField, - MapField: p.obj.MapField, - StructField: p.obj.StructField, - UnionField: p.obj.UnionField, - } -} - -func (s *StructLevelTerseStructBuilder) BoolField(boolField bool) *StructLevelTerseStructBuilder { - s.obj.BoolField = boolField - return s -} - -func (s *StructLevelTerseStructBuilder) ByteField(byteField int8) *StructLevelTerseStructBuilder { - s.obj.ByteField = byteField - return s -} - -func (s *StructLevelTerseStructBuilder) ShortField(shortField int16) *StructLevelTerseStructBuilder { - s.obj.ShortField = shortField - return s -} - -func (s *StructLevelTerseStructBuilder) IntField(intField int32) *StructLevelTerseStructBuilder { - s.obj.IntField = intField - return s -} - -func (s *StructLevelTerseStructBuilder) LongField(longField int64) *StructLevelTerseStructBuilder { - s.obj.LongField = longField - return s -} - -func (s *StructLevelTerseStructBuilder) FloatField(floatField float32) *StructLevelTerseStructBuilder { - s.obj.FloatField = floatField - return s -} - -func (s *StructLevelTerseStructBuilder) DoubleField(doubleField float64) *StructLevelTerseStructBuilder { - s.obj.DoubleField = doubleField - return s -} - -func (s *StructLevelTerseStructBuilder) StringField(stringField string) *StructLevelTerseStructBuilder { - s.obj.StringField = stringField - return s -} - -func (s *StructLevelTerseStructBuilder) BinaryField(binaryField []byte) *StructLevelTerseStructBuilder { - s.obj.BinaryField = binaryField - return s -} - -func (s *StructLevelTerseStructBuilder) EnumField(enumField MyEnum) *StructLevelTerseStructBuilder { - s.obj.EnumField = enumField - return s -} - -func (s *StructLevelTerseStructBuilder) ListField(listField []int16) *StructLevelTerseStructBuilder { - s.obj.ListField = listField - return s -} - -func (s *StructLevelTerseStructBuilder) SetField(setField []int16) *StructLevelTerseStructBuilder { - s.obj.SetField = setField - return s -} - -func (s *StructLevelTerseStructBuilder) MapField(mapField map[int16]int16) *StructLevelTerseStructBuilder { - s.obj.MapField = mapField - return s -} - -func (s *StructLevelTerseStructBuilder) StructField(structField *MyStruct) *StructLevelTerseStructBuilder { - s.obj.StructField = structField - return s -} - -func (s *StructLevelTerseStructBuilder) UnionField(unionField *MyUnion) *StructLevelTerseStructBuilder { - s.obj.UnionField = unionField - return s -} - -func (s *StructLevelTerseStruct) SetBoolField(boolField bool) *StructLevelTerseStruct { - s.BoolField = boolField - return s -} - -func (s *StructLevelTerseStruct) SetByteField(byteField int8) *StructLevelTerseStruct { - s.ByteField = byteField - return s -} - -func (s *StructLevelTerseStruct) SetShortField(shortField int16) *StructLevelTerseStruct { - s.ShortField = shortField - return s -} - -func (s *StructLevelTerseStruct) SetIntField(intField int32) *StructLevelTerseStruct { - s.IntField = intField - return s -} - -func (s *StructLevelTerseStruct) SetLongField(longField int64) *StructLevelTerseStruct { - s.LongField = longField - return s -} - -func (s *StructLevelTerseStruct) SetFloatField(floatField float32) *StructLevelTerseStruct { - s.FloatField = floatField - return s -} - -func (s *StructLevelTerseStruct) SetDoubleField(doubleField float64) *StructLevelTerseStruct { - s.DoubleField = doubleField - return s -} - -func (s *StructLevelTerseStruct) SetStringField(stringField string) *StructLevelTerseStruct { - s.StringField = stringField - return s -} - -func (s *StructLevelTerseStruct) SetBinaryField(binaryField []byte) *StructLevelTerseStruct { - s.BinaryField = binaryField - return s -} - -func (s *StructLevelTerseStruct) SetEnumField(enumField MyEnum) *StructLevelTerseStruct { - s.EnumField = enumField - return s -} - -func (s *StructLevelTerseStruct) SetListField(listField []int16) *StructLevelTerseStruct { - s.ListField = listField - return s -} - -func (s *StructLevelTerseStruct) SetSetField(setField []int16) *StructLevelTerseStruct { - s.SetField = setField - return s -} - -func (s *StructLevelTerseStruct) SetMapField(mapField map[int16]int16) *StructLevelTerseStruct { - s.MapField = mapField - return s -} - -func (s *StructLevelTerseStruct) SetStructField(structField *MyStruct) *StructLevelTerseStruct { - s.StructField = structField - return s -} - -func (s *StructLevelTerseStruct) SetUnionField(unionField *MyUnion) *StructLevelTerseStruct { - s.UnionField = unionField - return s -} - -func (p *StructLevelTerseStruct) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 3: - if err := p.ReadField3(iprot); err != nil { - return err - } - case 4: - if err := p.ReadField4(iprot); err != nil { - return err - } - case 5: - if err := p.ReadField5(iprot); err != nil { - return err - } - case 6: - if err := p.ReadField6(iprot); err != nil { - return err - } - case 7: - if err := p.ReadField7(iprot); err != nil { - return err - } - case 8: - if err := p.ReadField8(iprot); err != nil { - return err - } - case 9: - if err := p.ReadField9(iprot); err != nil { - return err - } - case 10: - if err := p.ReadField10(iprot); err != nil { - return err - } - case 11: - if err := p.ReadField11(iprot); err != nil { - return err - } - case 12: - if err := p.ReadField12(iprot); err != nil { - return err - } - case 13: - if err := p.ReadField13(iprot); err != nil { - return err - } - case 14: - if err := p.ReadField14(iprot); err != nil { - return err - } - case 15: - if err := p.ReadField15(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *StructLevelTerseStruct) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.BoolField = v - } - return nil -} - -func (p *StructLevelTerseStruct) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadByte(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - temp := int8(v) - p.ByteField = temp - } - return nil -} - -func (p *StructLevelTerseStruct) ReadField3(iprot thrift.Protocol) error { - if v, err := iprot.ReadI16(); err != nil { - return thrift.PrependError("error reading field 3: ", err) - } else { - p.ShortField = v - } - return nil -} - -func (p *StructLevelTerseStruct) ReadField4(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 4: ", err) - } else { - p.IntField = v - } - return nil -} - -func (p *StructLevelTerseStruct) ReadField5(iprot thrift.Protocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 5: ", err) - } else { - p.LongField = v - } - return nil -} - -func (p *StructLevelTerseStruct) ReadField6(iprot thrift.Protocol) error { - if v, err := iprot.ReadFloat(); err != nil { - return thrift.PrependError("error reading field 6: ", err) - } else { - p.FloatField = v - } - return nil -} - -func (p *StructLevelTerseStruct) ReadField7(iprot thrift.Protocol) error { - if v, err := iprot.ReadDouble(); err != nil { - return thrift.PrependError("error reading field 7: ", err) - } else { - p.DoubleField = v - } - return nil -} - -func (p *StructLevelTerseStruct) ReadField8(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 8: ", err) - } else { - p.StringField = v - } - return nil -} - -func (p *StructLevelTerseStruct) ReadField9(iprot thrift.Protocol) error { - if v, err := iprot.ReadBinary(); err != nil { - return thrift.PrependError("error reading field 9: ", err) - } else { - p.BinaryField = v - } - return nil -} - -func (p *StructLevelTerseStruct) ReadField10(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 10: ", err) - } else { - temp := MyEnum(v) - p.EnumField = temp - } - return nil -} - -func (p *StructLevelTerseStruct) ReadField11(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]int16, 0, size) - p.ListField = tSlice - for i := 0; i < size; i ++ { - var _elem4 int16 - if v, err := iprot.ReadI16(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem4 = v - } - p.ListField = append(p.ListField, _elem4) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *StructLevelTerseStruct) ReadField12(iprot thrift.Protocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return thrift.PrependError("error reading set begin: ", err) - } - tSet := make([]int16, 0, size) - p.SetField = tSet - for i := 0; i < size; i ++ { - var _elem5 int16 - if v, err := iprot.ReadI16(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem5 = v - } - p.SetField = append(p.SetField, _elem5) - } - if err := iprot.ReadSetEnd(); err != nil { - return thrift.PrependError("error reading set end: ", err) - } - return nil -} - -func (p *StructLevelTerseStruct) ReadField13(iprot thrift.Protocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[int16]int16, size) - p.MapField = tMap - for i := 0; i < size; i ++ { - var _key6 int16 - if v, err := iprot.ReadI16(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key6 = v - } - var _val7 int16 - if v, err := iprot.ReadI16(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _val7 = v - } - p.MapField[_key6] = _val7 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *StructLevelTerseStruct) ReadField14(iprot thrift.Protocol) error { - p.StructField = NewMyStruct() - if err := p.StructField.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.StructField), err) - } - return nil -} - -func (p *StructLevelTerseStruct) ReadField15(iprot thrift.Protocol) error { - p.UnionField = NewMyUnion() - if err := p.UnionField.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.UnionField), err) - } - return nil -} - -func (p *StructLevelTerseStruct) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("StructLevelTerseStruct"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := p.writeField4(oprot); err != nil { return err } - if err := p.writeField5(oprot); err != nil { return err } - if err := p.writeField6(oprot); err != nil { return err } - if err := p.writeField7(oprot); err != nil { return err } - if err := p.writeField8(oprot); err != nil { return err } - if err := p.writeField9(oprot); err != nil { return err } - if err := p.writeField10(oprot); err != nil { return err } - if err := p.writeField11(oprot); err != nil { return err } - if err := p.writeField12(oprot); err != nil { return err } - if err := p.writeField13(oprot); err != nil { return err } - if err := p.writeField14(oprot); err != nil { return err } - if err := p.writeField15(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *StructLevelTerseStruct) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("bool_field", thrift.BOOL, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:bool_field: ", p), err) } - if err := oprot.WriteBool(bool(p.BoolField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.bool_field (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:bool_field: ", p), err) } - return err -} - -func (p *StructLevelTerseStruct) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("byte_field", thrift.BYTE, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:byte_field: ", p), err) } - if err := oprot.WriteByte(byte(p.ByteField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.byte_field (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:byte_field: ", p), err) } - return err -} - -func (p *StructLevelTerseStruct) writeField3(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("short_field", thrift.I16, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:short_field: ", p), err) } - if err := oprot.WriteI16(int16(p.ShortField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.short_field (3) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:short_field: ", p), err) } - return err -} - -func (p *StructLevelTerseStruct) writeField4(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("int_field", thrift.I32, 4); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:int_field: ", p), err) } - if err := oprot.WriteI32(int32(p.IntField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.int_field (4) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 4:int_field: ", p), err) } - return err -} - -func (p *StructLevelTerseStruct) writeField5(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("long_field", thrift.I64, 5); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:long_field: ", p), err) } - if err := oprot.WriteI64(int64(p.LongField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.long_field (5) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 5:long_field: ", p), err) } - return err -} - -func (p *StructLevelTerseStruct) writeField6(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("float_field", thrift.FLOAT, 6); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 6:float_field: ", p), err) } - if err := oprot.WriteFloat(float32(p.FloatField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.float_field (6) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 6:float_field: ", p), err) } - return err -} - -func (p *StructLevelTerseStruct) writeField7(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("double_field", thrift.DOUBLE, 7); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 7:double_field: ", p), err) } - if err := oprot.WriteDouble(float64(p.DoubleField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.double_field (7) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 7:double_field: ", p), err) } - return err -} - -func (p *StructLevelTerseStruct) writeField8(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("string_field", thrift.STRING, 8); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 8:string_field: ", p), err) } - if err := oprot.WriteString(string(p.StringField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.string_field (8) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 8:string_field: ", p), err) } - return err -} - -func (p *StructLevelTerseStruct) writeField9(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("binary_field", thrift.STRING, 9); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 9:binary_field: ", p), err) } - if err := oprot.WriteBinary(p.BinaryField); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.binary_field (9) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 9:binary_field: ", p), err) } - return err -} - -func (p *StructLevelTerseStruct) writeField10(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("enum_field", thrift.I32, 10); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 10:enum_field: ", p), err) } - if err := oprot.WriteI32(int32(p.EnumField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.enum_field (10) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 10:enum_field: ", p), err) } - return err -} - -func (p *StructLevelTerseStruct) writeField11(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("list_field", thrift.LIST, 11); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 11:list_field: ", p), err) } - if err := oprot.WriteListBegin(thrift.I16, len(p.ListField)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.ListField { - if err := oprot.WriteI16(int16(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 11:list_field: ", p), err) } - return err -} - -func (p *StructLevelTerseStruct) writeField12(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("set_field", thrift.SET, 12); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 12:set_field: ", p), err) } - if err := oprot.WriteSetBegin(thrift.I16, len(p.SetField)); err != nil { - return thrift.PrependError("error writing set begin: ", err) - } - set := make(map[int16]bool, len(p.SetField)) - for _, v := range p.SetField { - if ok := set[v]; ok { - return thrift.PrependError("", fmt.Errorf("%T error writing set field: slice is not unique", v)) - } - set[v] = true - } - for _, v := range p.SetField { - if err := oprot.WriteI16(int16(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteSetEnd(); err != nil { - return thrift.PrependError("error writing set end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 12:set_field: ", p), err) } - return err -} - -func (p *StructLevelTerseStruct) writeField13(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("map_field", thrift.MAP, 13); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 13:map_field: ", p), err) } - if err := oprot.WriteMapBegin(thrift.I16, thrift.I16, len(p.MapField)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.MapField { - if err := oprot.WriteI16(int16(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := oprot.WriteI16(int16(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 13:map_field: ", p), err) } - return err -} - -func (p *StructLevelTerseStruct) writeField14(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("struct_field", thrift.STRUCT, 14); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 14:struct_field: ", p), err) } - if err := p.StructField.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.StructField), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 14:struct_field: ", p), err) } - return err -} - -func (p *StructLevelTerseStruct) writeField15(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("union_field", thrift.STRUCT, 15); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 15:union_field: ", p), err) } - if err := p.UnionField.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.UnionField), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 15:union_field: ", p), err) } - return err -} - -func (p *StructLevelTerseStruct) String() string { - if p == nil { - return "" - } - - boolFieldVal := fmt.Sprintf("%v", p.BoolField) - byteFieldVal := fmt.Sprintf("%v", p.ByteField) - shortFieldVal := fmt.Sprintf("%v", p.ShortField) - intFieldVal := fmt.Sprintf("%v", p.IntField) - longFieldVal := fmt.Sprintf("%v", p.LongField) - floatFieldVal := fmt.Sprintf("%v", p.FloatField) - doubleFieldVal := fmt.Sprintf("%v", p.DoubleField) - stringFieldVal := fmt.Sprintf("%v", p.StringField) - binaryFieldVal := fmt.Sprintf("%v", p.BinaryField) - enumFieldVal := fmt.Sprintf("%v", p.EnumField) - listFieldVal := fmt.Sprintf("%v", p.ListField) - setFieldVal := fmt.Sprintf("%v", p.SetField) - mapFieldVal := fmt.Sprintf("%v", p.MapField) - var structFieldVal string - if p.StructField == nil { - structFieldVal = "" - } else { - structFieldVal = fmt.Sprintf("%v", p.StructField) - } - var unionFieldVal string - if p.UnionField == nil { - unionFieldVal = "" - } else { - unionFieldVal = fmt.Sprintf("%v", p.UnionField) - } - return fmt.Sprintf("StructLevelTerseStruct({BoolField:%s ByteField:%s ShortField:%s IntField:%s LongField:%s FloatField:%s DoubleField:%s StringField:%s BinaryField:%s EnumField:%s ListField:%s SetField:%s MapField:%s StructField:%s UnionField:%s})", boolFieldVal, byteFieldVal, shortFieldVal, intFieldVal, longFieldVal, floatFieldVal, doubleFieldVal, stringFieldVal, binaryFieldVal, enumFieldVal, listFieldVal, setFieldVal, mapFieldVal, structFieldVal, unionFieldVal) -} - -// Attributes: -// - TerseBoolField -// - TerseByteField -// - TerseShortField -// - TerseIntField -// - TerseLongField -// - TerseFloatField -// - TerseDoubleField -// - TerseStringField -// - TerseBinaryField -// - TerseEnumField -// - TerseListField -// - TerseSetField -// - TerseMapField -// - TerseStructField -// - TerseUnionField -// - BoolField -// - ByteField -// - ShortField -// - IntField -// - LongField -// - FloatField -// - DoubleField -// - StringField -// - BinaryField -// - EnumField -// - ListField -// - SetField -// - MapField -// - StructField -// - UnionField -type FieldLevelTerseStruct struct { - TerseBoolField bool `thrift:"terse_bool_field,1" db:"terse_bool_field" json:"terse_bool_field"` - TerseByteField int8 `thrift:"terse_byte_field,2" db:"terse_byte_field" json:"terse_byte_field"` - TerseShortField int16 `thrift:"terse_short_field,3" db:"terse_short_field" json:"terse_short_field"` - TerseIntField int32 `thrift:"terse_int_field,4" db:"terse_int_field" json:"terse_int_field"` - TerseLongField int64 `thrift:"terse_long_field,5" db:"terse_long_field" json:"terse_long_field"` - TerseFloatField float32 `thrift:"terse_float_field,6" db:"terse_float_field" json:"terse_float_field"` - TerseDoubleField float64 `thrift:"terse_double_field,7" db:"terse_double_field" json:"terse_double_field"` - TerseStringField string `thrift:"terse_string_field,8" db:"terse_string_field" json:"terse_string_field"` - TerseBinaryField []byte `thrift:"terse_binary_field,9" db:"terse_binary_field" json:"terse_binary_field"` - TerseEnumField MyEnum `thrift:"terse_enum_field,10" db:"terse_enum_field" json:"terse_enum_field"` - TerseListField []int16 `thrift:"terse_list_field,11" db:"terse_list_field" json:"terse_list_field"` - TerseSetField []int16 `thrift:"terse_set_field,12" db:"terse_set_field" json:"terse_set_field"` - TerseMapField map[int16]int16 `thrift:"terse_map_field,13" db:"terse_map_field" json:"terse_map_field"` - TerseStructField *MyStruct `thrift:"terse_struct_field,14" db:"terse_struct_field" json:"terse_struct_field"` - BoolField bool `thrift:"bool_field,15" db:"bool_field" json:"bool_field"` - ByteField int8 `thrift:"byte_field,16" db:"byte_field" json:"byte_field"` - ShortField int16 `thrift:"short_field,17" db:"short_field" json:"short_field"` - IntField int32 `thrift:"int_field,18" db:"int_field" json:"int_field"` - LongField int64 `thrift:"long_field,19" db:"long_field" json:"long_field"` - FloatField float32 `thrift:"float_field,20" db:"float_field" json:"float_field"` - DoubleField float64 `thrift:"double_field,21" db:"double_field" json:"double_field"` - StringField string `thrift:"string_field,22" db:"string_field" json:"string_field"` - BinaryField []byte `thrift:"binary_field,23" db:"binary_field" json:"binary_field"` - EnumField MyEnum `thrift:"enum_field,24" db:"enum_field" json:"enum_field"` - ListField []int16 `thrift:"list_field,25" db:"list_field" json:"list_field"` - SetField []int16 `thrift:"set_field,26" db:"set_field" json:"set_field"` - MapField map[int16]int16 `thrift:"map_field,27" db:"map_field" json:"map_field"` - StructField *MyStruct `thrift:"struct_field,28" db:"struct_field" json:"struct_field"` - TerseUnionField *MyUnion `thrift:"terse_union_field,29" db:"terse_union_field" json:"terse_union_field"` - UnionField *MyUnion `thrift:"union_field,30" db:"union_field" json:"union_field"` -} - -func NewFieldLevelTerseStruct() *FieldLevelTerseStruct { - return &FieldLevelTerseStruct{ - TerseStructField: NewMyStruct(), - StructField: NewMyStruct(), - } -} - - -func (p *FieldLevelTerseStruct) GetTerseBoolField() bool { - return p.TerseBoolField -} - -func (p *FieldLevelTerseStruct) GetTerseByteField() int8 { - return p.TerseByteField -} - -func (p *FieldLevelTerseStruct) GetTerseShortField() int16 { - return p.TerseShortField -} - -func (p *FieldLevelTerseStruct) GetTerseIntField() int32 { - return p.TerseIntField -} - -func (p *FieldLevelTerseStruct) GetTerseLongField() int64 { - return p.TerseLongField -} - -func (p *FieldLevelTerseStruct) GetTerseFloatField() float32 { - return p.TerseFloatField -} - -func (p *FieldLevelTerseStruct) GetTerseDoubleField() float64 { - return p.TerseDoubleField -} - -func (p *FieldLevelTerseStruct) GetTerseStringField() string { - return p.TerseStringField -} - -func (p *FieldLevelTerseStruct) GetTerseBinaryField() []byte { - return p.TerseBinaryField -} - -func (p *FieldLevelTerseStruct) GetTerseEnumField() MyEnum { - return p.TerseEnumField -} - -func (p *FieldLevelTerseStruct) GetTerseListField() []int16 { - return p.TerseListField -} - -func (p *FieldLevelTerseStruct) GetTerseSetField() []int16 { - return p.TerseSetField -} - -func (p *FieldLevelTerseStruct) GetTerseMapField() map[int16]int16 { - return p.TerseMapField -} -var FieldLevelTerseStruct_TerseStructField_DEFAULT *MyStruct -func (p *FieldLevelTerseStruct) GetTerseStructField() *MyStruct { - if !p.IsSetTerseStructField() { - return FieldLevelTerseStruct_TerseStructField_DEFAULT - } - return p.TerseStructField -} -func (p *FieldLevelTerseStruct) DefaultGetTerseStructField() *MyStruct { - if !p.IsSetTerseStructField() { - return NewMyStruct() - } - return p.TerseStructField -} -var FieldLevelTerseStruct_TerseUnionField_DEFAULT *MyUnion -func (p *FieldLevelTerseStruct) GetTerseUnionField() *MyUnion { - if !p.IsSetTerseUnionField() { - return FieldLevelTerseStruct_TerseUnionField_DEFAULT - } - return p.TerseUnionField -} -func (p *FieldLevelTerseStruct) DefaultGetTerseUnionField() *MyUnion { - if !p.IsSetTerseUnionField() { - return NewMyUnion() - } - return p.TerseUnionField -} - -func (p *FieldLevelTerseStruct) GetBoolField() bool { - return p.BoolField -} - -func (p *FieldLevelTerseStruct) GetByteField() int8 { - return p.ByteField -} - -func (p *FieldLevelTerseStruct) GetShortField() int16 { - return p.ShortField -} - -func (p *FieldLevelTerseStruct) GetIntField() int32 { - return p.IntField -} - -func (p *FieldLevelTerseStruct) GetLongField() int64 { - return p.LongField -} - -func (p *FieldLevelTerseStruct) GetFloatField() float32 { - return p.FloatField -} - -func (p *FieldLevelTerseStruct) GetDoubleField() float64 { - return p.DoubleField -} - -func (p *FieldLevelTerseStruct) GetStringField() string { - return p.StringField -} - -func (p *FieldLevelTerseStruct) GetBinaryField() []byte { - return p.BinaryField -} - -func (p *FieldLevelTerseStruct) GetEnumField() MyEnum { - return p.EnumField -} - -func (p *FieldLevelTerseStruct) GetListField() []int16 { - return p.ListField -} - -func (p *FieldLevelTerseStruct) GetSetField() []int16 { - return p.SetField -} - -func (p *FieldLevelTerseStruct) GetMapField() map[int16]int16 { - return p.MapField -} -var FieldLevelTerseStruct_StructField_DEFAULT *MyStruct -func (p *FieldLevelTerseStruct) GetStructField() *MyStruct { - if !p.IsSetStructField() { - return FieldLevelTerseStruct_StructField_DEFAULT - } - return p.StructField -} -func (p *FieldLevelTerseStruct) DefaultGetStructField() *MyStruct { - if !p.IsSetStructField() { - return NewMyStruct() - } - return p.StructField -} -var FieldLevelTerseStruct_UnionField_DEFAULT *MyUnion -func (p *FieldLevelTerseStruct) GetUnionField() *MyUnion { - if !p.IsSetUnionField() { - return FieldLevelTerseStruct_UnionField_DEFAULT - } - return p.UnionField -} -func (p *FieldLevelTerseStruct) DefaultGetUnionField() *MyUnion { - if !p.IsSetUnionField() { - return NewMyUnion() - } - return p.UnionField -} -func (p *FieldLevelTerseStruct) IsSetTerseStructField() bool { - return p != nil && p.TerseStructField != nil -} - -func (p *FieldLevelTerseStruct) IsSetTerseUnionField() bool { - return p != nil && p.TerseUnionField != nil -} - -func (p *FieldLevelTerseStruct) IsSetStructField() bool { - return p != nil && p.StructField != nil -} - -func (p *FieldLevelTerseStruct) IsSetUnionField() bool { - return p != nil && p.UnionField != nil -} - -type FieldLevelTerseStructBuilder struct { - obj *FieldLevelTerseStruct -} - -func NewFieldLevelTerseStructBuilder() *FieldLevelTerseStructBuilder{ - return &FieldLevelTerseStructBuilder{ - obj: NewFieldLevelTerseStruct(), - } -} - -func (p FieldLevelTerseStructBuilder) Emit() *FieldLevelTerseStruct{ - return &FieldLevelTerseStruct{ - TerseBoolField: p.obj.TerseBoolField, - TerseByteField: p.obj.TerseByteField, - TerseShortField: p.obj.TerseShortField, - TerseIntField: p.obj.TerseIntField, - TerseLongField: p.obj.TerseLongField, - TerseFloatField: p.obj.TerseFloatField, - TerseDoubleField: p.obj.TerseDoubleField, - TerseStringField: p.obj.TerseStringField, - TerseBinaryField: p.obj.TerseBinaryField, - TerseEnumField: p.obj.TerseEnumField, - TerseListField: p.obj.TerseListField, - TerseSetField: p.obj.TerseSetField, - TerseMapField: p.obj.TerseMapField, - TerseStructField: p.obj.TerseStructField, - TerseUnionField: p.obj.TerseUnionField, - BoolField: p.obj.BoolField, - ByteField: p.obj.ByteField, - ShortField: p.obj.ShortField, - IntField: p.obj.IntField, - LongField: p.obj.LongField, - FloatField: p.obj.FloatField, - DoubleField: p.obj.DoubleField, - StringField: p.obj.StringField, - BinaryField: p.obj.BinaryField, - EnumField: p.obj.EnumField, - ListField: p.obj.ListField, - SetField: p.obj.SetField, - MapField: p.obj.MapField, - StructField: p.obj.StructField, - UnionField: p.obj.UnionField, - } -} - -func (f *FieldLevelTerseStructBuilder) TerseBoolField(terseBoolField bool) *FieldLevelTerseStructBuilder { - f.obj.TerseBoolField = terseBoolField - return f -} - -func (f *FieldLevelTerseStructBuilder) TerseByteField(terseByteField int8) *FieldLevelTerseStructBuilder { - f.obj.TerseByteField = terseByteField - return f -} - -func (f *FieldLevelTerseStructBuilder) TerseShortField(terseShortField int16) *FieldLevelTerseStructBuilder { - f.obj.TerseShortField = terseShortField - return f -} - -func (f *FieldLevelTerseStructBuilder) TerseIntField(terseIntField int32) *FieldLevelTerseStructBuilder { - f.obj.TerseIntField = terseIntField - return f -} - -func (f *FieldLevelTerseStructBuilder) TerseLongField(terseLongField int64) *FieldLevelTerseStructBuilder { - f.obj.TerseLongField = terseLongField - return f -} - -func (f *FieldLevelTerseStructBuilder) TerseFloatField(terseFloatField float32) *FieldLevelTerseStructBuilder { - f.obj.TerseFloatField = terseFloatField - return f -} - -func (f *FieldLevelTerseStructBuilder) TerseDoubleField(terseDoubleField float64) *FieldLevelTerseStructBuilder { - f.obj.TerseDoubleField = terseDoubleField - return f -} - -func (f *FieldLevelTerseStructBuilder) TerseStringField(terseStringField string) *FieldLevelTerseStructBuilder { - f.obj.TerseStringField = terseStringField - return f -} - -func (f *FieldLevelTerseStructBuilder) TerseBinaryField(terseBinaryField []byte) *FieldLevelTerseStructBuilder { - f.obj.TerseBinaryField = terseBinaryField - return f -} - -func (f *FieldLevelTerseStructBuilder) TerseEnumField(terseEnumField MyEnum) *FieldLevelTerseStructBuilder { - f.obj.TerseEnumField = terseEnumField - return f -} - -func (f *FieldLevelTerseStructBuilder) TerseListField(terseListField []int16) *FieldLevelTerseStructBuilder { - f.obj.TerseListField = terseListField - return f -} - -func (f *FieldLevelTerseStructBuilder) TerseSetField(terseSetField []int16) *FieldLevelTerseStructBuilder { - f.obj.TerseSetField = terseSetField - return f -} - -func (f *FieldLevelTerseStructBuilder) TerseMapField(terseMapField map[int16]int16) *FieldLevelTerseStructBuilder { - f.obj.TerseMapField = terseMapField - return f -} - -func (f *FieldLevelTerseStructBuilder) TerseStructField(terseStructField *MyStruct) *FieldLevelTerseStructBuilder { - f.obj.TerseStructField = terseStructField - return f -} - -func (f *FieldLevelTerseStructBuilder) TerseUnionField(terseUnionField *MyUnion) *FieldLevelTerseStructBuilder { - f.obj.TerseUnionField = terseUnionField - return f -} - -func (f *FieldLevelTerseStructBuilder) BoolField(boolField bool) *FieldLevelTerseStructBuilder { - f.obj.BoolField = boolField - return f -} - -func (f *FieldLevelTerseStructBuilder) ByteField(byteField int8) *FieldLevelTerseStructBuilder { - f.obj.ByteField = byteField - return f -} - -func (f *FieldLevelTerseStructBuilder) ShortField(shortField int16) *FieldLevelTerseStructBuilder { - f.obj.ShortField = shortField - return f -} - -func (f *FieldLevelTerseStructBuilder) IntField(intField int32) *FieldLevelTerseStructBuilder { - f.obj.IntField = intField - return f -} - -func (f *FieldLevelTerseStructBuilder) LongField(longField int64) *FieldLevelTerseStructBuilder { - f.obj.LongField = longField - return f -} - -func (f *FieldLevelTerseStructBuilder) FloatField(floatField float32) *FieldLevelTerseStructBuilder { - f.obj.FloatField = floatField - return f -} - -func (f *FieldLevelTerseStructBuilder) DoubleField(doubleField float64) *FieldLevelTerseStructBuilder { - f.obj.DoubleField = doubleField - return f -} - -func (f *FieldLevelTerseStructBuilder) StringField(stringField string) *FieldLevelTerseStructBuilder { - f.obj.StringField = stringField - return f -} - -func (f *FieldLevelTerseStructBuilder) BinaryField(binaryField []byte) *FieldLevelTerseStructBuilder { - f.obj.BinaryField = binaryField - return f -} - -func (f *FieldLevelTerseStructBuilder) EnumField(enumField MyEnum) *FieldLevelTerseStructBuilder { - f.obj.EnumField = enumField - return f -} - -func (f *FieldLevelTerseStructBuilder) ListField(listField []int16) *FieldLevelTerseStructBuilder { - f.obj.ListField = listField - return f -} - -func (f *FieldLevelTerseStructBuilder) SetField(setField []int16) *FieldLevelTerseStructBuilder { - f.obj.SetField = setField - return f -} - -func (f *FieldLevelTerseStructBuilder) MapField(mapField map[int16]int16) *FieldLevelTerseStructBuilder { - f.obj.MapField = mapField - return f -} - -func (f *FieldLevelTerseStructBuilder) StructField(structField *MyStruct) *FieldLevelTerseStructBuilder { - f.obj.StructField = structField - return f -} - -func (f *FieldLevelTerseStructBuilder) UnionField(unionField *MyUnion) *FieldLevelTerseStructBuilder { - f.obj.UnionField = unionField - return f -} - -func (f *FieldLevelTerseStruct) SetTerseBoolField(terseBoolField bool) *FieldLevelTerseStruct { - f.TerseBoolField = terseBoolField - return f -} - -func (f *FieldLevelTerseStruct) SetTerseByteField(terseByteField int8) *FieldLevelTerseStruct { - f.TerseByteField = terseByteField - return f -} - -func (f *FieldLevelTerseStruct) SetTerseShortField(terseShortField int16) *FieldLevelTerseStruct { - f.TerseShortField = terseShortField - return f -} - -func (f *FieldLevelTerseStruct) SetTerseIntField(terseIntField int32) *FieldLevelTerseStruct { - f.TerseIntField = terseIntField - return f -} - -func (f *FieldLevelTerseStruct) SetTerseLongField(terseLongField int64) *FieldLevelTerseStruct { - f.TerseLongField = terseLongField - return f -} - -func (f *FieldLevelTerseStruct) SetTerseFloatField(terseFloatField float32) *FieldLevelTerseStruct { - f.TerseFloatField = terseFloatField - return f -} - -func (f *FieldLevelTerseStruct) SetTerseDoubleField(terseDoubleField float64) *FieldLevelTerseStruct { - f.TerseDoubleField = terseDoubleField - return f -} - -func (f *FieldLevelTerseStruct) SetTerseStringField(terseStringField string) *FieldLevelTerseStruct { - f.TerseStringField = terseStringField - return f -} - -func (f *FieldLevelTerseStruct) SetTerseBinaryField(terseBinaryField []byte) *FieldLevelTerseStruct { - f.TerseBinaryField = terseBinaryField - return f -} - -func (f *FieldLevelTerseStruct) SetTerseEnumField(terseEnumField MyEnum) *FieldLevelTerseStruct { - f.TerseEnumField = terseEnumField - return f -} - -func (f *FieldLevelTerseStruct) SetTerseListField(terseListField []int16) *FieldLevelTerseStruct { - f.TerseListField = terseListField - return f -} - -func (f *FieldLevelTerseStruct) SetTerseSetField(terseSetField []int16) *FieldLevelTerseStruct { - f.TerseSetField = terseSetField - return f -} - -func (f *FieldLevelTerseStruct) SetTerseMapField(terseMapField map[int16]int16) *FieldLevelTerseStruct { - f.TerseMapField = terseMapField - return f -} - -func (f *FieldLevelTerseStruct) SetTerseStructField(terseStructField *MyStruct) *FieldLevelTerseStruct { - f.TerseStructField = terseStructField - return f -} - -func (f *FieldLevelTerseStruct) SetTerseUnionField(terseUnionField *MyUnion) *FieldLevelTerseStruct { - f.TerseUnionField = terseUnionField - return f -} - -func (f *FieldLevelTerseStruct) SetBoolField(boolField bool) *FieldLevelTerseStruct { - f.BoolField = boolField - return f -} - -func (f *FieldLevelTerseStruct) SetByteField(byteField int8) *FieldLevelTerseStruct { - f.ByteField = byteField - return f -} - -func (f *FieldLevelTerseStruct) SetShortField(shortField int16) *FieldLevelTerseStruct { - f.ShortField = shortField - return f -} - -func (f *FieldLevelTerseStruct) SetIntField(intField int32) *FieldLevelTerseStruct { - f.IntField = intField - return f -} - -func (f *FieldLevelTerseStruct) SetLongField(longField int64) *FieldLevelTerseStruct { - f.LongField = longField - return f -} - -func (f *FieldLevelTerseStruct) SetFloatField(floatField float32) *FieldLevelTerseStruct { - f.FloatField = floatField - return f -} - -func (f *FieldLevelTerseStruct) SetDoubleField(doubleField float64) *FieldLevelTerseStruct { - f.DoubleField = doubleField - return f -} - -func (f *FieldLevelTerseStruct) SetStringField(stringField string) *FieldLevelTerseStruct { - f.StringField = stringField - return f -} - -func (f *FieldLevelTerseStruct) SetBinaryField(binaryField []byte) *FieldLevelTerseStruct { - f.BinaryField = binaryField - return f -} - -func (f *FieldLevelTerseStruct) SetEnumField(enumField MyEnum) *FieldLevelTerseStruct { - f.EnumField = enumField - return f -} - -func (f *FieldLevelTerseStruct) SetListField(listField []int16) *FieldLevelTerseStruct { - f.ListField = listField - return f -} - -func (f *FieldLevelTerseStruct) SetSetField(setField []int16) *FieldLevelTerseStruct { - f.SetField = setField - return f -} - -func (f *FieldLevelTerseStruct) SetMapField(mapField map[int16]int16) *FieldLevelTerseStruct { - f.MapField = mapField - return f -} - -func (f *FieldLevelTerseStruct) SetStructField(structField *MyStruct) *FieldLevelTerseStruct { - f.StructField = structField - return f -} - -func (f *FieldLevelTerseStruct) SetUnionField(unionField *MyUnion) *FieldLevelTerseStruct { - f.UnionField = unionField - return f -} - -func (p *FieldLevelTerseStruct) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 3: - if err := p.ReadField3(iprot); err != nil { - return err - } - case 4: - if err := p.ReadField4(iprot); err != nil { - return err - } - case 5: - if err := p.ReadField5(iprot); err != nil { - return err - } - case 6: - if err := p.ReadField6(iprot); err != nil { - return err - } - case 7: - if err := p.ReadField7(iprot); err != nil { - return err - } - case 8: - if err := p.ReadField8(iprot); err != nil { - return err - } - case 9: - if err := p.ReadField9(iprot); err != nil { - return err - } - case 10: - if err := p.ReadField10(iprot); err != nil { - return err - } - case 11: - if err := p.ReadField11(iprot); err != nil { - return err - } - case 12: - if err := p.ReadField12(iprot); err != nil { - return err - } - case 13: - if err := p.ReadField13(iprot); err != nil { - return err - } - case 14: - if err := p.ReadField14(iprot); err != nil { - return err - } - case 29: - if err := p.ReadField29(iprot); err != nil { - return err - } - case 15: - if err := p.ReadField15(iprot); err != nil { - return err - } - case 16: - if err := p.ReadField16(iprot); err != nil { - return err - } - case 17: - if err := p.ReadField17(iprot); err != nil { - return err - } - case 18: - if err := p.ReadField18(iprot); err != nil { - return err - } - case 19: - if err := p.ReadField19(iprot); err != nil { - return err - } - case 20: - if err := p.ReadField20(iprot); err != nil { - return err - } - case 21: - if err := p.ReadField21(iprot); err != nil { - return err - } - case 22: - if err := p.ReadField22(iprot); err != nil { - return err - } - case 23: - if err := p.ReadField23(iprot); err != nil { - return err - } - case 24: - if err := p.ReadField24(iprot); err != nil { - return err - } - case 25: - if err := p.ReadField25(iprot); err != nil { - return err - } - case 26: - if err := p.ReadField26(iprot); err != nil { - return err - } - case 27: - if err := p.ReadField27(iprot); err != nil { - return err - } - case 28: - if err := p.ReadField28(iprot); err != nil { - return err - } - case 30: - if err := p.ReadField30(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *FieldLevelTerseStruct) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.TerseBoolField = v - } - return nil -} - -func (p *FieldLevelTerseStruct) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadByte(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - temp := int8(v) - p.TerseByteField = temp - } - return nil -} - -func (p *FieldLevelTerseStruct) ReadField3(iprot thrift.Protocol) error { - if v, err := iprot.ReadI16(); err != nil { - return thrift.PrependError("error reading field 3: ", err) - } else { - p.TerseShortField = v - } - return nil -} - -func (p *FieldLevelTerseStruct) ReadField4(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 4: ", err) - } else { - p.TerseIntField = v - } - return nil -} - -func (p *FieldLevelTerseStruct) ReadField5(iprot thrift.Protocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 5: ", err) - } else { - p.TerseLongField = v - } - return nil -} - -func (p *FieldLevelTerseStruct) ReadField6(iprot thrift.Protocol) error { - if v, err := iprot.ReadFloat(); err != nil { - return thrift.PrependError("error reading field 6: ", err) - } else { - p.TerseFloatField = v - } - return nil -} - -func (p *FieldLevelTerseStruct) ReadField7(iprot thrift.Protocol) error { - if v, err := iprot.ReadDouble(); err != nil { - return thrift.PrependError("error reading field 7: ", err) - } else { - p.TerseDoubleField = v - } - return nil -} - -func (p *FieldLevelTerseStruct) ReadField8(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 8: ", err) - } else { - p.TerseStringField = v - } - return nil -} - -func (p *FieldLevelTerseStruct) ReadField9(iprot thrift.Protocol) error { - if v, err := iprot.ReadBinary(); err != nil { - return thrift.PrependError("error reading field 9: ", err) - } else { - p.TerseBinaryField = v - } - return nil -} - -func (p *FieldLevelTerseStruct) ReadField10(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 10: ", err) - } else { - temp := MyEnum(v) - p.TerseEnumField = temp - } - return nil -} - -func (p *FieldLevelTerseStruct) ReadField11(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]int16, 0, size) - p.TerseListField = tSlice - for i := 0; i < size; i ++ { - var _elem8 int16 - if v, err := iprot.ReadI16(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem8 = v - } - p.TerseListField = append(p.TerseListField, _elem8) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *FieldLevelTerseStruct) ReadField12(iprot thrift.Protocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return thrift.PrependError("error reading set begin: ", err) - } - tSet := make([]int16, 0, size) - p.TerseSetField = tSet - for i := 0; i < size; i ++ { - var _elem9 int16 - if v, err := iprot.ReadI16(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem9 = v - } - p.TerseSetField = append(p.TerseSetField, _elem9) - } - if err := iprot.ReadSetEnd(); err != nil { - return thrift.PrependError("error reading set end: ", err) - } - return nil -} - -func (p *FieldLevelTerseStruct) ReadField13(iprot thrift.Protocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[int16]int16, size) - p.TerseMapField = tMap - for i := 0; i < size; i ++ { - var _key10 int16 - if v, err := iprot.ReadI16(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key10 = v - } - var _val11 int16 - if v, err := iprot.ReadI16(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _val11 = v - } - p.TerseMapField[_key10] = _val11 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *FieldLevelTerseStruct) ReadField14(iprot thrift.Protocol) error { - p.TerseStructField = NewMyStruct() - if err := p.TerseStructField.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.TerseStructField), err) - } - return nil -} - -func (p *FieldLevelTerseStruct) ReadField29(iprot thrift.Protocol) error { - p.TerseUnionField = NewMyUnion() - if err := p.TerseUnionField.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.TerseUnionField), err) - } - return nil -} - -func (p *FieldLevelTerseStruct) ReadField15(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 15: ", err) - } else { - p.BoolField = v - } - return nil -} - -func (p *FieldLevelTerseStruct) ReadField16(iprot thrift.Protocol) error { - if v, err := iprot.ReadByte(); err != nil { - return thrift.PrependError("error reading field 16: ", err) - } else { - temp := int8(v) - p.ByteField = temp - } - return nil -} - -func (p *FieldLevelTerseStruct) ReadField17(iprot thrift.Protocol) error { - if v, err := iprot.ReadI16(); err != nil { - return thrift.PrependError("error reading field 17: ", err) - } else { - p.ShortField = v - } - return nil -} - -func (p *FieldLevelTerseStruct) ReadField18(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 18: ", err) - } else { - p.IntField = v - } - return nil -} - -func (p *FieldLevelTerseStruct) ReadField19(iprot thrift.Protocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 19: ", err) - } else { - p.LongField = v - } - return nil -} - -func (p *FieldLevelTerseStruct) ReadField20(iprot thrift.Protocol) error { - if v, err := iprot.ReadFloat(); err != nil { - return thrift.PrependError("error reading field 20: ", err) - } else { - p.FloatField = v - } - return nil -} - -func (p *FieldLevelTerseStruct) ReadField21(iprot thrift.Protocol) error { - if v, err := iprot.ReadDouble(); err != nil { - return thrift.PrependError("error reading field 21: ", err) - } else { - p.DoubleField = v - } - return nil -} - -func (p *FieldLevelTerseStruct) ReadField22(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 22: ", err) - } else { - p.StringField = v - } - return nil -} - -func (p *FieldLevelTerseStruct) ReadField23(iprot thrift.Protocol) error { - if v, err := iprot.ReadBinary(); err != nil { - return thrift.PrependError("error reading field 23: ", err) - } else { - p.BinaryField = v - } - return nil -} - -func (p *FieldLevelTerseStruct) ReadField24(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 24: ", err) - } else { - temp := MyEnum(v) - p.EnumField = temp - } - return nil -} - -func (p *FieldLevelTerseStruct) ReadField25(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]int16, 0, size) - p.ListField = tSlice - for i := 0; i < size; i ++ { - var _elem12 int16 - if v, err := iprot.ReadI16(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem12 = v - } - p.ListField = append(p.ListField, _elem12) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *FieldLevelTerseStruct) ReadField26(iprot thrift.Protocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return thrift.PrependError("error reading set begin: ", err) - } - tSet := make([]int16, 0, size) - p.SetField = tSet - for i := 0; i < size; i ++ { - var _elem13 int16 - if v, err := iprot.ReadI16(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem13 = v - } - p.SetField = append(p.SetField, _elem13) - } - if err := iprot.ReadSetEnd(); err != nil { - return thrift.PrependError("error reading set end: ", err) - } - return nil -} - -func (p *FieldLevelTerseStruct) ReadField27(iprot thrift.Protocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[int16]int16, size) - p.MapField = tMap - for i := 0; i < size; i ++ { - var _key14 int16 - if v, err := iprot.ReadI16(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key14 = v - } - var _val15 int16 - if v, err := iprot.ReadI16(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _val15 = v - } - p.MapField[_key14] = _val15 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *FieldLevelTerseStruct) ReadField28(iprot thrift.Protocol) error { - p.StructField = NewMyStruct() - if err := p.StructField.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.StructField), err) - } - return nil -} - -func (p *FieldLevelTerseStruct) ReadField30(iprot thrift.Protocol) error { - p.UnionField = NewMyUnion() - if err := p.UnionField.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.UnionField), err) - } - return nil -} - -func (p *FieldLevelTerseStruct) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("FieldLevelTerseStruct"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := p.writeField4(oprot); err != nil { return err } - if err := p.writeField5(oprot); err != nil { return err } - if err := p.writeField6(oprot); err != nil { return err } - if err := p.writeField7(oprot); err != nil { return err } - if err := p.writeField8(oprot); err != nil { return err } - if err := p.writeField9(oprot); err != nil { return err } - if err := p.writeField10(oprot); err != nil { return err } - if err := p.writeField11(oprot); err != nil { return err } - if err := p.writeField12(oprot); err != nil { return err } - if err := p.writeField13(oprot); err != nil { return err } - if err := p.writeField14(oprot); err != nil { return err } - if err := p.writeField15(oprot); err != nil { return err } - if err := p.writeField16(oprot); err != nil { return err } - if err := p.writeField17(oprot); err != nil { return err } - if err := p.writeField18(oprot); err != nil { return err } - if err := p.writeField19(oprot); err != nil { return err } - if err := p.writeField20(oprot); err != nil { return err } - if err := p.writeField21(oprot); err != nil { return err } - if err := p.writeField22(oprot); err != nil { return err } - if err := p.writeField23(oprot); err != nil { return err } - if err := p.writeField24(oprot); err != nil { return err } - if err := p.writeField25(oprot); err != nil { return err } - if err := p.writeField26(oprot); err != nil { return err } - if err := p.writeField27(oprot); err != nil { return err } - if err := p.writeField28(oprot); err != nil { return err } - if err := p.writeField29(oprot); err != nil { return err } - if err := p.writeField30(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *FieldLevelTerseStruct) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("terse_bool_field", thrift.BOOL, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:terse_bool_field: ", p), err) } - if err := oprot.WriteBool(bool(p.TerseBoolField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.terse_bool_field (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:terse_bool_field: ", p), err) } - return err -} - -func (p *FieldLevelTerseStruct) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("terse_byte_field", thrift.BYTE, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:terse_byte_field: ", p), err) } - if err := oprot.WriteByte(byte(p.TerseByteField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.terse_byte_field (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:terse_byte_field: ", p), err) } - return err -} - -func (p *FieldLevelTerseStruct) writeField3(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("terse_short_field", thrift.I16, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:terse_short_field: ", p), err) } - if err := oprot.WriteI16(int16(p.TerseShortField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.terse_short_field (3) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:terse_short_field: ", p), err) } - return err -} - -func (p *FieldLevelTerseStruct) writeField4(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("terse_int_field", thrift.I32, 4); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:terse_int_field: ", p), err) } - if err := oprot.WriteI32(int32(p.TerseIntField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.terse_int_field (4) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 4:terse_int_field: ", p), err) } - return err -} - -func (p *FieldLevelTerseStruct) writeField5(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("terse_long_field", thrift.I64, 5); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:terse_long_field: ", p), err) } - if err := oprot.WriteI64(int64(p.TerseLongField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.terse_long_field (5) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 5:terse_long_field: ", p), err) } - return err -} - -func (p *FieldLevelTerseStruct) writeField6(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("terse_float_field", thrift.FLOAT, 6); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 6:terse_float_field: ", p), err) } - if err := oprot.WriteFloat(float32(p.TerseFloatField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.terse_float_field (6) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 6:terse_float_field: ", p), err) } - return err -} - -func (p *FieldLevelTerseStruct) writeField7(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("terse_double_field", thrift.DOUBLE, 7); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 7:terse_double_field: ", p), err) } - if err := oprot.WriteDouble(float64(p.TerseDoubleField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.terse_double_field (7) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 7:terse_double_field: ", p), err) } - return err -} - -func (p *FieldLevelTerseStruct) writeField8(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("terse_string_field", thrift.STRING, 8); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 8:terse_string_field: ", p), err) } - if err := oprot.WriteString(string(p.TerseStringField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.terse_string_field (8) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 8:terse_string_field: ", p), err) } - return err -} - -func (p *FieldLevelTerseStruct) writeField9(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("terse_binary_field", thrift.STRING, 9); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 9:terse_binary_field: ", p), err) } - if err := oprot.WriteBinary(p.TerseBinaryField); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.terse_binary_field (9) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 9:terse_binary_field: ", p), err) } - return err -} - -func (p *FieldLevelTerseStruct) writeField10(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("terse_enum_field", thrift.I32, 10); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 10:terse_enum_field: ", p), err) } - if err := oprot.WriteI32(int32(p.TerseEnumField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.terse_enum_field (10) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 10:terse_enum_field: ", p), err) } - return err -} - -func (p *FieldLevelTerseStruct) writeField11(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("terse_list_field", thrift.LIST, 11); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 11:terse_list_field: ", p), err) } - if err := oprot.WriteListBegin(thrift.I16, len(p.TerseListField)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.TerseListField { - if err := oprot.WriteI16(int16(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 11:terse_list_field: ", p), err) } - return err -} - -func (p *FieldLevelTerseStruct) writeField12(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("terse_set_field", thrift.SET, 12); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 12:terse_set_field: ", p), err) } - if err := oprot.WriteSetBegin(thrift.I16, len(p.TerseSetField)); err != nil { - return thrift.PrependError("error writing set begin: ", err) - } - set := make(map[int16]bool, len(p.TerseSetField)) - for _, v := range p.TerseSetField { - if ok := set[v]; ok { - return thrift.PrependError("", fmt.Errorf("%T error writing set field: slice is not unique", v)) - } - set[v] = true - } - for _, v := range p.TerseSetField { - if err := oprot.WriteI16(int16(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteSetEnd(); err != nil { - return thrift.PrependError("error writing set end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 12:terse_set_field: ", p), err) } - return err -} - -func (p *FieldLevelTerseStruct) writeField13(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("terse_map_field", thrift.MAP, 13); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 13:terse_map_field: ", p), err) } - if err := oprot.WriteMapBegin(thrift.I16, thrift.I16, len(p.TerseMapField)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.TerseMapField { - if err := oprot.WriteI16(int16(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := oprot.WriteI16(int16(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 13:terse_map_field: ", p), err) } - return err -} - -func (p *FieldLevelTerseStruct) writeField14(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("terse_struct_field", thrift.STRUCT, 14); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 14:terse_struct_field: ", p), err) } - if err := p.TerseStructField.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.TerseStructField), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 14:terse_struct_field: ", p), err) } - return err -} - -func (p *FieldLevelTerseStruct) writeField15(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("bool_field", thrift.BOOL, 15); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 15:bool_field: ", p), err) } - if err := oprot.WriteBool(bool(p.BoolField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.bool_field (15) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 15:bool_field: ", p), err) } - return err -} - -func (p *FieldLevelTerseStruct) writeField16(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("byte_field", thrift.BYTE, 16); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 16:byte_field: ", p), err) } - if err := oprot.WriteByte(byte(p.ByteField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.byte_field (16) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 16:byte_field: ", p), err) } - return err -} - -func (p *FieldLevelTerseStruct) writeField17(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("short_field", thrift.I16, 17); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 17:short_field: ", p), err) } - if err := oprot.WriteI16(int16(p.ShortField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.short_field (17) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 17:short_field: ", p), err) } - return err -} - -func (p *FieldLevelTerseStruct) writeField18(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("int_field", thrift.I32, 18); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 18:int_field: ", p), err) } - if err := oprot.WriteI32(int32(p.IntField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.int_field (18) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 18:int_field: ", p), err) } - return err -} - -func (p *FieldLevelTerseStruct) writeField19(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("long_field", thrift.I64, 19); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 19:long_field: ", p), err) } - if err := oprot.WriteI64(int64(p.LongField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.long_field (19) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 19:long_field: ", p), err) } - return err -} - -func (p *FieldLevelTerseStruct) writeField20(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("float_field", thrift.FLOAT, 20); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 20:float_field: ", p), err) } - if err := oprot.WriteFloat(float32(p.FloatField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.float_field (20) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 20:float_field: ", p), err) } - return err -} - -func (p *FieldLevelTerseStruct) writeField21(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("double_field", thrift.DOUBLE, 21); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 21:double_field: ", p), err) } - if err := oprot.WriteDouble(float64(p.DoubleField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.double_field (21) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 21:double_field: ", p), err) } - return err -} - -func (p *FieldLevelTerseStruct) writeField22(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("string_field", thrift.STRING, 22); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 22:string_field: ", p), err) } - if err := oprot.WriteString(string(p.StringField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.string_field (22) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 22:string_field: ", p), err) } - return err -} - -func (p *FieldLevelTerseStruct) writeField23(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("binary_field", thrift.STRING, 23); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 23:binary_field: ", p), err) } - if err := oprot.WriteBinary(p.BinaryField); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.binary_field (23) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 23:binary_field: ", p), err) } - return err -} - -func (p *FieldLevelTerseStruct) writeField24(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("enum_field", thrift.I32, 24); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 24:enum_field: ", p), err) } - if err := oprot.WriteI32(int32(p.EnumField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.enum_field (24) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 24:enum_field: ", p), err) } - return err -} - -func (p *FieldLevelTerseStruct) writeField25(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("list_field", thrift.LIST, 25); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 25:list_field: ", p), err) } - if err := oprot.WriteListBegin(thrift.I16, len(p.ListField)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.ListField { - if err := oprot.WriteI16(int16(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 25:list_field: ", p), err) } - return err -} - -func (p *FieldLevelTerseStruct) writeField26(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("set_field", thrift.SET, 26); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 26:set_field: ", p), err) } - if err := oprot.WriteSetBegin(thrift.I16, len(p.SetField)); err != nil { - return thrift.PrependError("error writing set begin: ", err) - } - set := make(map[int16]bool, len(p.SetField)) - for _, v := range p.SetField { - if ok := set[v]; ok { - return thrift.PrependError("", fmt.Errorf("%T error writing set field: slice is not unique", v)) - } - set[v] = true - } - for _, v := range p.SetField { - if err := oprot.WriteI16(int16(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteSetEnd(); err != nil { - return thrift.PrependError("error writing set end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 26:set_field: ", p), err) } - return err -} - -func (p *FieldLevelTerseStruct) writeField27(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("map_field", thrift.MAP, 27); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 27:map_field: ", p), err) } - if err := oprot.WriteMapBegin(thrift.I16, thrift.I16, len(p.MapField)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.MapField { - if err := oprot.WriteI16(int16(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := oprot.WriteI16(int16(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 27:map_field: ", p), err) } - return err -} - -func (p *FieldLevelTerseStruct) writeField28(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("struct_field", thrift.STRUCT, 28); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 28:struct_field: ", p), err) } - if err := p.StructField.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.StructField), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 28:struct_field: ", p), err) } - return err -} - -func (p *FieldLevelTerseStruct) writeField29(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("terse_union_field", thrift.STRUCT, 29); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 29:terse_union_field: ", p), err) } - if err := p.TerseUnionField.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.TerseUnionField), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 29:terse_union_field: ", p), err) } - return err -} - -func (p *FieldLevelTerseStruct) writeField30(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("union_field", thrift.STRUCT, 30); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 30:union_field: ", p), err) } - if err := p.UnionField.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.UnionField), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 30:union_field: ", p), err) } - return err -} - -func (p *FieldLevelTerseStruct) String() string { - if p == nil { - return "" - } - - terseBoolFieldVal := fmt.Sprintf("%v", p.TerseBoolField) - terseByteFieldVal := fmt.Sprintf("%v", p.TerseByteField) - terseShortFieldVal := fmt.Sprintf("%v", p.TerseShortField) - terseIntFieldVal := fmt.Sprintf("%v", p.TerseIntField) - terseLongFieldVal := fmt.Sprintf("%v", p.TerseLongField) - terseFloatFieldVal := fmt.Sprintf("%v", p.TerseFloatField) - terseDoubleFieldVal := fmt.Sprintf("%v", p.TerseDoubleField) - terseStringFieldVal := fmt.Sprintf("%v", p.TerseStringField) - terseBinaryFieldVal := fmt.Sprintf("%v", p.TerseBinaryField) - terseEnumFieldVal := fmt.Sprintf("%v", p.TerseEnumField) - terseListFieldVal := fmt.Sprintf("%v", p.TerseListField) - terseSetFieldVal := fmt.Sprintf("%v", p.TerseSetField) - terseMapFieldVal := fmt.Sprintf("%v", p.TerseMapField) - var terseStructFieldVal string - if p.TerseStructField == nil { - terseStructFieldVal = "" - } else { - terseStructFieldVal = fmt.Sprintf("%v", p.TerseStructField) - } - boolFieldVal := fmt.Sprintf("%v", p.BoolField) - byteFieldVal := fmt.Sprintf("%v", p.ByteField) - shortFieldVal := fmt.Sprintf("%v", p.ShortField) - intFieldVal := fmt.Sprintf("%v", p.IntField) - longFieldVal := fmt.Sprintf("%v", p.LongField) - floatFieldVal := fmt.Sprintf("%v", p.FloatField) - doubleFieldVal := fmt.Sprintf("%v", p.DoubleField) - stringFieldVal := fmt.Sprintf("%v", p.StringField) - binaryFieldVal := fmt.Sprintf("%v", p.BinaryField) - enumFieldVal := fmt.Sprintf("%v", p.EnumField) - listFieldVal := fmt.Sprintf("%v", p.ListField) - setFieldVal := fmt.Sprintf("%v", p.SetField) - mapFieldVal := fmt.Sprintf("%v", p.MapField) - var structFieldVal string - if p.StructField == nil { - structFieldVal = "" - } else { - structFieldVal = fmt.Sprintf("%v", p.StructField) - } - var terseUnionFieldVal string - if p.TerseUnionField == nil { - terseUnionFieldVal = "" - } else { - terseUnionFieldVal = fmt.Sprintf("%v", p.TerseUnionField) - } - var unionFieldVal string - if p.UnionField == nil { - unionFieldVal = "" - } else { - unionFieldVal = fmt.Sprintf("%v", p.UnionField) - } - return fmt.Sprintf("FieldLevelTerseStruct({TerseBoolField:%s TerseByteField:%s TerseShortField:%s TerseIntField:%s TerseLongField:%s TerseFloatField:%s TerseDoubleField:%s TerseStringField:%s TerseBinaryField:%s TerseEnumField:%s TerseListField:%s TerseSetField:%s TerseMapField:%s TerseStructField:%s BoolField:%s ByteField:%s ShortField:%s IntField:%s LongField:%s FloatField:%s DoubleField:%s StringField:%s BinaryField:%s EnumField:%s ListField:%s SetField:%s MapField:%s StructField:%s TerseUnionField:%s UnionField:%s})", terseBoolFieldVal, terseByteFieldVal, terseShortFieldVal, terseIntFieldVal, terseLongFieldVal, terseFloatFieldVal, terseDoubleFieldVal, terseStringFieldVal, terseBinaryFieldVal, terseEnumFieldVal, terseListFieldVal, terseSetFieldVal, terseMapFieldVal, terseStructFieldVal, boolFieldVal, byteFieldVal, shortFieldVal, intFieldVal, longFieldVal, floatFieldVal, doubleFieldVal, stringFieldVal, binaryFieldVal, enumFieldVal, listFieldVal, setFieldVal, mapFieldVal, structFieldVal, terseUnionFieldVal, unionFieldVal) -} - -// Attributes: -// - BoolField -// - ByteField -// - ShortField -// - IntField -// - LongField -// - FloatField -// - DoubleField -// - StringField -// - BinaryField -// - EnumField -// - ListField -// - SetField -// - MapField -// - StructField -type TerseStructWithCustomDefault struct { - BoolField bool `thrift:"bool_field,1" db:"bool_field" json:"bool_field"` - ByteField int8 `thrift:"byte_field,2" db:"byte_field" json:"byte_field"` - ShortField int16 `thrift:"short_field,3" db:"short_field" json:"short_field"` - IntField int32 `thrift:"int_field,4" db:"int_field" json:"int_field"` - LongField int64 `thrift:"long_field,5" db:"long_field" json:"long_field"` - FloatField float32 `thrift:"float_field,6" db:"float_field" json:"float_field"` - DoubleField float64 `thrift:"double_field,7" db:"double_field" json:"double_field"` - StringField string `thrift:"string_field,8" db:"string_field" json:"string_field"` - BinaryField []byte `thrift:"binary_field,9" db:"binary_field" json:"binary_field"` - EnumField MyEnum `thrift:"enum_field,10" db:"enum_field" json:"enum_field"` - ListField []int16 `thrift:"list_field,11" db:"list_field" json:"list_field"` - SetField []int16 `thrift:"set_field,12" db:"set_field" json:"set_field"` - MapField map[int16]int16 `thrift:"map_field,13" db:"map_field" json:"map_field"` - StructField *MyStructWithCustomDefault `thrift:"struct_field,14" db:"struct_field" json:"struct_field"` -} - -func NewTerseStructWithCustomDefault() *TerseStructWithCustomDefault { - return &TerseStructWithCustomDefault{ - BoolField: true, - ByteField: 1, - ShortField: 2, - IntField: 3, - LongField: 4, - FloatField: 5, - DoubleField: 6, - StringField: "7", - BinaryField: []byte("8"), - EnumField: 1, - ListField: []int16{ - 1, - }, - SetField: []int16{ - 1, }, - MapField: map[int16]int16{ - 1: 1, - }, - StructField: NewMyStructWithCustomDefault(), - } -} - - -func (p *TerseStructWithCustomDefault) GetBoolField() bool { - return p.BoolField -} - -func (p *TerseStructWithCustomDefault) GetByteField() int8 { - return p.ByteField -} - -func (p *TerseStructWithCustomDefault) GetShortField() int16 { - return p.ShortField -} - -func (p *TerseStructWithCustomDefault) GetIntField() int32 { - return p.IntField -} - -func (p *TerseStructWithCustomDefault) GetLongField() int64 { - return p.LongField -} - -func (p *TerseStructWithCustomDefault) GetFloatField() float32 { - return p.FloatField -} - -func (p *TerseStructWithCustomDefault) GetDoubleField() float64 { - return p.DoubleField -} - -func (p *TerseStructWithCustomDefault) GetStringField() string { - return p.StringField -} - -func (p *TerseStructWithCustomDefault) GetBinaryField() []byte { - return p.BinaryField -} - -func (p *TerseStructWithCustomDefault) GetEnumField() MyEnum { - return p.EnumField -} - -func (p *TerseStructWithCustomDefault) GetListField() []int16 { - return p.ListField -} - -func (p *TerseStructWithCustomDefault) GetSetField() []int16 { - return p.SetField -} - -func (p *TerseStructWithCustomDefault) GetMapField() map[int16]int16 { - return p.MapField -} -var TerseStructWithCustomDefault_StructField_DEFAULT *MyStructWithCustomDefault -func (p *TerseStructWithCustomDefault) GetStructField() *MyStructWithCustomDefault { - if !p.IsSetStructField() { - return TerseStructWithCustomDefault_StructField_DEFAULT - } - return p.StructField -} -func (p *TerseStructWithCustomDefault) DefaultGetStructField() *MyStructWithCustomDefault { - if !p.IsSetStructField() { - return NewMyStructWithCustomDefault() - } - return p.StructField -} -func (p *TerseStructWithCustomDefault) IsSetStructField() bool { - return p != nil && p.StructField != nil -} - -type TerseStructWithCustomDefaultBuilder struct { - obj *TerseStructWithCustomDefault -} - -func NewTerseStructWithCustomDefaultBuilder() *TerseStructWithCustomDefaultBuilder{ - return &TerseStructWithCustomDefaultBuilder{ - obj: NewTerseStructWithCustomDefault(), - } -} - -func (p TerseStructWithCustomDefaultBuilder) Emit() *TerseStructWithCustomDefault{ - return &TerseStructWithCustomDefault{ - BoolField: p.obj.BoolField, - ByteField: p.obj.ByteField, - ShortField: p.obj.ShortField, - IntField: p.obj.IntField, - LongField: p.obj.LongField, - FloatField: p.obj.FloatField, - DoubleField: p.obj.DoubleField, - StringField: p.obj.StringField, - BinaryField: p.obj.BinaryField, - EnumField: p.obj.EnumField, - ListField: p.obj.ListField, - SetField: p.obj.SetField, - MapField: p.obj.MapField, - StructField: p.obj.StructField, - } -} - -func (t *TerseStructWithCustomDefaultBuilder) BoolField(boolField bool) *TerseStructWithCustomDefaultBuilder { - t.obj.BoolField = boolField - return t -} - -func (t *TerseStructWithCustomDefaultBuilder) ByteField(byteField int8) *TerseStructWithCustomDefaultBuilder { - t.obj.ByteField = byteField - return t -} - -func (t *TerseStructWithCustomDefaultBuilder) ShortField(shortField int16) *TerseStructWithCustomDefaultBuilder { - t.obj.ShortField = shortField - return t -} - -func (t *TerseStructWithCustomDefaultBuilder) IntField(intField int32) *TerseStructWithCustomDefaultBuilder { - t.obj.IntField = intField - return t -} - -func (t *TerseStructWithCustomDefaultBuilder) LongField(longField int64) *TerseStructWithCustomDefaultBuilder { - t.obj.LongField = longField - return t -} - -func (t *TerseStructWithCustomDefaultBuilder) FloatField(floatField float32) *TerseStructWithCustomDefaultBuilder { - t.obj.FloatField = floatField - return t -} - -func (t *TerseStructWithCustomDefaultBuilder) DoubleField(doubleField float64) *TerseStructWithCustomDefaultBuilder { - t.obj.DoubleField = doubleField - return t -} - -func (t *TerseStructWithCustomDefaultBuilder) StringField(stringField string) *TerseStructWithCustomDefaultBuilder { - t.obj.StringField = stringField - return t -} - -func (t *TerseStructWithCustomDefaultBuilder) BinaryField(binaryField []byte) *TerseStructWithCustomDefaultBuilder { - t.obj.BinaryField = binaryField - return t -} - -func (t *TerseStructWithCustomDefaultBuilder) EnumField(enumField MyEnum) *TerseStructWithCustomDefaultBuilder { - t.obj.EnumField = enumField - return t -} - -func (t *TerseStructWithCustomDefaultBuilder) ListField(listField []int16) *TerseStructWithCustomDefaultBuilder { - t.obj.ListField = listField - return t -} - -func (t *TerseStructWithCustomDefaultBuilder) SetField(setField []int16) *TerseStructWithCustomDefaultBuilder { - t.obj.SetField = setField - return t -} - -func (t *TerseStructWithCustomDefaultBuilder) MapField(mapField map[int16]int16) *TerseStructWithCustomDefaultBuilder { - t.obj.MapField = mapField - return t -} - -func (t *TerseStructWithCustomDefaultBuilder) StructField(structField *MyStructWithCustomDefault) *TerseStructWithCustomDefaultBuilder { - t.obj.StructField = structField - return t -} - -func (t *TerseStructWithCustomDefault) SetBoolField(boolField bool) *TerseStructWithCustomDefault { - t.BoolField = boolField - return t -} - -func (t *TerseStructWithCustomDefault) SetByteField(byteField int8) *TerseStructWithCustomDefault { - t.ByteField = byteField - return t -} - -func (t *TerseStructWithCustomDefault) SetShortField(shortField int16) *TerseStructWithCustomDefault { - t.ShortField = shortField - return t -} - -func (t *TerseStructWithCustomDefault) SetIntField(intField int32) *TerseStructWithCustomDefault { - t.IntField = intField - return t -} - -func (t *TerseStructWithCustomDefault) SetLongField(longField int64) *TerseStructWithCustomDefault { - t.LongField = longField - return t -} - -func (t *TerseStructWithCustomDefault) SetFloatField(floatField float32) *TerseStructWithCustomDefault { - t.FloatField = floatField - return t -} - -func (t *TerseStructWithCustomDefault) SetDoubleField(doubleField float64) *TerseStructWithCustomDefault { - t.DoubleField = doubleField - return t -} - -func (t *TerseStructWithCustomDefault) SetStringField(stringField string) *TerseStructWithCustomDefault { - t.StringField = stringField - return t -} - -func (t *TerseStructWithCustomDefault) SetBinaryField(binaryField []byte) *TerseStructWithCustomDefault { - t.BinaryField = binaryField - return t -} - -func (t *TerseStructWithCustomDefault) SetEnumField(enumField MyEnum) *TerseStructWithCustomDefault { - t.EnumField = enumField - return t -} - -func (t *TerseStructWithCustomDefault) SetListField(listField []int16) *TerseStructWithCustomDefault { - t.ListField = listField - return t -} - -func (t *TerseStructWithCustomDefault) SetSetField(setField []int16) *TerseStructWithCustomDefault { - t.SetField = setField - return t -} - -func (t *TerseStructWithCustomDefault) SetMapField(mapField map[int16]int16) *TerseStructWithCustomDefault { - t.MapField = mapField - return t -} - -func (t *TerseStructWithCustomDefault) SetStructField(structField *MyStructWithCustomDefault) *TerseStructWithCustomDefault { - t.StructField = structField - return t -} - -func (p *TerseStructWithCustomDefault) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 3: - if err := p.ReadField3(iprot); err != nil { - return err - } - case 4: - if err := p.ReadField4(iprot); err != nil { - return err - } - case 5: - if err := p.ReadField5(iprot); err != nil { - return err - } - case 6: - if err := p.ReadField6(iprot); err != nil { - return err - } - case 7: - if err := p.ReadField7(iprot); err != nil { - return err - } - case 8: - if err := p.ReadField8(iprot); err != nil { - return err - } - case 9: - if err := p.ReadField9(iprot); err != nil { - return err - } - case 10: - if err := p.ReadField10(iprot); err != nil { - return err - } - case 11: - if err := p.ReadField11(iprot); err != nil { - return err - } - case 12: - if err := p.ReadField12(iprot); err != nil { - return err - } - case 13: - if err := p.ReadField13(iprot); err != nil { - return err - } - case 14: - if err := p.ReadField14(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *TerseStructWithCustomDefault) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.BoolField = v - } - return nil -} - -func (p *TerseStructWithCustomDefault) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadByte(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - temp := int8(v) - p.ByteField = temp - } - return nil -} - -func (p *TerseStructWithCustomDefault) ReadField3(iprot thrift.Protocol) error { - if v, err := iprot.ReadI16(); err != nil { - return thrift.PrependError("error reading field 3: ", err) - } else { - p.ShortField = v - } - return nil -} - -func (p *TerseStructWithCustomDefault) ReadField4(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 4: ", err) - } else { - p.IntField = v - } - return nil -} - -func (p *TerseStructWithCustomDefault) ReadField5(iprot thrift.Protocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 5: ", err) - } else { - p.LongField = v - } - return nil -} - -func (p *TerseStructWithCustomDefault) ReadField6(iprot thrift.Protocol) error { - if v, err := iprot.ReadFloat(); err != nil { - return thrift.PrependError("error reading field 6: ", err) - } else { - p.FloatField = v - } - return nil -} - -func (p *TerseStructWithCustomDefault) ReadField7(iprot thrift.Protocol) error { - if v, err := iprot.ReadDouble(); err != nil { - return thrift.PrependError("error reading field 7: ", err) - } else { - p.DoubleField = v - } - return nil -} - -func (p *TerseStructWithCustomDefault) ReadField8(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 8: ", err) - } else { - p.StringField = v - } - return nil -} - -func (p *TerseStructWithCustomDefault) ReadField9(iprot thrift.Protocol) error { - if v, err := iprot.ReadBinary(); err != nil { - return thrift.PrependError("error reading field 9: ", err) - } else { - p.BinaryField = v - } - return nil -} - -func (p *TerseStructWithCustomDefault) ReadField10(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 10: ", err) - } else { - temp := MyEnum(v) - p.EnumField = temp - } - return nil -} - -func (p *TerseStructWithCustomDefault) ReadField11(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]int16, 0, size) - p.ListField = tSlice - for i := 0; i < size; i ++ { - var _elem16 int16 - if v, err := iprot.ReadI16(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem16 = v - } - p.ListField = append(p.ListField, _elem16) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *TerseStructWithCustomDefault) ReadField12(iprot thrift.Protocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return thrift.PrependError("error reading set begin: ", err) - } - tSet := make([]int16, 0, size) - p.SetField = tSet - for i := 0; i < size; i ++ { - var _elem17 int16 - if v, err := iprot.ReadI16(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem17 = v - } - p.SetField = append(p.SetField, _elem17) - } - if err := iprot.ReadSetEnd(); err != nil { - return thrift.PrependError("error reading set end: ", err) - } - return nil -} - -func (p *TerseStructWithCustomDefault) ReadField13(iprot thrift.Protocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[int16]int16, size) - p.MapField = tMap - for i := 0; i < size; i ++ { - var _key18 int16 - if v, err := iprot.ReadI16(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key18 = v - } - var _val19 int16 - if v, err := iprot.ReadI16(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _val19 = v - } - p.MapField[_key18] = _val19 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *TerseStructWithCustomDefault) ReadField14(iprot thrift.Protocol) error { - p.StructField = NewMyStructWithCustomDefault() - if err := p.StructField.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.StructField), err) - } - return nil -} - -func (p *TerseStructWithCustomDefault) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("TerseStructWithCustomDefault"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := p.writeField4(oprot); err != nil { return err } - if err := p.writeField5(oprot); err != nil { return err } - if err := p.writeField6(oprot); err != nil { return err } - if err := p.writeField7(oprot); err != nil { return err } - if err := p.writeField8(oprot); err != nil { return err } - if err := p.writeField9(oprot); err != nil { return err } - if err := p.writeField10(oprot); err != nil { return err } - if err := p.writeField11(oprot); err != nil { return err } - if err := p.writeField12(oprot); err != nil { return err } - if err := p.writeField13(oprot); err != nil { return err } - if err := p.writeField14(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *TerseStructWithCustomDefault) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("bool_field", thrift.BOOL, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:bool_field: ", p), err) } - if err := oprot.WriteBool(bool(p.BoolField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.bool_field (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:bool_field: ", p), err) } - return err -} - -func (p *TerseStructWithCustomDefault) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("byte_field", thrift.BYTE, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:byte_field: ", p), err) } - if err := oprot.WriteByte(byte(p.ByteField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.byte_field (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:byte_field: ", p), err) } - return err -} - -func (p *TerseStructWithCustomDefault) writeField3(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("short_field", thrift.I16, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:short_field: ", p), err) } - if err := oprot.WriteI16(int16(p.ShortField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.short_field (3) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:short_field: ", p), err) } - return err -} - -func (p *TerseStructWithCustomDefault) writeField4(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("int_field", thrift.I32, 4); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:int_field: ", p), err) } - if err := oprot.WriteI32(int32(p.IntField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.int_field (4) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 4:int_field: ", p), err) } - return err -} - -func (p *TerseStructWithCustomDefault) writeField5(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("long_field", thrift.I64, 5); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:long_field: ", p), err) } - if err := oprot.WriteI64(int64(p.LongField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.long_field (5) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 5:long_field: ", p), err) } - return err -} - -func (p *TerseStructWithCustomDefault) writeField6(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("float_field", thrift.FLOAT, 6); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 6:float_field: ", p), err) } - if err := oprot.WriteFloat(float32(p.FloatField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.float_field (6) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 6:float_field: ", p), err) } - return err -} - -func (p *TerseStructWithCustomDefault) writeField7(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("double_field", thrift.DOUBLE, 7); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 7:double_field: ", p), err) } - if err := oprot.WriteDouble(float64(p.DoubleField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.double_field (7) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 7:double_field: ", p), err) } - return err -} - -func (p *TerseStructWithCustomDefault) writeField8(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("string_field", thrift.STRING, 8); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 8:string_field: ", p), err) } - if err := oprot.WriteString(string(p.StringField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.string_field (8) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 8:string_field: ", p), err) } - return err -} - -func (p *TerseStructWithCustomDefault) writeField9(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("binary_field", thrift.STRING, 9); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 9:binary_field: ", p), err) } - if err := oprot.WriteBinary(p.BinaryField); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.binary_field (9) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 9:binary_field: ", p), err) } - return err -} - -func (p *TerseStructWithCustomDefault) writeField10(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("enum_field", thrift.I32, 10); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 10:enum_field: ", p), err) } - if err := oprot.WriteI32(int32(p.EnumField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.enum_field (10) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 10:enum_field: ", p), err) } - return err -} - -func (p *TerseStructWithCustomDefault) writeField11(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("list_field", thrift.LIST, 11); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 11:list_field: ", p), err) } - if err := oprot.WriteListBegin(thrift.I16, len(p.ListField)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.ListField { - if err := oprot.WriteI16(int16(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 11:list_field: ", p), err) } - return err -} - -func (p *TerseStructWithCustomDefault) writeField12(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("set_field", thrift.SET, 12); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 12:set_field: ", p), err) } - if err := oprot.WriteSetBegin(thrift.I16, len(p.SetField)); err != nil { - return thrift.PrependError("error writing set begin: ", err) - } - set := make(map[int16]bool, len(p.SetField)) - for _, v := range p.SetField { - if ok := set[v]; ok { - return thrift.PrependError("", fmt.Errorf("%T error writing set field: slice is not unique", v)) - } - set[v] = true - } - for _, v := range p.SetField { - if err := oprot.WriteI16(int16(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteSetEnd(); err != nil { - return thrift.PrependError("error writing set end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 12:set_field: ", p), err) } - return err -} - -func (p *TerseStructWithCustomDefault) writeField13(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("map_field", thrift.MAP, 13); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 13:map_field: ", p), err) } - if err := oprot.WriteMapBegin(thrift.I16, thrift.I16, len(p.MapField)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.MapField { - if err := oprot.WriteI16(int16(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := oprot.WriteI16(int16(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 13:map_field: ", p), err) } - return err -} - -func (p *TerseStructWithCustomDefault) writeField14(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("struct_field", thrift.STRUCT, 14); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 14:struct_field: ", p), err) } - if err := p.StructField.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.StructField), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 14:struct_field: ", p), err) } - return err -} - -func (p *TerseStructWithCustomDefault) String() string { - if p == nil { - return "" - } - - boolFieldVal := fmt.Sprintf("%v", p.BoolField) - byteFieldVal := fmt.Sprintf("%v", p.ByteField) - shortFieldVal := fmt.Sprintf("%v", p.ShortField) - intFieldVal := fmt.Sprintf("%v", p.IntField) - longFieldVal := fmt.Sprintf("%v", p.LongField) - floatFieldVal := fmt.Sprintf("%v", p.FloatField) - doubleFieldVal := fmt.Sprintf("%v", p.DoubleField) - stringFieldVal := fmt.Sprintf("%v", p.StringField) - binaryFieldVal := fmt.Sprintf("%v", p.BinaryField) - enumFieldVal := fmt.Sprintf("%v", p.EnumField) - listFieldVal := fmt.Sprintf("%v", p.ListField) - setFieldVal := fmt.Sprintf("%v", p.SetField) - mapFieldVal := fmt.Sprintf("%v", p.MapField) - var structFieldVal string - if p.StructField == nil { - structFieldVal = "" - } else { - structFieldVal = fmt.Sprintf("%v", p.StructField) - } - return fmt.Sprintf("TerseStructWithCustomDefault({BoolField:%s ByteField:%s ShortField:%s IntField:%s LongField:%s FloatField:%s DoubleField:%s StringField:%s BinaryField:%s EnumField:%s ListField:%s SetField:%s MapField:%s StructField:%s})", boolFieldVal, byteFieldVal, shortFieldVal, intFieldVal, longFieldVal, floatFieldVal, doubleFieldVal, stringFieldVal, binaryFieldVal, enumFieldVal, listFieldVal, setFieldVal, mapFieldVal, structFieldVal) -} - -// Attributes: -// - Field1 -// - Field2 -// - Field3 -type AdaptedFields struct { - Field1 MyInteger `thrift:"field1,1" db:"field1" json:"field1"` - Field2 int32 `thrift:"field2,2" db:"field2" json:"field2"` - Field3 MyInteger `thrift:"field3,3" db:"field3" json:"field3"` -} - -func NewAdaptedFields() *AdaptedFields { - return &AdaptedFields{} -} - - -func (p *AdaptedFields) GetField1() MyInteger { - return p.Field1 -} - -func (p *AdaptedFields) GetField2() int32 { - return p.Field2 -} - -func (p *AdaptedFields) GetField3() MyInteger { - return p.Field3 -} -type AdaptedFieldsBuilder struct { - obj *AdaptedFields -} - -func NewAdaptedFieldsBuilder() *AdaptedFieldsBuilder{ - return &AdaptedFieldsBuilder{ - obj: NewAdaptedFields(), - } -} - -func (p AdaptedFieldsBuilder) Emit() *AdaptedFields{ - return &AdaptedFields{ - Field1: p.obj.Field1, - Field2: p.obj.Field2, - Field3: p.obj.Field3, - } -} - -func (a *AdaptedFieldsBuilder) Field1(field1 MyInteger) *AdaptedFieldsBuilder { - a.obj.Field1 = field1 - return a -} - -func (a *AdaptedFieldsBuilder) Field2(field2 int32) *AdaptedFieldsBuilder { - a.obj.Field2 = field2 - return a -} - -func (a *AdaptedFieldsBuilder) Field3(field3 MyInteger) *AdaptedFieldsBuilder { - a.obj.Field3 = field3 - return a -} - -func (a *AdaptedFields) SetField1(field1 MyInteger) *AdaptedFields { - a.Field1 = field1 - return a -} - -func (a *AdaptedFields) SetField2(field2 int32) *AdaptedFields { - a.Field2 = field2 - return a -} - -func (a *AdaptedFields) SetField3(field3 MyInteger) *AdaptedFields { - a.Field3 = field3 - return a -} - -func (p *AdaptedFields) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 3: - if err := p.ReadField3(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AdaptedFields) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - temp := MyInteger(v) - p.Field1 = temp - } - return nil -} - -func (p *AdaptedFields) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Field2 = v - } - return nil -} - -func (p *AdaptedFields) ReadField3(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 3: ", err) - } else { - temp := MyInteger(v) - p.Field3 = temp - } - return nil -} - -func (p *AdaptedFields) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("AdaptedFields"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *AdaptedFields) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("field1", thrift.I32, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:field1: ", p), err) } - if err := oprot.WriteI32(int32(p.Field1)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.field1 (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:field1: ", p), err) } - return err -} - -func (p *AdaptedFields) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("field2", thrift.I32, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:field2: ", p), err) } - if err := oprot.WriteI32(int32(p.Field2)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.field2 (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:field2: ", p), err) } - return err -} - -func (p *AdaptedFields) writeField3(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("field3", thrift.I32, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:field3: ", p), err) } - if err := oprot.WriteI32(int32(p.Field3)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.field3 (3) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:field3: ", p), err) } - return err -} - -func (p *AdaptedFields) String() string { - if p == nil { - return "" - } - - field1Val := fmt.Sprintf("%v", p.Field1) - field2Val := fmt.Sprintf("%v", p.Field2) - field3Val := fmt.Sprintf("%v", p.Field3) - return fmt.Sprintf("AdaptedFields({Field1:%s Field2:%s Field3:%s})", field1Val, field2Val, field3Val) -} - -// Attributes: -// - Field1 -type WrappedFields struct { - Field1 int32 `thrift:"field1,1" db:"field1" json:"field1"` -} - -func NewWrappedFields() *WrappedFields { - return &WrappedFields{ - Field1: 7, - } -} - - -func (p *WrappedFields) GetField1() int32 { - return p.Field1 -} -type WrappedFieldsBuilder struct { - obj *WrappedFields -} - -func NewWrappedFieldsBuilder() *WrappedFieldsBuilder{ - return &WrappedFieldsBuilder{ - obj: NewWrappedFields(), - } -} - -func (p WrappedFieldsBuilder) Emit() *WrappedFields{ - return &WrappedFields{ - Field1: p.obj.Field1, - } -} - -func (w *WrappedFieldsBuilder) Field1(field1 int32) *WrappedFieldsBuilder { - w.obj.Field1 = field1 - return w -} - -func (w *WrappedFields) SetField1(field1 int32) *WrappedFields { - w.Field1 = field1 - return w -} - -func (p *WrappedFields) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *WrappedFields) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Field1 = v - } - return nil -} - -func (p *WrappedFields) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("WrappedFields"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *WrappedFields) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("field1", thrift.I32, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:field1: ", p), err) } - if err := oprot.WriteI32(int32(p.Field1)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.field1 (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:field1: ", p), err) } - return err -} - -func (p *WrappedFields) String() string { - if p == nil { - return "" - } - - field1Val := fmt.Sprintf("%v", p.Field1) - return fmt.Sprintf("WrappedFields({Field1:%s})", field1Val) -} - -// Attributes: -// - Msg -type TerseException struct { - Msg string `thrift:"msg,1" db:"msg" json:"msg"` -} - -func NewTerseException() *TerseException { - return &TerseException{} -} - - -func (p *TerseException) GetMsg() string { - return p.Msg -} -type TerseExceptionBuilder struct { - obj *TerseException -} - -func NewTerseExceptionBuilder() *TerseExceptionBuilder{ - return &TerseExceptionBuilder{ - obj: NewTerseException(), - } -} - -func (p TerseExceptionBuilder) Emit() *TerseException{ - return &TerseException{ - Msg: p.obj.Msg, - } -} - -func (t *TerseExceptionBuilder) Msg(msg string) *TerseExceptionBuilder { - t.obj.Msg = msg - return t -} - -func (t *TerseException) SetMsg(msg string) *TerseException { - t.Msg = msg - return t -} - -func (p *TerseException) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *TerseException) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Msg = v - } - return nil -} - -func (p *TerseException) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("TerseException"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *TerseException) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("msg", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:msg: ", p), err) } - if err := oprot.WriteString(string(p.Msg)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.msg (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:msg: ", p), err) } - return err -} - -func (p *TerseException) String() string { - if p == nil { - return "" - } - - msgVal := fmt.Sprintf("%v", p.Msg) - return fmt.Sprintf("TerseException({Msg:%s})", msgVal) -} - -func (p *TerseException) Error() string { - return p.String() -} - diff --git a/thrift/compiler/test/fixtures/terse_write/gen-go/thrift/annotation/cpp/constants.go b/thrift/compiler/test/fixtures/terse_write/gen-go/thrift/annotation/cpp/constants.go deleted file mode 100644 index 966e368e2dd..00000000000 --- a/thrift/compiler/test/fixtures/terse_write/gen-go/thrift/annotation/cpp/constants.go +++ /dev/null @@ -1,25 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package cpp - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - - -func init() { -} - diff --git a/thrift/compiler/test/fixtures/terse_write/gen-go/thrift/annotation/cpp/ttypes.go b/thrift/compiler/test/fixtures/terse_write/gen-go/thrift/annotation/cpp/ttypes.go deleted file mode 100644 index 209f29e21fd..00000000000 --- a/thrift/compiler/test/fixtures/terse_write/gen-go/thrift/annotation/cpp/ttypes.go +++ /dev/null @@ -1,2188 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package cpp - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var GoUnusedProtection__ int; - -//Optional, defaults to Unique -type RefType int64 -const ( - RefType_Unique RefType = 0 - RefType_Shared RefType = 1 - RefType_SharedMutable RefType = 2 -) - -var RefTypeToName = map[RefType]string { - RefType_Unique: "Unique", - RefType_Shared: "Shared", - RefType_SharedMutable: "SharedMutable", -} - -var RefTypeToValue = map[string]RefType { - "Unique": RefType_Unique, - "Shared": RefType_Shared, - "SharedMutable": RefType_SharedMutable, -} - -var RefTypeNames = []string { - "Unique", - "Shared", - "SharedMutable", -} - -var RefTypeValues = []RefType { - RefType_Unique, - RefType_Shared, - RefType_SharedMutable, -} - -func (p RefType) String() string { - if v, ok := RefTypeToName[p]; ok { - return v - } - return "" -} - -func RefTypeFromString(s string) (RefType, error) { - if v, ok := RefTypeToValue[s]; ok { - return v, nil - } - return RefType(0), fmt.Errorf("not a valid RefType string") -} - -func RefTypePtr(v RefType) *RefType { return &v } - -//Enum in C++ by default uses signed 32 bit integer. There is no need to specify -//underlying type for signed 32 bit integer. -//64-bit is not supported to avoid truncation since enums are sent as 32-bit integers over the wire. -type EnumUnderlyingType int64 -const ( - EnumUnderlyingType_I8 EnumUnderlyingType = 0 - EnumUnderlyingType_U8 EnumUnderlyingType = 1 - EnumUnderlyingType_I16 EnumUnderlyingType = 2 - EnumUnderlyingType_U16 EnumUnderlyingType = 3 - EnumUnderlyingType_U32 EnumUnderlyingType = 4 -) - -var EnumUnderlyingTypeToName = map[EnumUnderlyingType]string { - EnumUnderlyingType_I8: "I8", - EnumUnderlyingType_U8: "U8", - EnumUnderlyingType_I16: "I16", - EnumUnderlyingType_U16: "U16", - EnumUnderlyingType_U32: "U32", -} - -var EnumUnderlyingTypeToValue = map[string]EnumUnderlyingType { - "I8": EnumUnderlyingType_I8, - "U8": EnumUnderlyingType_U8, - "I16": EnumUnderlyingType_I16, - "U16": EnumUnderlyingType_U16, - "U32": EnumUnderlyingType_U32, -} - -var EnumUnderlyingTypeNames = []string { - "I8", - "U8", - "I16", - "U16", - "U32", -} - -var EnumUnderlyingTypeValues = []EnumUnderlyingType { - EnumUnderlyingType_I8, - EnumUnderlyingType_U8, - EnumUnderlyingType_I16, - EnumUnderlyingType_U16, - EnumUnderlyingType_U32, -} - -func (p EnumUnderlyingType) String() string { - if v, ok := EnumUnderlyingTypeToName[p]; ok { - return v - } - return "" -} - -func EnumUnderlyingTypeFromString(s string) (EnumUnderlyingType, error) { - if v, ok := EnumUnderlyingTypeToValue[s]; ok { - return v, nil - } - return EnumUnderlyingType(0), fmt.Errorf("not a valid EnumUnderlyingType string") -} - -func EnumUnderlyingTypePtr(v EnumUnderlyingType) *EnumUnderlyingType { return &v } - -// Changes the native type of a Thrift object (the C++ type used in codegen) to the value of the `name` field. -// Container types may instead provide the `template` field, in which case template parameters will be filled in by thrift. -// (e.g. `template = "folly::sorted_vector_set"` is equivalent to `type = "folly::sorted_vector_set"` on `set`) -// -// It is also possible to add `cpp_include` to bring in additional data structures and use them here. -// It is required that the custom type matches the specified Thrift type even for internal container types. -// Prefer types that can leverage `reserve(size_t)` as Thrift makes uses these optimizations. -// *Special Case*: This annotation can be used to define a string/binary type as `IOBuf` or `unique_ptr` so that you can leverage Thrift's support for zero-copy buffer manipulation through `IOBuf`. -// During deserialization, thrift receives a buffer that is used to allocate the appropriate fields in the struct. When using smart pointers, instead of making a copy of the data, it only modifies the pointer to point to the address that is used by the buffer. -// -// The custom type must provide the following methods -// * `list`: `push_back(T)` -// * `map`: `insert(std::pair)` -// * `set`: `insert(T)` -// -// Attributes: -// - Name -// - Template -type Type struct { - Name string `thrift:"name,1" db:"name" json:"name"` - Template string `thrift:"template,2" db:"template" json:"template"` -} - -func NewType() *Type { - return &Type{} -} - - -func (p *Type) GetName() string { - return p.Name -} - -func (p *Type) GetTemplate() string { - return p.Template -} -type TypeBuilder struct { - obj *Type -} - -func NewTypeBuilder() *TypeBuilder{ - return &TypeBuilder{ - obj: NewType(), - } -} - -func (p TypeBuilder) Emit() *Type{ - return &Type{ - Name: p.obj.Name, - Template: p.obj.Template, - } -} - -func (t *TypeBuilder) Name(name string) *TypeBuilder { - t.obj.Name = name - return t -} - -func (t *TypeBuilder) Template(template string) *TypeBuilder { - t.obj.Template = template - return t -} - -func (t *Type) SetName(name string) *Type { - t.Name = name - return t -} - -func (t *Type) SetTemplate(template string) *Type { - t.Template = template - return t -} - -func (p *Type) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Type) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Name = v - } - return nil -} - -func (p *Type) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Template = v - } - return nil -} - -func (p *Type) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Type"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Type) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) } - if err := oprot.WriteString(string(p.Name)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) } - return err -} - -func (p *Type) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("template", thrift.STRING, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:template: ", p), err) } - if err := oprot.WriteString(string(p.Template)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.template (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:template: ", p), err) } - return err -} - -func (p *Type) String() string { - if p == nil { - return "" - } - - nameVal := fmt.Sprintf("%v", p.Name) - templateVal := fmt.Sprintf("%v", p.Template) - return fmt.Sprintf("Type({Name:%s Template:%s})", nameVal, templateVal) -} - -// Allocates a field on the heap instead of inline. -// This annotation is added to support recursive types. However, you can also use it to turn a field from a value to a smart pointer. -// `@cpp.Ref` is equivalent having type`@cpp.RefType.Unique`. -// -// NOTE: A struct may transitively contain itself as a field only if at least one of the fields in the inclusion chain is either an optional Ref field or a container. Otherwise the struct would have infinite size. -// -// Attributes: -// - Type -type Ref struct { - Type RefType `thrift:"type,1" db:"type" json:"type"` -} - -func NewRef() *Ref { - return &Ref{} -} - - -func (p *Ref) GetType() RefType { - return p.Type -} -type RefBuilder struct { - obj *Ref -} - -func NewRefBuilder() *RefBuilder{ - return &RefBuilder{ - obj: NewRef(), - } -} - -func (p RefBuilder) Emit() *Ref{ - return &Ref{ - Type: p.obj.Type, - } -} - -func (r *RefBuilder) Type(type_a1 RefType) *RefBuilder { - r.obj.Type = type_a1 - return r -} - -func (r *Ref) SetType(type_a1 RefType) *Ref { - r.Type = type_a1 - return r -} - -func (p *Ref) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Ref) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - temp := RefType(v) - p.Type = temp - } - return nil -} - -func (p *Ref) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Ref"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Ref) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("type", thrift.I32, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:type: ", p), err) } - if err := oprot.WriteI32(int32(p.Type)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.type (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:type: ", p), err) } - return err -} - -func (p *Ref) String() string { - if p == nil { - return "" - } - - typeVal := fmt.Sprintf("%v", p.Type) - return fmt.Sprintf("Ref({Type:%s})", typeVal) -} - -// Changes the name of the definition in generated C++ code. -// In most cases a much better solution is to rename the problematic Thrift field itself. Only use the `cpp.name` annotation if such renaming is problematic, -// e.g. when the field name appears in code as a string, particularly when using JSON serialization, and it is hard to change all usage sites. -// -// Attributes: -// - Value -type Name struct { - Value string `thrift:"value,1" db:"value" json:"value"` -} - -func NewName() *Name { - return &Name{} -} - - -func (p *Name) GetValue() string { - return p.Value -} -type NameBuilder struct { - obj *Name -} - -func NewNameBuilder() *NameBuilder{ - return &NameBuilder{ - obj: NewName(), - } -} - -func (p NameBuilder) Emit() *Name{ - return &Name{ - Value: p.obj.Value, - } -} - -func (n *NameBuilder) Value(value string) *NameBuilder { - n.obj.Value = value - return n -} - -func (n *Name) SetValue(value string) *Name { - n.Value = value - return n -} - -func (p *Name) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Name) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Value = v - } - return nil -} - -func (p *Name) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Name"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Name) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("value", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:value: ", p), err) } - if err := oprot.WriteString(string(p.Value)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.value (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:value: ", p), err) } - return err -} - -func (p *Name) String() string { - if p == nil { - return "" - } - - valueVal := fmt.Sprintf("%v", p.Value) - return fmt.Sprintf("Name({Value:%s})", valueVal) -} - -// Lazily deserialize large field on first access. -// -// ``` -// FooWithLazyField foo; -// apache::thrift::CompactSerializer::deserialize(serializedData, foo); -// -// // large_field is lazy field, it will be deserialized on first access -// // The data will be deserialized in method call large_field_ref() -// LOG(INFO) << foo.large_field_ref()->size(); -// -// // Result will be cached, we won't deserialize again -// LOG(INFO) << foo.large_field_ref()->size(); -// ``` -// -// Read more: /doc/fb/languages/cpp/lazy.md -// -// Attributes: -// - Ref -type Lazy struct { - Ref bool `thrift:"ref,1" db:"ref" json:"ref"` -} - -func NewLazy() *Lazy { - return &Lazy{} -} - - -func (p *Lazy) GetRef() bool { - return p.Ref -} -type LazyBuilder struct { - obj *Lazy -} - -func NewLazyBuilder() *LazyBuilder{ - return &LazyBuilder{ - obj: NewLazy(), - } -} - -func (p LazyBuilder) Emit() *Lazy{ - return &Lazy{ - Ref: p.obj.Ref, - } -} - -func (l *LazyBuilder) Ref(ref bool) *LazyBuilder { - l.obj.Ref = ref - return l -} - -func (l *Lazy) SetRef(ref bool) *Lazy { - l.Ref = ref - return l -} - -func (p *Lazy) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Lazy) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Ref = v - } - return nil -} - -func (p *Lazy) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Lazy"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Lazy) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("ref", thrift.BOOL, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:ref: ", p), err) } - if err := oprot.WriteBool(bool(p.Ref)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.ref (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:ref: ", p), err) } - return err -} - -func (p *Lazy) String() string { - if p == nil { - return "" - } - - refVal := fmt.Sprintf("%v", p.Ref) - return fmt.Sprintf("Lazy({Ref:%s})", refVal) -} - -type DisableLazyChecksum struct { -} - -func NewDisableLazyChecksum() *DisableLazyChecksum { - return &DisableLazyChecksum{} -} - -type DisableLazyChecksumBuilder struct { - obj *DisableLazyChecksum -} - -func NewDisableLazyChecksumBuilder() *DisableLazyChecksumBuilder{ - return &DisableLazyChecksumBuilder{ - obj: NewDisableLazyChecksum(), - } -} - -func (p DisableLazyChecksumBuilder) Emit() *DisableLazyChecksum{ - return &DisableLazyChecksum{ - } -} - -func (p *DisableLazyChecksum) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *DisableLazyChecksum) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("DisableLazyChecksum"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *DisableLazyChecksum) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("DisableLazyChecksum({})") -} - -// An annotation that applies a C++ adapter to typedef, field, or struct. -// -// For example: -// -// @cpp.Adapter{name = "::ns::IdAdapter"} -// typedef i64 MyI64; -// -// Here the type `MyI64` has the C++ adapter `IdAdapter`. -// -// struct User { -// @cpp.Adapter{name = "::ns::IdAdapter"} -// 1: i64 id; -// } -// -// Here the field `id` has the C++ adapter `IdAdapter`. -// -// Attributes: -// - Name: The name of a C++ adapter type used to convert between Thrift and native -// C++ representation. -// -// The adapter can be either a Type or Field adapter, providing either of the following APIs: -// -// struct ThriftTypeAdapter { -// static AdaptedType fromThrift(ThriftType thrift); -// static {const ThriftType& | ThriftType} toThrift(const AdaptedType& native); -// }; -// -// struct ThriftFieldAdapter { -// // Context is an instantiation of apache::thrift::FieldContext -// template -// static void construct(AdaptedType& field, Context ctx); -// -// template -// static AdaptedType fromThriftField(ThriftType value, Context ctx); -// -// template -// static {const ThriftType& | ThriftType} toThrift(const AdaptedType& adapted, Context ctx); -// }; -// - AdaptedType: It is sometimes necessary to specify AdaptedType here (in case the codegen would -// have a circular depdenceny, which will cause the C++ build to fail). -// - UnderlyingName: The name and/or extra namespace to use when directly adapting a type -// (as opposed a typedef). -// -// In this case, the IDL name of the type will refer to the adapted type in -// C++ and the underlying thrift type will be generated in a nested -// namespace and/or with a different name. -// -// If neither `underlyingName` or `extraNamespace` is provided, the -// underlying type will be generated in a nested 'detail' namespace with -// the same name. -// - ExtraNamespace -// - MoveOnly: Must set to true when adapted type is not copyable. -type Adapter struct { - Name string `thrift:"name,1" db:"name" json:"name"` - AdaptedType string `thrift:"adaptedType,2" db:"adaptedType" json:"adaptedType"` - UnderlyingName string `thrift:"underlyingName,3" db:"underlyingName" json:"underlyingName"` - ExtraNamespace string `thrift:"extraNamespace,4" db:"extraNamespace" json:"extraNamespace"` - MoveOnly bool `thrift:"moveOnly,5" db:"moveOnly" json:"moveOnly"` -} - -func NewAdapter() *Adapter { - return &Adapter{} -} - - -func (p *Adapter) GetName() string { - return p.Name -} - -func (p *Adapter) GetAdaptedType() string { - return p.AdaptedType -} - -func (p *Adapter) GetUnderlyingName() string { - return p.UnderlyingName -} - -func (p *Adapter) GetExtraNamespace() string { - return p.ExtraNamespace -} - -func (p *Adapter) GetMoveOnly() bool { - return p.MoveOnly -} -type AdapterBuilder struct { - obj *Adapter -} - -func NewAdapterBuilder() *AdapterBuilder{ - return &AdapterBuilder{ - obj: NewAdapter(), - } -} - -func (p AdapterBuilder) Emit() *Adapter{ - return &Adapter{ - Name: p.obj.Name, - AdaptedType: p.obj.AdaptedType, - UnderlyingName: p.obj.UnderlyingName, - ExtraNamespace: p.obj.ExtraNamespace, - MoveOnly: p.obj.MoveOnly, - } -} - -func (a *AdapterBuilder) Name(name string) *AdapterBuilder { - a.obj.Name = name - return a -} - -func (a *AdapterBuilder) AdaptedType(adaptedType string) *AdapterBuilder { - a.obj.AdaptedType = adaptedType - return a -} - -func (a *AdapterBuilder) UnderlyingName(underlyingName string) *AdapterBuilder { - a.obj.UnderlyingName = underlyingName - return a -} - -func (a *AdapterBuilder) ExtraNamespace(extraNamespace string) *AdapterBuilder { - a.obj.ExtraNamespace = extraNamespace - return a -} - -func (a *AdapterBuilder) MoveOnly(moveOnly bool) *AdapterBuilder { - a.obj.MoveOnly = moveOnly - return a -} - -func (a *Adapter) SetName(name string) *Adapter { - a.Name = name - return a -} - -func (a *Adapter) SetAdaptedType(adaptedType string) *Adapter { - a.AdaptedType = adaptedType - return a -} - -func (a *Adapter) SetUnderlyingName(underlyingName string) *Adapter { - a.UnderlyingName = underlyingName - return a -} - -func (a *Adapter) SetExtraNamespace(extraNamespace string) *Adapter { - a.ExtraNamespace = extraNamespace - return a -} - -func (a *Adapter) SetMoveOnly(moveOnly bool) *Adapter { - a.MoveOnly = moveOnly - return a -} - -func (p *Adapter) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 3: - if err := p.ReadField3(iprot); err != nil { - return err - } - case 4: - if err := p.ReadField4(iprot); err != nil { - return err - } - case 5: - if err := p.ReadField5(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Adapter) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Name = v - } - return nil -} - -func (p *Adapter) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.AdaptedType = v - } - return nil -} - -func (p *Adapter) ReadField3(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 3: ", err) - } else { - p.UnderlyingName = v - } - return nil -} - -func (p *Adapter) ReadField4(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 4: ", err) - } else { - p.ExtraNamespace = v - } - return nil -} - -func (p *Adapter) ReadField5(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 5: ", err) - } else { - p.MoveOnly = v - } - return nil -} - -func (p *Adapter) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Adapter"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := p.writeField4(oprot); err != nil { return err } - if err := p.writeField5(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Adapter) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) } - if err := oprot.WriteString(string(p.Name)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) } - return err -} - -func (p *Adapter) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("adaptedType", thrift.STRING, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:adaptedType: ", p), err) } - if err := oprot.WriteString(string(p.AdaptedType)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.adaptedType (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:adaptedType: ", p), err) } - return err -} - -func (p *Adapter) writeField3(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("underlyingName", thrift.STRING, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:underlyingName: ", p), err) } - if err := oprot.WriteString(string(p.UnderlyingName)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.underlyingName (3) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:underlyingName: ", p), err) } - return err -} - -func (p *Adapter) writeField4(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("extraNamespace", thrift.STRING, 4); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:extraNamespace: ", p), err) } - if err := oprot.WriteString(string(p.ExtraNamespace)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.extraNamespace (4) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 4:extraNamespace: ", p), err) } - return err -} - -func (p *Adapter) writeField5(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("moveOnly", thrift.BOOL, 5); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:moveOnly: ", p), err) } - if err := oprot.WriteBool(bool(p.MoveOnly)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.moveOnly (5) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 5:moveOnly: ", p), err) } - return err -} - -func (p *Adapter) String() string { - if p == nil { - return "" - } - - nameVal := fmt.Sprintf("%v", p.Name) - adaptedTypeVal := fmt.Sprintf("%v", p.AdaptedType) - underlyingNameVal := fmt.Sprintf("%v", p.UnderlyingName) - extraNamespaceVal := fmt.Sprintf("%v", p.ExtraNamespace) - moveOnlyVal := fmt.Sprintf("%v", p.MoveOnly) - return fmt.Sprintf("Adapter({Name:%s AdaptedType:%s UnderlyingName:%s ExtraNamespace:%s MoveOnly:%s})", nameVal, adaptedTypeVal, underlyingNameVal, extraNamespaceVal, moveOnlyVal) -} - -// Packs isset bits into fewer bytes to save space at the cost of making access more expensive. -// Passing `atomic = false` reduces the access cost while making concurrent writes UB. -// Read more: /doc/fb/languages/cpp/isset-bitpacking.md -// -// Attributes: -// - Atomic -type PackIsset struct { - Atomic bool `thrift:"atomic,1" db:"atomic" json:"atomic"` -} - -func NewPackIsset() *PackIsset { - return &PackIsset{ - Atomic: true, - } -} - - -func (p *PackIsset) GetAtomic() bool { - return p.Atomic -} -type PackIssetBuilder struct { - obj *PackIsset -} - -func NewPackIssetBuilder() *PackIssetBuilder{ - return &PackIssetBuilder{ - obj: NewPackIsset(), - } -} - -func (p PackIssetBuilder) Emit() *PackIsset{ - return &PackIsset{ - Atomic: p.obj.Atomic, - } -} - -func (p *PackIssetBuilder) Atomic(atomic bool) *PackIssetBuilder { - p.obj.Atomic = atomic - return p -} - -func (p *PackIsset) SetAtomic(atomic bool) *PackIsset { - p.Atomic = atomic - return p -} - -func (p *PackIsset) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *PackIsset) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Atomic = v - } - return nil -} - -func (p *PackIsset) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("PackIsset"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *PackIsset) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("atomic", thrift.BOOL, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:atomic: ", p), err) } - if err := oprot.WriteBool(bool(p.Atomic)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.atomic (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:atomic: ", p), err) } - return err -} - -func (p *PackIsset) String() string { - if p == nil { - return "" - } - - atomicVal := fmt.Sprintf("%v", p.Atomic) - return fmt.Sprintf("PackIsset({Atomic:%s})", atomicVal) -} - -// This annotation enables reordering of fields in the generated C++ struct to minimize padding. -// This is achieved by placing the fields in the order of decreasing alignments. The order of fields with the same alignment is preserved. -// -// ``` -// @cpp.MinimizePadding -// struct Padded { -// 1: byte small -// 2: i64 big -// 3: i16 medium -// 4: i32 biggish -// 5: byte tiny -// } -// ``` -// -// For example, the C++ fields for the `Padded` Thrift struct above will be generated in the following order: -// -// ``` -// int64_t big; -// int32_t biggish; -// int16_t medium; -// int8_t small; -// int8_t tiny; -// ``` -// -// which gives the size of 16 bytes compared to 32 bytes if `cpp.MinimizePadding` was not specified. -type MinimizePadding struct { -} - -func NewMinimizePadding() *MinimizePadding { - return &MinimizePadding{} -} - -type MinimizePaddingBuilder struct { - obj *MinimizePadding -} - -func NewMinimizePaddingBuilder() *MinimizePaddingBuilder{ - return &MinimizePaddingBuilder{ - obj: NewMinimizePadding(), - } -} - -func (p MinimizePaddingBuilder) Emit() *MinimizePadding{ - return &MinimizePadding{ - } -} - -func (p *MinimizePadding) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MinimizePadding) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("MinimizePadding"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MinimizePadding) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("MinimizePadding({})") -} - -type TriviallyRelocatable struct { -} - -func NewTriviallyRelocatable() *TriviallyRelocatable { - return &TriviallyRelocatable{} -} - -type TriviallyRelocatableBuilder struct { - obj *TriviallyRelocatable -} - -func NewTriviallyRelocatableBuilder() *TriviallyRelocatableBuilder{ - return &TriviallyRelocatableBuilder{ - obj: NewTriviallyRelocatable(), - } -} - -func (p TriviallyRelocatableBuilder) Emit() *TriviallyRelocatable{ - return &TriviallyRelocatable{ - } -} - -func (p *TriviallyRelocatable) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *TriviallyRelocatable) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("TriviallyRelocatable"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *TriviallyRelocatable) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("TriviallyRelocatable({})") -} - -type ScopedEnumAsUnionType struct { -} - -func NewScopedEnumAsUnionType() *ScopedEnumAsUnionType { - return &ScopedEnumAsUnionType{} -} - -type ScopedEnumAsUnionTypeBuilder struct { - obj *ScopedEnumAsUnionType -} - -func NewScopedEnumAsUnionTypeBuilder() *ScopedEnumAsUnionTypeBuilder{ - return &ScopedEnumAsUnionTypeBuilder{ - obj: NewScopedEnumAsUnionType(), - } -} - -func (p ScopedEnumAsUnionTypeBuilder) Emit() *ScopedEnumAsUnionType{ - return &ScopedEnumAsUnionType{ - } -} - -func (p *ScopedEnumAsUnionType) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ScopedEnumAsUnionType) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("ScopedEnumAsUnionType"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *ScopedEnumAsUnionType) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("ScopedEnumAsUnionType({})") -} - -// Indicates a typedef should be 'strong', and require an explicit cast to -// the underlying type. -// -// Currently only works for integer typedefs, for example: -// -// @cpp.StrongType -// typedef i32 MyId; -// -// Will cause an enum class to be used instead of a typedef in the genearte code, for example: -// -// enum class MyId : ::std::int32_t {}; -// -type StrongType struct { -} - -func NewStrongType() *StrongType { - return &StrongType{} -} - -type StrongTypeBuilder struct { - obj *StrongType -} - -func NewStrongTypeBuilder() *StrongTypeBuilder{ - return &StrongTypeBuilder{ - obj: NewStrongType(), - } -} - -func (p StrongTypeBuilder) Emit() *StrongType{ - return &StrongType{ - } -} - -func (p *StrongType) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *StrongType) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("StrongType"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *StrongType) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("StrongType({})") -} - -// An annotation that intercepts field access with C++ field interceptor. -// Use with *caution* since this may introduce substantial performance overhead on each field access. -// -// For example: -// -// struct Foo { -// @cpp.FieldInterceptor{name = "MyFieldInterceptor"} -// 1: i64 id; -// } -// -// The field interceptor `MyFieldInterceptor` will intercept with `interceptThriftFieldAccess` -// when the field `id` is accessed. -// -// Attributes: -// - Name: The name of a field interceptor. -// -// The field interceptor provides the following API: -// -// struct ThriftFieldInterceptor { -// template -// static void interceptThriftFieldAccess(T&& field, -// apache::thrift::FieldContext&& ctx); -// }; -// -// The field interceptor intercepts with the field value and the field context. -// It enforces an easily searchable function name `interceptThriftFieldAccess`. -// - Noinline: Setting to true makes compiler not inline and erase function signature for -// the intercepting field accessor. -type FieldInterceptor struct { - Name string `thrift:"name,1" db:"name" json:"name"` - Noinline bool `thrift:"noinline,2" db:"noinline" json:"noinline"` -} - -func NewFieldInterceptor() *FieldInterceptor { - return &FieldInterceptor{} -} - - -func (p *FieldInterceptor) GetName() string { - return p.Name -} - -func (p *FieldInterceptor) GetNoinline() bool { - return p.Noinline -} -type FieldInterceptorBuilder struct { - obj *FieldInterceptor -} - -func NewFieldInterceptorBuilder() *FieldInterceptorBuilder{ - return &FieldInterceptorBuilder{ - obj: NewFieldInterceptor(), - } -} - -func (p FieldInterceptorBuilder) Emit() *FieldInterceptor{ - return &FieldInterceptor{ - Name: p.obj.Name, - Noinline: p.obj.Noinline, - } -} - -func (f *FieldInterceptorBuilder) Name(name string) *FieldInterceptorBuilder { - f.obj.Name = name - return f -} - -func (f *FieldInterceptorBuilder) Noinline(noinline bool) *FieldInterceptorBuilder { - f.obj.Noinline = noinline - return f -} - -func (f *FieldInterceptor) SetName(name string) *FieldInterceptor { - f.Name = name - return f -} - -func (f *FieldInterceptor) SetNoinline(noinline bool) *FieldInterceptor { - f.Noinline = noinline - return f -} - -func (p *FieldInterceptor) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *FieldInterceptor) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Name = v - } - return nil -} - -func (p *FieldInterceptor) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Noinline = v - } - return nil -} - -func (p *FieldInterceptor) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("FieldInterceptor"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *FieldInterceptor) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) } - if err := oprot.WriteString(string(p.Name)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) } - return err -} - -func (p *FieldInterceptor) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("noinline", thrift.BOOL, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:noinline: ", p), err) } - if err := oprot.WriteBool(bool(p.Noinline)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.noinline (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:noinline: ", p), err) } - return err -} - -func (p *FieldInterceptor) String() string { - if p == nil { - return "" - } - - nameVal := fmt.Sprintf("%v", p.Name) - noinlineVal := fmt.Sprintf("%v", p.Noinline) - return fmt.Sprintf("FieldInterceptor({Name:%s Noinline:%s})", nameVal, noinlineVal) -} - -type UseOpEncode struct { -} - -func NewUseOpEncode() *UseOpEncode { - return &UseOpEncode{} -} - -type UseOpEncodeBuilder struct { - obj *UseOpEncode -} - -func NewUseOpEncodeBuilder() *UseOpEncodeBuilder{ - return &UseOpEncodeBuilder{ - obj: NewUseOpEncode(), - } -} - -func (p UseOpEncodeBuilder) Emit() *UseOpEncode{ - return &UseOpEncode{ - } -} - -func (p *UseOpEncode) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *UseOpEncode) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("UseOpEncode"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *UseOpEncode) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("UseOpEncode({})") -} - -// Indicates an integer type for C++ to use as the underlying type of enum, for example: -// -// @cpp.EnumType{type = cpp.EnumUnderlyingType.I8} -// enum Fruit { -// Apple = 0, -// Banana = 1, -// } -// -// will be generated into the following: -// -// enum class Fruit : ::std::int8_t { -// Apple = 0, -// Banana = 1, -// }; -// -// -// Attributes: -// - Type -type EnumType struct { - Type EnumUnderlyingType `thrift:"type,1" db:"type" json:"type"` -} - -func NewEnumType() *EnumType { - return &EnumType{} -} - - -func (p *EnumType) GetType() EnumUnderlyingType { - return p.Type -} -type EnumTypeBuilder struct { - obj *EnumType -} - -func NewEnumTypeBuilder() *EnumTypeBuilder{ - return &EnumTypeBuilder{ - obj: NewEnumType(), - } -} - -func (p EnumTypeBuilder) Emit() *EnumType{ - return &EnumType{ - Type: p.obj.Type, - } -} - -func (e *EnumTypeBuilder) Type(type_a1 EnumUnderlyingType) *EnumTypeBuilder { - e.obj.Type = type_a1 - return e -} - -func (e *EnumType) SetType(type_a1 EnumUnderlyingType) *EnumType { - e.Type = type_a1 - return e -} - -func (p *EnumType) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *EnumType) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - temp := EnumUnderlyingType(v) - p.Type = temp - } - return nil -} - -func (p *EnumType) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("EnumType"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *EnumType) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("type", thrift.I32, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:type: ", p), err) } - if err := oprot.WriteI32(int32(p.Type)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.type (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:type: ", p), err) } - return err -} - -func (p *EnumType) String() string { - if p == nil { - return "" - } - - typeVal := fmt.Sprintf("%v", p.Type) - return fmt.Sprintf("EnumType({Type:%s})", typeVal) -} - -// Indicates that frozen types should not be generated for a given struct. -type Frozen2Exclude struct { -} - -func NewFrozen2Exclude() *Frozen2Exclude { - return &Frozen2Exclude{} -} - -type Frozen2ExcludeBuilder struct { - obj *Frozen2Exclude -} - -func NewFrozen2ExcludeBuilder() *Frozen2ExcludeBuilder{ - return &Frozen2ExcludeBuilder{ - obj: NewFrozen2Exclude(), - } -} - -func (p Frozen2ExcludeBuilder) Emit() *Frozen2Exclude{ - return &Frozen2Exclude{ - } -} - -func (p *Frozen2Exclude) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Frozen2Exclude) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Frozen2Exclude"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Frozen2Exclude) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Frozen2Exclude({})") -} - -// Indicates that the container params must be complete at the time this type is instantiated. -// Only required in rare cases where the build fails with a frozen-related assert failure. -type Frozen2RequiresCompleteContainerParams struct { -} - -func NewFrozen2RequiresCompleteContainerParams() *Frozen2RequiresCompleteContainerParams { - return &Frozen2RequiresCompleteContainerParams{} -} - -type Frozen2RequiresCompleteContainerParamsBuilder struct { - obj *Frozen2RequiresCompleteContainerParams -} - -func NewFrozen2RequiresCompleteContainerParamsBuilder() *Frozen2RequiresCompleteContainerParamsBuilder{ - return &Frozen2RequiresCompleteContainerParamsBuilder{ - obj: NewFrozen2RequiresCompleteContainerParams(), - } -} - -func (p Frozen2RequiresCompleteContainerParamsBuilder) Emit() *Frozen2RequiresCompleteContainerParams{ - return &Frozen2RequiresCompleteContainerParams{ - } -} - -func (p *Frozen2RequiresCompleteContainerParams) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Frozen2RequiresCompleteContainerParams) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Frozen2RequiresCompleteContainerParams"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Frozen2RequiresCompleteContainerParams) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Frozen2RequiresCompleteContainerParams({})") -} - -// Generates typed interceptor stubs that can be overriden by user, -// and adorn the handler methods. This can be used on individual functions -// or on services (equivalent to adding it to all functions). -// -// service MyService { -// @cpp.GenerateTypedInterceptor -// void ping(); -// } -// -// This will generate the following interface: -// -// class TypedInterceptor { -// TypeErasedStorage before_ping(); -// TypeErasedStorage after_ping(); -// } -// -type GenerateTypedInterceptor struct { -} - -func NewGenerateTypedInterceptor() *GenerateTypedInterceptor { - return &GenerateTypedInterceptor{} -} - -type GenerateTypedInterceptorBuilder struct { - obj *GenerateTypedInterceptor -} - -func NewGenerateTypedInterceptorBuilder() *GenerateTypedInterceptorBuilder{ - return &GenerateTypedInterceptorBuilder{ - obj: NewGenerateTypedInterceptor(), - } -} - -func (p GenerateTypedInterceptorBuilder) Emit() *GenerateTypedInterceptor{ - return &GenerateTypedInterceptor{ - } -} - -func (p *GenerateTypedInterceptor) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *GenerateTypedInterceptor) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("GenerateTypedInterceptor"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *GenerateTypedInterceptor) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("GenerateTypedInterceptor({})") -} - -// Causes C++ handler code to run inline on the EventBase thread. -// Disables overload protection, use with caution. -// Cannot be applied to individual functions in interactions. -// -// Causes the request to be executed on the event base thread directly instead of rescheduling onto a thread manager thread, provided the async_eb_ handler method is implemented. -// You should only execute the request on the event base thread if it is very fast and you have measured that rescheduling is a substantial chunk of your service's CPU usage. -// If a request executing on the event base thread blocks or takes a long time, all other requests sharing the same event base are affected and latency will increase significantly. -// We strongly discourage the use of this annotation unless strictly necessary. You will have to implement the harder-to-use async_eb_ handler method. -// This also disables queue timeouts, an important form of overload protection. -type ProcessInEbThreadUnsafe struct { -} - -func NewProcessInEbThreadUnsafe() *ProcessInEbThreadUnsafe { - return &ProcessInEbThreadUnsafe{} -} - -type ProcessInEbThreadUnsafeBuilder struct { - obj *ProcessInEbThreadUnsafe -} - -func NewProcessInEbThreadUnsafeBuilder() *ProcessInEbThreadUnsafeBuilder{ - return &ProcessInEbThreadUnsafeBuilder{ - obj: NewProcessInEbThreadUnsafe(), - } -} - -func (p ProcessInEbThreadUnsafeBuilder) Emit() *ProcessInEbThreadUnsafe{ - return &ProcessInEbThreadUnsafe{ - } -} - -func (p *ProcessInEbThreadUnsafe) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ProcessInEbThreadUnsafe) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("ProcessInEbThreadUnsafe"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *ProcessInEbThreadUnsafe) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("ProcessInEbThreadUnsafe({})") -} - -// Applies to structured annotation that need to be accessed in Runtime. -type RuntimeAnnotation struct { -} - -func NewRuntimeAnnotation() *RuntimeAnnotation { - return &RuntimeAnnotation{} -} - -type RuntimeAnnotationBuilder struct { - obj *RuntimeAnnotation -} - -func NewRuntimeAnnotationBuilder() *RuntimeAnnotationBuilder{ - return &RuntimeAnnotationBuilder{ - obj: NewRuntimeAnnotation(), - } -} - -func (p RuntimeAnnotationBuilder) Emit() *RuntimeAnnotation{ - return &RuntimeAnnotation{ - } -} - -func (p *RuntimeAnnotation) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *RuntimeAnnotation) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("RuntimeAnnotation"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *RuntimeAnnotation) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("RuntimeAnnotation({})") -} - diff --git a/thrift/compiler/test/fixtures/terse_write/gen-go/thrift/annotation/hack/constants.go b/thrift/compiler/test/fixtures/terse_write/gen-go/thrift/annotation/hack/constants.go deleted file mode 100644 index 4054b104418..00000000000 --- a/thrift/compiler/test/fixtures/terse_write/gen-go/thrift/annotation/hack/constants.go +++ /dev/null @@ -1,25 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package hack - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - - -func init() { -} - diff --git a/thrift/compiler/test/fixtures/terse_write/gen-go/thrift/annotation/hack/ttypes.go b/thrift/compiler/test/fixtures/terse_write/gen-go/thrift/annotation/hack/ttypes.go deleted file mode 100644 index 4d27cf73b43..00000000000 --- a/thrift/compiler/test/fixtures/terse_write/gen-go/thrift/annotation/hack/ttypes.go +++ /dev/null @@ -1,1315 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package hack - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var GoUnusedProtection__ int; - -// An experimental annotation that applies a Hack wrapper to fields. -// For example: -// -// struct User { -// @hack.FieldWrapper{name="MyWrapper"} -// 1: i64 id; -// } -// -// Attributes: -// - Name: The name of a Hack wrapper class used to wrap the field -type FieldWrapper struct { - Name string `thrift:"name,1" db:"name" json:"name"` -} - -func NewFieldWrapper() *FieldWrapper { - return &FieldWrapper{} -} - - -func (p *FieldWrapper) GetName() string { - return p.Name -} -type FieldWrapperBuilder struct { - obj *FieldWrapper -} - -func NewFieldWrapperBuilder() *FieldWrapperBuilder{ - return &FieldWrapperBuilder{ - obj: NewFieldWrapper(), - } -} - -func (p FieldWrapperBuilder) Emit() *FieldWrapper{ - return &FieldWrapper{ - Name: p.obj.Name, - } -} - -func (f *FieldWrapperBuilder) Name(name string) *FieldWrapperBuilder { - f.obj.Name = name - return f -} - -func (f *FieldWrapper) SetName(name string) *FieldWrapper { - f.Name = name - return f -} - -func (p *FieldWrapper) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *FieldWrapper) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Name = v - } - return nil -} - -func (p *FieldWrapper) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("FieldWrapper"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *FieldWrapper) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) } - if err := oprot.WriteString(string(p.Name)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) } - return err -} - -func (p *FieldWrapper) String() string { - if p == nil { - return "" - } - - nameVal := fmt.Sprintf("%v", p.Name) - return fmt.Sprintf("FieldWrapper({Name:%s})", nameVal) -} - -// An annotation that applies a Hack wrapper to fields, typedef or structs. -// For example: -// -// struct User { -// @hack.FieldWrapper{name="MyWrapper"} -// 1: i64 id; -// } -// -// Attributes: -// - Name: The name of a Hack wrapper class used to wrap the field -// - UnderlyingName: When applied directly to a typedef or struct, the IDL name of the -// type will refer to the adapted type in Hack and the underlying thrift struct will be -// generated in a nested namespace and/or with a different name. By default the type/struct -// will be generated in a nested 'thrift_adapted_types' namespace with the same name, -// but both of these can be changed by setting these fields. -// Empty string enables the nested namespace and uses the IDL name for the struct. -// - ExtraNamespace -type Wrapper struct { - Name string `thrift:"name,1" db:"name" json:"name"` - UnderlyingName string `thrift:"underlyingName,2" db:"underlyingName" json:"underlyingName"` - ExtraNamespace string `thrift:"extraNamespace,3" db:"extraNamespace" json:"extraNamespace"` -} - -func NewWrapper() *Wrapper { - return &Wrapper{ - ExtraNamespace: "thrift_adapted_types", - } -} - - -func (p *Wrapper) GetName() string { - return p.Name -} - -func (p *Wrapper) GetUnderlyingName() string { - return p.UnderlyingName -} - -func (p *Wrapper) GetExtraNamespace() string { - return p.ExtraNamespace -} -type WrapperBuilder struct { - obj *Wrapper -} - -func NewWrapperBuilder() *WrapperBuilder{ - return &WrapperBuilder{ - obj: NewWrapper(), - } -} - -func (p WrapperBuilder) Emit() *Wrapper{ - return &Wrapper{ - Name: p.obj.Name, - UnderlyingName: p.obj.UnderlyingName, - ExtraNamespace: p.obj.ExtraNamespace, - } -} - -func (w *WrapperBuilder) Name(name string) *WrapperBuilder { - w.obj.Name = name - return w -} - -func (w *WrapperBuilder) UnderlyingName(underlyingName string) *WrapperBuilder { - w.obj.UnderlyingName = underlyingName - return w -} - -func (w *WrapperBuilder) ExtraNamespace(extraNamespace string) *WrapperBuilder { - w.obj.ExtraNamespace = extraNamespace - return w -} - -func (w *Wrapper) SetName(name string) *Wrapper { - w.Name = name - return w -} - -func (w *Wrapper) SetUnderlyingName(underlyingName string) *Wrapper { - w.UnderlyingName = underlyingName - return w -} - -func (w *Wrapper) SetExtraNamespace(extraNamespace string) *Wrapper { - w.ExtraNamespace = extraNamespace - return w -} - -func (p *Wrapper) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 3: - if err := p.ReadField3(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Wrapper) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Name = v - } - return nil -} - -func (p *Wrapper) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.UnderlyingName = v - } - return nil -} - -func (p *Wrapper) ReadField3(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 3: ", err) - } else { - p.ExtraNamespace = v - } - return nil -} - -func (p *Wrapper) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Wrapper"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Wrapper) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) } - if err := oprot.WriteString(string(p.Name)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) } - return err -} - -func (p *Wrapper) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("underlyingName", thrift.STRING, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:underlyingName: ", p), err) } - if err := oprot.WriteString(string(p.UnderlyingName)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.underlyingName (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:underlyingName: ", p), err) } - return err -} - -func (p *Wrapper) writeField3(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("extraNamespace", thrift.STRING, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:extraNamespace: ", p), err) } - if err := oprot.WriteString(string(p.ExtraNamespace)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.extraNamespace (3) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:extraNamespace: ", p), err) } - return err -} - -func (p *Wrapper) String() string { - if p == nil { - return "" - } - - nameVal := fmt.Sprintf("%v", p.Name) - underlyingNameVal := fmt.Sprintf("%v", p.UnderlyingName) - extraNamespaceVal := fmt.Sprintf("%v", p.ExtraNamespace) - return fmt.Sprintf("Wrapper({Name:%s UnderlyingName:%s ExtraNamespace:%s})", nameVal, underlyingNameVal, extraNamespaceVal) -} - -// An annotation that applies a Hack adapter to types. For example: -// @hack.Adapter{name="\\TimestampAdapter"} -// typedef i64 Timestamp; -// -// struct User { -// 1: Timestamp account_creation_time; -// } -// -// Here the field `account_creation_time` will have type TimestampAdapter::THackType instead of i64. -// -// in hack: -// ``` -// final class TimestampAdapter implements IThriftAdapter { -// const type TThriftType = int; -// const type THackType = Time; -// public static function fromThrift(int $seconds)[]: Time { -// return Time::fromEpochSeconds($seconds); -// } -// public static function toThrift(Time $time): int { -// return $hack_value->asFullSecondsSinceEpoch(); -// } -// } -// ``` -// elsewhere in hack: -// ``` -// function timeSinceCreated(Document $doc): Duration { -// // $doc->created_time is of type Time -// return Duration::between(Time::now(), $doc->created_time); -// } -// ``` -// This completely replaces the underlying type of a thrift for a custom implementation and uses -// the specified adapter to convert to and from the underlying Thrift type during (de)serialization. -// -// Attributes: -// - Name: The name of a Hack adapter class that implements IThriftAdapter -type Adapter struct { - Name string `thrift:"name,1" db:"name" json:"name"` -} - -func NewAdapter() *Adapter { - return &Adapter{} -} - - -func (p *Adapter) GetName() string { - return p.Name -} -type AdapterBuilder struct { - obj *Adapter -} - -func NewAdapterBuilder() *AdapterBuilder{ - return &AdapterBuilder{ - obj: NewAdapter(), - } -} - -func (p AdapterBuilder) Emit() *Adapter{ - return &Adapter{ - Name: p.obj.Name, - } -} - -func (a *AdapterBuilder) Name(name string) *AdapterBuilder { - a.obj.Name = name - return a -} - -func (a *Adapter) SetName(name string) *Adapter { - a.Name = name - return a -} - -func (p *Adapter) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Adapter) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Name = v - } - return nil -} - -func (p *Adapter) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Adapter"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Adapter) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) } - if err := oprot.WriteString(string(p.Name)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) } - return err -} - -func (p *Adapter) String() string { - if p == nil { - return "" - } - - nameVal := fmt.Sprintf("%v", p.Name) - return fmt.Sprintf("Adapter({Name:%s})", nameVal) -} - -// Attributes: -// - Reason -type SkipCodegen struct { - Reason string `thrift:"reason,1" db:"reason" json:"reason"` -} - -func NewSkipCodegen() *SkipCodegen { - return &SkipCodegen{} -} - - -func (p *SkipCodegen) GetReason() string { - return p.Reason -} -type SkipCodegenBuilder struct { - obj *SkipCodegen -} - -func NewSkipCodegenBuilder() *SkipCodegenBuilder{ - return &SkipCodegenBuilder{ - obj: NewSkipCodegen(), - } -} - -func (p SkipCodegenBuilder) Emit() *SkipCodegen{ - return &SkipCodegen{ - Reason: p.obj.Reason, - } -} - -func (s *SkipCodegenBuilder) Reason(reason string) *SkipCodegenBuilder { - s.obj.Reason = reason - return s -} - -func (s *SkipCodegen) SetReason(reason string) *SkipCodegen { - s.Reason = reason - return s -} - -func (p *SkipCodegen) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *SkipCodegen) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Reason = v - } - return nil -} - -func (p *SkipCodegen) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("SkipCodegen"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *SkipCodegen) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("reason", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:reason: ", p), err) } - if err := oprot.WriteString(string(p.Reason)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.reason (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:reason: ", p), err) } - return err -} - -func (p *SkipCodegen) String() string { - if p == nil { - return "" - } - - reasonVal := fmt.Sprintf("%v", p.Reason) - return fmt.Sprintf("SkipCodegen({Reason:%s})", reasonVal) -} - -// This annotation is mainly used to rename symbols which can result in symbol -// conflict errors in Hack codegen. -// For ex: reserved keywords in Hack language, symbols with similar names from -// other files in Hack -// -// Attributes: -// - Name -// - Reason -type Name struct { - Name string `thrift:"name,1" db:"name" json:"name"` - Reason string `thrift:"reason,2" db:"reason" json:"reason"` -} - -func NewName() *Name { - return &Name{} -} - - -func (p *Name) GetName() string { - return p.Name -} - -func (p *Name) GetReason() string { - return p.Reason -} -type NameBuilder struct { - obj *Name -} - -func NewNameBuilder() *NameBuilder{ - return &NameBuilder{ - obj: NewName(), - } -} - -func (p NameBuilder) Emit() *Name{ - return &Name{ - Name: p.obj.Name, - Reason: p.obj.Reason, - } -} - -func (n *NameBuilder) Name(name string) *NameBuilder { - n.obj.Name = name - return n -} - -func (n *NameBuilder) Reason(reason string) *NameBuilder { - n.obj.Reason = reason - return n -} - -func (n *Name) SetName(name string) *Name { - n.Name = name - return n -} - -func (n *Name) SetReason(reason string) *Name { - n.Reason = reason - return n -} - -func (p *Name) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Name) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Name = v - } - return nil -} - -func (p *Name) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Reason = v - } - return nil -} - -func (p *Name) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Name"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Name) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) } - if err := oprot.WriteString(string(p.Name)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) } - return err -} - -func (p *Name) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("reason", thrift.STRING, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:reason: ", p), err) } - if err := oprot.WriteString(string(p.Reason)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.reason (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:reason: ", p), err) } - return err -} - -func (p *Name) String() string { - if p == nil { - return "" - } - - nameVal := fmt.Sprintf("%v", p.Name) - reasonVal := fmt.Sprintf("%v", p.Reason) - return fmt.Sprintf("Name({Name:%s Reason:%s})", nameVal, reasonVal) -} - -// This annotation is for adding Hack attributes to union enums. -// -// Attributes: -// - Attributes -type UnionEnumAttributes struct { - Attributes []string `thrift:"attributes,1" db:"attributes" json:"attributes"` -} - -func NewUnionEnumAttributes() *UnionEnumAttributes { - return &UnionEnumAttributes{} -} - - -func (p *UnionEnumAttributes) GetAttributes() []string { - return p.Attributes -} -type UnionEnumAttributesBuilder struct { - obj *UnionEnumAttributes -} - -func NewUnionEnumAttributesBuilder() *UnionEnumAttributesBuilder{ - return &UnionEnumAttributesBuilder{ - obj: NewUnionEnumAttributes(), - } -} - -func (p UnionEnumAttributesBuilder) Emit() *UnionEnumAttributes{ - return &UnionEnumAttributes{ - Attributes: p.obj.Attributes, - } -} - -func (u *UnionEnumAttributesBuilder) Attributes(attributes []string) *UnionEnumAttributesBuilder { - u.obj.Attributes = attributes - return u -} - -func (u *UnionEnumAttributes) SetAttributes(attributes []string) *UnionEnumAttributes { - u.Attributes = attributes - return u -} - -func (p *UnionEnumAttributes) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *UnionEnumAttributes) ReadField1(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]string, 0, size) - p.Attributes = tSlice - for i := 0; i < size; i ++ { - var _elem0 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem0 = v - } - p.Attributes = append(p.Attributes, _elem0) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *UnionEnumAttributes) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("UnionEnumAttributes"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *UnionEnumAttributes) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("attributes", thrift.LIST, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:attributes: ", p), err) } - if err := oprot.WriteListBegin(thrift.STRING, len(p.Attributes)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.Attributes { - if err := oprot.WriteString(string(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:attributes: ", p), err) } - return err -} - -func (p *UnionEnumAttributes) String() string { - if p == nil { - return "" - } - - attributesVal := fmt.Sprintf("%v", p.Attributes) - return fmt.Sprintf("UnionEnumAttributes({Attributes:%s})", attributesVal) -} - -// This annotation is for using a custom trait for structs. -// -// Attributes: -// - Name -type StructTrait struct { - Name string `thrift:"name,1" db:"name" json:"name"` -} - -func NewStructTrait() *StructTrait { - return &StructTrait{} -} - - -func (p *StructTrait) GetName() string { - return p.Name -} -type StructTraitBuilder struct { - obj *StructTrait -} - -func NewStructTraitBuilder() *StructTraitBuilder{ - return &StructTraitBuilder{ - obj: NewStructTrait(), - } -} - -func (p StructTraitBuilder) Emit() *StructTrait{ - return &StructTrait{ - Name: p.obj.Name, - } -} - -func (s *StructTraitBuilder) Name(name string) *StructTraitBuilder { - s.obj.Name = name - return s -} - -func (s *StructTrait) SetName(name string) *StructTrait { - s.Name = name - return s -} - -func (p *StructTrait) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *StructTrait) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Name = v - } - return nil -} - -func (p *StructTrait) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("StructTrait"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *StructTrait) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) } - if err := oprot.WriteString(string(p.Name)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) } - return err -} - -func (p *StructTrait) String() string { - if p == nil { - return "" - } - - nameVal := fmt.Sprintf("%v", p.Name) - return fmt.Sprintf("StructTrait({Name:%s})", nameVal) -} - -// This annotation is for adding Hack attributes. -// * Where to use: field or struct type -// * Value: add attributes like `JSEnum` to structs or fields -// * Example: -// -// ``` -// // In thrift -// enum MyEnum { -// ALLOWED = 1, -// THIS_IS_ALLOWED = 2, -// THIS_IS_ALLOWED_2 = 3, -// }( -// hack.attributes= -// "\JSEnum(shape('name' => 'MyEnum')), -// \GraphQLEnum('MyEnum', 'Description for my enum',)" -// ) -// struct MyThriftStruct { -// 1: string foo (hack.attributes = "FieldAttribute"); -// 2: string bar; -// 3: string baz; -// } (hack.attributes = "ClassAttribute") -// ``` -// ``` -// //thrift compiler will generate this for you -// <<\JSEnum(shape('name' => 'MyEnum')), -// \GraphQLEnum('MyEnum', 'Description for my enum',)>> -// enum MyEnum: int { -// ALLOWED = 1; -// THIS_IS_ALLOWED = 2; -// THIS_IS_ALLOWED_2 = 3; -// } -// <> -// class MyThriftStruct implements \IThriftStruct { -// .... -// <> -// public string $foo; -// .... -// } -// ``` -// -// Attributes: -// - Attributes -type Attributes struct { - Attributes []string `thrift:"attributes,1" db:"attributes" json:"attributes"` -} - -func NewAttributes() *Attributes { - return &Attributes{} -} - - -func (p *Attributes) GetAttributes() []string { - return p.Attributes -} -type AttributesBuilder struct { - obj *Attributes -} - -func NewAttributesBuilder() *AttributesBuilder{ - return &AttributesBuilder{ - obj: NewAttributes(), - } -} - -func (p AttributesBuilder) Emit() *Attributes{ - return &Attributes{ - Attributes: p.obj.Attributes, - } -} - -func (a *AttributesBuilder) Attributes(attributes []string) *AttributesBuilder { - a.obj.Attributes = attributes - return a -} - -func (a *Attributes) SetAttributes(attributes []string) *Attributes { - a.Attributes = attributes - return a -} - -func (p *Attributes) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Attributes) ReadField1(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]string, 0, size) - p.Attributes = tSlice - for i := 0; i < size; i ++ { - var _elem1 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem1 = v - } - p.Attributes = append(p.Attributes, _elem1) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *Attributes) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Attributes"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Attributes) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("attributes", thrift.LIST, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:attributes: ", p), err) } - if err := oprot.WriteListBegin(thrift.STRING, len(p.Attributes)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.Attributes { - if err := oprot.WriteString(string(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:attributes: ", p), err) } - return err -} - -func (p *Attributes) String() string { - if p == nil { - return "" - } - - attributesVal := fmt.Sprintf("%v", p.Attributes) - return fmt.Sprintf("Attributes({Attributes:%s})", attributesVal) -} - -type StructAsTrait struct { -} - -func NewStructAsTrait() *StructAsTrait { - return &StructAsTrait{} -} - -type StructAsTraitBuilder struct { - obj *StructAsTrait -} - -func NewStructAsTraitBuilder() *StructAsTraitBuilder{ - return &StructAsTraitBuilder{ - obj: NewStructAsTrait(), - } -} - -func (p StructAsTraitBuilder) Emit() *StructAsTrait{ - return &StructAsTrait{ - } -} - -func (p *StructAsTrait) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *StructAsTrait) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("StructAsTrait"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *StructAsTrait) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("StructAsTrait({})") -} - -// This annotation is to generate an entity as internal -type ModuleInternal struct { -} - -func NewModuleInternal() *ModuleInternal { - return &ModuleInternal{} -} - -type ModuleInternalBuilder struct { - obj *ModuleInternal -} - -func NewModuleInternalBuilder() *ModuleInternalBuilder{ - return &ModuleInternalBuilder{ - obj: NewModuleInternal(), - } -} - -func (p ModuleInternalBuilder) Emit() *ModuleInternal{ - return &ModuleInternal{ - } -} - -func (p *ModuleInternal) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ModuleInternal) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("ModuleInternal"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *ModuleInternal) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("ModuleInternal({})") -} - diff --git a/thrift/compiler/test/fixtures/terse_write/gen-go/thrift/annotation/scope/constants.go b/thrift/compiler/test/fixtures/terse_write/gen-go/thrift/annotation/scope/constants.go deleted file mode 100644 index 0c3448a7126..00000000000 --- a/thrift/compiler/test/fixtures/terse_write/gen-go/thrift/annotation/scope/constants.go +++ /dev/null @@ -1,25 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package scope - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - - -func init() { -} - diff --git a/thrift/compiler/test/fixtures/terse_write/gen-go/thrift/annotation/scope/ttypes.go b/thrift/compiler/test/fixtures/terse_write/gen-go/thrift/annotation/scope/ttypes.go deleted file mode 100644 index 580c39e775c..00000000000 --- a/thrift/compiler/test/fixtures/terse_write/gen-go/thrift/annotation/scope/ttypes.go +++ /dev/null @@ -1,1169 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package scope - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var GoUnusedProtection__ int; - -// Indicates that the scope of sibling annotations is transitive. -// -// For example: -// -// @scope.Struct -// @scope.Union -// @scope.Exception -// @scope.Transitive -// struct Structured {} -// -// Annotating a Thrift struct with @Structured automatically applies -// @scope.Struct, @scope.Union and @scope.Exception annotations, i.e. -// -// @Structured -// struct MyAnnotation {} -// -// is equivalent to -// -// @scope.Struct -// @scope.Union -// @scope.Exception -// struct MyAnnotation {} -// -type Transitive struct { -} - -func NewTransitive() *Transitive { - return &Transitive{} -} - -type TransitiveBuilder struct { - obj *Transitive -} - -func NewTransitiveBuilder() *TransitiveBuilder{ - return &TransitiveBuilder{ - obj: NewTransitive(), - } -} - -func (p TransitiveBuilder) Emit() *Transitive{ - return &Transitive{ - } -} - -func (p *Transitive) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Transitive) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Transitive"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Transitive) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Transitive({})") -} - -// The Program scope. -// -// This allows annotations on the `package` definition, which implies the -// annotaiton applies to the entire program. -type Program struct { -} - -func NewProgram() *Program { - return &Program{} -} - -type ProgramBuilder struct { - obj *Program -} - -func NewProgramBuilder() *ProgramBuilder{ - return &ProgramBuilder{ - obj: NewProgram(), - } -} - -func (p ProgramBuilder) Emit() *Program{ - return &Program{ - } -} - -func (p *Program) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Program) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Program"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Program) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Program({})") -} - -// The `struct` definition scope. -type Struct struct { -} - -func NewStruct() *Struct { - return &Struct{} -} - -type StructBuilder struct { - obj *Struct -} - -func NewStructBuilder() *StructBuilder{ - return &StructBuilder{ - obj: NewStruct(), - } -} - -func (p StructBuilder) Emit() *Struct{ - return &Struct{ - } -} - -func (p *Struct) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Struct) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Struct"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Struct) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Struct({})") -} - -// The `union` definition scope. -type Union struct { -} - -func NewUnion() *Union { - return &Union{} -} - -type UnionBuilder struct { - obj *Union -} - -func NewUnionBuilder() *UnionBuilder{ - return &UnionBuilder{ - obj: NewUnion(), - } -} - -func (p UnionBuilder) Emit() *Union{ - return &Union{ - } -} - -func (p *Union) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Union) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Union"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Union) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Union({})") -} - -// The `exception` definition scope. -type Exception struct { -} - -func NewException() *Exception { - return &Exception{} -} - -type ExceptionBuilder struct { - obj *Exception -} - -func NewExceptionBuilder() *ExceptionBuilder{ - return &ExceptionBuilder{ - obj: NewException(), - } -} - -func (p ExceptionBuilder) Emit() *Exception{ - return &Exception{ - } -} - -func (p *Exception) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Exception) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Exception"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Exception) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Exception({})") -} - -// Field declartaions, for example in `struct` or `function` declartions. -type Field struct { -} - -func NewField() *Field { - return &Field{} -} - -type FieldBuilder struct { - obj *Field -} - -func NewFieldBuilder() *FieldBuilder{ - return &FieldBuilder{ - obj: NewField(), - } -} - -func (p FieldBuilder) Emit() *Field{ - return &Field{ - } -} - -func (p *Field) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Field) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Field"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Field) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Field({})") -} - -// The `typedef` definition scope. -type Typedef struct { -} - -func NewTypedef() *Typedef { - return &Typedef{} -} - -type TypedefBuilder struct { - obj *Typedef -} - -func NewTypedefBuilder() *TypedefBuilder{ - return &TypedefBuilder{ - obj: NewTypedef(), - } -} - -func (p TypedefBuilder) Emit() *Typedef{ - return &Typedef{ - } -} - -func (p *Typedef) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Typedef) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Typedef"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Typedef) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Typedef({})") -} - -// The `service` definition scope. -type Service struct { -} - -func NewService() *Service { - return &Service{} -} - -type ServiceBuilder struct { - obj *Service -} - -func NewServiceBuilder() *ServiceBuilder{ - return &ServiceBuilder{ - obj: NewService(), - } -} - -func (p ServiceBuilder) Emit() *Service{ - return &Service{ - } -} - -func (p *Service) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Service) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Service"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Service) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Service({})") -} - -// The `interaction` definition scope. -type Interaction struct { -} - -func NewInteraction() *Interaction { - return &Interaction{} -} - -type InteractionBuilder struct { - obj *Interaction -} - -func NewInteractionBuilder() *InteractionBuilder{ - return &InteractionBuilder{ - obj: NewInteraction(), - } -} - -func (p InteractionBuilder) Emit() *Interaction{ - return &Interaction{ - } -} - -func (p *Interaction) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Interaction) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Interaction"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Interaction) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Interaction({})") -} - -// The `function` definition scope. -type Function struct { -} - -func NewFunction() *Function { - return &Function{} -} - -type FunctionBuilder struct { - obj *Function -} - -func NewFunctionBuilder() *FunctionBuilder{ - return &FunctionBuilder{ - obj: NewFunction(), - } -} - -func (p FunctionBuilder) Emit() *Function{ - return &Function{ - } -} - -func (p *Function) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Function) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Function"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Function) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Function({})") -} - -// The Enum value definition scope. -type EnumValue struct { -} - -func NewEnumValue() *EnumValue { - return &EnumValue{} -} - -type EnumValueBuilder struct { - obj *EnumValue -} - -func NewEnumValueBuilder() *EnumValueBuilder{ - return &EnumValueBuilder{ - obj: NewEnumValue(), - } -} - -func (p EnumValueBuilder) Emit() *EnumValue{ - return &EnumValue{ - } -} - -func (p *EnumValue) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *EnumValue) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("EnumValue"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *EnumValue) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("EnumValue({})") -} - -// The `const` definition scope. -type Const struct { -} - -func NewConst() *Const { - return &Const{} -} - -type ConstBuilder struct { - obj *Const -} - -func NewConstBuilder() *ConstBuilder{ - return &ConstBuilder{ - obj: NewConst(), - } -} - -func (p ConstBuilder) Emit() *Const{ - return &Const{ - } -} - -func (p *Const) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Const) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Const"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Const) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Const({})") -} - -type Enum struct { -} - -func NewEnum() *Enum { - return &Enum{} -} - -type EnumBuilder struct { - obj *Enum -} - -func NewEnumBuilder() *EnumBuilder{ - return &EnumBuilder{ - obj: NewEnum(), - } -} - -func (p EnumBuilder) Emit() *Enum{ - return &Enum{ - } -} - -func (p *Enum) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Enum) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Enum"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Enum) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Enum({})") -} - -// A scope that includes all 'structured' definitions. -type Structured struct { -} - -func NewStructured() *Structured { - return &Structured{} -} - -type StructuredBuilder struct { - obj *Structured -} - -func NewStructuredBuilder() *StructuredBuilder{ - return &StructuredBuilder{ - obj: NewStructured(), - } -} - -func (p StructuredBuilder) Emit() *Structured{ - return &Structured{ - } -} - -func (p *Structured) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Structured) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Structured"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Structured) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Structured({})") -} - -// A scope that includes all 'interface' definitions. -type Interface struct { -} - -func NewInterface() *Interface { - return &Interface{} -} - -type InterfaceBuilder struct { - obj *Interface -} - -func NewInterfaceBuilder() *InterfaceBuilder{ - return &InterfaceBuilder{ - obj: NewInterface(), - } -} - -func (p InterfaceBuilder) Emit() *Interface{ - return &Interface{ - } -} - -func (p *Interface) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Interface) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Interface"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Interface) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Interface({})") -} - -// A scope that includes all program-scoped definition. -type RootDefinition struct { -} - -func NewRootDefinition() *RootDefinition { - return &RootDefinition{} -} - -type RootDefinitionBuilder struct { - obj *RootDefinition -} - -func NewRootDefinitionBuilder() *RootDefinitionBuilder{ - return &RootDefinitionBuilder{ - obj: NewRootDefinition(), - } -} - -func (p RootDefinitionBuilder) Emit() *RootDefinition{ - return &RootDefinition{ - } -} - -func (p *RootDefinition) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *RootDefinition) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("RootDefinition"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *RootDefinition) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("RootDefinition({})") -} - -// A scope that includes all definitions. -type Definition struct { -} - -func NewDefinition() *Definition { - return &Definition{} -} - -type DefinitionBuilder struct { - obj *Definition -} - -func NewDefinitionBuilder() *DefinitionBuilder{ - return &DefinitionBuilder{ - obj: NewDefinition(), - } -} - -func (p DefinitionBuilder) Emit() *Definition{ - return &Definition{ - } -} - -func (p *Definition) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Definition) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Definition"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Definition) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Definition({})") -} - diff --git a/thrift/compiler/test/fixtures/terse_write/gen-go/thrift/annotation/thrift/constants.go b/thrift/compiler/test/fixtures/terse_write/gen-go/thrift/annotation/thrift/constants.go deleted file mode 100644 index 50d9b0fe3ee..00000000000 --- a/thrift/compiler/test/fixtures/terse_write/gen-go/thrift/annotation/thrift/constants.go +++ /dev/null @@ -1,25 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package thrift - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - - -func init() { -} - diff --git a/thrift/compiler/test/fixtures/terse_write/gen-go/thrift/annotation/thrift/ttypes.go b/thrift/compiler/test/fixtures/terse_write/gen-go/thrift/annotation/thrift/ttypes.go deleted file mode 100644 index 35ea75e3dd0..00000000000 --- a/thrift/compiler/test/fixtures/terse_write/gen-go/thrift/annotation/thrift/ttypes.go +++ /dev/null @@ -1,1545 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package thrift - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var GoUnusedProtection__ int; - -type RpcPriority int64 -const ( - RpcPriority_HIGH_IMPORTANT RpcPriority = 0 - RpcPriority_HIGH RpcPriority = 1 - RpcPriority_IMPORTANT RpcPriority = 2 - RpcPriority_NORMAL RpcPriority = 3 - RpcPriority_BEST_EFFORT RpcPriority = 4 -) - -var RpcPriorityToName = map[RpcPriority]string { - RpcPriority_HIGH_IMPORTANT: "HIGH_IMPORTANT", - RpcPriority_HIGH: "HIGH", - RpcPriority_IMPORTANT: "IMPORTANT", - RpcPriority_NORMAL: "NORMAL", - RpcPriority_BEST_EFFORT: "BEST_EFFORT", -} - -var RpcPriorityToValue = map[string]RpcPriority { - "HIGH_IMPORTANT": RpcPriority_HIGH_IMPORTANT, - "HIGH": RpcPriority_HIGH, - "IMPORTANT": RpcPriority_IMPORTANT, - "NORMAL": RpcPriority_NORMAL, - "BEST_EFFORT": RpcPriority_BEST_EFFORT, -} - -var RpcPriorityNames = []string { - "HIGH_IMPORTANT", - "HIGH", - "IMPORTANT", - "NORMAL", - "BEST_EFFORT", -} - -var RpcPriorityValues = []RpcPriority { - RpcPriority_HIGH_IMPORTANT, - RpcPriority_HIGH, - RpcPriority_IMPORTANT, - RpcPriority_NORMAL, - RpcPriority_BEST_EFFORT, -} - -func (p RpcPriority) String() string { - if v, ok := RpcPriorityToName[p]; ok { - return v - } - return "" -} - -func RpcPriorityFromString(s string) (RpcPriority, error) { - if v, ok := RpcPriorityToValue[s]; ok { - return v, nil - } - return RpcPriority(0), fmt.Errorf("not a valid RpcPriority string") -} - -func RpcPriorityPtr(v RpcPriority) *RpcPriority { return &v } - -// Indicates a definition/feature should only be used with permission, may -// only work in specific contexts, and may change in incompatible ways without -// notice. Note that this is primarily intended to annotate features by the Thrift Team -// and isn't recommended for general use. -type Experimental struct { -} - -func NewExperimental() *Experimental { - return &Experimental{} -} - -type ExperimentalBuilder struct { - obj *Experimental -} - -func NewExperimentalBuilder() *ExperimentalBuilder{ - return &ExperimentalBuilder{ - obj: NewExperimental(), - } -} - -func (p ExperimentalBuilder) Emit() *Experimental{ - return &Experimental{ - } -} - -func (p *Experimental) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Experimental) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Experimental"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Experimental) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Experimental({})") -} - -// Annotate a thrift structured or enum to indicate if ids or values should not -// be used. -// -// For example, you may want to mark ids as deprecated, or these ids -// might be reserved for other use cases or annotations. -// -// The resolved set of disallowed ids is the union of the values in `ids` and -// the range of values represented in `id_ranges`. Example: -// -// // These ids are not allowed: 3, 8, half-open ranges [10, 15), [20, 30) -// @thrift.ReserveIds{ids = [3, 8], id_ranges = {10: 15, 20: 30}} -// struct Foo { -// ... -// 3: i64 f; // Build failure: 3 cannot be used -// } -// -// Attributes: -// - Ids: Individual ids that cannot be used. -// - IdRanges: Represents ranges of ids that cannot be used. -// -// Each (key: value) pair represents the half-open range `[key, value)`, -// where `key` is included and `value` is not. For example, the map -// `{10: 15, 20: 30}` represents the union of id/value ranges `[10, 15)` and -// `[20, 30)`. -type ReserveIds struct { - Ids []int32 `thrift:"ids,1" db:"ids" json:"ids"` - IdRanges map[int32]int32 `thrift:"id_ranges,2" db:"id_ranges" json:"id_ranges"` -} - -func NewReserveIds() *ReserveIds { - return &ReserveIds{} -} - - -func (p *ReserveIds) GetIds() []int32 { - return p.Ids -} - -func (p *ReserveIds) GetIdRanges() map[int32]int32 { - return p.IdRanges -} -type ReserveIdsBuilder struct { - obj *ReserveIds -} - -func NewReserveIdsBuilder() *ReserveIdsBuilder{ - return &ReserveIdsBuilder{ - obj: NewReserveIds(), - } -} - -func (p ReserveIdsBuilder) Emit() *ReserveIds{ - return &ReserveIds{ - Ids: p.obj.Ids, - IdRanges: p.obj.IdRanges, - } -} - -func (r *ReserveIdsBuilder) Ids(ids []int32) *ReserveIdsBuilder { - r.obj.Ids = ids - return r -} - -func (r *ReserveIdsBuilder) IdRanges(idRanges map[int32]int32) *ReserveIdsBuilder { - r.obj.IdRanges = idRanges - return r -} - -func (r *ReserveIds) SetIds(ids []int32) *ReserveIds { - r.Ids = ids - return r -} - -func (r *ReserveIds) SetIdRanges(idRanges map[int32]int32) *ReserveIds { - r.IdRanges = idRanges - return r -} - -func (p *ReserveIds) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ReserveIds) ReadField1(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]int32, 0, size) - p.Ids = tSlice - for i := 0; i < size; i ++ { - var _elem0 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem0 = v - } - p.Ids = append(p.Ids, _elem0) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *ReserveIds) ReadField2(iprot thrift.Protocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[int32]int32, size) - p.IdRanges = tMap - for i := 0; i < size; i ++ { - var _key1 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key1 = v - } - var _val2 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _val2 = v - } - p.IdRanges[_key1] = _val2 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *ReserveIds) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("ReserveIds"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *ReserveIds) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("ids", thrift.LIST, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:ids: ", p), err) } - if err := oprot.WriteListBegin(thrift.I32, len(p.Ids)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.Ids { - if err := oprot.WriteI32(int32(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:ids: ", p), err) } - return err -} - -func (p *ReserveIds) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("id_ranges", thrift.MAP, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:id_ranges: ", p), err) } - if err := oprot.WriteMapBegin(thrift.I32, thrift.I32, len(p.IdRanges)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.IdRanges { - if err := oprot.WriteI32(int32(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := oprot.WriteI32(int32(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:id_ranges: ", p), err) } - return err -} - -func (p *ReserveIds) String() string { - if p == nil { - return "" - } - - idsVal := fmt.Sprintf("%v", p.Ids) - idRangesVal := fmt.Sprintf("%v", p.IdRanges) - return fmt.Sprintf("ReserveIds({Ids:%s IdRanges:%s})", idsVal, idRangesVal) -} - -// Indicates additional backward compatibility restrictions, beyond the -// standard Thrift required 'wire' compatibility. -// -// Attributes: -// - FieldName -type RequiresBackwardCompatibility struct { - FieldName bool `thrift:"field_name,1" db:"field_name" json:"field_name"` -} - -func NewRequiresBackwardCompatibility() *RequiresBackwardCompatibility { - return &RequiresBackwardCompatibility{} -} - - -func (p *RequiresBackwardCompatibility) GetFieldName() bool { - return p.FieldName -} -type RequiresBackwardCompatibilityBuilder struct { - obj *RequiresBackwardCompatibility -} - -func NewRequiresBackwardCompatibilityBuilder() *RequiresBackwardCompatibilityBuilder{ - return &RequiresBackwardCompatibilityBuilder{ - obj: NewRequiresBackwardCompatibility(), - } -} - -func (p RequiresBackwardCompatibilityBuilder) Emit() *RequiresBackwardCompatibility{ - return &RequiresBackwardCompatibility{ - FieldName: p.obj.FieldName, - } -} - -func (r *RequiresBackwardCompatibilityBuilder) FieldName(fieldName bool) *RequiresBackwardCompatibilityBuilder { - r.obj.FieldName = fieldName - return r -} - -func (r *RequiresBackwardCompatibility) SetFieldName(fieldName bool) *RequiresBackwardCompatibility { - r.FieldName = fieldName - return r -} - -func (p *RequiresBackwardCompatibility) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *RequiresBackwardCompatibility) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.FieldName = v - } - return nil -} - -func (p *RequiresBackwardCompatibility) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("RequiresBackwardCompatibility"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *RequiresBackwardCompatibility) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("field_name", thrift.BOOL, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:field_name: ", p), err) } - if err := oprot.WriteBool(bool(p.FieldName)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.field_name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:field_name: ", p), err) } - return err -} - -func (p *RequiresBackwardCompatibility) String() string { - if p == nil { - return "" - } - - fieldNameVal := fmt.Sprintf("%v", p.FieldName) - return fmt.Sprintf("RequiresBackwardCompatibility({FieldName:%s})", fieldNameVal) -} - -// An annotation that changes the field qualifier from 'none' to 'terse'. -// A terse field is eligible to skip serialization, when it equals to the -// intrinsic default value. It also clears to the intrinsic default value -// before deserialization to distinguish between if a terse field was skipped -// or missing during serialization. This is different from an unqualified -// field, as an unqualified field is always serialized regardless of its value, -// and it is not cleared before deserialization. -// -// The annotation can be only used to annotate an unqualified field, and when -// it is annotating a struct or exception, it changes all unqualified fields to -// terse fields. Note, the annotation can not be used for union. -type TerseWrite struct { -} - -func NewTerseWrite() *TerseWrite { - return &TerseWrite{} -} - -type TerseWriteBuilder struct { - obj *TerseWrite -} - -func NewTerseWriteBuilder() *TerseWriteBuilder{ - return &TerseWriteBuilder{ - obj: NewTerseWrite(), - } -} - -func (p TerseWriteBuilder) Emit() *TerseWrite{ - return &TerseWrite{ - } -} - -func (p *TerseWrite) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *TerseWrite) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("TerseWrite"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *TerseWrite) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("TerseWrite({})") -} - -// Indicates that an optional field's value should never be stored on the stack, -// i.e. the subobject should be allocated separately (e.g. because it is large and infrequently set). -// -// NOTE: The APIs and initialization behavior are same as normal field, but different from `@cpp.Ref`. e.g. -// -// ``` -// struct Foo { -// 1: optional i32 normal; -// @thrift.Box -// 2: optional i32 boxed; -// @cpp.Ref -// 3: optional i32 referred; -// } -// ``` -// in C++ -// -// ``` -// Foo foo; -// EXPECT_FALSE(foo.normal().has_value()); // okay -// EXPECT_FALSE(foo.boxed().has_value()); // okay -// EXPECT_FALSE(foo.referred().has_value()); // build failure: std::unique_ptr doesn't have has_value method -// -// EXPECT_EQ(*foo.normal(), 0); // throw bad_field_access exception -// EXPECT_EQ(*foo.boxed(), 0); // throw bad_field_access exception -// EXPECT_EQ(*foo.referred(), 0); // okay, field has value by default -// ``` -// -// Affects C++ and Rust. -// TODO: replace with @cpp.Box + @rust.Box -type Box struct { -} - -func NewBox() *Box { - return &Box{} -} - -type BoxBuilder struct { - obj *Box -} - -func NewBoxBuilder() *BoxBuilder{ - return &BoxBuilder{ - obj: NewBox(), - } -} - -func (p BoxBuilder) Emit() *Box{ - return &Box{ - } -} - -func (p *Box) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Box) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Box"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Box) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Box({})") -} - -// Indicates whether the nested fields are accessible directly. -// https://github.com/facebook/fbthrift/blob/v2023.11.20.00/thrift/doc/idl/mixins.md -type Mixin struct { -} - -func NewMixin() *Mixin { - return &Mixin{} -} - -type MixinBuilder struct { - obj *Mixin -} - -func NewMixinBuilder() *MixinBuilder{ - return &MixinBuilder{ - obj: NewMixin(), - } -} - -func (p MixinBuilder) Emit() *Mixin{ - return &Mixin{ - } -} - -func (p *Mixin) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Mixin) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Mixin"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Mixin) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Mixin({})") -} - -// Option to serialize thrift struct in ascending field id order instead of field declaration order. -// -// This can potentially make serialized data size smaller in compact protocol, -// since compact protocol can write deltas between subsequent field ids instead of full ids. -// -// NOTE: This annotation won't reduce payload size for other protocols. -type SerializeInFieldIdOrder struct { -} - -func NewSerializeInFieldIdOrder() *SerializeInFieldIdOrder { - return &SerializeInFieldIdOrder{} -} - -type SerializeInFieldIdOrderBuilder struct { - obj *SerializeInFieldIdOrder -} - -func NewSerializeInFieldIdOrderBuilder() *SerializeInFieldIdOrderBuilder{ - return &SerializeInFieldIdOrderBuilder{ - obj: NewSerializeInFieldIdOrder(), - } -} - -func (p SerializeInFieldIdOrderBuilder) Emit() *SerializeInFieldIdOrder{ - return &SerializeInFieldIdOrder{ - } -} - -func (p *SerializeInFieldIdOrder) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *SerializeInFieldIdOrder) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("SerializeInFieldIdOrder"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *SerializeInFieldIdOrder) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("SerializeInFieldIdOrder({})") -} - -// Indicates an enum is a bitmask and should support bit-wise operators. -// Currently generates additional code in C++ and Hack. -type BitmaskEnum struct { -} - -func NewBitmaskEnum() *BitmaskEnum { - return &BitmaskEnum{} -} - -type BitmaskEnumBuilder struct { - obj *BitmaskEnum -} - -func NewBitmaskEnumBuilder() *BitmaskEnumBuilder{ - return &BitmaskEnumBuilder{ - obj: NewBitmaskEnum(), - } -} - -func (p BitmaskEnumBuilder) Emit() *BitmaskEnum{ - return &BitmaskEnum{ - } -} - -func (p *BitmaskEnum) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *BitmaskEnum) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("BitmaskEnum"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *BitmaskEnum) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("BitmaskEnum({})") -} - -// Specifies the field where the exception message is stored. -type ExceptionMessage struct { -} - -func NewExceptionMessage() *ExceptionMessage { - return &ExceptionMessage{} -} - -type ExceptionMessageBuilder struct { - obj *ExceptionMessage -} - -func NewExceptionMessageBuilder() *ExceptionMessageBuilder{ - return &ExceptionMessageBuilder{ - obj: NewExceptionMessage(), - } -} - -func (p ExceptionMessageBuilder) Emit() *ExceptionMessage{ - return &ExceptionMessage{ - } -} - -func (p *ExceptionMessage) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ExceptionMessage) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("ExceptionMessage"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *ExceptionMessage) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("ExceptionMessage({})") -} - -// Generates a const of type schema. Struct containing the schema of the -// annotated type. Optionally specify name to override default -// schema. -// -// Attributes: -// - Name -type GenerateRuntimeSchema struct { - Name string `thrift:"name,1" db:"name" json:"name"` -} - -func NewGenerateRuntimeSchema() *GenerateRuntimeSchema { - return &GenerateRuntimeSchema{} -} - - -func (p *GenerateRuntimeSchema) GetName() string { - return p.Name -} -type GenerateRuntimeSchemaBuilder struct { - obj *GenerateRuntimeSchema -} - -func NewGenerateRuntimeSchemaBuilder() *GenerateRuntimeSchemaBuilder{ - return &GenerateRuntimeSchemaBuilder{ - obj: NewGenerateRuntimeSchema(), - } -} - -func (p GenerateRuntimeSchemaBuilder) Emit() *GenerateRuntimeSchema{ - return &GenerateRuntimeSchema{ - Name: p.obj.Name, - } -} - -func (g *GenerateRuntimeSchemaBuilder) Name(name string) *GenerateRuntimeSchemaBuilder { - g.obj.Name = name - return g -} - -func (g *GenerateRuntimeSchema) SetName(name string) *GenerateRuntimeSchema { - g.Name = name - return g -} - -func (p *GenerateRuntimeSchema) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *GenerateRuntimeSchema) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Name = v - } - return nil -} - -func (p *GenerateRuntimeSchema) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("GenerateRuntimeSchema"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *GenerateRuntimeSchema) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) } - if err := oprot.WriteString(string(p.Name)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) } - return err -} - -func (p *GenerateRuntimeSchema) String() string { - if p == nil { - return "" - } - - nameVal := fmt.Sprintf("%v", p.Name) - return fmt.Sprintf("GenerateRuntimeSchema({Name:%s})", nameVal) -} - -// Indicates that a field's value should never be stored on the stack, and that -// identical values can be shared in immutable contexts. -type InternBox struct { -} - -func NewInternBox() *InternBox { - return &InternBox{} -} - -type InternBoxBuilder struct { - obj *InternBox -} - -func NewInternBoxBuilder() *InternBoxBuilder{ - return &InternBoxBuilder{ - obj: NewInternBox(), - } -} - -func (p InternBoxBuilder) Emit() *InternBox{ - return &InternBox{ - } -} - -func (p *InternBox) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *InternBox) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("InternBox"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *InternBox) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("InternBox({})") -} - -// Indicates that an interaction's methods should be processed sequentially. -type Serial struct { -} - -func NewSerial() *Serial { - return &Serial{} -} - -type SerialBuilder struct { - obj *Serial -} - -func NewSerialBuilder() *SerialBuilder{ - return &SerialBuilder{ - obj: NewSerial(), - } -} - -func (p SerialBuilder) Emit() *Serial{ - return &Serial{ - } -} - -func (p *Serial) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Serial) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Serial"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Serial) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Serial({})") -} - -// Changes the URI of this definition away from the default-generated one. -// -// Attributes: -// - Value -type Uri struct { - Value string `thrift:"value,1" db:"value" json:"value"` -} - -func NewUri() *Uri { - return &Uri{} -} - - -func (p *Uri) GetValue() string { - return p.Value -} -type UriBuilder struct { - obj *Uri -} - -func NewUriBuilder() *UriBuilder{ - return &UriBuilder{ - obj: NewUri(), - } -} - -func (p UriBuilder) Emit() *Uri{ - return &Uri{ - Value: p.obj.Value, - } -} - -func (u *UriBuilder) Value(value string) *UriBuilder { - u.obj.Value = value - return u -} - -func (u *Uri) SetValue(value string) *Uri { - u.Value = value - return u -} - -func (p *Uri) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Uri) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Value = v - } - return nil -} - -func (p *Uri) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Uri"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Uri) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("value", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:value: ", p), err) } - if err := oprot.WriteString(string(p.Value)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.value (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:value: ", p), err) } - return err -} - -func (p *Uri) String() string { - if p == nil { - return "" - } - - valueVal := fmt.Sprintf("%v", p.Value) - return fmt.Sprintf("Uri({Value:%s})", valueVal) -} - -// Changes the priority of this function (default NORMAL). -// -// Attributes: -// - Level -type Priority struct { - Level RpcPriority `thrift:"level,1" db:"level" json:"level"` -} - -func NewPriority() *Priority { - return &Priority{} -} - - -func (p *Priority) GetLevel() RpcPriority { - return p.Level -} -type PriorityBuilder struct { - obj *Priority -} - -func NewPriorityBuilder() *PriorityBuilder{ - return &PriorityBuilder{ - obj: NewPriority(), - } -} - -func (p PriorityBuilder) Emit() *Priority{ - return &Priority{ - Level: p.obj.Level, - } -} - -func (p *PriorityBuilder) Level(level RpcPriority) *PriorityBuilder { - p.obj.Level = level - return p -} - -func (p *Priority) SetLevel(level RpcPriority) *Priority { - p.Level = level - return p -} - -func (p *Priority) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Priority) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - temp := RpcPriority(v) - p.Level = temp - } - return nil -} - -func (p *Priority) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Priority"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Priority) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("level", thrift.I32, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:level: ", p), err) } - if err := oprot.WriteI32(int32(p.Level)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.level (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:level: ", p), err) } - return err -} - -func (p *Priority) String() string { - if p == nil { - return "" - } - - levelVal := fmt.Sprintf("%v", p.Level) - return fmt.Sprintf("Priority({Level:%s})", levelVal) -} - -// Applies unstructured annotations to a definition. -// -// Attributes: -// - Items -type DeprecatedUnvalidatedAnnotations struct { - Items map[string]string `thrift:"items,1" db:"items" json:"items"` -} - -func NewDeprecatedUnvalidatedAnnotations() *DeprecatedUnvalidatedAnnotations { - return &DeprecatedUnvalidatedAnnotations{} -} - - -func (p *DeprecatedUnvalidatedAnnotations) GetItems() map[string]string { - return p.Items -} -type DeprecatedUnvalidatedAnnotationsBuilder struct { - obj *DeprecatedUnvalidatedAnnotations -} - -func NewDeprecatedUnvalidatedAnnotationsBuilder() *DeprecatedUnvalidatedAnnotationsBuilder{ - return &DeprecatedUnvalidatedAnnotationsBuilder{ - obj: NewDeprecatedUnvalidatedAnnotations(), - } -} - -func (p DeprecatedUnvalidatedAnnotationsBuilder) Emit() *DeprecatedUnvalidatedAnnotations{ - return &DeprecatedUnvalidatedAnnotations{ - Items: p.obj.Items, - } -} - -func (d *DeprecatedUnvalidatedAnnotationsBuilder) Items(items map[string]string) *DeprecatedUnvalidatedAnnotationsBuilder { - d.obj.Items = items - return d -} - -func (d *DeprecatedUnvalidatedAnnotations) SetItems(items map[string]string) *DeprecatedUnvalidatedAnnotations { - d.Items = items - return d -} - -func (p *DeprecatedUnvalidatedAnnotations) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *DeprecatedUnvalidatedAnnotations) ReadField1(iprot thrift.Protocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[string]string, size) - p.Items = tMap - for i := 0; i < size; i ++ { - var _key3 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key3 = v - } - var _val4 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _val4 = v - } - p.Items[_key3] = _val4 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *DeprecatedUnvalidatedAnnotations) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("DeprecatedUnvalidatedAnnotations"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *DeprecatedUnvalidatedAnnotations) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("items", thrift.MAP, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:items: ", p), err) } - if err := oprot.WriteMapBegin(thrift.STRING, thrift.STRING, len(p.Items)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.Items { - if err := oprot.WriteString(string(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := oprot.WriteString(string(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:items: ", p), err) } - return err -} - -func (p *DeprecatedUnvalidatedAnnotations) String() string { - if p == nil { - return "" - } - - itemsVal := fmt.Sprintf("%v", p.Items) - return fmt.Sprintf("DeprecatedUnvalidatedAnnotations({Items:%s})", itemsVal) -} - diff --git a/thrift/compiler/test/fixtures/types/gen-go/included/constants.go b/thrift/compiler/test/fixtures/types/gen-go/included/constants.go deleted file mode 100644 index 771112df761..00000000000 --- a/thrift/compiler/test/fixtures/types/gen-go/included/constants.go +++ /dev/null @@ -1,25 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package included - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - - -func init() { -} - diff --git a/thrift/compiler/test/fixtures/types/gen-go/included/ttypes.go b/thrift/compiler/test/fixtures/types/gen-go/included/ttypes.go deleted file mode 100644 index f4ee1706c75..00000000000 --- a/thrift/compiler/test/fixtures/types/gen-go/included/ttypes.go +++ /dev/null @@ -1,31 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package included - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var GoUnusedProtection__ int; - -type SomeMap = map[int32]string - -func SomeMapPtr(v SomeMap) *SomeMap { return &v } - -type SomeListOfTypeMap = []SomeMap - -func SomeListOfTypeMapPtr(v SomeListOfTypeMap) *SomeListOfTypeMap { return &v } - diff --git a/thrift/compiler/test/fixtures/types/gen-go/module/constants.go b/thrift/compiler/test/fixtures/types/gen-go/module/constants.go deleted file mode 100644 index 5c16afa1c2a..00000000000 --- a/thrift/compiler/test/fixtures/types/gen-go/module/constants.go +++ /dev/null @@ -1,28 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package module - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" - included0 "included" - -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var _ = included0.GoUnusedProtection__ - -func init() { -} - diff --git a/thrift/compiler/test/fixtures/types/gen-go/module/someservice.go b/thrift/compiler/test/fixtures/types/gen-go/module/someservice.go deleted file mode 100644 index 7db01ea82a7..00000000000 --- a/thrift/compiler/test/fixtures/types/gen-go/module/someservice.go +++ /dev/null @@ -1,963 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package module - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" - included0 "included" - -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var _ = included0.GoUnusedProtection__ -type SomeService interface { - // Parameters: - // - M - BounceMap(m included0.SomeMap) (_r included0.SomeMap, err error) - // Parameters: - // - R - BinaryKeyedMap(r []int64) (_r map[string]int64, err error) -} - -type SomeServiceClientInterface interface { - thrift.ClientInterface - // Parameters: - // - M - BounceMap(m included0.SomeMap) (_r included0.SomeMap, err error) - // Parameters: - // - R - BinaryKeyedMap(r []int64) (_r map[string]int64, err error) -} - -type SomeServiceClient struct { - SomeServiceClientInterface - CC thrift.ClientConn -} - -func(client *SomeServiceClient) Open() error { - return client.CC.Open() -} - -func(client *SomeServiceClient) Close() error { - return client.CC.Close() -} - -func(client *SomeServiceClient) IsOpen() bool { - return client.CC.IsOpen() -} - -func NewSomeServiceClientFactory(t thrift.Transport, f thrift.ProtocolFactory) *SomeServiceClient { - return &SomeServiceClient{ CC: thrift.NewClientConn(t, f) } -} - -func NewSomeServiceClient(t thrift.Transport, iprot thrift.Protocol, oprot thrift.Protocol) *SomeServiceClient { - return &SomeServiceClient{ CC: thrift.NewClientConnWithProtocols(t, iprot, oprot) } -} - -func NewSomeServiceClientProtocol(prot thrift.Protocol) *SomeServiceClient { - return NewSomeServiceClient(prot.Transport(), prot, prot) -} - -// Parameters: -// - M -func (p *SomeServiceClient) BounceMap(m included0.SomeMap) (_r included0.SomeMap, err error) { - args := SomeServiceBounceMapArgs{ - M : m, - } - err = p.CC.SendMsg("bounce_map", &args, thrift.CALL) - if err != nil { return } - return p.recvBounceMap() -} - - -func (p *SomeServiceClient) recvBounceMap() (value included0.SomeMap, err error) { - var __result SomeServiceBounceMapResult - err = p.CC.RecvMsg("bounce_map", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -// Parameters: -// - R -func (p *SomeServiceClient) BinaryKeyedMap(r []int64) (_r map[string]int64, err error) { - args := SomeServiceBinaryKeyedMapArgs{ - R : r, - } - err = p.CC.SendMsg("binary_keyed_map", &args, thrift.CALL) - if err != nil { return } - return p.recvBinaryKeyedMap() -} - - -func (p *SomeServiceClient) recvBinaryKeyedMap() (value map[string]int64, err error) { - var __result SomeServiceBinaryKeyedMapResult - err = p.CC.RecvMsg("binary_keyed_map", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - - -type SomeServiceThreadsafeClient struct { - SomeServiceClientInterface - CC thrift.ClientConn - Mu sync.Mutex -} - -func(client *SomeServiceThreadsafeClient) Open() error { - client.Mu.Lock() - defer client.Mu.Unlock() - return client.CC.Open() -} - -func(client *SomeServiceThreadsafeClient) Close() error { - client.Mu.Lock() - defer client.Mu.Unlock() - return client.CC.Close() -} - -func(client *SomeServiceThreadsafeClient) IsOpen() bool { - client.Mu.Lock() - defer client.Mu.Unlock() - return client.CC.IsOpen() -} - -func NewSomeServiceThreadsafeClientFactory(t thrift.Transport, f thrift.ProtocolFactory) *SomeServiceThreadsafeClient { - return &SomeServiceThreadsafeClient{ CC: thrift.NewClientConn(t, f) } -} - -func NewSomeServiceThreadsafeClient(t thrift.Transport, iprot thrift.Protocol, oprot thrift.Protocol) *SomeServiceThreadsafeClient { - return &SomeServiceThreadsafeClient{ CC: thrift.NewClientConnWithProtocols(t, iprot, oprot) } -} - -func NewSomeServiceThreadsafeClientProtocol(prot thrift.Protocol) *SomeServiceThreadsafeClient { - return NewSomeServiceThreadsafeClient(prot.Transport(), prot, prot) -} - -// Parameters: -// - M -func (p *SomeServiceThreadsafeClient) BounceMap(m included0.SomeMap) (_r included0.SomeMap, err error) { - p.Mu.Lock() - defer p.Mu.Unlock() - args := SomeServiceBounceMapArgs{ - M : m, - } - err = p.CC.SendMsg("bounce_map", &args, thrift.CALL) - if err != nil { return } - return p.recvBounceMap() -} - - -func (p *SomeServiceThreadsafeClient) recvBounceMap() (value included0.SomeMap, err error) { - var __result SomeServiceBounceMapResult - err = p.CC.RecvMsg("bounce_map", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -// Parameters: -// - R -func (p *SomeServiceThreadsafeClient) BinaryKeyedMap(r []int64) (_r map[string]int64, err error) { - p.Mu.Lock() - defer p.Mu.Unlock() - args := SomeServiceBinaryKeyedMapArgs{ - R : r, - } - err = p.CC.SendMsg("binary_keyed_map", &args, thrift.CALL) - if err != nil { return } - return p.recvBinaryKeyedMap() -} - - -func (p *SomeServiceThreadsafeClient) recvBinaryKeyedMap() (value map[string]int64, err error) { - var __result SomeServiceBinaryKeyedMapResult - err = p.CC.RecvMsg("binary_keyed_map", &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - - -type SomeServiceChannelClient struct { - RequestChannel thrift.RequestChannel -} - -func (c *SomeServiceChannelClient) Close() error { - return c.RequestChannel.Close() -} - -func (c *SomeServiceChannelClient) IsOpen() bool { - return c.RequestChannel.IsOpen() -} - -func (c *SomeServiceChannelClient) Open() error { - return c.RequestChannel.Open() -} - -func NewSomeServiceChannelClient(channel thrift.RequestChannel) *SomeServiceChannelClient { - return &SomeServiceChannelClient{RequestChannel: channel} -} - -// Parameters: -// - M -func (p *SomeServiceChannelClient) BounceMap(ctx context.Context, m included0.SomeMap) (_r included0.SomeMap, err error) { - args := SomeServiceBounceMapArgs{ - M : m, - } - var __result SomeServiceBounceMapResult - err = p.RequestChannel.Call(ctx, "bounce_map", &args, &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - -// Parameters: -// - R -func (p *SomeServiceChannelClient) BinaryKeyedMap(ctx context.Context, r []int64) (_r map[string]int64, err error) { - args := SomeServiceBinaryKeyedMapArgs{ - R : r, - } - var __result SomeServiceBinaryKeyedMapResult - err = p.RequestChannel.Call(ctx, "binary_keyed_map", &args, &__result) - if err != nil { return } - - return __result.GetSuccess(), nil -} - - -type SomeServiceProcessor struct { - processorMap map[string]thrift.ProcessorFunction - functionServiceMap map[string]string - handler SomeService -} - -func (p *SomeServiceProcessor) AddToProcessorMap(key string, processor thrift.ProcessorFunction) { - p.processorMap[key] = processor -} - -func (p *SomeServiceProcessor) AddToFunctionServiceMap(key, service string) { - p.functionServiceMap[key] = service -} - -func (p *SomeServiceProcessor) GetProcessorFunction(key string) (processor thrift.ProcessorFunction, err error) { - if processor, ok := p.processorMap[key]; ok { - return processor, nil - } - return nil, nil // generic error message will be sent -} - -func (p *SomeServiceProcessor) ProcessorMap() map[string]thrift.ProcessorFunction { - return p.processorMap -} - -func (p *SomeServiceProcessor) FunctionServiceMap() map[string]string { - return p.functionServiceMap -} - -func NewSomeServiceProcessor(handler SomeService) *SomeServiceProcessor { - self29 := &SomeServiceProcessor{handler:handler, processorMap:make(map[string]thrift.ProcessorFunction), functionServiceMap:make(map[string]string)} - self29.processorMap["bounce_map"] = &someServiceProcessorBounceMap{handler:handler} - self29.processorMap["binary_keyed_map"] = &someServiceProcessorBinaryKeyedMap{handler:handler} - self29.functionServiceMap["bounce_map"] = "SomeService" - self29.functionServiceMap["binary_keyed_map"] = "SomeService" - return self29 -} - -type someServiceProcessorBounceMap struct { - handler SomeService -} - -func (p *SomeServiceBounceMapResult) Exception() thrift.WritableException { - if p == nil { return nil } - return nil -} - -func (p *someServiceProcessorBounceMap) Read(iprot thrift.Protocol) (thrift.Struct, thrift.Exception) { - args := SomeServiceBounceMapArgs{} - if err := args.Read(iprot); err != nil { - return nil, err - } - iprot.ReadMessageEnd() - return &args, nil -} - -func (p *someServiceProcessorBounceMap) Write(seqId int32, result thrift.WritableStruct, oprot thrift.Protocol) (err thrift.Exception) { - var err2 error - messageType := thrift.REPLY - switch result.(type) { - case thrift.ApplicationException: - messageType = thrift.EXCEPTION - } - if err2 = oprot.WriteMessageBegin("bounce_map", messageType, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - return err -} - -func (p *someServiceProcessorBounceMap) Run(argStruct thrift.Struct) (thrift.WritableStruct, thrift.ApplicationException) { - args := argStruct.(*SomeServiceBounceMapArgs) - var __result SomeServiceBounceMapResult - if retval, err := p.handler.BounceMap(args.M); err != nil { - switch err.(type) { - default: - x := thrift.NewApplicationExceptionCause(thrift.INTERNAL_ERROR, "Internal error processing bounce_map: " + err.Error(), err) - return x, x - } - } else { - __result.Success = retval - } - return &__result, nil -} - -type someServiceProcessorBinaryKeyedMap struct { - handler SomeService -} - -func (p *SomeServiceBinaryKeyedMapResult) Exception() thrift.WritableException { - if p == nil { return nil } - return nil -} - -func (p *someServiceProcessorBinaryKeyedMap) Read(iprot thrift.Protocol) (thrift.Struct, thrift.Exception) { - args := SomeServiceBinaryKeyedMapArgs{} - if err := args.Read(iprot); err != nil { - return nil, err - } - iprot.ReadMessageEnd() - return &args, nil -} - -func (p *someServiceProcessorBinaryKeyedMap) Write(seqId int32, result thrift.WritableStruct, oprot thrift.Protocol) (err thrift.Exception) { - var err2 error - messageType := thrift.REPLY - switch result.(type) { - case thrift.ApplicationException: - messageType = thrift.EXCEPTION - } - if err2 = oprot.WriteMessageBegin("binary_keyed_map", messageType, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - return err -} - -func (p *someServiceProcessorBinaryKeyedMap) Run(argStruct thrift.Struct) (thrift.WritableStruct, thrift.ApplicationException) { - args := argStruct.(*SomeServiceBinaryKeyedMapArgs) - var __result SomeServiceBinaryKeyedMapResult - if retval, err := p.handler.BinaryKeyedMap(args.R); err != nil { - switch err.(type) { - default: - x := thrift.NewApplicationExceptionCause(thrift.INTERNAL_ERROR, "Internal error processing binary_keyed_map: " + err.Error(), err) - return x, x - } - } else { - __result.Success = retval - } - return &__result, nil -} - - -// HELPER FUNCTIONS AND STRUCTURES - -// Attributes: -// - M -type SomeServiceBounceMapArgs struct { - thrift.IRequest - M included0.SomeMap `thrift:"m,1" db:"m" json:"m"` -} - -func NewSomeServiceBounceMapArgs() *SomeServiceBounceMapArgs { - return &SomeServiceBounceMapArgs{} -} - - -func (p *SomeServiceBounceMapArgs) GetM() included0.SomeMap { - return p.M -} -type SomeServiceBounceMapArgsBuilder struct { - obj *SomeServiceBounceMapArgs -} - -func NewSomeServiceBounceMapArgsBuilder() *SomeServiceBounceMapArgsBuilder{ - return &SomeServiceBounceMapArgsBuilder{ - obj: NewSomeServiceBounceMapArgs(), - } -} - -func (p SomeServiceBounceMapArgsBuilder) Emit() *SomeServiceBounceMapArgs{ - return &SomeServiceBounceMapArgs{ - M: p.obj.M, - } -} - -func (s *SomeServiceBounceMapArgsBuilder) M(m included0.SomeMap) *SomeServiceBounceMapArgsBuilder { - s.obj.M = m - return s -} - -func (s *SomeServiceBounceMapArgs) SetM(m included0.SomeMap) *SomeServiceBounceMapArgs { - s.M = m - return s -} - -func (p *SomeServiceBounceMapArgs) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *SomeServiceBounceMapArgs) ReadField1(iprot thrift.Protocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(included0.SomeMap, size) - p.M = tMap - for i := 0; i < size; i ++ { - var _key31 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key31 = v - } - var _val32 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _val32 = v - } - p.M[_key31] = _val32 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *SomeServiceBounceMapArgs) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("bounce_map_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *SomeServiceBounceMapArgs) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("m", thrift.MAP, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:m: ", p), err) } - if err := oprot.WriteMapBegin(thrift.I32, thrift.STRING, len(p.M)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.M { - if err := oprot.WriteI32(int32(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := oprot.WriteString(string(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:m: ", p), err) } - return err -} - -func (p *SomeServiceBounceMapArgs) String() string { - if p == nil { - return "" - } - - mVal := fmt.Sprintf("%v", p.M) - return fmt.Sprintf("SomeServiceBounceMapArgs({M:%s})", mVal) -} - -// Attributes: -// - Success -type SomeServiceBounceMapResult struct { - thrift.IResponse - Success included0.SomeMap `thrift:"success,0,optional" db:"success" json:"success,omitempty"` -} - -func NewSomeServiceBounceMapResult() *SomeServiceBounceMapResult { - return &SomeServiceBounceMapResult{} -} - -var SomeServiceBounceMapResult_Success_DEFAULT included0.SomeMap - -func (p *SomeServiceBounceMapResult) GetSuccess() included0.SomeMap { - return p.Success -} -func (p *SomeServiceBounceMapResult) IsSetSuccess() bool { - return p != nil && p.Success != nil -} - -type SomeServiceBounceMapResultBuilder struct { - obj *SomeServiceBounceMapResult -} - -func NewSomeServiceBounceMapResultBuilder() *SomeServiceBounceMapResultBuilder{ - return &SomeServiceBounceMapResultBuilder{ - obj: NewSomeServiceBounceMapResult(), - } -} - -func (p SomeServiceBounceMapResultBuilder) Emit() *SomeServiceBounceMapResult{ - return &SomeServiceBounceMapResult{ - Success: p.obj.Success, - } -} - -func (s *SomeServiceBounceMapResultBuilder) Success(success included0.SomeMap) *SomeServiceBounceMapResultBuilder { - s.obj.Success = success - return s -} - -func (s *SomeServiceBounceMapResult) SetSuccess(success included0.SomeMap) *SomeServiceBounceMapResult { - s.Success = success - return s -} - -func (p *SomeServiceBounceMapResult) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 0: - if err := p.ReadField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *SomeServiceBounceMapResult) ReadField0(iprot thrift.Protocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(included0.SomeMap, size) - p.Success = tMap - for i := 0; i < size; i ++ { - var _key33 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key33 = v - } - var _val34 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _val34 = v - } - p.Success[_key33] = _val34 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *SomeServiceBounceMapResult) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("bounce_map_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField0(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *SomeServiceBounceMapResult) writeField0(oprot thrift.Protocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.MAP, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := oprot.WriteMapBegin(thrift.I32, thrift.STRING, len(p.Success)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.Success { - if err := oprot.WriteI32(int32(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := oprot.WriteString(string(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } - } - return err -} - -func (p *SomeServiceBounceMapResult) String() string { - if p == nil { - return "" - } - - successVal := fmt.Sprintf("%v", p.Success) - return fmt.Sprintf("SomeServiceBounceMapResult({Success:%s})", successVal) -} - -// Attributes: -// - R -type SomeServiceBinaryKeyedMapArgs struct { - thrift.IRequest - R []int64 `thrift:"r,1" db:"r" json:"r"` -} - -func NewSomeServiceBinaryKeyedMapArgs() *SomeServiceBinaryKeyedMapArgs { - return &SomeServiceBinaryKeyedMapArgs{} -} - - -func (p *SomeServiceBinaryKeyedMapArgs) GetR() []int64 { - return p.R -} -type SomeServiceBinaryKeyedMapArgsBuilder struct { - obj *SomeServiceBinaryKeyedMapArgs -} - -func NewSomeServiceBinaryKeyedMapArgsBuilder() *SomeServiceBinaryKeyedMapArgsBuilder{ - return &SomeServiceBinaryKeyedMapArgsBuilder{ - obj: NewSomeServiceBinaryKeyedMapArgs(), - } -} - -func (p SomeServiceBinaryKeyedMapArgsBuilder) Emit() *SomeServiceBinaryKeyedMapArgs{ - return &SomeServiceBinaryKeyedMapArgs{ - R: p.obj.R, - } -} - -func (s *SomeServiceBinaryKeyedMapArgsBuilder) R(r []int64) *SomeServiceBinaryKeyedMapArgsBuilder { - s.obj.R = r - return s -} - -func (s *SomeServiceBinaryKeyedMapArgs) SetR(r []int64) *SomeServiceBinaryKeyedMapArgs { - s.R = r - return s -} - -func (p *SomeServiceBinaryKeyedMapArgs) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *SomeServiceBinaryKeyedMapArgs) ReadField1(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]int64, 0, size) - p.R = tSlice - for i := 0; i < size; i ++ { - var _elem35 int64 - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem35 = v - } - p.R = append(p.R, _elem35) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *SomeServiceBinaryKeyedMapArgs) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("binary_keyed_map_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *SomeServiceBinaryKeyedMapArgs) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("r", thrift.LIST, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:r: ", p), err) } - if err := oprot.WriteListBegin(thrift.I64, len(p.R)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.R { - if err := oprot.WriteI64(int64(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:r: ", p), err) } - return err -} - -func (p *SomeServiceBinaryKeyedMapArgs) String() string { - if p == nil { - return "" - } - - rVal := fmt.Sprintf("%v", p.R) - return fmt.Sprintf("SomeServiceBinaryKeyedMapArgs({R:%s})", rVal) -} - -// Attributes: -// - Success -type SomeServiceBinaryKeyedMapResult struct { - thrift.IResponse - Success map[string]int64 `thrift:"success,0,optional" db:"success" json:"success,omitempty"` -} - -func NewSomeServiceBinaryKeyedMapResult() *SomeServiceBinaryKeyedMapResult { - return &SomeServiceBinaryKeyedMapResult{} -} - -var SomeServiceBinaryKeyedMapResult_Success_DEFAULT map[string]int64 - -func (p *SomeServiceBinaryKeyedMapResult) GetSuccess() map[string]int64 { - return p.Success -} -func (p *SomeServiceBinaryKeyedMapResult) IsSetSuccess() bool { - return p != nil && p.Success != nil -} - -type SomeServiceBinaryKeyedMapResultBuilder struct { - obj *SomeServiceBinaryKeyedMapResult -} - -func NewSomeServiceBinaryKeyedMapResultBuilder() *SomeServiceBinaryKeyedMapResultBuilder{ - return &SomeServiceBinaryKeyedMapResultBuilder{ - obj: NewSomeServiceBinaryKeyedMapResult(), - } -} - -func (p SomeServiceBinaryKeyedMapResultBuilder) Emit() *SomeServiceBinaryKeyedMapResult{ - return &SomeServiceBinaryKeyedMapResult{ - Success: p.obj.Success, - } -} - -func (s *SomeServiceBinaryKeyedMapResultBuilder) Success(success map[string]int64) *SomeServiceBinaryKeyedMapResultBuilder { - s.obj.Success = success - return s -} - -func (s *SomeServiceBinaryKeyedMapResult) SetSuccess(success map[string]int64) *SomeServiceBinaryKeyedMapResult { - s.Success = success - return s -} - -func (p *SomeServiceBinaryKeyedMapResult) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 0: - if err := p.ReadField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *SomeServiceBinaryKeyedMapResult) ReadField0(iprot thrift.Protocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[string]int64, size) - p.Success = tMap - for i := 0; i < size; i ++ { - var _key36 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key36 = v - } - var _val37 int64 - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _val37 = v - } - p.Success[_key36] = _val37 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *SomeServiceBinaryKeyedMapResult) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("binary_keyed_map_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField0(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *SomeServiceBinaryKeyedMapResult) writeField0(oprot thrift.Protocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.MAP, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := oprot.WriteMapBegin(thrift.STRING, thrift.I64, len(p.Success)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.Success { - if err := oprot.WriteString(string(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := oprot.WriteI64(int64(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } - } - return err -} - -func (p *SomeServiceBinaryKeyedMapResult) String() string { - if p == nil { - return "" - } - - successVal := fmt.Sprintf("%v", p.Success) - return fmt.Sprintf("SomeServiceBinaryKeyedMapResult({Success:%s})", successVal) -} - - diff --git a/thrift/compiler/test/fixtures/types/gen-go/module/ttypes.go b/thrift/compiler/test/fixtures/types/gen-go/module/ttypes.go deleted file mode 100644 index a650ecf5480..00000000000 --- a/thrift/compiler/test/fixtures/types/gen-go/module/ttypes.go +++ /dev/null @@ -1,6044 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package module - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" - included0 "included" - -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var _ = included0.GoUnusedProtection__ -var GoUnusedProtection__ int; - -type HasBitwiseOps int64 -const ( - HasBitwiseOps_none HasBitwiseOps = 0 - HasBitwiseOps_zero HasBitwiseOps = 1 - HasBitwiseOps_one HasBitwiseOps = 2 - HasBitwiseOps_two HasBitwiseOps = 4 - HasBitwiseOps_three HasBitwiseOps = 8 -) - -var HasBitwiseOpsToName = map[HasBitwiseOps]string { - HasBitwiseOps_none: "none", - HasBitwiseOps_zero: "zero", - HasBitwiseOps_one: "one", - HasBitwiseOps_two: "two", - HasBitwiseOps_three: "three", -} - -var HasBitwiseOpsToValue = map[string]HasBitwiseOps { - "none": HasBitwiseOps_none, - "zero": HasBitwiseOps_zero, - "one": HasBitwiseOps_one, - "two": HasBitwiseOps_two, - "three": HasBitwiseOps_three, -} - -var HasBitwiseOpsNames = []string { - "none", - "zero", - "one", - "two", - "three", -} - -var HasBitwiseOpsValues = []HasBitwiseOps { - HasBitwiseOps_none, - HasBitwiseOps_zero, - HasBitwiseOps_one, - HasBitwiseOps_two, - HasBitwiseOps_three, -} - -func (p HasBitwiseOps) String() string { - if v, ok := HasBitwiseOpsToName[p]; ok { - return v - } - return "" -} - -func HasBitwiseOpsFromString(s string) (HasBitwiseOps, error) { - if v, ok := HasBitwiseOpsToValue[s]; ok { - return v, nil - } - return HasBitwiseOps(0), fmt.Errorf("not a valid HasBitwiseOps string") -} - -func HasBitwiseOpsPtr(v HasBitwiseOps) *HasBitwiseOps { return &v } - -type IsUnscoped int64 -const ( - IsUnscoped_hello IsUnscoped = 0 - IsUnscoped_world IsUnscoped = 1 -) - -var IsUnscopedToName = map[IsUnscoped]string { - IsUnscoped_hello: "hello", - IsUnscoped_world: "world", -} - -var IsUnscopedToValue = map[string]IsUnscoped { - "hello": IsUnscoped_hello, - "world": IsUnscoped_world, -} - -var IsUnscopedNames = []string { - "hello", - "world", -} - -var IsUnscopedValues = []IsUnscoped { - IsUnscoped_hello, - IsUnscoped_world, -} - -func (p IsUnscoped) String() string { - if v, ok := IsUnscopedToName[p]; ok { - return v - } - return "" -} - -func IsUnscopedFromString(s string) (IsUnscoped, error) { - if v, ok := IsUnscopedToValue[s]; ok { - return v, nil - } - return IsUnscoped(0), fmt.Errorf("not a valid IsUnscoped string") -} - -func IsUnscopedPtr(v IsUnscoped) *IsUnscoped { return &v } - -type MyForwardRefEnum int64 -const ( - MyForwardRefEnum_ZERO MyForwardRefEnum = 0 - MyForwardRefEnum_NONZERO MyForwardRefEnum = 12 -) - -var MyForwardRefEnumToName = map[MyForwardRefEnum]string { - MyForwardRefEnum_ZERO: "ZERO", - MyForwardRefEnum_NONZERO: "NONZERO", -} - -var MyForwardRefEnumToValue = map[string]MyForwardRefEnum { - "ZERO": MyForwardRefEnum_ZERO, - "NONZERO": MyForwardRefEnum_NONZERO, -} - -var MyForwardRefEnumNames = []string { - "ZERO", - "NONZERO", -} - -var MyForwardRefEnumValues = []MyForwardRefEnum { - MyForwardRefEnum_ZERO, - MyForwardRefEnum_NONZERO, -} - -func (p MyForwardRefEnum) String() string { - if v, ok := MyForwardRefEnumToName[p]; ok { - return v - } - return "" -} - -func MyForwardRefEnumFromString(s string) (MyForwardRefEnum, error) { - if v, ok := MyForwardRefEnumToValue[s]; ok { - return v, nil - } - return MyForwardRefEnum(0), fmt.Errorf("not a valid MyForwardRefEnum string") -} - -func MyForwardRefEnumPtr(v MyForwardRefEnum) *MyForwardRefEnum { return &v } - -type TBinary = []byte - -func TBinaryPtr(v TBinary) *TBinary { return &v } - -type IntTypedef = int32 - -func IntTypedefPtr(v IntTypedef) *IntTypedef { return &v } - -type UintTypedef = IntTypedef - -func UintTypedefPtr(v UintTypedef) *UintTypedef { return &v } - -type SomeListOfTypeMap_2468 = included0.SomeListOfTypeMap - -func SomeListOfTypeMap_2468Ptr(v SomeListOfTypeMap_2468) *SomeListOfTypeMap_2468 { return &v } - -type TBinary_8623 = TBinary - -func TBinary_8623Ptr(v TBinary_8623) *TBinary_8623 { return &v } - -type I32_9314 = int32 - -func I32_9314Ptr(v I32_9314) *I32_9314 { return &v } - -type ListI32_9187 = []int32 - -func ListI32_9187Ptr(v ListI32_9187) *ListI32_9187 { return &v } - -type MapI32I32_9565 = map[int32]int32 - -func MapI32I32_9565Ptr(v MapI32I32_9565) *MapI32I32_9565 { return &v } - -type MapI32String_1261 = map[int32]string - -func MapI32String_1261Ptr(v MapI32String_1261) *MapI32String_1261 { return &v } - -type SetI32_7070 = []int32 - -func SetI32_7070Ptr(v SetI32_7070) *SetI32_7070 { return &v } - -type SetI32_7194 = []int32 - -func SetI32_7194Ptr(v SetI32_7194) *SetI32_7194 { return &v } - -type String_5252 = string - -func String_5252Ptr(v String_5252) *String_5252 { return &v } - -type EmptyStruct struct { -} - -func NewEmptyStruct() *EmptyStruct { - return &EmptyStruct{} -} - -type EmptyStructBuilder struct { - obj *EmptyStruct -} - -func NewEmptyStructBuilder() *EmptyStructBuilder{ - return &EmptyStructBuilder{ - obj: NewEmptyStruct(), - } -} - -func (p EmptyStructBuilder) Emit() *EmptyStruct{ - return &EmptyStruct{ - } -} - -func (p *EmptyStruct) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *EmptyStruct) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("empty_struct"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *EmptyStruct) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("EmptyStruct({})") -} - -// Attributes: -// - Field -type DecoratedStruct struct { - Field string `thrift:"field,1" db:"field" json:"field"` -} - -func NewDecoratedStruct() *DecoratedStruct { - return &DecoratedStruct{} -} - - -func (p *DecoratedStruct) GetField() string { - return p.Field -} -type DecoratedStructBuilder struct { - obj *DecoratedStruct -} - -func NewDecoratedStructBuilder() *DecoratedStructBuilder{ - return &DecoratedStructBuilder{ - obj: NewDecoratedStruct(), - } -} - -func (p DecoratedStructBuilder) Emit() *DecoratedStruct{ - return &DecoratedStruct{ - Field: p.obj.Field, - } -} - -func (d *DecoratedStructBuilder) Field(field string) *DecoratedStructBuilder { - d.obj.Field = field - return d -} - -func (d *DecoratedStruct) SetField(field string) *DecoratedStruct { - d.Field = field - return d -} - -func (p *DecoratedStruct) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *DecoratedStruct) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Field = v - } - return nil -} - -func (p *DecoratedStruct) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("decorated_struct"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *DecoratedStruct) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("field", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:field: ", p), err) } - if err := oprot.WriteString(string(p.Field)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.field (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:field: ", p), err) } - return err -} - -func (p *DecoratedStruct) String() string { - if p == nil { - return "" - } - - fieldVal := fmt.Sprintf("%v", p.Field) - return fmt.Sprintf("DecoratedStruct({Field:%s})", fieldVal) -} - -// Attributes: -// - FieldA -// - FieldB -// - FieldC -// - FieldD -// - FieldE -// - FieldF -// - FieldG -// - FieldH -type ContainerStruct struct { - // unused field # 1 - FieldB []int32 `thrift:"fieldB,2" db:"fieldB" json:"fieldB"` - FieldC []int32 `thrift:"fieldC,3" db:"fieldC" json:"fieldC"` - FieldD []int32 `thrift:"fieldD,4" db:"fieldD" json:"fieldD"` - FieldE []int32 `thrift:"fieldE,5" db:"fieldE" json:"fieldE"` - FieldF []int32 `thrift:"fieldF,6" db:"fieldF" json:"fieldF"` - FieldG map[int32]string `thrift:"fieldG,7" db:"fieldG" json:"fieldG"` - FieldH included0.SomeMap `thrift:"fieldH,8" db:"fieldH" json:"fieldH"` - // unused fields # 9 to 11 - FieldA []int32 `thrift:"fieldA,12" db:"fieldA" json:"fieldA"` -} - -func NewContainerStruct() *ContainerStruct { - return &ContainerStruct{} -} - - -func (p *ContainerStruct) GetFieldA() []int32 { - return p.FieldA -} - -func (p *ContainerStruct) GetFieldB() []int32 { - return p.FieldB -} - -func (p *ContainerStruct) GetFieldC() []int32 { - return p.FieldC -} - -func (p *ContainerStruct) GetFieldD() []int32 { - return p.FieldD -} - -func (p *ContainerStruct) GetFieldE() []int32 { - return p.FieldE -} - -func (p *ContainerStruct) GetFieldF() []int32 { - return p.FieldF -} - -func (p *ContainerStruct) GetFieldG() map[int32]string { - return p.FieldG -} - -func (p *ContainerStruct) GetFieldH() included0.SomeMap { - return p.FieldH -} -type ContainerStructBuilder struct { - obj *ContainerStruct -} - -func NewContainerStructBuilder() *ContainerStructBuilder{ - return &ContainerStructBuilder{ - obj: NewContainerStruct(), - } -} - -func (p ContainerStructBuilder) Emit() *ContainerStruct{ - return &ContainerStruct{ - FieldA: p.obj.FieldA, - FieldB: p.obj.FieldB, - FieldC: p.obj.FieldC, - FieldD: p.obj.FieldD, - FieldE: p.obj.FieldE, - FieldF: p.obj.FieldF, - FieldG: p.obj.FieldG, - FieldH: p.obj.FieldH, - } -} - -func (c *ContainerStructBuilder) FieldA(fieldA []int32) *ContainerStructBuilder { - c.obj.FieldA = fieldA - return c -} - -func (c *ContainerStructBuilder) FieldB(fieldB []int32) *ContainerStructBuilder { - c.obj.FieldB = fieldB - return c -} - -func (c *ContainerStructBuilder) FieldC(fieldC []int32) *ContainerStructBuilder { - c.obj.FieldC = fieldC - return c -} - -func (c *ContainerStructBuilder) FieldD(fieldD []int32) *ContainerStructBuilder { - c.obj.FieldD = fieldD - return c -} - -func (c *ContainerStructBuilder) FieldE(fieldE []int32) *ContainerStructBuilder { - c.obj.FieldE = fieldE - return c -} - -func (c *ContainerStructBuilder) FieldF(fieldF []int32) *ContainerStructBuilder { - c.obj.FieldF = fieldF - return c -} - -func (c *ContainerStructBuilder) FieldG(fieldG map[int32]string) *ContainerStructBuilder { - c.obj.FieldG = fieldG - return c -} - -func (c *ContainerStructBuilder) FieldH(fieldH included0.SomeMap) *ContainerStructBuilder { - c.obj.FieldH = fieldH - return c -} - -func (c *ContainerStruct) SetFieldA(fieldA []int32) *ContainerStruct { - c.FieldA = fieldA - return c -} - -func (c *ContainerStruct) SetFieldB(fieldB []int32) *ContainerStruct { - c.FieldB = fieldB - return c -} - -func (c *ContainerStruct) SetFieldC(fieldC []int32) *ContainerStruct { - c.FieldC = fieldC - return c -} - -func (c *ContainerStruct) SetFieldD(fieldD []int32) *ContainerStruct { - c.FieldD = fieldD - return c -} - -func (c *ContainerStruct) SetFieldE(fieldE []int32) *ContainerStruct { - c.FieldE = fieldE - return c -} - -func (c *ContainerStruct) SetFieldF(fieldF []int32) *ContainerStruct { - c.FieldF = fieldF - return c -} - -func (c *ContainerStruct) SetFieldG(fieldG map[int32]string) *ContainerStruct { - c.FieldG = fieldG - return c -} - -func (c *ContainerStruct) SetFieldH(fieldH included0.SomeMap) *ContainerStruct { - c.FieldH = fieldH - return c -} - -func (p *ContainerStruct) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 12: - if err := p.ReadField12(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 3: - if err := p.ReadField3(iprot); err != nil { - return err - } - case 4: - if err := p.ReadField4(iprot); err != nil { - return err - } - case 5: - if err := p.ReadField5(iprot); err != nil { - return err - } - case 6: - if err := p.ReadField6(iprot); err != nil { - return err - } - case 7: - if err := p.ReadField7(iprot); err != nil { - return err - } - case 8: - if err := p.ReadField8(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ContainerStruct) ReadField12(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]int32, 0, size) - p.FieldA = tSlice - for i := 0; i < size; i ++ { - var _elem1 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem1 = v - } - p.FieldA = append(p.FieldA, _elem1) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *ContainerStruct) ReadField2(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]int32, 0, size) - p.FieldB = tSlice - for i := 0; i < size; i ++ { - var _elem2 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem2 = v - } - p.FieldB = append(p.FieldB, _elem2) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *ContainerStruct) ReadField3(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]int32, 0, size) - p.FieldC = tSlice - for i := 0; i < size; i ++ { - var _elem3 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem3 = v - } - p.FieldC = append(p.FieldC, _elem3) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *ContainerStruct) ReadField4(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]int32, 0, size) - p.FieldD = tSlice - for i := 0; i < size; i ++ { - var _elem4 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem4 = v - } - p.FieldD = append(p.FieldD, _elem4) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *ContainerStruct) ReadField5(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]int32, 0, size) - p.FieldE = tSlice - for i := 0; i < size; i ++ { - var _elem5 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem5 = v - } - p.FieldE = append(p.FieldE, _elem5) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *ContainerStruct) ReadField6(iprot thrift.Protocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return thrift.PrependError("error reading set begin: ", err) - } - tSet := make([]int32, 0, size) - p.FieldF = tSet - for i := 0; i < size; i ++ { - var _elem6 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem6 = v - } - p.FieldF = append(p.FieldF, _elem6) - } - if err := iprot.ReadSetEnd(); err != nil { - return thrift.PrependError("error reading set end: ", err) - } - return nil -} - -func (p *ContainerStruct) ReadField7(iprot thrift.Protocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[int32]string, size) - p.FieldG = tMap - for i := 0; i < size; i ++ { - var _key7 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key7 = v - } - var _val8 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _val8 = v - } - p.FieldG[_key7] = _val8 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *ContainerStruct) ReadField8(iprot thrift.Protocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(included0.SomeMap, size) - p.FieldH = tMap - for i := 0; i < size; i ++ { - var _key9 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key9 = v - } - var _val10 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _val10 = v - } - p.FieldH[_key9] = _val10 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *ContainerStruct) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("ContainerStruct"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := p.writeField4(oprot); err != nil { return err } - if err := p.writeField5(oprot); err != nil { return err } - if err := p.writeField6(oprot); err != nil { return err } - if err := p.writeField7(oprot); err != nil { return err } - if err := p.writeField8(oprot); err != nil { return err } - if err := p.writeField12(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *ContainerStruct) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("fieldB", thrift.LIST, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:fieldB: ", p), err) } - if err := oprot.WriteListBegin(thrift.I32, len(p.FieldB)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.FieldB { - if err := oprot.WriteI32(int32(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:fieldB: ", p), err) } - return err -} - -func (p *ContainerStruct) writeField3(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("fieldC", thrift.LIST, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:fieldC: ", p), err) } - if err := oprot.WriteListBegin(thrift.I32, len(p.FieldC)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.FieldC { - if err := oprot.WriteI32(int32(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:fieldC: ", p), err) } - return err -} - -func (p *ContainerStruct) writeField4(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("fieldD", thrift.LIST, 4); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:fieldD: ", p), err) } - if err := oprot.WriteListBegin(thrift.I32, len(p.FieldD)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.FieldD { - if err := oprot.WriteI32(int32(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 4:fieldD: ", p), err) } - return err -} - -func (p *ContainerStruct) writeField5(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("fieldE", thrift.LIST, 5); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:fieldE: ", p), err) } - if err := oprot.WriteListBegin(thrift.I32, len(p.FieldE)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.FieldE { - if err := oprot.WriteI32(int32(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 5:fieldE: ", p), err) } - return err -} - -func (p *ContainerStruct) writeField6(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("fieldF", thrift.SET, 6); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 6:fieldF: ", p), err) } - if err := oprot.WriteSetBegin(thrift.I32, len(p.FieldF)); err != nil { - return thrift.PrependError("error writing set begin: ", err) - } - set := make(map[int32]bool, len(p.FieldF)) - for _, v := range p.FieldF { - if ok := set[v]; ok { - return thrift.PrependError("", fmt.Errorf("%T error writing set field: slice is not unique", v)) - } - set[v] = true - } - for _, v := range p.FieldF { - if err := oprot.WriteI32(int32(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteSetEnd(); err != nil { - return thrift.PrependError("error writing set end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 6:fieldF: ", p), err) } - return err -} - -func (p *ContainerStruct) writeField7(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("fieldG", thrift.MAP, 7); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 7:fieldG: ", p), err) } - if err := oprot.WriteMapBegin(thrift.I32, thrift.STRING, len(p.FieldG)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.FieldG { - if err := oprot.WriteI32(int32(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := oprot.WriteString(string(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 7:fieldG: ", p), err) } - return err -} - -func (p *ContainerStruct) writeField8(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("fieldH", thrift.MAP, 8); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 8:fieldH: ", p), err) } - if err := oprot.WriteMapBegin(thrift.I32, thrift.STRING, len(p.FieldH)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.FieldH { - if err := oprot.WriteI32(int32(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := oprot.WriteString(string(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 8:fieldH: ", p), err) } - return err -} - -func (p *ContainerStruct) writeField12(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("fieldA", thrift.LIST, 12); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 12:fieldA: ", p), err) } - if err := oprot.WriteListBegin(thrift.I32, len(p.FieldA)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.FieldA { - if err := oprot.WriteI32(int32(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 12:fieldA: ", p), err) } - return err -} - -func (p *ContainerStruct) String() string { - if p == nil { - return "" - } - - fieldBVal := fmt.Sprintf("%v", p.FieldB) - fieldCVal := fmt.Sprintf("%v", p.FieldC) - fieldDVal := fmt.Sprintf("%v", p.FieldD) - fieldEVal := fmt.Sprintf("%v", p.FieldE) - fieldFVal := fmt.Sprintf("%v", p.FieldF) - fieldGVal := fmt.Sprintf("%v", p.FieldG) - fieldHVal := fmt.Sprintf("%v", p.FieldH) - fieldAVal := fmt.Sprintf("%v", p.FieldA) - return fmt.Sprintf("ContainerStruct({FieldB:%s FieldC:%s FieldD:%s FieldE:%s FieldF:%s FieldG:%s FieldH:%s FieldA:%s})", fieldBVal, fieldCVal, fieldDVal, fieldEVal, fieldFVal, fieldGVal, fieldHVal, fieldAVal) -} - -// Attributes: -// - FieldA -type CppTypeStruct struct { - FieldA []int32 `thrift:"fieldA,1" db:"fieldA" json:"fieldA"` -} - -func NewCppTypeStruct() *CppTypeStruct { - return &CppTypeStruct{} -} - - -func (p *CppTypeStruct) GetFieldA() []int32 { - return p.FieldA -} -type CppTypeStructBuilder struct { - obj *CppTypeStruct -} - -func NewCppTypeStructBuilder() *CppTypeStructBuilder{ - return &CppTypeStructBuilder{ - obj: NewCppTypeStruct(), - } -} - -func (p CppTypeStructBuilder) Emit() *CppTypeStruct{ - return &CppTypeStruct{ - FieldA: p.obj.FieldA, - } -} - -func (c *CppTypeStructBuilder) FieldA(fieldA []int32) *CppTypeStructBuilder { - c.obj.FieldA = fieldA - return c -} - -func (c *CppTypeStruct) SetFieldA(fieldA []int32) *CppTypeStruct { - c.FieldA = fieldA - return c -} - -func (p *CppTypeStruct) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *CppTypeStruct) ReadField1(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]int32, 0, size) - p.FieldA = tSlice - for i := 0; i < size; i ++ { - var _elem11 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem11 = v - } - p.FieldA = append(p.FieldA, _elem11) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *CppTypeStruct) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("CppTypeStruct"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *CppTypeStruct) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("fieldA", thrift.LIST, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:fieldA: ", p), err) } - if err := oprot.WriteListBegin(thrift.I32, len(p.FieldA)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.FieldA { - if err := oprot.WriteI32(int32(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:fieldA: ", p), err) } - return err -} - -func (p *CppTypeStruct) String() string { - if p == nil { - return "" - } - - fieldAVal := fmt.Sprintf("%v", p.FieldA) - return fmt.Sprintf("CppTypeStruct({FieldA:%s})", fieldAVal) -} - -// Attributes: -// - MyIntField -type VirtualStruct struct { - MyIntField int64 `thrift:"MyIntField,1" db:"MyIntField" json:"MyIntField"` -} - -func NewVirtualStruct() *VirtualStruct { - return &VirtualStruct{} -} - - -func (p *VirtualStruct) GetMyIntField() int64 { - return p.MyIntField -} -type VirtualStructBuilder struct { - obj *VirtualStruct -} - -func NewVirtualStructBuilder() *VirtualStructBuilder{ - return &VirtualStructBuilder{ - obj: NewVirtualStruct(), - } -} - -func (p VirtualStructBuilder) Emit() *VirtualStruct{ - return &VirtualStruct{ - MyIntField: p.obj.MyIntField, - } -} - -func (v *VirtualStructBuilder) MyIntField(myIntField int64) *VirtualStructBuilder { - v.obj.MyIntField = myIntField - return v -} - -func (v *VirtualStruct) SetMyIntField(myIntField int64) *VirtualStruct { - v.MyIntField = myIntField - return v -} - -func (p *VirtualStruct) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *VirtualStruct) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.MyIntField = v - } - return nil -} - -func (p *VirtualStruct) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("VirtualStruct"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *VirtualStruct) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("MyIntField", thrift.I64, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:MyIntField: ", p), err) } - if err := oprot.WriteI64(int64(p.MyIntField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.MyIntField (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:MyIntField: ", p), err) } - return err -} - -func (p *VirtualStruct) String() string { - if p == nil { - return "" - } - - myIntFieldVal := fmt.Sprintf("%v", p.MyIntField) - return fmt.Sprintf("VirtualStruct({MyIntField:%s})", myIntFieldVal) -} - -// Attributes: -// - A -// - B -type MyStructWithForwardRefEnum struct { - A MyForwardRefEnum `thrift:"a,1" db:"a" json:"a"` - B MyForwardRefEnum `thrift:"b,2" db:"b" json:"b"` -} - -func NewMyStructWithForwardRefEnum() *MyStructWithForwardRefEnum { - return &MyStructWithForwardRefEnum{ - A: 12, - B: 12, - } -} - - -func (p *MyStructWithForwardRefEnum) GetA() MyForwardRefEnum { - return p.A -} - -func (p *MyStructWithForwardRefEnum) GetB() MyForwardRefEnum { - return p.B -} -type MyStructWithForwardRefEnumBuilder struct { - obj *MyStructWithForwardRefEnum -} - -func NewMyStructWithForwardRefEnumBuilder() *MyStructWithForwardRefEnumBuilder{ - return &MyStructWithForwardRefEnumBuilder{ - obj: NewMyStructWithForwardRefEnum(), - } -} - -func (p MyStructWithForwardRefEnumBuilder) Emit() *MyStructWithForwardRefEnum{ - return &MyStructWithForwardRefEnum{ - A: p.obj.A, - B: p.obj.B, - } -} - -func (m *MyStructWithForwardRefEnumBuilder) A(a MyForwardRefEnum) *MyStructWithForwardRefEnumBuilder { - m.obj.A = a - return m -} - -func (m *MyStructWithForwardRefEnumBuilder) B(b MyForwardRefEnum) *MyStructWithForwardRefEnumBuilder { - m.obj.B = b - return m -} - -func (m *MyStructWithForwardRefEnum) SetA(a MyForwardRefEnum) *MyStructWithForwardRefEnum { - m.A = a - return m -} - -func (m *MyStructWithForwardRefEnum) SetB(b MyForwardRefEnum) *MyStructWithForwardRefEnum { - m.B = b - return m -} - -func (p *MyStructWithForwardRefEnum) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyStructWithForwardRefEnum) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - temp := MyForwardRefEnum(v) - p.A = temp - } - return nil -} - -func (p *MyStructWithForwardRefEnum) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - temp := MyForwardRefEnum(v) - p.B = temp - } - return nil -} - -func (p *MyStructWithForwardRefEnum) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("MyStructWithForwardRefEnum"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyStructWithForwardRefEnum) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("a", thrift.I32, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:a: ", p), err) } - if err := oprot.WriteI32(int32(p.A)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.a (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:a: ", p), err) } - return err -} - -func (p *MyStructWithForwardRefEnum) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("b", thrift.I32, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:b: ", p), err) } - if err := oprot.WriteI32(int32(p.B)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.b (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:b: ", p), err) } - return err -} - -func (p *MyStructWithForwardRefEnum) String() string { - if p == nil { - return "" - } - - aVal := fmt.Sprintf("%v", p.A) - bVal := fmt.Sprintf("%v", p.B) - return fmt.Sprintf("MyStructWithForwardRefEnum({A:%s B:%s})", aVal, bVal) -} - -// Attributes: -// - A -// - B -type TrivialNumeric struct { - A int32 `thrift:"a,1" db:"a" json:"a"` - B bool `thrift:"b,2" db:"b" json:"b"` -} - -func NewTrivialNumeric() *TrivialNumeric { - return &TrivialNumeric{} -} - - -func (p *TrivialNumeric) GetA() int32 { - return p.A -} - -func (p *TrivialNumeric) GetB() bool { - return p.B -} -type TrivialNumericBuilder struct { - obj *TrivialNumeric -} - -func NewTrivialNumericBuilder() *TrivialNumericBuilder{ - return &TrivialNumericBuilder{ - obj: NewTrivialNumeric(), - } -} - -func (p TrivialNumericBuilder) Emit() *TrivialNumeric{ - return &TrivialNumeric{ - A: p.obj.A, - B: p.obj.B, - } -} - -func (t *TrivialNumericBuilder) A(a int32) *TrivialNumericBuilder { - t.obj.A = a - return t -} - -func (t *TrivialNumericBuilder) B(b bool) *TrivialNumericBuilder { - t.obj.B = b - return t -} - -func (t *TrivialNumeric) SetA(a int32) *TrivialNumeric { - t.A = a - return t -} - -func (t *TrivialNumeric) SetB(b bool) *TrivialNumeric { - t.B = b - return t -} - -func (p *TrivialNumeric) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *TrivialNumeric) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.A = v - } - return nil -} - -func (p *TrivialNumeric) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.B = v - } - return nil -} - -func (p *TrivialNumeric) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("TrivialNumeric"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *TrivialNumeric) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("a", thrift.I32, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:a: ", p), err) } - if err := oprot.WriteI32(int32(p.A)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.a (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:a: ", p), err) } - return err -} - -func (p *TrivialNumeric) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("b", thrift.BOOL, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:b: ", p), err) } - if err := oprot.WriteBool(bool(p.B)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.b (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:b: ", p), err) } - return err -} - -func (p *TrivialNumeric) String() string { - if p == nil { - return "" - } - - aVal := fmt.Sprintf("%v", p.A) - bVal := fmt.Sprintf("%v", p.B) - return fmt.Sprintf("TrivialNumeric({A:%s B:%s})", aVal, bVal) -} - -// Attributes: -// - Z -// - N -type TrivialNestedWithDefault struct { - Z int32 `thrift:"z,1" db:"z" json:"z"` - N *TrivialNumeric `thrift:"n,2" db:"n" json:"n"` -} - -func NewTrivialNestedWithDefault() *TrivialNestedWithDefault { - return &TrivialNestedWithDefault{ - Z: 4, - N: NewTrivialNumeric(), - } -} - - -func (p *TrivialNestedWithDefault) GetZ() int32 { - return p.Z -} -var TrivialNestedWithDefault_N_DEFAULT *TrivialNumeric = &TrivialNumeric{ - A: 3, - B: true, -} -func (p *TrivialNestedWithDefault) GetN() *TrivialNumeric { - if !p.IsSetN() { - return TrivialNestedWithDefault_N_DEFAULT - } - return p.N -} -func (p *TrivialNestedWithDefault) DefaultGetN() *TrivialNumeric { - if !p.IsSetN() { - return NewTrivialNumeric() - } - return p.N -} -func (p *TrivialNestedWithDefault) IsSetN() bool { - return p != nil && p.N != nil -} - -type TrivialNestedWithDefaultBuilder struct { - obj *TrivialNestedWithDefault -} - -func NewTrivialNestedWithDefaultBuilder() *TrivialNestedWithDefaultBuilder{ - return &TrivialNestedWithDefaultBuilder{ - obj: NewTrivialNestedWithDefault(), - } -} - -func (p TrivialNestedWithDefaultBuilder) Emit() *TrivialNestedWithDefault{ - return &TrivialNestedWithDefault{ - Z: p.obj.Z, - N: p.obj.N, - } -} - -func (t *TrivialNestedWithDefaultBuilder) Z(z int32) *TrivialNestedWithDefaultBuilder { - t.obj.Z = z - return t -} - -func (t *TrivialNestedWithDefaultBuilder) N(n *TrivialNumeric) *TrivialNestedWithDefaultBuilder { - t.obj.N = n - return t -} - -func (t *TrivialNestedWithDefault) SetZ(z int32) *TrivialNestedWithDefault { - t.Z = z - return t -} - -func (t *TrivialNestedWithDefault) SetN(n *TrivialNumeric) *TrivialNestedWithDefault { - t.N = n - return t -} - -func (p *TrivialNestedWithDefault) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *TrivialNestedWithDefault) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Z = v - } - return nil -} - -func (p *TrivialNestedWithDefault) ReadField2(iprot thrift.Protocol) error { - p.N = NewTrivialNumeric() - if err := p.N.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.N), err) - } - return nil -} - -func (p *TrivialNestedWithDefault) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("TrivialNestedWithDefault"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *TrivialNestedWithDefault) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("z", thrift.I32, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:z: ", p), err) } - if err := oprot.WriteI32(int32(p.Z)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.z (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:z: ", p), err) } - return err -} - -func (p *TrivialNestedWithDefault) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("n", thrift.STRUCT, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:n: ", p), err) } - if err := p.N.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.N), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:n: ", p), err) } - return err -} - -func (p *TrivialNestedWithDefault) String() string { - if p == nil { - return "" - } - - zVal := fmt.Sprintf("%v", p.Z) - var nVal string - if p.N == nil { - nVal = "" - } else { - nVal = fmt.Sprintf("%v", p.N) - } - return fmt.Sprintf("TrivialNestedWithDefault({Z:%s N:%s})", zVal, nVal) -} - -// Attributes: -// - A -// - B -type ComplexString struct { - A string `thrift:"a,1" db:"a" json:"a"` - B map[string]int32 `thrift:"b,2" db:"b" json:"b"` -} - -func NewComplexString() *ComplexString { - return &ComplexString{} -} - - -func (p *ComplexString) GetA() string { - return p.A -} - -func (p *ComplexString) GetB() map[string]int32 { - return p.B -} -type ComplexStringBuilder struct { - obj *ComplexString -} - -func NewComplexStringBuilder() *ComplexStringBuilder{ - return &ComplexStringBuilder{ - obj: NewComplexString(), - } -} - -func (p ComplexStringBuilder) Emit() *ComplexString{ - return &ComplexString{ - A: p.obj.A, - B: p.obj.B, - } -} - -func (c *ComplexStringBuilder) A(a string) *ComplexStringBuilder { - c.obj.A = a - return c -} - -func (c *ComplexStringBuilder) B(b map[string]int32) *ComplexStringBuilder { - c.obj.B = b - return c -} - -func (c *ComplexString) SetA(a string) *ComplexString { - c.A = a - return c -} - -func (c *ComplexString) SetB(b map[string]int32) *ComplexString { - c.B = b - return c -} - -func (p *ComplexString) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ComplexString) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.A = v - } - return nil -} - -func (p *ComplexString) ReadField2(iprot thrift.Protocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[string]int32, size) - p.B = tMap - for i := 0; i < size; i ++ { - var _key12 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key12 = v - } - var _val13 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _val13 = v - } - p.B[_key12] = _val13 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *ComplexString) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("ComplexString"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *ComplexString) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("a", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:a: ", p), err) } - if err := oprot.WriteString(string(p.A)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.a (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:a: ", p), err) } - return err -} - -func (p *ComplexString) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("b", thrift.MAP, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:b: ", p), err) } - if err := oprot.WriteMapBegin(thrift.STRING, thrift.I32, len(p.B)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.B { - if err := oprot.WriteString(string(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := oprot.WriteI32(int32(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:b: ", p), err) } - return err -} - -func (p *ComplexString) String() string { - if p == nil { - return "" - } - - aVal := fmt.Sprintf("%v", p.A) - bVal := fmt.Sprintf("%v", p.B) - return fmt.Sprintf("ComplexString({A:%s B:%s})", aVal, bVal) -} - -// Attributes: -// - Z -// - N -type ComplexNestedWithDefault struct { - Z string `thrift:"z,1" db:"z" json:"z"` - N *ComplexString `thrift:"n,2" db:"n" json:"n"` -} - -func NewComplexNestedWithDefault() *ComplexNestedWithDefault { - return &ComplexNestedWithDefault{ - Z: "4", - N: NewComplexString(), - } -} - - -func (p *ComplexNestedWithDefault) GetZ() string { - return p.Z -} -var ComplexNestedWithDefault_N_DEFAULT *ComplexString = &ComplexString{ - A: "3", - B: map[string]int32{ - "a": 3, - }, -} -func (p *ComplexNestedWithDefault) GetN() *ComplexString { - if !p.IsSetN() { - return ComplexNestedWithDefault_N_DEFAULT - } - return p.N -} -func (p *ComplexNestedWithDefault) DefaultGetN() *ComplexString { - if !p.IsSetN() { - return NewComplexString() - } - return p.N -} -func (p *ComplexNestedWithDefault) IsSetN() bool { - return p != nil && p.N != nil -} - -type ComplexNestedWithDefaultBuilder struct { - obj *ComplexNestedWithDefault -} - -func NewComplexNestedWithDefaultBuilder() *ComplexNestedWithDefaultBuilder{ - return &ComplexNestedWithDefaultBuilder{ - obj: NewComplexNestedWithDefault(), - } -} - -func (p ComplexNestedWithDefaultBuilder) Emit() *ComplexNestedWithDefault{ - return &ComplexNestedWithDefault{ - Z: p.obj.Z, - N: p.obj.N, - } -} - -func (c *ComplexNestedWithDefaultBuilder) Z(z string) *ComplexNestedWithDefaultBuilder { - c.obj.Z = z - return c -} - -func (c *ComplexNestedWithDefaultBuilder) N(n *ComplexString) *ComplexNestedWithDefaultBuilder { - c.obj.N = n - return c -} - -func (c *ComplexNestedWithDefault) SetZ(z string) *ComplexNestedWithDefault { - c.Z = z - return c -} - -func (c *ComplexNestedWithDefault) SetN(n *ComplexString) *ComplexNestedWithDefault { - c.N = n - return c -} - -func (p *ComplexNestedWithDefault) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ComplexNestedWithDefault) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Z = v - } - return nil -} - -func (p *ComplexNestedWithDefault) ReadField2(iprot thrift.Protocol) error { - p.N = NewComplexString() - if err := p.N.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.N), err) - } - return nil -} - -func (p *ComplexNestedWithDefault) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("ComplexNestedWithDefault"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *ComplexNestedWithDefault) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("z", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:z: ", p), err) } - if err := oprot.WriteString(string(p.Z)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.z (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:z: ", p), err) } - return err -} - -func (p *ComplexNestedWithDefault) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("n", thrift.STRUCT, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:n: ", p), err) } - if err := p.N.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.N), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:n: ", p), err) } - return err -} - -func (p *ComplexNestedWithDefault) String() string { - if p == nil { - return "" - } - - zVal := fmt.Sprintf("%v", p.Z) - var nVal string - if p.N == nil { - nVal = "" - } else { - nVal = fmt.Sprintf("%v", p.N) - } - return fmt.Sprintf("ComplexNestedWithDefault({Z:%s N:%s})", zVal, nVal) -} - -// Attributes: -// - Small -// - Big -// - Medium -// - Biggish -// - Tiny -type MinPadding struct { - Small int8 `thrift:"small,1,required" db:"small" json:"small"` - Big int64 `thrift:"big,2,required" db:"big" json:"big"` - Medium int16 `thrift:"medium,3,required" db:"medium" json:"medium"` - Biggish int32 `thrift:"biggish,4,required" db:"biggish" json:"biggish"` - Tiny int8 `thrift:"tiny,5,required" db:"tiny" json:"tiny"` -} - -func NewMinPadding() *MinPadding { - return &MinPadding{} -} - - -func (p *MinPadding) GetSmall() int8 { - return p.Small -} - -func (p *MinPadding) GetBig() int64 { - return p.Big -} - -func (p *MinPadding) GetMedium() int16 { - return p.Medium -} - -func (p *MinPadding) GetBiggish() int32 { - return p.Biggish -} - -func (p *MinPadding) GetTiny() int8 { - return p.Tiny -} -type MinPaddingBuilder struct { - obj *MinPadding -} - -func NewMinPaddingBuilder() *MinPaddingBuilder{ - return &MinPaddingBuilder{ - obj: NewMinPadding(), - } -} - -func (p MinPaddingBuilder) Emit() *MinPadding{ - return &MinPadding{ - Small: p.obj.Small, - Big: p.obj.Big, - Medium: p.obj.Medium, - Biggish: p.obj.Biggish, - Tiny: p.obj.Tiny, - } -} - -func (m *MinPaddingBuilder) Small(small int8) *MinPaddingBuilder { - m.obj.Small = small - return m -} - -func (m *MinPaddingBuilder) Big(big int64) *MinPaddingBuilder { - m.obj.Big = big - return m -} - -func (m *MinPaddingBuilder) Medium(medium int16) *MinPaddingBuilder { - m.obj.Medium = medium - return m -} - -func (m *MinPaddingBuilder) Biggish(biggish int32) *MinPaddingBuilder { - m.obj.Biggish = biggish - return m -} - -func (m *MinPaddingBuilder) Tiny(tiny int8) *MinPaddingBuilder { - m.obj.Tiny = tiny - return m -} - -func (m *MinPadding) SetSmall(small int8) *MinPadding { - m.Small = small - return m -} - -func (m *MinPadding) SetBig(big int64) *MinPadding { - m.Big = big - return m -} - -func (m *MinPadding) SetMedium(medium int16) *MinPadding { - m.Medium = medium - return m -} - -func (m *MinPadding) SetBiggish(biggish int32) *MinPadding { - m.Biggish = biggish - return m -} - -func (m *MinPadding) SetTiny(tiny int8) *MinPadding { - m.Tiny = tiny - return m -} - -func (p *MinPadding) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - var issetSmall bool = false; - var issetBig bool = false; - var issetMedium bool = false; - var issetBiggish bool = false; - var issetTiny bool = false; - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - issetSmall = true - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - issetBig = true - case 3: - if err := p.ReadField3(iprot); err != nil { - return err - } - issetMedium = true - case 4: - if err := p.ReadField4(iprot); err != nil { - return err - } - issetBiggish = true - case 5: - if err := p.ReadField5(iprot); err != nil { - return err - } - issetTiny = true - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - if !issetSmall{ - return thrift.NewProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field Small is not set")); - } - if !issetBig{ - return thrift.NewProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field Big is not set")); - } - if !issetMedium{ - return thrift.NewProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field Medium is not set")); - } - if !issetBiggish{ - return thrift.NewProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field Biggish is not set")); - } - if !issetTiny{ - return thrift.NewProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field Tiny is not set")); - } - return nil -} - -func (p *MinPadding) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadByte(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - temp := int8(v) - p.Small = temp - } - return nil -} - -func (p *MinPadding) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Big = v - } - return nil -} - -func (p *MinPadding) ReadField3(iprot thrift.Protocol) error { - if v, err := iprot.ReadI16(); err != nil { - return thrift.PrependError("error reading field 3: ", err) - } else { - p.Medium = v - } - return nil -} - -func (p *MinPadding) ReadField4(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 4: ", err) - } else { - p.Biggish = v - } - return nil -} - -func (p *MinPadding) ReadField5(iprot thrift.Protocol) error { - if v, err := iprot.ReadByte(); err != nil { - return thrift.PrependError("error reading field 5: ", err) - } else { - temp := int8(v) - p.Tiny = temp - } - return nil -} - -func (p *MinPadding) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("MinPadding"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := p.writeField4(oprot); err != nil { return err } - if err := p.writeField5(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MinPadding) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("small", thrift.BYTE, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:small: ", p), err) } - if err := oprot.WriteByte(byte(p.Small)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.small (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:small: ", p), err) } - return err -} - -func (p *MinPadding) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("big", thrift.I64, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:big: ", p), err) } - if err := oprot.WriteI64(int64(p.Big)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.big (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:big: ", p), err) } - return err -} - -func (p *MinPadding) writeField3(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("medium", thrift.I16, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:medium: ", p), err) } - if err := oprot.WriteI16(int16(p.Medium)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.medium (3) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:medium: ", p), err) } - return err -} - -func (p *MinPadding) writeField4(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("biggish", thrift.I32, 4); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:biggish: ", p), err) } - if err := oprot.WriteI32(int32(p.Biggish)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.biggish (4) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 4:biggish: ", p), err) } - return err -} - -func (p *MinPadding) writeField5(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("tiny", thrift.BYTE, 5); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:tiny: ", p), err) } - if err := oprot.WriteByte(byte(p.Tiny)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.tiny (5) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 5:tiny: ", p), err) } - return err -} - -func (p *MinPadding) String() string { - if p == nil { - return "" - } - - smallVal := fmt.Sprintf("%v", p.Small) - bigVal := fmt.Sprintf("%v", p.Big) - mediumVal := fmt.Sprintf("%v", p.Medium) - biggishVal := fmt.Sprintf("%v", p.Biggish) - tinyVal := fmt.Sprintf("%v", p.Tiny) - return fmt.Sprintf("MinPadding({Small:%s Big:%s Medium:%s Biggish:%s Tiny:%s})", smallVal, bigVal, mediumVal, biggishVal, tinyVal) -} - -// Attributes: -// - Small -// - Big -// - Medium -// - Biggish -// - Tiny -type MinPaddingWithCustomType struct { - Small int8 `thrift:"small,1" db:"small" json:"small"` - Big int64 `thrift:"big,2" db:"big" json:"big"` - Medium int16 `thrift:"medium,3" db:"medium" json:"medium"` - Biggish int32 `thrift:"biggish,4" db:"biggish" json:"biggish"` - Tiny int8 `thrift:"tiny,5" db:"tiny" json:"tiny"` -} - -func NewMinPaddingWithCustomType() *MinPaddingWithCustomType { - return &MinPaddingWithCustomType{} -} - - -func (p *MinPaddingWithCustomType) GetSmall() int8 { - return p.Small -} - -func (p *MinPaddingWithCustomType) GetBig() int64 { - return p.Big -} - -func (p *MinPaddingWithCustomType) GetMedium() int16 { - return p.Medium -} - -func (p *MinPaddingWithCustomType) GetBiggish() int32 { - return p.Biggish -} - -func (p *MinPaddingWithCustomType) GetTiny() int8 { - return p.Tiny -} -type MinPaddingWithCustomTypeBuilder struct { - obj *MinPaddingWithCustomType -} - -func NewMinPaddingWithCustomTypeBuilder() *MinPaddingWithCustomTypeBuilder{ - return &MinPaddingWithCustomTypeBuilder{ - obj: NewMinPaddingWithCustomType(), - } -} - -func (p MinPaddingWithCustomTypeBuilder) Emit() *MinPaddingWithCustomType{ - return &MinPaddingWithCustomType{ - Small: p.obj.Small, - Big: p.obj.Big, - Medium: p.obj.Medium, - Biggish: p.obj.Biggish, - Tiny: p.obj.Tiny, - } -} - -func (m *MinPaddingWithCustomTypeBuilder) Small(small int8) *MinPaddingWithCustomTypeBuilder { - m.obj.Small = small - return m -} - -func (m *MinPaddingWithCustomTypeBuilder) Big(big int64) *MinPaddingWithCustomTypeBuilder { - m.obj.Big = big - return m -} - -func (m *MinPaddingWithCustomTypeBuilder) Medium(medium int16) *MinPaddingWithCustomTypeBuilder { - m.obj.Medium = medium - return m -} - -func (m *MinPaddingWithCustomTypeBuilder) Biggish(biggish int32) *MinPaddingWithCustomTypeBuilder { - m.obj.Biggish = biggish - return m -} - -func (m *MinPaddingWithCustomTypeBuilder) Tiny(tiny int8) *MinPaddingWithCustomTypeBuilder { - m.obj.Tiny = tiny - return m -} - -func (m *MinPaddingWithCustomType) SetSmall(small int8) *MinPaddingWithCustomType { - m.Small = small - return m -} - -func (m *MinPaddingWithCustomType) SetBig(big int64) *MinPaddingWithCustomType { - m.Big = big - return m -} - -func (m *MinPaddingWithCustomType) SetMedium(medium int16) *MinPaddingWithCustomType { - m.Medium = medium - return m -} - -func (m *MinPaddingWithCustomType) SetBiggish(biggish int32) *MinPaddingWithCustomType { - m.Biggish = biggish - return m -} - -func (m *MinPaddingWithCustomType) SetTiny(tiny int8) *MinPaddingWithCustomType { - m.Tiny = tiny - return m -} - -func (p *MinPaddingWithCustomType) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 3: - if err := p.ReadField3(iprot); err != nil { - return err - } - case 4: - if err := p.ReadField4(iprot); err != nil { - return err - } - case 5: - if err := p.ReadField5(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MinPaddingWithCustomType) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadByte(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - temp := int8(v) - p.Small = temp - } - return nil -} - -func (p *MinPaddingWithCustomType) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Big = v - } - return nil -} - -func (p *MinPaddingWithCustomType) ReadField3(iprot thrift.Protocol) error { - if v, err := iprot.ReadI16(); err != nil { - return thrift.PrependError("error reading field 3: ", err) - } else { - p.Medium = v - } - return nil -} - -func (p *MinPaddingWithCustomType) ReadField4(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 4: ", err) - } else { - p.Biggish = v - } - return nil -} - -func (p *MinPaddingWithCustomType) ReadField5(iprot thrift.Protocol) error { - if v, err := iprot.ReadByte(); err != nil { - return thrift.PrependError("error reading field 5: ", err) - } else { - temp := int8(v) - p.Tiny = temp - } - return nil -} - -func (p *MinPaddingWithCustomType) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("MinPaddingWithCustomType"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := p.writeField4(oprot); err != nil { return err } - if err := p.writeField5(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MinPaddingWithCustomType) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("small", thrift.BYTE, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:small: ", p), err) } - if err := oprot.WriteByte(byte(p.Small)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.small (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:small: ", p), err) } - return err -} - -func (p *MinPaddingWithCustomType) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("big", thrift.I64, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:big: ", p), err) } - if err := oprot.WriteI64(int64(p.Big)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.big (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:big: ", p), err) } - return err -} - -func (p *MinPaddingWithCustomType) writeField3(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("medium", thrift.I16, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:medium: ", p), err) } - if err := oprot.WriteI16(int16(p.Medium)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.medium (3) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:medium: ", p), err) } - return err -} - -func (p *MinPaddingWithCustomType) writeField4(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("biggish", thrift.I32, 4); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:biggish: ", p), err) } - if err := oprot.WriteI32(int32(p.Biggish)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.biggish (4) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 4:biggish: ", p), err) } - return err -} - -func (p *MinPaddingWithCustomType) writeField5(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("tiny", thrift.BYTE, 5); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:tiny: ", p), err) } - if err := oprot.WriteByte(byte(p.Tiny)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.tiny (5) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 5:tiny: ", p), err) } - return err -} - -func (p *MinPaddingWithCustomType) String() string { - if p == nil { - return "" - } - - smallVal := fmt.Sprintf("%v", p.Small) - bigVal := fmt.Sprintf("%v", p.Big) - mediumVal := fmt.Sprintf("%v", p.Medium) - biggishVal := fmt.Sprintf("%v", p.Biggish) - tinyVal := fmt.Sprintf("%v", p.Tiny) - return fmt.Sprintf("MinPaddingWithCustomType({Small:%s Big:%s Medium:%s Biggish:%s Tiny:%s})", smallVal, bigVal, mediumVal, biggishVal, tinyVal) -} - -// Attributes: -// - MyIntField -// - MyStringField -// - MajorVer -// - Data -type MyStruct struct { - MyIntField int64 `thrift:"MyIntField,1" db:"MyIntField" json:"MyIntField"` - MyStringField string `thrift:"MyStringField,2" db:"MyStringField" json:"MyStringField"` - MajorVer int64 `thrift:"majorVer,3" db:"majorVer" json:"majorVer"` - Data *MyDataItem `thrift:"data,4" db:"data" json:"data"` -} - -func NewMyStruct() *MyStruct { - return &MyStruct{ - Data: NewMyDataItem(), - } -} - - -func (p *MyStruct) GetMyIntField() int64 { - return p.MyIntField -} - -func (p *MyStruct) GetMyStringField() string { - return p.MyStringField -} - -func (p *MyStruct) GetMajorVer() int64 { - return p.MajorVer -} -var MyStruct_Data_DEFAULT *MyDataItem -func (p *MyStruct) GetData() *MyDataItem { - if !p.IsSetData() { - return MyStruct_Data_DEFAULT - } - return p.Data -} -func (p *MyStruct) IsSetData() bool { - return p != nil && p.Data != nil -} - -type MyStructBuilder struct { - obj *MyStruct -} - -func NewMyStructBuilder() *MyStructBuilder{ - return &MyStructBuilder{ - obj: NewMyStruct(), - } -} - -func (p MyStructBuilder) Emit() *MyStruct{ - return &MyStruct{ - MyIntField: p.obj.MyIntField, - MyStringField: p.obj.MyStringField, - MajorVer: p.obj.MajorVer, - Data: p.obj.Data, - } -} - -func (m *MyStructBuilder) MyIntField(myIntField int64) *MyStructBuilder { - m.obj.MyIntField = myIntField - return m -} - -func (m *MyStructBuilder) MyStringField(myStringField string) *MyStructBuilder { - m.obj.MyStringField = myStringField - return m -} - -func (m *MyStructBuilder) MajorVer(majorVer int64) *MyStructBuilder { - m.obj.MajorVer = majorVer - return m -} - -func (m *MyStructBuilder) Data(data *MyDataItem) *MyStructBuilder { - m.obj.Data = data - return m -} - -func (m *MyStruct) SetMyIntField(myIntField int64) *MyStruct { - m.MyIntField = myIntField - return m -} - -func (m *MyStruct) SetMyStringField(myStringField string) *MyStruct { - m.MyStringField = myStringField - return m -} - -func (m *MyStruct) SetMajorVer(majorVer int64) *MyStruct { - m.MajorVer = majorVer - return m -} - -func (m *MyStruct) SetData(data *MyDataItem) *MyStruct { - m.Data = data - return m -} - -func (p *MyStruct) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 3: - if err := p.ReadField3(iprot); err != nil { - return err - } - case 4: - if err := p.ReadField4(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyStruct) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.MyIntField = v - } - return nil -} - -func (p *MyStruct) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.MyStringField = v - } - return nil -} - -func (p *MyStruct) ReadField3(iprot thrift.Protocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 3: ", err) - } else { - p.MajorVer = v - } - return nil -} - -func (p *MyStruct) ReadField4(iprot thrift.Protocol) error { - p.Data = NewMyDataItem() - if err := p.Data.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Data), err) - } - return nil -} - -func (p *MyStruct) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("MyStruct"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := p.writeField4(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyStruct) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("MyIntField", thrift.I64, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:MyIntField: ", p), err) } - if err := oprot.WriteI64(int64(p.MyIntField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.MyIntField (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:MyIntField: ", p), err) } - return err -} - -func (p *MyStruct) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("MyStringField", thrift.STRING, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:MyStringField: ", p), err) } - if err := oprot.WriteString(string(p.MyStringField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.MyStringField (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:MyStringField: ", p), err) } - return err -} - -func (p *MyStruct) writeField3(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("majorVer", thrift.I64, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:majorVer: ", p), err) } - if err := oprot.WriteI64(int64(p.MajorVer)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.majorVer (3) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:majorVer: ", p), err) } - return err -} - -func (p *MyStruct) writeField4(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("data", thrift.STRUCT, 4); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:data: ", p), err) } - if err := p.Data.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Data), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 4:data: ", p), err) } - return err -} - -func (p *MyStruct) String() string { - if p == nil { - return "" - } - - myIntFieldVal := fmt.Sprintf("%v", p.MyIntField) - myStringFieldVal := fmt.Sprintf("%v", p.MyStringField) - majorVerVal := fmt.Sprintf("%v", p.MajorVer) - var dataVal string - if p.Data == nil { - dataVal = "" - } else { - dataVal = fmt.Sprintf("%v", p.Data) - } - return fmt.Sprintf("MyStruct({MyIntField:%s MyStringField:%s MajorVer:%s Data:%s})", myIntFieldVal, myStringFieldVal, majorVerVal, dataVal) -} - -type MyDataItem struct { -} - -func NewMyDataItem() *MyDataItem { - return &MyDataItem{} -} - -type MyDataItemBuilder struct { - obj *MyDataItem -} - -func NewMyDataItemBuilder() *MyDataItemBuilder{ - return &MyDataItemBuilder{ - obj: NewMyDataItem(), - } -} - -func (p MyDataItemBuilder) Emit() *MyDataItem{ - return &MyDataItem{ - } -} - -func (p *MyDataItem) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyDataItem) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("MyDataItem"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MyDataItem) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("MyDataItem({})") -} - -// Attributes: -// - Foo -type Renaming struct { - Foo int64 `thrift:"foo,1" db:"foo" json:"foo"` -} - -func NewRenaming() *Renaming { - return &Renaming{} -} - - -func (p *Renaming) GetFoo() int64 { - return p.Foo -} -type RenamingBuilder struct { - obj *Renaming -} - -func NewRenamingBuilder() *RenamingBuilder{ - return &RenamingBuilder{ - obj: NewRenaming(), - } -} - -func (p RenamingBuilder) Emit() *Renaming{ - return &Renaming{ - Foo: p.obj.Foo, - } -} - -func (r *RenamingBuilder) Foo(foo int64) *RenamingBuilder { - r.obj.Foo = foo - return r -} - -func (r *Renaming) SetFoo(foo int64) *Renaming { - r.Foo = foo - return r -} - -func (p *Renaming) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Renaming) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Foo = v - } - return nil -} - -func (p *Renaming) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Renaming"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Renaming) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("foo", thrift.I64, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:foo: ", p), err) } - if err := oprot.WriteI64(int64(p.Foo)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.foo (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:foo: ", p), err) } - return err -} - -func (p *Renaming) String() string { - if p == nil { - return "" - } - - fooVal := fmt.Sprintf("%v", p.Foo) - return fmt.Sprintf("Renaming({Foo:%s})", fooVal) -} - -// Attributes: -// - BinaryField -// - ListField -type AnnotatedTypes struct { - BinaryField []byte `thrift:"binary_field,1" db:"binary_field" json:"binary_field"` - ListField []included0.SomeMap `thrift:"list_field,2" db:"list_field" json:"list_field"` -} - -func NewAnnotatedTypes() *AnnotatedTypes { - return &AnnotatedTypes{} -} - - -func (p *AnnotatedTypes) GetBinaryField() []byte { - return p.BinaryField -} - -func (p *AnnotatedTypes) GetListField() []included0.SomeMap { - return p.ListField -} -type AnnotatedTypesBuilder struct { - obj *AnnotatedTypes -} - -func NewAnnotatedTypesBuilder() *AnnotatedTypesBuilder{ - return &AnnotatedTypesBuilder{ - obj: NewAnnotatedTypes(), - } -} - -func (p AnnotatedTypesBuilder) Emit() *AnnotatedTypes{ - return &AnnotatedTypes{ - BinaryField: p.obj.BinaryField, - ListField: p.obj.ListField, - } -} - -func (a *AnnotatedTypesBuilder) BinaryField(binaryField []byte) *AnnotatedTypesBuilder { - a.obj.BinaryField = binaryField - return a -} - -func (a *AnnotatedTypesBuilder) ListField(listField []included0.SomeMap) *AnnotatedTypesBuilder { - a.obj.ListField = listField - return a -} - -func (a *AnnotatedTypes) SetBinaryField(binaryField []byte) *AnnotatedTypes { - a.BinaryField = binaryField - return a -} - -func (a *AnnotatedTypes) SetListField(listField []included0.SomeMap) *AnnotatedTypes { - a.ListField = listField - return a -} - -func (p *AnnotatedTypes) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AnnotatedTypes) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadBinary(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - temp := TBinary_8623(v) - p.BinaryField = temp - } - return nil -} - -func (p *AnnotatedTypes) ReadField2(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]included0.SomeMap, 0, size) - p.ListField = tSlice - for i := 0; i < size; i ++ { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(included0.SomeMap, size) - _elem14 := tMap - for i := 0; i < size; i ++ { - var _key15 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key15 = v - } - var _val16 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _val16 = v - } - _elem14[_key15] = _val16 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - p.ListField = append(p.ListField, _elem14) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *AnnotatedTypes) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("AnnotatedTypes"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *AnnotatedTypes) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("binary_field", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:binary_field: ", p), err) } - if err := oprot.WriteBinary(p.BinaryField); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.binary_field (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:binary_field: ", p), err) } - return err -} - -func (p *AnnotatedTypes) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("list_field", thrift.LIST, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:list_field: ", p), err) } - if err := oprot.WriteListBegin(thrift.MAP, len(p.ListField)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.ListField { - if err := oprot.WriteMapBegin(thrift.I32, thrift.STRING, len(v)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range v { - if err := oprot.WriteI32(int32(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := oprot.WriteString(string(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:list_field: ", p), err) } - return err -} - -func (p *AnnotatedTypes) String() string { - if p == nil { - return "" - } - - binaryFieldVal := fmt.Sprintf("%v", p.BinaryField) - listFieldVal := fmt.Sprintf("%v", p.ListField) - return fmt.Sprintf("AnnotatedTypes({BinaryField:%s ListField:%s})", binaryFieldVal, listFieldVal) -} - -// Attributes: -// - ForwardUsageStruct -// - ForwardUsageByRef -type ForwardUsageRoot struct { - ForwardUsageStruct *ForwardUsageStruct `thrift:"ForwardUsageStruct,1,optional" db:"ForwardUsageStruct" json:"ForwardUsageStruct,omitempty"` - ForwardUsageByRef *ForwardUsageByRef `thrift:"ForwardUsageByRef,2,optional" db:"ForwardUsageByRef" json:"ForwardUsageByRef,omitempty"` -} - -func NewForwardUsageRoot() *ForwardUsageRoot { - return &ForwardUsageRoot{} -} - -var ForwardUsageRoot_ForwardUsageStruct_DEFAULT *ForwardUsageStruct -func (p *ForwardUsageRoot) GetForwardUsageStruct() *ForwardUsageStruct { - if !p.IsSetForwardUsageStruct() { - return ForwardUsageRoot_ForwardUsageStruct_DEFAULT - } - return p.ForwardUsageStruct -} -var ForwardUsageRoot_ForwardUsageByRef_DEFAULT *ForwardUsageByRef -func (p *ForwardUsageRoot) GetForwardUsageByRef() *ForwardUsageByRef { - if !p.IsSetForwardUsageByRef() { - return ForwardUsageRoot_ForwardUsageByRef_DEFAULT - } - return p.ForwardUsageByRef -} -func (p *ForwardUsageRoot) IsSetForwardUsageStruct() bool { - return p != nil && p.ForwardUsageStruct != nil -} - -func (p *ForwardUsageRoot) IsSetForwardUsageByRef() bool { - return p != nil && p.ForwardUsageByRef != nil -} - -type ForwardUsageRootBuilder struct { - obj *ForwardUsageRoot -} - -func NewForwardUsageRootBuilder() *ForwardUsageRootBuilder{ - return &ForwardUsageRootBuilder{ - obj: NewForwardUsageRoot(), - } -} - -func (p ForwardUsageRootBuilder) Emit() *ForwardUsageRoot{ - return &ForwardUsageRoot{ - ForwardUsageStruct: p.obj.ForwardUsageStruct, - ForwardUsageByRef: p.obj.ForwardUsageByRef, - } -} - -func (f *ForwardUsageRootBuilder) ForwardUsageStruct(forwardUsageStruct *ForwardUsageStruct) *ForwardUsageRootBuilder { - f.obj.ForwardUsageStruct = forwardUsageStruct - return f -} - -func (f *ForwardUsageRootBuilder) ForwardUsageByRef(forwardUsageByRef *ForwardUsageByRef) *ForwardUsageRootBuilder { - f.obj.ForwardUsageByRef = forwardUsageByRef - return f -} - -func (f *ForwardUsageRoot) SetForwardUsageStruct(forwardUsageStruct *ForwardUsageStruct) *ForwardUsageRoot { - f.ForwardUsageStruct = forwardUsageStruct - return f -} - -func (f *ForwardUsageRoot) SetForwardUsageByRef(forwardUsageByRef *ForwardUsageByRef) *ForwardUsageRoot { - f.ForwardUsageByRef = forwardUsageByRef - return f -} - -func (p *ForwardUsageRoot) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ForwardUsageRoot) ReadField1(iprot thrift.Protocol) error { - p.ForwardUsageStruct = NewForwardUsageStruct() - if err := p.ForwardUsageStruct.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.ForwardUsageStruct), err) - } - return nil -} - -func (p *ForwardUsageRoot) ReadField2(iprot thrift.Protocol) error { - p.ForwardUsageByRef = NewForwardUsageByRef() - if err := p.ForwardUsageByRef.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.ForwardUsageByRef), err) - } - return nil -} - -func (p *ForwardUsageRoot) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("ForwardUsageRoot"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *ForwardUsageRoot) writeField1(oprot thrift.Protocol) (err error) { - if p.IsSetForwardUsageStruct() { - if err := oprot.WriteFieldBegin("ForwardUsageStruct", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:ForwardUsageStruct: ", p), err) } - if err := p.ForwardUsageStruct.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.ForwardUsageStruct), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:ForwardUsageStruct: ", p), err) } - } - return err -} - -func (p *ForwardUsageRoot) writeField2(oprot thrift.Protocol) (err error) { - if p.IsSetForwardUsageByRef() { - if err := oprot.WriteFieldBegin("ForwardUsageByRef", thrift.STRUCT, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:ForwardUsageByRef: ", p), err) } - if err := p.ForwardUsageByRef.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.ForwardUsageByRef), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:ForwardUsageByRef: ", p), err) } - } - return err -} - -func (p *ForwardUsageRoot) String() string { - if p == nil { - return "" - } - - var forwardUsageStructVal string - if p.ForwardUsageStruct == nil { - forwardUsageStructVal = "" - } else { - forwardUsageStructVal = fmt.Sprintf("%v", p.ForwardUsageStruct) - } - var forwardUsageByRefVal string - if p.ForwardUsageByRef == nil { - forwardUsageByRefVal = "" - } else { - forwardUsageByRefVal = fmt.Sprintf("%v", p.ForwardUsageByRef) - } - return fmt.Sprintf("ForwardUsageRoot({ForwardUsageStruct:%s ForwardUsageByRef:%s})", forwardUsageStructVal, forwardUsageByRefVal) -} - -// Attributes: -// - Foo -type ForwardUsageStruct struct { - Foo *ForwardUsageRoot `thrift:"foo,1,optional" db:"foo" json:"foo,omitempty"` -} - -func NewForwardUsageStruct() *ForwardUsageStruct { - return &ForwardUsageStruct{} -} - -var ForwardUsageStruct_Foo_DEFAULT *ForwardUsageRoot -func (p *ForwardUsageStruct) GetFoo() *ForwardUsageRoot { - if !p.IsSetFoo() { - return ForwardUsageStruct_Foo_DEFAULT - } - return p.Foo -} -func (p *ForwardUsageStruct) DefaultGetFoo() *ForwardUsageRoot { - if !p.IsSetFoo() { - return NewForwardUsageRoot() - } - return p.Foo -} -func (p *ForwardUsageStruct) IsSetFoo() bool { - return p != nil && p.Foo != nil -} - -type ForwardUsageStructBuilder struct { - obj *ForwardUsageStruct -} - -func NewForwardUsageStructBuilder() *ForwardUsageStructBuilder{ - return &ForwardUsageStructBuilder{ - obj: NewForwardUsageStruct(), - } -} - -func (p ForwardUsageStructBuilder) Emit() *ForwardUsageStruct{ - return &ForwardUsageStruct{ - Foo: p.obj.Foo, - } -} - -func (f *ForwardUsageStructBuilder) Foo(foo *ForwardUsageRoot) *ForwardUsageStructBuilder { - f.obj.Foo = foo - return f -} - -func (f *ForwardUsageStruct) SetFoo(foo *ForwardUsageRoot) *ForwardUsageStruct { - f.Foo = foo - return f -} - -func (p *ForwardUsageStruct) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ForwardUsageStruct) ReadField1(iprot thrift.Protocol) error { - p.Foo = NewForwardUsageRoot() - if err := p.Foo.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Foo), err) - } - return nil -} - -func (p *ForwardUsageStruct) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("ForwardUsageStruct"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *ForwardUsageStruct) writeField1(oprot thrift.Protocol) (err error) { - if p.IsSetFoo() { - if err := oprot.WriteFieldBegin("foo", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:foo: ", p), err) } - if err := p.Foo.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Foo), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:foo: ", p), err) } - } - return err -} - -func (p *ForwardUsageStruct) String() string { - if p == nil { - return "" - } - - var fooVal string - if p.Foo == nil { - fooVal = "" - } else { - fooVal = fmt.Sprintf("%v", p.Foo) - } - return fmt.Sprintf("ForwardUsageStruct({Foo:%s})", fooVal) -} - -// Attributes: -// - Foo -type ForwardUsageByRef struct { - Foo *ForwardUsageRoot `thrift:"foo,1,optional" db:"foo" json:"foo,omitempty"` -} - -func NewForwardUsageByRef() *ForwardUsageByRef { - return &ForwardUsageByRef{} -} - -var ForwardUsageByRef_Foo_DEFAULT *ForwardUsageRoot -func (p *ForwardUsageByRef) GetFoo() *ForwardUsageRoot { - if !p.IsSetFoo() { - return ForwardUsageByRef_Foo_DEFAULT - } - return p.Foo -} -func (p *ForwardUsageByRef) DefaultGetFoo() *ForwardUsageRoot { - if !p.IsSetFoo() { - return NewForwardUsageRoot() - } - return p.Foo -} -func (p *ForwardUsageByRef) IsSetFoo() bool { - return p != nil && p.Foo != nil -} - -type ForwardUsageByRefBuilder struct { - obj *ForwardUsageByRef -} - -func NewForwardUsageByRefBuilder() *ForwardUsageByRefBuilder{ - return &ForwardUsageByRefBuilder{ - obj: NewForwardUsageByRef(), - } -} - -func (p ForwardUsageByRefBuilder) Emit() *ForwardUsageByRef{ - return &ForwardUsageByRef{ - Foo: p.obj.Foo, - } -} - -func (f *ForwardUsageByRefBuilder) Foo(foo *ForwardUsageRoot) *ForwardUsageByRefBuilder { - f.obj.Foo = foo - return f -} - -func (f *ForwardUsageByRef) SetFoo(foo *ForwardUsageRoot) *ForwardUsageByRef { - f.Foo = foo - return f -} - -func (p *ForwardUsageByRef) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ForwardUsageByRef) ReadField1(iprot thrift.Protocol) error { - p.Foo = NewForwardUsageRoot() - if err := p.Foo.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Foo), err) - } - return nil -} - -func (p *ForwardUsageByRef) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("ForwardUsageByRef"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *ForwardUsageByRef) writeField1(oprot thrift.Protocol) (err error) { - if p.IsSetFoo() { - if err := oprot.WriteFieldBegin("foo", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:foo: ", p), err) } - if err := p.Foo.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Foo), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:foo: ", p), err) } - } - return err -} - -func (p *ForwardUsageByRef) String() string { - if p == nil { - return "" - } - - var fooVal string - if p.Foo == nil { - fooVal = "" - } else { - fooVal = fmt.Sprintf("%v", p.Foo) - } - return fmt.Sprintf("ForwardUsageByRef({Foo:%s})", fooVal) -} - -// Attributes: -// - Field -type IncompleteMap struct { - Field map[int32]*IncompleteMapDep `thrift:"field,1,optional" db:"field" json:"field,omitempty"` -} - -func NewIncompleteMap() *IncompleteMap { - return &IncompleteMap{} -} - -var IncompleteMap_Field_DEFAULT map[int32]*IncompleteMapDep - -func (p *IncompleteMap) GetField() map[int32]*IncompleteMapDep { - return p.Field -} -func (p *IncompleteMap) IsSetField() bool { - return p != nil && p.Field != nil -} - -type IncompleteMapBuilder struct { - obj *IncompleteMap -} - -func NewIncompleteMapBuilder() *IncompleteMapBuilder{ - return &IncompleteMapBuilder{ - obj: NewIncompleteMap(), - } -} - -func (p IncompleteMapBuilder) Emit() *IncompleteMap{ - return &IncompleteMap{ - Field: p.obj.Field, - } -} - -func (i *IncompleteMapBuilder) Field(field map[int32]*IncompleteMapDep) *IncompleteMapBuilder { - i.obj.Field = field - return i -} - -func (i *IncompleteMap) SetField(field map[int32]*IncompleteMapDep) *IncompleteMap { - i.Field = field - return i -} - -func (p *IncompleteMap) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *IncompleteMap) ReadField1(iprot thrift.Protocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[int32]*IncompleteMapDep, size) - p.Field = tMap - for i := 0; i < size; i ++ { - var _key17 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key17 = v - } - _val18 := NewIncompleteMapDep() - if err := _val18.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _val18), err) - } - p.Field[_key17] = _val18 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *IncompleteMap) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("IncompleteMap"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *IncompleteMap) writeField1(oprot thrift.Protocol) (err error) { - if p.IsSetField() { - if err := oprot.WriteFieldBegin("field", thrift.MAP, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:field: ", p), err) } - if err := oprot.WriteMapBegin(thrift.I32, thrift.STRUCT, len(p.Field)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.Field { - if err := oprot.WriteI32(int32(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := v.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) - } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:field: ", p), err) } - } - return err -} - -func (p *IncompleteMap) String() string { - if p == nil { - return "" - } - - fieldVal := fmt.Sprintf("%v", p.Field) - return fmt.Sprintf("IncompleteMap({Field:%s})", fieldVal) -} - -type IncompleteMapDep struct { -} - -func NewIncompleteMapDep() *IncompleteMapDep { - return &IncompleteMapDep{} -} - -type IncompleteMapDepBuilder struct { - obj *IncompleteMapDep -} - -func NewIncompleteMapDepBuilder() *IncompleteMapDepBuilder{ - return &IncompleteMapDepBuilder{ - obj: NewIncompleteMapDep(), - } -} - -func (p IncompleteMapDepBuilder) Emit() *IncompleteMapDep{ - return &IncompleteMapDep{ - } -} - -func (p *IncompleteMapDep) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *IncompleteMapDep) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("IncompleteMapDep"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *IncompleteMapDep) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("IncompleteMapDep({})") -} - -// Attributes: -// - Field -type CompleteMap struct { - Field map[int32]*CompleteMapDep `thrift:"field,1,optional" db:"field" json:"field,omitempty"` -} - -func NewCompleteMap() *CompleteMap { - return &CompleteMap{} -} - -var CompleteMap_Field_DEFAULT map[int32]*CompleteMapDep - -func (p *CompleteMap) GetField() map[int32]*CompleteMapDep { - return p.Field -} -func (p *CompleteMap) IsSetField() bool { - return p != nil && p.Field != nil -} - -type CompleteMapBuilder struct { - obj *CompleteMap -} - -func NewCompleteMapBuilder() *CompleteMapBuilder{ - return &CompleteMapBuilder{ - obj: NewCompleteMap(), - } -} - -func (p CompleteMapBuilder) Emit() *CompleteMap{ - return &CompleteMap{ - Field: p.obj.Field, - } -} - -func (c *CompleteMapBuilder) Field(field map[int32]*CompleteMapDep) *CompleteMapBuilder { - c.obj.Field = field - return c -} - -func (c *CompleteMap) SetField(field map[int32]*CompleteMapDep) *CompleteMap { - c.Field = field - return c -} - -func (p *CompleteMap) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *CompleteMap) ReadField1(iprot thrift.Protocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[int32]*CompleteMapDep, size) - p.Field = tMap - for i := 0; i < size; i ++ { - var _key19 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key19 = v - } - _val20 := NewCompleteMapDep() - if err := _val20.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _val20), err) - } - p.Field[_key19] = _val20 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *CompleteMap) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("CompleteMap"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *CompleteMap) writeField1(oprot thrift.Protocol) (err error) { - if p.IsSetField() { - if err := oprot.WriteFieldBegin("field", thrift.MAP, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:field: ", p), err) } - if err := oprot.WriteMapBegin(thrift.I32, thrift.STRUCT, len(p.Field)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.Field { - if err := oprot.WriteI32(int32(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := v.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) - } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:field: ", p), err) } - } - return err -} - -func (p *CompleteMap) String() string { - if p == nil { - return "" - } - - fieldVal := fmt.Sprintf("%v", p.Field) - return fmt.Sprintf("CompleteMap({Field:%s})", fieldVal) -} - -type CompleteMapDep struct { -} - -func NewCompleteMapDep() *CompleteMapDep { - return &CompleteMapDep{} -} - -type CompleteMapDepBuilder struct { - obj *CompleteMapDep -} - -func NewCompleteMapDepBuilder() *CompleteMapDepBuilder{ - return &CompleteMapDepBuilder{ - obj: NewCompleteMapDep(), - } -} - -func (p CompleteMapDepBuilder) Emit() *CompleteMapDep{ - return &CompleteMapDep{ - } -} - -func (p *CompleteMapDep) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *CompleteMapDep) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("CompleteMapDep"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *CompleteMapDep) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("CompleteMapDep({})") -} - -// Attributes: -// - Field -type IncompleteList struct { - Field []*IncompleteListDep `thrift:"field,1,optional" db:"field" json:"field,omitempty"` -} - -func NewIncompleteList() *IncompleteList { - return &IncompleteList{} -} - -var IncompleteList_Field_DEFAULT []*IncompleteListDep - -func (p *IncompleteList) GetField() []*IncompleteListDep { - return p.Field -} -func (p *IncompleteList) IsSetField() bool { - return p != nil && p.Field != nil -} - -type IncompleteListBuilder struct { - obj *IncompleteList -} - -func NewIncompleteListBuilder() *IncompleteListBuilder{ - return &IncompleteListBuilder{ - obj: NewIncompleteList(), - } -} - -func (p IncompleteListBuilder) Emit() *IncompleteList{ - return &IncompleteList{ - Field: p.obj.Field, - } -} - -func (i *IncompleteListBuilder) Field(field []*IncompleteListDep) *IncompleteListBuilder { - i.obj.Field = field - return i -} - -func (i *IncompleteList) SetField(field []*IncompleteListDep) *IncompleteList { - i.Field = field - return i -} - -func (p *IncompleteList) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *IncompleteList) ReadField1(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]*IncompleteListDep, 0, size) - p.Field = tSlice - for i := 0; i < size; i ++ { - _elem21 := NewIncompleteListDep() - if err := _elem21.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem21), err) - } - p.Field = append(p.Field, _elem21) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *IncompleteList) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("IncompleteList"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *IncompleteList) writeField1(oprot thrift.Protocol) (err error) { - if p.IsSetField() { - if err := oprot.WriteFieldBegin("field", thrift.LIST, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:field: ", p), err) } - if err := oprot.WriteListBegin(thrift.STRUCT, len(p.Field)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.Field { - if err := v.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) - } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:field: ", p), err) } - } - return err -} - -func (p *IncompleteList) String() string { - if p == nil { - return "" - } - - fieldVal := fmt.Sprintf("%v", p.Field) - return fmt.Sprintf("IncompleteList({Field:%s})", fieldVal) -} - -type IncompleteListDep struct { -} - -func NewIncompleteListDep() *IncompleteListDep { - return &IncompleteListDep{} -} - -type IncompleteListDepBuilder struct { - obj *IncompleteListDep -} - -func NewIncompleteListDepBuilder() *IncompleteListDepBuilder{ - return &IncompleteListDepBuilder{ - obj: NewIncompleteListDep(), - } -} - -func (p IncompleteListDepBuilder) Emit() *IncompleteListDep{ - return &IncompleteListDep{ - } -} - -func (p *IncompleteListDep) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *IncompleteListDep) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("IncompleteListDep"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *IncompleteListDep) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("IncompleteListDep({})") -} - -// Attributes: -// - Field -type CompleteList struct { - Field []*CompleteListDep `thrift:"field,1,optional" db:"field" json:"field,omitempty"` -} - -func NewCompleteList() *CompleteList { - return &CompleteList{} -} - -var CompleteList_Field_DEFAULT []*CompleteListDep - -func (p *CompleteList) GetField() []*CompleteListDep { - return p.Field -} -func (p *CompleteList) IsSetField() bool { - return p != nil && p.Field != nil -} - -type CompleteListBuilder struct { - obj *CompleteList -} - -func NewCompleteListBuilder() *CompleteListBuilder{ - return &CompleteListBuilder{ - obj: NewCompleteList(), - } -} - -func (p CompleteListBuilder) Emit() *CompleteList{ - return &CompleteList{ - Field: p.obj.Field, - } -} - -func (c *CompleteListBuilder) Field(field []*CompleteListDep) *CompleteListBuilder { - c.obj.Field = field - return c -} - -func (c *CompleteList) SetField(field []*CompleteListDep) *CompleteList { - c.Field = field - return c -} - -func (p *CompleteList) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *CompleteList) ReadField1(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]*CompleteListDep, 0, size) - p.Field = tSlice - for i := 0; i < size; i ++ { - _elem22 := NewCompleteListDep() - if err := _elem22.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem22), err) - } - p.Field = append(p.Field, _elem22) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *CompleteList) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("CompleteList"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *CompleteList) writeField1(oprot thrift.Protocol) (err error) { - if p.IsSetField() { - if err := oprot.WriteFieldBegin("field", thrift.LIST, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:field: ", p), err) } - if err := oprot.WriteListBegin(thrift.STRUCT, len(p.Field)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.Field { - if err := v.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) - } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:field: ", p), err) } - } - return err -} - -func (p *CompleteList) String() string { - if p == nil { - return "" - } - - fieldVal := fmt.Sprintf("%v", p.Field) - return fmt.Sprintf("CompleteList({Field:%s})", fieldVal) -} - -type CompleteListDep struct { -} - -func NewCompleteListDep() *CompleteListDep { - return &CompleteListDep{} -} - -type CompleteListDepBuilder struct { - obj *CompleteListDep -} - -func NewCompleteListDepBuilder() *CompleteListDepBuilder{ - return &CompleteListDepBuilder{ - obj: NewCompleteListDep(), - } -} - -func (p CompleteListDepBuilder) Emit() *CompleteListDep{ - return &CompleteListDep{ - } -} - -func (p *CompleteListDep) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *CompleteListDep) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("CompleteListDep"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *CompleteListDep) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("CompleteListDep({})") -} - -// Attributes: -// - Field -type AdaptedList struct { - Field []*AdaptedListDep `thrift:"field,1,optional" db:"field" json:"field,omitempty"` -} - -func NewAdaptedList() *AdaptedList { - return &AdaptedList{} -} - -var AdaptedList_Field_DEFAULT []*AdaptedListDep - -func (p *AdaptedList) GetField() []*AdaptedListDep { - return p.Field -} -func (p *AdaptedList) IsSetField() bool { - return p != nil && p.Field != nil -} - -type AdaptedListBuilder struct { - obj *AdaptedList -} - -func NewAdaptedListBuilder() *AdaptedListBuilder{ - return &AdaptedListBuilder{ - obj: NewAdaptedList(), - } -} - -func (p AdaptedListBuilder) Emit() *AdaptedList{ - return &AdaptedList{ - Field: p.obj.Field, - } -} - -func (a *AdaptedListBuilder) Field(field []*AdaptedListDep) *AdaptedListBuilder { - a.obj.Field = field - return a -} - -func (a *AdaptedList) SetField(field []*AdaptedListDep) *AdaptedList { - a.Field = field - return a -} - -func (p *AdaptedList) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AdaptedList) ReadField1(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]*AdaptedListDep, 0, size) - p.Field = tSlice - for i := 0; i < size; i ++ { - _elem23 := NewAdaptedListDep() - if err := _elem23.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem23), err) - } - p.Field = append(p.Field, _elem23) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *AdaptedList) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("AdaptedList"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *AdaptedList) writeField1(oprot thrift.Protocol) (err error) { - if p.IsSetField() { - if err := oprot.WriteFieldBegin("field", thrift.LIST, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:field: ", p), err) } - if err := oprot.WriteListBegin(thrift.STRUCT, len(p.Field)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.Field { - if err := v.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) - } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:field: ", p), err) } - } - return err -} - -func (p *AdaptedList) String() string { - if p == nil { - return "" - } - - fieldVal := fmt.Sprintf("%v", p.Field) - return fmt.Sprintf("AdaptedList({Field:%s})", fieldVal) -} - -// Attributes: -// - Field -type AdaptedListDep struct { - Field *AdaptedList `thrift:"field,1" db:"field" json:"field"` -} - -func NewAdaptedListDep() *AdaptedListDep { - return &AdaptedListDep{ - Field: NewAdaptedList(), - } -} - -var AdaptedListDep_Field_DEFAULT *AdaptedList -func (p *AdaptedListDep) GetField() *AdaptedList { - if !p.IsSetField() { - return AdaptedListDep_Field_DEFAULT - } - return p.Field -} -func (p *AdaptedListDep) DefaultGetField() *AdaptedList { - if !p.IsSetField() { - return NewAdaptedList() - } - return p.Field -} -func (p *AdaptedListDep) IsSetField() bool { - return p != nil && p.Field != nil -} - -type AdaptedListDepBuilder struct { - obj *AdaptedListDep -} - -func NewAdaptedListDepBuilder() *AdaptedListDepBuilder{ - return &AdaptedListDepBuilder{ - obj: NewAdaptedListDep(), - } -} - -func (p AdaptedListDepBuilder) Emit() *AdaptedListDep{ - return &AdaptedListDep{ - Field: p.obj.Field, - } -} - -func (a *AdaptedListDepBuilder) Field(field *AdaptedList) *AdaptedListDepBuilder { - a.obj.Field = field - return a -} - -func (a *AdaptedListDep) SetField(field *AdaptedList) *AdaptedListDep { - a.Field = field - return a -} - -func (p *AdaptedListDep) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AdaptedListDep) ReadField1(iprot thrift.Protocol) error { - p.Field = NewAdaptedList() - if err := p.Field.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Field), err) - } - return nil -} - -func (p *AdaptedListDep) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("AdaptedListDep"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *AdaptedListDep) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("field", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:field: ", p), err) } - if err := p.Field.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Field), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:field: ", p), err) } - return err -} - -func (p *AdaptedListDep) String() string { - if p == nil { - return "" - } - - var fieldVal string - if p.Field == nil { - fieldVal = "" - } else { - fieldVal = fmt.Sprintf("%v", p.Field) - } - return fmt.Sprintf("AdaptedListDep({Field:%s})", fieldVal) -} - -// Attributes: -// - Field -type DependentAdaptedList struct { - Field []*DependentAdaptedListDep `thrift:"field,1,optional" db:"field" json:"field,omitempty"` -} - -func NewDependentAdaptedList() *DependentAdaptedList { - return &DependentAdaptedList{} -} - -var DependentAdaptedList_Field_DEFAULT []*DependentAdaptedListDep - -func (p *DependentAdaptedList) GetField() []*DependentAdaptedListDep { - return p.Field -} -func (p *DependentAdaptedList) IsSetField() bool { - return p != nil && p.Field != nil -} - -type DependentAdaptedListBuilder struct { - obj *DependentAdaptedList -} - -func NewDependentAdaptedListBuilder() *DependentAdaptedListBuilder{ - return &DependentAdaptedListBuilder{ - obj: NewDependentAdaptedList(), - } -} - -func (p DependentAdaptedListBuilder) Emit() *DependentAdaptedList{ - return &DependentAdaptedList{ - Field: p.obj.Field, - } -} - -func (d *DependentAdaptedListBuilder) Field(field []*DependentAdaptedListDep) *DependentAdaptedListBuilder { - d.obj.Field = field - return d -} - -func (d *DependentAdaptedList) SetField(field []*DependentAdaptedListDep) *DependentAdaptedList { - d.Field = field - return d -} - -func (p *DependentAdaptedList) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *DependentAdaptedList) ReadField1(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]*DependentAdaptedListDep, 0, size) - p.Field = tSlice - for i := 0; i < size; i ++ { - _elem24 := NewDependentAdaptedListDep() - if err := _elem24.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem24), err) - } - p.Field = append(p.Field, _elem24) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *DependentAdaptedList) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("DependentAdaptedList"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *DependentAdaptedList) writeField1(oprot thrift.Protocol) (err error) { - if p.IsSetField() { - if err := oprot.WriteFieldBegin("field", thrift.LIST, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:field: ", p), err) } - if err := oprot.WriteListBegin(thrift.STRUCT, len(p.Field)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.Field { - if err := v.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) - } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:field: ", p), err) } - } - return err -} - -func (p *DependentAdaptedList) String() string { - if p == nil { - return "" - } - - fieldVal := fmt.Sprintf("%v", p.Field) - return fmt.Sprintf("DependentAdaptedList({Field:%s})", fieldVal) -} - -// Attributes: -// - Field -type DependentAdaptedListDep struct { - Field *int16 `thrift:"field,1,optional" db:"field" json:"field,omitempty"` -} - -func NewDependentAdaptedListDep() *DependentAdaptedListDep { - return &DependentAdaptedListDep{} -} - -var DependentAdaptedListDep_Field_DEFAULT int16 -func (p *DependentAdaptedListDep) GetField() int16 { - if !p.IsSetField() { - return DependentAdaptedListDep_Field_DEFAULT - } - return *p.Field -} -func (p *DependentAdaptedListDep) IsSetField() bool { - return p != nil && p.Field != nil -} - -type DependentAdaptedListDepBuilder struct { - obj *DependentAdaptedListDep -} - -func NewDependentAdaptedListDepBuilder() *DependentAdaptedListDepBuilder{ - return &DependentAdaptedListDepBuilder{ - obj: NewDependentAdaptedListDep(), - } -} - -func (p DependentAdaptedListDepBuilder) Emit() *DependentAdaptedListDep{ - return &DependentAdaptedListDep{ - Field: p.obj.Field, - } -} - -func (d *DependentAdaptedListDepBuilder) Field(field *int16) *DependentAdaptedListDepBuilder { - d.obj.Field = field - return d -} - -func (d *DependentAdaptedListDep) SetField(field *int16) *DependentAdaptedListDep { - d.Field = field - return d -} - -func (p *DependentAdaptedListDep) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *DependentAdaptedListDep) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI16(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Field = &v - } - return nil -} - -func (p *DependentAdaptedListDep) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("DependentAdaptedListDep"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *DependentAdaptedListDep) writeField1(oprot thrift.Protocol) (err error) { - if p.IsSetField() { - if err := oprot.WriteFieldBegin("field", thrift.I16, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:field: ", p), err) } - if err := oprot.WriteI16(int16(*p.Field)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.field (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:field: ", p), err) } - } - return err -} - -func (p *DependentAdaptedListDep) String() string { - if p == nil { - return "" - } - - var fieldVal string - if p.Field == nil { - fieldVal = "" - } else { - fieldVal = fmt.Sprintf("%v", *p.Field) - } - return fmt.Sprintf("DependentAdaptedListDep({Field:%s})", fieldVal) -} - -// Attributes: -// - AaList -// - AaSet -// - AaMap -// - AaString -// - NotAContainer -// - AaUnique -// - AaShared -type AllocatorAware struct { - AaList []int32 `thrift:"aa_list,1" db:"aa_list" json:"aa_list"` - AaSet []int32 `thrift:"aa_set,2" db:"aa_set" json:"aa_set"` - AaMap map[int32]int32 `thrift:"aa_map,3" db:"aa_map" json:"aa_map"` - AaString string `thrift:"aa_string,4" db:"aa_string" json:"aa_string"` - NotAContainer int32 `thrift:"not_a_container,5" db:"not_a_container" json:"not_a_container"` - AaUnique *int32 `thrift:"aa_unique,6" db:"aa_unique" json:"aa_unique"` - AaShared *int32 `thrift:"aa_shared,7" db:"aa_shared" json:"aa_shared"` -} - -func NewAllocatorAware() *AllocatorAware { - return &AllocatorAware{} -} - - -func (p *AllocatorAware) GetAaList() []int32 { - return p.AaList -} - -func (p *AllocatorAware) GetAaSet() []int32 { - return p.AaSet -} - -func (p *AllocatorAware) GetAaMap() map[int32]int32 { - return p.AaMap -} - -func (p *AllocatorAware) GetAaString() string { - return p.AaString -} - -func (p *AllocatorAware) GetNotAContainer() int32 { - return p.NotAContainer -} -var AllocatorAware_AaUnique_DEFAULT int32 -func (p *AllocatorAware) GetAaUnique() int32 { - if !p.IsSetAaUnique() { - return AllocatorAware_AaUnique_DEFAULT - } - return *p.AaUnique -} -var AllocatorAware_AaShared_DEFAULT int32 -func (p *AllocatorAware) GetAaShared() int32 { - if !p.IsSetAaShared() { - return AllocatorAware_AaShared_DEFAULT - } - return *p.AaShared -} -func (p *AllocatorAware) IsSetAaUnique() bool { - return p != nil && p.AaUnique != nil -} - -func (p *AllocatorAware) IsSetAaShared() bool { - return p != nil && p.AaShared != nil -} - -type AllocatorAwareBuilder struct { - obj *AllocatorAware -} - -func NewAllocatorAwareBuilder() *AllocatorAwareBuilder{ - return &AllocatorAwareBuilder{ - obj: NewAllocatorAware(), - } -} - -func (p AllocatorAwareBuilder) Emit() *AllocatorAware{ - return &AllocatorAware{ - AaList: p.obj.AaList, - AaSet: p.obj.AaSet, - AaMap: p.obj.AaMap, - AaString: p.obj.AaString, - NotAContainer: p.obj.NotAContainer, - AaUnique: p.obj.AaUnique, - AaShared: p.obj.AaShared, - } -} - -func (a *AllocatorAwareBuilder) AaList(aaList []int32) *AllocatorAwareBuilder { - a.obj.AaList = aaList - return a -} - -func (a *AllocatorAwareBuilder) AaSet(aaSet []int32) *AllocatorAwareBuilder { - a.obj.AaSet = aaSet - return a -} - -func (a *AllocatorAwareBuilder) AaMap(aaMap map[int32]int32) *AllocatorAwareBuilder { - a.obj.AaMap = aaMap - return a -} - -func (a *AllocatorAwareBuilder) AaString(aaString string) *AllocatorAwareBuilder { - a.obj.AaString = aaString - return a -} - -func (a *AllocatorAwareBuilder) NotAContainer(notAContainer int32) *AllocatorAwareBuilder { - a.obj.NotAContainer = notAContainer - return a -} - -func (a *AllocatorAwareBuilder) AaUnique(aaUnique *int32) *AllocatorAwareBuilder { - a.obj.AaUnique = aaUnique - return a -} - -func (a *AllocatorAwareBuilder) AaShared(aaShared *int32) *AllocatorAwareBuilder { - a.obj.AaShared = aaShared - return a -} - -func (a *AllocatorAware) SetAaList(aaList []int32) *AllocatorAware { - a.AaList = aaList - return a -} - -func (a *AllocatorAware) SetAaSet(aaSet []int32) *AllocatorAware { - a.AaSet = aaSet - return a -} - -func (a *AllocatorAware) SetAaMap(aaMap map[int32]int32) *AllocatorAware { - a.AaMap = aaMap - return a -} - -func (a *AllocatorAware) SetAaString(aaString string) *AllocatorAware { - a.AaString = aaString - return a -} - -func (a *AllocatorAware) SetNotAContainer(notAContainer int32) *AllocatorAware { - a.NotAContainer = notAContainer - return a -} - -func (a *AllocatorAware) SetAaUnique(aaUnique *int32) *AllocatorAware { - a.AaUnique = aaUnique - return a -} - -func (a *AllocatorAware) SetAaShared(aaShared *int32) *AllocatorAware { - a.AaShared = aaShared - return a -} - -func (p *AllocatorAware) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 3: - if err := p.ReadField3(iprot); err != nil { - return err - } - case 4: - if err := p.ReadField4(iprot); err != nil { - return err - } - case 5: - if err := p.ReadField5(iprot); err != nil { - return err - } - case 6: - if err := p.ReadField6(iprot); err != nil { - return err - } - case 7: - if err := p.ReadField7(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AllocatorAware) ReadField1(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]int32, 0, size) - p.AaList = tSlice - for i := 0; i < size; i ++ { - var _elem25 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem25 = v - } - p.AaList = append(p.AaList, _elem25) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *AllocatorAware) ReadField2(iprot thrift.Protocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return thrift.PrependError("error reading set begin: ", err) - } - tSet := make([]int32, 0, size) - p.AaSet = tSet - for i := 0; i < size; i ++ { - var _elem26 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem26 = v - } - p.AaSet = append(p.AaSet, _elem26) - } - if err := iprot.ReadSetEnd(); err != nil { - return thrift.PrependError("error reading set end: ", err) - } - return nil -} - -func (p *AllocatorAware) ReadField3(iprot thrift.Protocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[int32]int32, size) - p.AaMap = tMap - for i := 0; i < size; i ++ { - var _key27 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key27 = v - } - var _val28 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _val28 = v - } - p.AaMap[_key27] = _val28 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *AllocatorAware) ReadField4(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 4: ", err) - } else { - temp := String_5252(v) - p.AaString = temp - } - return nil -} - -func (p *AllocatorAware) ReadField5(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 5: ", err) - } else { - p.NotAContainer = v - } - return nil -} - -func (p *AllocatorAware) ReadField6(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 6: ", err) - } else { - temp := I32_9314(v) - p.AaUnique = &temp - } - return nil -} - -func (p *AllocatorAware) ReadField7(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 7: ", err) - } else { - temp := I32_9314(v) - p.AaShared = &temp - } - return nil -} - -func (p *AllocatorAware) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("AllocatorAware"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := p.writeField4(oprot); err != nil { return err } - if err := p.writeField5(oprot); err != nil { return err } - if err := p.writeField6(oprot); err != nil { return err } - if err := p.writeField7(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *AllocatorAware) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("aa_list", thrift.LIST, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:aa_list: ", p), err) } - if err := oprot.WriteListBegin(thrift.I32, len(p.AaList)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.AaList { - if err := oprot.WriteI32(int32(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:aa_list: ", p), err) } - return err -} - -func (p *AllocatorAware) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("aa_set", thrift.SET, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:aa_set: ", p), err) } - if err := oprot.WriteSetBegin(thrift.I32, len(p.AaSet)); err != nil { - return thrift.PrependError("error writing set begin: ", err) - } - set := make(map[int32]bool, len(p.AaSet)) - for _, v := range p.AaSet { - if ok := set[v]; ok { - return thrift.PrependError("", fmt.Errorf("%T error writing set field: slice is not unique", v)) - } - set[v] = true - } - for _, v := range p.AaSet { - if err := oprot.WriteI32(int32(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteSetEnd(); err != nil { - return thrift.PrependError("error writing set end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:aa_set: ", p), err) } - return err -} - -func (p *AllocatorAware) writeField3(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("aa_map", thrift.MAP, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:aa_map: ", p), err) } - if err := oprot.WriteMapBegin(thrift.I32, thrift.I32, len(p.AaMap)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.AaMap { - if err := oprot.WriteI32(int32(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := oprot.WriteI32(int32(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:aa_map: ", p), err) } - return err -} - -func (p *AllocatorAware) writeField4(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("aa_string", thrift.STRING, 4); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:aa_string: ", p), err) } - if err := oprot.WriteString(string(p.AaString)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.aa_string (4) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 4:aa_string: ", p), err) } - return err -} - -func (p *AllocatorAware) writeField5(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("not_a_container", thrift.I32, 5); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:not_a_container: ", p), err) } - if err := oprot.WriteI32(int32(p.NotAContainer)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.not_a_container (5) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 5:not_a_container: ", p), err) } - return err -} - -func (p *AllocatorAware) writeField6(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("aa_unique", thrift.I32, 6); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 6:aa_unique: ", p), err) } - if err := oprot.WriteI32(int32(*p.AaUnique)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.aa_unique (6) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 6:aa_unique: ", p), err) } - return err -} - -func (p *AllocatorAware) writeField7(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("aa_shared", thrift.I32, 7); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 7:aa_shared: ", p), err) } - if err := oprot.WriteI32(int32(*p.AaShared)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.aa_shared (7) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 7:aa_shared: ", p), err) } - return err -} - -func (p *AllocatorAware) String() string { - if p == nil { - return "" - } - - aaListVal := fmt.Sprintf("%v", p.AaList) - aaSetVal := fmt.Sprintf("%v", p.AaSet) - aaMapVal := fmt.Sprintf("%v", p.AaMap) - aaStringVal := fmt.Sprintf("%v", p.AaString) - notAContainerVal := fmt.Sprintf("%v", p.NotAContainer) - var aaUniqueVal string - if p.AaUnique == nil { - aaUniqueVal = "" - } else { - aaUniqueVal = fmt.Sprintf("%v", *p.AaUnique) - } - var aaSharedVal string - if p.AaShared == nil { - aaSharedVal = "" - } else { - aaSharedVal = fmt.Sprintf("%v", *p.AaShared) - } - return fmt.Sprintf("AllocatorAware({AaList:%s AaSet:%s AaMap:%s AaString:%s NotAContainer:%s AaUnique:%s AaShared:%s})", aaListVal, aaSetVal, aaMapVal, aaStringVal, notAContainerVal, aaUniqueVal, aaSharedVal) -} - -// Attributes: -// - NotAContainer -// - BoxField -type AllocatorAware2 struct { - NotAContainer int32 `thrift:"not_a_container,1" db:"not_a_container" json:"not_a_container"` - BoxField *int32 `thrift:"box_field,2,optional" db:"box_field" json:"box_field,omitempty"` -} - -func NewAllocatorAware2() *AllocatorAware2 { - return &AllocatorAware2{} -} - - -func (p *AllocatorAware2) GetNotAContainer() int32 { - return p.NotAContainer -} -var AllocatorAware2_BoxField_DEFAULT int32 -func (p *AllocatorAware2) GetBoxField() int32 { - if !p.IsSetBoxField() { - return AllocatorAware2_BoxField_DEFAULT - } - return *p.BoxField -} -func (p *AllocatorAware2) IsSetBoxField() bool { - return p != nil && p.BoxField != nil -} - -type AllocatorAware2Builder struct { - obj *AllocatorAware2 -} - -func NewAllocatorAware2Builder() *AllocatorAware2Builder{ - return &AllocatorAware2Builder{ - obj: NewAllocatorAware2(), - } -} - -func (p AllocatorAware2Builder) Emit() *AllocatorAware2{ - return &AllocatorAware2{ - NotAContainer: p.obj.NotAContainer, - BoxField: p.obj.BoxField, - } -} - -func (a *AllocatorAware2Builder) NotAContainer(notAContainer int32) *AllocatorAware2Builder { - a.obj.NotAContainer = notAContainer - return a -} - -func (a *AllocatorAware2Builder) BoxField(boxField *int32) *AllocatorAware2Builder { - a.obj.BoxField = boxField - return a -} - -func (a *AllocatorAware2) SetNotAContainer(notAContainer int32) *AllocatorAware2 { - a.NotAContainer = notAContainer - return a -} - -func (a *AllocatorAware2) SetBoxField(boxField *int32) *AllocatorAware2 { - a.BoxField = boxField - return a -} - -func (p *AllocatorAware2) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AllocatorAware2) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.NotAContainer = v - } - return nil -} - -func (p *AllocatorAware2) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.BoxField = &v - } - return nil -} - -func (p *AllocatorAware2) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("AllocatorAware2"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *AllocatorAware2) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("not_a_container", thrift.I32, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:not_a_container: ", p), err) } - if err := oprot.WriteI32(int32(p.NotAContainer)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.not_a_container (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:not_a_container: ", p), err) } - return err -} - -func (p *AllocatorAware2) writeField2(oprot thrift.Protocol) (err error) { - if p.IsSetBoxField() { - if err := oprot.WriteFieldBegin("box_field", thrift.I32, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:box_field: ", p), err) } - if err := oprot.WriteI32(int32(*p.BoxField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.box_field (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:box_field: ", p), err) } - } - return err -} - -func (p *AllocatorAware2) String() string { - if p == nil { - return "" - } - - notAContainerVal := fmt.Sprintf("%v", p.NotAContainer) - var boxFieldVal string - if p.BoxField == nil { - boxFieldVal = "" - } else { - boxFieldVal = fmt.Sprintf("%v", *p.BoxField) - } - return fmt.Sprintf("AllocatorAware2({NotAContainer:%s BoxField:%s})", notAContainerVal, boxFieldVal) -} - -// Attributes: -// - I32Field -// - IntTypedefField -// - UintTypedefField -type TypedefStruct struct { - I32Field int32 `thrift:"i32_field,1" db:"i32_field" json:"i32_field"` - IntTypedefField IntTypedef `thrift:"IntTypedef_field,2" db:"IntTypedef_field" json:"IntTypedef_field"` - UintTypedefField UintTypedef `thrift:"UintTypedef_field,3" db:"UintTypedef_field" json:"UintTypedef_field"` -} - -func NewTypedefStruct() *TypedefStruct { - return &TypedefStruct{} -} - - -func (p *TypedefStruct) GetI32Field() int32 { - return p.I32Field -} - -func (p *TypedefStruct) GetIntTypedefField() IntTypedef { - return p.IntTypedefField -} - -func (p *TypedefStruct) GetUintTypedefField() UintTypedef { - return p.UintTypedefField -} -type TypedefStructBuilder struct { - obj *TypedefStruct -} - -func NewTypedefStructBuilder() *TypedefStructBuilder{ - return &TypedefStructBuilder{ - obj: NewTypedefStruct(), - } -} - -func (p TypedefStructBuilder) Emit() *TypedefStruct{ - return &TypedefStruct{ - I32Field: p.obj.I32Field, - IntTypedefField: p.obj.IntTypedefField, - UintTypedefField: p.obj.UintTypedefField, - } -} - -func (t *TypedefStructBuilder) I32Field(i32Field int32) *TypedefStructBuilder { - t.obj.I32Field = i32Field - return t -} - -func (t *TypedefStructBuilder) IntTypedefField(intTypedefField IntTypedef) *TypedefStructBuilder { - t.obj.IntTypedefField = intTypedefField - return t -} - -func (t *TypedefStructBuilder) UintTypedefField(uintTypedefField UintTypedef) *TypedefStructBuilder { - t.obj.UintTypedefField = uintTypedefField - return t -} - -func (t *TypedefStruct) SetI32Field(i32Field int32) *TypedefStruct { - t.I32Field = i32Field - return t -} - -func (t *TypedefStruct) SetIntTypedefField(intTypedefField IntTypedef) *TypedefStruct { - t.IntTypedefField = intTypedefField - return t -} - -func (t *TypedefStruct) SetUintTypedefField(uintTypedefField UintTypedef) *TypedefStruct { - t.UintTypedefField = uintTypedefField - return t -} - -func (p *TypedefStruct) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 3: - if err := p.ReadField3(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *TypedefStruct) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.I32Field = v - } - return nil -} - -func (p *TypedefStruct) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - temp := IntTypedef(v) - p.IntTypedefField = temp - } - return nil -} - -func (p *TypedefStruct) ReadField3(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 3: ", err) - } else { - temp := UintTypedef(v) - p.UintTypedefField = temp - } - return nil -} - -func (p *TypedefStruct) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("TypedefStruct"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *TypedefStruct) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("i32_field", thrift.I32, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:i32_field: ", p), err) } - if err := oprot.WriteI32(int32(p.I32Field)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.i32_field (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:i32_field: ", p), err) } - return err -} - -func (p *TypedefStruct) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("IntTypedef_field", thrift.I32, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:IntTypedef_field: ", p), err) } - if err := oprot.WriteI32(int32(p.IntTypedefField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.IntTypedef_field (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:IntTypedef_field: ", p), err) } - return err -} - -func (p *TypedefStruct) writeField3(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("UintTypedef_field", thrift.I32, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:UintTypedef_field: ", p), err) } - if err := oprot.WriteI32(int32(p.UintTypedefField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.UintTypedef_field (3) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:UintTypedef_field: ", p), err) } - return err -} - -func (p *TypedefStruct) String() string { - if p == nil { - return "" - } - - i32FieldVal := fmt.Sprintf("%v", p.I32Field) - intTypedefFieldVal := fmt.Sprintf("%v", p.IntTypedefField) - uintTypedefFieldVal := fmt.Sprintf("%v", p.UintTypedefField) - return fmt.Sprintf("TypedefStruct({I32Field:%s IntTypedefField:%s UintTypedefField:%s})", i32FieldVal, intTypedefFieldVal, uintTypedefFieldVal) -} - -// Attributes: -// - XField -type StructWithDoubleUnderscores struct { - XField int32 `thrift:"__field,1" db:"__field" json:"__field"` -} - -func NewStructWithDoubleUnderscores() *StructWithDoubleUnderscores { - return &StructWithDoubleUnderscores{} -} - - -func (p *StructWithDoubleUnderscores) GetXField() int32 { - return p.XField -} -type StructWithDoubleUnderscoresBuilder struct { - obj *StructWithDoubleUnderscores -} - -func NewStructWithDoubleUnderscoresBuilder() *StructWithDoubleUnderscoresBuilder{ - return &StructWithDoubleUnderscoresBuilder{ - obj: NewStructWithDoubleUnderscores(), - } -} - -func (p StructWithDoubleUnderscoresBuilder) Emit() *StructWithDoubleUnderscores{ - return &StructWithDoubleUnderscores{ - XField: p.obj.XField, - } -} - -func (s *StructWithDoubleUnderscoresBuilder) XField(xField int32) *StructWithDoubleUnderscoresBuilder { - s.obj.XField = xField - return s -} - -func (s *StructWithDoubleUnderscores) SetXField(xField int32) *StructWithDoubleUnderscores { - s.XField = xField - return s -} - -func (p *StructWithDoubleUnderscores) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *StructWithDoubleUnderscores) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.XField = v - } - return nil -} - -func (p *StructWithDoubleUnderscores) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("StructWithDoubleUnderscores"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *StructWithDoubleUnderscores) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("__field", thrift.I32, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:__field: ", p), err) } - if err := oprot.WriteI32(int32(p.XField)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.__field (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:__field: ", p), err) } - return err -} - -func (p *StructWithDoubleUnderscores) String() string { - if p == nil { - return "" - } - - xFieldVal := fmt.Sprintf("%v", p.XField) - return fmt.Sprintf("StructWithDoubleUnderscores({XField:%s})", xFieldVal) -} - diff --git a/thrift/compiler/test/fixtures/types/gen-go/thrift/annotation/cpp/constants.go b/thrift/compiler/test/fixtures/types/gen-go/thrift/annotation/cpp/constants.go deleted file mode 100644 index 966e368e2dd..00000000000 --- a/thrift/compiler/test/fixtures/types/gen-go/thrift/annotation/cpp/constants.go +++ /dev/null @@ -1,25 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package cpp - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - - -func init() { -} - diff --git a/thrift/compiler/test/fixtures/types/gen-go/thrift/annotation/cpp/ttypes.go b/thrift/compiler/test/fixtures/types/gen-go/thrift/annotation/cpp/ttypes.go deleted file mode 100644 index 209f29e21fd..00000000000 --- a/thrift/compiler/test/fixtures/types/gen-go/thrift/annotation/cpp/ttypes.go +++ /dev/null @@ -1,2188 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package cpp - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var GoUnusedProtection__ int; - -//Optional, defaults to Unique -type RefType int64 -const ( - RefType_Unique RefType = 0 - RefType_Shared RefType = 1 - RefType_SharedMutable RefType = 2 -) - -var RefTypeToName = map[RefType]string { - RefType_Unique: "Unique", - RefType_Shared: "Shared", - RefType_SharedMutable: "SharedMutable", -} - -var RefTypeToValue = map[string]RefType { - "Unique": RefType_Unique, - "Shared": RefType_Shared, - "SharedMutable": RefType_SharedMutable, -} - -var RefTypeNames = []string { - "Unique", - "Shared", - "SharedMutable", -} - -var RefTypeValues = []RefType { - RefType_Unique, - RefType_Shared, - RefType_SharedMutable, -} - -func (p RefType) String() string { - if v, ok := RefTypeToName[p]; ok { - return v - } - return "" -} - -func RefTypeFromString(s string) (RefType, error) { - if v, ok := RefTypeToValue[s]; ok { - return v, nil - } - return RefType(0), fmt.Errorf("not a valid RefType string") -} - -func RefTypePtr(v RefType) *RefType { return &v } - -//Enum in C++ by default uses signed 32 bit integer. There is no need to specify -//underlying type for signed 32 bit integer. -//64-bit is not supported to avoid truncation since enums are sent as 32-bit integers over the wire. -type EnumUnderlyingType int64 -const ( - EnumUnderlyingType_I8 EnumUnderlyingType = 0 - EnumUnderlyingType_U8 EnumUnderlyingType = 1 - EnumUnderlyingType_I16 EnumUnderlyingType = 2 - EnumUnderlyingType_U16 EnumUnderlyingType = 3 - EnumUnderlyingType_U32 EnumUnderlyingType = 4 -) - -var EnumUnderlyingTypeToName = map[EnumUnderlyingType]string { - EnumUnderlyingType_I8: "I8", - EnumUnderlyingType_U8: "U8", - EnumUnderlyingType_I16: "I16", - EnumUnderlyingType_U16: "U16", - EnumUnderlyingType_U32: "U32", -} - -var EnumUnderlyingTypeToValue = map[string]EnumUnderlyingType { - "I8": EnumUnderlyingType_I8, - "U8": EnumUnderlyingType_U8, - "I16": EnumUnderlyingType_I16, - "U16": EnumUnderlyingType_U16, - "U32": EnumUnderlyingType_U32, -} - -var EnumUnderlyingTypeNames = []string { - "I8", - "U8", - "I16", - "U16", - "U32", -} - -var EnumUnderlyingTypeValues = []EnumUnderlyingType { - EnumUnderlyingType_I8, - EnumUnderlyingType_U8, - EnumUnderlyingType_I16, - EnumUnderlyingType_U16, - EnumUnderlyingType_U32, -} - -func (p EnumUnderlyingType) String() string { - if v, ok := EnumUnderlyingTypeToName[p]; ok { - return v - } - return "" -} - -func EnumUnderlyingTypeFromString(s string) (EnumUnderlyingType, error) { - if v, ok := EnumUnderlyingTypeToValue[s]; ok { - return v, nil - } - return EnumUnderlyingType(0), fmt.Errorf("not a valid EnumUnderlyingType string") -} - -func EnumUnderlyingTypePtr(v EnumUnderlyingType) *EnumUnderlyingType { return &v } - -// Changes the native type of a Thrift object (the C++ type used in codegen) to the value of the `name` field. -// Container types may instead provide the `template` field, in which case template parameters will be filled in by thrift. -// (e.g. `template = "folly::sorted_vector_set"` is equivalent to `type = "folly::sorted_vector_set"` on `set`) -// -// It is also possible to add `cpp_include` to bring in additional data structures and use them here. -// It is required that the custom type matches the specified Thrift type even for internal container types. -// Prefer types that can leverage `reserve(size_t)` as Thrift makes uses these optimizations. -// *Special Case*: This annotation can be used to define a string/binary type as `IOBuf` or `unique_ptr` so that you can leverage Thrift's support for zero-copy buffer manipulation through `IOBuf`. -// During deserialization, thrift receives a buffer that is used to allocate the appropriate fields in the struct. When using smart pointers, instead of making a copy of the data, it only modifies the pointer to point to the address that is used by the buffer. -// -// The custom type must provide the following methods -// * `list`: `push_back(T)` -// * `map`: `insert(std::pair)` -// * `set`: `insert(T)` -// -// Attributes: -// - Name -// - Template -type Type struct { - Name string `thrift:"name,1" db:"name" json:"name"` - Template string `thrift:"template,2" db:"template" json:"template"` -} - -func NewType() *Type { - return &Type{} -} - - -func (p *Type) GetName() string { - return p.Name -} - -func (p *Type) GetTemplate() string { - return p.Template -} -type TypeBuilder struct { - obj *Type -} - -func NewTypeBuilder() *TypeBuilder{ - return &TypeBuilder{ - obj: NewType(), - } -} - -func (p TypeBuilder) Emit() *Type{ - return &Type{ - Name: p.obj.Name, - Template: p.obj.Template, - } -} - -func (t *TypeBuilder) Name(name string) *TypeBuilder { - t.obj.Name = name - return t -} - -func (t *TypeBuilder) Template(template string) *TypeBuilder { - t.obj.Template = template - return t -} - -func (t *Type) SetName(name string) *Type { - t.Name = name - return t -} - -func (t *Type) SetTemplate(template string) *Type { - t.Template = template - return t -} - -func (p *Type) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Type) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Name = v - } - return nil -} - -func (p *Type) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Template = v - } - return nil -} - -func (p *Type) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Type"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Type) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) } - if err := oprot.WriteString(string(p.Name)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) } - return err -} - -func (p *Type) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("template", thrift.STRING, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:template: ", p), err) } - if err := oprot.WriteString(string(p.Template)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.template (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:template: ", p), err) } - return err -} - -func (p *Type) String() string { - if p == nil { - return "" - } - - nameVal := fmt.Sprintf("%v", p.Name) - templateVal := fmt.Sprintf("%v", p.Template) - return fmt.Sprintf("Type({Name:%s Template:%s})", nameVal, templateVal) -} - -// Allocates a field on the heap instead of inline. -// This annotation is added to support recursive types. However, you can also use it to turn a field from a value to a smart pointer. -// `@cpp.Ref` is equivalent having type`@cpp.RefType.Unique`. -// -// NOTE: A struct may transitively contain itself as a field only if at least one of the fields in the inclusion chain is either an optional Ref field or a container. Otherwise the struct would have infinite size. -// -// Attributes: -// - Type -type Ref struct { - Type RefType `thrift:"type,1" db:"type" json:"type"` -} - -func NewRef() *Ref { - return &Ref{} -} - - -func (p *Ref) GetType() RefType { - return p.Type -} -type RefBuilder struct { - obj *Ref -} - -func NewRefBuilder() *RefBuilder{ - return &RefBuilder{ - obj: NewRef(), - } -} - -func (p RefBuilder) Emit() *Ref{ - return &Ref{ - Type: p.obj.Type, - } -} - -func (r *RefBuilder) Type(type_a1 RefType) *RefBuilder { - r.obj.Type = type_a1 - return r -} - -func (r *Ref) SetType(type_a1 RefType) *Ref { - r.Type = type_a1 - return r -} - -func (p *Ref) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Ref) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - temp := RefType(v) - p.Type = temp - } - return nil -} - -func (p *Ref) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Ref"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Ref) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("type", thrift.I32, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:type: ", p), err) } - if err := oprot.WriteI32(int32(p.Type)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.type (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:type: ", p), err) } - return err -} - -func (p *Ref) String() string { - if p == nil { - return "" - } - - typeVal := fmt.Sprintf("%v", p.Type) - return fmt.Sprintf("Ref({Type:%s})", typeVal) -} - -// Changes the name of the definition in generated C++ code. -// In most cases a much better solution is to rename the problematic Thrift field itself. Only use the `cpp.name` annotation if such renaming is problematic, -// e.g. when the field name appears in code as a string, particularly when using JSON serialization, and it is hard to change all usage sites. -// -// Attributes: -// - Value -type Name struct { - Value string `thrift:"value,1" db:"value" json:"value"` -} - -func NewName() *Name { - return &Name{} -} - - -func (p *Name) GetValue() string { - return p.Value -} -type NameBuilder struct { - obj *Name -} - -func NewNameBuilder() *NameBuilder{ - return &NameBuilder{ - obj: NewName(), - } -} - -func (p NameBuilder) Emit() *Name{ - return &Name{ - Value: p.obj.Value, - } -} - -func (n *NameBuilder) Value(value string) *NameBuilder { - n.obj.Value = value - return n -} - -func (n *Name) SetValue(value string) *Name { - n.Value = value - return n -} - -func (p *Name) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Name) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Value = v - } - return nil -} - -func (p *Name) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Name"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Name) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("value", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:value: ", p), err) } - if err := oprot.WriteString(string(p.Value)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.value (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:value: ", p), err) } - return err -} - -func (p *Name) String() string { - if p == nil { - return "" - } - - valueVal := fmt.Sprintf("%v", p.Value) - return fmt.Sprintf("Name({Value:%s})", valueVal) -} - -// Lazily deserialize large field on first access. -// -// ``` -// FooWithLazyField foo; -// apache::thrift::CompactSerializer::deserialize(serializedData, foo); -// -// // large_field is lazy field, it will be deserialized on first access -// // The data will be deserialized in method call large_field_ref() -// LOG(INFO) << foo.large_field_ref()->size(); -// -// // Result will be cached, we won't deserialize again -// LOG(INFO) << foo.large_field_ref()->size(); -// ``` -// -// Read more: /doc/fb/languages/cpp/lazy.md -// -// Attributes: -// - Ref -type Lazy struct { - Ref bool `thrift:"ref,1" db:"ref" json:"ref"` -} - -func NewLazy() *Lazy { - return &Lazy{} -} - - -func (p *Lazy) GetRef() bool { - return p.Ref -} -type LazyBuilder struct { - obj *Lazy -} - -func NewLazyBuilder() *LazyBuilder{ - return &LazyBuilder{ - obj: NewLazy(), - } -} - -func (p LazyBuilder) Emit() *Lazy{ - return &Lazy{ - Ref: p.obj.Ref, - } -} - -func (l *LazyBuilder) Ref(ref bool) *LazyBuilder { - l.obj.Ref = ref - return l -} - -func (l *Lazy) SetRef(ref bool) *Lazy { - l.Ref = ref - return l -} - -func (p *Lazy) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Lazy) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Ref = v - } - return nil -} - -func (p *Lazy) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Lazy"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Lazy) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("ref", thrift.BOOL, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:ref: ", p), err) } - if err := oprot.WriteBool(bool(p.Ref)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.ref (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:ref: ", p), err) } - return err -} - -func (p *Lazy) String() string { - if p == nil { - return "" - } - - refVal := fmt.Sprintf("%v", p.Ref) - return fmt.Sprintf("Lazy({Ref:%s})", refVal) -} - -type DisableLazyChecksum struct { -} - -func NewDisableLazyChecksum() *DisableLazyChecksum { - return &DisableLazyChecksum{} -} - -type DisableLazyChecksumBuilder struct { - obj *DisableLazyChecksum -} - -func NewDisableLazyChecksumBuilder() *DisableLazyChecksumBuilder{ - return &DisableLazyChecksumBuilder{ - obj: NewDisableLazyChecksum(), - } -} - -func (p DisableLazyChecksumBuilder) Emit() *DisableLazyChecksum{ - return &DisableLazyChecksum{ - } -} - -func (p *DisableLazyChecksum) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *DisableLazyChecksum) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("DisableLazyChecksum"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *DisableLazyChecksum) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("DisableLazyChecksum({})") -} - -// An annotation that applies a C++ adapter to typedef, field, or struct. -// -// For example: -// -// @cpp.Adapter{name = "::ns::IdAdapter"} -// typedef i64 MyI64; -// -// Here the type `MyI64` has the C++ adapter `IdAdapter`. -// -// struct User { -// @cpp.Adapter{name = "::ns::IdAdapter"} -// 1: i64 id; -// } -// -// Here the field `id` has the C++ adapter `IdAdapter`. -// -// Attributes: -// - Name: The name of a C++ adapter type used to convert between Thrift and native -// C++ representation. -// -// The adapter can be either a Type or Field adapter, providing either of the following APIs: -// -// struct ThriftTypeAdapter { -// static AdaptedType fromThrift(ThriftType thrift); -// static {const ThriftType& | ThriftType} toThrift(const AdaptedType& native); -// }; -// -// struct ThriftFieldAdapter { -// // Context is an instantiation of apache::thrift::FieldContext -// template -// static void construct(AdaptedType& field, Context ctx); -// -// template -// static AdaptedType fromThriftField(ThriftType value, Context ctx); -// -// template -// static {const ThriftType& | ThriftType} toThrift(const AdaptedType& adapted, Context ctx); -// }; -// - AdaptedType: It is sometimes necessary to specify AdaptedType here (in case the codegen would -// have a circular depdenceny, which will cause the C++ build to fail). -// - UnderlyingName: The name and/or extra namespace to use when directly adapting a type -// (as opposed a typedef). -// -// In this case, the IDL name of the type will refer to the adapted type in -// C++ and the underlying thrift type will be generated in a nested -// namespace and/or with a different name. -// -// If neither `underlyingName` or `extraNamespace` is provided, the -// underlying type will be generated in a nested 'detail' namespace with -// the same name. -// - ExtraNamespace -// - MoveOnly: Must set to true when adapted type is not copyable. -type Adapter struct { - Name string `thrift:"name,1" db:"name" json:"name"` - AdaptedType string `thrift:"adaptedType,2" db:"adaptedType" json:"adaptedType"` - UnderlyingName string `thrift:"underlyingName,3" db:"underlyingName" json:"underlyingName"` - ExtraNamespace string `thrift:"extraNamespace,4" db:"extraNamespace" json:"extraNamespace"` - MoveOnly bool `thrift:"moveOnly,5" db:"moveOnly" json:"moveOnly"` -} - -func NewAdapter() *Adapter { - return &Adapter{} -} - - -func (p *Adapter) GetName() string { - return p.Name -} - -func (p *Adapter) GetAdaptedType() string { - return p.AdaptedType -} - -func (p *Adapter) GetUnderlyingName() string { - return p.UnderlyingName -} - -func (p *Adapter) GetExtraNamespace() string { - return p.ExtraNamespace -} - -func (p *Adapter) GetMoveOnly() bool { - return p.MoveOnly -} -type AdapterBuilder struct { - obj *Adapter -} - -func NewAdapterBuilder() *AdapterBuilder{ - return &AdapterBuilder{ - obj: NewAdapter(), - } -} - -func (p AdapterBuilder) Emit() *Adapter{ - return &Adapter{ - Name: p.obj.Name, - AdaptedType: p.obj.AdaptedType, - UnderlyingName: p.obj.UnderlyingName, - ExtraNamespace: p.obj.ExtraNamespace, - MoveOnly: p.obj.MoveOnly, - } -} - -func (a *AdapterBuilder) Name(name string) *AdapterBuilder { - a.obj.Name = name - return a -} - -func (a *AdapterBuilder) AdaptedType(adaptedType string) *AdapterBuilder { - a.obj.AdaptedType = adaptedType - return a -} - -func (a *AdapterBuilder) UnderlyingName(underlyingName string) *AdapterBuilder { - a.obj.UnderlyingName = underlyingName - return a -} - -func (a *AdapterBuilder) ExtraNamespace(extraNamespace string) *AdapterBuilder { - a.obj.ExtraNamespace = extraNamespace - return a -} - -func (a *AdapterBuilder) MoveOnly(moveOnly bool) *AdapterBuilder { - a.obj.MoveOnly = moveOnly - return a -} - -func (a *Adapter) SetName(name string) *Adapter { - a.Name = name - return a -} - -func (a *Adapter) SetAdaptedType(adaptedType string) *Adapter { - a.AdaptedType = adaptedType - return a -} - -func (a *Adapter) SetUnderlyingName(underlyingName string) *Adapter { - a.UnderlyingName = underlyingName - return a -} - -func (a *Adapter) SetExtraNamespace(extraNamespace string) *Adapter { - a.ExtraNamespace = extraNamespace - return a -} - -func (a *Adapter) SetMoveOnly(moveOnly bool) *Adapter { - a.MoveOnly = moveOnly - return a -} - -func (p *Adapter) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - case 3: - if err := p.ReadField3(iprot); err != nil { - return err - } - case 4: - if err := p.ReadField4(iprot); err != nil { - return err - } - case 5: - if err := p.ReadField5(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Adapter) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Name = v - } - return nil -} - -func (p *Adapter) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.AdaptedType = v - } - return nil -} - -func (p *Adapter) ReadField3(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 3: ", err) - } else { - p.UnderlyingName = v - } - return nil -} - -func (p *Adapter) ReadField4(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 4: ", err) - } else { - p.ExtraNamespace = v - } - return nil -} - -func (p *Adapter) ReadField5(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 5: ", err) - } else { - p.MoveOnly = v - } - return nil -} - -func (p *Adapter) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Adapter"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := p.writeField4(oprot); err != nil { return err } - if err := p.writeField5(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Adapter) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) } - if err := oprot.WriteString(string(p.Name)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) } - return err -} - -func (p *Adapter) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("adaptedType", thrift.STRING, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:adaptedType: ", p), err) } - if err := oprot.WriteString(string(p.AdaptedType)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.adaptedType (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:adaptedType: ", p), err) } - return err -} - -func (p *Adapter) writeField3(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("underlyingName", thrift.STRING, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:underlyingName: ", p), err) } - if err := oprot.WriteString(string(p.UnderlyingName)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.underlyingName (3) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:underlyingName: ", p), err) } - return err -} - -func (p *Adapter) writeField4(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("extraNamespace", thrift.STRING, 4); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:extraNamespace: ", p), err) } - if err := oprot.WriteString(string(p.ExtraNamespace)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.extraNamespace (4) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 4:extraNamespace: ", p), err) } - return err -} - -func (p *Adapter) writeField5(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("moveOnly", thrift.BOOL, 5); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:moveOnly: ", p), err) } - if err := oprot.WriteBool(bool(p.MoveOnly)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.moveOnly (5) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 5:moveOnly: ", p), err) } - return err -} - -func (p *Adapter) String() string { - if p == nil { - return "" - } - - nameVal := fmt.Sprintf("%v", p.Name) - adaptedTypeVal := fmt.Sprintf("%v", p.AdaptedType) - underlyingNameVal := fmt.Sprintf("%v", p.UnderlyingName) - extraNamespaceVal := fmt.Sprintf("%v", p.ExtraNamespace) - moveOnlyVal := fmt.Sprintf("%v", p.MoveOnly) - return fmt.Sprintf("Adapter({Name:%s AdaptedType:%s UnderlyingName:%s ExtraNamespace:%s MoveOnly:%s})", nameVal, adaptedTypeVal, underlyingNameVal, extraNamespaceVal, moveOnlyVal) -} - -// Packs isset bits into fewer bytes to save space at the cost of making access more expensive. -// Passing `atomic = false` reduces the access cost while making concurrent writes UB. -// Read more: /doc/fb/languages/cpp/isset-bitpacking.md -// -// Attributes: -// - Atomic -type PackIsset struct { - Atomic bool `thrift:"atomic,1" db:"atomic" json:"atomic"` -} - -func NewPackIsset() *PackIsset { - return &PackIsset{ - Atomic: true, - } -} - - -func (p *PackIsset) GetAtomic() bool { - return p.Atomic -} -type PackIssetBuilder struct { - obj *PackIsset -} - -func NewPackIssetBuilder() *PackIssetBuilder{ - return &PackIssetBuilder{ - obj: NewPackIsset(), - } -} - -func (p PackIssetBuilder) Emit() *PackIsset{ - return &PackIsset{ - Atomic: p.obj.Atomic, - } -} - -func (p *PackIssetBuilder) Atomic(atomic bool) *PackIssetBuilder { - p.obj.Atomic = atomic - return p -} - -func (p *PackIsset) SetAtomic(atomic bool) *PackIsset { - p.Atomic = atomic - return p -} - -func (p *PackIsset) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *PackIsset) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Atomic = v - } - return nil -} - -func (p *PackIsset) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("PackIsset"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *PackIsset) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("atomic", thrift.BOOL, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:atomic: ", p), err) } - if err := oprot.WriteBool(bool(p.Atomic)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.atomic (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:atomic: ", p), err) } - return err -} - -func (p *PackIsset) String() string { - if p == nil { - return "" - } - - atomicVal := fmt.Sprintf("%v", p.Atomic) - return fmt.Sprintf("PackIsset({Atomic:%s})", atomicVal) -} - -// This annotation enables reordering of fields in the generated C++ struct to minimize padding. -// This is achieved by placing the fields in the order of decreasing alignments. The order of fields with the same alignment is preserved. -// -// ``` -// @cpp.MinimizePadding -// struct Padded { -// 1: byte small -// 2: i64 big -// 3: i16 medium -// 4: i32 biggish -// 5: byte tiny -// } -// ``` -// -// For example, the C++ fields for the `Padded` Thrift struct above will be generated in the following order: -// -// ``` -// int64_t big; -// int32_t biggish; -// int16_t medium; -// int8_t small; -// int8_t tiny; -// ``` -// -// which gives the size of 16 bytes compared to 32 bytes if `cpp.MinimizePadding` was not specified. -type MinimizePadding struct { -} - -func NewMinimizePadding() *MinimizePadding { - return &MinimizePadding{} -} - -type MinimizePaddingBuilder struct { - obj *MinimizePadding -} - -func NewMinimizePaddingBuilder() *MinimizePaddingBuilder{ - return &MinimizePaddingBuilder{ - obj: NewMinimizePadding(), - } -} - -func (p MinimizePaddingBuilder) Emit() *MinimizePadding{ - return &MinimizePadding{ - } -} - -func (p *MinimizePadding) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MinimizePadding) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("MinimizePadding"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MinimizePadding) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("MinimizePadding({})") -} - -type TriviallyRelocatable struct { -} - -func NewTriviallyRelocatable() *TriviallyRelocatable { - return &TriviallyRelocatable{} -} - -type TriviallyRelocatableBuilder struct { - obj *TriviallyRelocatable -} - -func NewTriviallyRelocatableBuilder() *TriviallyRelocatableBuilder{ - return &TriviallyRelocatableBuilder{ - obj: NewTriviallyRelocatable(), - } -} - -func (p TriviallyRelocatableBuilder) Emit() *TriviallyRelocatable{ - return &TriviallyRelocatable{ - } -} - -func (p *TriviallyRelocatable) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *TriviallyRelocatable) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("TriviallyRelocatable"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *TriviallyRelocatable) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("TriviallyRelocatable({})") -} - -type ScopedEnumAsUnionType struct { -} - -func NewScopedEnumAsUnionType() *ScopedEnumAsUnionType { - return &ScopedEnumAsUnionType{} -} - -type ScopedEnumAsUnionTypeBuilder struct { - obj *ScopedEnumAsUnionType -} - -func NewScopedEnumAsUnionTypeBuilder() *ScopedEnumAsUnionTypeBuilder{ - return &ScopedEnumAsUnionTypeBuilder{ - obj: NewScopedEnumAsUnionType(), - } -} - -func (p ScopedEnumAsUnionTypeBuilder) Emit() *ScopedEnumAsUnionType{ - return &ScopedEnumAsUnionType{ - } -} - -func (p *ScopedEnumAsUnionType) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ScopedEnumAsUnionType) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("ScopedEnumAsUnionType"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *ScopedEnumAsUnionType) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("ScopedEnumAsUnionType({})") -} - -// Indicates a typedef should be 'strong', and require an explicit cast to -// the underlying type. -// -// Currently only works for integer typedefs, for example: -// -// @cpp.StrongType -// typedef i32 MyId; -// -// Will cause an enum class to be used instead of a typedef in the genearte code, for example: -// -// enum class MyId : ::std::int32_t {}; -// -type StrongType struct { -} - -func NewStrongType() *StrongType { - return &StrongType{} -} - -type StrongTypeBuilder struct { - obj *StrongType -} - -func NewStrongTypeBuilder() *StrongTypeBuilder{ - return &StrongTypeBuilder{ - obj: NewStrongType(), - } -} - -func (p StrongTypeBuilder) Emit() *StrongType{ - return &StrongType{ - } -} - -func (p *StrongType) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *StrongType) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("StrongType"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *StrongType) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("StrongType({})") -} - -// An annotation that intercepts field access with C++ field interceptor. -// Use with *caution* since this may introduce substantial performance overhead on each field access. -// -// For example: -// -// struct Foo { -// @cpp.FieldInterceptor{name = "MyFieldInterceptor"} -// 1: i64 id; -// } -// -// The field interceptor `MyFieldInterceptor` will intercept with `interceptThriftFieldAccess` -// when the field `id` is accessed. -// -// Attributes: -// - Name: The name of a field interceptor. -// -// The field interceptor provides the following API: -// -// struct ThriftFieldInterceptor { -// template -// static void interceptThriftFieldAccess(T&& field, -// apache::thrift::FieldContext&& ctx); -// }; -// -// The field interceptor intercepts with the field value and the field context. -// It enforces an easily searchable function name `interceptThriftFieldAccess`. -// - Noinline: Setting to true makes compiler not inline and erase function signature for -// the intercepting field accessor. -type FieldInterceptor struct { - Name string `thrift:"name,1" db:"name" json:"name"` - Noinline bool `thrift:"noinline,2" db:"noinline" json:"noinline"` -} - -func NewFieldInterceptor() *FieldInterceptor { - return &FieldInterceptor{} -} - - -func (p *FieldInterceptor) GetName() string { - return p.Name -} - -func (p *FieldInterceptor) GetNoinline() bool { - return p.Noinline -} -type FieldInterceptorBuilder struct { - obj *FieldInterceptor -} - -func NewFieldInterceptorBuilder() *FieldInterceptorBuilder{ - return &FieldInterceptorBuilder{ - obj: NewFieldInterceptor(), - } -} - -func (p FieldInterceptorBuilder) Emit() *FieldInterceptor{ - return &FieldInterceptor{ - Name: p.obj.Name, - Noinline: p.obj.Noinline, - } -} - -func (f *FieldInterceptorBuilder) Name(name string) *FieldInterceptorBuilder { - f.obj.Name = name - return f -} - -func (f *FieldInterceptorBuilder) Noinline(noinline bool) *FieldInterceptorBuilder { - f.obj.Noinline = noinline - return f -} - -func (f *FieldInterceptor) SetName(name string) *FieldInterceptor { - f.Name = name - return f -} - -func (f *FieldInterceptor) SetNoinline(noinline bool) *FieldInterceptor { - f.Noinline = noinline - return f -} - -func (p *FieldInterceptor) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *FieldInterceptor) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Name = v - } - return nil -} - -func (p *FieldInterceptor) ReadField2(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Noinline = v - } - return nil -} - -func (p *FieldInterceptor) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("FieldInterceptor"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *FieldInterceptor) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) } - if err := oprot.WriteString(string(p.Name)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) } - return err -} - -func (p *FieldInterceptor) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("noinline", thrift.BOOL, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:noinline: ", p), err) } - if err := oprot.WriteBool(bool(p.Noinline)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.noinline (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:noinline: ", p), err) } - return err -} - -func (p *FieldInterceptor) String() string { - if p == nil { - return "" - } - - nameVal := fmt.Sprintf("%v", p.Name) - noinlineVal := fmt.Sprintf("%v", p.Noinline) - return fmt.Sprintf("FieldInterceptor({Name:%s Noinline:%s})", nameVal, noinlineVal) -} - -type UseOpEncode struct { -} - -func NewUseOpEncode() *UseOpEncode { - return &UseOpEncode{} -} - -type UseOpEncodeBuilder struct { - obj *UseOpEncode -} - -func NewUseOpEncodeBuilder() *UseOpEncodeBuilder{ - return &UseOpEncodeBuilder{ - obj: NewUseOpEncode(), - } -} - -func (p UseOpEncodeBuilder) Emit() *UseOpEncode{ - return &UseOpEncode{ - } -} - -func (p *UseOpEncode) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *UseOpEncode) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("UseOpEncode"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *UseOpEncode) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("UseOpEncode({})") -} - -// Indicates an integer type for C++ to use as the underlying type of enum, for example: -// -// @cpp.EnumType{type = cpp.EnumUnderlyingType.I8} -// enum Fruit { -// Apple = 0, -// Banana = 1, -// } -// -// will be generated into the following: -// -// enum class Fruit : ::std::int8_t { -// Apple = 0, -// Banana = 1, -// }; -// -// -// Attributes: -// - Type -type EnumType struct { - Type EnumUnderlyingType `thrift:"type,1" db:"type" json:"type"` -} - -func NewEnumType() *EnumType { - return &EnumType{} -} - - -func (p *EnumType) GetType() EnumUnderlyingType { - return p.Type -} -type EnumTypeBuilder struct { - obj *EnumType -} - -func NewEnumTypeBuilder() *EnumTypeBuilder{ - return &EnumTypeBuilder{ - obj: NewEnumType(), - } -} - -func (p EnumTypeBuilder) Emit() *EnumType{ - return &EnumType{ - Type: p.obj.Type, - } -} - -func (e *EnumTypeBuilder) Type(type_a1 EnumUnderlyingType) *EnumTypeBuilder { - e.obj.Type = type_a1 - return e -} - -func (e *EnumType) SetType(type_a1 EnumUnderlyingType) *EnumType { - e.Type = type_a1 - return e -} - -func (p *EnumType) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *EnumType) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - temp := EnumUnderlyingType(v) - p.Type = temp - } - return nil -} - -func (p *EnumType) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("EnumType"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *EnumType) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("type", thrift.I32, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:type: ", p), err) } - if err := oprot.WriteI32(int32(p.Type)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.type (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:type: ", p), err) } - return err -} - -func (p *EnumType) String() string { - if p == nil { - return "" - } - - typeVal := fmt.Sprintf("%v", p.Type) - return fmt.Sprintf("EnumType({Type:%s})", typeVal) -} - -// Indicates that frozen types should not be generated for a given struct. -type Frozen2Exclude struct { -} - -func NewFrozen2Exclude() *Frozen2Exclude { - return &Frozen2Exclude{} -} - -type Frozen2ExcludeBuilder struct { - obj *Frozen2Exclude -} - -func NewFrozen2ExcludeBuilder() *Frozen2ExcludeBuilder{ - return &Frozen2ExcludeBuilder{ - obj: NewFrozen2Exclude(), - } -} - -func (p Frozen2ExcludeBuilder) Emit() *Frozen2Exclude{ - return &Frozen2Exclude{ - } -} - -func (p *Frozen2Exclude) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Frozen2Exclude) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Frozen2Exclude"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Frozen2Exclude) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Frozen2Exclude({})") -} - -// Indicates that the container params must be complete at the time this type is instantiated. -// Only required in rare cases where the build fails with a frozen-related assert failure. -type Frozen2RequiresCompleteContainerParams struct { -} - -func NewFrozen2RequiresCompleteContainerParams() *Frozen2RequiresCompleteContainerParams { - return &Frozen2RequiresCompleteContainerParams{} -} - -type Frozen2RequiresCompleteContainerParamsBuilder struct { - obj *Frozen2RequiresCompleteContainerParams -} - -func NewFrozen2RequiresCompleteContainerParamsBuilder() *Frozen2RequiresCompleteContainerParamsBuilder{ - return &Frozen2RequiresCompleteContainerParamsBuilder{ - obj: NewFrozen2RequiresCompleteContainerParams(), - } -} - -func (p Frozen2RequiresCompleteContainerParamsBuilder) Emit() *Frozen2RequiresCompleteContainerParams{ - return &Frozen2RequiresCompleteContainerParams{ - } -} - -func (p *Frozen2RequiresCompleteContainerParams) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Frozen2RequiresCompleteContainerParams) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Frozen2RequiresCompleteContainerParams"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Frozen2RequiresCompleteContainerParams) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Frozen2RequiresCompleteContainerParams({})") -} - -// Generates typed interceptor stubs that can be overriden by user, -// and adorn the handler methods. This can be used on individual functions -// or on services (equivalent to adding it to all functions). -// -// service MyService { -// @cpp.GenerateTypedInterceptor -// void ping(); -// } -// -// This will generate the following interface: -// -// class TypedInterceptor { -// TypeErasedStorage before_ping(); -// TypeErasedStorage after_ping(); -// } -// -type GenerateTypedInterceptor struct { -} - -func NewGenerateTypedInterceptor() *GenerateTypedInterceptor { - return &GenerateTypedInterceptor{} -} - -type GenerateTypedInterceptorBuilder struct { - obj *GenerateTypedInterceptor -} - -func NewGenerateTypedInterceptorBuilder() *GenerateTypedInterceptorBuilder{ - return &GenerateTypedInterceptorBuilder{ - obj: NewGenerateTypedInterceptor(), - } -} - -func (p GenerateTypedInterceptorBuilder) Emit() *GenerateTypedInterceptor{ - return &GenerateTypedInterceptor{ - } -} - -func (p *GenerateTypedInterceptor) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *GenerateTypedInterceptor) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("GenerateTypedInterceptor"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *GenerateTypedInterceptor) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("GenerateTypedInterceptor({})") -} - -// Causes C++ handler code to run inline on the EventBase thread. -// Disables overload protection, use with caution. -// Cannot be applied to individual functions in interactions. -// -// Causes the request to be executed on the event base thread directly instead of rescheduling onto a thread manager thread, provided the async_eb_ handler method is implemented. -// You should only execute the request on the event base thread if it is very fast and you have measured that rescheduling is a substantial chunk of your service's CPU usage. -// If a request executing on the event base thread blocks or takes a long time, all other requests sharing the same event base are affected and latency will increase significantly. -// We strongly discourage the use of this annotation unless strictly necessary. You will have to implement the harder-to-use async_eb_ handler method. -// This also disables queue timeouts, an important form of overload protection. -type ProcessInEbThreadUnsafe struct { -} - -func NewProcessInEbThreadUnsafe() *ProcessInEbThreadUnsafe { - return &ProcessInEbThreadUnsafe{} -} - -type ProcessInEbThreadUnsafeBuilder struct { - obj *ProcessInEbThreadUnsafe -} - -func NewProcessInEbThreadUnsafeBuilder() *ProcessInEbThreadUnsafeBuilder{ - return &ProcessInEbThreadUnsafeBuilder{ - obj: NewProcessInEbThreadUnsafe(), - } -} - -func (p ProcessInEbThreadUnsafeBuilder) Emit() *ProcessInEbThreadUnsafe{ - return &ProcessInEbThreadUnsafe{ - } -} - -func (p *ProcessInEbThreadUnsafe) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ProcessInEbThreadUnsafe) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("ProcessInEbThreadUnsafe"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *ProcessInEbThreadUnsafe) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("ProcessInEbThreadUnsafe({})") -} - -// Applies to structured annotation that need to be accessed in Runtime. -type RuntimeAnnotation struct { -} - -func NewRuntimeAnnotation() *RuntimeAnnotation { - return &RuntimeAnnotation{} -} - -type RuntimeAnnotationBuilder struct { - obj *RuntimeAnnotation -} - -func NewRuntimeAnnotationBuilder() *RuntimeAnnotationBuilder{ - return &RuntimeAnnotationBuilder{ - obj: NewRuntimeAnnotation(), - } -} - -func (p RuntimeAnnotationBuilder) Emit() *RuntimeAnnotation{ - return &RuntimeAnnotation{ - } -} - -func (p *RuntimeAnnotation) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *RuntimeAnnotation) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("RuntimeAnnotation"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *RuntimeAnnotation) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("RuntimeAnnotation({})") -} - diff --git a/thrift/compiler/test/fixtures/types/gen-go/thrift/annotation/scope/constants.go b/thrift/compiler/test/fixtures/types/gen-go/thrift/annotation/scope/constants.go deleted file mode 100644 index 0c3448a7126..00000000000 --- a/thrift/compiler/test/fixtures/types/gen-go/thrift/annotation/scope/constants.go +++ /dev/null @@ -1,25 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package scope - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - - -func init() { -} - diff --git a/thrift/compiler/test/fixtures/types/gen-go/thrift/annotation/scope/ttypes.go b/thrift/compiler/test/fixtures/types/gen-go/thrift/annotation/scope/ttypes.go deleted file mode 100644 index 580c39e775c..00000000000 --- a/thrift/compiler/test/fixtures/types/gen-go/thrift/annotation/scope/ttypes.go +++ /dev/null @@ -1,1169 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package scope - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var GoUnusedProtection__ int; - -// Indicates that the scope of sibling annotations is transitive. -// -// For example: -// -// @scope.Struct -// @scope.Union -// @scope.Exception -// @scope.Transitive -// struct Structured {} -// -// Annotating a Thrift struct with @Structured automatically applies -// @scope.Struct, @scope.Union and @scope.Exception annotations, i.e. -// -// @Structured -// struct MyAnnotation {} -// -// is equivalent to -// -// @scope.Struct -// @scope.Union -// @scope.Exception -// struct MyAnnotation {} -// -type Transitive struct { -} - -func NewTransitive() *Transitive { - return &Transitive{} -} - -type TransitiveBuilder struct { - obj *Transitive -} - -func NewTransitiveBuilder() *TransitiveBuilder{ - return &TransitiveBuilder{ - obj: NewTransitive(), - } -} - -func (p TransitiveBuilder) Emit() *Transitive{ - return &Transitive{ - } -} - -func (p *Transitive) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Transitive) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Transitive"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Transitive) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Transitive({})") -} - -// The Program scope. -// -// This allows annotations on the `package` definition, which implies the -// annotaiton applies to the entire program. -type Program struct { -} - -func NewProgram() *Program { - return &Program{} -} - -type ProgramBuilder struct { - obj *Program -} - -func NewProgramBuilder() *ProgramBuilder{ - return &ProgramBuilder{ - obj: NewProgram(), - } -} - -func (p ProgramBuilder) Emit() *Program{ - return &Program{ - } -} - -func (p *Program) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Program) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Program"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Program) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Program({})") -} - -// The `struct` definition scope. -type Struct struct { -} - -func NewStruct() *Struct { - return &Struct{} -} - -type StructBuilder struct { - obj *Struct -} - -func NewStructBuilder() *StructBuilder{ - return &StructBuilder{ - obj: NewStruct(), - } -} - -func (p StructBuilder) Emit() *Struct{ - return &Struct{ - } -} - -func (p *Struct) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Struct) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Struct"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Struct) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Struct({})") -} - -// The `union` definition scope. -type Union struct { -} - -func NewUnion() *Union { - return &Union{} -} - -type UnionBuilder struct { - obj *Union -} - -func NewUnionBuilder() *UnionBuilder{ - return &UnionBuilder{ - obj: NewUnion(), - } -} - -func (p UnionBuilder) Emit() *Union{ - return &Union{ - } -} - -func (p *Union) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Union) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Union"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Union) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Union({})") -} - -// The `exception` definition scope. -type Exception struct { -} - -func NewException() *Exception { - return &Exception{} -} - -type ExceptionBuilder struct { - obj *Exception -} - -func NewExceptionBuilder() *ExceptionBuilder{ - return &ExceptionBuilder{ - obj: NewException(), - } -} - -func (p ExceptionBuilder) Emit() *Exception{ - return &Exception{ - } -} - -func (p *Exception) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Exception) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Exception"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Exception) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Exception({})") -} - -// Field declartaions, for example in `struct` or `function` declartions. -type Field struct { -} - -func NewField() *Field { - return &Field{} -} - -type FieldBuilder struct { - obj *Field -} - -func NewFieldBuilder() *FieldBuilder{ - return &FieldBuilder{ - obj: NewField(), - } -} - -func (p FieldBuilder) Emit() *Field{ - return &Field{ - } -} - -func (p *Field) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Field) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Field"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Field) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Field({})") -} - -// The `typedef` definition scope. -type Typedef struct { -} - -func NewTypedef() *Typedef { - return &Typedef{} -} - -type TypedefBuilder struct { - obj *Typedef -} - -func NewTypedefBuilder() *TypedefBuilder{ - return &TypedefBuilder{ - obj: NewTypedef(), - } -} - -func (p TypedefBuilder) Emit() *Typedef{ - return &Typedef{ - } -} - -func (p *Typedef) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Typedef) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Typedef"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Typedef) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Typedef({})") -} - -// The `service` definition scope. -type Service struct { -} - -func NewService() *Service { - return &Service{} -} - -type ServiceBuilder struct { - obj *Service -} - -func NewServiceBuilder() *ServiceBuilder{ - return &ServiceBuilder{ - obj: NewService(), - } -} - -func (p ServiceBuilder) Emit() *Service{ - return &Service{ - } -} - -func (p *Service) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Service) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Service"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Service) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Service({})") -} - -// The `interaction` definition scope. -type Interaction struct { -} - -func NewInteraction() *Interaction { - return &Interaction{} -} - -type InteractionBuilder struct { - obj *Interaction -} - -func NewInteractionBuilder() *InteractionBuilder{ - return &InteractionBuilder{ - obj: NewInteraction(), - } -} - -func (p InteractionBuilder) Emit() *Interaction{ - return &Interaction{ - } -} - -func (p *Interaction) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Interaction) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Interaction"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Interaction) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Interaction({})") -} - -// The `function` definition scope. -type Function struct { -} - -func NewFunction() *Function { - return &Function{} -} - -type FunctionBuilder struct { - obj *Function -} - -func NewFunctionBuilder() *FunctionBuilder{ - return &FunctionBuilder{ - obj: NewFunction(), - } -} - -func (p FunctionBuilder) Emit() *Function{ - return &Function{ - } -} - -func (p *Function) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Function) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Function"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Function) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Function({})") -} - -// The Enum value definition scope. -type EnumValue struct { -} - -func NewEnumValue() *EnumValue { - return &EnumValue{} -} - -type EnumValueBuilder struct { - obj *EnumValue -} - -func NewEnumValueBuilder() *EnumValueBuilder{ - return &EnumValueBuilder{ - obj: NewEnumValue(), - } -} - -func (p EnumValueBuilder) Emit() *EnumValue{ - return &EnumValue{ - } -} - -func (p *EnumValue) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *EnumValue) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("EnumValue"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *EnumValue) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("EnumValue({})") -} - -// The `const` definition scope. -type Const struct { -} - -func NewConst() *Const { - return &Const{} -} - -type ConstBuilder struct { - obj *Const -} - -func NewConstBuilder() *ConstBuilder{ - return &ConstBuilder{ - obj: NewConst(), - } -} - -func (p ConstBuilder) Emit() *Const{ - return &Const{ - } -} - -func (p *Const) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Const) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Const"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Const) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Const({})") -} - -type Enum struct { -} - -func NewEnum() *Enum { - return &Enum{} -} - -type EnumBuilder struct { - obj *Enum -} - -func NewEnumBuilder() *EnumBuilder{ - return &EnumBuilder{ - obj: NewEnum(), - } -} - -func (p EnumBuilder) Emit() *Enum{ - return &Enum{ - } -} - -func (p *Enum) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Enum) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Enum"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Enum) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Enum({})") -} - -// A scope that includes all 'structured' definitions. -type Structured struct { -} - -func NewStructured() *Structured { - return &Structured{} -} - -type StructuredBuilder struct { - obj *Structured -} - -func NewStructuredBuilder() *StructuredBuilder{ - return &StructuredBuilder{ - obj: NewStructured(), - } -} - -func (p StructuredBuilder) Emit() *Structured{ - return &Structured{ - } -} - -func (p *Structured) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Structured) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Structured"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Structured) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Structured({})") -} - -// A scope that includes all 'interface' definitions. -type Interface struct { -} - -func NewInterface() *Interface { - return &Interface{} -} - -type InterfaceBuilder struct { - obj *Interface -} - -func NewInterfaceBuilder() *InterfaceBuilder{ - return &InterfaceBuilder{ - obj: NewInterface(), - } -} - -func (p InterfaceBuilder) Emit() *Interface{ - return &Interface{ - } -} - -func (p *Interface) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Interface) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Interface"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Interface) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Interface({})") -} - -// A scope that includes all program-scoped definition. -type RootDefinition struct { -} - -func NewRootDefinition() *RootDefinition { - return &RootDefinition{} -} - -type RootDefinitionBuilder struct { - obj *RootDefinition -} - -func NewRootDefinitionBuilder() *RootDefinitionBuilder{ - return &RootDefinitionBuilder{ - obj: NewRootDefinition(), - } -} - -func (p RootDefinitionBuilder) Emit() *RootDefinition{ - return &RootDefinition{ - } -} - -func (p *RootDefinition) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *RootDefinition) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("RootDefinition"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *RootDefinition) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("RootDefinition({})") -} - -// A scope that includes all definitions. -type Definition struct { -} - -func NewDefinition() *Definition { - return &Definition{} -} - -type DefinitionBuilder struct { - obj *Definition -} - -func NewDefinitionBuilder() *DefinitionBuilder{ - return &DefinitionBuilder{ - obj: NewDefinition(), - } -} - -func (p DefinitionBuilder) Emit() *Definition{ - return &Definition{ - } -} - -func (p *Definition) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Definition) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Definition"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Definition) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Definition({})") -} - diff --git a/thrift/compiler/test/fixtures/types/gen-go/thrift/annotation/thrift/constants.go b/thrift/compiler/test/fixtures/types/gen-go/thrift/annotation/thrift/constants.go deleted file mode 100644 index 50d9b0fe3ee..00000000000 --- a/thrift/compiler/test/fixtures/types/gen-go/thrift/annotation/thrift/constants.go +++ /dev/null @@ -1,25 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package thrift - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - - -func init() { -} - diff --git a/thrift/compiler/test/fixtures/types/gen-go/thrift/annotation/thrift/ttypes.go b/thrift/compiler/test/fixtures/types/gen-go/thrift/annotation/thrift/ttypes.go deleted file mode 100644 index 35ea75e3dd0..00000000000 --- a/thrift/compiler/test/fixtures/types/gen-go/thrift/annotation/thrift/ttypes.go +++ /dev/null @@ -1,1545 +0,0 @@ -// Autogenerated by Thrift Compiler (facebook) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// @generated - -package thrift - -import ( - "bytes" - "context" - "sync" - "fmt" - thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = sync.Mutex{} -var _ = bytes.Equal -var _ = context.Background - -var GoUnusedProtection__ int; - -type RpcPriority int64 -const ( - RpcPriority_HIGH_IMPORTANT RpcPriority = 0 - RpcPriority_HIGH RpcPriority = 1 - RpcPriority_IMPORTANT RpcPriority = 2 - RpcPriority_NORMAL RpcPriority = 3 - RpcPriority_BEST_EFFORT RpcPriority = 4 -) - -var RpcPriorityToName = map[RpcPriority]string { - RpcPriority_HIGH_IMPORTANT: "HIGH_IMPORTANT", - RpcPriority_HIGH: "HIGH", - RpcPriority_IMPORTANT: "IMPORTANT", - RpcPriority_NORMAL: "NORMAL", - RpcPriority_BEST_EFFORT: "BEST_EFFORT", -} - -var RpcPriorityToValue = map[string]RpcPriority { - "HIGH_IMPORTANT": RpcPriority_HIGH_IMPORTANT, - "HIGH": RpcPriority_HIGH, - "IMPORTANT": RpcPriority_IMPORTANT, - "NORMAL": RpcPriority_NORMAL, - "BEST_EFFORT": RpcPriority_BEST_EFFORT, -} - -var RpcPriorityNames = []string { - "HIGH_IMPORTANT", - "HIGH", - "IMPORTANT", - "NORMAL", - "BEST_EFFORT", -} - -var RpcPriorityValues = []RpcPriority { - RpcPriority_HIGH_IMPORTANT, - RpcPriority_HIGH, - RpcPriority_IMPORTANT, - RpcPriority_NORMAL, - RpcPriority_BEST_EFFORT, -} - -func (p RpcPriority) String() string { - if v, ok := RpcPriorityToName[p]; ok { - return v - } - return "" -} - -func RpcPriorityFromString(s string) (RpcPriority, error) { - if v, ok := RpcPriorityToValue[s]; ok { - return v, nil - } - return RpcPriority(0), fmt.Errorf("not a valid RpcPriority string") -} - -func RpcPriorityPtr(v RpcPriority) *RpcPriority { return &v } - -// Indicates a definition/feature should only be used with permission, may -// only work in specific contexts, and may change in incompatible ways without -// notice. Note that this is primarily intended to annotate features by the Thrift Team -// and isn't recommended for general use. -type Experimental struct { -} - -func NewExperimental() *Experimental { - return &Experimental{} -} - -type ExperimentalBuilder struct { - obj *Experimental -} - -func NewExperimentalBuilder() *ExperimentalBuilder{ - return &ExperimentalBuilder{ - obj: NewExperimental(), - } -} - -func (p ExperimentalBuilder) Emit() *Experimental{ - return &Experimental{ - } -} - -func (p *Experimental) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Experimental) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Experimental"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Experimental) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Experimental({})") -} - -// Annotate a thrift structured or enum to indicate if ids or values should not -// be used. -// -// For example, you may want to mark ids as deprecated, or these ids -// might be reserved for other use cases or annotations. -// -// The resolved set of disallowed ids is the union of the values in `ids` and -// the range of values represented in `id_ranges`. Example: -// -// // These ids are not allowed: 3, 8, half-open ranges [10, 15), [20, 30) -// @thrift.ReserveIds{ids = [3, 8], id_ranges = {10: 15, 20: 30}} -// struct Foo { -// ... -// 3: i64 f; // Build failure: 3 cannot be used -// } -// -// Attributes: -// - Ids: Individual ids that cannot be used. -// - IdRanges: Represents ranges of ids that cannot be used. -// -// Each (key: value) pair represents the half-open range `[key, value)`, -// where `key` is included and `value` is not. For example, the map -// `{10: 15, 20: 30}` represents the union of id/value ranges `[10, 15)` and -// `[20, 30)`. -type ReserveIds struct { - Ids []int32 `thrift:"ids,1" db:"ids" json:"ids"` - IdRanges map[int32]int32 `thrift:"id_ranges,2" db:"id_ranges" json:"id_ranges"` -} - -func NewReserveIds() *ReserveIds { - return &ReserveIds{} -} - - -func (p *ReserveIds) GetIds() []int32 { - return p.Ids -} - -func (p *ReserveIds) GetIdRanges() map[int32]int32 { - return p.IdRanges -} -type ReserveIdsBuilder struct { - obj *ReserveIds -} - -func NewReserveIdsBuilder() *ReserveIdsBuilder{ - return &ReserveIdsBuilder{ - obj: NewReserveIds(), - } -} - -func (p ReserveIdsBuilder) Emit() *ReserveIds{ - return &ReserveIds{ - Ids: p.obj.Ids, - IdRanges: p.obj.IdRanges, - } -} - -func (r *ReserveIdsBuilder) Ids(ids []int32) *ReserveIdsBuilder { - r.obj.Ids = ids - return r -} - -func (r *ReserveIdsBuilder) IdRanges(idRanges map[int32]int32) *ReserveIdsBuilder { - r.obj.IdRanges = idRanges - return r -} - -func (r *ReserveIds) SetIds(ids []int32) *ReserveIds { - r.Ids = ids - return r -} - -func (r *ReserveIds) SetIdRanges(idRanges map[int32]int32) *ReserveIds { - r.IdRanges = idRanges - return r -} - -func (p *ReserveIds) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - case 2: - if err := p.ReadField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ReserveIds) ReadField1(iprot thrift.Protocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]int32, 0, size) - p.Ids = tSlice - for i := 0; i < size; i ++ { - var _elem0 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem0 = v - } - p.Ids = append(p.Ids, _elem0) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *ReserveIds) ReadField2(iprot thrift.Protocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[int32]int32, size) - p.IdRanges = tMap - for i := 0; i < size; i ++ { - var _key1 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key1 = v - } - var _val2 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _val2 = v - } - p.IdRanges[_key1] = _val2 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *ReserveIds) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("ReserveIds"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *ReserveIds) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("ids", thrift.LIST, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:ids: ", p), err) } - if err := oprot.WriteListBegin(thrift.I32, len(p.Ids)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.Ids { - if err := oprot.WriteI32(int32(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:ids: ", p), err) } - return err -} - -func (p *ReserveIds) writeField2(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("id_ranges", thrift.MAP, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:id_ranges: ", p), err) } - if err := oprot.WriteMapBegin(thrift.I32, thrift.I32, len(p.IdRanges)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.IdRanges { - if err := oprot.WriteI32(int32(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := oprot.WriteI32(int32(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:id_ranges: ", p), err) } - return err -} - -func (p *ReserveIds) String() string { - if p == nil { - return "" - } - - idsVal := fmt.Sprintf("%v", p.Ids) - idRangesVal := fmt.Sprintf("%v", p.IdRanges) - return fmt.Sprintf("ReserveIds({Ids:%s IdRanges:%s})", idsVal, idRangesVal) -} - -// Indicates additional backward compatibility restrictions, beyond the -// standard Thrift required 'wire' compatibility. -// -// Attributes: -// - FieldName -type RequiresBackwardCompatibility struct { - FieldName bool `thrift:"field_name,1" db:"field_name" json:"field_name"` -} - -func NewRequiresBackwardCompatibility() *RequiresBackwardCompatibility { - return &RequiresBackwardCompatibility{} -} - - -func (p *RequiresBackwardCompatibility) GetFieldName() bool { - return p.FieldName -} -type RequiresBackwardCompatibilityBuilder struct { - obj *RequiresBackwardCompatibility -} - -func NewRequiresBackwardCompatibilityBuilder() *RequiresBackwardCompatibilityBuilder{ - return &RequiresBackwardCompatibilityBuilder{ - obj: NewRequiresBackwardCompatibility(), - } -} - -func (p RequiresBackwardCompatibilityBuilder) Emit() *RequiresBackwardCompatibility{ - return &RequiresBackwardCompatibility{ - FieldName: p.obj.FieldName, - } -} - -func (r *RequiresBackwardCompatibilityBuilder) FieldName(fieldName bool) *RequiresBackwardCompatibilityBuilder { - r.obj.FieldName = fieldName - return r -} - -func (r *RequiresBackwardCompatibility) SetFieldName(fieldName bool) *RequiresBackwardCompatibility { - r.FieldName = fieldName - return r -} - -func (p *RequiresBackwardCompatibility) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *RequiresBackwardCompatibility) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.FieldName = v - } - return nil -} - -func (p *RequiresBackwardCompatibility) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("RequiresBackwardCompatibility"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *RequiresBackwardCompatibility) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("field_name", thrift.BOOL, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:field_name: ", p), err) } - if err := oprot.WriteBool(bool(p.FieldName)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.field_name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:field_name: ", p), err) } - return err -} - -func (p *RequiresBackwardCompatibility) String() string { - if p == nil { - return "" - } - - fieldNameVal := fmt.Sprintf("%v", p.FieldName) - return fmt.Sprintf("RequiresBackwardCompatibility({FieldName:%s})", fieldNameVal) -} - -// An annotation that changes the field qualifier from 'none' to 'terse'. -// A terse field is eligible to skip serialization, when it equals to the -// intrinsic default value. It also clears to the intrinsic default value -// before deserialization to distinguish between if a terse field was skipped -// or missing during serialization. This is different from an unqualified -// field, as an unqualified field is always serialized regardless of its value, -// and it is not cleared before deserialization. -// -// The annotation can be only used to annotate an unqualified field, and when -// it is annotating a struct or exception, it changes all unqualified fields to -// terse fields. Note, the annotation can not be used for union. -type TerseWrite struct { -} - -func NewTerseWrite() *TerseWrite { - return &TerseWrite{} -} - -type TerseWriteBuilder struct { - obj *TerseWrite -} - -func NewTerseWriteBuilder() *TerseWriteBuilder{ - return &TerseWriteBuilder{ - obj: NewTerseWrite(), - } -} - -func (p TerseWriteBuilder) Emit() *TerseWrite{ - return &TerseWrite{ - } -} - -func (p *TerseWrite) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *TerseWrite) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("TerseWrite"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *TerseWrite) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("TerseWrite({})") -} - -// Indicates that an optional field's value should never be stored on the stack, -// i.e. the subobject should be allocated separately (e.g. because it is large and infrequently set). -// -// NOTE: The APIs and initialization behavior are same as normal field, but different from `@cpp.Ref`. e.g. -// -// ``` -// struct Foo { -// 1: optional i32 normal; -// @thrift.Box -// 2: optional i32 boxed; -// @cpp.Ref -// 3: optional i32 referred; -// } -// ``` -// in C++ -// -// ``` -// Foo foo; -// EXPECT_FALSE(foo.normal().has_value()); // okay -// EXPECT_FALSE(foo.boxed().has_value()); // okay -// EXPECT_FALSE(foo.referred().has_value()); // build failure: std::unique_ptr doesn't have has_value method -// -// EXPECT_EQ(*foo.normal(), 0); // throw bad_field_access exception -// EXPECT_EQ(*foo.boxed(), 0); // throw bad_field_access exception -// EXPECT_EQ(*foo.referred(), 0); // okay, field has value by default -// ``` -// -// Affects C++ and Rust. -// TODO: replace with @cpp.Box + @rust.Box -type Box struct { -} - -func NewBox() *Box { - return &Box{} -} - -type BoxBuilder struct { - obj *Box -} - -func NewBoxBuilder() *BoxBuilder{ - return &BoxBuilder{ - obj: NewBox(), - } -} - -func (p BoxBuilder) Emit() *Box{ - return &Box{ - } -} - -func (p *Box) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Box) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Box"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Box) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Box({})") -} - -// Indicates whether the nested fields are accessible directly. -// https://github.com/facebook/fbthrift/blob/v2023.11.20.00/thrift/doc/idl/mixins.md -type Mixin struct { -} - -func NewMixin() *Mixin { - return &Mixin{} -} - -type MixinBuilder struct { - obj *Mixin -} - -func NewMixinBuilder() *MixinBuilder{ - return &MixinBuilder{ - obj: NewMixin(), - } -} - -func (p MixinBuilder) Emit() *Mixin{ - return &Mixin{ - } -} - -func (p *Mixin) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Mixin) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Mixin"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Mixin) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Mixin({})") -} - -// Option to serialize thrift struct in ascending field id order instead of field declaration order. -// -// This can potentially make serialized data size smaller in compact protocol, -// since compact protocol can write deltas between subsequent field ids instead of full ids. -// -// NOTE: This annotation won't reduce payload size for other protocols. -type SerializeInFieldIdOrder struct { -} - -func NewSerializeInFieldIdOrder() *SerializeInFieldIdOrder { - return &SerializeInFieldIdOrder{} -} - -type SerializeInFieldIdOrderBuilder struct { - obj *SerializeInFieldIdOrder -} - -func NewSerializeInFieldIdOrderBuilder() *SerializeInFieldIdOrderBuilder{ - return &SerializeInFieldIdOrderBuilder{ - obj: NewSerializeInFieldIdOrder(), - } -} - -func (p SerializeInFieldIdOrderBuilder) Emit() *SerializeInFieldIdOrder{ - return &SerializeInFieldIdOrder{ - } -} - -func (p *SerializeInFieldIdOrder) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *SerializeInFieldIdOrder) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("SerializeInFieldIdOrder"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *SerializeInFieldIdOrder) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("SerializeInFieldIdOrder({})") -} - -// Indicates an enum is a bitmask and should support bit-wise operators. -// Currently generates additional code in C++ and Hack. -type BitmaskEnum struct { -} - -func NewBitmaskEnum() *BitmaskEnum { - return &BitmaskEnum{} -} - -type BitmaskEnumBuilder struct { - obj *BitmaskEnum -} - -func NewBitmaskEnumBuilder() *BitmaskEnumBuilder{ - return &BitmaskEnumBuilder{ - obj: NewBitmaskEnum(), - } -} - -func (p BitmaskEnumBuilder) Emit() *BitmaskEnum{ - return &BitmaskEnum{ - } -} - -func (p *BitmaskEnum) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *BitmaskEnum) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("BitmaskEnum"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *BitmaskEnum) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("BitmaskEnum({})") -} - -// Specifies the field where the exception message is stored. -type ExceptionMessage struct { -} - -func NewExceptionMessage() *ExceptionMessage { - return &ExceptionMessage{} -} - -type ExceptionMessageBuilder struct { - obj *ExceptionMessage -} - -func NewExceptionMessageBuilder() *ExceptionMessageBuilder{ - return &ExceptionMessageBuilder{ - obj: NewExceptionMessage(), - } -} - -func (p ExceptionMessageBuilder) Emit() *ExceptionMessage{ - return &ExceptionMessage{ - } -} - -func (p *ExceptionMessage) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ExceptionMessage) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("ExceptionMessage"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *ExceptionMessage) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("ExceptionMessage({})") -} - -// Generates a const of type schema. Struct containing the schema of the -// annotated type. Optionally specify name to override default -// schema. -// -// Attributes: -// - Name -type GenerateRuntimeSchema struct { - Name string `thrift:"name,1" db:"name" json:"name"` -} - -func NewGenerateRuntimeSchema() *GenerateRuntimeSchema { - return &GenerateRuntimeSchema{} -} - - -func (p *GenerateRuntimeSchema) GetName() string { - return p.Name -} -type GenerateRuntimeSchemaBuilder struct { - obj *GenerateRuntimeSchema -} - -func NewGenerateRuntimeSchemaBuilder() *GenerateRuntimeSchemaBuilder{ - return &GenerateRuntimeSchemaBuilder{ - obj: NewGenerateRuntimeSchema(), - } -} - -func (p GenerateRuntimeSchemaBuilder) Emit() *GenerateRuntimeSchema{ - return &GenerateRuntimeSchema{ - Name: p.obj.Name, - } -} - -func (g *GenerateRuntimeSchemaBuilder) Name(name string) *GenerateRuntimeSchemaBuilder { - g.obj.Name = name - return g -} - -func (g *GenerateRuntimeSchema) SetName(name string) *GenerateRuntimeSchema { - g.Name = name - return g -} - -func (p *GenerateRuntimeSchema) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *GenerateRuntimeSchema) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Name = v - } - return nil -} - -func (p *GenerateRuntimeSchema) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("GenerateRuntimeSchema"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *GenerateRuntimeSchema) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) } - if err := oprot.WriteString(string(p.Name)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) } - return err -} - -func (p *GenerateRuntimeSchema) String() string { - if p == nil { - return "" - } - - nameVal := fmt.Sprintf("%v", p.Name) - return fmt.Sprintf("GenerateRuntimeSchema({Name:%s})", nameVal) -} - -// Indicates that a field's value should never be stored on the stack, and that -// identical values can be shared in immutable contexts. -type InternBox struct { -} - -func NewInternBox() *InternBox { - return &InternBox{} -} - -type InternBoxBuilder struct { - obj *InternBox -} - -func NewInternBoxBuilder() *InternBoxBuilder{ - return &InternBoxBuilder{ - obj: NewInternBox(), - } -} - -func (p InternBoxBuilder) Emit() *InternBox{ - return &InternBox{ - } -} - -func (p *InternBox) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *InternBox) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("InternBox"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *InternBox) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("InternBox({})") -} - -// Indicates that an interaction's methods should be processed sequentially. -type Serial struct { -} - -func NewSerial() *Serial { - return &Serial{} -} - -type SerialBuilder struct { - obj *Serial -} - -func NewSerialBuilder() *SerialBuilder{ - return &SerialBuilder{ - obj: NewSerial(), - } -} - -func (p SerialBuilder) Emit() *Serial{ - return &Serial{ - } -} - -func (p *Serial) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Serial) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Serial"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Serial) String() string { - if p == nil { - return "" - } - - return fmt.Sprintf("Serial({})") -} - -// Changes the URI of this definition away from the default-generated one. -// -// Attributes: -// - Value -type Uri struct { - Value string `thrift:"value,1" db:"value" json:"value"` -} - -func NewUri() *Uri { - return &Uri{} -} - - -func (p *Uri) GetValue() string { - return p.Value -} -type UriBuilder struct { - obj *Uri -} - -func NewUriBuilder() *UriBuilder{ - return &UriBuilder{ - obj: NewUri(), - } -} - -func (p UriBuilder) Emit() *Uri{ - return &Uri{ - Value: p.obj.Value, - } -} - -func (u *UriBuilder) Value(value string) *UriBuilder { - u.obj.Value = value - return u -} - -func (u *Uri) SetValue(value string) *Uri { - u.Value = value - return u -} - -func (p *Uri) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Uri) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Value = v - } - return nil -} - -func (p *Uri) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Uri"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Uri) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("value", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:value: ", p), err) } - if err := oprot.WriteString(string(p.Value)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.value (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:value: ", p), err) } - return err -} - -func (p *Uri) String() string { - if p == nil { - return "" - } - - valueVal := fmt.Sprintf("%v", p.Value) - return fmt.Sprintf("Uri({Value:%s})", valueVal) -} - -// Changes the priority of this function (default NORMAL). -// -// Attributes: -// - Level -type Priority struct { - Level RpcPriority `thrift:"level,1" db:"level" json:"level"` -} - -func NewPriority() *Priority { - return &Priority{} -} - - -func (p *Priority) GetLevel() RpcPriority { - return p.Level -} -type PriorityBuilder struct { - obj *Priority -} - -func NewPriorityBuilder() *PriorityBuilder{ - return &PriorityBuilder{ - obj: NewPriority(), - } -} - -func (p PriorityBuilder) Emit() *Priority{ - return &Priority{ - Level: p.obj.Level, - } -} - -func (p *PriorityBuilder) Level(level RpcPriority) *PriorityBuilder { - p.obj.Level = level - return p -} - -func (p *Priority) SetLevel(level RpcPriority) *Priority { - p.Level = level - return p -} - -func (p *Priority) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Priority) ReadField1(iprot thrift.Protocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - temp := RpcPriority(v) - p.Level = temp - } - return nil -} - -func (p *Priority) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("Priority"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *Priority) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("level", thrift.I32, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:level: ", p), err) } - if err := oprot.WriteI32(int32(p.Level)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.level (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:level: ", p), err) } - return err -} - -func (p *Priority) String() string { - if p == nil { - return "" - } - - levelVal := fmt.Sprintf("%v", p.Level) - return fmt.Sprintf("Priority({Level:%s})", levelVal) -} - -// Applies unstructured annotations to a definition. -// -// Attributes: -// - Items -type DeprecatedUnvalidatedAnnotations struct { - Items map[string]string `thrift:"items,1" db:"items" json:"items"` -} - -func NewDeprecatedUnvalidatedAnnotations() *DeprecatedUnvalidatedAnnotations { - return &DeprecatedUnvalidatedAnnotations{} -} - - -func (p *DeprecatedUnvalidatedAnnotations) GetItems() map[string]string { - return p.Items -} -type DeprecatedUnvalidatedAnnotationsBuilder struct { - obj *DeprecatedUnvalidatedAnnotations -} - -func NewDeprecatedUnvalidatedAnnotationsBuilder() *DeprecatedUnvalidatedAnnotationsBuilder{ - return &DeprecatedUnvalidatedAnnotationsBuilder{ - obj: NewDeprecatedUnvalidatedAnnotations(), - } -} - -func (p DeprecatedUnvalidatedAnnotationsBuilder) Emit() *DeprecatedUnvalidatedAnnotations{ - return &DeprecatedUnvalidatedAnnotations{ - Items: p.obj.Items, - } -} - -func (d *DeprecatedUnvalidatedAnnotationsBuilder) Items(items map[string]string) *DeprecatedUnvalidatedAnnotationsBuilder { - d.obj.Items = items - return d -} - -func (d *DeprecatedUnvalidatedAnnotations) SetItems(items map[string]string) *DeprecatedUnvalidatedAnnotations { - d.Items = items - return d -} - -func (p *DeprecatedUnvalidatedAnnotations) Read(iprot thrift.Protocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if err := p.ReadField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *DeprecatedUnvalidatedAnnotations) ReadField1(iprot thrift.Protocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[string]string, size) - p.Items = tMap - for i := 0; i < size; i ++ { - var _key3 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key3 = v - } - var _val4 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _val4 = v - } - p.Items[_key3] = _val4 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *DeprecatedUnvalidatedAnnotations) Write(oprot thrift.Protocol) error { - if err := oprot.WriteStructBegin("DeprecatedUnvalidatedAnnotations"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if err := p.writeField1(oprot); err != nil { return err } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *DeprecatedUnvalidatedAnnotations) writeField1(oprot thrift.Protocol) (err error) { - if err := oprot.WriteFieldBegin("items", thrift.MAP, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:items: ", p), err) } - if err := oprot.WriteMapBegin(thrift.STRING, thrift.STRING, len(p.Items)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.Items { - if err := oprot.WriteString(string(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := oprot.WriteString(string(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:items: ", p), err) } - return err -} - -func (p *DeprecatedUnvalidatedAnnotations) String() string { - if p == nil { - return "" - } - - itemsVal := fmt.Sprintf("%v", p.Items) - return fmt.Sprintf("DeprecatedUnvalidatedAnnotations({Items:%s})", itemsVal) -} -