aboutsummaryrefslogtreecommitdiff
path: root/py/nativeglue.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2016-01-15 15:20:43 +0000
committerDamien George <damien.p.george@gmail.com>2016-01-27 14:27:10 +0000
commit8f54c08691faa3dd859852d211230fd7d9791abd (patch)
tree5cc82db6ea4d9d6538c6a876a09592a85fca4242 /py/nativeglue.c
parent3d42aa07dd6e94942b3721ee42ba5454cd0edf55 (diff)
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)
Diffstat (limited to 'py/nativeglue.c')
-rw-r--r--py/nativeglue.c12
1 files changed, 10 insertions, 2 deletions
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) {