summaryrefslogtreecommitdiff
path: root/base/android/jni_generator
diff options
context:
space:
mode:
Diffstat (limited to 'base/android/jni_generator')
-rwxr-xr-xbase/android/jni_generator/jni_generator.py25
-rwxr-xr-xbase/android/jni_generator/jni_generator_tests.py4
-rwxr-xr-xbase/android/jni_generator/jni_registration_generator.py11
3 files changed, 17 insertions, 23 deletions
diff --git a/base/android/jni_generator/jni_generator.py b/base/android/jni_generator/jni_generator.py
index ef676e26e1..b5bbe1b9ad 100755
--- a/base/android/jni_generator/jni_generator.py
+++ b/base/android/jni_generator/jni_generator.py
@@ -17,14 +17,7 @@ import sys
import textwrap
import zipfile
-CHROMIUM_SRC = os.path.join(
- os.path.dirname(__file__), os.pardir, os.pardir, os.pardir)
-BUILD_ANDROID_GYP = os.path.join(
- CHROMIUM_SRC, 'build', 'android', 'gyp')
-
-sys.path.append(BUILD_ANDROID_GYP)
-
-from util import build_utils
+from build.android.gyp.util import build_utils
# Match single line comments, multiline comments, character literals, and
@@ -53,7 +46,7 @@ _WRAPPERS_BY_INDENT = [
replace_whitespace=False,
subsequent_indent=' ' * (indent + 4),
break_long_words=False)
- for indent in xrange(50)] # 50 chosen experimentally.
+ for indent in range(50)] # 50 chosen experimentally.
class ParseError(Exception):
@@ -799,7 +792,7 @@ class JNIFromJavaSource(object):
@staticmethod
def CreateFromFile(java_file_name, options):
- contents = file(java_file_name).read()
+ contents = open(java_file_name).read()
fully_qualified_class = ExtractFullyQualifiedJavaClassName(java_file_name,
contents)
return JNIFromJavaSource(contents, fully_qualified_class, options)
@@ -856,7 +849,7 @@ const char kClassPath_${JAVA_CLASS}[] = \
"${JNI_CLASS_PATH}";
""")
- for full_clazz in classes.itervalues():
+ for full_clazz in classes.values():
values = {
'JAVA_CLASS': GetBinaryClassName(full_clazz),
'JNI_CLASS_PATH': full_clazz,
@@ -882,7 +875,7 @@ extern base::subtle::AtomicWord g_${JAVA_CLASS}_clazz;
JNI_REGISTRATION_EXPORT base::subtle::AtomicWord g_${JAVA_CLASS}_clazz = 0;
""" + class_getter)
- for full_clazz in classes.itervalues():
+ for full_clazz in classes.values():
values = {
'JAVA_CLASS': GetBinaryClassName(full_clazz),
}
@@ -1311,13 +1304,13 @@ def GenerateJNIHeader(input_file, output_file, options):
jni_from_java_source = JNIFromJavaSource.CreateFromFile(
input_file, options)
content = jni_from_java_source.GetContent()
- except ParseError, e:
- print e
+ except ParseError as e:
+ print(e)
sys.exit(1)
if output_file:
WriteOutput(output_file, content)
else:
- print content
+ print(content)
def WriteOutput(output_file, content):
@@ -1393,7 +1386,7 @@ See SampleForTests.java for more details.
input_file = options.input_file
else:
option_parser.print_help()
- print '\nError: Must specify --jar_file or --input_file.'
+ print('\nError: Must specify --jar_file or --input_file.')
return 1
output_file = None
if options.output_dir:
diff --git a/base/android/jni_generator/jni_generator_tests.py b/base/android/jni_generator/jni_generator_tests.py
index 12812a5c54..4e856befd2 100755
--- a/base/android/jni_generator/jni_generator_tests.py
+++ b/base/android/jni_generator/jni_generator_tests.py
@@ -53,7 +53,7 @@ class TestGenerator(unittest.TestCase):
dict_first = first.__dict__
dict_second = second.__dict__
self.assertEquals(dict_first.keys(), dict_second.keys())
- for key, value in dict_first.iteritems():
+ for key, value in dict_first.items():
if (type(value) is list and len(value) and
isinstance(type(value[0]), object)):
self.assertListEquals(value, second.__getattribute__(key))
@@ -64,7 +64,7 @@ class TestGenerator(unittest.TestCase):
def assertListEquals(self, first, second):
self.assertEquals(len(first), len(second))
- for i in xrange(len(first)):
+ for i in range(len(first)):
if isinstance(first[i], object):
self.assertObjEquals(first[i], second[i])
else:
diff --git a/base/android/jni_generator/jni_registration_generator.py b/base/android/jni_generator/jni_registration_generator.py
index 8c545f6d1b..f9c3fcd7a3 100755
--- a/base/android/jni_generator/jni_registration_generator.py
+++ b/base/android/jni_generator/jni_registration_generator.py
@@ -10,11 +10,12 @@ RegisterNonMainDexNatives(). Together, these will use manual JNI registration
to register all native methods that exist within an application."""
import argparse
-import jni_generator
import multiprocessing
import string
import sys
-from util import build_utils
+
+import jni_generator
+from build.android.gyp.util import build_utils
# All but FULL_CLASS_NAME, which is used only for sorting.
@@ -58,7 +59,7 @@ def GenerateJNIHeader(java_file_paths, output_file, args):
if output_file:
jni_generator.WriteOutput(output_file, header_content)
else:
- print header_content
+ print(header_content)
def _DictForPath(path):
@@ -244,7 +245,7 @@ ${KMETHODS}
ret = []
all_classes = self.helper.GetUniqueClasses(self.natives)
all_classes[self.class_name] = self.fully_qualified_class
- for clazz, full_clazz in all_classes.iteritems():
+ for clazz, full_clazz in all_classes.items():
kmethods = self._GetKMethodsString(clazz)
namespace_str = ''
if self.namespace:
@@ -321,7 +322,7 @@ def main(argv):
args.sources_files = build_utils.ParseGnList(args.sources_files)
if not args.sources_files:
- print '\nError: Must specify --sources_files.'
+ print('\nError: Must specify --sources_files.')
return 1
java_file_paths = []