Chromium Code Reviews| 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 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 349 return '"' + ''.join(items) + '"' | 349 return '"' + ''.join(items) + '"' |
| 350 | 350 |
| 351 @staticmethod | 351 @staticmethod |
| 352 def Parse(params): | 352 def Parse(params): |
| 353 """Parses the params into a list of Param objects.""" | 353 """Parses the params into a list of Param objects.""" |
| 354 if not params: | 354 if not params: |
| 355 return [] | 355 return [] |
| 356 ret = [] | 356 ret = [] |
| 357 for p in [p.strip() for p in params.split(',')]: | 357 for p in [p.strip() for p in params.split(',')]: |
| 358 items = p.split(' ') | 358 items = p.split(' ') |
| 359 | |
| 360 # Remove @Annotations from parameters. | |
| 361 if items[0][0] is '@': | |
|
PEConn
2016/08/23 15:30:12
It'd be really cool if we could do some magic that
Bernhard Bauer
2016/08/23 15:33:08
Hm, but we only use @IntDef enums, which are just
Torne
2016/08/23 15:40:03
I'd prefer "if items[0].startswith('@')" - and als
Bernhard Bauer
2016/08/25 10:29:05
OK, I'm now handling any number of annotations, bu
| |
| 362 del items[0] | |
| 363 | |
| 359 if 'final' in items: | 364 if 'final' in items: |
| 360 items.remove('final') | 365 items.remove('final') |
| 366 | |
| 361 param = Param( | 367 param = Param( |
| 362 datatype=items[0], | 368 datatype=items[0], |
| 363 name=(items[1] if len(items) > 1 else 'p%s' % len(ret)), | 369 name=(items[1] if len(items) > 1 else 'p%s' % len(ret)), |
| 364 ) | 370 ) |
| 365 ret += [param] | 371 ret += [param] |
| 366 return ret | 372 return ret |
| 367 | 373 |
| 368 | 374 |
| 369 def ExtractJNINamespace(contents): | 375 def ExtractJNINamespace(contents): |
| 370 re_jni_namespace = re.compile('.*?@JNINamespace\("(.*?)"\)') | 376 re_jni_namespace = re.compile('.*?@JNINamespace\("(.*?)"\)') |
| (...skipping 1002 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1373 GenerateJNIHeader(input_file, output_file, options) | 1379 GenerateJNIHeader(input_file, output_file, options) |
| 1374 | 1380 |
| 1375 if options.depfile: | 1381 if options.depfile: |
| 1376 build_utils.WriteDepfile( | 1382 build_utils.WriteDepfile( |
| 1377 options.depfile, | 1383 options.depfile, |
| 1378 build_utils.GetPythonDependencies()) | 1384 build_utils.GetPythonDependencies()) |
| 1379 | 1385 |
| 1380 | 1386 |
| 1381 if __name__ == '__main__': | 1387 if __name__ == '__main__': |
| 1382 sys.exit(main(sys.argv)) | 1388 sys.exit(main(sys.argv)) |
| OLD | NEW |