Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(153)

Side by Side Diff: mojo/public/tools/bindings/generators/cpp_templates/module-shared-internal.h.tmpl

Issue 2247083003: Mojo C++ bindings: extract code shared by different variants. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // TODO(yzshen): Move code here. 5 {%- set header_guard = "%s_SHARED_INTERNAL_H_"|format(
6 module.path|upper|replace("/","_")|replace(".","_")|
7 replace("-", "_")) %}
8
9 #ifndef {{header_guard}}
10 #define {{header_guard}}
11
12 #include <stdint.h>
13
14 #include "mojo/public/cpp/bindings/lib/array_internal.h"
15 #include "mojo/public/cpp/bindings/lib/bindings_internal.h"
16 #include "mojo/public/cpp/bindings/lib/map_data_internal.h"
17 #include "mojo/public/cpp/bindings/lib/native_enum_data.h"
18 #include "mojo/public/cpp/bindings/lib/native_struct_data.h"
19 #include "mojo/public/cpp/bindings/lib/buffer.h"
20
21 {%- for import in imports %}
22 #include "{{import.module.path}}-shared-internal.h"
23 {%- endfor %}
24
25 namespace mojo {
26 namespace internal {
27 class ValidationContext;
28 }
29 }
30
31 {%- for namespace in namespaces_as_array %}
32 namespace {{namespace}} {
33 {%- endfor %}
34 namespace internal {
35
36 {#--- Internal forward declarations #}
37 {%- for struct in structs %}
38 {%- if struct|is_native_only_kind %}
39 using {{struct.name}}_Data = mojo::internal::NativeStruct_Data;
40 {%- else %}
41 class {{struct.name}}_Data;
42 {%- endif %}
43 {%- endfor %}
44
45 {%- for union in unions %}
46 class {{union.name}}_Data;
47 {%- endfor %}
48
49 {#--- Enums #}
50 {%- from "enum_macros.tmpl" import enum_data_decl -%}
51 {%- for enum in all_enums %}
52 {%- if enum|is_native_only_kind %}
53 using {{enum.name}}_Data = mojo::internal::NativeEnum_Data;
54 {%- else %}
55 {{enum_data_decl(enum)}}
56 {%- endif %}
57 {%- endfor %}
58
59 #pragma pack(push, 1)
60
61 {#--- Unions must be declared first because they can be members of structs #}
62 {#--- Union class declarations #}
63 {%- for union in unions %}
64 {% include "union_declaration.tmpl" %}
65 {%- endfor %}
66
67 {#--- Struct class declarations #}
68 {%- for struct in structs %}
69 {%- if not struct|is_native_only_kind %}
70 {% include "struct_declaration.tmpl" %}
71 {%- endif %}
72 {%- endfor %}
73
74 {#--- Interface parameter definitions #}
75 {%- for interface in interfaces %}
76 {%- for method in interface.methods %}
77 {%- set method_name = "k%s_%s_Name"|format(interface.name, method.name) %}
78 const uint32_t {{method_name}} = {{method.ordinal}};
79 {%- set struct = method.param_struct %}
80 {% include "struct_declaration.tmpl" %}
81 {%- if method.response_parameters != None %}
82 {%- set struct = method.response_param_struct %}
83 {% include "struct_declaration.tmpl" %}
84 {%- endif %}
85 {%- endfor %}
86 {%- endfor %}
87
88 #pragma pack(pop)
89
90 } // namespace internal
91 {%- for namespace in namespaces_as_array|reverse %}
92 } // namespace {{namespace}}
93 {%- endfor %}
94
95 #endif // {{header_guard}}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698