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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: mojo/public/tools/bindings/generators/cpp_templates/module.cc.tmpl
diff --git a/mojo/public/tools/bindings/generators/cpp_templates/module.cc.tmpl b/mojo/public/tools/bindings/generators/cpp_templates/module.cc.tmpl
index 4383acbd8facb7d68151dd36ae89b38288165187..2c66a85f87331a6946af9155dfb533501e99a28a 100644
--- a/mojo/public/tools/bindings/generators/cpp_templates/module.cc.tmpl
+++ b/mojo/public/tools/bindings/generators/cpp_templates/module.cc.tmpl
@@ -50,18 +50,16 @@ namespace {{variant}} {
{#--- Constants #}
{%- for constant in module.constants %}
-{%- if not constant.kind|is_integral_kind %}
-const {{constant.kind|cpp_pod_type}} {{constant.name}} = {{constant|constant_value}};
+{%- if constant.kind|is_string_kind %}
+const char {{constant.name}}[] = {{constant|constant_value}};
{%- endif %}
{%- endfor %}
{#--- Struct Constants #}
{%- for struct in structs %}
{%- for constant in struct.constants %}
-{%- if constant.kind|is_integral_kind %}
-const {{constant.kind|cpp_pod_type}} {{struct.name}}::{{constant.name}};
-{%- else %}
-const {{constant.kind|cpp_pod_type}} {{struct.name}}::{{constant.name}} = {{constant|constant_value}};
+{%- if constant.kind|is_string_kind %}
+const char {{struct.name}}::{{constant.name}}[] = {{constant|constant_value}};
{%- endif %}
{%- endfor %}
{%- endfor %}

Powered by Google App Engine
This is Rietveld 408576698