mirror of https://github.com/kivy/pyjnius.git
varargs works!
at least for printf, and probably for other methods accepting Strings need more tests cases!
This commit is contained in:
parent
708b2d075f
commit
858bff6e25
|
@ -294,7 +294,7 @@ cdef jobject convert_pyarray_to_java(JNIEnv *j_env, definition, pyarray) except
|
|||
j_env[0].SetObjectArrayElement(
|
||||
j_env, <jobjectArray>ret, i, NULL)
|
||||
elif isinstance(arg, basestring) and \
|
||||
definition == 'Ljava/lang/String;':
|
||||
definition in ('Ljava/lang/String;', 'Ljava/lang/Object;'):
|
||||
j_string = j_env[0].NewStringUTF(
|
||||
j_env, <bytes>arg)
|
||||
j_env[0].SetObjectArrayElement(
|
||||
|
@ -309,9 +309,9 @@ cdef jobject convert_pyarray_to_java(JNIEnv *j_env, definition, pyarray) except
|
|||
j_env[0].SetObjectArrayElement(
|
||||
j_env, <jobjectArray>ret, i, jo.obj)
|
||||
else:
|
||||
raise JavaException('Invalid variable used for L array')
|
||||
raise JavaException('Invalid variable used for L array', definition, pyarray)
|
||||
|
||||
else:
|
||||
raise JavaException('Invalid array definition')
|
||||
raise JavaException('Invalid array definition', definition, pyarray)
|
||||
|
||||
return <jobject>ret
|
||||
|
|
|
@ -740,16 +740,16 @@ cdef class JavaMultipleMethod(object):
|
|||
|
||||
if score <= 0:
|
||||
continue
|
||||
scores.append((score, signature, args_))
|
||||
scores.append((score, signature))
|
||||
|
||||
if not scores:
|
||||
raise JavaException('No methods matching your arguments')
|
||||
scores.sort()
|
||||
score, signature, args_ = scores[-1]
|
||||
score, signature = scores[-1]
|
||||
|
||||
jm = methods[signature]
|
||||
jm.j_self = self.j_self
|
||||
return jm.__call__(*args_)
|
||||
return jm.__call__(*args)
|
||||
|
||||
|
||||
class JavaStaticMethod(JavaMethod):
|
||||
|
|
|
@ -13,4 +13,4 @@ class ImplementationTest(unittest.TestCase):
|
|||
def test_printf(self):
|
||||
System = autoclass('java.lang.System')
|
||||
System.out.printf('hi\n')
|
||||
System.out.printf('hi %s\n', 'jnius')
|
||||
System.out.printf('hi %s %s\n', 'jnius', 'other string')
|
||||
|
|
Loading…
Reference in New Issue