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:
Mathieu Virbel 2013-07-02 09:43:39 +02:00
parent 8e2564ccc8
commit 481b3e5d30
2 changed files with 16 additions and 0 deletions

View File

@ -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)

11
tests/test_output_args.py Normal file
View File

@ -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])