| // 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 }}> |
| |
| {{ if IncludeProxiesAndStubs -}} |
| #include "lib/fidl/cpp/internal/implementation.h" |
| {{ else -}} |
| #include "lib/fidl/cpp/internal/natural_types_implementation.h" |
| {{- end }} |
| |
| {{ template "Implementation/NaturalTypes" . }} |
| {{ if IncludeProxiesAndStubs -}} |
| {{ template "Implementation/ProxiesAndStubs" . }} |
| {{- end }} |
| |
| {{ 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.Enum }}{{ template "EnumDefinition" . }}{{- 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 -}} |
| ` |