OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Extracts native methods from a Java file and generates the JNI bindings. | 6 """Extracts native methods from a Java file and generates the JNI bindings. |
7 If you change this, please run and update the tests.""" | 7 If you change this, please run and update the tests.""" |
8 | 8 |
9 import collections | 9 import collections |
10 import errno | 10 import errno |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 | 202 |
203 re_additional_imports = re.compile( | 203 re_additional_imports = re.compile( |
204 r'@JNIAdditionalImport\(\s*{?(?P<class_names>.*?)}?\s*\)') | 204 r'@JNIAdditionalImport\(\s*{?(?P<class_names>.*?)}?\s*\)') |
205 for match in re.finditer(re_additional_imports, contents): | 205 for match in re.finditer(re_additional_imports, contents): |
206 for class_name in match.group('class_names').split(','): | 206 for class_name in match.group('class_names').split(','): |
207 JniParams.AddAdditionalImport(class_name.strip()) | 207 JniParams.AddAdditionalImport(class_name.strip()) |
208 | 208 |
209 @staticmethod | 209 @staticmethod |
210 def ParseJavaPSignature(signature_line): | 210 def ParseJavaPSignature(signature_line): |
211 prefix = 'Signature: ' | 211 prefix = 'Signature: ' |
212 return '"%s"' % signature_line[signature_line.index(prefix) + len(prefix):] | 212 index = signature_line.find(prefix) |
| 213 if index == -1: |
| 214 prefix = 'descriptor: ' |
| 215 index = signature_line.index(prefix) |
| 216 return '"%s"' % signature_line[index + len(prefix):] |
213 | 217 |
214 @staticmethod | 218 @staticmethod |
215 def JavaToJni(param): | 219 def JavaToJni(param): |
216 """Converts a java param into a JNI signature type.""" | 220 """Converts a java param into a JNI signature type.""" |
217 pod_param_map = { | 221 pod_param_map = { |
218 'int': 'I', | 222 'int': 'I', |
219 'boolean': 'Z', | 223 'boolean': 'Z', |
220 'char': 'C', | 224 'char': 'C', |
221 'short': 'S', | 225 'short': 'S', |
222 'long': 'J', | 226 'long': 'J', |
(...skipping 1293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1516 GenerateJNIHeader(input_file, output_file, options) | 1520 GenerateJNIHeader(input_file, output_file, options) |
1517 | 1521 |
1518 if options.depfile: | 1522 if options.depfile: |
1519 build_utils.WriteDepfile( | 1523 build_utils.WriteDepfile( |
1520 options.depfile, | 1524 options.depfile, |
1521 build_utils.GetPythonDependencies()) | 1525 build_utils.GetPythonDependencies()) |
1522 | 1526 |
1523 | 1527 |
1524 if __name__ == '__main__': | 1528 if __name__ == '__main__': |
1525 sys.exit(main(sys.argv)) | 1529 sys.exit(main(sys.argv)) |
OLD | NEW |