blob: e7f9acb4b1aa7c5768fe758960f370b706f34726 [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.
package codegen
const fragmentClientSyncMethodsTmpl = `
{{- define "ClientSyncRequestCallerAllocateMethodDefinition" }}
{{ EnsureNamespace "" }}
{{- if .HasResponse }}
{{- IfdefFuchsia -}}
{{ .WireUnownedResult }}
{{ .Protocol.WireClientImpl.NoLeading }}::{{ .Name }}_Sync(
{{- template "SyncRequestCallerAllocateMethodArguments" . }}) {
if (auto _channel = ::fidl::internal::ClientBase::GetChannel()) {
return {{ .WireUnownedResult }}(
::fidl::UnownedClientEnd<{{ .Protocol }}>(_channel->handle())
{{- if .RequestArgs -}}
, _request_buffer.data, _request_buffer.capacity
{{- end -}}
{{- .RequestArgs | ForwardCommaParams -}},
_response_buffer.data, _response_buffer.capacity);
}
return {{ .WireUnownedResult }}(
::fidl::Result(ZX_ERR_CANCELED, ::fidl::kErrorChannelUnbound));
}
{{- EndifFuchsia -}}
{{- else }}{{ if .RequestArgs }}
{{- IfdefFuchsia -}}
::fidl::Result {{ .Protocol.WireClientImpl.NoLeading }}::{{ .Name }}(
{{- template "SyncRequestCallerAllocateMethodArguments" . }}) {
if (auto _channel = ::fidl::internal::ClientBase::GetChannel()) {
auto _res = {{ .WireUnownedResult }}(
::fidl::UnownedClientEnd<{{ .Protocol }}>(_channel->handle())
{{- if .RequestArgs -}}
, _request_buffer.data, _request_buffer.capacity
{{- end }}
{{- .RequestArgs | ForwardCommaParams -}});
return ::fidl::Result(_res.status(), _res.error());
}
return ::fidl::Result(ZX_ERR_CANCELED, ::fidl::kErrorChannelUnbound);
}
{{- EndifFuchsia -}}
{{- end }}{{ end }}
{{- end }}
{{- define "ClientSyncRequestManagedMethodDefinition" }}
{{ EnsureNamespace "" }}
{{- if .HasResponse }}
{{- IfdefFuchsia -}}
{{ .WireResult }}
{{ .Protocol.WireClientImpl.NoLeading }}::{{ .Name }}_Sync({{ .RequestArgs | CalleeParams }}) {
if (auto _channel = ::fidl::internal::ClientBase::GetChannel()) {
return {{ .WireResult }}(
::fidl::UnownedClientEnd<{{ .Protocol }}>(_channel->handle())
{{- .RequestArgs | ForwardCommaParams -}}
);
}
return {{ .WireResult }}(
::fidl::Result(ZX_ERR_CANCELED, ::fidl::kErrorChannelUnbound));
}
{{- EndifFuchsia -}}
{{- else }}
{{- IfdefFuchsia -}}
::fidl::Result {{ .Protocol.WireClientImpl.NoLeading }}::{{ .Name }}(
{{ .RequestArgs | CalleeParams }}) {
if (auto _channel = ::fidl::internal::ClientBase::GetChannel()) {
auto _res = {{ .WireResult }}(
::fidl::UnownedClientEnd<{{ .Protocol }}>(_channel->handle())
{{- .RequestArgs | ForwardCommaParams -}}
);
return ::fidl::Result(_res.status(), _res.error());
}
return ::fidl::Result(ZX_ERR_CANCELED, ::fidl::kErrorChannelUnbound);
}
{{- EndifFuchsia -}}
{{- end }}
{{- end }}
`