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

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: 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
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 e4f2b431abcb5df0a4a9547687f2d80e903d1af1..1057c30d1b5be5fb5aa7476764da2381356ee103 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]) +

Powered by Google App Engine
This is Rietveld 408576698