summaryrefslogtreecommitdiffstats
path: root/mojo/public/tools/bindings/generators/cpp_templates/module-internal.h.tmpl
blob: 52aab994d2587cb1e5321afca18cde0b95a58c92 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

{%- if variant -%}
{%-   set variant_path = "%s-%s"|format(module.path, variant) -%}
{%- else -%}
{%-   set variant_path = module.path -%}
{%- endif -%}

{%- set header_guard = "%s_INTERNAL_H_"|format(
        variant_path|upper|replace("/","_")|replace(".","_")|
            replace("-", "_")) %}

#ifndef {{header_guard}}
#define {{header_guard}}

#include "mojo/public/cpp/bindings/lib/bindings_internal.h"
#include "mojo/public/cpp/bindings/lib/buffer.h"
#include "mojo/public/cpp/bindings/lib/serialization.h"
#include "mojo/public/cpp/bindings/lib/union_accessor.h"
#include "mojo/public/cpp/bindings/lib/value_traits.h"
#include "mojo/public/cpp/bindings/struct_ptr.h"
{%- for header in extra_headers %}
#include "{{header}}"
{%- endfor %}

{%- for import in imports %}
#include "{{import.module.path}}-internal.h"
{%- endfor %}

namespace mojo {
namespace internal {
class BoundsChecker;
}
}

{%- for namespace in namespaces_as_array %}
namespace {{namespace}} {
{%- endfor %}
{%- if variant %}
namespace {{variant}} {
{%- endif %}

{#--- Wrapper forward declarations #}
{%  for struct in structs %}
class {{struct.name}};
{%- endfor %}

{#--- Wrapper forward declarations for unions #}
{%  for union in unions %}
class {{union.name}};
{%- endfor %}

namespace internal {

{#--- Internal forward declarations #}
{%  for struct in structs %}
class {{struct.name}}_Data;
{%- endfor %}

{%  for union in unions %}
class {{union.name}}_Data;
{%- endfor %}

{#--- Enums #}
{% from "enum_macros.tmpl" import enum_data_decl -%}
{%- for enum in enums %}
  {{enum_data_decl(enum)}}
{%- endfor %}

#pragma pack(push, 1)

{#--- Unions must be declared first because they can be members of structs #}
{#--- Union class declarations #}
{%  for union in unions %}
{%    include "union_declaration.tmpl" %}
{%- endfor %}

{#--- Struct class declarations #}
{%  for struct in structs %}
{%    include "struct_declaration.tmpl" %}
{%- endfor %}

{#--- Interface class declarations. They are needed only when they contain
    enums. #}
{%- for interface in interfaces %}
{%-   if interface.enums %}
class {{interface.name}}_Data {
 public:
{%-     for enum in interface.enums %}
  {{enum_data_decl(enum)|indent(2)}}
{%-     endfor %}
};
{%-   endif %}
{%- endfor %}

#pragma pack(pop)

}  // namespace internal
{%- if variant %}
}  // namespace {{variant}}
{%- endif %}
{%- for namespace in namespaces_as_array|reverse %}
}  // namespace {{namespace}}
{%- endfor %}

#endif  // {{header_guard}}