mirror of https://github.com/kivy/pyjnius.git
accept python string as a valid argument for [B and [C
This commit is contained in:
parent
3fe55c1bb2
commit
5ec6d80ba3
|
@ -76,13 +76,18 @@ cdef void populate_args(JNIEnv *j_env, tuple definition_args, jvalue *j_args, ar
|
|||
elif argtype[0] == '[':
|
||||
if py_arg is None:
|
||||
j_args[index].l = NULL
|
||||
else:
|
||||
if not isinstance(py_arg, list) and \
|
||||
not isinstance(py_arg, tuple):
|
||||
raise JavaException('Expecting a python list/tuple, got '
|
||||
'{0!r}'.format(py_arg))
|
||||
j_args[index].l = convert_pyarray_to_java(
|
||||
j_env, argtype[1:], py_arg)
|
||||
continue
|
||||
if isinstance(py_arg, basestring):
|
||||
if argtype == '[B':
|
||||
py_arg = map(ord, py_arg)
|
||||
elif argtype == '[C':
|
||||
py_arg = list(py_arg)
|
||||
if not isinstance(py_arg, list) and \
|
||||
not isinstance(py_arg, tuple):
|
||||
raise JavaException('Expecting a python list/tuple, got '
|
||||
'{0!r}'.format(py_arg))
|
||||
j_args[index].l = convert_pyarray_to_java(
|
||||
j_env, argtype[1:], py_arg)
|
||||
|
||||
|
||||
cdef convert_jobject_to_python(JNIEnv *j_env, bytes definition, jobject j_object):
|
||||
|
|
|
@ -198,7 +198,12 @@ cdef int calculate_score(sign_args, args, is_varargs=False) except *:
|
|||
if r[0] == '[':
|
||||
|
||||
if arg is None:
|
||||
return 10
|
||||
score += 10
|
||||
continue
|
||||
|
||||
if (r == '[B' or r == '[C') and isinstance(arg, basestring):
|
||||
score += 10
|
||||
continue
|
||||
|
||||
if not isinstance(arg, tuple) and not isinstance(arg, list):
|
||||
return -1
|
||||
|
|
Loading…
Reference in New Issue