| // Copyright 2015 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| // This file is autogenerated by: |
| // mojo/public/tools/bindings/mojom_bindings_generator.py |
| // For: |
| // mojom/vanadium/discovery.mojom |
| // |
| |
| package discovery |
| |
| import ( |
| fmt "fmt" |
| bindings "mojo/public/go/bindings" |
| system "mojo/public/go/system" |
| mojom_types "mojo/public/interfaces/bindings/mojom_types" |
| service_describer "mojo/public/interfaces/bindings/service_describer" |
| sort "sort" |
| ) |
| |
| type Discovery interface { |
| Advertise(inAd Advertisement, inVisibility *[]string) (outInstanceId *[16]uint8, outCloser *Closer_Pointer, outErr *Error, err error) |
| Scan(inQuery string, inHandler ScanHandler_Pointer) (outCloser *Closer_Pointer, outErr *Error, err error) |
| } |
| |
| var discovery_Name = "v23::discovery::Discovery" |
| |
| type Discovery_Request bindings.InterfaceRequest |
| |
| func (r *Discovery_Request) Name() string { |
| return discovery_Name |
| } |
| |
| type Discovery_Pointer bindings.InterfacePointer |
| |
| func (p *Discovery_Pointer) Name() string { |
| return discovery_Name |
| } |
| |
| type Discovery_ServiceFactory struct { |
| Delegate Discovery_Factory |
| } |
| |
| type Discovery_Factory interface { |
| Create(request Discovery_Request) |
| } |
| |
| func (f *Discovery_ServiceFactory) Name() string { |
| return discovery_Name |
| } |
| |
| // TODO(rudominer) This should only be defined for top-level interfaces. |
| func (f *Discovery_ServiceFactory) ServiceDescription() service_describer.ServiceDescription { |
| return &Discovery_ServiceDescription{} |
| } |
| |
| func (f *Discovery_ServiceFactory) Create(messagePipe system.MessagePipeHandle) { |
| request := Discovery_Request{bindings.NewMessagePipeHandleOwner(messagePipe)} |
| f.Delegate.Create(request) |
| } |
| |
| // CreateMessagePipeForDiscovery creates a message pipe for use with the |
| // Discovery interface with a Discovery_Request on one end and a Discovery_Pointer on the other. |
| func CreateMessagePipeForDiscovery() (Discovery_Request, Discovery_Pointer) { |
| r, p := bindings.CreateMessagePipeForMojoInterface() |
| return Discovery_Request(r), Discovery_Pointer(p) |
| } |
| |
| const discovery_Advertise_Name uint32 = 0 |
| const discovery_Scan_Name uint32 = 1 |
| |
| type Discovery_Proxy struct { |
| router *bindings.Router |
| ids bindings.Counter |
| } |
| |
| func NewDiscoveryProxy(p Discovery_Pointer, waiter bindings.AsyncWaiter) *Discovery_Proxy { |
| return &Discovery_Proxy{ |
| bindings.NewRouter(p.PassMessagePipe(), waiter), |
| bindings.NewCounter(), |
| } |
| } |
| |
| func (p *Discovery_Proxy) Close_Proxy() { |
| p.router.Close() |
| } |
| |
| type discovery_Advertise_Params struct { |
| inAd Advertisement |
| inVisibility *[]string |
| } |
| |
| func (s *discovery_Advertise_Params) Encode(encoder *bindings.Encoder) error { |
| encoder.StartStruct(16, 0) |
| if err := encoder.WritePointer(); err != nil { |
| return err |
| } |
| if err := s.inAd.Encode(encoder); err != nil { |
| return err |
| } |
| if s.inVisibility == nil { |
| encoder.WriteNullPointer() |
| } else { |
| if err := encoder.WritePointer(); err != nil { |
| return err |
| } |
| encoder.StartArray(uint32(len((*s.inVisibility))), 64) |
| for _, elem0 := range *s.inVisibility { |
| if err := encoder.WritePointer(); err != nil { |
| return err |
| } |
| if err := encoder.WriteString(elem0); err != nil { |
| return err |
| } |
| } |
| if err := encoder.Finish(); err != nil { |
| return err |
| } |
| } |
| if err := encoder.Finish(); err != nil { |
| return err |
| } |
| return nil |
| } |
| |
| var discovery_Advertise_Params_Versions []bindings.DataHeader = []bindings.DataHeader{ |
| bindings.DataHeader{24, 0}, |
| } |
| |
| func (s *discovery_Advertise_Params) Decode(decoder *bindings.Decoder) error { |
| header, err := decoder.StartStruct() |
| if err != nil { |
| return err |
| } |
| index := sort.Search(len(discovery_Advertise_Params_Versions), func(i int) bool { |
| return discovery_Advertise_Params_Versions[i].ElementsOrVersion >= header.ElementsOrVersion |
| }) |
| if index < len(discovery_Advertise_Params_Versions) { |
| if discovery_Advertise_Params_Versions[index].ElementsOrVersion > header.ElementsOrVersion { |
| index-- |
| } |
| expectedSize := discovery_Advertise_Params_Versions[index].Size |
| if expectedSize != header.Size { |
| return &bindings.ValidationError{bindings.UnexpectedStructHeader, |
| fmt.Sprintf("invalid struct header size: should be %d, but was %d", expectedSize, header.Size), |
| } |
| } |
| } |
| if header.ElementsOrVersion >= 0 { |
| pointer0, err := decoder.ReadPointer() |
| if err != nil { |
| return err |
| } |
| if pointer0 == 0 { |
| return &bindings.ValidationError{bindings.UnexpectedNullPointer, "unexpected null pointer"} |
| } else { |
| if err := s.inAd.Decode(decoder); err != nil { |
| return err |
| } |
| } |
| } |
| if header.ElementsOrVersion >= 0 { |
| pointer0, err := decoder.ReadPointer() |
| if err != nil { |
| return err |
| } |
| if pointer0 == 0 { |
| s.inVisibility = nil |
| } else { |
| s.inVisibility = new([]string) |
| len0, err := decoder.StartArray(64) |
| if err != nil { |
| return err |
| } |
| (*s.inVisibility) = make([]string, len0) |
| for i0 := uint32(0); i0 < len0; i0++ { |
| pointer1, err := decoder.ReadPointer() |
| if err != nil { |
| return err |
| } |
| if pointer1 == 0 { |
| return &bindings.ValidationError{bindings.UnexpectedNullPointer, "unexpected null pointer"} |
| } else { |
| value1, err := decoder.ReadString() |
| if err != nil { |
| return err |
| } |
| (*s.inVisibility)[i0] = value1 |
| } |
| } |
| if err := decoder.Finish(); err != nil { |
| return err |
| } |
| } |
| } |
| if err := decoder.Finish(); err != nil { |
| return err |
| } |
| return nil |
| } |
| |
| type discovery_Advertise_ResponseParams struct { |
| outInstanceId *[16]uint8 |
| outCloser *Closer_Pointer |
| outErr *Error |
| } |
| |
| func (s *discovery_Advertise_ResponseParams) Encode(encoder *bindings.Encoder) error { |
| encoder.StartStruct(24, 0) |
| if s.outInstanceId == nil { |
| encoder.WriteNullPointer() |
| } else { |
| if err := encoder.WritePointer(); err != nil { |
| return err |
| } |
| encoder.StartArray(uint32(len((*s.outInstanceId))), 8) |
| for _, elem0 := range *s.outInstanceId { |
| if err := encoder.WriteUint8(elem0); err != nil { |
| return err |
| } |
| } |
| if err := encoder.Finish(); err != nil { |
| return err |
| } |
| } |
| if s.outCloser == nil { |
| encoder.WriteInvalidInterface() |
| } else { |
| if err := encoder.WriteInterface((*s.outCloser).PassMessagePipe()); err != nil { |
| return err |
| } |
| } |
| if s.outErr == nil { |
| encoder.WriteNullPointer() |
| } else { |
| if err := encoder.WritePointer(); err != nil { |
| return err |
| } |
| if err := (*s.outErr).Encode(encoder); err != nil { |
| return err |
| } |
| } |
| if err := encoder.Finish(); err != nil { |
| return err |
| } |
| return nil |
| } |
| |
| var discovery_Advertise_ResponseParams_Versions []bindings.DataHeader = []bindings.DataHeader{ |
| bindings.DataHeader{32, 0}, |
| } |
| |
| func (s *discovery_Advertise_ResponseParams) Decode(decoder *bindings.Decoder) error { |
| header, err := decoder.StartStruct() |
| if err != nil { |
| return err |
| } |
| index := sort.Search(len(discovery_Advertise_ResponseParams_Versions), func(i int) bool { |
| return discovery_Advertise_ResponseParams_Versions[i].ElementsOrVersion >= header.ElementsOrVersion |
| }) |
| if index < len(discovery_Advertise_ResponseParams_Versions) { |
| if discovery_Advertise_ResponseParams_Versions[index].ElementsOrVersion > header.ElementsOrVersion { |
| index-- |
| } |
| expectedSize := discovery_Advertise_ResponseParams_Versions[index].Size |
| if expectedSize != header.Size { |
| return &bindings.ValidationError{bindings.UnexpectedStructHeader, |
| fmt.Sprintf("invalid struct header size: should be %d, but was %d", expectedSize, header.Size), |
| } |
| } |
| } |
| if header.ElementsOrVersion >= 0 { |
| pointer0, err := decoder.ReadPointer() |
| if err != nil { |
| return err |
| } |
| if pointer0 == 0 { |
| s.outInstanceId = nil |
| } else { |
| s.outInstanceId = new([16]uint8) |
| len0, err := decoder.StartArray(8) |
| if err != nil { |
| return err |
| } |
| if len0 != 16 { |
| return &bindings.ValidationError{bindings.UnexpectedArrayHeader, |
| fmt.Sprintf("invalid array length: expected %d, got %d", 16, len0), |
| } |
| } |
| for i0 := uint32(0); i0 < len0; i0++ { |
| value1, err := decoder.ReadUint8() |
| if err != nil { |
| return err |
| } |
| (*s.outInstanceId)[i0] = value1 |
| } |
| if err := decoder.Finish(); err != nil { |
| return err |
| } |
| } |
| } |
| if header.ElementsOrVersion >= 0 { |
| handle0, err := decoder.ReadInterface() |
| if err != nil { |
| return err |
| } |
| if handle0.IsValid() { |
| handleOwner := bindings.NewMessagePipeHandleOwner(handle0) |
| s.outCloser = &Closer_Pointer{handleOwner} |
| } else { |
| s.outCloser = nil |
| } |
| } |
| if header.ElementsOrVersion >= 0 { |
| pointer0, err := decoder.ReadPointer() |
| if err != nil { |
| return err |
| } |
| if pointer0 == 0 { |
| s.outErr = nil |
| } else { |
| s.outErr = new(Error) |
| if err := (*s.outErr).Decode(decoder); err != nil { |
| return err |
| } |
| } |
| } |
| if err := decoder.Finish(); err != nil { |
| return err |
| } |
| return nil |
| } |
| |
| func (p *Discovery_Proxy) Advertise(inAd Advertisement, inVisibility *[]string) (outInstanceId *[16]uint8, outCloser *Closer_Pointer, outErr *Error, err error) { |
| payload := &discovery_Advertise_Params{ |
| inAd, |
| inVisibility, |
| } |
| header := bindings.MessageHeader{ |
| Type: discovery_Advertise_Name, |
| Flags: bindings.MessageExpectsResponseFlag, |
| RequestId: p.ids.Count(), |
| } |
| var message *bindings.Message |
| if message, err = bindings.EncodeMessage(header, payload); err != nil { |
| err = fmt.Errorf("can't encode request: %v", err.Error()) |
| p.Close_Proxy() |
| return |
| } |
| readResult := <-p.router.AcceptWithResponse(message) |
| if err = readResult.Error; err != nil { |
| p.Close_Proxy() |
| return |
| } |
| if readResult.Message.Header.Flags != bindings.MessageIsResponseFlag { |
| err = &bindings.ValidationError{bindings.MessageHeaderInvalidFlags, |
| fmt.Sprintf("invalid message header flag: %v", readResult.Message.Header.Flags), |
| } |
| return |
| } |
| if got, want := readResult.Message.Header.Type, discovery_Advertise_Name; got != want { |
| err = &bindings.ValidationError{bindings.MessageHeaderUnknownMethod, |
| fmt.Sprintf("invalid method in response: expected %v, got %v", want, got), |
| } |
| return |
| } |
| var response discovery_Advertise_ResponseParams |
| if err = readResult.Message.DecodePayload(&response); err != nil { |
| p.Close_Proxy() |
| return |
| } |
| outInstanceId = response.outInstanceId |
| outCloser = response.outCloser |
| outErr = response.outErr |
| return |
| } |
| |
| type discovery_Scan_Params struct { |
| inQuery string |
| inHandler ScanHandler_Pointer |
| } |
| |
| func (s *discovery_Scan_Params) Encode(encoder *bindings.Encoder) error { |
| encoder.StartStruct(16, 0) |
| if err := encoder.WritePointer(); err != nil { |
| return err |
| } |
| if err := encoder.WriteString(s.inQuery); err != nil { |
| return err |
| } |
| if err := encoder.WriteInterface(s.inHandler.PassMessagePipe()); err != nil { |
| return err |
| } |
| if err := encoder.Finish(); err != nil { |
| return err |
| } |
| return nil |
| } |
| |
| var discovery_Scan_Params_Versions []bindings.DataHeader = []bindings.DataHeader{ |
| bindings.DataHeader{24, 0}, |
| } |
| |
| func (s *discovery_Scan_Params) Decode(decoder *bindings.Decoder) error { |
| header, err := decoder.StartStruct() |
| if err != nil { |
| return err |
| } |
| index := sort.Search(len(discovery_Scan_Params_Versions), func(i int) bool { |
| return discovery_Scan_Params_Versions[i].ElementsOrVersion >= header.ElementsOrVersion |
| }) |
| if index < len(discovery_Scan_Params_Versions) { |
| if discovery_Scan_Params_Versions[index].ElementsOrVersion > header.ElementsOrVersion { |
| index-- |
| } |
| expectedSize := discovery_Scan_Params_Versions[index].Size |
| if expectedSize != header.Size { |
| return &bindings.ValidationError{bindings.UnexpectedStructHeader, |
| fmt.Sprintf("invalid struct header size: should be %d, but was %d", expectedSize, header.Size), |
| } |
| } |
| } |
| if header.ElementsOrVersion >= 0 { |
| pointer0, err := decoder.ReadPointer() |
| if err != nil { |
| return err |
| } |
| if pointer0 == 0 { |
| return &bindings.ValidationError{bindings.UnexpectedNullPointer, "unexpected null pointer"} |
| } else { |
| value0, err := decoder.ReadString() |
| if err != nil { |
| return err |
| } |
| s.inQuery = value0 |
| } |
| } |
| if header.ElementsOrVersion >= 0 { |
| handle0, err := decoder.ReadInterface() |
| if err != nil { |
| return err |
| } |
| if handle0.IsValid() { |
| handleOwner := bindings.NewMessagePipeHandleOwner(handle0) |
| s.inHandler = ScanHandler_Pointer{handleOwner} |
| } else { |
| return &bindings.ValidationError{bindings.UnexpectedInvalidHandle, "unexpected invalid handle"} |
| } |
| } |
| if err := decoder.Finish(); err != nil { |
| return err |
| } |
| return nil |
| } |
| |
| type discovery_Scan_ResponseParams struct { |
| outCloser *Closer_Pointer |
| outErr *Error |
| } |
| |
| func (s *discovery_Scan_ResponseParams) Encode(encoder *bindings.Encoder) error { |
| encoder.StartStruct(16, 0) |
| if s.outCloser == nil { |
| encoder.WriteInvalidInterface() |
| } else { |
| if err := encoder.WriteInterface((*s.outCloser).PassMessagePipe()); err != nil { |
| return err |
| } |
| } |
| if s.outErr == nil { |
| encoder.WriteNullPointer() |
| } else { |
| if err := encoder.WritePointer(); err != nil { |
| return err |
| } |
| if err := (*s.outErr).Encode(encoder); err != nil { |
| return err |
| } |
| } |
| if err := encoder.Finish(); err != nil { |
| return err |
| } |
| return nil |
| } |
| |
| var discovery_Scan_ResponseParams_Versions []bindings.DataHeader = []bindings.DataHeader{ |
| bindings.DataHeader{24, 0}, |
| } |
| |
| func (s *discovery_Scan_ResponseParams) Decode(decoder *bindings.Decoder) error { |
| header, err := decoder.StartStruct() |
| if err != nil { |
| return err |
| } |
| index := sort.Search(len(discovery_Scan_ResponseParams_Versions), func(i int) bool { |
| return discovery_Scan_ResponseParams_Versions[i].ElementsOrVersion >= header.ElementsOrVersion |
| }) |
| if index < len(discovery_Scan_ResponseParams_Versions) { |
| if discovery_Scan_ResponseParams_Versions[index].ElementsOrVersion > header.ElementsOrVersion { |
| index-- |
| } |
| expectedSize := discovery_Scan_ResponseParams_Versions[index].Size |
| if expectedSize != header.Size { |
| return &bindings.ValidationError{bindings.UnexpectedStructHeader, |
| fmt.Sprintf("invalid struct header size: should be %d, but was %d", expectedSize, header.Size), |
| } |
| } |
| } |
| if header.ElementsOrVersion >= 0 { |
| handle0, err := decoder.ReadInterface() |
| if err != nil { |
| return err |
| } |
| if handle0.IsValid() { |
| handleOwner := bindings.NewMessagePipeHandleOwner(handle0) |
| s.outCloser = &Closer_Pointer{handleOwner} |
| } else { |
| s.outCloser = nil |
| } |
| } |
| if header.ElementsOrVersion >= 0 { |
| pointer0, err := decoder.ReadPointer() |
| if err != nil { |
| return err |
| } |
| if pointer0 == 0 { |
| s.outErr = nil |
| } else { |
| s.outErr = new(Error) |
| if err := (*s.outErr).Decode(decoder); err != nil { |
| return err |
| } |
| } |
| } |
| if err := decoder.Finish(); err != nil { |
| return err |
| } |
| return nil |
| } |
| |
| func (p *Discovery_Proxy) Scan(inQuery string, inHandler ScanHandler_Pointer) (outCloser *Closer_Pointer, outErr *Error, err error) { |
| payload := &discovery_Scan_Params{ |
| inQuery, |
| inHandler, |
| } |
| header := bindings.MessageHeader{ |
| Type: discovery_Scan_Name, |
| Flags: bindings.MessageExpectsResponseFlag, |
| RequestId: p.ids.Count(), |
| } |
| var message *bindings.Message |
| if message, err = bindings.EncodeMessage(header, payload); err != nil { |
| err = fmt.Errorf("can't encode request: %v", err.Error()) |
| p.Close_Proxy() |
| return |
| } |
| readResult := <-p.router.AcceptWithResponse(message) |
| if err = readResult.Error; err != nil { |
| p.Close_Proxy() |
| return |
| } |
| if readResult.Message.Header.Flags != bindings.MessageIsResponseFlag { |
| err = &bindings.ValidationError{bindings.MessageHeaderInvalidFlags, |
| fmt.Sprintf("invalid message header flag: %v", readResult.Message.Header.Flags), |
| } |
| return |
| } |
| if got, want := readResult.Message.Header.Type, discovery_Scan_Name; got != want { |
| err = &bindings.ValidationError{bindings.MessageHeaderUnknownMethod, |
| fmt.Sprintf("invalid method in response: expected %v, got %v", want, got), |
| } |
| return |
| } |
| var response discovery_Scan_ResponseParams |
| if err = readResult.Message.DecodePayload(&response); err != nil { |
| p.Close_Proxy() |
| return |
| } |
| outCloser = response.outCloser |
| outErr = response.outErr |
| return |
| } |
| |
| type discovery_Stub struct { |
| connector *bindings.Connector |
| impl Discovery |
| } |
| |
| func NewDiscoveryStub(r Discovery_Request, impl Discovery, waiter bindings.AsyncWaiter) *bindings.Stub { |
| connector := bindings.NewConnector(r.PassMessagePipe(), waiter) |
| return bindings.NewStub(connector, &discovery_Stub{connector, impl}) |
| } |
| |
| func (f *Discovery_Request) ServiceDescription() service_describer.ServiceDescription { |
| return &Discovery_ServiceDescription{} |
| } |
| |
| type Discovery_ServiceDescription struct{} |
| |
| func (sd *Discovery_ServiceDescription) GetTopLevelInterface() (outMojomInterface mojom_types.MojomInterface, err error) { |
| err = fmt.Errorf("GetTopLevelInterface not implemented") |
| return |
| } |
| |
| func (sd *Discovery_ServiceDescription) GetTypeDefinition(inTypeKey string) (outType mojom_types.UserDefinedType, err error) { |
| err = fmt.Errorf("GetTypeDefinition not implemented") |
| return |
| } |
| |
| func (sd *Discovery_ServiceDescription) GetAllTypeDefinitions() (outDefinitions *map[string]mojom_types.UserDefinedType, err error) { |
| err = fmt.Errorf("GetAllTypeDefinitions not implemented") |
| return |
| } |
| |
| var _ service_describer.ServiceDescription = (*Discovery_ServiceDescription)(nil) |
| |
| func (s *discovery_Stub) Accept(message *bindings.Message) (err error) { |
| switch message.Header.Type { |
| case discovery_Advertise_Name: |
| if message.Header.Flags != bindings.MessageExpectsResponseFlag { |
| return &bindings.ValidationError{bindings.MessageHeaderInvalidFlags, |
| fmt.Sprintf("invalid message header flag: %v", message.Header.Flags), |
| } |
| } |
| var request discovery_Advertise_Params |
| if err := message.DecodePayload(&request); err != nil { |
| return err |
| } |
| var response discovery_Advertise_ResponseParams |
| response.outInstanceId, response.outCloser, response.outErr, err = s.impl.Advertise(request.inAd, request.inVisibility) |
| if err != nil { |
| return |
| } |
| header := bindings.MessageHeader{ |
| Type: discovery_Advertise_Name, |
| Flags: bindings.MessageIsResponseFlag, |
| RequestId: message.Header.RequestId, |
| } |
| message, err = bindings.EncodeMessage(header, &response) |
| if err != nil { |
| return err |
| } |
| return s.connector.WriteMessage(message) |
| case discovery_Scan_Name: |
| if message.Header.Flags != bindings.MessageExpectsResponseFlag { |
| return &bindings.ValidationError{bindings.MessageHeaderInvalidFlags, |
| fmt.Sprintf("invalid message header flag: %v", message.Header.Flags), |
| } |
| } |
| var request discovery_Scan_Params |
| if err := message.DecodePayload(&request); err != nil { |
| return err |
| } |
| var response discovery_Scan_ResponseParams |
| response.outCloser, response.outErr, err = s.impl.Scan(request.inQuery, request.inHandler) |
| if err != nil { |
| return |
| } |
| header := bindings.MessageHeader{ |
| Type: discovery_Scan_Name, |
| Flags: bindings.MessageIsResponseFlag, |
| RequestId: message.Header.RequestId, |
| } |
| message, err = bindings.EncodeMessage(header, &response) |
| if err != nil { |
| return err |
| } |
| return s.connector.WriteMessage(message) |
| default: |
| return &bindings.ValidationError{ |
| bindings.MessageHeaderUnknownMethod, |
| fmt.Sprintf("unknown method %v", message.Header.Type), |
| } |
| } |
| return |
| } |
| |
| type Closer interface { |
| Close() (err error) |
| } |
| |
| type Closer_Request bindings.InterfaceRequest |
| |
| type Closer_Pointer bindings.InterfacePointer |
| |
| type Closer_ServiceFactory struct { |
| Delegate Closer_Factory |
| } |
| |
| type Closer_Factory interface { |
| Create(request Closer_Request) |
| } |
| |
| // TODO(rudominer) This should only be defined for top-level interfaces. |
| func (f *Closer_ServiceFactory) ServiceDescription() service_describer.ServiceDescription { |
| return &Closer_ServiceDescription{} |
| } |
| |
| func (f *Closer_ServiceFactory) Create(messagePipe system.MessagePipeHandle) { |
| request := Closer_Request{bindings.NewMessagePipeHandleOwner(messagePipe)} |
| f.Delegate.Create(request) |
| } |
| |
| // CreateMessagePipeForCloser creates a message pipe for use with the |
| // Closer interface with a Closer_Request on one end and a Closer_Pointer on the other. |
| func CreateMessagePipeForCloser() (Closer_Request, Closer_Pointer) { |
| r, p := bindings.CreateMessagePipeForMojoInterface() |
| return Closer_Request(r), Closer_Pointer(p) |
| } |
| |
| const closer_Close_Name uint32 = 0 |
| |
| type Closer_Proxy struct { |
| router *bindings.Router |
| ids bindings.Counter |
| } |
| |
| func NewCloserProxy(p Closer_Pointer, waiter bindings.AsyncWaiter) *Closer_Proxy { |
| return &Closer_Proxy{ |
| bindings.NewRouter(p.PassMessagePipe(), waiter), |
| bindings.NewCounter(), |
| } |
| } |
| |
| func (p *Closer_Proxy) Close_Proxy() { |
| p.router.Close() |
| } |
| |
| type closer_Close_Params struct { |
| } |
| |
| func (s *closer_Close_Params) Encode(encoder *bindings.Encoder) error { |
| encoder.StartStruct(0, 0) |
| if err := encoder.Finish(); err != nil { |
| return err |
| } |
| return nil |
| } |
| |
| var closer_Close_Params_Versions []bindings.DataHeader = []bindings.DataHeader{ |
| bindings.DataHeader{8, 0}, |
| } |
| |
| func (s *closer_Close_Params) Decode(decoder *bindings.Decoder) error { |
| header, err := decoder.StartStruct() |
| if err != nil { |
| return err |
| } |
| index := sort.Search(len(closer_Close_Params_Versions), func(i int) bool { |
| return closer_Close_Params_Versions[i].ElementsOrVersion >= header.ElementsOrVersion |
| }) |
| if index < len(closer_Close_Params_Versions) { |
| if closer_Close_Params_Versions[index].ElementsOrVersion > header.ElementsOrVersion { |
| index-- |
| } |
| expectedSize := closer_Close_Params_Versions[index].Size |
| if expectedSize != header.Size { |
| return &bindings.ValidationError{bindings.UnexpectedStructHeader, |
| fmt.Sprintf("invalid struct header size: should be %d, but was %d", expectedSize, header.Size), |
| } |
| } |
| } |
| if err := decoder.Finish(); err != nil { |
| return err |
| } |
| return nil |
| } |
| |
| type closer_Close_ResponseParams struct { |
| } |
| |
| func (s *closer_Close_ResponseParams) Encode(encoder *bindings.Encoder) error { |
| encoder.StartStruct(0, 0) |
| if err := encoder.Finish(); err != nil { |
| return err |
| } |
| return nil |
| } |
| |
| var closer_Close_ResponseParams_Versions []bindings.DataHeader = []bindings.DataHeader{ |
| bindings.DataHeader{8, 0}, |
| } |
| |
| func (s *closer_Close_ResponseParams) Decode(decoder *bindings.Decoder) error { |
| header, err := decoder.StartStruct() |
| if err != nil { |
| return err |
| } |
| index := sort.Search(len(closer_Close_ResponseParams_Versions), func(i int) bool { |
| return closer_Close_ResponseParams_Versions[i].ElementsOrVersion >= header.ElementsOrVersion |
| }) |
| if index < len(closer_Close_ResponseParams_Versions) { |
| if closer_Close_ResponseParams_Versions[index].ElementsOrVersion > header.ElementsOrVersion { |
| index-- |
| } |
| expectedSize := closer_Close_ResponseParams_Versions[index].Size |
| if expectedSize != header.Size { |
| return &bindings.ValidationError{bindings.UnexpectedStructHeader, |
| fmt.Sprintf("invalid struct header size: should be %d, but was %d", expectedSize, header.Size), |
| } |
| } |
| } |
| if err := decoder.Finish(); err != nil { |
| return err |
| } |
| return nil |
| } |
| |
| func (p *Closer_Proxy) Close() (err error) { |
| payload := &closer_Close_Params{} |
| header := bindings.MessageHeader{ |
| Type: closer_Close_Name, |
| Flags: bindings.MessageExpectsResponseFlag, |
| RequestId: p.ids.Count(), |
| } |
| var message *bindings.Message |
| if message, err = bindings.EncodeMessage(header, payload); err != nil { |
| err = fmt.Errorf("can't encode request: %v", err.Error()) |
| p.Close_Proxy() |
| return |
| } |
| readResult := <-p.router.AcceptWithResponse(message) |
| if err = readResult.Error; err != nil { |
| p.Close_Proxy() |
| return |
| } |
| if readResult.Message.Header.Flags != bindings.MessageIsResponseFlag { |
| err = &bindings.ValidationError{bindings.MessageHeaderInvalidFlags, |
| fmt.Sprintf("invalid message header flag: %v", readResult.Message.Header.Flags), |
| } |
| return |
| } |
| if got, want := readResult.Message.Header.Type, closer_Close_Name; got != want { |
| err = &bindings.ValidationError{bindings.MessageHeaderUnknownMethod, |
| fmt.Sprintf("invalid method in response: expected %v, got %v", want, got), |
| } |
| return |
| } |
| var response closer_Close_ResponseParams |
| if err = readResult.Message.DecodePayload(&response); err != nil { |
| p.Close_Proxy() |
| return |
| } |
| return |
| } |
| |
| type closer_Stub struct { |
| connector *bindings.Connector |
| impl Closer |
| } |
| |
| func NewCloserStub(r Closer_Request, impl Closer, waiter bindings.AsyncWaiter) *bindings.Stub { |
| connector := bindings.NewConnector(r.PassMessagePipe(), waiter) |
| return bindings.NewStub(connector, &closer_Stub{connector, impl}) |
| } |
| |
| func (f *Closer_Request) ServiceDescription() service_describer.ServiceDescription { |
| return &Closer_ServiceDescription{} |
| } |
| |
| type Closer_ServiceDescription struct{} |
| |
| func (sd *Closer_ServiceDescription) GetTopLevelInterface() (outMojomInterface mojom_types.MojomInterface, err error) { |
| err = fmt.Errorf("GetTopLevelInterface not implemented") |
| return |
| } |
| |
| func (sd *Closer_ServiceDescription) GetTypeDefinition(inTypeKey string) (outType mojom_types.UserDefinedType, err error) { |
| err = fmt.Errorf("GetTypeDefinition not implemented") |
| return |
| } |
| |
| func (sd *Closer_ServiceDescription) GetAllTypeDefinitions() (outDefinitions *map[string]mojom_types.UserDefinedType, err error) { |
| err = fmt.Errorf("GetAllTypeDefinitions not implemented") |
| return |
| } |
| |
| var _ service_describer.ServiceDescription = (*Closer_ServiceDescription)(nil) |
| |
| func (s *closer_Stub) Accept(message *bindings.Message) (err error) { |
| switch message.Header.Type { |
| case closer_Close_Name: |
| if message.Header.Flags != bindings.MessageExpectsResponseFlag { |
| return &bindings.ValidationError{bindings.MessageHeaderInvalidFlags, |
| fmt.Sprintf("invalid message header flag: %v", message.Header.Flags), |
| } |
| } |
| var request closer_Close_Params |
| if err := message.DecodePayload(&request); err != nil { |
| return err |
| } |
| var response closer_Close_ResponseParams |
| err = s.impl.Close() |
| if err != nil { |
| return |
| } |
| header := bindings.MessageHeader{ |
| Type: closer_Close_Name, |
| Flags: bindings.MessageIsResponseFlag, |
| RequestId: message.Header.RequestId, |
| } |
| message, err = bindings.EncodeMessage(header, &response) |
| if err != nil { |
| return err |
| } |
| return s.connector.WriteMessage(message) |
| default: |
| return &bindings.ValidationError{ |
| bindings.MessageHeaderUnknownMethod, |
| fmt.Sprintf("unknown method %v", message.Header.Type), |
| } |
| } |
| return |
| } |
| |
| type ScanHandler interface { |
| OnUpdate(inUpdate Update_Pointer) (err error) |
| } |
| |
| type ScanHandler_Request bindings.InterfaceRequest |
| |
| type ScanHandler_Pointer bindings.InterfacePointer |
| |
| type ScanHandler_ServiceFactory struct { |
| Delegate ScanHandler_Factory |
| } |
| |
| type ScanHandler_Factory interface { |
| Create(request ScanHandler_Request) |
| } |
| |
| // TODO(rudominer) This should only be defined for top-level interfaces. |
| func (f *ScanHandler_ServiceFactory) ServiceDescription() service_describer.ServiceDescription { |
| return &ScanHandler_ServiceDescription{} |
| } |
| |
| func (f *ScanHandler_ServiceFactory) Create(messagePipe system.MessagePipeHandle) { |
| request := ScanHandler_Request{bindings.NewMessagePipeHandleOwner(messagePipe)} |
| f.Delegate.Create(request) |
| } |
| |
| // CreateMessagePipeForScanHandler creates a message pipe for use with the |
| // ScanHandler interface with a ScanHandler_Request on one end and a ScanHandler_Pointer on the other. |
| func CreateMessagePipeForScanHandler() (ScanHandler_Request, ScanHandler_Pointer) { |
| r, p := bindings.CreateMessagePipeForMojoInterface() |
| return ScanHandler_Request(r), ScanHandler_Pointer(p) |
| } |
| |
| const scanHandler_OnUpdate_Name uint32 = 0 |
| |
| type ScanHandler_Proxy struct { |
| router *bindings.Router |
| ids bindings.Counter |
| } |
| |
| func NewScanHandlerProxy(p ScanHandler_Pointer, waiter bindings.AsyncWaiter) *ScanHandler_Proxy { |
| return &ScanHandler_Proxy{ |
| bindings.NewRouter(p.PassMessagePipe(), waiter), |
| bindings.NewCounter(), |
| } |
| } |
| |
| func (p *ScanHandler_Proxy) Close_Proxy() { |
| p.router.Close() |
| } |
| |
| type scanHandler_OnUpdate_Params struct { |
| inUpdate Update_Pointer |
| } |
| |
| func (s *scanHandler_OnUpdate_Params) Encode(encoder *bindings.Encoder) error { |
| encoder.StartStruct(8, 0) |
| if err := encoder.WriteInterface(s.inUpdate.PassMessagePipe()); err != nil { |
| return err |
| } |
| if err := encoder.Finish(); err != nil { |
| return err |
| } |
| return nil |
| } |
| |
| var scanHandler_OnUpdate_Params_Versions []bindings.DataHeader = []bindings.DataHeader{ |
| bindings.DataHeader{16, 0}, |
| } |
| |
| func (s *scanHandler_OnUpdate_Params) Decode(decoder *bindings.Decoder) error { |
| header, err := decoder.StartStruct() |
| if err != nil { |
| return err |
| } |
| index := sort.Search(len(scanHandler_OnUpdate_Params_Versions), func(i int) bool { |
| return scanHandler_OnUpdate_Params_Versions[i].ElementsOrVersion >= header.ElementsOrVersion |
| }) |
| if index < len(scanHandler_OnUpdate_Params_Versions) { |
| if scanHandler_OnUpdate_Params_Versions[index].ElementsOrVersion > header.ElementsOrVersion { |
| index-- |
| } |
| expectedSize := scanHandler_OnUpdate_Params_Versions[index].Size |
| if expectedSize != header.Size { |
| return &bindings.ValidationError{bindings.UnexpectedStructHeader, |
| fmt.Sprintf("invalid struct header size: should be %d, but was %d", expectedSize, header.Size), |
| } |
| } |
| } |
| if header.ElementsOrVersion >= 0 { |
| handle0, err := decoder.ReadInterface() |
| if err != nil { |
| return err |
| } |
| if handle0.IsValid() { |
| handleOwner := bindings.NewMessagePipeHandleOwner(handle0) |
| s.inUpdate = Update_Pointer{handleOwner} |
| } else { |
| return &bindings.ValidationError{bindings.UnexpectedInvalidHandle, "unexpected invalid handle"} |
| } |
| } |
| if err := decoder.Finish(); err != nil { |
| return err |
| } |
| return nil |
| } |
| |
| func (p *ScanHandler_Proxy) OnUpdate(inUpdate Update_Pointer) (err error) { |
| payload := &scanHandler_OnUpdate_Params{ |
| inUpdate, |
| } |
| header := bindings.MessageHeader{ |
| Type: scanHandler_OnUpdate_Name, |
| Flags: bindings.MessageNoFlag, |
| } |
| var message *bindings.Message |
| if message, err = bindings.EncodeMessage(header, payload); err != nil { |
| err = fmt.Errorf("can't encode request: %v", err.Error()) |
| p.Close_Proxy() |
| return |
| } |
| if err = p.router.Accept(message); err != nil { |
| p.Close_Proxy() |
| return |
| } |
| return |
| } |
| |
| type scanHandler_Stub struct { |
| connector *bindings.Connector |
| impl ScanHandler |
| } |
| |
| func NewScanHandlerStub(r ScanHandler_Request, impl ScanHandler, waiter bindings.AsyncWaiter) *bindings.Stub { |
| connector := bindings.NewConnector(r.PassMessagePipe(), waiter) |
| return bindings.NewStub(connector, &scanHandler_Stub{connector, impl}) |
| } |
| |
| func (f *ScanHandler_Request) ServiceDescription() service_describer.ServiceDescription { |
| return &ScanHandler_ServiceDescription{} |
| } |
| |
| type ScanHandler_ServiceDescription struct{} |
| |
| func (sd *ScanHandler_ServiceDescription) GetTopLevelInterface() (outMojomInterface mojom_types.MojomInterface, err error) { |
| err = fmt.Errorf("GetTopLevelInterface not implemented") |
| return |
| } |
| |
| func (sd *ScanHandler_ServiceDescription) GetTypeDefinition(inTypeKey string) (outType mojom_types.UserDefinedType, err error) { |
| err = fmt.Errorf("GetTypeDefinition not implemented") |
| return |
| } |
| |
| func (sd *ScanHandler_ServiceDescription) GetAllTypeDefinitions() (outDefinitions *map[string]mojom_types.UserDefinedType, err error) { |
| err = fmt.Errorf("GetAllTypeDefinitions not implemented") |
| return |
| } |
| |
| var _ service_describer.ServiceDescription = (*ScanHandler_ServiceDescription)(nil) |
| |
| func (s *scanHandler_Stub) Accept(message *bindings.Message) (err error) { |
| switch message.Header.Type { |
| case scanHandler_OnUpdate_Name: |
| if message.Header.Flags != bindings.MessageNoFlag { |
| return &bindings.ValidationError{bindings.MessageHeaderInvalidFlags, |
| fmt.Sprintf("invalid message header flag: %v", message.Header.Flags), |
| } |
| } |
| var request scanHandler_OnUpdate_Params |
| if err := message.DecodePayload(&request); err != nil { |
| return err |
| } |
| err = s.impl.OnUpdate(request.inUpdate) |
| if err != nil { |
| return |
| } |
| default: |
| return &bindings.ValidationError{ |
| bindings.MessageHeaderUnknownMethod, |
| fmt.Sprintf("unknown method %v", message.Header.Type), |
| } |
| } |
| return |
| } |
| |
| type Update interface { |
| IsLost() (outLost bool, err error) |
| GetId() (outId [16]uint8, err error) |
| GetInterfaceName() (outInterfaceName string, err error) |
| GetAddresses() (outAddresses []string, err error) |
| GetAttribute(inName string) (outAttribute string, err error) |
| GetAttachment(inName string) (outData system.ConsumerHandle, err error) |
| GetAdvertisement() (outAd Advertisement, err error) |
| } |
| |
| type Update_Request bindings.InterfaceRequest |
| |
| type Update_Pointer bindings.InterfacePointer |
| |
| type Update_ServiceFactory struct { |
| Delegate Update_Factory |
| } |
| |
| type Update_Factory interface { |
| Create(request Update_Request) |
| } |
| |
| // TODO(rudominer) This should only be defined for top-level interfaces. |
| func (f *Update_ServiceFactory) ServiceDescription() service_describer.ServiceDescription { |
| return &Update_ServiceDescription{} |
| } |
| |
| func (f *Update_ServiceFactory) Create(messagePipe system.MessagePipeHandle) { |
| request := Update_Request{bindings.NewMessagePipeHandleOwner(messagePipe)} |
| f.Delegate.Create(request) |
| } |
| |
| // CreateMessagePipeForUpdate creates a message pipe for use with the |
| // Update interface with a Update_Request on one end and a Update_Pointer on the other. |
| func CreateMessagePipeForUpdate() (Update_Request, Update_Pointer) { |
| r, p := bindings.CreateMessagePipeForMojoInterface() |
| return Update_Request(r), Update_Pointer(p) |
| } |
| |
| const update_IsLost_Name uint32 = 0 |
| const update_GetId_Name uint32 = 1 |
| const update_GetInterfaceName_Name uint32 = 2 |
| const update_GetAddresses_Name uint32 = 3 |
| const update_GetAttribute_Name uint32 = 4 |
| const update_GetAttachment_Name uint32 = 5 |
| const update_GetAdvertisement_Name uint32 = 6 |
| |
| type Update_Proxy struct { |
| router *bindings.Router |
| ids bindings.Counter |
| } |
| |
| func NewUpdateProxy(p Update_Pointer, waiter bindings.AsyncWaiter) *Update_Proxy { |
| return &Update_Proxy{ |
| bindings.NewRouter(p.PassMessagePipe(), waiter), |
| bindings.NewCounter(), |
| } |
| } |
| |
| func (p *Update_Proxy) Close_Proxy() { |
| p.router.Close() |
| } |
| |
| type update_IsLost_Params struct { |
| } |
| |
| func (s *update_IsLost_Params) Encode(encoder *bindings.Encoder) error { |
| encoder.StartStruct(0, 0) |
| if err := encoder.Finish(); err != nil { |
| return err |
| } |
| return nil |
| } |
| |
| var update_IsLost_Params_Versions []bindings.DataHeader = []bindings.DataHeader{ |
| bindings.DataHeader{8, 0}, |
| } |
| |
| func (s *update_IsLost_Params) Decode(decoder *bindings.Decoder) error { |
| header, err := decoder.StartStruct() |
| if err != nil { |
| return err |
| } |
| index := sort.Search(len(update_IsLost_Params_Versions), func(i int) bool { |
| return update_IsLost_Params_Versions[i].ElementsOrVersion >= header.ElementsOrVersion |
| }) |
| if index < len(update_IsLost_Params_Versions) { |
| if update_IsLost_Params_Versions[index].ElementsOrVersion > header.ElementsOrVersion { |
| index-- |
| } |
| expectedSize := update_IsLost_Params_Versions[index].Size |
| if expectedSize != header.Size { |
| return &bindings.ValidationError{bindings.UnexpectedStructHeader, |
| fmt.Sprintf("invalid struct header size: should be %d, but was %d", expectedSize, header.Size), |
| } |
| } |
| } |
| if err := decoder.Finish(); err != nil { |
| return err |
| } |
| return nil |
| } |
| |
| type update_IsLost_ResponseParams struct { |
| outLost bool |
| } |
| |
| func (s *update_IsLost_ResponseParams) Encode(encoder *bindings.Encoder) error { |
| encoder.StartStruct(8, 0) |
| if err := encoder.WriteBool(s.outLost); err != nil { |
| return err |
| } |
| if err := encoder.Finish(); err != nil { |
| return err |
| } |
| return nil |
| } |
| |
| var update_IsLost_ResponseParams_Versions []bindings.DataHeader = []bindings.DataHeader{ |
| bindings.DataHeader{16, 0}, |
| } |
| |
| func (s *update_IsLost_ResponseParams) Decode(decoder *bindings.Decoder) error { |
| header, err := decoder.StartStruct() |
| if err != nil { |
| return err |
| } |
| index := sort.Search(len(update_IsLost_ResponseParams_Versions), func(i int) bool { |
| return update_IsLost_ResponseParams_Versions[i].ElementsOrVersion >= header.ElementsOrVersion |
| }) |
| if index < len(update_IsLost_ResponseParams_Versions) { |
| if update_IsLost_ResponseParams_Versions[index].ElementsOrVersion > header.ElementsOrVersion { |
| index-- |
| } |
| expectedSize := update_IsLost_ResponseParams_Versions[index].Size |
| if expectedSize != header.Size { |
| return &bindings.ValidationError{bindings.UnexpectedStructHeader, |
| fmt.Sprintf("invalid struct header size: should be %d, but was %d", expectedSize, header.Size), |
| } |
| } |
| } |
| if header.ElementsOrVersion >= 0 { |
| value0, err := decoder.ReadBool() |
| if err != nil { |
| return err |
| } |
| s.outLost = value0 |
| } |
| if err := decoder.Finish(); err != nil { |
| return err |
| } |
| return nil |
| } |
| |
| func (p *Update_Proxy) IsLost() (outLost bool, err error) { |
| payload := &update_IsLost_Params{} |
| header := bindings.MessageHeader{ |
| Type: update_IsLost_Name, |
| Flags: bindings.MessageExpectsResponseFlag, |
| RequestId: p.ids.Count(), |
| } |
| var message *bindings.Message |
| if message, err = bindings.EncodeMessage(header, payload); err != nil { |
| err = fmt.Errorf("can't encode request: %v", err.Error()) |
| p.Close_Proxy() |
| return |
| } |
| readResult := <-p.router.AcceptWithResponse(message) |
| if err = readResult.Error; err != nil { |
| p.Close_Proxy() |
| return |
| } |
| if readResult.Message.Header.Flags != bindings.MessageIsResponseFlag { |
| err = &bindings.ValidationError{bindings.MessageHeaderInvalidFlags, |
| fmt.Sprintf("invalid message header flag: %v", readResult.Message.Header.Flags), |
| } |
| return |
| } |
| if got, want := readResult.Message.Header.Type, update_IsLost_Name; got != want { |
| err = &bindings.ValidationError{bindings.MessageHeaderUnknownMethod, |
| fmt.Sprintf("invalid method in response: expected %v, got %v", want, got), |
| } |
| return |
| } |
| var response update_IsLost_ResponseParams |
| if err = readResult.Message.DecodePayload(&response); err != nil { |
| p.Close_Proxy() |
| return |
| } |
| outLost = response.outLost |
| return |
| } |
| |
| type update_GetId_Params struct { |
| } |
| |
| func (s *update_GetId_Params) Encode(encoder *bindings.Encoder) error { |
| encoder.StartStruct(0, 0) |
| if err := encoder.Finish(); err != nil { |
| return err |
| } |
| return nil |
| } |
| |
| var update_GetId_Params_Versions []bindings.DataHeader = []bindings.DataHeader{ |
| bindings.DataHeader{8, 0}, |
| } |
| |
| func (s *update_GetId_Params) Decode(decoder *bindings.Decoder) error { |
| header, err := decoder.StartStruct() |
| if err != nil { |
| return err |
| } |
| index := sort.Search(len(update_GetId_Params_Versions), func(i int) bool { |
| return update_GetId_Params_Versions[i].ElementsOrVersion >= header.ElementsOrVersion |
| }) |
| if index < len(update_GetId_Params_Versions) { |
| if update_GetId_Params_Versions[index].ElementsOrVersion > header.ElementsOrVersion { |
| index-- |
| } |
| expectedSize := update_GetId_Params_Versions[index].Size |
| if expectedSize != header.Size { |
| return &bindings.ValidationError{bindings.UnexpectedStructHeader, |
| fmt.Sprintf("invalid struct header size: should be %d, but was %d", expectedSize, header.Size), |
| } |
| } |
| } |
| if err := decoder.Finish(); err != nil { |
| return err |
| } |
| return nil |
| } |
| |
| type update_GetId_ResponseParams struct { |
| outId [16]uint8 |
| } |
| |
| func (s *update_GetId_ResponseParams) Encode(encoder *bindings.Encoder) error { |
| encoder.StartStruct(8, 0) |
| if err := encoder.WritePointer(); err != nil { |
| return err |
| } |
| encoder.StartArray(uint32(len(s.outId)), 8) |
| for _, elem0 := range s.outId { |
| if err := encoder.WriteUint8(elem0); err != nil { |
| return err |
| } |
| } |
| if err := encoder.Finish(); err != nil { |
| return err |
| } |
| if err := encoder.Finish(); err != nil { |
| return err |
| } |
| return nil |
| } |
| |
| var update_GetId_ResponseParams_Versions []bindings.DataHeader = []bindings.DataHeader{ |
| bindings.DataHeader{16, 0}, |
| } |
| |
| func (s *update_GetId_ResponseParams) Decode(decoder *bindings.Decoder) error { |
| header, err := decoder.StartStruct() |
| if err != nil { |
| return err |
| } |
| index := sort.Search(len(update_GetId_ResponseParams_Versions), func(i int) bool { |
| return update_GetId_ResponseParams_Versions[i].ElementsOrVersion >= header.ElementsOrVersion |
| }) |
| if index < len(update_GetId_ResponseParams_Versions) { |
| if update_GetId_ResponseParams_Versions[index].ElementsOrVersion > header.ElementsOrVersion { |
| index-- |
| } |
| expectedSize := update_GetId_ResponseParams_Versions[index].Size |
| if expectedSize != header.Size { |
| return &bindings.ValidationError{bindings.UnexpectedStructHeader, |
| fmt.Sprintf("invalid struct header size: should be %d, but was %d", expectedSize, header.Size), |
| } |
| } |
| } |
| if header.ElementsOrVersion >= 0 { |
| pointer0, err := decoder.ReadPointer() |
| if err != nil { |
| return err |
| } |
| if pointer0 == 0 { |
| return &bindings.ValidationError{bindings.UnexpectedNullPointer, "unexpected null pointer"} |
| } else { |
| len0, err := decoder.StartArray(8) |
| if err != nil { |
| return err |
| } |
| if len0 != 16 { |
| return &bindings.ValidationError{bindings.UnexpectedArrayHeader, |
| fmt.Sprintf("invalid array length: expected %d, got %d", 16, len0), |
| } |
| } |
| for i0 := uint32(0); i0 < len0; i0++ { |
| value1, err := decoder.ReadUint8() |
| if err != nil { |
| return err |
| } |
| s.outId[i0] = value1 |
| } |
| if err := decoder.Finish(); err != nil { |
| return err |
| } |
| } |
| } |
| if err := decoder.Finish(); err != nil { |
| return err |
| } |
| return nil |
| } |
| |
| func (p *Update_Proxy) GetId() (outId [16]uint8, err error) { |
| payload := &update_GetId_Params{} |
| header := bindings.MessageHeader{ |
| Type: update_GetId_Name, |
| Flags: bindings.MessageExpectsResponseFlag, |
| RequestId: p.ids.Count(), |
| } |
| var message *bindings.Message |
| if message, err = bindings.EncodeMessage(header, payload); err != nil { |
| err = fmt.Errorf("can't encode request: %v", err.Error()) |
| p.Close_Proxy() |
| return |
| } |
| readResult := <-p.router.AcceptWithResponse(message) |
| if err = readResult.Error; err != nil { |
| p.Close_Proxy() |
| return |
| } |
| if readResult.Message.Header.Flags != bindings.MessageIsResponseFlag { |
| err = &bindings.ValidationError{bindings.MessageHeaderInvalidFlags, |
| fmt.Sprintf("invalid message header flag: %v", readResult.Message.Header.Flags), |
| } |
| return |
| } |
| if got, want := readResult.Message.Header.Type, update_GetId_Name; got != want { |
| err = &bindings.ValidationError{bindings.MessageHeaderUnknownMethod, |
| fmt.Sprintf("invalid method in response: expected %v, got %v", want, got), |
| } |
| return |
| } |
| var response update_GetId_ResponseParams |
| if err = readResult.Message.DecodePayload(&response); err != nil { |
| p.Close_Proxy() |
| return |
| } |
| outId = response.outId |
| return |
| } |
| |
| type update_GetInterfaceName_Params struct { |
| } |
| |
| func (s *update_GetInterfaceName_Params) Encode(encoder *bindings.Encoder) error { |
| encoder.StartStruct(0, 0) |
| if err := encoder.Finish(); err != nil { |
| return err |
| } |
| return nil |
| } |
| |
| var update_GetInterfaceName_Params_Versions []bindings.DataHeader = []bindings.DataHeader{ |
| bindings.DataHeader{8, 0}, |
| } |
| |
| func (s *update_GetInterfaceName_Params) Decode(decoder *bindings.Decoder) error { |
| header, err := decoder.StartStruct() |
| if err != nil { |
| return err |
| } |
| index := sort.Search(len(update_GetInterfaceName_Params_Versions), func(i int) bool { |
| return update_GetInterfaceName_Params_Versions[i].ElementsOrVersion >= header.ElementsOrVersion |
| }) |
| if index < len(update_GetInterfaceName_Params_Versions) { |
| if update_GetInterfaceName_Params_Versions[index].ElementsOrVersion > header.ElementsOrVersion { |
| index-- |
| } |
| expectedSize := update_GetInterfaceName_Params_Versions[index].Size |
| if expectedSize != header.Size { |
| return &bindings.ValidationError{bindings.UnexpectedStructHeader, |
| fmt.Sprintf("invalid struct header size: should be %d, but was %d", expectedSize, header.Size), |
| } |
| } |
| } |
| if err := decoder.Finish(); err != nil { |
| return err |
| } |
| return nil |
| } |
| |
| type update_GetInterfaceName_ResponseParams struct { |
| outInterfaceName string |
| } |
| |
| func (s *update_GetInterfaceName_ResponseParams) Encode(encoder *bindings.Encoder) error { |
| encoder.StartStruct(8, 0) |
| if err := encoder.WritePointer(); err != nil { |
| return err |
| } |
| if err := encoder.WriteString(s.outInterfaceName); err != nil { |
| return err |
| } |
| if err := encoder.Finish(); err != nil { |
| return err |
| } |
| return nil |
| } |
| |
| var update_GetInterfaceName_ResponseParams_Versions []bindings.DataHeader = []bindings.DataHeader{ |
| bindings.DataHeader{16, 0}, |
| } |
| |
| func (s *update_GetInterfaceName_ResponseParams) Decode(decoder *bindings.Decoder) error { |
| header, err := decoder.StartStruct() |
| if err != nil { |
| return err |
| } |
| index := sort.Search(len(update_GetInterfaceName_ResponseParams_Versions), func(i int) bool { |
| return update_GetInterfaceName_ResponseParams_Versions[i].ElementsOrVersion >= header.ElementsOrVersion |
| }) |
| if index < len(update_GetInterfaceName_ResponseParams_Versions) { |
| if update_GetInterfaceName_ResponseParams_Versions[index].ElementsOrVersion > header.ElementsOrVersion { |
| index-- |
| } |
| expectedSize := update_GetInterfaceName_ResponseParams_Versions[index].Size |
| if expectedSize != header.Size { |
| return &bindings.ValidationError{bindings.UnexpectedStructHeader, |
| fmt.Sprintf("invalid struct header size: should be %d, but was %d", expectedSize, header.Size), |
| } |
| } |
| } |
| if header.ElementsOrVersion >= 0 { |
| pointer0, err := decoder.ReadPointer() |
| if err != nil { |
| return err |
| } |
| if pointer0 == 0 { |
| return &bindings.ValidationError{bindings.UnexpectedNullPointer, "unexpected null pointer"} |
| } else { |
| value0, err := decoder.ReadString() |
| if err != nil { |
| return err |
| } |
| s.outInterfaceName = value0 |
| } |
| } |
| if err := decoder.Finish(); err != nil { |
| return err |
| } |
| return nil |
| } |
| |
| func (p *Update_Proxy) GetInterfaceName() (outInterfaceName string, err error) { |
| payload := &update_GetInterfaceName_Params{} |
| header := bindings.MessageHeader{ |
| Type: update_GetInterfaceName_Name, |
| Flags: bindings.MessageExpectsResponseFlag, |
| RequestId: p.ids.Count(), |
| } |
| var message *bindings.Message |
| if message, err = bindings.EncodeMessage(header, payload); err != nil { |
| err = fmt.Errorf("can't encode request: %v", err.Error()) |
| p.Close_Proxy() |
| return |
| } |
| readResult := <-p.router.AcceptWithResponse(message) |
| if err = readResult.Error; err != nil { |
| p.Close_Proxy() |
| return |
| } |
| if readResult.Message.Header.Flags != bindings.MessageIsResponseFlag { |
| err = &bindings.ValidationError{bindings.MessageHeaderInvalidFlags, |
| fmt.Sprintf("invalid message header flag: %v", readResult.Message.Header.Flags), |
| } |
| return |
| } |
| if got, want := readResult.Message.Header.Type, update_GetInterfaceName_Name; got != want { |
| err = &bindings.ValidationError{bindings.MessageHeaderUnknownMethod, |
| fmt.Sprintf("invalid method in response: expected %v, got %v", want, got), |
| } |
| return |
| } |
| var response update_GetInterfaceName_ResponseParams |
| if err = readResult.Message.DecodePayload(&response); err != nil { |
| p.Close_Proxy() |
| return |
| } |
| outInterfaceName = response.outInterfaceName |
| return |
| } |
| |
| type update_GetAddresses_Params struct { |
| } |
| |
| func (s *update_GetAddresses_Params) Encode(encoder *bindings.Encoder) error { |
| encoder.StartStruct(0, 0) |
| if err := encoder.Finish(); err != nil { |
| return err |
| } |
| return nil |
| } |
| |
| var update_GetAddresses_Params_Versions []bindings.DataHeader = []bindings.DataHeader{ |
| bindings.DataHeader{8, 0}, |
| } |
| |
| func (s *update_GetAddresses_Params) Decode(decoder *bindings.Decoder) error { |
| header, err := decoder.StartStruct() |
| if err != nil { |
| return err |
| } |
| index := sort.Search(len(update_GetAddresses_Params_Versions), func(i int) bool { |
| return update_GetAddresses_Params_Versions[i].ElementsOrVersion >= header.ElementsOrVersion |
| }) |
| if index < len(update_GetAddresses_Params_Versions) { |
| if update_GetAddresses_Params_Versions[index].ElementsOrVersion > header.ElementsOrVersion { |
| index-- |
| } |
| expectedSize := update_GetAddresses_Params_Versions[index].Size |
| if expectedSize != header.Size { |
| return &bindings.ValidationError{bindings.UnexpectedStructHeader, |
| fmt.Sprintf("invalid struct header size: should be %d, but was %d", expectedSize, header.Size), |
| } |
| } |
| } |
| if err := decoder.Finish(); err != nil { |
| return err |
| } |
| return nil |
| } |
| |
| type update_GetAddresses_ResponseParams struct { |
| outAddresses []string |
| } |
| |
| func (s *update_GetAddresses_ResponseParams) Encode(encoder *bindings.Encoder) error { |
| encoder.StartStruct(8, 0) |
| if err := encoder.WritePointer(); err != nil { |
| return err |
| } |
| encoder.StartArray(uint32(len(s.outAddresses)), 64) |
| for _, elem0 := range s.outAddresses { |
| if err := encoder.WritePointer(); err != nil { |
| return err |
| } |
| if err := encoder.WriteString(elem0); err != nil { |
| return err |
| } |
| } |
| if err := encoder.Finish(); err != nil { |
| return err |
| } |
| if err := encoder.Finish(); err != nil { |
| return err |
| } |
| return nil |
| } |
| |
| var update_GetAddresses_ResponseParams_Versions []bindings.DataHeader = []bindings.DataHeader{ |
| bindings.DataHeader{16, 0}, |
| } |
| |
| func (s *update_GetAddresses_ResponseParams) Decode(decoder *bindings.Decoder) error { |
| header, err := decoder.StartStruct() |
| if err != nil { |
| return err |
| } |
| index := sort.Search(len(update_GetAddresses_ResponseParams_Versions), func(i int) bool { |
| return update_GetAddresses_ResponseParams_Versions[i].ElementsOrVersion >= header.ElementsOrVersion |
| }) |
| if index < len(update_GetAddresses_ResponseParams_Versions) { |
| if update_GetAddresses_ResponseParams_Versions[index].ElementsOrVersion > header.ElementsOrVersion { |
| index-- |
| } |
| expectedSize := update_GetAddresses_ResponseParams_Versions[index].Size |
| if expectedSize != header.Size { |
| return &bindings.ValidationError{bindings.UnexpectedStructHeader, |
| fmt.Sprintf("invalid struct header size: should be %d, but was %d", expectedSize, header.Size), |
| } |
| } |
| } |
| if header.ElementsOrVersion >= 0 { |
| pointer0, err := decoder.ReadPointer() |
| if err != nil { |
| return err |
| } |
| if pointer0 == 0 { |
| return &bindings.ValidationError{bindings.UnexpectedNullPointer, "unexpected null pointer"} |
| } else { |
| len0, err := decoder.StartArray(64) |
| if err != nil { |
| return err |
| } |
| s.outAddresses = make([]string, len0) |
| for i0 := uint32(0); i0 < len0; i0++ { |
| pointer1, err := decoder.ReadPointer() |
| if err != nil { |
| return err |
| } |
| if pointer1 == 0 { |
| return &bindings.ValidationError{bindings.UnexpectedNullPointer, "unexpected null pointer"} |
| } else { |
| value1, err := decoder.ReadString() |
| if err != nil { |
| return err |
| } |
| s.outAddresses[i0] = value1 |
| } |
| } |
| if err := decoder.Finish(); err != nil { |
| return err |
| } |
| } |
| } |
| if err := decoder.Finish(); err != nil { |
| return err |
| } |
| return nil |
| } |
| |
| func (p *Update_Proxy) GetAddresses() (outAddresses []string, err error) { |
| payload := &update_GetAddresses_Params{} |
| header := bindings.MessageHeader{ |
| Type: update_GetAddresses_Name, |
| Flags: bindings.MessageExpectsResponseFlag, |
| RequestId: p.ids.Count(), |
| } |
| var message *bindings.Message |
| if message, err = bindings.EncodeMessage(header, payload); err != nil { |
| err = fmt.Errorf("can't encode request: %v", err.Error()) |
| p.Close_Proxy() |
| return |
| } |
| readResult := <-p.router.AcceptWithResponse(message) |
| if err = readResult.Error; err != nil { |
| p.Close_Proxy() |
| return |
| } |
| if readResult.Message.Header.Flags != bindings.MessageIsResponseFlag { |
| err = &bindings.ValidationError{bindings.MessageHeaderInvalidFlags, |
| fmt.Sprintf("invalid message header flag: %v", readResult.Message.Header.Flags), |
| } |
| return |
| } |
| if got, want := readResult.Message.Header.Type, update_GetAddresses_Name; got != want { |
| err = &bindings.ValidationError{bindings.MessageHeaderUnknownMethod, |
| fmt.Sprintf("invalid method in response: expected %v, got %v", want, got), |
| } |
| return |
| } |
| var response update_GetAddresses_ResponseParams |
| if err = readResult.Message.DecodePayload(&response); err != nil { |
| p.Close_Proxy() |
| return |
| } |
| outAddresses = response.outAddresses |
| return |
| } |
| |
| type update_GetAttribute_Params struct { |
| inName string |
| } |
| |
| func (s *update_GetAttribute_Params) Encode(encoder *bindings.Encoder) error { |
| encoder.StartStruct(8, 0) |
| if err := encoder.WritePointer(); err != nil { |
| return err |
| } |
| if err := encoder.WriteString(s.inName); err != nil { |
| return err |
| } |
| if err := encoder.Finish(); err != nil { |
| return err |
| } |
| return nil |
| } |
| |
| var update_GetAttribute_Params_Versions []bindings.DataHeader = []bindings.DataHeader{ |
| bindings.DataHeader{16, 0}, |
| } |
| |
| func (s *update_GetAttribute_Params) Decode(decoder *bindings.Decoder) error { |
| header, err := decoder.StartStruct() |
| if err != nil { |
| return err |
| } |
| index := sort.Search(len(update_GetAttribute_Params_Versions), func(i int) bool { |
| return update_GetAttribute_Params_Versions[i].ElementsOrVersion >= header.ElementsOrVersion |
| }) |
| if index < len(update_GetAttribute_Params_Versions) { |
| if update_GetAttribute_Params_Versions[index].ElementsOrVersion > header.ElementsOrVersion { |
| index-- |
| } |
| expectedSize := update_GetAttribute_Params_Versions[index].Size |
| if expectedSize != header.Size { |
| return &bindings.ValidationError{bindings.UnexpectedStructHeader, |
| fmt.Sprintf("invalid struct header size: should be %d, but was %d", expectedSize, header.Size), |
| } |
| } |
| } |
| if header.ElementsOrVersion >= 0 { |
| pointer0, err := decoder.ReadPointer() |
| if err != nil { |
| return err |
| } |
| if pointer0 == 0 { |
| return &bindings.ValidationError{bindings.UnexpectedNullPointer, "unexpected null pointer"} |
| } else { |
| value0, err := decoder.ReadString() |
| if err != nil { |
| return err |
| } |
| s.inName = value0 |
| } |
| } |
| if err := decoder.Finish(); err != nil { |
| return err |
| } |
| return nil |
| } |
| |
| type update_GetAttribute_ResponseParams struct { |
| outAttribute string |
| } |
| |
| func (s *update_GetAttribute_ResponseParams) Encode(encoder *bindings.Encoder) error { |
| encoder.StartStruct(8, 0) |
| if err := encoder.WritePointer(); err != nil { |
| return err |
| } |
| if err := encoder.WriteString(s.outAttribute); err != nil { |
| return err |
| } |
| if err := encoder.Finish(); err != nil { |
| return err |
| } |
| return nil |
| } |
| |
| var update_GetAttribute_ResponseParams_Versions []bindings.DataHeader = []bindings.DataHeader{ |
| bindings.DataHeader{16, 0}, |
| } |
| |
| func (s *update_GetAttribute_ResponseParams) Decode(decoder *bindings.Decoder) error { |
| header, err := decoder.StartStruct() |
| if err != nil { |
| return err |
| } |
| index := sort.Search(len(update_GetAttribute_ResponseParams_Versions), func(i int) bool { |
| return update_GetAttribute_ResponseParams_Versions[i].ElementsOrVersion >= header.ElementsOrVersion |
| }) |
| if index < len(update_GetAttribute_ResponseParams_Versions) { |
| if update_GetAttribute_ResponseParams_Versions[index].ElementsOrVersion > header.ElementsOrVersion { |
| index-- |
| } |
| expectedSize := update_GetAttribute_ResponseParams_Versions[index].Size |
| if expectedSize != header.Size { |
| return &bindings.ValidationError{bindings.UnexpectedStructHeader, |
| fmt.Sprintf("invalid struct header size: should be %d, but was %d", expectedSize, header.Size), |
| } |
| } |
| } |
| if header.ElementsOrVersion >= 0 { |
| pointer0, err := decoder.ReadPointer() |
| if err != nil { |
| return err |
| } |
| if pointer0 == 0 { |
| return &bindings.ValidationError{bindings.UnexpectedNullPointer, "unexpected null pointer"} |
| } else { |
| value0, err := decoder.ReadString() |
| if err != nil { |
| return err |
| } |
| s.outAttribute = value0 |
| } |
| } |
| if err := decoder.Finish(); err != nil { |
| return err |
| } |
| return nil |
| } |
| |
| func (p *Update_Proxy) GetAttribute(inName string) (outAttribute string, err error) { |
| payload := &update_GetAttribute_Params{ |
| inName, |
| } |
| header := bindings.MessageHeader{ |
| Type: update_GetAttribute_Name, |
| Flags: bindings.MessageExpectsResponseFlag, |
| RequestId: p.ids.Count(), |
| } |
| var message *bindings.Message |
| if message, err = bindings.EncodeMessage(header, payload); err != nil { |
| err = fmt.Errorf("can't encode request: %v", err.Error()) |
| p.Close_Proxy() |
| return |
| } |
| readResult := <-p.router.AcceptWithResponse(message) |
| if err = readResult.Error; err != nil { |
| p.Close_Proxy() |
| return |
| } |
| if readResult.Message.Header.Flags != bindings.MessageIsResponseFlag { |
| err = &bindings.ValidationError{bindings.MessageHeaderInvalidFlags, |
| fmt.Sprintf("invalid message header flag: %v", readResult.Message.Header.Flags), |
| } |
| return |
| } |
| if got, want := readResult.Message.Header.Type, update_GetAttribute_Name; got != want { |
| err = &bindings.ValidationError{bindings.MessageHeaderUnknownMethod, |
| fmt.Sprintf("invalid method in response: expected %v, got %v", want, got), |
| } |
| return |
| } |
| var response update_GetAttribute_ResponseParams |
| if err = readResult.Message.DecodePayload(&response); err != nil { |
| p.Close_Proxy() |
| return |
| } |
| outAttribute = response.outAttribute |
| return |
| } |
| |
| type update_GetAttachment_Params struct { |
| inName string |
| } |
| |
| func (s *update_GetAttachment_Params) Encode(encoder *bindings.Encoder) error { |
| encoder.StartStruct(8, 0) |
| if err := encoder.WritePointer(); err != nil { |
| return err |
| } |
| if err := encoder.WriteString(s.inName); err != nil { |
| return err |
| } |
| if err := encoder.Finish(); err != nil { |
| return err |
| } |
| return nil |
| } |
| |
| var update_GetAttachment_Params_Versions []bindings.DataHeader = []bindings.DataHeader{ |
| bindings.DataHeader{16, 0}, |
| } |
| |
| func (s *update_GetAttachment_Params) Decode(decoder *bindings.Decoder) error { |
| header, err := decoder.StartStruct() |
| if err != nil { |
| return err |
| } |
| index := sort.Search(len(update_GetAttachment_Params_Versions), func(i int) bool { |
| return update_GetAttachment_Params_Versions[i].ElementsOrVersion >= header.ElementsOrVersion |
| }) |
| if index < len(update_GetAttachment_Params_Versions) { |
| if update_GetAttachment_Params_Versions[index].ElementsOrVersion > header.ElementsOrVersion { |
| index-- |
| } |
| expectedSize := update_GetAttachment_Params_Versions[index].Size |
| if expectedSize != header.Size { |
| return &bindings.ValidationError{bindings.UnexpectedStructHeader, |
| fmt.Sprintf("invalid struct header size: should be %d, but was %d", expectedSize, header.Size), |
| } |
| } |
| } |
| if header.ElementsOrVersion >= 0 { |
| pointer0, err := decoder.ReadPointer() |
| if err != nil { |
| return err |
| } |
| if pointer0 == 0 { |
| return &bindings.ValidationError{bindings.UnexpectedNullPointer, "unexpected null pointer"} |
| } else { |
| value0, err := decoder.ReadString() |
| if err != nil { |
| return err |
| } |
| s.inName = value0 |
| } |
| } |
| if err := decoder.Finish(); err != nil { |
| return err |
| } |
| return nil |
| } |
| |
| type update_GetAttachment_ResponseParams struct { |
| outData system.ConsumerHandle |
| } |
| |
| func (s *update_GetAttachment_ResponseParams) Encode(encoder *bindings.Encoder) error { |
| encoder.StartStruct(8, 0) |
| if err := encoder.WriteHandle(s.outData); err != nil { |
| return err |
| } |
| if err := encoder.Finish(); err != nil { |
| return err |
| } |
| return nil |
| } |
| |
| var update_GetAttachment_ResponseParams_Versions []bindings.DataHeader = []bindings.DataHeader{ |
| bindings.DataHeader{16, 0}, |
| } |
| |
| func (s *update_GetAttachment_ResponseParams) Decode(decoder *bindings.Decoder) error { |
| header, err := decoder.StartStruct() |
| if err != nil { |
| return err |
| } |
| index := sort.Search(len(update_GetAttachment_ResponseParams_Versions), func(i int) bool { |
| return update_GetAttachment_ResponseParams_Versions[i].ElementsOrVersion >= header.ElementsOrVersion |
| }) |
| if index < len(update_GetAttachment_ResponseParams_Versions) { |
| if update_GetAttachment_ResponseParams_Versions[index].ElementsOrVersion > header.ElementsOrVersion { |
| index-- |
| } |
| expectedSize := update_GetAttachment_ResponseParams_Versions[index].Size |
| if expectedSize != header.Size { |
| return &bindings.ValidationError{bindings.UnexpectedStructHeader, |
| fmt.Sprintf("invalid struct header size: should be %d, but was %d", expectedSize, header.Size), |
| } |
| } |
| } |
| if header.ElementsOrVersion >= 0 { |
| handle0, err := decoder.ReadConsumerHandle() |
| if err != nil { |
| return err |
| } |
| if handle0.IsValid() { |
| s.outData = handle0 |
| } else { |
| return &bindings.ValidationError{bindings.UnexpectedInvalidHandle, "unexpected invalid handle"} |
| } |
| } |
| if err := decoder.Finish(); err != nil { |
| return err |
| } |
| return nil |
| } |
| |
| func (p *Update_Proxy) GetAttachment(inName string) (outData system.ConsumerHandle, err error) { |
| payload := &update_GetAttachment_Params{ |
| inName, |
| } |
| header := bindings.MessageHeader{ |
| Type: update_GetAttachment_Name, |
| Flags: bindings.MessageExpectsResponseFlag, |
| RequestId: p.ids.Count(), |
| } |
| var message *bindings.Message |
| if message, err = bindings.EncodeMessage(header, payload); err != nil { |
| err = fmt.Errorf("can't encode request: %v", err.Error()) |
| p.Close_Proxy() |
| return |
| } |
| readResult := <-p.router.AcceptWithResponse(message) |
| if err = readResult.Error; err != nil { |
| p.Close_Proxy() |
| return |
| } |
| if readResult.Message.Header.Flags != bindings.MessageIsResponseFlag { |
| err = &bindings.ValidationError{bindings.MessageHeaderInvalidFlags, |
| fmt.Sprintf("invalid message header flag: %v", readResult.Message.Header.Flags), |
| } |
| return |
| } |
| if got, want := readResult.Message.Header.Type, update_GetAttachment_Name; got != want { |
| err = &bindings.ValidationError{bindings.MessageHeaderUnknownMethod, |
| fmt.Sprintf("invalid method in response: expected %v, got %v", want, got), |
| } |
| return |
| } |
| var response update_GetAttachment_ResponseParams |
| if err = readResult.Message.DecodePayload(&response); err != nil { |
| p.Close_Proxy() |
| return |
| } |
| outData = response.outData |
| return |
| } |
| |
| type update_GetAdvertisement_Params struct { |
| } |
| |
| func (s *update_GetAdvertisement_Params) Encode(encoder *bindings.Encoder) error { |
| encoder.StartStruct(0, 0) |
| if err := encoder.Finish(); err != nil { |
| return err |
| } |
| return nil |
| } |
| |
| var update_GetAdvertisement_Params_Versions []bindings.DataHeader = []bindings.DataHeader{ |
| bindings.DataHeader{8, 0}, |
| } |
| |
| func (s *update_GetAdvertisement_Params) Decode(decoder *bindings.Decoder) error { |
| header, err := decoder.StartStruct() |
| if err != nil { |
| return err |
| } |
| index := sort.Search(len(update_GetAdvertisement_Params_Versions), func(i int) bool { |
| return update_GetAdvertisement_Params_Versions[i].ElementsOrVersion >= header.ElementsOrVersion |
| }) |
| if index < len(update_GetAdvertisement_Params_Versions) { |
| if update_GetAdvertisement_Params_Versions[index].ElementsOrVersion > header.ElementsOrVersion { |
| index-- |
| } |
| expectedSize := update_GetAdvertisement_Params_Versions[index].Size |
| if expectedSize != header.Size { |
| return &bindings.ValidationError{bindings.UnexpectedStructHeader, |
| fmt.Sprintf("invalid struct header size: should be %d, but was %d", expectedSize, header.Size), |
| } |
| } |
| } |
| if err := decoder.Finish(); err != nil { |
| return err |
| } |
| return nil |
| } |
| |
| type update_GetAdvertisement_ResponseParams struct { |
| outAd Advertisement |
| } |
| |
| func (s *update_GetAdvertisement_ResponseParams) Encode(encoder *bindings.Encoder) error { |
| encoder.StartStruct(8, 0) |
| if err := encoder.WritePointer(); err != nil { |
| return err |
| } |
| if err := s.outAd.Encode(encoder); err != nil { |
| return err |
| } |
| if err := encoder.Finish(); err != nil { |
| return err |
| } |
| return nil |
| } |
| |
| var update_GetAdvertisement_ResponseParams_Versions []bindings.DataHeader = []bindings.DataHeader{ |
| bindings.DataHeader{16, 0}, |
| } |
| |
| func (s *update_GetAdvertisement_ResponseParams) Decode(decoder *bindings.Decoder) error { |
| header, err := decoder.StartStruct() |
| if err != nil { |
| return err |
| } |
| index := sort.Search(len(update_GetAdvertisement_ResponseParams_Versions), func(i int) bool { |
| return update_GetAdvertisement_ResponseParams_Versions[i].ElementsOrVersion >= header.ElementsOrVersion |
| }) |
| if index < len(update_GetAdvertisement_ResponseParams_Versions) { |
| if update_GetAdvertisement_ResponseParams_Versions[index].ElementsOrVersion > header.ElementsOrVersion { |
| index-- |
| } |
| expectedSize := update_GetAdvertisement_ResponseParams_Versions[index].Size |
| if expectedSize != header.Size { |
| return &bindings.ValidationError{bindings.UnexpectedStructHeader, |
| fmt.Sprintf("invalid struct header size: should be %d, but was %d", expectedSize, header.Size), |
| } |
| } |
| } |
| if header.ElementsOrVersion >= 0 { |
| pointer0, err := decoder.ReadPointer() |
| if err != nil { |
| return err |
| } |
| if pointer0 == 0 { |
| return &bindings.ValidationError{bindings.UnexpectedNullPointer, "unexpected null pointer"} |
| } else { |
| if err := s.outAd.Decode(decoder); err != nil { |
| return err |
| } |
| } |
| } |
| if err := decoder.Finish(); err != nil { |
| return err |
| } |
| return nil |
| } |
| |
| func (p *Update_Proxy) GetAdvertisement() (outAd Advertisement, err error) { |
| payload := &update_GetAdvertisement_Params{} |
| header := bindings.MessageHeader{ |
| Type: update_GetAdvertisement_Name, |
| Flags: bindings.MessageExpectsResponseFlag, |
| RequestId: p.ids.Count(), |
| } |
| var message *bindings.Message |
| if message, err = bindings.EncodeMessage(header, payload); err != nil { |
| err = fmt.Errorf("can't encode request: %v", err.Error()) |
| p.Close_Proxy() |
| return |
| } |
| readResult := <-p.router.AcceptWithResponse(message) |
| if err = readResult.Error; err != nil { |
| p.Close_Proxy() |
| return |
| } |
| if readResult.Message.Header.Flags != bindings.MessageIsResponseFlag { |
| err = &bindings.ValidationError{bindings.MessageHeaderInvalidFlags, |
| fmt.Sprintf("invalid message header flag: %v", readResult.Message.Header.Flags), |
| } |
| return |
| } |
| if got, want := readResult.Message.Header.Type, update_GetAdvertisement_Name; got != want { |
| err = &bindings.ValidationError{bindings.MessageHeaderUnknownMethod, |
| fmt.Sprintf("invalid method in response: expected %v, got %v", want, got), |
| } |
| return |
| } |
| var response update_GetAdvertisement_ResponseParams |
| if err = readResult.Message.DecodePayload(&response); err != nil { |
| p.Close_Proxy() |
| return |
| } |
| outAd = response.outAd |
| return |
| } |
| |
| type update_Stub struct { |
| connector *bindings.Connector |
| impl Update |
| } |
| |
| func NewUpdateStub(r Update_Request, impl Update, waiter bindings.AsyncWaiter) *bindings.Stub { |
| connector := bindings.NewConnector(r.PassMessagePipe(), waiter) |
| return bindings.NewStub(connector, &update_Stub{connector, impl}) |
| } |
| |
| func (f *Update_Request) ServiceDescription() service_describer.ServiceDescription { |
| return &Update_ServiceDescription{} |
| } |
| |
| type Update_ServiceDescription struct{} |
| |
| func (sd *Update_ServiceDescription) GetTopLevelInterface() (outMojomInterface mojom_types.MojomInterface, err error) { |
| err = fmt.Errorf("GetTopLevelInterface not implemented") |
| return |
| } |
| |
| func (sd *Update_ServiceDescription) GetTypeDefinition(inTypeKey string) (outType mojom_types.UserDefinedType, err error) { |
| err = fmt.Errorf("GetTypeDefinition not implemented") |
| return |
| } |
| |
| func (sd *Update_ServiceDescription) GetAllTypeDefinitions() (outDefinitions *map[string]mojom_types.UserDefinedType, err error) { |
| err = fmt.Errorf("GetAllTypeDefinitions not implemented") |
| return |
| } |
| |
| var _ service_describer.ServiceDescription = (*Update_ServiceDescription)(nil) |
| |
| func (s *update_Stub) Accept(message *bindings.Message) (err error) { |
| switch message.Header.Type { |
| case update_IsLost_Name: |
| if message.Header.Flags != bindings.MessageExpectsResponseFlag { |
| return &bindings.ValidationError{bindings.MessageHeaderInvalidFlags, |
| fmt.Sprintf("invalid message header flag: %v", message.Header.Flags), |
| } |
| } |
| var request update_IsLost_Params |
| if err := message.DecodePayload(&request); err != nil { |
| return err |
| } |
| var response update_IsLost_ResponseParams |
| response.outLost, err = s.impl.IsLost() |
| if err != nil { |
| return |
| } |
| header := bindings.MessageHeader{ |
| Type: update_IsLost_Name, |
| Flags: bindings.MessageIsResponseFlag, |
| RequestId: message.Header.RequestId, |
| } |
| message, err = bindings.EncodeMessage(header, &response) |
| if err != nil { |
| return err |
| } |
| return s.connector.WriteMessage(message) |
| case update_GetId_Name: |
| if message.Header.Flags != bindings.MessageExpectsResponseFlag { |
| return &bindings.ValidationError{bindings.MessageHeaderInvalidFlags, |
| fmt.Sprintf("invalid message header flag: %v", message.Header.Flags), |
| } |
| } |
| var request update_GetId_Params |
| if err := message.DecodePayload(&request); err != nil { |
| return err |
| } |
| var response update_GetId_ResponseParams |
| response.outId, err = s.impl.GetId() |
| if err != nil { |
| return |
| } |
| header := bindings.MessageHeader{ |
| Type: update_GetId_Name, |
| Flags: bindings.MessageIsResponseFlag, |
| RequestId: message.Header.RequestId, |
| } |
| message, err = bindings.EncodeMessage(header, &response) |
| if err != nil { |
| return err |
| } |
| return s.connector.WriteMessage(message) |
| case update_GetInterfaceName_Name: |
| if message.Header.Flags != bindings.MessageExpectsResponseFlag { |
| return &bindings.ValidationError{bindings.MessageHeaderInvalidFlags, |
| fmt.Sprintf("invalid message header flag: %v", message.Header.Flags), |
| } |
| } |
| var request update_GetInterfaceName_Params |
| if err := message.DecodePayload(&request); err != nil { |
| return err |
| } |
| var response update_GetInterfaceName_ResponseParams |
| response.outInterfaceName, err = s.impl.GetInterfaceName() |
| if err != nil { |
| return |
| } |
| header := bindings.MessageHeader{ |
| Type: update_GetInterfaceName_Name, |
| Flags: bindings.MessageIsResponseFlag, |
| RequestId: message.Header.RequestId, |
| } |
| message, err = bindings.EncodeMessage(header, &response) |
| if err != nil { |
| return err |
| } |
| return s.connector.WriteMessage(message) |
| case update_GetAddresses_Name: |
| if message.Header.Flags != bindings.MessageExpectsResponseFlag { |
| return &bindings.ValidationError{bindings.MessageHeaderInvalidFlags, |
| fmt.Sprintf("invalid message header flag: %v", message.Header.Flags), |
| } |
| } |
| var request update_GetAddresses_Params |
| if err := message.DecodePayload(&request); err != nil { |
| return err |
| } |
| var response update_GetAddresses_ResponseParams |
| response.outAddresses, err = s.impl.GetAddresses() |
| if err != nil { |
| return |
| } |
| header := bindings.MessageHeader{ |
| Type: update_GetAddresses_Name, |
| Flags: bindings.MessageIsResponseFlag, |
| RequestId: message.Header.RequestId, |
| } |
| message, err = bindings.EncodeMessage(header, &response) |
| if err != nil { |
| return err |
| } |
| return s.connector.WriteMessage(message) |
| case update_GetAttribute_Name: |
| if message.Header.Flags != bindings.MessageExpectsResponseFlag { |
| return &bindings.ValidationError{bindings.MessageHeaderInvalidFlags, |
| fmt.Sprintf("invalid message header flag: %v", message.Header.Flags), |
| } |
| } |
| var request update_GetAttribute_Params |
| if err := message.DecodePayload(&request); err != nil { |
| return err |
| } |
| var response update_GetAttribute_ResponseParams |
| response.outAttribute, err = s.impl.GetAttribute(request.inName) |
| if err != nil { |
| return |
| } |
| header := bindings.MessageHeader{ |
| Type: update_GetAttribute_Name, |
| Flags: bindings.MessageIsResponseFlag, |
| RequestId: message.Header.RequestId, |
| } |
| message, err = bindings.EncodeMessage(header, &response) |
| if err != nil { |
| return err |
| } |
| return s.connector.WriteMessage(message) |
| case update_GetAttachment_Name: |
| if message.Header.Flags != bindings.MessageExpectsResponseFlag { |
| return &bindings.ValidationError{bindings.MessageHeaderInvalidFlags, |
| fmt.Sprintf("invalid message header flag: %v", message.Header.Flags), |
| } |
| } |
| var request update_GetAttachment_Params |
| if err := message.DecodePayload(&request); err != nil { |
| return err |
| } |
| var response update_GetAttachment_ResponseParams |
| response.outData, err = s.impl.GetAttachment(request.inName) |
| if err != nil { |
| return |
| } |
| header := bindings.MessageHeader{ |
| Type: update_GetAttachment_Name, |
| Flags: bindings.MessageIsResponseFlag, |
| RequestId: message.Header.RequestId, |
| } |
| message, err = bindings.EncodeMessage(header, &response) |
| if err != nil { |
| return err |
| } |
| return s.connector.WriteMessage(message) |
| case update_GetAdvertisement_Name: |
| if message.Header.Flags != bindings.MessageExpectsResponseFlag { |
| return &bindings.ValidationError{bindings.MessageHeaderInvalidFlags, |
| fmt.Sprintf("invalid message header flag: %v", message.Header.Flags), |
| } |
| } |
| var request update_GetAdvertisement_Params |
| if err := message.DecodePayload(&request); err != nil { |
| return err |
| } |
| var response update_GetAdvertisement_ResponseParams |
| response.outAd, err = s.impl.GetAdvertisement() |
| if err != nil { |
| return |
| } |
| header := bindings.MessageHeader{ |
| Type: update_GetAdvertisement_Name, |
| Flags: bindings.MessageIsResponseFlag, |
| RequestId: message.Header.RequestId, |
| } |
| message, err = bindings.EncodeMessage(header, &response) |
| if err != nil { |
| return err |
| } |
| return s.connector.WriteMessage(message) |
| default: |
| return &bindings.ValidationError{ |
| bindings.MessageHeaderUnknownMethod, |
| fmt.Sprintf("unknown method %v", message.Header.Type), |
| } |
| } |
| return |
| } |
| |
| type Advertisement struct { |
| Id *[16]uint8 |
| InterfaceName string |
| Addresses []string |
| Attributes *map[string]string |
| Attachments *map[string][]uint8 |
| } |
| |
| func (s *Advertisement) Encode(encoder *bindings.Encoder) error { |
| encoder.StartStruct(40, 0) |
| if s.Id == nil { |
| encoder.WriteNullPointer() |
| } else { |
| if err := encoder.WritePointer(); err != nil { |
| return err |
| } |
| encoder.StartArray(uint32(len((*s.Id))), 8) |
| for _, elem0 := range *s.Id { |
| if err := encoder.WriteUint8(elem0); err != nil { |
| return err |
| } |
| } |
| if err := encoder.Finish(); err != nil { |
| return err |
| } |
| } |
| if err := encoder.WritePointer(); err != nil { |
| return err |
| } |
| if err := encoder.WriteString(s.InterfaceName); err != nil { |
| return err |
| } |
| if err := encoder.WritePointer(); err != nil { |
| return err |
| } |
| encoder.StartArray(uint32(len(s.Addresses)), 64) |
| for _, elem0 := range s.Addresses { |
| if err := encoder.WritePointer(); err != nil { |
| return err |
| } |
| if err := encoder.WriteString(elem0); err != nil { |
| return err |
| } |
| } |
| if err := encoder.Finish(); err != nil { |
| return err |
| } |
| if s.Attributes == nil { |
| encoder.WriteNullPointer() |
| } else { |
| if err := encoder.WritePointer(); err != nil { |
| return err |
| } |
| encoder.StartMap() |
| { |
| var keys0 []string |
| var values0 []string |
| for key0, value0 := range *s.Attributes { |
| keys0 = append(keys0, key0) |
| values0 = append(values0, value0) |
| } |
| if err := encoder.WritePointer(); err != nil { |
| return err |
| } |
| encoder.StartArray(uint32(len(keys0)), 64) |
| for _, elem1 := range keys0 { |
| if err := encoder.WritePointer(); err != nil { |
| return err |
| } |
| if err := encoder.WriteString(elem1); err != nil { |
| return err |
| } |
| } |
| if err := encoder.Finish(); err != nil { |
| return err |
| } |
| if err := encoder.WritePointer(); err != nil { |
| return err |
| } |
| encoder.StartArray(uint32(len(values0)), 64) |
| for _, elem1 := range values0 { |
| if err := encoder.WritePointer(); err != nil { |
| return err |
| } |
| if err := encoder.WriteString(elem1); err != nil { |
| return err |
| } |
| } |
| if err := encoder.Finish(); err != nil { |
| return err |
| } |
| } |
| if err := encoder.Finish(); err != nil { |
| return err |
| } |
| } |
| if s.Attachments == nil { |
| encoder.WriteNullPointer() |
| } else { |
| if err := encoder.WritePointer(); err != nil { |
| return err |
| } |
| encoder.StartMap() |
| { |
| var keys0 []string |
| var values0 [][]uint8 |
| for key0, value0 := range *s.Attachments { |
| keys0 = append(keys0, key0) |
| values0 = append(values0, value0) |
| } |
| if err := encoder.WritePointer(); err != nil { |
| return err |
| } |
| encoder.StartArray(uint32(len(keys0)), 64) |
| for _, elem1 := range keys0 { |
| if err := encoder.WritePointer(); err != nil { |
| return err |
| } |
| if err := encoder.WriteString(elem1); err != nil { |
| return err |
| } |
| } |
| if err := encoder.Finish(); err != nil { |
| return err |
| } |
| if err := encoder.WritePointer(); err != nil { |
| return err |
| } |
| encoder.StartArray(uint32(len(values0)), 64) |
| for _, elem1 := range values0 { |
| if err := encoder.WritePointer(); err != nil { |
| return err |
| } |
| encoder.StartArray(uint32(len(elem1)), 8) |
| for _, elem2 := range elem1 { |
| if err := encoder.WriteUint8(elem2); err != nil { |
| return err |
| } |
| } |
| if err := encoder.Finish(); err != nil { |
| return err |
| } |
| } |
| if err := encoder.Finish(); err != nil { |
| return err |
| } |
| } |
| if err := encoder.Finish(); err != nil { |
| return err |
| } |
| } |
| if err := encoder.Finish(); err != nil { |
| return err |
| } |
| return nil |
| } |
| |
| var advertisement_Versions []bindings.DataHeader = []bindings.DataHeader{ |
| bindings.DataHeader{48, 0}, |
| } |
| |
| func (s *Advertisement) Decode(decoder *bindings.Decoder) error { |
| header, err := decoder.StartStruct() |
| if err != nil { |
| return err |
| } |
| index := sort.Search(len(advertisement_Versions), func(i int) bool { |
| return advertisement_Versions[i].ElementsOrVersion >= header.ElementsOrVersion |
| }) |
| if index < len(advertisement_Versions) { |
| if advertisement_Versions[index].ElementsOrVersion > header.ElementsOrVersion { |
| index-- |
| } |
| expectedSize := advertisement_Versions[index].Size |
| if expectedSize != header.Size { |
| return &bindings.ValidationError{bindings.UnexpectedStructHeader, |
| fmt.Sprintf("invalid struct header size: should be %d, but was %d", expectedSize, header.Size), |
| } |
| } |
| } |
| if header.ElementsOrVersion >= 0 { |
| pointer0, err := decoder.ReadPointer() |
| if err != nil { |
| return err |
| } |
| if pointer0 == 0 { |
| s.Id = nil |
| } else { |
| s.Id = new([16]uint8) |
| len0, err := decoder.StartArray(8) |
| if err != nil { |
| return err |
| } |
| if len0 != 16 { |
| return &bindings.ValidationError{bindings.UnexpectedArrayHeader, |
| fmt.Sprintf("invalid array length: expected %d, got %d", 16, len0), |
| } |
| } |
| for i0 := uint32(0); i0 < len0; i0++ { |
| value1, err := decoder.ReadUint8() |
| if err != nil { |
| return err |
| } |
| (*s.Id)[i0] = value1 |
| } |
| if err := decoder.Finish(); err != nil { |
| return err |
| } |
| } |
| } |
| if header.ElementsOrVersion >= 0 { |
| pointer0, err := decoder.ReadPointer() |
| if err != nil { |
| return err |
| } |
| if pointer0 == 0 { |
| return &bindings.ValidationError{bindings.UnexpectedNullPointer, "unexpected null pointer"} |
| } else { |
| value0, err := decoder.ReadString() |
| if err != nil { |
| return err |
| } |
| s.InterfaceName = value0 |
| } |
| } |
| if header.ElementsOrVersion >= 0 { |
| pointer0, err := decoder.ReadPointer() |
| if err != nil { |
| return err |
| } |
| if pointer0 == 0 { |
| return &bindings.ValidationError{bindings.UnexpectedNullPointer, "unexpected null pointer"} |
| } else { |
| len0, err := decoder.StartArray(64) |
| if err != nil { |
| return err |
| } |
| s.Addresses = make([]string, len0) |
| for i0 := uint32(0); i0 < len0; i0++ { |
| pointer1, err := decoder.ReadPointer() |
| if err != nil { |
| return err |
| } |
| if pointer1 == 0 { |
| return &bindings.ValidationError{bindings.UnexpectedNullPointer, "unexpected null pointer"} |
| } else { |
| value1, err := decoder.ReadString() |
| if err != nil { |
| return err |
| } |
| s.Addresses[i0] = value1 |
| } |
| } |
| if err := decoder.Finish(); err != nil { |
| return err |
| } |
| } |
| } |
| if header.ElementsOrVersion >= 0 { |
| pointer0, err := decoder.ReadPointer() |
| if err != nil { |
| return err |
| } |
| if pointer0 == 0 { |
| s.Attributes = nil |
| } else { |
| s.Attributes = new(map[string]string) |
| if err := decoder.StartMap(); err != nil { |
| return err |
| } |
| var keys0 []string |
| { |
| pointer1, err := decoder.ReadPointer() |
| if err != nil { |
| return err |
| } |
| if pointer1 == 0 { |
| return &bindings.ValidationError{bindings.UnexpectedNullPointer, "unexpected null pointer"} |
| } else { |
| len1, err := decoder.StartArray(64) |
| if err != nil { |
| return err |
| } |
| keys0 = make([]string, len1) |
| for i1 := uint32(0); i1 < len1; i1++ { |
| pointer2, err := decoder.ReadPointer() |
| if err != nil { |
| return err |
| } |
| if pointer2 == 0 { |
| return &bindings.ValidationError{bindings.UnexpectedNullPointer, "unexpected null pointer"} |
| } else { |
| value2, err := decoder.ReadString() |
| if err != nil { |
| return err |
| } |
| keys0[i1] = value2 |
| } |
| } |
| if err := decoder.Finish(); err != nil { |
| return err |
| } |
| } |
| } |
| var values0 []string |
| { |
| pointer1, err := decoder.ReadPointer() |
| if err != nil { |
| return err |
| } |
| if pointer1 == 0 { |
| return &bindings.ValidationError{bindings.UnexpectedNullPointer, "unexpected null pointer"} |
| } else { |
| len1, err := decoder.StartArray(64) |
| if err != nil { |
| return err |
| } |
| values0 = make([]string, len1) |
| for i1 := uint32(0); i1 < len1; i1++ { |
| pointer2, err := decoder.ReadPointer() |
| if err != nil { |
| return err |
| } |
| if pointer2 == 0 { |
| return &bindings.ValidationError{bindings.UnexpectedNullPointer, "unexpected null pointer"} |
| } else { |
| value2, err := decoder.ReadString() |
| if err != nil { |
| return err |
| } |
| values0[i1] = value2 |
| } |
| } |
| if err := decoder.Finish(); err != nil { |
| return err |
| } |
| } |
| } |
| if len(keys0) != len(values0) { |
| return &bindings.ValidationError{bindings.DifferentSizedArraysInMap, |
| fmt.Sprintf("Number of keys %d is different from number of values %d", len(keys0), len(values0)), |
| } |
| } |
| if err := decoder.Finish(); err != nil { |
| return err |
| } |
| len0 := len(keys0) |
| map0 := make(map[string]string) |
| for i0 := 0; i0 < len0; i0++ { |
| map0[keys0[i0]] = values0[i0] |
| } |
| (*s.Attributes) = map0 |
| } |
| } |
| if header.ElementsOrVersion >= 0 { |
| pointer0, err := decoder.ReadPointer() |
| if err != nil { |
| return err |
| } |
| if pointer0 == 0 { |
| s.Attachments = nil |
| } else { |
| s.Attachments = new(map[string][]uint8) |
| if err := decoder.StartMap(); err != nil { |
| return err |
| } |
| var keys0 []string |
| { |
| pointer1, err := decoder.ReadPointer() |
| if err != nil { |
| return err |
| } |
| if pointer1 == 0 { |
| return &bindings.ValidationError{bindings.UnexpectedNullPointer, "unexpected null pointer"} |
| } else { |
| len1, err := decoder.StartArray(64) |
| if err != nil { |
| return err |
| } |
| keys0 = make([]string, len1) |
| for i1 := uint32(0); i1 < len1; i1++ { |
| pointer2, err := decoder.ReadPointer() |
| if err != nil { |
| return err |
| } |
| if pointer2 == 0 { |
| return &bindings.ValidationError{bindings.UnexpectedNullPointer, "unexpected null pointer"} |
| } else { |
| value2, err := decoder.ReadString() |
| if err != nil { |
| return err |
| } |
| keys0[i1] = value2 |
| } |
| } |
| if err := decoder.Finish(); err != nil { |
| return err |
| } |
| } |
| } |
| var values0 [][]uint8 |
| { |
| pointer1, err := decoder.ReadPointer() |
| if err != nil { |
| return err |
| } |
| if pointer1 == 0 { |
| return &bindings.ValidationError{bindings.UnexpectedNullPointer, "unexpected null pointer"} |
| } else { |
| len1, err := decoder.StartArray(64) |
| if err != nil { |
| return err |
| } |
| values0 = make([][]uint8, len1) |
| for i1 := uint32(0); i1 < len1; i1++ { |
| pointer2, err := decoder.ReadPointer() |
| if err != nil { |
| return err |
| } |
| if pointer2 == 0 { |
| return &bindings.ValidationError{bindings.UnexpectedNullPointer, "unexpected null pointer"} |
| } else { |
| len2, err := decoder.StartArray(8) |
| if err != nil { |
| return err |
| } |
| values0[i1] = make([]uint8, len2) |
| for i2 := uint32(0); i2 < len2; i2++ { |
| value3, err := decoder.ReadUint8() |
| if err != nil { |
| return err |
| } |
| values0[i1][i2] = value3 |
| } |
| if err := decoder.Finish(); err != nil { |
| return err |
| } |
| } |
| } |
| if err := decoder.Finish(); err != nil { |
| return err |
| } |
| } |
| } |
| if len(keys0) != len(values0) { |
| return &bindings.ValidationError{bindings.DifferentSizedArraysInMap, |
| fmt.Sprintf("Number of keys %d is different from number of values %d", len(keys0), len(values0)), |
| } |
| } |
| if err := decoder.Finish(); err != nil { |
| return err |
| } |
| len0 := len(keys0) |
| map0 := make(map[string][]uint8) |
| for i0 := 0; i0 < len0; i0++ { |
| map0[keys0[i0]] = values0[i0] |
| } |
| (*s.Attachments) = map0 |
| } |
| } |
| if err := decoder.Finish(); err != nil { |
| return err |
| } |
| return nil |
| } |
| |
| type Error struct { |
| Id string |
| ActionCode uint32 |
| Msg string |
| } |
| |
| func (s *Error) Encode(encoder *bindings.Encoder) error { |
| encoder.StartStruct(24, 0) |
| if err := encoder.WritePointer(); err != nil { |
| return err |
| } |
| if err := encoder.WriteString(s.Id); err != nil { |
| return err |
| } |
| if err := encoder.WriteUint32(s.ActionCode); err != nil { |
| return err |
| } |
| if err := encoder.WritePointer(); err != nil { |
| return err |
| } |
| if err := encoder.WriteString(s.Msg); err != nil { |
| return err |
| } |
| if err := encoder.Finish(); err != nil { |
| return err |
| } |
| return nil |
| } |
| |
| var error_Versions []bindings.DataHeader = []bindings.DataHeader{ |
| bindings.DataHeader{32, 0}, |
| } |
| |
| func (s *Error) Decode(decoder *bindings.Decoder) error { |
| header, err := decoder.StartStruct() |
| if err != nil { |
| return err |
| } |
| index := sort.Search(len(error_Versions), func(i int) bool { |
| return error_Versions[i].ElementsOrVersion >= header.ElementsOrVersion |
| }) |
| if index < len(error_Versions) { |
| if error_Versions[index].ElementsOrVersion > header.ElementsOrVersion { |
| index-- |
| } |
| expectedSize := error_Versions[index].Size |
| if expectedSize != header.Size { |
| return &bindings.ValidationError{bindings.UnexpectedStructHeader, |
| fmt.Sprintf("invalid struct header size: should be %d, but was %d", expectedSize, header.Size), |
| } |
| } |
| } |
| if header.ElementsOrVersion >= 0 { |
| pointer0, err := decoder.ReadPointer() |
| if err != nil { |
| return err |
| } |
| if pointer0 == 0 { |
| return &bindings.ValidationError{bindings.UnexpectedNullPointer, "unexpected null pointer"} |
| } else { |
| value0, err := decoder.ReadString() |
| if err != nil { |
| return err |
| } |
| s.Id = value0 |
| } |
| } |
| if header.ElementsOrVersion >= 0 { |
| value0, err := decoder.ReadUint32() |
| if err != nil { |
| return err |
| } |
| s.ActionCode = value0 |
| } |
| if header.ElementsOrVersion >= 0 { |
| pointer0, err := decoder.ReadPointer() |
| if err != nil { |
| return err |
| } |
| if pointer0 == 0 { |
| return &bindings.ValidationError{bindings.UnexpectedNullPointer, "unexpected null pointer"} |
| } else { |
| value0, err := decoder.ReadString() |
| if err != nil { |
| return err |
| } |
| s.Msg = value0 |
| } |
| } |
| if err := decoder.Finish(); err != nil { |
| return err |
| } |
| return nil |
| } |