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

Unified Diff: base/android/jni_generator/jni_generator.py

Issue 298973005: Updating JNIAdditionalImport to allow more than one import. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix tests 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: base/android/jni_generator/jni_generator.py
diff --git a/base/android/jni_generator/jni_generator.py b/base/android/jni_generator/jni_generator.py
index 7a6a163bb759b90cc477d8f1f1894dda53776ac5..a1a654a472bbcfeefd4e2240c1138eff3fe55f8f 100755
--- a/base/android/jni_generator/jni_generator.py
+++ b/base/android/jni_generator/jni_generator.py
@@ -162,6 +162,19 @@ class JniParams(object):
JniParams._package = '/'.join(fully_qualified_class.split('/')[:-1])
@staticmethod
+ def AddAdditionalImport(class_name):
+ assert class_name.endswith('.class')
+ raw_class_name = class_name[:-len('.class')]
+ if '.' in raw_class_name:
+ raise SyntaxError('%s cannot be used in @JNIAdditionalImport. '
+ 'Only import unqualified outer classes.' % class_name)
+ new_import = 'L%s/%s' % (JniParams._package, raw_class_name)
+ if new_import in JniParams._imports:
+ raise SyntaxError('Do not use JNIAdditionalImport on an already '
+ 'imported class: %s' % (new_import.replace('/', '.')))
+ JniParams._imports += [new_import]
+
+ @staticmethod
def ExtractImportsAndInnerClasses(contents):
if not JniParams._package:
raise RuntimeError('SetFullyQualifiedClass must be called before '
@@ -179,17 +192,10 @@ class JniParams(object):
inner]
re_additional_imports = re.compile(
- r'@JNIAdditionalImport\((?P<class_name>\w+?)\.class\)')
+ r'@JNIAdditionalImport\(\s*{?(?P<class_names>.*?)}?\s*\)')
for match in re.finditer(re_additional_imports, contents):
- class_name = match.group('class_name')
- if '.' in class_name:
- raise SyntaxError('*.class cannot be used in @JNIAdditionalImport. '
- 'Only import unqualified outer classes.' % class_name)
- new_import = 'L%s/%s' % (JniParams._package, class_name)
- if new_import in JniParams._imports:
- raise SyntaxError('Do not use JNIAdditionalImport on an already '
- 'imported class: %s' % (new_import.replace('/', '.')))
- JniParams._imports += [new_import]
+ for class_name in match.group('class_names').split(','):
+ JniParams.AddAdditionalImport(class_name.strip())
@staticmethod
def ParseJavaPSignature(signature_line):

Powered by Google App Engine
This is Rietveld 408576698