mirror of https://github.com/kivy/pyjnius.git
allow to use python list and tuple as Object params
This commit is contained in:
parent
78a68134ae
commit
20b4bd5d62
|
@ -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(
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue