@@ -359,11 +359,22 @@ STATIC mp_obj_t call_method(jobject obj, const char *name, jarray methods, bool
359359 JJ (ReleaseStringUTFChars , name_o , decl );
360360 return new_jobject (res );
361361 } else {
362- res = JJ (CallObjectMethodA , obj , method_id , jargs );
363- mp_obj_t ret = jvalue2py (ret_type , res );
364- JJ (ReleaseStringUTFChars , name_o , decl );
365- if (ret != MP_OBJ_NULL ) {
366- return ret ;
362+ if (MATCH (ret_type , "void" )) {
363+ JJ (CallVoidMethodA , obj , method_id , jargs );
364+ return mp_const_none ;
365+ } else if (MATCH (ret_type , "int" )) {
366+ jint res = JJ (CallIntMethodA , obj , method_id , jargs );
367+ return mp_obj_new_int (res );
368+ } else if (MATCH (ret_type , "boolean" )) {
369+ jboolean res = JJ (CallBooleanMethodA , obj , method_id , jargs );
370+ return mp_obj_new_bool (res );
371+ } else if (is_object_type (ret_type )) {
372+ res = JJ (CallObjectMethodA , obj , method_id , jargs );
373+ mp_obj_t ret = jvalue2py (ret_type , res );
374+ JJ (ReleaseStringUTFChars , name_o , decl );
375+ if (ret != MP_OBJ_NULL ) {
376+ return ret ;
377+ }
367378 }
368379 nlr_raise (mp_obj_new_exception_msg_varg (& mp_type_TypeError , "cannot handle return type" ));
369380 }
0 commit comments