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 782e76a6611abe063e5a3164b4fdc88d59ae509d..eaff24da9d6511e81ff3c2ff624cd437996c3a26 100755 |
| --- a/base/android/jni_generator/jni_generator.py |
| +++ b/base/android/jni_generator/jni_generator.py |
| @@ -53,7 +53,7 @@ class NativeMethod(object): |
| assert type(self.params) is list |
| assert type(self.params[0]) is Param |
| if (self.params and |
| - self.params[0].datatype == 'int' and |
| + self.params[0].datatype == kwargs.get('ptr_type', 'int') and |
| self.params[0].name.startswith('native')): |
| self.type = 'method' |
| self.p0_type = self.params[0].name[len('native'):] |
| @@ -290,7 +290,7 @@ def ExtractFullyQualifiedJavaClassName(java_file_name, contents): |
| os.path.splitext(os.path.basename(java_file_name))[0]) |
| -def ExtractNatives(contents): |
| +def ExtractNatives(contents, options): |
| """Returns a list of dict containing information about a native method.""" |
| contents = contents.replace('\n', '') |
| natives = [] |
| @@ -307,7 +307,8 @@ def ExtractNatives(contents): |
| native_class_name=match.group('native_class_name'), |
| return_type=match.group('return_type'), |
| name=match.group('name').replace('native', ''), |
| - params=JniParams.Parse(match.group('params'))) |
| + params=JniParams.Parse(match.group('params')), |
| + ptr_type=options.ptr_type) |
| natives += [native] |
| return natives |
| @@ -530,7 +531,7 @@ class JNIFromJavaSource(object): |
| JniParams.SetFullyQualifiedClass(fully_qualified_class) |
| JniParams.ExtractImportsAndInnerClasses(contents) |
| jni_namespace = ExtractJNINamespace(contents) |
| - natives = ExtractNatives(contents) |
| + natives = ExtractNatives(contents, options) |
|
rmcilroy
2013/10/29 11:12:00
nit - Unless you think other fields in the "option
bulach
2013/10/29 18:22:20
good point, done.
|
| called_by_natives = ExtractCalledByNatives(contents) |
| if len(natives) == 0 and len(called_by_natives) == 0: |
| raise SyntaxError('Unable to find any JNI methods for %s.' % |
| @@ -1073,6 +1074,10 @@ See SampleForTests.java for more details. |
| option_parser.add_option('--script_name', default=GetScriptName(), |
| help='The name of this script in the generated ' |
| 'header.') |
| + option_parser.add_option('--ptr_type', default='int', |
| + type='choice', choices=['int', 'long'], |
| + help='The type of "p0" to be cast to a native ' |
|
rmcilroy
2013/10/29 11:12:00
nit - the reference to "p0" is a bit obscure. How
Andrew Hayden (chromium.org)
2013/10/29 11:49:21
Or even more explicitly:
"The type used to represe
bulach
2013/10/29 18:22:20
Done.
|
| + 'pointer.') |
| options, args = option_parser.parse_args(argv) |
| if options.jar_file: |
| input_file = ExtractJarInputFile(options.jar_file, options.input_file, |