blob: 0f3193de85ad4d8df0f8c06f4600bae88bed0643 [file] [log] [blame]
{{/*
// Copyright 2021 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:Request:MessagingHeader" }}
{{- EnsureNamespace "" }}
{{- if .Request.IsResource }}
{{- IfdefFuchsia -}}
{{- end }}
template<>
struct {{ .WireRequest }} final {
{{- range .RequestAnonymousChildren }}
using {{ .ScopedName }} = {{ .FlattenedName }};
{{- end }}
FIDL_ALIGNDECL
{{- /* Add underscore to prevent name collision */}}
fidl_message_header_t _hdr;
{{- range $index, $param := .RequestArgs }}
{{ $param.Type }} {{ $param.Name }};
{{- end }}
{{ if .RequestArgs }}
explicit {{ .WireRequest.Self }}({{ RenderParams .RequestArgs }})
{{ RenderInitMessage .RequestArgs }} {
_InitHeader();
}
{{- end }}
{{ .WireRequest.Self }}() {
_InitHeader();
}
static constexpr const fidl_type_t* Type =
{{- if .RequestArgs }}
&{{ .Request.WireCodingTable }};
{{- else }}
&::fidl::_llcpp_coding_AnyZeroArgMessageTable;
{{- end }}
static constexpr uint32_t MaxNumHandles = {{ .Request.TypeShapeV2.MaxHandles }};
static constexpr uint32_t PrimarySize = {{ .Request.TypeShapeV2.InlineSize }};
static constexpr uint32_t PrimarySizeV1 = {{ .Request.TypeShapeV1.InlineSize }};
static constexpr uint32_t MaxOutOfLine = {{ .Request.TypeShapeV2.MaxOutOfLine }};
static constexpr uint32_t MaxOutOfLineV1 = {{ .Request.TypeShapeV1.MaxOutOfLine }};
static constexpr bool HasFlexibleEnvelope = {{ .Request.TypeShapeV2.HasFlexibleEnvelope }};
static constexpr bool HasPointer = {{ .Request.TypeShapeV2.HasPointer }};
static constexpr ::fidl::internal::TransactionalMessageKind MessageKind =
::fidl::internal::TransactionalMessageKind::kRequest;
{{- if and .HasResponse .ResponseArgs }}
using ResponseType = {{ .WireResponse }};
{{- end }}
{{- if .Request.IsResource }}
void _CloseHandles();
{{- end }}
class UnownedEncodedMessage;
class OwnedEncodedMessage;
public:
class DecodedMessage;
private:
void _InitHeader();
};
{{- if .Request.IsResource }}
{{- EndifFuchsia -}}
{{- end }}
{{- end }}
{{- define "Method:Request:MessagingSource" }}
{{- EnsureNamespace "" }}
{{- if .Request.IsResource }}
{{- IfdefFuchsia -}}
{{- end }}
void {{ .WireRequest }}::_InitHeader() {
fidl_init_txn_header(&_hdr, 0, {{ .OrdinalName }});
}
{{ if .Request.IsResource }}
void {{ .WireRequest }}::_CloseHandles() {
{{- range .RequestArgs }}
{{- CloseHandles . false false }}
{{- end }}
}
{{- end }}
{{- if .Request.IsResource }}
{{- EndifFuchsia -}}
{{- end }}
{{- end }}