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

Side by Side Diff: mojo/public/tools/bindings/generators/cpp_templates/module-shared.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 {%- set header_guard = "%s_SHARED_H_"|format( 5 {%- set header_guard = "%s_SHARED_H_"|format(
6 module.path|upper|replace("/","_")|replace(".","_")| 6 module.path|upper|replace("/","_")|replace(".","_")|
7 replace("-", "_")) %} 7 replace("-", "_")) %}
8 8
9 #ifndef {{header_guard}} 9 #ifndef {{header_guard}}
10 #define {{header_guard}} 10 #define {{header_guard}}
11 11
12 // TODO(yzshen): Move code here. 12 #include <stdint.h>
13
14 #include <functional>
15 #include <ostream>
16 #include <type_traits>
17 #include <utility>
18
19 #include "mojo/public/cpp/bindings/enum_traits.h"
20 #include "mojo/public/cpp/bindings/lib/serialization_forward.h"
21 #include "mojo/public/cpp/bindings/native_enum.h"
22 #include "{{module.path}}-shared-internal.h"
23 {%- for import in imports %}
24 #include "{{import.module.path}}-shared.h"
25 {%- endfor %}
26
27 {%- for namespace in namespaces_as_array %}
28 namespace {{namespace}} {
29 {%- endfor %}
30
31 {#--- Enums #}
32 {%- from "enum_macros.tmpl" import enum_decl%}
33 {%- for enum in all_enums %}
34 {%- if enum|is_native_only_kind %}
35 using {{enum.name}} = mojo::NativeEnum;
36 {%- else %}
37 {{enum_decl(enum)}}
38 {%- endif %}
39 {%- endfor %}
40
41 {%- for namespace in namespaces_as_array|reverse %}
42 } // namespace {{namespace}}
43 {%- endfor %}
44
45 namespace std {
46
47 {%- from "enum_macros.tmpl" import enum_hash %}
48 {%- for enum in all_enums %}
49 {%- if not enum|is_native_only_kind %}
50 {{enum_hash(enum)}}
51 {%- endif %}
52 {%- endfor %}
53
54 } // namespace std
55
56 namespace mojo {
57
58 {#--- Enum Serialization Helpers -#}
59 {%- for enum in all_enums %}
60 {%- if not enum|is_native_only_kind %}
61 {% include "enum_serialization_declaration.tmpl" %}
62 {%- endif %}
63 {%- endfor %}
64
65 } // namespace mojo
13 66
14 #endif // {{header_guard}} 67 #endif // {{header_guard}}
15 68
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698