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

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

Issue 300223008: Add module annotation to specify the name of the java class for constants. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove expression Created 6 years, 7 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 | « mojo/public/interfaces/bindings/tests/sample_interfaces.mojom ('k') | 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_java_generator.py
diff --git a/mojo/public/tools/bindings/generators/mojom_java_generator.py b/mojo/public/tools/bindings/generators/mojom_java_generator.py
index 0b381270122f982c512769990be54e1f27a7f985..7d9110f0d5a4a818f40f1dd13545dad1c9e5c95f 100644
--- a/mojo/public/tools/bindings/generators/mojom_java_generator.py
+++ b/mojo/public/tools/bindings/generators/mojom_java_generator.py
@@ -78,14 +78,16 @@ def GetNameForElement(element):
return ConstantStyle(element.name)
raise Exception("Unexpected element: " % element)
+def ParseStringAttribute(attribute):
+ if isinstance(attribute, basestring):
+ return attribute
+ assert attribute[0] == 'EXPRESSION'
+ assert len(attribute[1]) == 1
+ return attribute[1][0][1:-1].encode('string_escape')
+
def GetPackage(module):
if 'JavaPackage' in module.attributes:
- package = module.attributes['JavaPackage']
- if isinstance(package, basestring):
- return package
- assert package[0] == 'EXPRESSION'
- assert len(package[1]) == 1
- return package[1][0][1:-1].encode('string_escape')
+ return ParseStringAttribute(module.attributes['JavaPackage'])
# Default package.
return "org.chromium.mojom." + module.namespace
@@ -135,6 +137,8 @@ def ExpressionToText(value, module):
lambda token: TranslateConstants(token, module)))
def GetConstantsMainEntityName(module):
+ if 'JavaConstantsClassName' in module.attributes:
+ return ParseStringAttribute(module.attributes['JavaConstantsClassName'])
# This constructs the name of the embedding classes for module level constants
# by extracting the mojom's filename and prepending it to Constants.
return (UpperCamelCase(module.path.split('/')[-1].rsplit('.', 1)[0]) +
« no previous file with comments | « mojo/public/interfaces/bindings/tests/sample_interfaces.mojom ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698