Skip to content

Commit

Permalink
Make jni_generator support the returing of the inner class.
Browse files Browse the repository at this point in the history
TEST=jni_generator_tests

BUG=


Review URL: https://chromiumcodereview.appspot.com/12604014

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@188784 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
ycheo@chromium.org committed Mar 18, 2013
1 parent d7a24e2 commit db5f70f
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion base/android/jni_generator/jni_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ def MangleCalledByNatives(called_by_natives):
RE_CALLED_BY_NATIVE = re.compile(
'@CalledByNative(?P<Unchecked>(Unchecked)*?)(?:\("(?P<annotation>.*)"\))?'
'\s+(?P<prefix>[\w ]*?)'
'\s*(?P<return_type>\w+(\[\])*?)'
'\s*(?P<return_type>[\w\.]+(\[\])*?)'
'\s+(?P<name>\w+)'
'\s*\((?P<params>[^\)]*)\)')

Expand Down
37 changes: 37 additions & 0 deletions base/android/jni_generator/jni_generator_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,9 @@ class InnerClass {}
@CalledByNative
public byte[][] returnArrayOfByteArray();
@CalledByNative
public Bitmap.CompressFormat getCompressFormat();
"""
jni_generator.JniParams.SetFullyQualifiedClass('org/chromium/Foo')
jni_generator.JniParams.ExtractImportsAndInnerClasses(test_data)
Expand Down Expand Up @@ -992,6 +995,17 @@ class InnerClass {}
env_call=('Void', ''),
unchecked=False,
),
CalledByNative(
return_type='Bitmap.CompressFormat',
system_class=False,
static=False,
name='getCompressFormat',
method_id_var_name='getCompressFormat',
java_class_name='',
params=[],
env_call=('Void', ''),
unchecked=False,
),
]
self.assertListEquals(golden_called_by_natives, called_by_natives)
h = jni_generator.InlHeaderFileGenerator('', 'org/chromium/TestJni',
Expand Down Expand Up @@ -1425,6 +1439,29 @@ class InnerClass {}
return ScopedJavaLocalRef<jobjectArray>(env, ret);
}
static base::subtle::AtomicWord g_TestJni_getCompressFormat = 0;
static ScopedJavaLocalRef<jobject> Java_TestJni_getCompressFormat(JNIEnv* env,
jobject obj) {
/* Must call RegisterNativesImpl() */
DCHECK(g_TestJni_clazz);
jmethodID method_id =
base::android::MethodID::LazyGet<
base::android::MethodID::TYPE_INSTANCE>(
env, g_TestJni_clazz,
"getCompressFormat",
"("
")"
"Landroid/graphics/Bitmap$CompressFormat;",
&g_TestJni_getCompressFormat);
jobject ret =
env->CallObjectMethod(obj,
method_id);
base::android::CheckException(env);
return ScopedJavaLocalRef<jobject>(env, ret);
}
// Step 3: RegisterNatives.
static bool RegisterNativesImpl(JNIEnv* env) {
Expand Down

0 comments on commit db5f70f

Please sign in to comment.