diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2015-09-25 17:11:24 -0700 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2015-09-26 08:49:12 -0700 |
commit | c0a79cc919f9a4b9d8ad1c9503284587580071f0 (patch) | |
tree | 81a8e2ad9876ee179ee2077d1d21a78cdbe6968f /unix/modjni.c | |
parent | 7e18d3b6ff54e422779362a65450a0ed7029f74d (diff) |
unix/modjni: Need to really use per-rettype Call*Method functions.
Diffstat (limited to 'unix/modjni.c')
-rw-r--r-- | unix/modjni.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/unix/modjni.c b/unix/modjni.c index 0eedd095e..cd3b6616e 100644 --- a/unix/modjni.c +++ b/unix/modjni.c @@ -359,11 +359,22 @@ STATIC mp_obj_t call_method(jobject obj, const char *name, jarray methods, bool JJ(ReleaseStringUTFChars, name_o, decl); return new_jobject(res); } else { - res = JJ(CallObjectMethodA, obj, method_id, jargs); - mp_obj_t ret = jvalue2py(ret_type, res); - JJ(ReleaseStringUTFChars, name_o, decl); - if (ret != MP_OBJ_NULL) { - return ret; + if (MATCH(ret_type, "void")) { + JJ(CallVoidMethodA, obj, method_id, jargs); + return mp_const_none; + } else if (MATCH(ret_type, "int")) { + jint res = JJ(CallIntMethodA, obj, method_id, jargs); + return mp_obj_new_int(res); + } else if (MATCH(ret_type, "boolean")) { + jboolean res = JJ(CallBooleanMethodA, obj, method_id, jargs); + return mp_obj_new_bool(res); + } else if (is_object_type(ret_type)) { + res = JJ(CallObjectMethodA, obj, method_id, jargs); + mp_obj_t ret = jvalue2py(ret_type, res); + JJ(ReleaseStringUTFChars, name_o, decl); + if (ret != MP_OBJ_NULL) { + return ret; + } } nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, "cannot handle return type")); } |