1// Copyright 2013 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5{%- if variant -%} 6{%- set variant_path = "%s-%s"|format(module.path, variant) -%} 7{%- else -%} 8{%- set variant_path = module.path -%} 9{%- endif -%} 10 11{%- set header_guard = "%s_H_"|format( 12 variant_path|upper|replace("/","_")|replace(".","_")| 13 replace("-", "_")) %} 14 15{%- macro namespace_begin() %} 16{%- for namespace in namespaces_as_array %} 17namespace {{namespace}} { 18{%- endfor %} 19{%- if variant %} 20namespace {{variant}} { 21{%- endif %} 22{%- endmacro %} 23 24{%- macro namespace_end() %} 25{%- if variant %} 26} // namespace {{variant}} 27{%- endif %} 28{%- for namespace in namespaces_as_array|reverse %} 29} // namespace {{namespace}} 30{%- endfor %} 31{%- endmacro %} 32 33#ifndef {{header_guard}} 34#define {{header_guard}} 35 36#include <stdint.h> 37 38#include <limits> 39#include <type_traits> 40#include <utility> 41 42#include "base/callback.h" 43#include "base/optional.h" 44#include "mojo/public/cpp/bindings/associated_interface_ptr.h" 45#include "mojo/public/cpp/bindings/associated_interface_ptr_info.h" 46#include "mojo/public/cpp/bindings/associated_interface_request.h" 47#include "mojo/public/cpp/bindings/clone_traits.h" 48#include "mojo/public/cpp/bindings/interface_ptr.h" 49#include "mojo/public/cpp/bindings/interface_request.h" 50#include "mojo/public/cpp/bindings/lib/equals_traits.h" 51#include "mojo/public/cpp/bindings/lib/control_message_handler.h" 52#include "mojo/public/cpp/bindings/lib/control_message_proxy.h" 53#include "mojo/public/cpp/bindings/lib/serialization.h" 54#include "mojo/public/cpp/bindings/lib/union_accessor.h" 55#include "mojo/public/cpp/bindings/native_struct.h" 56#include "mojo/public/cpp/bindings/raw_ptr_impl_ref_traits.h" 57#include "mojo/public/cpp/bindings/struct_ptr.h" 58#include "mojo/public/cpp/bindings/struct_traits.h" 59#include "mojo/public/cpp/bindings/thread_safe_interface_ptr.h" 60#include "mojo/public/cpp/bindings/union_traits.h" 61#include "{{module.path}}-shared.h" 62{%- for import in imports %} 63{%- if variant %} 64#include "{{"%s-%s.h"|format(import.module.path, variant)}}" 65{%- else %} 66#include "{{import.module.path}}.h" 67{%- endif %} 68{%- endfor %} 69{%- if not for_blink %} 70#include <string> 71#include <vector> 72{%- else %} 73{# hash_util.h includes template specializations that should be present for 74 every use of {Inlined}StructPtr. #} 75#include "mojo/public/cpp/bindings/lib/wtf_hash_util.h" 76#include "third_party/WebKit/Source/wtf/HashFunctions.h" 77#include "third_party/WebKit/Source/wtf/Optional.h" 78#include "third_party/WebKit/Source/wtf/text/WTFString.h" 79{%- endif %} 80 81{%- for header in extra_public_headers %} 82#include "{{header}}" 83{%- endfor %} 84 85{%- if export_header %} 86#include "{{export_header}}" 87{%- endif %} 88 89{#--- WTF enum hashing #} 90{%- from "enum_macros.tmpl" import enum_hash_blink%} 91{%- if for_blink %} 92{%- for enum in all_enums %} 93{%- if not enum|is_native_only_kind %} 94{{enum_hash_blink(enum)}} 95{%- endif %} 96{%- endfor %} 97{%- endif %} 98 99{{namespace_begin()}} 100 101{#--- Enums #} 102{%- if variant %} 103{%- for enum in enums %} 104using {{enum.name}} = {{enum.name}}; // Alias for definition in the parent namespace. 105{%- endfor %} 106{%- endif %} 107 108{#--- Constants #} 109{%- for constant in module.constants %} 110{{constant|format_constant_declaration}}; 111{%- endfor %} 112 113{#--- Interface Forward Declarations -#} 114{% for interface in interfaces %} 115class {{interface.name}}; 116using {{interface.name}}Ptr = mojo::InterfacePtr<{{interface.name}}>; 117using {{interface.name}}PtrInfo = mojo::InterfacePtrInfo<{{interface.name}}>; 118using ThreadSafe{{interface.name}}Ptr = 119 mojo::ThreadSafeInterfacePtr<{{interface.name}}>; 120using {{interface.name}}Request = mojo::InterfaceRequest<{{interface.name}}>; 121using {{interface.name}}AssociatedPtr = 122 mojo::AssociatedInterfacePtr<{{interface.name}}>; 123using ThreadSafe{{interface.name}}AssociatedPtr = 124 mojo::ThreadSafeAssociatedInterfacePtr<{{interface.name}}>; 125using {{interface.name}}AssociatedPtrInfo = 126 mojo::AssociatedInterfacePtrInfo<{{interface.name}}>; 127using {{interface.name}}AssociatedRequest = 128 mojo::AssociatedInterfaceRequest<{{interface.name}}>; 129{% endfor %} 130 131{#--- Struct Forward Declarations -#} 132{% for struct in structs %} 133{%- if struct|is_native_only_kind %} 134using {{struct.name}} = mojo::NativeStruct; 135using {{struct.name}}Ptr = mojo::NativeStructPtr; 136{%- else %} 137class {{struct.name}}; 138{%- if struct|should_inline %} 139using {{struct.name}}Ptr = mojo::InlinedStructPtr<{{struct.name}}>; 140{%- else %} 141using {{struct.name}}Ptr = mojo::StructPtr<{{struct.name}}>; 142{%- endif %} 143{%- endif %} 144{% endfor %} 145 146{#--- Union Forward Declarations -#} 147{% for union in unions %} 148class {{union.name}}; 149{% if union|should_inline_union %} 150typedef mojo::InlinedStructPtr<{{union.name}}> {{union.name}}Ptr; 151{% else %} 152typedef mojo::StructPtr<{{union.name}}> {{union.name}}Ptr; 153{% endif %} 154{%- endfor %} 155 156{#--- Interfaces -#} 157{% for interface in interfaces %} 158{% include "interface_declaration.tmpl" %} 159{%- endfor %} 160 161{#--- Interface Proxies -#} 162{% for interface in interfaces %} 163{% include "interface_proxy_declaration.tmpl" %} 164{%- endfor %} 165 166{#--- Interface Stubs -#} 167{% for interface in interfaces %} 168{% include "interface_stub_declaration.tmpl" %} 169{%- endfor %} 170 171{#--- Interface Request Validators -#} 172{% for interface in interfaces %} 173{% include "interface_request_validator_declaration.tmpl" %} 174{%- endfor %} 175 176{#--- Interface Response Validators -#} 177{% for interface in interfaces if interface|has_callbacks %} 178{% include "interface_response_validator_declaration.tmpl" %} 179{%- endfor %} 180 181{#--- NOTE: Unions and non-inlined structs may have pointers to inlined structs, 182 so we need to fully define inlined structs ahead of the others. #} 183 184{#--- Inlined structs #} 185{% for struct in structs %} 186{% if struct|should_inline and not struct|is_native_only_kind %} 187{% include "wrapper_class_declaration.tmpl" %} 188{% endif %} 189{%- endfor %} 190 191{#--- Unions must be declared before non-inlined structs because they can be 192 members of structs. #} 193{#--- Unions #} 194{% for union in unions %} 195{% include "wrapper_union_class_declaration.tmpl" %} 196{%- endfor %} 197 198{#--- Non-inlined structs #} 199{% for struct in structs %} 200{% if not struct|should_inline and not struct|is_native_only_kind %} 201{% include "wrapper_class_declaration.tmpl" %} 202{% endif %} 203{%- endfor %} 204 205{%- for union in unions %} 206{% include "wrapper_union_class_template_definition.tmpl" %} 207{%- endfor %} 208 209{%- for struct in structs %} 210{%- if not struct|is_native_only_kind %} 211{% include "wrapper_class_template_definition.tmpl" %} 212{%- endif %} 213{%- endfor %} 214 215{{namespace_end()}} 216 217namespace mojo { 218 219{#--- Struct Serialization Helpers -#} 220{% for struct in structs %} 221{%- if not struct|is_native_only_kind %} 222{% include "struct_traits_declaration.tmpl" %} 223{%- endif %} 224{%- endfor %} 225 226{#--- Union Serialization Helpers -#} 227{% if unions %} 228{%- for union in unions %} 229{% include "union_traits_declaration.tmpl" %} 230{%- endfor %} 231{%- endif %} 232 233} // namespace mojo 234 235#endif // {{header_guard}} 236