blob: 374860703679b9f0b862bacf2495d324f310d9ec [file]
// 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.
package codegen
const fragmentClientSyncMethodsTmpl = `
{{- define "ClientSyncRequestCallerAllocateMethodDefinition" }}
{{ EnsureNamespace "" }}
{{- $base_args := (printf "::fidl::UnownedClientEnd<%s>(_channel->handle())" .Protocol) }}
{{- if .RequestArgs }}
{{- $base_args = (List $base_args "_request_buffer.data" "_request_buffer.capacity") }}
{{- end }}
{{- $base_args = (List $base_args .RequestArgs) }}
{{- if .HasResponse }}
{{- IfdefFuchsia -}}
{{ .WireUnownedResult }}
{{ .Protocol.WireClientImpl.NoLeading }}::{{ .Name }}_Sync(
{{- template "SyncRequestCallerAllocateMethodArguments" . }}) {
if (auto _channel = ::fidl::internal::ClientBase::GetChannel()) {
return {{ .WireUnownedResult }}({{ RenderForwardParams $base_args "_response_buffer.data" "_response_buffer.capacity" }});
}
return {{ .WireUnownedResult }}(::fidl::Result::Unbound());
}
{{- EndifFuchsia -}}
{{- else }}{{ if .RequestArgs }}
{{- IfdefFuchsia -}}
::fidl::Result {{ .Protocol.WireClientImpl.NoLeading }}::{{ .Name }}(
{{- template "SyncRequestCallerAllocateMethodArguments" . }}) {
if (auto _channel = ::fidl::internal::ClientBase::GetChannel()) {
auto _res = {{ .WireUnownedResult }}({{ RenderForwardParams $base_args }});
return _res;
}
return ::fidl::Result::Unbound();
}
{{- EndifFuchsia -}}
{{- end }}{{ end }}
{{- end }}
{{- define "ClientSyncRequestManagedMethodDefinition" }}
{{ EnsureNamespace "" }}
{{- if .HasResponse }}
{{- IfdefFuchsia -}}
{{ .WireResult }}
{{ .Protocol.WireClientImpl.NoLeading }}::{{ .Name }}_Sync({{ RenderParams .RequestArgs }}) {
if (auto _channel = ::fidl::internal::ClientBase::GetChannel()) {
return {{ .WireResult }}(
{{- RenderForwardParams (printf "::fidl::UnownedClientEnd<%s>(_channel->handle())" .Protocol)
.RequestArgs }});
}
return {{ .WireResult }}(::fidl::Result::Unbound());
}
{{- EndifFuchsia -}}
{{- else }}
{{- IfdefFuchsia -}}
::fidl::Result {{ .Protocol.WireClientImpl.NoLeading }}::{{ .Name }}({{ RenderParams .RequestArgs }}) {
if (auto _channel = ::fidl::internal::ClientBase::GetChannel()) {
auto _res = {{ .WireResult }}(
{{- RenderForwardParams (printf "::fidl::UnownedClientEnd<%s>(_channel->handle())" .Protocol)
.RequestArgs }});
return _res;
}
return ::fidl::Result::Unbound();
}
{{- EndifFuchsia -}}
{{- end }}
{{- end }}
`