allow to use python list and tuple as Object params

This commit is contained in:
Amirouche Boubekki 2012-10-01 01:21:24 +02:00
parent 78a68134ae
commit 20b4bd5d62
3 changed files with 11 additions and 0 deletions

View File

@ -52,6 +52,8 @@ cdef void populate_args(JNIEnv *j_env, list definition_args, jvalue *j_args, arg
elif isinstance(py_arg, JavaObject):
jo = py_arg
j_args[index].l = jo.obj
elif isinstance(py_arg, (tuple, list)):
j_args[index].l = convert_pyarray_to_java(j_env, argtype, py_arg)
else:
raise JavaException('Invalid python object for this '
'argument. Want {0!r}, got {1!r}'.format(

View File

@ -112,4 +112,8 @@ public class BasicsTest {
return false;
return (x[0].equals("hello") && x[1].equals("world"));
}
public boolean methodParamsObject(Object x) {
return true;
}
}

View File

@ -77,3 +77,8 @@ class BasicsTest(unittest.TestCase):
self.assertEquals(test.methodParamsArrayI([1, 2, 3]), True)
self.assertEquals(test.methodParamsArrayString([
'hello', 'world']), True)
def test_instances_methods_params_object_list_str(self):
test = autoclass('org.jnius.BasicsTest')()
self.assertEquals(test.methodParamsObject([
'hello', 'world']), True)