esp8266: Update lexer constructors so they can raise exceptions.
parent
180045bce9
commit
52f8f5666a
|
@ -58,10 +58,7 @@ STATIC void str32_buf_free(void *sb_in) {
|
||||||
}
|
}
|
||||||
|
|
||||||
mp_lexer_t *mp_lexer_new_from_str32(qstr src_name, const char *str, mp_uint_t len, mp_uint_t free_len) {
|
mp_lexer_t *mp_lexer_new_from_str32(qstr src_name, const char *str, mp_uint_t len, mp_uint_t free_len) {
|
||||||
mp_lexer_str32_buf_t *sb = m_new_obj_maybe(mp_lexer_str32_buf_t);
|
mp_lexer_str32_buf_t *sb = m_new_obj(mp_lexer_str32_buf_t);
|
||||||
if (sb == NULL) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
sb->byte_off = (uint32_t)str & 3;
|
sb->byte_off = (uint32_t)str & 3;
|
||||||
sb->src_cur = (uint32_t*)(str - sb->byte_off);
|
sb->src_cur = (uint32_t*)(str - sb->byte_off);
|
||||||
sb->val = *sb->src_cur++ >> sb->byte_off * 8;
|
sb->val = *sb->src_cur++ >> sb->byte_off * 8;
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
#include "py/runtime0.h"
|
#include "py/runtime0.h"
|
||||||
#include "py/runtime.h"
|
#include "py/runtime.h"
|
||||||
#include "py/stackctrl.h"
|
#include "py/stackctrl.h"
|
||||||
|
#include "py/mperrno.h"
|
||||||
#include "py/mphal.h"
|
#include "py/mphal.h"
|
||||||
#include "py/gc.h"
|
#include "py/gc.h"
|
||||||
#include "lib/mp-readline/readline.h"
|
#include "lib/mp-readline/readline.h"
|
||||||
|
@ -111,7 +112,7 @@ void user_init(void) {
|
||||||
|
|
||||||
#if !MICROPY_VFS
|
#if !MICROPY_VFS
|
||||||
mp_lexer_t *mp_lexer_new_from_file(const char *filename) {
|
mp_lexer_t *mp_lexer_new_from_file(const char *filename) {
|
||||||
return NULL;
|
mp_raise_OSError(MP_ENOENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
mp_import_stat_t mp_import_stat(const char *path) {
|
mp_import_stat_t mp_import_stat(const char *path) {
|
||||||
|
|
Loading…
Reference in New Issue