summaryrefslogtreecommitdiffstatshomepage
path: root/py/nativeglue.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2019-03-09 10:16:09 +1100
committerDamien George <damien.p.george@gmail.com>2019-03-14 12:22:25 +1100
commit3b973a5658025bb99f503fb15ba11884729ac77a (patch)
treed11ff8a6999d8be5ec16149dc17dbf77883927dc /py/nativeglue.c
parent28c2873d99a6dcd8978eea1161fc2346fed067d0 (diff)
downloadmicropython-3b973a5658025bb99f503fb15ba11884729ac77a.tar.gz
micropython-3b973a5658025bb99f503fb15ba11884729ac77a.zip
py: Move mp_native_type_from_qstr() from emitnative.c to nativeglue.c.
Diffstat (limited to 'py/nativeglue.c')
-rw-r--r--py/nativeglue.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/py/nativeglue.c b/py/nativeglue.c
index b7031a5d27..6e5bd6ce2e 100644
--- a/py/nativeglue.c
+++ b/py/nativeglue.c
@@ -41,6 +41,20 @@
#if MICROPY_EMIT_NATIVE
+int mp_native_type_from_qstr(qstr qst) {
+ switch (qst) {
+ case MP_QSTR_object: return MP_NATIVE_TYPE_OBJ;
+ case MP_QSTR_bool: return MP_NATIVE_TYPE_BOOL;
+ case MP_QSTR_int: return MP_NATIVE_TYPE_INT;
+ case MP_QSTR_uint: return MP_NATIVE_TYPE_UINT;
+ case MP_QSTR_ptr: return MP_NATIVE_TYPE_PTR;
+ case MP_QSTR_ptr8: return MP_NATIVE_TYPE_PTR8;
+ case MP_QSTR_ptr16: return MP_NATIVE_TYPE_PTR16;
+ case MP_QSTR_ptr32: return MP_NATIVE_TYPE_PTR32;
+ default: return -1;
+ }
+}
+
// convert a MicroPython 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);