modffi: Support void (None) return value for Python callback functions.

This commit is contained in:
Paul Sokolovsky 2014-12-16 00:28:02 +02:00
parent 7a4765dbeb
commit 0078561303

View File

@ -211,8 +211,10 @@ STATIC void call_py_func(ffi_cif *cif, void *ret, void** args, mp_obj_t func) {
} }
mp_obj_t res = mp_call_function_n_kw(func, cif->nargs, 0, pyargs); mp_obj_t res = mp_call_function_n_kw(func, cif->nargs, 0, pyargs);
if (res != mp_const_none) {
*(ffi_arg*)ret = mp_obj_int_get_truncated(res); *(ffi_arg*)ret = mp_obj_int_get_truncated(res);
} }
}
STATIC mp_obj_t mod_ffi_callback(mp_obj_t rettype_in, mp_obj_t func_in, mp_obj_t paramtypes_in) { STATIC mp_obj_t mod_ffi_callback(mp_obj_t rettype_in, mp_obj_t func_in, mp_obj_t paramtypes_in) {
const char *rettype = mp_obj_str_get_str(rettype_in); const char *rettype = mp_obj_str_get_str(rettype_in);