diff options
author | Damien George <damien.p.george@gmail.com> | 2019-11-05 11:41:39 +1100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2019-12-12 20:15:28 +1100 |
commit | 83f9fb169e5d9b9304e06237a747a30d3ea53458 (patch) | |
tree | 23d3dc794827719446e2f13a2eebfc725fbb122d | |
parent | 37817ab4ba5fa84624dc9715e01d6bd5a8d187b0 (diff) |
examples/natmod: Add uheapq example.
-rw-r--r-- | examples/natmod/uheapq/Makefile | 13 | ||||
-rw-r--r-- | examples/natmod/uheapq/uheapq.c | 17 |
2 files changed, 30 insertions, 0 deletions
diff --git a/examples/natmod/uheapq/Makefile b/examples/natmod/uheapq/Makefile new file mode 100644 index 000000000..55de3cc08 --- /dev/null +++ b/examples/natmod/uheapq/Makefile @@ -0,0 +1,13 @@ +# Location of top-level MicroPython directory +MPY_DIR = ../../.. + +# Name of module (different to built-in uheapq so it can coexist) +MOD = uheapq_$(ARCH) + +# Source files (.c or .py) +SRC = uheapq.c + +# Architecture to build for (x86, x64, armv7m, xtensa, xtensawin) +ARCH = x64 + +include $(MPY_DIR)/py/dynruntime.mk diff --git a/examples/natmod/uheapq/uheapq.c b/examples/natmod/uheapq/uheapq.c new file mode 100644 index 000000000..df880bd38 --- /dev/null +++ b/examples/natmod/uheapq/uheapq.c @@ -0,0 +1,17 @@ +#define MICROPY_ENABLE_DYNRUNTIME (1) +#define MICROPY_PY_UHEAPQ (1) + +#include "py/dynruntime.h" + +#include "extmod/moduheapq.c" + +mp_obj_t mpy_init(mp_obj_fun_bc_t *self, size_t n_args, size_t n_kw, mp_obj_t *args) { + MP_DYNRUNTIME_INIT_ENTRY + + mp_store_global(MP_QSTR___name__, MP_OBJ_NEW_QSTR(MP_QSTR_uheapq)); + mp_store_global(MP_QSTR_heappush, MP_OBJ_FROM_PTR(&mod_uheapq_heappush_obj)); + mp_store_global(MP_QSTR_heappop, MP_OBJ_FROM_PTR(&mod_uheapq_heappop_obj)); + mp_store_global(MP_QSTR_heapify, MP_OBJ_FROM_PTR(&mod_uheapq_heapify_obj)); + + MP_DYNRUNTIME_INIT_EXIT +} |