| {{/* | |
| // Copyright 2020 The Fuchsia Authors. All rights reserved. | |
| // Use of this source code is governed by a BSD-style license that can be | |
| // found in the LICENSE file. | |
| */}} | |
| {{- define "Protocol:ClientImpl:WireMessagingHeader" }} | |
| {{- EnsureNamespace "" }} | |
| template<> | |
| class {{ .WireWeakOnewayClientImpl }} : public ::fidl::internal::ClientImplBase { | |
| public: | |
| using ClientImplBase::ClientImplBase; | |
| {{- range .OneWayMethods }} | |
| {{- template "Method:WireWeakOnewayClientImpl:WireMessagingHeader" . }} | |
| {{- end }} | |
| }; | |
| template<> | |
| class {{ .WireWeakAsyncClientImpl }} final : public {{ .WireWeakOnewayClientImpl }} { | |
| public: | |
| using {{ .WireWeakOnewayClientImpl.Self }}::{{ .WireWeakOnewayClientImpl.Self }}; | |
| {{- range .TwoWayMethods }} | |
| {{- template "Method:WireWeakAsyncClientImpl:WireMessagingHeader" . }} | |
| {{- end }} | |
| }; | |
| template<> | |
| class {{ .WireWeakOnewayBufferClientImpl }} : public ::fidl::internal::BufferClientImplBase { | |
| public: | |
| using BufferClientImplBase::BufferClientImplBase; | |
| {{- range .OneWayMethods }} | |
| {{- template "Method:ClientImplOnewayBuffer:WireMessagingHeader" . }} | |
| {{- end }} | |
| }; | |
| template<> | |
| class {{ .WireWeakAsyncBufferClientImpl }} final : public {{ .WireWeakOnewayBufferClientImpl }} { | |
| public: | |
| using {{ .WireWeakOnewayBufferClientImpl.Self }}::{{ .WireWeakOnewayBufferClientImpl.Self }}; | |
| {{- range .TwoWayMethods }} | |
| {{- template "Method:ClientImplAsyncBuffer:WireMessagingHeader" . }} | |
| {{- end }} | |
| }; | |
| {{- if .Transport.HasSyncClient }} | |
| template<> | |
| class {{ .WireWeakSyncClientImpl }} final : public {{ .WireWeakOnewayClientImpl }} { | |
| public: | |
| using {{ .WireWeakOnewayClientImpl.Self }}::{{ .WireWeakOnewayClientImpl.Self }}; | |
| {{- range .TwoWayMethods }} | |
| {{- template "Method:WireWeakSyncClientImpl:WireMessagingHeader" . }} | |
| {{- end }} | |
| }; | |
| {{- end }} | |
| {{- end }} | |
| {{- define "Protocol:ClientImpl:WireMessagingSource" }} | |
| {{ EnsureNamespace ""}} | |
| {{- range .OneWayMethods }} | |
| {{- template "Method:WireWeakOnewayClientImpl:WireMessagingSource" . }} | |
| {{- end }} | |
| {{- range .TwoWayMethods }} | |
| {{- template "Method:WireWeakAsyncClientImpl:WireMessagingSource" . }} | |
| {{- end }} | |
| {{- range .OneWayMethods }} | |
| {{- template "Method:ClientImplOnewayBuffer:WireMessagingSource" . }} | |
| {{- end }} | |
| {{- range .TwoWayMethods }} | |
| {{- template "Method:ClientImplAsyncBuffer:WireMessagingSource" . }} | |
| {{- end }} | |
| {{- if .Transport.HasSyncClient }} | |
| {{- range .TwoWayMethods }} | |
| {{- template "Method:WireWeakSyncClientImpl:WireMessagingSource" . }} | |
| {{- end }} | |
| {{- end }} | |
| {{- end }} | |
| {{- define "Protocol:Client:NaturalMessagingHeader" }} | |
| {{- range .Events }} | |
| {{- template "Method:Event:NaturalMessagingHeader" . }} | |
| {{- end }} | |
| {{- range .TwoWayMethods }} | |
| {{- template "Method:Response:NaturalMessagingHeader" . }} | |
| {{- EnsureNamespace "" }} | |
| template <> | |
| class {{ .NaturalResult }} final : public {{ .NaturalResultBase }} { | |
| public: | |
| using {{ .NaturalResultBase }}::result; | |
| protected: | |
| {{ .NaturalResult.Self }}() = default; | |
| }; | |
| {{ end }} | |
| {{- EnsureNamespace "" }} | |
| template<> | |
| class {{ .NaturalClientImpl }} final : public ::fidl::internal::NaturalClientBase { | |
| public: | |
| using NaturalClientBase::NaturalClientBase; | |
| {{- range .TwoWayMethods }} | |
| {{- .Docs }} | |
| {{ .NaturalThenable }} {{ .Name }}({{ .NaturalRequestArg "request" }}) const; | |
| {{ "" }} | |
| {{- end }} | |
| {{- range .OneWayMethods }} | |
| {{- .Docs }} | |
| ::fit::result<::fidl::OneWayError> {{ .Name }}({{ .NaturalRequestArg "request" }}) const; | |
| {{ "" }} | |
| {{- end }} | |
| }; | |
| {{- end }} | |
| {{- define "Protocol:Client:NaturalMessagingSource" }} | |
| {{- range .Events }} | |
| {{- template "Method:Event:NaturalMessagingSource" . }} | |
| {{- end }} | |
| {{- range .TwoWayMethods }} | |
| {{- template "Method:Response:NaturalMessagingSource" . }} | |
| {{- EnsureNamespace "" }} | |
| {{- if ExperimentEnabled "api_coverage" }} | |
| {{ .ApiCoverageMethodAnnotation }} | |
| {{ end }} | |
| {{ .NaturalThenable }} | |
| {{ $.NaturalClientImpl.NoLeading }}::{{ .Name }}({{ .NaturalRequestArg "request" }}) const { | |
| return {{ .NaturalThenable }}( | |
| &client_base(), {}, &::fidl::internal::ChannelTransport::VTable, {{ .OrdinalName }}, {{ .DynamicFlagsName }}, | |
| [{{ if .HasRequestPayload }}request = {{ .Request.Forward "request" }}{{ end }}](NaturalMessageEncoder& encoder) mutable { | |
| {{- if .HasRequestPayload }} | |
| encoder.EncodeBody({{ .Request.Forward "request" }}); | |
| {{- end }} | |
| return ZX_OK; | |
| }, | |
| [] ( | |
| ::fidl::internal::ThenableBase* base, | |
| ::fidl::internal::NaturalMessageEncoder& encoder, | |
| ::fidl::internal::ResponseContext* response_context | |
| ) { | |
| ::fidl::OutgoingMessage msg = encoder.GetMessage(); | |
| return base->SendTwoWay(msg, response_context); | |
| }); | |
| } | |
| {{- if ExperimentEnabled "api_coverage" }} | |
| {{ .ApiCoverageMethodAnnotation }}:end | |
| {{ end }} | |
| {{ end }} | |
| {{- range .OneWayMethods }} | |
| {{- EnsureNamespace "" }} | |
| {{- if ExperimentEnabled "api_coverage" }} | |
| {{ .ApiCoverageMethodAnnotation }} | |
| {{ end }} | |
| ::fit::result<::fidl::OneWayError> | |
| {{ $.NaturalClientImpl.NoLeading }}::{{ .Name }}({{ .NaturalRequestArg "request" }}) const { | |
| ::fidl::internal::NaturalMessageEncoder _encoder{ | |
| &::fidl::internal::ChannelTransport::VTable, {{ .OrdinalName }}, {{ .DynamicFlagsName }} }; | |
| {{- if .HasRequestPayload }} | |
| _encoder.EncodeBody({{ .Request.Forward "request" }}); | |
| {{ end }} | |
| ::fidl::OutgoingMessage _encoded_message = _encoder.GetMessage(); | |
| ::fidl::OneWayStatus status = client_base().SendOneWay(_encoded_message); | |
| return ::fidl::internal::ToFitxResult(status); | |
| } | |
| {{- if ExperimentEnabled "api_coverage" }} | |
| {{ .ApiCoverageMethodAnnotation }}:end | |
| {{ end }} | |
| {{ end }} | |
| {{- end }} |