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

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

Issue 2637393002: Make mojom-generated C++ string constants really constant. (Closed)
Patch Set: Created 3 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
(...skipping 17 matching lines...) Expand all
28 {%- for namespace in namespaces_as_array|reverse %} 28 {%- for namespace in namespaces_as_array|reverse %}
29 } // namespace {{namespace}} 29 } // namespace {{namespace}}
30 {%- endfor %} 30 {%- endfor %}
31 {%- endmacro %} 31 {%- endmacro %}
32 32
33 #ifndef {{header_guard}} 33 #ifndef {{header_guard}}
34 #define {{header_guard}} 34 #define {{header_guard}}
35 35
36 #include <stdint.h> 36 #include <stdint.h>
37 37
38 #include <limits>
38 #include <type_traits> 39 #include <type_traits>
39 #include <utility> 40 #include <utility>
40 41
41 #include "base/callback.h" 42 #include "base/callback.h"
42 #include "base/optional.h" 43 #include "base/optional.h"
43 #include "mojo/public/cpp/bindings/associated_interface_ptr.h" 44 #include "mojo/public/cpp/bindings/associated_interface_ptr.h"
44 #include "mojo/public/cpp/bindings/associated_interface_ptr_info.h" 45 #include "mojo/public/cpp/bindings/associated_interface_ptr_info.h"
45 #include "mojo/public/cpp/bindings/associated_interface_request.h" 46 #include "mojo/public/cpp/bindings/associated_interface_request.h"
46 #include "mojo/public/cpp/bindings/interface_ptr.h" 47 #include "mojo/public/cpp/bindings/interface_ptr.h"
47 #include "mojo/public/cpp/bindings/interface_request.h" 48 #include "mojo/public/cpp/bindings/interface_request.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 90
90 {#--- Enums #} 91 {#--- Enums #}
91 {%- if variant %} 92 {%- if variant %}
92 {%- for enum in enums %} 93 {%- for enum in enums %}
93 using {{enum.name}} = {{enum.name}}; // Alias for definition in the parent name space. 94 using {{enum.name}} = {{enum.name}}; // Alias for definition in the parent name space.
94 {%- endfor %} 95 {%- endfor %}
95 {%- endif %} 96 {%- endif %}
96 97
97 {#--- Constants #} 98 {#--- Constants #}
98 {%- for constant in module.constants %} 99 {%- for constant in module.constants %}
99 {#- To be consistent with constants defined inside interfaces, only make 100 {{constant|format_constant_declaration}};
100 integral types compile-time constants. #}
101 {%- if constant.kind|is_integral_kind %}
102 const {{constant.kind|cpp_pod_type}} {{constant.name}} = {{constant|constant_val ue}};
103 {%- else %}
104 extern const {{constant.kind|cpp_pod_type}} {{constant.name}};
105 {%- endif %}
106 {%- endfor %} 101 {%- endfor %}
107 102
108 {#--- Interface Forward Declarations -#} 103 {#--- Interface Forward Declarations -#}
109 {% for interface in interfaces %} 104 {% for interface in interfaces %}
110 class {{interface.name}}; 105 class {{interface.name}};
111 using {{interface.name}}Ptr = mojo::InterfacePtr<{{interface.name}}>; 106 using {{interface.name}}Ptr = mojo::InterfacePtr<{{interface.name}}>;
112 using {{interface.name}}PtrInfo = mojo::InterfacePtrInfo<{{interface.name}}>; 107 using {{interface.name}}PtrInfo = mojo::InterfacePtrInfo<{{interface.name}}>;
113 using ThreadSafe{{interface.name}}Ptr = 108 using ThreadSafe{{interface.name}}Ptr =
114 mojo::ThreadSafeInterfacePtr<{{interface.name}}>; 109 mojo::ThreadSafeInterfacePtr<{{interface.name}}>;
115 using {{interface.name}}Request = mojo::InterfaceRequest<{{interface.name}}>; 110 using {{interface.name}}Request = mojo::InterfaceRequest<{{interface.name}}>;
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 {#--- Union Serialization Helpers -#} 216 {#--- Union Serialization Helpers -#}
222 {% if unions %} 217 {% if unions %}
223 {%- for union in unions %} 218 {%- for union in unions %}
224 {% include "union_traits_declaration.tmpl" %} 219 {% include "union_traits_declaration.tmpl" %}
225 {%- endfor %} 220 {%- endfor %}
226 {%- endif %} 221 {%- endif %}
227 222
228 } // namespace mojo 223 } // namespace mojo
229 224
230 #endif // {{header_guard}} 225 #endif // {{header_guard}}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698