From 52e062ef3396bb94381073547f0dff7b36a6815d Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Wed, 16 Mar 2016 17:42:37 +0700 Subject: [PATCH] py/frozenmod: Allow port to override lexer to use for frozen modules. --- py/frozenmod.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/py/frozenmod.c b/py/frozenmod.c index 9eea1dbcfc..6b76bf662b 100644 --- a/py/frozenmod.c +++ b/py/frozenmod.c @@ -32,6 +32,12 @@ #if MICROPY_MODULE_FROZEN +#ifndef MICROPY_MODULE_FROZEN_LEXER +#define MICROPY_MODULE_FROZEN_LEXER mp_lexer_new_from_str_len +#else +mp_lexer_t *MICROPY_MODULE_FROZEN_LEXER(qstr src_name, const char *str, mp_uint_t len, mp_uint_t free_len); +#endif + extern const char mp_frozen_names[]; extern const uint32_t mp_frozen_sizes[]; extern const char mp_frozen_content[]; @@ -43,7 +49,7 @@ mp_lexer_t *mp_find_frozen_module(const char *str, int len) { for (int i = 0; *name != 0; i++) { int l = strlen(name); if (l == len && !memcmp(str, name, l)) { - mp_lexer_t *lex = mp_lexer_new_from_str_len(MP_QSTR_, mp_frozen_content + offset, mp_frozen_sizes[i], 0); + mp_lexer_t *lex = MICROPY_MODULE_FROZEN_LEXER(MP_QSTR_, mp_frozen_content + offset, mp_frozen_sizes[i], 0); return lex; } name += l + 1;