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

Unified Diff: mojo/public/tools/bindings/generators/mojom_cpp_generator.py

Issue 2721953003: Makes mojo generator generate export for constants (Closed)
Patch Set: global Created 3 years, 10 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/tools/bindings/generators/mojom_cpp_generator.py
diff --git a/mojo/public/tools/bindings/generators/mojom_cpp_generator.py b/mojo/public/tools/bindings/generators/mojom_cpp_generator.py
index c75013badf88a19cab5a678a1b77174e20c877fc..82888e95f088d74d21239128c40efe951dce3c74 100644
--- a/mojo/public/tools/bindings/generators/mojom_cpp_generator.py
+++ b/mojo/public/tools/bindings/generators/mojom_cpp_generator.py
@@ -39,6 +39,7 @@ _for_blink = False
# TODO(rockot, yzshen): The variant handling is kind of a hack currently. Make
# it right.
_variant = None
+_export_attribute = None
class _NameFormatter(object):
@@ -220,7 +221,8 @@ def FormatConstantDeclaration(constant, nested=False):
if mojom.IsStringKind(constant.kind):
if nested:
return "const char %s[]" % constant.name
- return "extern const char %s[]" % constant.name
+ return "%sextern const char %s[]" % \
+ ((_export_attribute + " ") if _export_attribute else "", constant.name)
return "constexpr %s %s = %s" % (GetCppPodType(constant.kind), constant.name,
ConstantValue(constant))
@@ -730,6 +732,8 @@ class Generator(generator.Generator):
_use_once_callback = self.use_once_callback
global _variant
_variant = self.variant
+ global _export_attribute
+ _export_attribute = self.export_attribute
suffix = "-%s" % self.variant if self.variant else ""
self.Write(self.GenerateModuleHeader(),
self.MatchMojomFilePath("%s%s.h" % (self.module.name, suffix)))
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698