Chromium Code Reviews| 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..fc96ec965b513e445ee293fe5a5fa556c9b32dec 100755 |
| --- a/base/android/jni_generator/jni_generator.py |
| +++ b/base/android/jni_generator/jni_generator.py |
| @@ -162,6 +162,18 @@ class JniParams(object): |
| JniParams._package = '/'.join(fully_qualified_class.split('/')[:-1]) |
| @staticmethod |
| + def AddAdditionalImport(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('/', '.'))) |
| + print 'Adding ' + new_import |
|
bulach
2014/05/22 16:40:00
nit: remove
qsr
2014/05/22 16:47:55
Done.
|
| + JniParams._imports += [new_import] |
| + |
| + @staticmethod |
| def ExtractImportsAndInnerClasses(contents): |
| if not JniParams._package: |
| raise RuntimeError('SetFullyQualifiedClass must be called before ' |
| @@ -178,18 +190,16 @@ class JniParams(object): |
| JniParams._inner_classes += [JniParams._fully_qualified_class + '$' + |
| inner] |
| - re_additional_imports = re.compile( |
| + re_additional_import = re.compile( |
| r'@JNIAdditionalImport\((?P<class_name>\w+?)\.class\)') |
| + for match in re.finditer(re_additional_import, contents): |
| + JniParams.AddAdditionalImport(match.group('class_name')) |
| + |
| + re_additional_imports = re.compile( |
| + r'@JNIAdditionalImport\({(?P<class_names>.*?)}\)') |
|
bulach
2014/05/22 16:40:00
shouldn't this be sufficient, i.e., remove 193-197
qsr
2014/05/22 16:47:55
Not necessarly, you can use @JNIAdditionalImport(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()[:-6]) |
|
bulach
2014/05/22 16:40:00
hmm, the -6 seems out of place here.
how about jus
qsr
2014/05/22 16:47:55
Done.
|
| @staticmethod |
| def ParseJavaPSignature(signature_line): |