Copy /micropython-master/py/*.{c,h} into my C++ project's source tree /myProj/uPy/py/
Next I get /micropython-master/unix/ to build, which creates /micropython-master/unix/build/genhdr/qstrdefs.generated.h which I also copy to /myProj/uPy/
Search /myProj/uPy/py/qstr.{c,h} for "qstrdefs.generated.h", and modify TWO #include-s to:
Code: Select all
#include "qstrdefs.generated.h"
Code: Select all
#ifndef NULL
#define NULL 0
#endif
#define MICROPY_NLR_SETJMP (1)
Code: Select all
#include "mpconfig.h"
#include "nlr.h" // <-- port specific nlr_jmp_fail
#include "misc.h"
#include "qstr.h"
#include "lexer.h" // <-- port specific at bottom
//#include "parse.h"
#include "obj.h"
//#include "parsehelper.h"
//#include "compile.h"
//#include "runtime0.h"
//#include "runtime.h"
//#include "repl.h"
void gc_collect(void) {
}
mp_lexer_t *mp_lexer_new_from_file(const char *filename) {
return NULL;
}
mp_import_stat_t mp_import_stat(const char *path) {
return MP_IMPORT_STAT_NO_EXIST;
}
mp_obj_t mp_builtin_open(uint n_args, const mp_obj_t *args) {
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_open_obj, 1, 2, mp_builtin_open);
void nlr_jump_fail(void *val) {
}
Tomorrow I will set about trying to get it up and running.
As far as I am aware from talking with dhylands, two further modifications are required:
1. implementing gc_collect so that it to(a) informs µPy of all external references C++-land holds on Python objects, so µPy doesn't garbage collect them and (b) prods µPy to do its own internal checking
2. implementing mp_builtin_open, so that µPy can open files, and #import will work
π