Im wondering if this is the correct way:
Code: Select all
void *operator new(size_t size) {
return gc_alloc(size, 0);
}
void *operator new[](size_t size) {
return gc_alloc(size, 0);
}
void operator delete(void *p) {
gc_free(p);
}
void operator delete[](void *p) {
gc_free(p);
}
My micropython.mk is:
Code: Select all
CPPEXAMPLE_MOD_DIR := $(USERMOD_DIR)
# Add our source files to the respective variables.
SRC_USERMOD += $(CPPEXAMPLE_MOD_DIR)/ppl_module.c << here are the mp_rom_map_elem_t ppl_module_globals_table
SRC_USERMOD += $(CPPEXAMPLE_MOD_DIR)/sysmem.c << here I needed to reimplement syscall _sbrk. I think I can solve with new/delete overloading and redirecting to upy gc.
SRC_USERMOD += $(CPPEXAMPLE_MOD_DIR)/syscalls.c << here I reimplemented mocks of _read, _write, _lseek...needed by -lc
SRC_USERMOD_CXX += $(CPPEXAMPLE_MOD_DIR)/ppl.cpp << here are the upy<>cpp wrappers
# Add our module directory to the include path.
CFLAGS_USERMOD += -I$(CPPEXAMPLE_MOD_DIR)
CXXFLAGS_USERMOD += -I$(CPPEXAMPLE_MOD_DIR) -std=c++11
LDFLAGS_USERMOD += -lpointperfect - lstdc++ -lc -lm -L$(USERMOD_DIR)
Can someone with more experience guide me?