• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_INTERNAL_H_"|format(
12        variant_path|upper|replace("/","_")|replace(".","_")|
13            replace("-", "_")) %}
14
15#ifndef {{header_guard}}
16#define {{header_guard}}
17
18#include "mojo/public/cpp/bindings/lib/bindings_internal.h"
19#include "mojo/public/cpp/bindings/lib/buffer.h"
20#include "mojo/public/cpp/bindings/lib/serialization.h"
21#include "mojo/public/cpp/bindings/lib/union_accessor.h"
22#include "mojo/public/cpp/bindings/struct_ptr.h"
23
24{%- for import in imports %}
25{%-   if variant %}
26#include "{{"%s-%s-internal.h"|format(import.module.path, variant)}}"
27{%-   else %}
28#include "{{import.module.path}}-internal.h"
29{%-   endif %}
30{%- endfor %}
31
32namespace mojo {
33namespace internal {
34class ValidationContext;
35}
36}
37
38{%- for namespace in namespaces_as_array %}
39namespace {{namespace}} {
40{%- endfor %}
41{%- if variant %}
42namespace {{variant}} {
43{%- endif %}
44
45{#--- Wrapper forward declarations #}
46{%  for struct in structs %}
47{%-   if struct|is_native_only_kind %}
48using {{struct.name}} = mojo::NativeStruct;
49{%-   else %}
50class {{struct.name}};
51{%-   endif %}
52{%- endfor %}
53
54{#--- Wrapper forward declarations for unions #}
55{%  for union in unions %}
56class {{union.name}};
57{%- endfor %}
58
59namespace internal {
60
61{#--- Internal forward declarations #}
62{%  for struct in structs %}
63{%-   if struct|is_native_only_kind %}
64using {{struct.name}}_Data = mojo::internal::NativeStruct_Data;
65{%-   else %}
66class {{struct.name}}_Data;
67{%-   endif %}
68{%- endfor %}
69
70{%  for union in unions %}
71class {{union.name}}_Data;
72{%- endfor %}
73
74{#--- Enums #}
75{% from "enum_macros.tmpl" import enum_data_decl -%}
76{%- for enum in enums %}
77{%-   if enum|is_native_only_kind %}
78  using {{enum.name}}_Data = mojo::internal::NativeEnum_Data;
79{%-   else %}
80  {{enum_data_decl(enum)}}
81{%-   endif %}
82{%- endfor %}
83
84#pragma pack(push, 1)
85
86{#--- Unions must be declared first because they can be members of structs #}
87{#--- Union class declarations #}
88{%  for union in unions %}
89{%    include "union_declaration.tmpl" %}
90{%- endfor %}
91
92{#--- Struct class declarations #}
93{%  for struct in structs %}
94{%-   if not struct|is_native_only_kind %}
95{%      include "struct_declaration.tmpl" %}
96{%-   endif %}
97{%- endfor %}
98
99{#--- Interface class declarations. They are needed only when they contain
100    enums. #}
101{%- for interface in interfaces %}
102{%-   if interface.enums %}
103class {{interface.name}}_Data {
104 public:
105{%-     for enum in interface.enums %}
106{%-       if enum|is_native_only_kind %}
107  using {{enum.name}}_Data = mojo::internal::NativeEnum_Data;
108{%-       else %}
109  {{enum_data_decl(enum)|indent(2)}}
110{%-       endif %}
111{%-     endfor %}
112};
113{%-   endif %}
114{%- endfor %}
115
116#pragma pack(pop)
117
118}  // namespace internal
119{%- if variant %}
120}  // namespace {{variant}}
121{%- endif %}
122{%- for namespace in namespaces_as_array|reverse %}
123}  // namespace {{namespace}}
124{%- endfor %}
125
126#endif  // {{header_guard}}
127