mirror of https://github.com/kivy/pyjnius.git
basic support for output args. works only in the original type allow slice assignment. We gently ignore TypeError if the assignation didnt work. closes #58
This commit is contained in:
parent
8e2564ccc8
commit
481b3e5d30
|
@ -12,6 +12,11 @@ cdef void release_args(JNIEnv *j_env, tuple definition_args, jvalue *j_args, arg
|
|||
argtype in ('Ljava/lang/String;', 'Ljava/lang/Object;'):
|
||||
j_env[0].DeleteLocalRef(j_env, j_args[index].l)
|
||||
elif argtype[0] == '[':
|
||||
ret = convert_jarray_to_python(j_env, argtype[1:], j_args[index].l)
|
||||
try:
|
||||
args[index][:] = ret
|
||||
except TypeError:
|
||||
pass
|
||||
j_env[0].DeleteLocalRef(j_env, j_args[index].l)
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
import unittest
|
||||
from jnius import autoclass
|
||||
|
||||
class OutputArgs(unittest.TestCase):
|
||||
|
||||
def test_string_output_args(self):
|
||||
String = autoclass('java.lang.String')
|
||||
string = String('word'.encode('utf-8'))
|
||||
btarray= [0] * 4
|
||||
string.getBytes(0, 4, btarray, 0)
|
||||
self.assertEquals(btarray, [119, 111, 114, 100])
|
Loading…
Reference in New Issue