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

Side by Side Diff: mojo/public/tools/bindings/generators/cpp_templates/module.cc.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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 43
44 {%- for namespace in namespaces_as_array %} 44 {%- for namespace in namespaces_as_array %}
45 namespace {{namespace}} { 45 namespace {{namespace}} {
46 {%- endfor %} 46 {%- endfor %}
47 {%- if variant %} 47 {%- if variant %}
48 namespace {{variant}} { 48 namespace {{variant}} {
49 {%- endif %} 49 {%- endif %}
50 50
51 {#--- Constants #} 51 {#--- Constants #}
52 {%- for constant in module.constants %} 52 {%- for constant in module.constants %}
53 {%- if not constant.kind|is_integral_kind %} 53 {%- if constant.kind|is_string_kind %}
54 const {{constant.kind|cpp_pod_type}} {{constant.name}} = {{constant|constant_val ue}}; 54 const char {{constant.name}}[] = {{constant|constant_value}};
55 {%- endif %} 55 {%- endif %}
56 {%- endfor %} 56 {%- endfor %}
57 57
58 {#--- Struct Constants #} 58 {#--- Struct Constants #}
59 {%- for struct in structs %} 59 {%- for struct in structs %}
60 {%- for constant in struct.constants %} 60 {%- for constant in struct.constants %}
61 {%- if constant.kind|is_integral_kind %} 61 {%- if constant.kind|is_string_kind %}
62 const {{constant.kind|cpp_pod_type}} {{struct.name}}::{{constant.name}}; 62 const char {{struct.name}}::{{constant.name}}[] = {{constant|constant_value}};
63 {%- else %}
64 const {{constant.kind|cpp_pod_type}} {{struct.name}}::{{constant.name}} = {{cons tant|constant_value}};
65 {%- endif %} 63 {%- endif %}
66 {%- endfor %} 64 {%- endfor %}
67 {%- endfor %} 65 {%- endfor %}
68 66
69 {#--- Struct builder definitions #} 67 {#--- Struct builder definitions #}
70 {%- for struct in structs %} 68 {%- for struct in structs %}
71 {%- if not struct|is_native_only_kind %} 69 {%- if not struct|is_native_only_kind %}
72 {%- include "wrapper_class_definition.tmpl" %} 70 {%- include "wrapper_class_definition.tmpl" %}
73 {%- endif %} 71 {%- endif %}
74 {%- endfor %} 72 {%- endfor %}
(...skipping 29 matching lines...) Expand all
104 {%- include "union_traits_definition.tmpl" %} 102 {%- include "union_traits_definition.tmpl" %}
105 {%- endfor %} 103 {%- endfor %}
106 104
107 } // namespace mojo 105 } // namespace mojo
108 106
109 #if defined(__clang__) 107 #if defined(__clang__)
110 #pragma clang diagnostic pop 108 #pragma clang diagnostic pop
111 #elif defined(_MSC_VER) 109 #elif defined(_MSC_VER)
112 #pragma warning(pop) 110 #pragma warning(pop)
113 #endif 111 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698