blob: 233be1a5364784b1209730aa3525acdce220328d [file] [log] [blame]
{{/*
// 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 "Method:ClientImplSyncCallerAllocateArguments:Helper" -}}
{{- /* TODO(fxbug.dev/85688): Replace with a `.buffer()` accessor on the client object. */}}
{{- $args := (List "::fidl::BufferSpan _buffer_span" .RequestArgs) }}
{{- RenderParams $args }}
{{- end }}
{{- define "Method:ClientImplSync:MessagingHeader" }}
{{- /* Sync managed flavor */}}
{{- .Docs }}
{{ if .DocComments }}
//
{{- end }}
// Synchronous variant of |{{ $.Name }}.{{ .Name }}()|.
// {{- template "Method:ClientAllocationComment:Helper" . }}
{{ .WireResult }} {{ .Name }}_Sync({{ RenderParams .RequestArgs }});
{{- /* Sync caller-allocate flavor */}}
{{- if or .RequestArgs .ResponseArgs }}
{{ .Docs }}
{{- if .DocComments }}
//
{{- end }}
// Synchronous variant of |{{ $.Name }}.{{ .Name }}()|.
// Caller provides the backing storage for FIDL message via request and
// response buffers.
{{ .WireUnownedResult }} {{ .Name }}{{ if .HasResponse }}_Sync{{ end }}(
{{- template "Method:ClientImplSyncCallerAllocateArguments:Helper" . }});
{{- end }}
{{- end }}
{{- define "Method:ClientImplSyncCallerAllocate:MessagingSource" }}
{{ EnsureNamespace "" }}
{{- IfdefFuchsia -}}
{{ .WireUnownedResult }}
{{ .Protocol.WireClientImpl.NoLeading }}::{{ .Name }}_Sync(
{{- template "Method:ClientImplSyncCallerAllocateArguments:Helper" . }}) {
auto _allocator = ::fidl::internal::MakeAnyBufferAllocator(_buffer_span);
return ::fidl::internal::ClientBase::MakeSyncCallWith([&] (std::shared_ptr<::fidl::internal::AnyTransport> _transport) {
{{ .WireRequest }} _request{ {{ RenderForwardParams .RequestArgs }} };
{{- $args := (printf "::fidl::UnownedClientEnd<%s>(_transport->get<fidl::internal::ChannelTransport>())" .Protocol) }}
{{- $args = (List $args "_allocator" "&_request") }}
return {{ .WireUnownedResult }}({{ RenderForwardParams $args }});
});
}
{{- EndifFuchsia -}}
{{- end }}
{{- define "Method:ClientImplSyncManaged:MessagingSource" }}
{{ EnsureNamespace "" }}
{{- IfdefFuchsia -}}
{{ .WireResult }}
{{ .Protocol.WireClientImpl.NoLeading }}::{{ .Name }}_Sync({{ RenderParams .RequestArgs }}) {
return ::fidl::internal::ClientBase::MakeSyncCallWith([&] (std::shared_ptr<::fidl::internal::AnyTransport> _transport) {
{{ .WireRequest }} _request{ {{ RenderForwardParams .RequestArgs }} };
{{- $args := (printf "::fidl::UnownedClientEnd<%s>(_transport->get<fidl::internal::ChannelTransport>())" .Protocol) }}
{{- $args = (List $args "&_request") }}
return {{ .WireResult }}({{- RenderForwardParams $args }});
});
}
{{- EndifFuchsia -}}
{{- end }}
{{- define "Method:ClientImplSync:MessagingSource" }}
{{- template "Method:ClientImplSyncManaged:MessagingSource" . }}
{{- if or .RequestArgs .ResponseArgs }}
{{- template "Method:ClientImplSyncCallerAllocate:MessagingSource" . }}
{{- end }}
{{- end }}