blob: bdf0a8a20e678fb6d30d3d0442d84cd5edf98aa8 [file] [log] [blame]
// Copyright 2018 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 implementationTemplate = `
{{- define "Implementation" -}}
// WARNING: This file is machine generated by fidlgen.
#include <{{ .PrimaryHeader }}>
#include "lib/fidl/cpp/internal/implementation.h"
{{ template "Implementation/NaturalTypes" . }}
{{ template "Implementation/ProxiesAndStubs" . }}
{{ end }}
{{- define "Implementation/NaturalTypes" }}
//
// Domain objects definitions (i.e. "natural types" in unified bindings)
//
{{- range .Library }}
namespace {{ . }} {
{{- end }}
{{ "" }}
{{- range .Decls }}
{{- if Eq .Kind Kinds.Bits }}{{ template "BitsDefinition" . }}{{- end }}
{{- if Eq .Kind Kinds.Const }}{{ template "ConstDefinition" . }}{{- end }}
{{- if Eq .Kind Kinds.Struct }}{{ template "StructDefinition" . }}{{- end }}
{{- if Eq .Kind Kinds.Union }}{{ template "UnionDefinition" . }}{{- end }}
{{- if Eq .Kind Kinds.Table }}{{ template "TableDefinition" . }}{{- end }}
{{- end }}
{{- range .LibraryReversed }}
} // namespace {{ . }}
{{- end }}
{{- end }}
{{- define "Implementation/ProxiesAndStubs" }}
//
// Proxies and stubs definitions
//
{{- range .Library }}
namespace {{ . }} {
{{- end }}
{{ "" }}
{{- range .Decls }}
{{- if Eq .Kind Kinds.Protocol }}{{ template "DispatchProtocolDefinition" . }}{{- end }}
{{- end }}
{{- range .LibraryReversed }}
} // namespace {{ . }}
{{- end }}
{{- end }}
{{- define "DispatchProtocolDefinition" -}}
{{- range $transport, $_ := .Transports }}
{{- if eq $transport "Channel" -}}{{ template "ProtocolDefinition" $ }}{{- end }}
{{- end }}
{{- end -}}
`