py: Factor out persistent-code reader into separate files.

Implementations of persistent-code reader are provided for POSIX systems
and systems using FatFS.  Macros to use these are MICROPY_READER_POSIX and
MICROPY_READER_FATFS respectively.  If an alternative implementation is
needed then a port can define the function mp_reader_new_file.
This commit is contained in:
Damien George
2016-11-16 16:04:57 +11:00
parent 6810f2c134
commit 6b239c271c
14 changed files with 316 additions and 121 deletions

View File

@@ -26,13 +26,9 @@
#ifndef MICROPY_INCLUDED_PY_PERSISTENTCODE_H
#define MICROPY_INCLUDED_PY_PERSISTENTCODE_H
#include "py/obj.h"
typedef struct _mp_reader_t {
void *data;
mp_uint_t (*read_byte)(void *data);
void (*close)(void *data);
} mp_reader_t;
#include "py/mpprint.h"
#include "py/reader.h"
#include "py/emitglue.h"
mp_raw_code_t *mp_raw_code_load(mp_reader_t *reader);
mp_raw_code_t *mp_raw_code_load_mem(const byte *buf, size_t len);