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

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

Issue 1527183003: Change mojo enums to be scoped enums in the generated C++ bindings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mojo-binding-equals
Patch Set: Created 4 years, 11 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 2013 The Chromium Authors. All rights reserved. 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 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 {%- if variant -%} 5 {%- if variant -%}
6 {%- set variant_path = "%s-%s"|format(module.path, variant) -%} 6 {%- set variant_path = "%s-%s"|format(module.path, variant) -%}
7 {%- else -%} 7 {%- else -%}
8 {%- set variant_path = module.path -%} 8 {%- set variant_path = module.path -%}
9 {%- endif -%} 9 {%- endif -%}
10 10
11 {%- set header_guard = "%s_H_"|format( 11 {%- set header_guard = "%s_H_"|format(
12 variant_path|upper|replace("/","_")|replace(".","_")| 12 variant_path|upper|replace("/","_")|replace(".","_")|
13 replace("-", "_")) %} 13 replace("-", "_")) %}
14 14
15 #ifndef {{header_guard}} 15 #ifndef {{header_guard}}
16 #define {{header_guard}} 16 #define {{header_guard}}
17 17
18 #include <stdint.h> 18 #include <stdint.h>
19 #include <ostream>
19 20
20 #include "mojo/public/cpp/bindings/array.h" 21 #include "mojo/public/cpp/bindings/array.h"
21 #include "mojo/public/cpp/bindings/associated_interface_ptr.h" 22 #include "mojo/public/cpp/bindings/associated_interface_ptr.h"
22 #include "mojo/public/cpp/bindings/associated_interface_ptr_info.h" 23 #include "mojo/public/cpp/bindings/associated_interface_ptr_info.h"
23 #include "mojo/public/cpp/bindings/associated_interface_request.h" 24 #include "mojo/public/cpp/bindings/associated_interface_request.h"
24 #include "mojo/public/cpp/bindings/callback.h" 25 #include "mojo/public/cpp/bindings/callback.h"
25 #include "mojo/public/cpp/bindings/interface_ptr.h" 26 #include "mojo/public/cpp/bindings/interface_ptr.h"
26 #include "mojo/public/cpp/bindings/interface_request.h" 27 #include "mojo/public/cpp/bindings/interface_request.h"
27 #include "mojo/public/cpp/bindings/lib/control_message_handler.h" 28 #include "mojo/public/cpp/bindings/lib/control_message_handler.h"
28 #include "mojo/public/cpp/bindings/lib/control_message_proxy.h" 29 #include "mojo/public/cpp/bindings/lib/control_message_proxy.h"
(...skipping 13 matching lines...) Expand all
42 43
43 {%- for namespace in namespaces_as_array %} 44 {%- for namespace in namespaces_as_array %}
44 namespace {{namespace}} { 45 namespace {{namespace}} {
45 {%- endfor %} 46 {%- endfor %}
46 {%- if variant %} 47 {%- if variant %}
47 namespace {{variant}} { 48 namespace {{variant}} {
48 {%- endif %} 49 {%- endif %}
49 50
50 {#--- Enums #} 51 {#--- Enums #}
51 {% from "enum_macros.tmpl" import enum_decl -%} 52 {% from "enum_macros.tmpl" import enum_decl -%}
53 {% from "enum_macros.tmpl" import enum_stream_operator -%}
52 {% for enum in enums %} 54 {% for enum in enums %}
53 {{enum_decl(enum)}} 55 {{enum_decl(enum)}}
56 {{enum_stream_operator(enum)}}
54 {%- endfor %} 57 {%- endfor %}
55 58
56 {#--- Constants #} 59 {#--- Constants #}
57 {%- for constant in module.constants %} 60 {%- for constant in module.constants %}
58 {#- To be consistent with constants defined inside interfaces, only make 61 {#- To be consistent with constants defined inside interfaces, only make
59 integral types compile-time constants. #} 62 integral types compile-time constants. #}
60 {%- if constant.kind|is_integral_kind %} 63 {%- if constant.kind|is_integral_kind %}
61 const {{constant.kind|cpp_pod_type}} {{constant.name}} = {{constant|constant_val ue}}; 64 const {{constant.kind|cpp_pod_type}} {{constant.name}} = {{constant|constant_val ue}};
62 {%- else %} 65 {%- else %}
63 extern const {{constant.kind|cpp_pod_type}} {{constant.name}}; 66 extern const {{constant.kind|cpp_pod_type}} {{constant.name}};
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 {%- endfor %} 150 {%- endfor %}
148 {%- endif %} 151 {%- endif %}
149 152
150 {#--- Union Serialization Helpers -#} 153 {#--- Union Serialization Helpers -#}
151 {% if unions %} 154 {% if unions %}
152 {% for union in unions %} 155 {% for union in unions %}
153 {% include "union_serialization_declaration.tmpl" %} 156 {% include "union_serialization_declaration.tmpl" %}
154 {%- endfor %} 157 {%- endfor %}
155 {%- endif %} 158 {%- endif %}
156 159
160 {% for struct in structs %}
161 {% for enum in struct.enums %}
162 {{enum_stream_operator(enum)}}
163 {%- endfor %}
164 {%- endfor %}
165
166 {% for interface in interfaces %}
167 {% for enum in interface.enums %}
168 {{enum_stream_operator(enum)}}
169 {%- endfor %}
170 {%- endfor %}
171
157 {%- if variant %} 172 {%- if variant %}
158 } // namespace {{variant}} 173 } // namespace {{variant}}
159 {%- endif %} 174 {%- endif %}
160 {%- for namespace in namespaces_as_array|reverse %} 175 {%- for namespace in namespaces_as_array|reverse %}
161 } // namespace {{namespace}} 176 } // namespace {{namespace}}
162 {%- endfor %} 177 {%- endfor %}
163 178
164 #endif // {{header_guard}} 179 #endif // {{header_guard}}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698