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