From 8f54c08691faa3dd859852d211230fd7d9791abd Mon Sep 17 00:00:00 2001 From: Damien George Date: Fri, 15 Jan 2016 15:20:43 +0000 Subject: py/inlineasm: Add ability to specify return type of asm_thumb funcs. Supported return types are: object, bool, int, uint. For example: @micropython.asm_thumb def foo(r0, r1) -> uint: add(r0, r0, r1) --- py/nativeglue.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'py/nativeglue.c') diff --git a/py/nativeglue.c b/py/nativeglue.c index 3220996f9..cc0d61ce9 100644 --- a/py/nativeglue.c +++ b/py/nativeglue.c @@ -34,14 +34,14 @@ #include "py/emitglue.h" #include "py/bc.h" -#if MICROPY_EMIT_NATIVE - #if 0 // print debugging info #define DEBUG_printf DEBUG_printf #else // don't print debugging info #define DEBUG_printf(...) (void)0 #endif +#if MICROPY_EMIT_NATIVE + // convert a Micro Python object to a valid native value based on type mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type) { DEBUG_printf("mp_convert_obj_to_native(%p, " UINT_FMT ")\n", obj, type); @@ -61,6 +61,10 @@ mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type) { } } +#endif + +#if MICROPY_EMIT_NATIVE || MICROPY_EMIT_INLINE_THUMB + // convert a native value to a Micro Python object based on type mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type) { DEBUG_printf("mp_convert_native_to_obj(" UINT_FMT ", " UINT_FMT ")\n", val, type); @@ -73,6 +77,10 @@ mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type) { } } +#endif + +#if MICROPY_EMIT_NATIVE + // wrapper that accepts n_args and n_kw in one argument // (native emitter can only pass at most 3 arguments to a function) mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, mp_uint_t n_args_kw, const mp_obj_t *args) { -- cgit v1.2.3