change CIRCUITPY change markers to CIRCUITPY-CHANGE
This commit is contained in:
parent
c0a4abc03c
commit
367e13c69f
@ -1,7 +1,7 @@
|
||||
# This makefile fragment adds the source code files for the core extmod modules
|
||||
# and provides rules to build 3rd-party components for extmod modules.
|
||||
|
||||
# CIRCUITPY has removed many extmod modules.
|
||||
# CIRCUITPY-CHANGE: many extmod modules removed
|
||||
SRC_EXTMOD_C += \
|
||||
extmod/modasyncio.c \
|
||||
extmod/modbinascii.c \
|
||||
|
@ -228,7 +228,7 @@ STATIC mp_obj_t task_cancel(mp_obj_t self_in) {
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(task_cancel_obj, task_cancel);
|
||||
|
||||
// CIRCUITPY provides __await__().
|
||||
// CIRCUITPY-CHANGE: CircuitPython provides __await__().
|
||||
STATIC mp_obj_t task_getiter(mp_obj_t self_in, mp_obj_iter_buf_t *iter_buf);
|
||||
|
||||
STATIC mp_obj_t task_await(mp_obj_t self_in) {
|
||||
|
@ -127,7 +127,7 @@ STATIC mp_obj_t mod_binascii_b2a_base64(size_t n_args, const mp_obj_t *pos_args,
|
||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||
uint8_t newline = args[ARG_newline].u_bool;
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
check_not_unicode(pos_args[0]);
|
||||
mp_buffer_info_t bufinfo;
|
||||
mp_get_buffer_raise(pos_args[0], &bufinfo, MP_BUFFER_READ);
|
||||
@ -182,7 +182,7 @@ STATIC mp_obj_t mod_binascii_b2a_base64(size_t n_args, const mp_obj_t *pos_args,
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(mod_binascii_b2a_base64_obj, 1, mod_binascii_b2a_base64);
|
||||
|
||||
// CIRCUITPY uses a self-contained implementation of CRC32,
|
||||
// CIRCUITPY-CHANGE: uses a self-contained implementation of CRC32,
|
||||
// instead of depending on uzlib, like MicroPython.
|
||||
|
||||
/*
|
||||
@ -223,7 +223,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(mod_binascii_b2a_base64_obj, 1, mod_binascii_b
|
||||
|
||||
STATIC mp_obj_t mod_binascii_crc32(size_t n_args, const mp_obj_t *args) {
|
||||
mp_buffer_info_t bufinfo;
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
check_not_unicode(args[0]);
|
||||
mp_get_buffer_raise(args[0], &bufinfo, MP_BUFFER_READ);
|
||||
uint32_t crc = (n_args > 1) ? mp_obj_get_int_truncated(args[1]) : 0;
|
||||
|
@ -130,7 +130,7 @@ typedef struct _json_stream_t {
|
||||
mp_obj_t stream_obj;
|
||||
mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode);
|
||||
int errcode;
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
mp_obj_t python_readinto[2 + 1];
|
||||
mp_obj_array_t bytearray_obj;
|
||||
size_t start;
|
||||
@ -154,7 +154,7 @@ STATIC byte json_stream_next(json_stream_t *s) {
|
||||
return s->cur;
|
||||
}
|
||||
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
|
||||
// We read from an object's `readinto` method in chunks larger than the json
|
||||
// parser needs to reduce the number of function calls done.
|
||||
@ -398,7 +398,7 @@ STATIC mp_obj_t _mod_json_load(mp_obj_t stream_obj, bool return_first_json) {
|
||||
}
|
||||
}
|
||||
success:
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
|
||||
// It is legal for a stream to have contents after JSON.
|
||||
// E.g., A UART is not closed after receiving an object; in load() we will
|
||||
|
@ -206,7 +206,7 @@ STATIC mp_obj_t re_exec(bool is_anchored, uint n_args, const mp_obj_t *args) {
|
||||
size_t len;
|
||||
subj.begin_line = subj.begin = mp_obj_str_get_data(args[1], &len);
|
||||
subj.end = subj.begin + len;
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
#if MICROPY_PY_RE_MATCH_SPAN_START_END && !(defined(MICROPY_ENABLE_DYNRUNTIME) && MICROPY_ENABLE_DYNRUNTIME)
|
||||
|
||||
if (n_args > 2) {
|
||||
|
@ -367,7 +367,7 @@ STATIC mp_uint_t poll_set_poll_until_ready_or_timeout(poll_set_t *poll_set, size
|
||||
if (n_ready > 0 || (timeout != (mp_uint_t)-1 && mp_hal_ticks_ms() - start_ticks >= timeout)) {
|
||||
return n_ready;
|
||||
}
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
RUN_BACKGROUND_TASKS;
|
||||
if (mp_hal_is_interrupted()) {
|
||||
return 0;
|
||||
@ -425,7 +425,7 @@ STATIC mp_obj_t select_select(size_t n_args, const mp_obj_t *args) {
|
||||
if (!mp_map_slot_is_filled(&poll_set.map, i)) {
|
||||
continue;
|
||||
}
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
RUN_BACKGROUND_TASKS;
|
||||
|
||||
poll_obj_t *poll_obj = MP_OBJ_TO_PTR(poll_set.map.table[i].value);
|
||||
|
@ -365,7 +365,7 @@ mp_obj_t mp_vfs_getcwd(void) {
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_0(mp_vfs_getcwd_obj, mp_vfs_getcwd);
|
||||
|
||||
// CIRCUITPY: accessible from shared-module/os/__init__.c
|
||||
// CIRCUITPY-CHANGE: accessible from shared-module/os/__init__.c
|
||||
mp_obj_t mp_vfs_ilistdir_it_iternext(mp_obj_t self_in) {
|
||||
mp_vfs_ilistdir_it_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
if (self->is_iter) {
|
||||
|
@ -257,7 +257,7 @@ STATIC mp_obj_t fat_vfs_open(mp_obj_t self_in, mp_obj_t path_in, mp_obj_t mode_i
|
||||
m_del_obj(pyb_file_obj_t, o);
|
||||
mp_raise_OSError_errno_str(fresult_to_errno_table[res], path_in);
|
||||
}
|
||||
// CIRCUITPY does fast seek.
|
||||
// CIRCUITPY-CHANGE: does fast seek.
|
||||
// If we're reading, turn on fast seek.
|
||||
if (mode == FA_READ) {
|
||||
// One call to determine how much space we need.
|
||||
|
@ -254,7 +254,7 @@ int re1_5_compilecode(ByteProg *prog, const char *re)
|
||||
return 0;
|
||||
}
|
||||
|
||||
// CIRCUITPY debug as main program
|
||||
// CIRCUITPY-CHANGE: debug as main program
|
||||
#if defined(DEBUG_COMPILECODE)
|
||||
#include <assert.h>
|
||||
void re1_5_fatal(char *x) {
|
||||
|
@ -262,13 +262,13 @@ include $(TOP)/py/mkrules.mk
|
||||
|
||||
.PHONY: test test_full
|
||||
|
||||
# CIRCUITPY: these two targets are ours
|
||||
# CIRCUITPY-CHANGE: these two targets are for CircuitPython builds
|
||||
.PHONY: print-failures clean-failures
|
||||
print-failures clean-failures:
|
||||
../../tests/run-tests.py --$@
|
||||
|
||||
|
||||
# CIRCUITPY: support for passing args to run-tests, like `make test TEST_ARGS="basics/*.py"`
|
||||
# CIRCUITPY-CHANGE: support for passing args to run-tests, like `make test TEST_ARGS="basics/*.py"`
|
||||
TEST_ARGS ?=
|
||||
test: $(BUILD)/$(PROG) $(TOP)/tests/run-tests.py
|
||||
$(eval DIRNAME=ports/$(notdir $(CURDIR)))
|
||||
|
@ -59,7 +59,7 @@ STATIC mp_obj_t mp_os_getenv(size_t n_args, const mp_obj_t *args) {
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_os_getenv_obj, 1, 2, mp_os_getenv);
|
||||
|
||||
// CIRCUITPY getenv differences
|
||||
// CIRCUITPY-CHANGE: getenv differences
|
||||
#if defined(MICROPY_UNIX_COVERAGE)
|
||||
STATIC mp_obj_t mp_os_getenv_int(mp_obj_t var_in) {
|
||||
mp_int_t value;
|
||||
|
@ -37,7 +37,7 @@
|
||||
// Variant-specific definitions.
|
||||
#include "mpconfigvariant.h"
|
||||
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
#define CIRCUITPY_MICROPYTHON_ADVANCED (1)
|
||||
#define MICROPY_PY_ASYNC_AWAIT (1)
|
||||
|
||||
@ -254,4 +254,5 @@ static inline unsigned long mp_random_seed_init(void) {
|
||||
#define MICROPY_PY_BLUETOOTH_ENABLE_L2CAP_CHANNELS (MICROPY_BLUETOOTH_NIMBLE)
|
||||
#endif
|
||||
|
||||
#define RUN_BACKGROUND_TASKS ((void)0) // CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
#define RUN_BACKGROUND_TASKS ((void)0)
|
||||
|
@ -8,7 +8,7 @@ MICROPY_FORCE_32BIT = 0
|
||||
# 1 - use MicroPython version of readline
|
||||
MICROPY_USE_READLINE = 1
|
||||
|
||||
# CIRCUITPY: not present
|
||||
# CIRCUITPY-CHANGE: not present
|
||||
# btree module using Berkeley DB 1.xx
|
||||
MICROPY_PY_BTREE = 0
|
||||
|
||||
@ -18,14 +18,14 @@ MICROPY_PY_THREAD = 1
|
||||
# Subset of CPython termios module
|
||||
MICROPY_PY_TERMIOS = 1
|
||||
|
||||
# CIRCUITPY: not present
|
||||
# CIRCUITPY-CHANGE: not present
|
||||
# Subset of CPython socket module
|
||||
MICROPY_PY_SOCKET = 0
|
||||
|
||||
# ffi module requires libffi (libffi-dev Debian package)
|
||||
MICROPY_PY_FFI = 1
|
||||
|
||||
# CIRCUITPY: not present
|
||||
# CIRCUITPY-CHANGE: not present
|
||||
# ssl module requires one of the TLS libraries below
|
||||
MICROPY_PY_SSL = 0
|
||||
# axTLS has minimal size but implements only a subset of modern TLS
|
||||
@ -33,7 +33,7 @@ MICROPY_PY_SSL = 0
|
||||
MICROPY_SSL_AXTLS = 0
|
||||
# mbedTLS is more up to date and complete implementation, but also
|
||||
# more bloated.
|
||||
# CIRCUITPY: not present
|
||||
# CIRCUITPY-CHANGE: not present
|
||||
MICROPY_SSL_MBEDTLS = 0
|
||||
|
||||
# jni module requires JVM/JNI
|
||||
@ -43,15 +43,15 @@ MICROPY_PY_JNI = 0
|
||||
# as submodules (currently affects only libffi).
|
||||
MICROPY_STANDALONE = 0
|
||||
|
||||
# CIRCUITPY: not used
|
||||
# CIRCUITPY-CHANGE: not used
|
||||
MICROPY_ROM_TEXT_COMPRESSION = 0
|
||||
|
||||
MICROPY_VFS_FAT = 1
|
||||
# CIRCUITPY: not used
|
||||
# CIRCUITPY-CHANGE: not used
|
||||
MICROPY_VFS_LFS1 = 0
|
||||
MICROPY_VFS_LFS2 = 0
|
||||
|
||||
# CIRCUITPY
|
||||
# CIRCUITPY-CHANGE
|
||||
CIRCUITPY_ULAB = 1
|
||||
MICROPY_EMIT_NATIVE = 0
|
||||
CFLAGS += -DCIRCUITPY=1
|
||||
|
@ -95,7 +95,7 @@ void mp_hal_set_interrupt_char(char c) {
|
||||
}
|
||||
}
|
||||
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
bool mp_hal_is_interrupted(void) {
|
||||
return false;
|
||||
}
|
||||
@ -192,7 +192,7 @@ main_term:;
|
||||
void mp_hal_stdout_tx_strn(const char *str, size_t len) {
|
||||
ssize_t ret;
|
||||
MP_HAL_RETRY_SYSCALL(ret, write(STDOUT_FILENO, str, len), {});
|
||||
// CIRCUITPY: need to conditionalize MICROPY_PY_OS_DUPTERM
|
||||
// CIRCUITPY-CHANGE: need to conditionalize MICROPY_PY_OS_DUPTERM
|
||||
#if MICROPY_PY_OS_DUPTERM
|
||||
mp_os_dupterm_tx_strn(str, len);
|
||||
#endif
|
||||
|
@ -42,7 +42,7 @@
|
||||
#define MICROPY_TRACKED_ALLOC (1)
|
||||
#define MICROPY_WARNINGS_CATEGORY (1)
|
||||
|
||||
// CIRCUITPY Disable things never used in circuitpython
|
||||
// CIRCUITPY-CHANGE: Disable things never used in circuitpython
|
||||
#define MICROPY_PY_CRYPTOLIB (0)
|
||||
#define MICROPY_PY_CRYPTOLIB_CTR (0)
|
||||
#define MICROPY_PY_STRUCT (0) // uses shared-bindings struct
|
||||
|
@ -215,7 +215,7 @@ long long mp_binary_get_int(size_t size, bool is_signed, bool big_endian, const
|
||||
val = -1;
|
||||
}
|
||||
for (uint i = 0; i < size; i++) {
|
||||
// CIRCUITPY fix for undefined behavior on left shift
|
||||
// CIRCUITPY-CHANGE: fix for undefined behavior on left shift
|
||||
val *= 256;
|
||||
val |= *src;
|
||||
src += delta;
|
||||
|
@ -31,7 +31,7 @@
|
||||
#include <assert.h>
|
||||
|
||||
#include "py/compile.h"
|
||||
// CIRCUITPY: for gc_collect() after each import
|
||||
// CIRCUITPY-CHANGE: for gc_collect() after each import
|
||||
#include "py/gc.h"
|
||||
#include "py/objmodule.h"
|
||||
#include "py/persistentcode.h"
|
||||
@ -511,7 +511,7 @@ STATIC mp_obj_t process_import_at_level(qstr full_mod_name, qstr level_mod_name,
|
||||
// a __path__ attribute, and not attempt to stat it.
|
||||
}
|
||||
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
// Loading a module thrashes the heap significantly so we explicitly clean up
|
||||
// afterwards.
|
||||
gc_collect();
|
||||
|
@ -74,7 +74,7 @@ static inline bool emit_inline_thumb_allow_float(emit_inline_asm_t *emit) {
|
||||
|
||||
#endif
|
||||
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
STATIC void emit_inline_thumb_error_msg(emit_inline_asm_t *emit, const compressed_string_t *msg) {
|
||||
*emit->error_slot = mp_obj_new_exception_msg(&mp_type_SyntaxError, msg);
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ struct _emit_inline_asm_t {
|
||||
qstr *label_lookup;
|
||||
};
|
||||
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
STATIC void emit_inline_xtensa_error_msg(emit_inline_asm_t *emit, const compressed_string_t *msg) {
|
||||
*emit->error_slot = mp_obj_new_exception_msg(&mp_type_SyntaxError, msg);
|
||||
}
|
||||
|
@ -58,7 +58,7 @@
|
||||
#define DEBUG_printf(...) (void)0
|
||||
#endif
|
||||
|
||||
// CIRCUITPY: force definitions
|
||||
// CIRCUITPY-CHANGE: force definitions
|
||||
#ifndef N_X64
|
||||
#define N_X64 (0)
|
||||
#endif
|
||||
|
36
py/gc.c
36
py/gc.c
@ -36,7 +36,7 @@
|
||||
#include <valgrind/memcheck.h>
|
||||
#endif
|
||||
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
#include "supervisor/shared/safe_mode.h"
|
||||
|
||||
#if CIRCUITPY_MEMORYMONITOR
|
||||
@ -53,7 +53,7 @@
|
||||
#define DEBUG_printf(...) (void)0
|
||||
#endif
|
||||
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
// Uncomment this if you want to use a debugger to capture state at every allocation and free.
|
||||
// #define LOG_HEAP_ACTIVITY 1
|
||||
|
||||
@ -131,7 +131,7 @@
|
||||
#define GC_EXIT()
|
||||
#endif
|
||||
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
#ifdef LOG_HEAP_ACTIVITY
|
||||
volatile uint32_t change_me;
|
||||
#pragma GCC push_options
|
||||
@ -338,7 +338,7 @@ STATIC bool gc_try_add_heap(size_t failed_alloc) {
|
||||
|
||||
#endif
|
||||
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
// TODO FOR MERGE: fix this for multiple areas??
|
||||
void gc_deinit(void) {
|
||||
// Run any finalisers before we stop using the heap.
|
||||
@ -381,7 +381,7 @@ STATIC inline mp_state_mem_area_t *gc_get_ptr_area(const void *ptr) {
|
||||
}
|
||||
#endif
|
||||
|
||||
// CIRCUITPY: VERIFY_PTR moved to gc.h to make it available elsewhere.
|
||||
// CIRCUITPY-CHANGE: VERIFY_PTR moved to gc.h to make it available elsewhere.
|
||||
|
||||
#ifndef TRACE_MARK
|
||||
#if DEBUG_PRINT
|
||||
@ -395,7 +395,7 @@ STATIC inline mp_state_mem_area_t *gc_get_ptr_area(const void *ptr) {
|
||||
// children: mark the unmarked child blocks and put those newly marked
|
||||
// blocks on the stack. When all children have been checked, pop off the
|
||||
// topmost block on the stack and repeat with that one.
|
||||
// CIRCUITPY: We don't instrument these functions because they occur a lot during GC and
|
||||
// CIRCUITPY-CHANGE: We don't instrument these functions because they occur a lot during GC and
|
||||
#if MICROPY_GC_SPLIT_HEAP
|
||||
STATIC void MP_NO_INSTRUMENT PLACE_IN_ITCM(gc_mark_subtree)(mp_state_mem_area_t * area, size_t block)
|
||||
#else
|
||||
@ -599,7 +599,7 @@ void gc_collect_start(void) {
|
||||
#endif
|
||||
}
|
||||
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
void gc_collect_ptr(void *ptr) {
|
||||
void *ptrs[1] = { ptr };
|
||||
gc_collect_root(ptrs, 1);
|
||||
@ -611,7 +611,7 @@ void gc_collect_ptr(void *ptr) {
|
||||
#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))
|
||||
__attribute__((no_sanitize_address))
|
||||
#endif
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
static void *MP_NO_INSTRUMENT PLACE_IN_ITCM(gc_get_ptr)(void **ptrs, int i) {
|
||||
#if MICROPY_DEBUG_VALGRIND
|
||||
if (!VALGRIND_CHECK_MEM_IS_ADDRESSABLE(&ptrs[i], sizeof(*ptrs))) {
|
||||
@ -744,7 +744,7 @@ void gc_info(gc_info_t *info) {
|
||||
GC_EXIT();
|
||||
}
|
||||
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
bool gc_alloc_possible(void) {
|
||||
#if MICROPY_GC_SPLIT_HEAP
|
||||
return MP_STATE_MEM(gc_last_free_area) != 0;
|
||||
@ -797,7 +797,7 @@ void *gc_alloc(size_t n_bytes, unsigned int alloc_flags) {
|
||||
area = &MP_STATE_MEM(area);
|
||||
#endif
|
||||
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
if (area == 0) {
|
||||
reset_into_safe_mode(SAFE_MODE_GC_ALLOC_OUTSIDE_VM);
|
||||
}
|
||||
@ -861,7 +861,7 @@ found:
|
||||
area->gc_last_free_atb_index = (i + 1) / BLOCKS_PER_ATB;
|
||||
}
|
||||
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
#ifdef LOG_HEAP_ACTIVITY
|
||||
gc_log_change(start_block, end_block - start_block + 1);
|
||||
#endif
|
||||
@ -958,7 +958,7 @@ void gc_free(void *ptr) {
|
||||
mp_state_mem_area_t *area;
|
||||
#if MICROPY_GC_SPLIT_HEAP
|
||||
area = gc_get_ptr_area(ptr);
|
||||
// CIRCUITPY extra checking
|
||||
// CIRCUITPY-CHANGE: extra checking
|
||||
if (MP_STATE_MEM(gc_pool_start) == 0) {
|
||||
reset_into_safe_mode(SAFE_MODE_GC_ALLOC_OUTSIDE_VM);
|
||||
}
|
||||
@ -995,7 +995,7 @@ void gc_free(void *ptr) {
|
||||
area->gc_last_free_atb_index = block / BLOCKS_PER_ATB;
|
||||
}
|
||||
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
#ifdef LOG_HEAP_ACTIVITY
|
||||
gc_log_change(start_block, 0);
|
||||
#endif
|
||||
@ -1166,7 +1166,7 @@ void *gc_realloc(void *ptr_in, size_t n_bytes, bool allow_move) {
|
||||
gc_dump_alloc_table(&mp_plat_print);
|
||||
#endif
|
||||
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
#ifdef LOG_HEAP_ACTIVITY
|
||||
gc_log_change(block, new_blocks);
|
||||
#endif
|
||||
@ -1203,7 +1203,7 @@ void *gc_realloc(void *ptr_in, size_t n_bytes, bool allow_move) {
|
||||
gc_dump_alloc_table(&mp_plat_print);
|
||||
#endif
|
||||
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
#ifdef LOG_HEAP_ACTIVITY
|
||||
gc_log_change(block, new_blocks);
|
||||
#endif
|
||||
@ -1243,7 +1243,7 @@ void *gc_realloc(void *ptr_in, size_t n_bytes, bool allow_move) {
|
||||
}
|
||||
#endif // Alternative gc_realloc impl
|
||||
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
bool gc_never_free(void *ptr) {
|
||||
// Check to make sure the pointer is on the heap in the first place.
|
||||
if (gc_nbytes(ptr) == 0) {
|
||||
@ -1353,7 +1353,7 @@ void gc_dump_alloc_table(const mp_print_t *print) {
|
||||
*/
|
||||
/* this prints the uPy object type of the head block */
|
||||
case AT_HEAD: {
|
||||
// CIRCUITPY compiler warning avoidance
|
||||
// CIRCUITPY-CHANGE: compiler warning avoidance
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wcast-align"
|
||||
void **ptr = (void **)(area->gc_pool_start + bl * BYTES_PER_BLOCK);
|
||||
@ -1419,7 +1419,7 @@ void gc_dump_alloc_table(const mp_print_t *print) {
|
||||
}
|
||||
mp_print_str(print, "\n");
|
||||
}
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
mp_print_str(&mp_plat_print, "\n");
|
||||
GC_EXIT();
|
||||
}
|
||||
|
12
py/gc.h
12
py/gc.h
@ -34,7 +34,7 @@
|
||||
#include "py/mpstate.h"
|
||||
#include "py/misc.h"
|
||||
|
||||
// CIRCUITPY - this may change when use split heap
|
||||
// CIRCUITPY-CHANGE: - this may change when use split heap
|
||||
#if !MICROPY_GC_SPLIT_HEAP
|
||||
#define HEAP_PTR(ptr) ( \
|
||||
MP_STATE_MEM(area).gc_pool_start != 0 /* Not on the heap if it isn't inited */ \
|
||||
@ -42,7 +42,7 @@
|
||||
&& ptr < (void *)MP_STATE_MEM(area).gc_pool_end /* must be below end of pool */ \
|
||||
)
|
||||
|
||||
// CIRCUITPY: defined here so available outside of gc.c
|
||||
// CIRCUITPY-CHANGE: defined here so available outside of gc.c
|
||||
// ptr should be of type void*
|
||||
#define VERIFY_PTR(ptr) ( \
|
||||
((uintptr_t)(ptr) & (MICROPY_BYTES_PER_GC_BLOCK - 1)) == 0 /* must be aligned on a block */ \
|
||||
@ -51,7 +51,7 @@
|
||||
#endif
|
||||
|
||||
void gc_init(void *start, void *end);
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
void gc_deinit(void);
|
||||
|
||||
#if MICROPY_GC_SPLIT_HEAP
|
||||
@ -74,12 +74,12 @@ bool gc_is_locked(void);
|
||||
// A given port must implement gc_collect by using the other collect functions.
|
||||
void gc_collect(void);
|
||||
void gc_collect_start(void);
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
void gc_collect_ptr(void *ptr);
|
||||
void gc_collect_root(void **ptrs, size_t len);
|
||||
void gc_collect_end(void);
|
||||
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
// Is the gc heap available?
|
||||
bool gc_alloc_possible(void);
|
||||
|
||||
@ -96,7 +96,7 @@ size_t gc_nbytes(const void *ptr);
|
||||
bool gc_has_finaliser(const void *ptr);
|
||||
void *gc_realloc(void *ptr, size_t n_bytes, bool allow_move);
|
||||
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
// Prevents a pointer from ever being freed because it establishes a permanent reference to it. Use
|
||||
// very sparingly because it can leak memory.
|
||||
bool gc_never_free(void *ptr);
|
||||
|
@ -3,7 +3,7 @@ Process raw qstr file and output qstr data with length, hash and data bytes.
|
||||
|
||||
This script works with Python 2.7, 3.3 and 3.4.
|
||||
|
||||
CIRCUITPY:
|
||||
CIRCUITPY-CHANGE:
|
||||
For documentation about the format of compressed translated strings, see
|
||||
supervisor/shared/translate/translate.h
|
||||
"""
|
||||
@ -272,7 +272,7 @@ def qstr_escape(qst):
|
||||
return re.sub(r"[^A-Za-z0-9_]", esc_char, qst)
|
||||
|
||||
|
||||
# CIRCUITPY: add translations handling
|
||||
# CIRCUITPY-CHANGE: add translations handling
|
||||
def parse_input_headers_with_translations(infiles):
|
||||
qcfgs = {}
|
||||
qstrs = {}
|
||||
@ -306,7 +306,7 @@ def parse_input_headers_with_translations(infiles):
|
||||
qcfgs[match.group(1)] = value
|
||||
continue
|
||||
|
||||
# CIRCUITPY
|
||||
# CIRCUITPY-CHANGE
|
||||
match = re.match(r'^TRANSLATE\("(.*)"\)$', line)
|
||||
if match:
|
||||
translations.add(match.group(1))
|
||||
@ -345,7 +345,7 @@ def parse_input_headers_with_translations(infiles):
|
||||
order = -190000
|
||||
elif ident.startswith("__"):
|
||||
order -= 100000
|
||||
# CIRCUITPY
|
||||
# CIRCUITPY-CHANGE
|
||||
elif ident.startswith("_lt"):
|
||||
order -= 100000
|
||||
elif ident.startswith("_gt"):
|
||||
@ -359,7 +359,7 @@ def parse_input_headers_with_translations(infiles):
|
||||
return qcfgs, qstrs, translations
|
||||
|
||||
|
||||
# CIRCUITPY: Used externally by mpy-tool.py. Don't pass back translations.
|
||||
# CIRCUITPY-CHANGE: Used externally by mpy-tool.py. Don't pass back translations.
|
||||
def parse_input_headers(infiles):
|
||||
qcfgs, qstrs, translations = parse_input_headers_with_translations(infiles)
|
||||
return (qcfgs, qstrs)
|
||||
@ -385,7 +385,7 @@ def make_bytes(cfg_bytes_len, cfg_bytes_hash, qstr):
|
||||
return '%d, %d, "%s"' % (qhash, qlen, qdata)
|
||||
|
||||
|
||||
# CIRCUITPY: add translations
|
||||
# CIRCUITPY-CHANGE: add translations
|
||||
def print_qstr_data(qcfgs, qstrs, translations):
|
||||
# get config variables
|
||||
cfg_bytes_len = int(qcfgs["BYTES_IN_LEN"])
|
||||
|
@ -2,7 +2,7 @@
|
||||
This script processes the output from the C preprocessor and extracts all
|
||||
qstr. Each qstr is transformed into a qstr definition of the form 'Q(...)'.
|
||||
|
||||
This script works with Python 3.x (CIRCUITPY: not 2.x)
|
||||
This script works with Python 3.x (CIRCUITPY-CHANGE: not 2.x)
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
@ -165,7 +165,7 @@ def process_file(f):
|
||||
for match in re_match.findall(line):
|
||||
if args.mode == _MODE_QSTR:
|
||||
name = match.replace("MP_QSTR_", "")
|
||||
# CIRCUITPY: undo character escapes in qstrs in C code
|
||||
# CIRCUITPY-CHANGE: undo character escapes in qstrs in C code
|
||||
output.append("Q(" + qstr_unescape(name) + ")")
|
||||
elif args.mode in (_MODE_COMPRESS, _MODE_MODULE, _MODE_ROOT_POINTER):
|
||||
output.append(match)
|
||||
|
@ -13,7 +13,7 @@ import pathlib
|
||||
import datetime
|
||||
import subprocess
|
||||
|
||||
# CIRCUITPY: use external script that can override git describe output with an
|
||||
# CIRCUITPY-CHANGE: use external script that can override git describe output with an
|
||||
# environment variable.
|
||||
tools_describe = str(pathlib.Path(__file__).resolve().parent.parent / "tools/describe")
|
||||
|
||||
@ -72,7 +72,7 @@ def get_version_info_from_git(repo_path):
|
||||
except OSError:
|
||||
return None
|
||||
|
||||
# CIRCUITPY
|
||||
# CIRCUITPY-CHANGE
|
||||
# Try to extract MicroPython version from git tag
|
||||
ver = git_tag.split("-")[0].split(".")
|
||||
|
||||
|
@ -69,7 +69,7 @@ typedef unsigned int uint;
|
||||
// TODO make a lazy m_renew that can increase by a smaller amount than requested (but by at least 1 more element)
|
||||
|
||||
#define m_new(type, num) ((type *)(m_malloc(sizeof(type) * (num))))
|
||||
#define m_new_ll(type, num) m_new(type, num) // CIRCUITPY: clue to long-lived allocator
|
||||
#define m_new_ll(type, num) m_new(type, num) // CIRCUITPY-CHANGE: clue to long-lived allocator
|
||||
#define m_new_maybe(type, num) ((type *)(m_malloc_maybe(sizeof(type) * (num))))
|
||||
#define m_new0(type, num) ((type *)(m_malloc0(sizeof(type) * (num))))
|
||||
#define m_new_obj(type) (m_new(type, 1))
|
||||
@ -79,7 +79,7 @@ typedef unsigned int uint;
|
||||
#define m_new_obj_var_maybe(obj_type, var_type, var_num) ((obj_type *)m_malloc_maybe(sizeof(obj_type) + sizeof(var_type) * (var_num)))
|
||||
#if MICROPY_ENABLE_FINALISER
|
||||
#define m_new_obj_with_finaliser(type) ((type *)(m_malloc_with_finaliser(sizeof(type))))
|
||||
#define m_new_ll_obj_with_finaliser(type) m_new_obj_with_finaliser(type) // CIRCUITPY: clue to long-lived allocator
|
||||
#define m_new_ll_obj_with_finaliser(type) m_new_obj_with_finaliser(type) // CIRCUITPY-CHANGE: clue to long-lived allocator
|
||||
#define m_new_obj_var_with_finaliser(type, var_type, var_num) ((type *)m_malloc_with_finaliser(sizeof(type) + sizeof(var_type) * (var_num)))
|
||||
#else
|
||||
#define m_new_obj_with_finaliser(type) m_new_obj(type)
|
||||
@ -134,7 +134,7 @@ size_t m_get_peak_bytes_allocated(void);
|
||||
// align ptr to the nearest multiple of "alignment"
|
||||
#define MP_ALIGN(ptr, alignment) (void *)(((uintptr_t)(ptr) + ((alignment) - 1)) & ~((alignment) - 1))
|
||||
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
#define sizeof_field(TYPE, MEMBER) sizeof((((TYPE *)0)->MEMBER))
|
||||
|
||||
/** unichar / UTF-8 *********************************************/
|
||||
@ -341,7 +341,7 @@ typedef const char *mp_rom_error_text_t;
|
||||
|
||||
// Might add more types of compressed text in the future.
|
||||
// For now, forward directly to MP_COMPRESSED_ROM_TEXT.
|
||||
// CIRCUITPY: MP_ERROR_TEXT() -> translate()
|
||||
// CIRCUITPY-CHANGE: MP_ERROR_TEXT() -> translate()
|
||||
#if CIRCUITPY
|
||||
#include "supervisor/shared/translate/translate.h"
|
||||
#else
|
||||
|
@ -12,7 +12,7 @@ endif
|
||||
THIS_MAKEFILE := $(lastword $(MAKEFILE_LIST))
|
||||
TOP := $(patsubst %/py/mkenv.mk,%,$(THIS_MAKEFILE))
|
||||
|
||||
# CIRCUITPY: verbosity differences, STEPECHO
|
||||
# CIRCUITPY-CHANGE: verbosity differences, STEPECHO
|
||||
# Turn on increased build verbosity by defining BUILD_VERBOSE in your main
|
||||
# Makefile or in your environment. You can also use V="steps commands rules" or any combination thereof
|
||||
# on the make command line.
|
||||
@ -74,7 +74,7 @@ AR = $(CROSS_COMPILE)ar
|
||||
MAKE_MANIFEST = $(PYTHON) $(TOP)/tools/makemanifest.py
|
||||
MAKE_FROZEN = $(PYTHON) $(TOP)/tools/make-frozen.py
|
||||
MPY_TOOL = $(PYTHON) $(TOP)/tools/mpy-tool.py
|
||||
# CIRCUITPY
|
||||
# CIRCUITPY-CHANGE
|
||||
PREPROCESS_FROZEN_MODULES = PYTHONPATH=$(TOP)/tools/python-semver $(TOP)/tools/preprocess_frozen_modules.py
|
||||
|
||||
MPY_LIB_SUBMODULE_DIR = $(TOP)/lib/micropython-lib
|
||||
|
@ -44,7 +44,7 @@ QSTR_GEN_CXXFLAGS += $(QSTR_GEN_FLAGS)
|
||||
# can be located. By following this scheme, it allows a single build rule
|
||||
# to be used to compile all .c files.
|
||||
|
||||
# CIRCUITPY adds STEPECHO
|
||||
# CIRCUITPY-CHANGE: adds STEPECHO
|
||||
vpath %.S . $(TOP) $(USER_C_MODULES)
|
||||
$(BUILD)/%.o: %.S
|
||||
$(STEPECHO) "CC $<"
|
||||
@ -79,7 +79,7 @@ $(Q)$(CXX) $(CXXFLAGS) -c -MD -o $@ $< || (echo -e $(HELP_BUILD_ERROR); false)
|
||||
$(RM) -f $(@:.o=.d)
|
||||
endef
|
||||
|
||||
# CIRCUITPY: add $(DEVICES_MODULES) and $(BUILD)
|
||||
# CIRCUITPY-CHANGE: add $(DEVICES_MODULES) and $(BUILD)
|
||||
vpath %.c . $(TOP) $(USER_C_MODULES) $(DEVICES_MODULES) $(BUILD)
|
||||
$(BUILD)/%.o: %.c
|
||||
$(call compile_c)
|
||||
@ -191,7 +191,7 @@ CFLAGS += -DMICROPY_MODULE_FROZEN_MPY
|
||||
CFLAGS += -DMICROPY_MODULE_FROZEN_STR
|
||||
|
||||
# to build frozen_content.c from a manifest
|
||||
# CIRCUITPY: FROZEN_MANIFEST is constructed at build time
|
||||
# CIRCUITPY-CHANGE: FROZEN_MANIFEST is constructed at build time
|
||||
$(BUILD)/frozen_content.c: FORCE $(BUILD)/genhdr/qstrdefs.generated.h $(BUILD)/genhdr/root_pointers.h $(FROZEN_MANIFEST) | $(MICROPY_MPYCROSS_DEPENDENCY)
|
||||
$(Q)test -e "$(MPY_LIB_DIR)/README.md" || (echo -e $(HELP_MPY_LIB_SUBMODULE); false)
|
||||
$(Q)$(MAKE_MANIFEST) -o $@ -v "MPY_DIR=$(TOP)" -v "MPY_LIB_DIR=$(MPY_LIB_DIR)" -v "PORT_DIR=$(shell pwd)" -v "BOARD_DIR=$(BOARD_DIR)" -b "$(BUILD)" $(if $(MPY_CROSS_FLAGS),-f"$(MPY_CROSS_FLAGS)",) --mpy-tool-flags="$(MPY_TOOL_FLAGS)" $(FROZEN_MANIFEST)
|
||||
|
@ -188,7 +188,7 @@ STATIC mp_obj_t mp_builtin_dir(size_t n_args, const mp_obj_t *args) {
|
||||
// Implemented by probing all possible qstrs with mp_load_method_maybe
|
||||
size_t nqstr = QSTR_TOTAL();
|
||||
for (size_t i = MP_QSTR_ + 1; i < nqstr; ++i) {
|
||||
// CIRCUITPY changes PR #6539
|
||||
// CIRCUITPY-CHANGE: changes PR #6539
|
||||
mp_obj_t dest[2] = {};
|
||||
mp_load_method_protected(args[0], i, dest, true);
|
||||
if (dest[0] != MP_OBJ_NULL) {
|
||||
@ -398,7 +398,7 @@ STATIC mp_obj_t mp_builtin_pow(size_t n_args, const mp_obj_t *args) {
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_pow_obj, 2, 3, mp_builtin_pow);
|
||||
|
||||
// CIRCUITPY adds flush()
|
||||
// CIRCUITPY-CHANGE: adds flush()
|
||||
STATIC mp_obj_t mp_builtin_print(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||
enum { ARG_sep, ARG_end, ARG_flush, ARG_file };
|
||||
static const mp_arg_t allowed_args[] = {
|
||||
|
@ -252,7 +252,7 @@ STATIC mp_obj_t mp_math_log(size_t n_args, const mp_obj_t *args) {
|
||||
if (base <= (mp_float_t)0.0) {
|
||||
math_error();
|
||||
} else if (base == (mp_float_t)1.0) {
|
||||
// CIRCUITPY: remove redundant text error message
|
||||
// CIRCUITPY-CHANGE: remove redundant text error message
|
||||
mp_raise_ZeroDivisionError();
|
||||
}
|
||||
return mp_obj_new_float(l / MICROPY_FLOAT_C_FUN(log)(base));
|
||||
|
@ -181,7 +181,7 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(struct_unpack_from_obj, 2, 3, struct_unpack_
|
||||
|
||||
// This function assumes there is enough room in p to store all the values
|
||||
STATIC void struct_pack_into_internal(mp_obj_t fmt_in, byte *p, size_t n_args, const mp_obj_t *args) {
|
||||
// CIRCUITPY additional error checking
|
||||
// CIRCUITPY-CHANGE: additional error checking
|
||||
size_t size;
|
||||
size_t count = calc_size_items(mp_obj_str_get_str(fmt_in), &size);
|
||||
if (count != n_args) {
|
||||
|
@ -166,7 +166,7 @@ STATIC mp_obj_t mp_sys_exc_info(void) {
|
||||
|
||||
t->items[0] = MP_OBJ_FROM_PTR(mp_obj_get_type(cur_exc));
|
||||
t->items[1] = cur_exc;
|
||||
// CIRCUITPY has traceback obj
|
||||
// CIRCUITPY-CHANGE: has traceback obj
|
||||
t->items[2] = mp_obj_exception_get_traceback_obj(cur_exc);
|
||||
return MP_OBJ_FROM_PTR(t);
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ STATIC MP_DEFINE_CONST_OBJ_TYPE(
|
||||
STATIC size_t thread_stack_size = 0;
|
||||
|
||||
STATIC mp_obj_t mod_thread_get_ident(void) {
|
||||
// CIRCUITPY: uintptr_t cast to avoid warning
|
||||
// CIRCUITPY-CHANGE: uintptr_t cast to avoid warning
|
||||
return mp_obj_new_int_from_uint((uintptr_t)mp_thread_get_state());
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_0(mod_thread_get_ident_obj, mod_thread_get_ident);
|
||||
|
@ -540,7 +540,7 @@
|
||||
#define MICROPY_OPT_COMPUTED_GOTO (0)
|
||||
#endif
|
||||
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
// Whether to save trade flash space for speed in MICROPY_OPT_COMPUTED_GOTO.
|
||||
// Costs about 3% speed, saves about 1500 bytes space. In addition to the assumptions
|
||||
// of MICROPY_OPT_COMPUTED_GOTO, also assumes that mp_execute_bytecode is less than
|
||||
@ -606,7 +606,7 @@
|
||||
#define MICROPY_HAS_FILE_READER (MICROPY_READER_POSIX || MICROPY_READER_VFS)
|
||||
#endif
|
||||
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
// Number of VFS mounts to persist across soft-reset.
|
||||
#ifndef MICROPY_FATFS_NUM_PERSISTENT
|
||||
#define MICROPY_FATFS_NUM_PERSISTENT (0)
|
||||
@ -811,13 +811,13 @@ typedef long long mp_longint_impl_t;
|
||||
#define MICROPY_ERROR_PRINTER (&mp_plat_print)
|
||||
#endif
|
||||
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
// Whether to support chained exceptions
|
||||
#ifndef MICROPY_CPYTHON_EXCEPTION_CHAIN
|
||||
#define MICROPY_CPYTHON_EXCEPTION_CHAIN (0)
|
||||
#endif
|
||||
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
// Whether the statically allocated GeneratorExit exception may be const
|
||||
#ifndef MICROPY_CONST_GENERATOREXIT_OBJ
|
||||
#define MICROPY_CONST_GENERATOREXIT_OBJ (!MICROPY_CPYTHON_EXCEPTION_CHAIN)
|
||||
@ -1606,7 +1606,7 @@ typedef double mp_float_t;
|
||||
#define MICROPY_PY_UCTYPES_NATIVE_C_TYPES (1)
|
||||
#endif
|
||||
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
// TODO? CIRCUITPY_ZLIB instead
|
||||
#ifndef MICROPY_PY_ZLIB
|
||||
#define MICROPY_PY_ZLIB (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
|
||||
@ -1696,7 +1696,7 @@ typedef double mp_float_t;
|
||||
#define MICROPY_PY_BINASCII (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
|
||||
#endif
|
||||
|
||||
// CIRCUITPY: does not depend on MICROPY_PY_DEFLATE
|
||||
// CIRCUITPY-CHANGE: does not depend on MICROPY_PY_DEFLATE
|
||||
#ifndef MICROPY_PY_BINASCII_CRC32
|
||||
#define MICROPY_PY_BINASCII_CRC32 (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
|
||||
#endif
|
||||
@ -1993,14 +1993,14 @@ typedef double mp_float_t;
|
||||
#define MP_WEAK __attribute__((weak))
|
||||
#endif
|
||||
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
// Modifier for functions which should not be instrumented when tracing with
|
||||
// -finstrument-functions
|
||||
#ifndef MP_NO_INSTRUMENT
|
||||
#define MP_NO_INSTRUMENT __attribute__((no_instrument_function))
|
||||
#endif
|
||||
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
// Modifier for functions which should ideally inlined
|
||||
#ifndef MP_INLINE
|
||||
#define MP_INLINE inline MP_NO_INSTRUMENT
|
||||
@ -2026,7 +2026,7 @@ typedef double mp_float_t;
|
||||
#define MP_UNLIKELY(x) __builtin_expect((x), 0)
|
||||
#endif
|
||||
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
// Modifier for functions which aren't often used. Calls will also be considered
|
||||
// unlikely. Section names are `.text.unlikely` for use in linker scripts.
|
||||
#ifndef MP_COLD
|
||||
|
@ -147,7 +147,7 @@
|
||||
#include "py/obj.h"
|
||||
|
||||
qstr mp_errno_to_str(mp_obj_t errno_val);
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
const char *mp_common_errno_to_str(mp_obj_t errno_val, char *buf, size_t len);
|
||||
#endif
|
||||
|
||||
|
@ -376,7 +376,7 @@ int mp_print_float(const mp_print_t *print, mp_float_t f, char fmt, int flags, c
|
||||
}
|
||||
#endif
|
||||
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
static int print_str_common(const mp_print_t *print, const char *str, int prec, size_t len, int flags, int fill, int width) {
|
||||
if (prec >= 0 && (size_t)prec < len) {
|
||||
len = prec;
|
||||
|
@ -79,7 +79,7 @@ int mp_printf(const mp_print_t *print, const char *fmt, ...);
|
||||
int mp_vprintf(const mp_print_t *print, const char *fmt, va_list args);
|
||||
#endif
|
||||
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
struct compressed_string;
|
||||
int mp_cprintf(const mp_print_t *print, const struct compressed_string *compressed_fmt, ...);
|
||||
#ifdef va_start
|
||||
|
@ -25,7 +25,7 @@
|
||||
*/
|
||||
|
||||
#include "py/mpstate.h"
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
#include "supervisor/linker.h"
|
||||
|
||||
#if MICROPY_DYNAMIC_COMPILER
|
||||
|
@ -142,7 +142,7 @@ typedef struct _mp_state_mem_t {
|
||||
mp_thread_mutex_t gc_mutex;
|
||||
#endif
|
||||
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
void **permanent_pointers;
|
||||
} mp_state_mem_t;
|
||||
|
||||
@ -270,7 +270,7 @@ typedef struct _mp_state_thread_t {
|
||||
// Stack top at the start of program
|
||||
char *stack_top;
|
||||
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
#if MICROPY_MAX_STACK_USAGE
|
||||
char *stack_bottom;
|
||||
#endif
|
||||
|
2
py/mpz.c
2
py/mpz.c
@ -452,7 +452,7 @@ STATIC size_t mpn_mul(mpz_dig_t *idig, mpz_dig_t *jdig, size_t jlen, mpz_dig_t *
|
||||
}
|
||||
|
||||
ilen = id - oidig;
|
||||
// CIRCUITPY: check to prevent usb starvation
|
||||
// CIRCUITPY-CHANGE: check to prevent usb starvation
|
||||
#ifdef RUN_BACKGROUND_TASKS
|
||||
RUN_BACKGROUND_TASKS;
|
||||
#endif
|
||||
|
2
py/mpz.h
2
py/mpz.h
@ -142,7 +142,7 @@ void mpz_divmod_inpl(mpz_t *dest_quo, mpz_t *dest_rem, const mpz_t *lhs, const m
|
||||
static inline size_t mpz_max_num_bits(const mpz_t *z) {
|
||||
return z->len * MPZ_DIG_SIZE;
|
||||
}
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
static inline size_t mpz_num_bits(const mpz_t *z) {
|
||||
if (mpz_is_zero(z)) {
|
||||
return 0;
|
||||
|
@ -320,7 +320,7 @@ const mp_fun_table_t mp_fun_table = {
|
||||
gc_realloc,
|
||||
mp_printf,
|
||||
mp_vprintf,
|
||||
mp_raise_msg_str, // CIRCUITPY
|
||||
mp_raise_msg_str, // CIRCUITPY-CHANGE
|
||||
mp_obj_get_type,
|
||||
mp_obj_new_str,
|
||||
mp_obj_new_bytes,
|
||||
|
@ -36,7 +36,7 @@
|
||||
// For reference, arm/thumb callee save regs are:
|
||||
// r4-r11, r13=sp
|
||||
|
||||
// CIRCUITPY: added returns_twice
|
||||
// CIRCUITPY-CHANGE: added returns_twice
|
||||
__attribute__((naked, returns_twice)) unsigned int nlr_push(nlr_buf_t *nlr) {
|
||||
|
||||
__asm volatile (
|
||||
|
16
py/obj.c
16
py/obj.c
@ -107,14 +107,14 @@ const mp_obj_type_t *MICROPY_WRAP_MP_OBJ_GET_TYPE(mp_obj_get_type)(mp_const_obj_
|
||||
}
|
||||
|
||||
const char *mp_obj_get_type_str(mp_const_obj_t o_in) {
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
return qstr_str(mp_obj_get_type_qstr(o_in));
|
||||
}
|
||||
|
||||
void mp_obj_print_helper(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
|
||||
// There can be data structures nested too deep, or just recursive
|
||||
MP_STACK_CHECK();
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
#ifdef RUN_BACKGROUND_TASKS
|
||||
RUN_BACKGROUND_TASKS;
|
||||
#endif
|
||||
@ -143,7 +143,7 @@ void mp_obj_print(mp_obj_t o_in, mp_print_kind_t kind) {
|
||||
mp_obj_print_helper(MP_PYTHON_PRINTER, o_in, kind);
|
||||
}
|
||||
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
static void mp_obj_print_inner_exception(const mp_print_t *print, mp_obj_t self_in, mp_int_t limit) {
|
||||
#if MICROPY_CPYTHON_EXCEPTION_CHAIN
|
||||
mp_obj_exception_t *self = mp_obj_exception_get_native(self_in);
|
||||
@ -166,7 +166,7 @@ static void mp_obj_print_inner_exception(const mp_print_t *print, mp_obj_t self_
|
||||
#endif
|
||||
}
|
||||
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
// helper function to print an exception with traceback
|
||||
void mp_obj_print_exception_with_limit(const mp_print_t *print, mp_obj_t exc, mp_int_t limit) {
|
||||
if (mp_obj_is_exception_instance(exc) && stack_ok()) {
|
||||
@ -227,7 +227,7 @@ void mp_obj_print_exception_with_limit(const mp_print_t *print, mp_obj_t exc, mp
|
||||
mp_print_str(print, "\n");
|
||||
}
|
||||
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
void mp_obj_print_exception(const mp_print_t *print, mp_obj_t exc) {
|
||||
mp_obj_print_exception_with_limit(print, exc, 0);
|
||||
}
|
||||
@ -488,7 +488,7 @@ void mp_obj_get_complex(mp_obj_t arg, mp_float_t *real, mp_float_t *imag) {
|
||||
|
||||
// note: returned value in *items may point to the interior of a GC block
|
||||
void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items) {
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
if (mp_obj_is_tuple_compatible(o)) {
|
||||
mp_obj_tuple_get(o, len, items);
|
||||
} else if (mp_obj_is_type(o, &mp_type_list)) {
|
||||
@ -542,7 +542,7 @@ size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, bool
|
||||
i = len;
|
||||
}
|
||||
} else {
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
mp_arg_validate_index_range(i, 0, len - 1, MP_QSTR_index);
|
||||
}
|
||||
|
||||
@ -645,7 +645,7 @@ mp_obj_t mp_identity(mp_obj_t self) {
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(mp_identity_obj, mp_identity);
|
||||
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
// generic subscript iterator, which iterates through anything with a 0-based subscript.
|
||||
typedef struct {
|
||||
mp_obj_base_t base;
|
||||
|
45
py/obj.h
45
py/obj.h
@ -34,7 +34,7 @@
|
||||
#include "py/mpprint.h"
|
||||
#include "py/runtime0.h"
|
||||
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
#include "supervisor/shared/translate/compressed_string.h"
|
||||
|
||||
// This is the definition of the opaque MicroPython object type.
|
||||
@ -833,7 +833,7 @@ extern const mp_obj_type_t mp_type_bytearray;
|
||||
extern const mp_obj_type_t mp_type_memoryview;
|
||||
extern const mp_obj_type_t mp_type_float;
|
||||
extern const mp_obj_type_t mp_type_complex;
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
extern const mp_obj_type_t mp_type_traceback;
|
||||
extern const mp_obj_type_t mp_type_tuple;
|
||||
extern const mp_obj_type_t mp_type_list;
|
||||
@ -851,13 +851,13 @@ extern const mp_obj_type_t mp_type_zip;
|
||||
extern const mp_obj_type_t mp_type_array;
|
||||
extern const mp_obj_type_t mp_type_super;
|
||||
extern const mp_obj_type_t mp_type_gen_wrap;
|
||||
// CIRCUITPY distinguishes generators and coroutines
|
||||
// CIRCUITPY-CHANGE: distinguishes generators and coroutines
|
||||
extern const mp_obj_type_t mp_type_coro_wrap;
|
||||
extern const mp_obj_type_t mp_type_native_gen_wrap;
|
||||
// CIRCUITPY distinguishes generators and coroutines
|
||||
// CIRCUITPY-CHANGE: distinguishes generators and coroutines
|
||||
extern const mp_obj_type_t mp_type_native_coro_wrap;
|
||||
extern const mp_obj_type_t mp_type_gen_instance;
|
||||
// CIRCUITPY distinguishes generators and coroutines
|
||||
// CIRCUITPY-CHANGE: distinguishes generators and coroutines
|
||||
extern const mp_obj_type_t mp_type_coro_instance;
|
||||
extern const mp_obj_type_t mp_type_fun_builtin_0;
|
||||
extern const mp_obj_type_t mp_type_fun_builtin_1;
|
||||
@ -889,7 +889,7 @@ extern const mp_obj_type_t mp_type_ImportError;
|
||||
extern const mp_obj_type_t mp_type_IndentationError;
|
||||
extern const mp_obj_type_t mp_type_IndexError;
|
||||
extern const mp_obj_type_t mp_type_KeyboardInterrupt;
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
extern const mp_obj_type_t mp_type_ReloadException;
|
||||
extern const mp_obj_type_t mp_type_KeyError;
|
||||
extern const mp_obj_type_t mp_type_LookupError;
|
||||
@ -897,9 +897,9 @@ extern const mp_obj_type_t mp_type_MemoryError;
|
||||
extern const mp_obj_type_t mp_type_NameError;
|
||||
extern const mp_obj_type_t mp_type_NotImplementedError;
|
||||
extern const mp_obj_type_t mp_type_OSError;
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
extern const mp_obj_type_t mp_type_ConnectionError;
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
extern const mp_obj_type_t mp_type_BrokenPipeError;
|
||||
extern const mp_obj_type_t mp_type_OverflowError;
|
||||
extern const mp_obj_type_t mp_type_RuntimeError;
|
||||
@ -943,7 +943,7 @@ extern const struct _mp_obj_str_t mp_const_empty_bytes_obj;
|
||||
extern const struct _mp_obj_tuple_t mp_const_empty_tuple_obj;
|
||||
extern const struct _mp_obj_dict_t mp_const_empty_dict_obj;
|
||||
extern const struct _mp_obj_singleton_t mp_const_ellipsis_obj;
|
||||
// CIRCUITPY next several lines
|
||||
// CIRCUITPY-CHANGE: next several lines
|
||||
extern const struct _mp_obj_traceback_t mp_const_empty_traceback_obj;
|
||||
extern const struct _mp_obj_singleton_t mp_const_notimplemented_obj;
|
||||
#if MICROPY_CONST_GENERATOREXIT_OBJ
|
||||
@ -992,7 +992,7 @@ void *mp_obj_malloc_helper(size_t num_bytes, const mp_obj_type_t *type);
|
||||
#define mp_obj_is_str_or_bytes(o) (mp_obj_is_qstr(o) || (mp_obj_is_obj(o) && MP_OBJ_TYPE_GET_SLOT_OR_NULL(((mp_obj_base_t *)MP_OBJ_TO_PTR(o))->type, binary_op) == mp_obj_str_binary_op))
|
||||
bool mp_obj_is_dict_or_ordereddict(mp_obj_t o);
|
||||
#define mp_obj_is_fun(o) (mp_obj_is_obj(o) && (((mp_obj_base_t *)MP_OBJ_TO_PTR(o))->type->name == MP_QSTR_function))
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
// type check is done on iter method to allow tuple, namedtuple, attrtuple
|
||||
#define mp_obj_is_tuple_compatible(o) (MP_OBJ_TYPE_GET_SLOT_OR_NULL(mp_obj_get_type(o), iter) == mp_obj_tuple_getiter)
|
||||
|
||||
@ -1016,16 +1016,17 @@ mp_obj_t mp_obj_new_str_from_utf8_vstr(vstr_t *vstr); // input data must be vali
|
||||
#endif
|
||||
mp_obj_t mp_obj_new_bytes_from_vstr(vstr_t *vstr);
|
||||
mp_obj_t mp_obj_new_bytes(const byte *data, size_t len);
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
mp_obj_t mp_obj_new_bytes_of_zeros(size_t len);
|
||||
mp_obj_t mp_obj_new_bytearray(size_t n, const void *items);
|
||||
mp_obj_t mp_obj_new_bytearray_of_zeros(size_t n); // CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
mp_obj_t mp_obj_new_bytearray_of_zeros(size_t n);
|
||||
mp_obj_t mp_obj_new_bytearray_by_ref(size_t n, void *items);
|
||||
#if MICROPY_PY_BUILTINS_FLOAT
|
||||
mp_obj_t mp_obj_new_int_from_float(mp_float_t val);
|
||||
mp_obj_t mp_obj_new_complex(mp_float_t real, mp_float_t imag);
|
||||
|
||||
// CIRCUITPY: our own conversion routines that don't bring double routines
|
||||
// CIRCUITPY-CHANGE: our own conversion routines that don't bring double routines
|
||||
extern mp_float_t uint64_to_float(uint64_t ui64);
|
||||
extern uint64_t float_to_uint64(float f);
|
||||
#endif
|
||||
@ -1035,12 +1036,12 @@ mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args,
|
||||
#define mp_obj_new_exception_msg(exc_type, msg) mp_obj_new_exception(exc_type)
|
||||
#define mp_obj_new_exception_msg_varg(exc_type, ...) mp_obj_new_exception(exc_type)
|
||||
#else
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const compressed_string_t *msg);
|
||||
mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const compressed_string_t *fmt, ...); // counts args by number of % symbols in fmt, excluding %%; can only handle void* sizes (ie no float/double!)
|
||||
#endif
|
||||
#ifdef va_start
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
mp_obj_t mp_obj_new_exception_msg_vlist(const mp_obj_type_t *exc_type, const compressed_string_t *fmt, va_list arg); // same fmt restrictions as above
|
||||
#endif
|
||||
mp_obj_t mp_obj_new_gen_wrap(mp_obj_t fun);
|
||||
@ -1057,7 +1058,7 @@ mp_obj_t mp_obj_new_memoryview(byte typecode, size_t nitems, void *items);
|
||||
|
||||
const mp_obj_type_t *mp_obj_get_type(mp_const_obj_t o_in);
|
||||
const char *mp_obj_get_type_str(mp_const_obj_t o_in);
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
#define mp_obj_get_type_qstr(o_in) (mp_obj_get_type((o_in))->name)
|
||||
bool mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); // arguments should be type objects
|
||||
mp_obj_t mp_obj_cast_to_native_base(mp_obj_t self_in, mp_const_obj_t native_type);
|
||||
@ -1065,7 +1066,7 @@ mp_obj_t mp_obj_cast_to_native_base(mp_obj_t self_in, mp_const_obj_t native_type
|
||||
void mp_obj_print_helper(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind);
|
||||
void mp_obj_print(mp_obj_t o, mp_print_kind_t kind);
|
||||
void mp_obj_print_exception(const mp_print_t *print, mp_obj_t exc);
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
void mp_obj_print_exception_with_limit(const mp_print_t *print, mp_obj_t exc, mp_int_t limit);
|
||||
|
||||
bool mp_obj_is_true(mp_obj_t arg);
|
||||
@ -1128,7 +1129,7 @@ bool mp_obj_exception_match(mp_obj_t exc, mp_const_obj_t exc_type);
|
||||
void mp_obj_exception_clear_traceback(mp_obj_t self_in);
|
||||
void mp_obj_exception_add_traceback(mp_obj_t self_in, qstr file, size_t line, qstr block);
|
||||
void mp_obj_exception_get_traceback(mp_obj_t self_in, size_t *n, size_t **values);
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
mp_obj_t mp_obj_exception_get_traceback_obj(mp_obj_t self_in);
|
||||
mp_obj_t mp_obj_exception_get_value(mp_obj_t self_in);
|
||||
mp_obj_t mp_obj_exception_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args);
|
||||
@ -1205,7 +1206,7 @@ void mp_obj_tuple_del(mp_obj_t self_in);
|
||||
mp_int_t mp_obj_tuple_hash(mp_obj_t self_in);
|
||||
|
||||
// list
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
mp_obj_t mp_obj_list_clear(mp_obj_t self_in);
|
||||
mp_obj_t mp_obj_list_append(mp_obj_t self_in, mp_obj_t arg);
|
||||
mp_obj_t mp_obj_list_remove(mp_obj_t self_in, mp_obj_t value);
|
||||
@ -1275,7 +1276,7 @@ qstr mp_obj_fun_get_name(mp_const_obj_t fun);
|
||||
mp_obj_t mp_identity(mp_obj_t self);
|
||||
MP_DECLARE_CONST_FUN_OBJ_1(mp_identity_obj);
|
||||
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
// Generic iterator that uses unary op and subscr to iterate over a native type. It will be slower
|
||||
// than a custom iterator but applies broadly.
|
||||
mp_obj_t mp_obj_generic_subscript_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf);
|
||||
@ -1301,12 +1302,12 @@ typedef struct _mp_rom_obj_static_class_method_t {
|
||||
} mp_rom_obj_static_class_method_t;
|
||||
|
||||
// property
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
const mp_obj_t *mp_obj_property_get(mp_obj_t self_in, size_t *n_proxy);
|
||||
|
||||
// sequence helpers
|
||||
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
// Compute the new length of a sequence and ensure an exception is thrown on overflow.
|
||||
size_t mp_seq_multiply_len(size_t item_sz, size_t len);
|
||||
void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest);
|
||||
|
@ -65,7 +65,7 @@ STATIC mp_obj_t array_iterator_new(mp_obj_t array_in, mp_obj_iter_buf_t *iter_bu
|
||||
STATIC mp_obj_t array_append(mp_obj_t self_in, mp_obj_t arg);
|
||||
STATIC mp_obj_t array_extend(mp_obj_t self_in, mp_obj_t arg_in);
|
||||
STATIC mp_int_t array_get_buffer(mp_obj_t o_in, mp_buffer_info_t *bufinfo, mp_uint_t flags);
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
#if MICROPY_CPYTHON_COMPAT
|
||||
STATIC mp_obj_t array_decode(size_t n_args, const mp_obj_t *args);
|
||||
#endif
|
||||
@ -100,7 +100,7 @@ STATIC void array_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t
|
||||
|
||||
#if MICROPY_PY_BUILTINS_BYTEARRAY || MICROPY_PY_ARRAY
|
||||
STATIC mp_obj_array_t *array_new(char typecode, size_t n) {
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
if (typecode == 'x') {
|
||||
mp_raise_ValueError(MP_ERROR_TEXT("bad typecode"));
|
||||
}
|
||||
@ -134,7 +134,7 @@ STATIC mp_obj_t array_construct(char typecode, mp_obj_t initializer) {
|
||||
&& mp_get_buffer(initializer, &bufinfo, MP_BUFFER_READ)) {
|
||||
// construct array from raw bytes
|
||||
size_t sz = mp_binary_get_size('@', typecode, NULL);
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
if (bufinfo.len % sz) {
|
||||
mp_raise_ValueError(MP_ERROR_TEXT("bytes length not a multiple of item size"));
|
||||
}
|
||||
@ -198,7 +198,7 @@ STATIC mp_obj_t bytearray_make_new(const mp_obj_type_t *type_in, size_t n_args,
|
||||
// no args: construct an empty bytearray
|
||||
return MP_OBJ_FROM_PTR(array_new(BYTEARRAY_TYPECODE, 0));
|
||||
} else if (mp_obj_is_int(args[0])) {
|
||||
// CIRCUITPY error checks this
|
||||
// CIRCUITPY-CHANGE: error checks this
|
||||
if (n_args > 1) {
|
||||
mp_raise_TypeError(MP_ERROR_TEXT("wrong number of arguments"));
|
||||
}
|
||||
@ -261,7 +261,7 @@ STATIC mp_obj_t memoryview_make_new(const mp_obj_type_t *type_in, size_t n_args,
|
||||
return MP_OBJ_FROM_PTR(self);
|
||||
}
|
||||
|
||||
// CIRCUITPY adds cast
|
||||
// CIRCUITPY-CHANGE: adds cast
|
||||
#if MICROPY_CPYTHON_COMPAT
|
||||
STATIC mp_obj_t memoryview_cast(const mp_obj_t self_in, const mp_obj_t typecode_in) {
|
||||
mp_obj_array_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
@ -330,7 +330,7 @@ STATIC int typecode_for_comparison(int typecode, bool *is_unsigned) {
|
||||
STATIC mp_obj_t array_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
|
||||
mp_obj_array_t *lhs = MP_OBJ_TO_PTR(lhs_in);
|
||||
switch (op) {
|
||||
// CIRCUITPY does multiply
|
||||
// CIRCUITPY-CHANGE: does multiply
|
||||
case MP_BINARY_OP_MULTIPLY:
|
||||
case MP_BINARY_OP_INPLACE_MULTIPLY: {
|
||||
if (!mp_obj_is_int(rhs_in)) {
|
||||
@ -486,7 +486,7 @@ STATIC mp_obj_t array_extend(mp_obj_t self_in, mp_obj_t arg_in) {
|
||||
|
||||
// allow to extend by anything that has the buffer protocol (extension to CPython)
|
||||
mp_buffer_info_t arg_bufinfo;
|
||||
// CIRCUITPY: allow appending an iterable
|
||||
// CIRCUITPY-CHANGE: allow appending an iterable
|
||||
if (mp_get_buffer(arg_in, &arg_bufinfo, MP_BUFFER_READ)) {
|
||||
size_t sz = mp_binary_get_size('@', self->typecode, NULL);
|
||||
|
||||
@ -557,7 +557,7 @@ STATIC mp_obj_t buffer_finder(size_t n_args, const mp_obj_t *args, int direction
|
||||
return MP_OBJ_NEW_SMALL_INT(p - (const byte *)haystack_bufinfo.buf);
|
||||
}
|
||||
|
||||
// CIRCUITPY provides find, rfind, index
|
||||
// CIRCUITPY-CHANGE: provides find, rfind, index
|
||||
STATIC mp_obj_t buffer_find(size_t n_args, const mp_obj_t *args) {
|
||||
return buffer_finder(n_args, args, 1, false);
|
||||
}
|
||||
@ -733,7 +733,7 @@ STATIC mp_int_t array_get_buffer(mp_obj_t o_in, mp_buffer_info_t *bufinfo, mp_ui
|
||||
}
|
||||
|
||||
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
#if MICROPY_CPYTHON_COMPAT && MICROPY_PY_BUILTINS_BYTEARRAY
|
||||
// Directly lifted from objstr.c
|
||||
STATIC mp_obj_t array_decode(size_t n_args, const mp_obj_t *args) {
|
||||
@ -808,7 +808,8 @@ MP_DEFINE_CONST_OBJ_TYPE(
|
||||
#define MEMORYVIEW_TYPE_ATTR
|
||||
#endif
|
||||
|
||||
#if MICROPY_CPYTHON_COMPAT // CIRCUITPY provides cast
|
||||
#if MICROPY_CPYTHON_COMPAT
|
||||
// CIRCUITPY-CHANGE: provides cast
|
||||
STATIC const mp_rom_map_elem_t memoryview_locals_dict_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR_cast), MP_ROM_PTR(&memoryview_cast_obj) },
|
||||
#if MICROPY_PY_BUILTINS_BYTES_HEX
|
||||
@ -851,7 +852,7 @@ mp_obj_t mp_obj_new_bytearray(size_t n, const void *items) {
|
||||
return MP_OBJ_FROM_PTR(o);
|
||||
}
|
||||
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
mp_obj_t mp_obj_new_bytearray_of_zeros(size_t n) {
|
||||
mp_obj_array_t *o = array_new(BYTEARRAY_TYPECODE, n);
|
||||
memset(o->items, 0, n);
|
||||
|
@ -36,7 +36,7 @@
|
||||
#include <math.h>
|
||||
#include "py/formatfloat.h"
|
||||
|
||||
// CIRCUITPY compilation warning removal
|
||||
// CIRCUITPY-CHANGE: compilation warning removal
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wfloat-equal"
|
||||
|
||||
|
@ -305,7 +305,7 @@ STATIC mp_obj_t dict_fromkeys(size_t n_args, const mp_obj_t *args) {
|
||||
mp_obj_t len = mp_obj_len_maybe(args[1]);
|
||||
if (len == MP_OBJ_NULL) {
|
||||
/* object's type doesn't have a __len__ slot */
|
||||
// CIRCUITPY uses dict_new_typed() here.
|
||||
// CIRCUITPY-CHANGE: uses dict_new_typed() here.
|
||||
self_out = dict_new_typed(type, 0);
|
||||
} else {
|
||||
self_out = dict_new_typed(type, MP_OBJ_SMALL_INT_VALUE(len));
|
||||
@ -442,7 +442,7 @@ STATIC mp_obj_t dict_update(size_t n_args, const mp_obj_t *args, mp_map_t *kwarg
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(dict_update_obj, 1, dict_update);
|
||||
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
#if MICROPY_PY_COLLECTIONS_ORDEREDDICT
|
||||
STATIC mp_obj_t dict_move_to_end(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||
mp_obj_dict_t *self = MP_OBJ_TO_PTR(pos_args[0]);
|
||||
@ -578,7 +578,7 @@ STATIC void dict_view_print(const mp_print_t *print, mp_obj_t self_in, mp_print_
|
||||
mp_print_str(print, "])");
|
||||
}
|
||||
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
STATIC mp_obj_t dict_view_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
|
||||
mp_obj_dict_view_t *o = MP_OBJ_TO_PTR(o_in);
|
||||
// only dict.values() supports __hash__.
|
||||
@ -663,7 +663,7 @@ STATIC const mp_rom_map_elem_t dict_locals_dict_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR_get), MP_ROM_PTR(&dict_get_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_items), MP_ROM_PTR(&dict_items_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_keys), MP_ROM_PTR(&dict_keys_obj) },
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
#if MICROPY_PY_COLLECTIONS_ORDEREDDICT
|
||||
{ MP_ROM_QSTR(MP_QSTR_move_to_end), MP_ROM_PTR(&dict_move_to_end_obj) },
|
||||
#endif
|
||||
|
@ -116,7 +116,7 @@ bool mp_obj_is_native_exception_instance(mp_obj_t self_in) {
|
||||
return MP_OBJ_TYPE_GET_SLOT_OR_NULL(mp_obj_get_type(self_in), make_new) == mp_obj_exception_make_new;
|
||||
}
|
||||
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
mp_obj_exception_t *mp_obj_exception_get_native(mp_obj_t self_in) {
|
||||
assert(mp_obj_is_exception_instance(self_in));
|
||||
if (mp_obj_is_native_exception_instance(self_in)) {
|
||||
@ -183,7 +183,7 @@ void mp_obj_exception_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kin
|
||||
#if MICROPY_PY_ERRNO
|
||||
// try to provide a nice OSError error message
|
||||
if (o->base.type == &mp_type_OSError && o->args->len > 0 && o->args->len < 3 && mp_obj_is_small_int(o->args->items[0])) {
|
||||
// CIRCUITPY can print a whole string, not just the errno qstr
|
||||
// CIRCUITPY-CHANGE: can print a whole string, not just the errno qstr
|
||||
char decompressed[50];
|
||||
const char *msg = mp_common_errno_to_str(o->args->items[0], decompressed, sizeof(decompressed));
|
||||
if (msg != NULL) {
|
||||
@ -206,7 +206,7 @@ void mp_obj_exception_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kin
|
||||
mp_obj_tuple_print(print, MP_OBJ_FROM_PTR(o->args), kind);
|
||||
}
|
||||
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
void mp_obj_exception_initialize0(mp_obj_exception_t *o_exc, const mp_obj_type_t *type) {
|
||||
o_exc->base.type = type;
|
||||
o_exc->args = (mp_obj_tuple_t *)&mp_const_empty_tuple_obj;
|
||||
@ -224,7 +224,7 @@ mp_obj_t mp_obj_exception_make_new(const mp_obj_type_t *type, size_t n_args, siz
|
||||
|
||||
// Populate the exception object
|
||||
o_exc->base.type = type;
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
o_exc->traceback = (mp_obj_traceback_t *)&mp_const_empty_traceback_obj;
|
||||
|
||||
mp_obj_tuple_t *o_tuple;
|
||||
@ -265,7 +265,7 @@ mp_obj_t mp_obj_exception_make_new(const mp_obj_type_t *type, size_t n_args, siz
|
||||
|
||||
// Get exception "value" - that is, first argument, or None
|
||||
mp_obj_t mp_obj_exception_get_value(mp_obj_t self_in) {
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
mp_obj_exception_t *self = mp_obj_exception_get_native(self_in);
|
||||
if (self->args->len == 0) {
|
||||
return mp_const_none;
|
||||
@ -279,7 +279,7 @@ void mp_obj_exception_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
|
||||
mp_obj_exception_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
if (dest[0] != MP_OBJ_NULL) {
|
||||
// store/delete attribute
|
||||
// CIRCUITPY changes till end of function
|
||||
// CIRCUITPY-CHANGE: changes till end of function
|
||||
#if MICROPY_CONST_GENERATOREXIT_OBJ
|
||||
if (self == &mp_const_GeneratorExit_obj) {
|
||||
mp_raise_AttributeError(MP_ERROR_TEXT("can't set attribute"));
|
||||
@ -380,7 +380,7 @@ MP_DEFINE_CONST_OBJ_TYPE(
|
||||
// http://docs.python.org/3/library/exceptions.html
|
||||
MP_DEFINE_EXCEPTION(SystemExit, BaseException)
|
||||
MP_DEFINE_EXCEPTION(KeyboardInterrupt, BaseException)
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
MP_DEFINE_EXCEPTION(ReloadException, BaseException)
|
||||
MP_DEFINE_EXCEPTION(GeneratorExit, BaseException)
|
||||
MP_DEFINE_EXCEPTION(Exception, BaseException)
|
||||
@ -410,7 +410,7 @@ MP_DEFINE_EXCEPTION(Exception, BaseException)
|
||||
MP_DEFINE_EXCEPTION(BlockingIOError, OSError)
|
||||
MP_DEFINE_EXCEPTION(ChildProcessError, OSError)
|
||||
*/
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
MP_DEFINE_EXCEPTION(ConnectionError, OSError)
|
||||
MP_DEFINE_EXCEPTION(BrokenPipeError, ConnectionError)
|
||||
/*
|
||||
@ -423,7 +423,7 @@ MP_DEFINE_EXCEPTION(Exception, BaseException)
|
||||
MP_DEFINE_EXCEPTION(PermissionError, OSError)
|
||||
MP_DEFINE_EXCEPTION(ProcessLookupError, OSError)
|
||||
*/
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
MP_DEFINE_EXCEPTION(TimeoutError, OSError)
|
||||
/*
|
||||
MP_DEFINE_EXCEPTION(FileExistsError, OSError)
|
||||
@ -478,7 +478,7 @@ mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args,
|
||||
|
||||
#if MICROPY_ERROR_REPORTING != MICROPY_ERROR_REPORTING_NONE
|
||||
mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const compressed_string_t *msg) {
|
||||
// CIRCUITPY is different here and for many lines below.
|
||||
// CIRCUITPY-CHANGE: is different here and for many lines below.
|
||||
return mp_obj_new_exception_msg_varg(exc_type, msg);
|
||||
}
|
||||
|
||||
@ -712,7 +712,7 @@ void mp_obj_exception_get_traceback(mp_obj_t self_in, size_t *n, size_t **values
|
||||
}
|
||||
}
|
||||
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
#if MICROPY_PY_SYS_EXC_INFO
|
||||
STATIC const mp_obj_namedtuple_type_t code_type_obj = {
|
||||
NAMEDTUPLE_TYPE_BASE_AND_SLOTS(MP_QSTR_code),
|
||||
|
@ -28,7 +28,7 @@
|
||||
|
||||
#include "py/obj.h"
|
||||
#include "py/objtuple.h"
|
||||
// CIRCUITPY changes here and below for traceback.
|
||||
// CIRCUITPY-CHANGE: changes here and below for traceback.
|
||||
#include "py/objtraceback.h"
|
||||
|
||||
typedef struct _mp_obj_exception_t {
|
||||
|
@ -37,7 +37,7 @@
|
||||
#include <math.h>
|
||||
#include "py/formatfloat.h"
|
||||
|
||||
// CIRCUITPY avoid compiler warning
|
||||
// CIRCUITPY-CHANGE: avoid compiler warning
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wfloat-equal"
|
||||
|
||||
@ -347,7 +347,7 @@ mp_obj_t mp_obj_float_binary_op(mp_binary_op_t op, mp_float_t lhs_val, mp_obj_t
|
||||
return mp_obj_new_float(lhs_val);
|
||||
}
|
||||
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
// Convert a uint64_t to a 32-bit float without invoking the double-precision math routines,
|
||||
// which are large.
|
||||
mp_float_t uint64_to_float(uint64_t ui64) {
|
||||
@ -355,7 +355,7 @@ mp_float_t uint64_to_float(uint64_t ui64) {
|
||||
return (mp_float_t)((uint32_t)(ui64 >> 32) * 4294967296.0f + (uint32_t)(ui64 & 0xffffffff));
|
||||
}
|
||||
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
// Convert a uint64_t to a 32-bit float to a uint64_t without invoking extra math routines.
|
||||
// which are large.
|
||||
// Assume f >= 0.
|
||||
|
@ -36,7 +36,7 @@
|
||||
#include "py/stackctrl.h"
|
||||
|
||||
// Instance of GeneratorExit exception - needed by generator.close()
|
||||
// CIRCUITPY: https://github.com/adafruit/circuitpython/pull/7069 fix
|
||||
// CIRCUITPY-CHANGE: https://github.com/adafruit/circuitpython/pull/7069 fix
|
||||
#if MICROPY_CONST_GENERATOREXIT_OBJ
|
||||
const
|
||||
mp_obj_exception_t mp_const_GeneratorExit_obj = {{&mp_type_GeneratorExit}, (mp_obj_tuple_t *)&mp_const_empty_tuple_obj, (mp_obj_traceback_t *)&mp_const_empty_traceback_obj};
|
||||
@ -205,7 +205,7 @@ STATIC void gen_instance_print(const mp_print_t *print, mp_obj_t self_in, mp_pri
|
||||
mp_printf(print, "<generator object '%q' at %p>", mp_obj_fun_get_name(MP_OBJ_FROM_PTR(self->code_state.fun_bc)), self);
|
||||
}
|
||||
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
#if MICROPY_PY_ASYNC_AWAIT
|
||||
STATIC void coro_instance_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
|
||||
(void)kind;
|
||||
@ -216,7 +216,7 @@ STATIC void coro_instance_print(const mp_print_t *print, mp_obj_t self_in, mp_pr
|
||||
|
||||
mp_vm_return_kind_t mp_obj_gen_resume(mp_obj_t self_in, mp_obj_t send_value, mp_obj_t throw_value, mp_obj_t *ret_val) {
|
||||
MP_STACK_CHECK();
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
// note that self may have as its type either gen or coro,
|
||||
// both of which are stored as an mp_obj_gen_instance_t .
|
||||
mp_check_self(
|
||||
@ -453,7 +453,7 @@ MP_DEFINE_CONST_OBJ_TYPE(
|
||||
);
|
||||
|
||||
#if MICROPY_PY_ASYNC_AWAIT
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
// coroutine instance locals dict and type
|
||||
// same as generator, but with addition of __await()__.
|
||||
STATIC const mp_rom_map_elem_t coro_instance_locals_dict_table[] = {
|
||||
|
10
py/objint.c
10
py/objint.c
@ -300,7 +300,7 @@ char *mp_obj_int_formatted(char **buf, size_t *buf_size, size_t *fmt_size, mp_co
|
||||
return b;
|
||||
}
|
||||
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
#if MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_NONE
|
||||
|
||||
void mp_obj_int_buffer_overflow_check(mp_obj_t self_in, size_t nbytes, bool is_signed) {
|
||||
@ -395,7 +395,7 @@ mp_obj_t mp_obj_int_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_i
|
||||
|
||||
// This is called only with strings whose value doesn't fit in SMALL_INT
|
||||
mp_obj_t mp_obj_new_int_from_str_len(const char **str, size_t len, bool neg, unsigned int base) {
|
||||
// CIRCUITPY different error message
|
||||
// CIRCUITPY-CHANGE: different error message
|
||||
mp_raise_msg(&mp_type_OverflowError, MP_ERROR_TEXT("No long integer support"));
|
||||
return mp_const_none;
|
||||
}
|
||||
@ -458,7 +458,7 @@ mp_obj_t mp_obj_int_binary_op_extra_cases(mp_binary_op_t op, mp_obj_t lhs_in, mp
|
||||
return MP_OBJ_NULL; // op not supported
|
||||
}
|
||||
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
#if MICROPY_CPYTHON_COMPAT
|
||||
STATIC mp_obj_t int_bit_length(mp_obj_t self_in) {
|
||||
#if MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_NONE
|
||||
@ -480,7 +480,7 @@ STATIC mp_obj_t int_bit_length(mp_obj_t self_in) {
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(int_bit_length_obj, int_bit_length);
|
||||
#endif
|
||||
|
||||
// CIRCUITPY more functionality
|
||||
// CIRCUITPY-CHANGE: more functionality
|
||||
// this is a classmethod
|
||||
STATIC mp_obj_t int_from_bytes(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||
// TODO: Support signed param (assumes signed=False at the moment)
|
||||
@ -575,7 +575,7 @@ STATIC mp_obj_t int_to_bytes(size_t n_args, const mp_obj_t *pos_args, mp_map_t *
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(int_to_bytes_obj, 3, int_to_bytes);
|
||||
|
||||
STATIC const mp_rom_map_elem_t int_locals_dict_table[] = {
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
#if MICROPY_CPYTHON_COMPAT
|
||||
{ MP_ROM_QSTR(MP_QSTR_bit_length), MP_ROM_PTR(&int_bit_length_obj) },
|
||||
#endif
|
||||
|
@ -53,7 +53,7 @@ char *mp_obj_int_formatted(char **buf, size_t *buf_size, size_t *fmt_size, mp_co
|
||||
int base, const char *prefix, char base_char, char comma);
|
||||
char *mp_obj_int_formatted_impl(char **buf, size_t *buf_size, size_t *fmt_size, mp_const_obj_t self_in,
|
||||
int base, const char *prefix, char base_char, char comma);
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
#if MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_NONE
|
||||
void mp_obj_int_buffer_overflow_check(mp_obj_t self_in, size_t nbytes, bool is_signed);
|
||||
#endif
|
||||
@ -61,7 +61,7 @@ void mp_obj_int_buffer_overflow_check(mp_obj_t self_in, size_t nbytes, bool is_s
|
||||
void mp_small_int_buffer_overflow_check(mp_int_t val, size_t nbytes, bool is_signed);
|
||||
|
||||
mp_int_t mp_obj_int_hash(mp_obj_t self_in);
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
mp_obj_t mp_obj_int_bit_length_impl(mp_obj_t self_in);
|
||||
mp_obj_t mp_obj_int_from_bytes_impl(bool big_endian, size_t len, const byte *buf);
|
||||
void mp_obj_int_to_bytes_impl(mp_obj_t self_in, bool big_endian, size_t len, byte *buf);
|
||||
|
@ -43,7 +43,7 @@
|
||||
const mp_obj_int_t mp_sys_maxsize_obj = {{&mp_type_int}, MP_SSIZE_MAX};
|
||||
#endif
|
||||
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
mp_obj_t mp_obj_int_bit_length_impl(mp_obj_t self_in) {
|
||||
assert(mp_obj_is_type(self_in, &mp_type_int));
|
||||
mp_obj_int_t *self = self_in;
|
||||
|
@ -106,7 +106,7 @@ char *mp_obj_int_formatted_impl(char **buf, size_t *buf_size, size_t *fmt_size,
|
||||
return str;
|
||||
}
|
||||
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
mp_obj_t mp_obj_int_bit_length_impl(mp_obj_t self_in) {
|
||||
assert(mp_obj_is_exact_type(self_in, &mp_type_int));
|
||||
mp_obj_int_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
|
@ -39,7 +39,7 @@ STATIC mp_obj_t list_pop(size_t n_args, const mp_obj_t *args);
|
||||
// TODO: Move to mpconfig.h
|
||||
#define LIST_MIN_ALLOC 4
|
||||
|
||||
// CIRCUITPY: native_list() and other changes here for broadcom port
|
||||
// CIRCUITPY-CHANGE: native_list() and other changes here for broadcom port
|
||||
// https://github.com/adafruit/circuitpython/pull/5610
|
||||
|
||||
/******************************************************************************/
|
||||
@ -293,7 +293,7 @@ inline mp_obj_t mp_obj_list_pop(mp_obj_list_t *self, size_t index) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
STATIC mp_obj_t list_pop(size_t n_args, const mp_obj_t *args) {
|
||||
mp_check_self(mp_obj_is_type(args[0], &mp_type_list));
|
||||
mp_obj_list_t *self = native_list(args[0]);
|
||||
|
@ -37,7 +37,7 @@ typedef struct _mp_obj_list_t {
|
||||
|
||||
void mp_obj_list_init(mp_obj_list_t *o, size_t n);
|
||||
mp_obj_t mp_obj_list_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args);
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
mp_obj_t mp_obj_list_pop(mp_obj_list_t *self, size_t index);
|
||||
void mp_obj_list_insert(mp_obj_list_t *self, size_t index, mp_obj_t obj);
|
||||
|
||||
|
@ -44,7 +44,7 @@ size_t mp_obj_namedtuple_find_field(const mp_obj_namedtuple_type_t *type, qstr n
|
||||
return (size_t)-1;
|
||||
}
|
||||
|
||||
// CIRCUITPY differences
|
||||
// CIRCUITPY-CHANGE: differences
|
||||
#if MICROPY_PY_COLLECTIONS_NAMEDTUPLE__ASDICT
|
||||
STATIC mp_obj_t namedtuple_asdict(mp_obj_t self_in) {
|
||||
mp_obj_namedtuple_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
|
@ -52,7 +52,7 @@ void namedtuple_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest);
|
||||
mp_obj_namedtuple_type_t *mp_obj_new_namedtuple_base(size_t n_fields, mp_obj_t *fields);
|
||||
mp_obj_t namedtuple_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args);
|
||||
|
||||
// CIRCUITPY yikes
|
||||
// CIRCUITPY-CHANGE: yikes
|
||||
#define NAMEDTUPLE_TYPE_BASE_AND_SLOTS_MAKE_NEW(type_name, make_new_fun) \
|
||||
.base = { \
|
||||
.base = { .type = &mp_type_type }, \
|
||||
|
@ -49,7 +49,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(object___init___obj, object___init__);
|
||||
|
||||
STATIC mp_obj_t object___new__(mp_obj_t cls) {
|
||||
if (!mp_obj_is_type(cls, &mp_type_type) || !mp_obj_is_instance_type((mp_obj_type_t *)MP_OBJ_TO_PTR(cls))) {
|
||||
// CIRCUITPY better error
|
||||
// CIRCUITPY-CHANGE: better error
|
||||
mp_raise_TypeError(MP_ERROR_TEXT("__new__ arg must be a user-type"));
|
||||
}
|
||||
// This executes only "__new__" part of instance creation.
|
||||
|
@ -31,7 +31,7 @@
|
||||
#include "py/objproperty.h"
|
||||
#include "py/runtime.h"
|
||||
|
||||
// CIRCUITPY changes to reduce property proxy table size
|
||||
// CIRCUITPY-CHANGE: changes to reduce property proxy table size
|
||||
// when possible
|
||||
|
||||
#if MICROPY_PY_BUILTINS_PROPERTY
|
||||
|
12
py/objstr.c
12
py/objstr.c
@ -34,7 +34,7 @@
|
||||
#include "py/runtime.h"
|
||||
#include "py/stackctrl.h"
|
||||
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
const char nibble_to_hex_upper[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
||||
'A', 'B', 'C', 'D', 'E', 'F'};
|
||||
|
||||
@ -272,7 +272,7 @@ STATIC mp_obj_t bytes_make_new(const mp_obj_type_t *type_in, size_t n_args, size
|
||||
return mp_obj_new_bytes_from_vstr(&vstr);
|
||||
}
|
||||
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
// check if __bytes__ exists, and if so delegate to it
|
||||
mp_obj_t dest[2];
|
||||
mp_load_method_maybe(args[0], MP_QSTR___bytes__, dest);
|
||||
@ -381,7 +381,7 @@ mp_obj_t mp_obj_str_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_i
|
||||
return mp_const_empty_bytes;
|
||||
}
|
||||
}
|
||||
// CIRCUITPY: more careful checking of length
|
||||
// CIRCUITPY-CHANGE: more careful checking of length
|
||||
size_t new_len = mp_seq_multiply_len(lhs_len, n);
|
||||
vstr_t vstr;
|
||||
vstr_init_len(&vstr, new_len);
|
||||
@ -1024,7 +1024,7 @@ STATIC vstr_t mp_obj_str_format_helper(const char *str, const char *top, int *ar
|
||||
#if MICROPY_ERROR_REPORTING <= MICROPY_ERROR_REPORTING_TERSE
|
||||
terse_str_format_value_error();
|
||||
#else
|
||||
// CIRCUITPY better error message
|
||||
// CIRCUITPY-CHANGE: better error message
|
||||
mp_raise_ValueError_varg(MP_ERROR_TEXT("unmatched '%c' in format"), '}');
|
||||
#endif
|
||||
}
|
||||
@ -2179,7 +2179,7 @@ MP_DEFINE_CONST_DICT_WITH_SIZE(mp_obj_array_locals_dict,
|
||||
TABLE_ENTRIES_ARRAY);
|
||||
#endif
|
||||
|
||||
// CIRCUITPY: hex() but no cast()
|
||||
// CIRCUITPY-CHANGE: hex() but no cast()
|
||||
#if MICROPY_PY_BUILTINS_MEMORYVIEW && MICROPY_PY_BUILTINS_BYTES_HEX && !MICROPY_CPYTHON_COMPAT
|
||||
MP_DEFINE_CONST_DICT_WITH_SIZE(mp_obj_memoryview_locals_dict,
|
||||
array_bytearray_str_bytes_locals_table + TABLE_ENTRIES_ARRAY,
|
||||
@ -2342,7 +2342,7 @@ mp_obj_t mp_obj_new_bytes(const byte *data, size_t len) {
|
||||
return mp_obj_new_str_copy(&mp_type_bytes, data, len);
|
||||
}
|
||||
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
mp_obj_t mp_obj_new_bytes_of_zeros(size_t len) {
|
||||
vstr_t vstr;
|
||||
vstr_init_len(&vstr, len);
|
||||
|
@ -29,7 +29,7 @@
|
||||
#include "py/obj.h"
|
||||
#include "py/objarray.h"
|
||||
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
extern const char nibble_to_hex_upper[16];
|
||||
extern const char nibble_to_hex_lower[16];
|
||||
|
||||
@ -121,7 +121,7 @@ extern const mp_obj_dict_t mp_obj_bytearray_locals_dict;
|
||||
extern const mp_obj_dict_t mp_obj_array_locals_dict;
|
||||
#endif
|
||||
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(bytes_decode_obj);
|
||||
MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_obj_bytes_hex_as_str_obj);
|
||||
|
||||
|
@ -73,7 +73,7 @@ STATIC void uni_print_quoted(const mp_print_t *print, const byte *str_data, uint
|
||||
mp_print_str(print, "\\r");
|
||||
} else if (ch == '\t') {
|
||||
mp_print_str(print, "\\t");
|
||||
// CIRCUITPY difference: print printable Unicode chars
|
||||
// CIRCUITPY-CHANGE: print printable Unicode chars
|
||||
} else if (ch <= 0x1f || (0x7f <= ch && ch <= 0xa0) || ch == 0xad) {
|
||||
mp_printf(print, "\\x%02x", ch);
|
||||
} else if ((0x2000 <= ch && ch <= 0x200f) || ch == 0x2028 || ch == 0x2029) {
|
||||
|
@ -165,7 +165,7 @@ mp_obj_t mp_obj_tuple_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) {
|
||||
if (n <= 0) {
|
||||
return mp_const_empty_tuple;
|
||||
}
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
size_t new_len = mp_seq_multiply_len(o->len, n);
|
||||
mp_obj_tuple_t *s = MP_OBJ_TO_PTR(mp_obj_new_tuple(new_len, NULL));
|
||||
mp_seq_multiply(o->items, sizeof(*o->items), o->len, n, s->items);
|
||||
|
@ -50,7 +50,7 @@ mp_obj_t mp_obj_tuple_getiter(mp_obj_t o_in, mp_obj_iter_buf_t *iter_buf);
|
||||
|
||||
extern const mp_obj_type_t mp_type_attrtuple;
|
||||
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
// Relies on gcc Variadic Macros and Statement Expressions
|
||||
#define MP_OBJ_NEW_TUPLE(...) ({mp_obj_t _z[] = {__VA_ARGS__}; mp_obj_new_tuple(MP_ARRAY_SIZE(_z), _z);})
|
||||
|
||||
|
10
py/objtype.c
10
py/objtype.c
@ -82,7 +82,7 @@ STATIC int instance_count_native_bases(const mp_obj_type_t *type, const mp_obj_t
|
||||
}
|
||||
}
|
||||
|
||||
// CIRCUITPY differences
|
||||
// CIRCUITPY-CHANGE: differences
|
||||
// This wrapper function is allows a subclass of a native type to call the
|
||||
// __init__() method (corresponding to type->make_new) of the native type.
|
||||
STATIC mp_obj_t native_base_init_wrapper(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||
@ -128,7 +128,7 @@ mp_obj_instance_t *mp_obj_new_instance(const mp_obj_type_t *class, const mp_obj_
|
||||
return o;
|
||||
}
|
||||
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
// When instances are first created they have the base_init wrapper as their native parent's
|
||||
// instance because make_new combines __new__ and __init__. This object is invalid for the native
|
||||
// code so it must call this method to ensure that the given object has been __init__'d and is
|
||||
@ -303,7 +303,7 @@ STATIC void instance_print(const mp_print_t *print, mp_obj_t self_in, mp_print_k
|
||||
}
|
||||
|
||||
// TODO: CPython prints fully-qualified type name
|
||||
// CIRCUITPY: use qstr
|
||||
// CIRCUITPY-CHANGE: use qstr
|
||||
mp_printf(print, "<%q object at %p>", mp_obj_get_type_qstr(self_in), self);
|
||||
}
|
||||
|
||||
@ -732,7 +732,7 @@ STATIC bool mp_obj_instance_store_attr(mp_obj_t self_in, qstr attr, mp_obj_t val
|
||||
// would be called by the descriptor code down below. But that way
|
||||
// requires overhead for the nested mp_call's and overhead for
|
||||
// the code.
|
||||
// CIRCUITPY: variable number of proxies
|
||||
// CIRCUITPY-CHANGE: variable number of proxies
|
||||
size_t n_proxy;
|
||||
const mp_obj_t *proxy = mp_obj_property_get(member[0], &n_proxy);
|
||||
mp_obj_t dest[2] = {self_in, value};
|
||||
@ -1347,7 +1347,7 @@ STATIC void super_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
|
||||
// Looked up native __init__ so defer to it
|
||||
dest[0] = MP_OBJ_FROM_PTR(&native_base_init_wrapper_obj);
|
||||
dest[1] = self->obj;
|
||||
// CIRCUITPY better support for properties
|
||||
// CIRCUITPY-CHANGE: better support for properties
|
||||
} else {
|
||||
mp_obj_t member = dest[0];
|
||||
// changes to mp_obj_instance_load_attr may require changes
|
||||
|
@ -52,7 +52,7 @@ mp_obj_t mp_obj_instance_call(mp_obj_t self_in, size_t n_args, size_t n_kw, cons
|
||||
// this needs to be exposed for mp_getiter
|
||||
mp_obj_t mp_obj_instance_getiter(mp_obj_t self_in, mp_obj_iter_buf_t *iter_buf);
|
||||
|
||||
// CIRCUITPY addition
|
||||
// CIRCUITPY-CHANGE: addition
|
||||
void mp_obj_assert_native_inited(mp_obj_t native_object);
|
||||
|
||||
#endif // MICROPY_INCLUDED_PY_OBJTYPE_H
|
||||
|
@ -252,7 +252,7 @@ STATIC const uint16_t *get_rule_arg(uint8_t r_id) {
|
||||
return &rule_arg_combined_table[off];
|
||||
}
|
||||
|
||||
// CIRCUITPY ignore compiler warning
|
||||
// CIRCUITPY-CHANGE: ignore compiler warning
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wcast-align"
|
||||
|
||||
@ -1038,7 +1038,7 @@ mp_parse_tree_t mp_parse(mp_lexer_t *lex, mp_parse_input_kind_t input_kind) {
|
||||
|
||||
parser.rule_stack_alloc = MICROPY_ALLOC_PARSE_RULE_INIT;
|
||||
parser.rule_stack_top = 0;
|
||||
// CIRCUITPY make parsing more memory flexible
|
||||
// CIRCUITPY-CHANGE: make parsing more memory flexible
|
||||
// https://github.com/adafruit/circuitpython/pull/552
|
||||
parser.rule_stack = NULL;
|
||||
while (parser.rule_stack_alloc > 1) {
|
||||
|
@ -53,7 +53,7 @@ mp_obj_t mp_parse_num_integer(const char *restrict str_, size_t len, int base, m
|
||||
mp_obj_t ret_val;
|
||||
|
||||
// check radix base
|
||||
// CIRCUITPY use validator
|
||||
// CIRCUITPY-CHANGE: use validator
|
||||
if (base != 0) {
|
||||
// this won't be reached if lex!=NULL
|
||||
mp_arg_validate_int_range(base, 2, 36, MP_QSTR_base);
|
||||
|
@ -87,7 +87,7 @@ void mp_native_relocate(void *ri_in, uint8_t *text, uintptr_t reloc_text) {
|
||||
size_t addr = read_uint(ri->reader);
|
||||
if ((addr & 1) == 0) {
|
||||
// Point to somewhere in text
|
||||
// CIRCUITPY avoid compiler warnings
|
||||
// CIRCUITPY-CHANGE: avoid compiler warnings
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wcast-align"
|
||||
addr_to_adjust = &((uintptr_t *)text)[addr >> 1];
|
||||
@ -405,7 +405,7 @@ void mp_raw_code_load(mp_reader_t *reader, mp_compiled_module_t *cm) {
|
||||
byte header[4];
|
||||
read_bytes(reader, header, sizeof(header));
|
||||
byte arch = MPY_FEATURE_DECODE_ARCH(header[2]);
|
||||
// CIRCUITPY: 'C', not 'M'
|
||||
// CIRCUITPY-CHANGE: 'C', not 'M'
|
||||
if (header[0] != 'C'
|
||||
|| header[1] != MPY_VERSION
|
||||
|| (arch != MP_NATIVE_ARCH_NONE && MPY_FEATURE_DECODE_SUB_VERSION(header[2]) != MPY_SUB_VERSION)
|
||||
|
8
py/py.mk
8
py/py.mk
@ -7,7 +7,7 @@ HEADER_BUILD = $(BUILD)/genhdr
|
||||
# file containing qstr defs for the core Python bit
|
||||
PY_QSTR_DEFS = $(PY_SRC)/qstrdefs.h
|
||||
|
||||
# CIRCUITPY
|
||||
# CIRCUITPY-CHANGE
|
||||
TRANSLATION ?= en_US
|
||||
|
||||
# If qstr autogeneration is not disabled we specify the output header
|
||||
@ -75,7 +75,7 @@ PY_O += $(addprefix $(BUILD)/, $(SRC_USERMOD_PATHFIX_LIB_C:.c=.o))
|
||||
PY_O += $(addprefix $(BUILD)/, $(SRC_USERMOD_PATHFIX_LIB_CXX:.cpp=.o))
|
||||
endif # USER_C_MODULES
|
||||
|
||||
# CIRCUITPY
|
||||
# CIRCUITPY-CHANGE
|
||||
ifeq ($(CIRCUITPY_ULAB),1)
|
||||
ULAB_SRCS := $(shell find $(TOP)/extmod/ulab/code -type f -name "*.c")
|
||||
ULAB_SRC_PATHFIX := $(patsubst $(TOP)/%,%,$(ULAB_SRCS))
|
||||
@ -255,7 +255,7 @@ $(HEADER_BUILD)/compressed.data.h: $(HEADER_BUILD)/compressed.collected
|
||||
$(ECHO) "GEN $@"
|
||||
$(Q)$(PYTHON) $(PY_SRC)/makecompresseddata.py $< > $@
|
||||
|
||||
# CIRCUITPY: for translations
|
||||
# CIRCUITPY-CHANGE: for translations
|
||||
$(HEADER_BUILD)/$(TRANSLATION).mo: $(TOP)/locale/$(TRANSLATION).po | $(HEADER_BUILD)
|
||||
$(Q)$(PYTHON) $(TOP)/tools/msgfmt.py -o $@ $^
|
||||
|
||||
@ -293,7 +293,7 @@ $(BUILD)/shared/libc/string0.o: CFLAGS += $(CFLAGS_BUILTIN)
|
||||
# that the function preludes are of a minimal and predictable form.
|
||||
$(PY_BUILD)/nlr%.o: CFLAGS += -Os
|
||||
|
||||
# CIRCUITPY: separate SUPEROPT for gc.o and vm.o
|
||||
# CIRCUITPY-CHANGE: separate SUPEROPT for gc.o and vm.o
|
||||
# optimising gc for speed; 5ms down to 4ms on pybv2
|
||||
ifndef SUPEROPT_GC
|
||||
SUPEROPT_GC = 1
|
||||
|
@ -33,7 +33,7 @@
|
||||
#include "py/gc.h"
|
||||
#include "py/runtime.h"
|
||||
|
||||
// CIRCUITPY changes for TRANSLATION
|
||||
// CIRCUITPY-CHANGE: changes for TRANSLATION
|
||||
|
||||
// NOTE: we are using linear arrays to store and search for qstr's (unique strings, interned strings)
|
||||
// ultimately we will replace this with a static hash table of some kind
|
||||
@ -121,7 +121,7 @@ extern const qstr_pool_t MICROPY_QSTR_EXTRA_POOL;
|
||||
#define CONST_POOL mp_qstr_const_pool
|
||||
#endif
|
||||
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
void qstr_reset(void) {
|
||||
MP_STATE_VM(last_pool) = (qstr_pool_t *)&CONST_POOL; // we won't modify the const_pool since it has no allocated room left
|
||||
MP_STATE_VM(qstr_last_chunk) = NULL;
|
||||
|
@ -39,7 +39,7 @@
|
||||
enum {
|
||||
#ifndef NO_QSTR
|
||||
#define QDEF(id, hash, len, str) id,
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
#define TRANSLATION(english_id, number)
|
||||
#include "genhdr/qstrdefs.generated.h"
|
||||
#undef QDEF
|
||||
|
@ -35,7 +35,7 @@
|
||||
QCFG(BYTES_IN_LEN, MICROPY_QSTR_BYTES_IN_LEN)
|
||||
QCFG(BYTES_IN_HASH, MICROPY_QSTR_BYTES_IN_HASH)
|
||||
|
||||
// CIRCUITPY translatable messages removed
|
||||
// CIRCUITPY-CHANGE: translatable messages removed
|
||||
|
||||
Q()
|
||||
Q(*)
|
||||
|
@ -26,7 +26,7 @@
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
// CIRCUITPY thoroughly reworked
|
||||
// CIRCUITPY-CHANGE: thoroughly reworked
|
||||
|
||||
#include "ringbuf.h"
|
||||
|
||||
|
@ -31,7 +31,7 @@
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
// CIRCUITPY thoroughly reworked
|
||||
// CIRCUITPY-CHANGE: thoroughly reworked
|
||||
|
||||
typedef struct _ringbuf_t {
|
||||
uint8_t *buf;
|
||||
|
24
py/runtime.c
24
py/runtime.c
@ -89,7 +89,7 @@ void mp_init(void) {
|
||||
|
||||
#if MICROPY_KBD_EXCEPTION
|
||||
// initialise the exception object for raising KeyboardInterrupt
|
||||
// CIRCUITPY chained exception support
|
||||
// CIRCUITPY-CHANGE: chained exception support
|
||||
mp_obj_exception_initialize0(&MP_STATE_VM(mp_kbd_exception), &mp_type_KeyboardInterrupt);
|
||||
#endif
|
||||
|
||||
@ -134,7 +134,7 @@ void mp_init(void) {
|
||||
}
|
||||
#endif
|
||||
|
||||
// CIRCUITPY: do not unmount /
|
||||
// CIRCUITPY-CHANGE: do not unmount /
|
||||
#if MICROPY_VFS && 0
|
||||
// initialise the VFS sub-system
|
||||
MP_STATE_VM(vfs_cur) = NULL;
|
||||
@ -248,7 +248,7 @@ mp_obj_t MICROPY_WRAP_MP_LOAD_GLOBAL(mp_load_global)(qstr qst) {
|
||||
return elem->value;
|
||||
}
|
||||
|
||||
// CIRCUITPY noinline
|
||||
// CIRCUITPY-CHANGE: noinline
|
||||
// https://github.com/adafruit/circuitpython/pull/8071
|
||||
mp_obj_t __attribute__((noinline)) mp_load_build_class(void) {
|
||||
DEBUG_OP_printf("load_build_class\n");
|
||||
@ -950,7 +950,7 @@ mp_obj_t mp_call_method_n_kw_var(bool have_self, size_t n_args_n_kw, const mp_ob
|
||||
}
|
||||
|
||||
// unpacked items are stored in reverse order into the array pointed to by items
|
||||
// CIRCUITPY noline
|
||||
// CIRCUITPY-CHANGE: noline
|
||||
void __attribute__((noinline, )) mp_unpack_sequence(mp_obj_t seq_in, size_t num, mp_obj_t *items) {
|
||||
size_t seq_len;
|
||||
if (mp_obj_is_type(seq_in, &mp_type_tuple) || mp_obj_is_type(seq_in, &mp_type_list)) {
|
||||
@ -998,7 +998,7 @@ too_long:
|
||||
}
|
||||
|
||||
// unpacked items are stored in reverse order into the array pointed to by items
|
||||
// CIRCUITPY noinline
|
||||
// CIRCUITPY-CHANGE: noinline
|
||||
void __attribute__((noinline)) mp_unpack_ex(mp_obj_t seq_in, size_t num_in, mp_obj_t *items) {
|
||||
size_t num_left = num_in & 0xff;
|
||||
size_t num_right = (num_in >> 8) & 0xff;
|
||||
@ -1164,7 +1164,7 @@ void mp_convert_member_lookup(mp_obj_t self, const mp_obj_type_t *type, mp_obj_t
|
||||
}
|
||||
dest[0] = ((mp_obj_static_class_method_t *)MP_OBJ_TO_PTR(member))->fun;
|
||||
dest[1] = MP_OBJ_FROM_PTR(type);
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
// https://github.com/adafruit/circuitpython/commit/8fae7d2e3024de6336affc4b2a8fa992c946e017
|
||||
#if MICROPY_PY_BUILTINS_PROPERTY
|
||||
// If self is MP_OBJ_NULL, we looking at the class itself, not an instance.
|
||||
@ -1297,7 +1297,7 @@ void mp_store_attr(mp_obj_t base, qstr attr, mp_obj_t value) {
|
||||
// success
|
||||
return;
|
||||
}
|
||||
// CIRCUITPY https://github.com/adafruit/circuitpython/pull/50
|
||||
// CIRCUITPY-CHANGE: https://github.com/adafruit/circuitpython/pull/50
|
||||
#if MICROPY_PY_BUILTINS_PROPERTY
|
||||
} else if (MP_OBJ_TYPE_HAS_SLOT(type, locals_dict)) {
|
||||
// generic method lookup
|
||||
@ -1334,7 +1334,7 @@ void mp_store_attr(mp_obj_t base, qstr attr, mp_obj_t value) {
|
||||
mp_raise_AttributeError(MP_ERROR_TEXT("no such attribute"));
|
||||
#else
|
||||
mp_raise_msg_varg(&mp_type_AttributeError,
|
||||
// CIRCUITPY better error message
|
||||
// CIRCUITPY-CHANGE: better error message
|
||||
MP_ERROR_TEXT("can't set attribute '%q'"),
|
||||
attr);
|
||||
#endif
|
||||
@ -1393,7 +1393,7 @@ mp_obj_t mp_getiter(mp_obj_t o_in, mp_obj_iter_buf_t *iter_buf) {
|
||||
|
||||
STATIC mp_fun_1_t type_get_iternext(const mp_obj_type_t *type) {
|
||||
if ((type->flags & MP_TYPE_FLAG_ITER_IS_STREAM) == MP_TYPE_FLAG_ITER_IS_STREAM) {
|
||||
// CIRCUITPY: unneeded declaration
|
||||
// CIRCUITPY-CHANGE: unneeded declaration
|
||||
// mp_obj_t mp_stream_unbuffered_iter(mp_obj_t self);
|
||||
return mp_stream_unbuffered_iter;
|
||||
} else if (type->flags & MP_TYPE_FLAG_ITER_IS_ITERNEXT) {
|
||||
@ -1471,7 +1471,7 @@ mp_vm_return_kind_t mp_resume(mp_obj_t self_in, mp_obj_t send_value, mp_obj_t th
|
||||
assert((send_value != MP_OBJ_NULL) ^ (throw_value != MP_OBJ_NULL));
|
||||
const mp_obj_type_t *type = mp_obj_get_type(self_in);
|
||||
|
||||
// CIRCUITPY distinguishes generators and coroutines.
|
||||
// CIRCUITPY-CHANGE: distinguishes generators and coroutines.
|
||||
if (type == &mp_type_gen_instance
|
||||
#if MICROPY_PY_ASYNC_AWAIT
|
||||
|| type == &mp_type_coro_instance
|
||||
@ -1597,7 +1597,7 @@ mp_obj_t mp_import_name(qstr name, mp_obj_t fromlist, mp_obj_t level) {
|
||||
return mp_builtin___import__(5, args);
|
||||
}
|
||||
|
||||
// CIRCUITPY noinline
|
||||
// CIRCUITPY-CHANGE: noinline
|
||||
mp_obj_t __attribute__((noinline, )) mp_import_from(mp_obj_t module, qstr name) {
|
||||
DEBUG_printf("import from %p %s\n", module, qstr_str(name));
|
||||
|
||||
@ -1702,7 +1702,7 @@ mp_obj_t mp_parse_compile_execute(mp_lexer_t *lex, mp_parse_input_kind_t parse_i
|
||||
|
||||
#endif // MICROPY_ENABLE_COMPILER
|
||||
|
||||
// CIRCUITPY MP_COLD are CIRCUITPY
|
||||
// CIRCUITPY-CHANGE: MP_COLD are CIRCUITPY
|
||||
NORETURN MP_COLD void m_malloc_fail(size_t num_bytes) {
|
||||
DEBUG_printf("memory allocation failed, allocating %u bytes\n", (uint)num_bytes);
|
||||
#if MICROPY_ENABLE_GC
|
||||
|
@ -31,7 +31,7 @@
|
||||
#include "py/mpstate.h"
|
||||
#include "py/pystack.h"
|
||||
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
#include "supervisor/linker.h"
|
||||
#include "supervisor/shared/translate/translate.h"
|
||||
|
||||
@ -127,7 +127,7 @@ void mp_arg_parse_all_kw_array(size_t n_pos, size_t n_kw, const mp_obj_t *args,
|
||||
NORETURN void mp_arg_error_terse_mismatch(void);
|
||||
NORETURN void mp_arg_error_unimpl_kw(void);
|
||||
|
||||
// CIRCUITPY arg validation routines
|
||||
// CIRCUITPY-CHANGE: arg validation routines
|
||||
NORETURN void mp_arg_error_invalid(qstr arg_name);
|
||||
mp_int_t mp_arg_validate_int(mp_int_t i, mp_int_t required_i, qstr arg_name);
|
||||
mp_int_t mp_arg_validate_int_min(mp_int_t i, mp_int_t min, qstr arg_name);
|
||||
|
@ -35,7 +35,7 @@
|
||||
#define MP_SCOPE_FLAG_VARKEYWORDS (0x02)
|
||||
#define MP_SCOPE_FLAG_VARARGS (0x04)
|
||||
#define MP_SCOPE_FLAG_DEFKWARGS (0x08)
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
#define MP_SCOPE_FLAG_ASYNC (0x10)
|
||||
#define MP_SCOPE_FLAG_REFGLOBALS (0x20) // used only if native emitter enabled
|
||||
#define MP_SCOPE_FLAG_HASCONSTS (0x40) // used only if native emitter enabled
|
||||
|
@ -46,7 +46,7 @@ void MICROPY_WRAP_MP_SCHED_EXCEPTION(mp_sched_exception)(mp_obj_t exc) {
|
||||
#if MICROPY_KBD_EXCEPTION
|
||||
// This function may be called asynchronously at any time so only do the bare minimum.
|
||||
void MICROPY_WRAP_MP_SCHED_KEYBOARD_INTERRUPT(mp_sched_keyboard_interrupt)(void) {
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
MP_STATE_VM(mp_kbd_exception).traceback = (mp_obj_traceback_t *)&mp_const_empty_traceback_obj;
|
||||
mp_sched_exception(MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception)));
|
||||
}
|
||||
|
@ -28,7 +28,7 @@
|
||||
#include "py/stackctrl.h"
|
||||
|
||||
void mp_stack_ctrl_init(void) {
|
||||
// CIRCUITPY: Force routine to not be inlined. Better guarantee than MP_NOINLINE for -flto.
|
||||
// CIRCUITPY-CHANGE: Force routine to not be inlined. Better guarantee than MP_NOINLINE for -flto.
|
||||
__asm volatile ("");
|
||||
#if __GNUC__ >= 13
|
||||
#pragma GCC diagnostic push
|
||||
@ -47,7 +47,7 @@ void mp_stack_set_top(void *top) {
|
||||
|
||||
mp_uint_t PLACE_IN_ITCM(mp_stack_usage)(void) {
|
||||
// Assumes descending stack
|
||||
// CIRCUITPY: Force routine to not be inlined. Better guarantee than MP_NOINLINE for -flto.
|
||||
// CIRCUITPY-CHANGE: Force routine to not be inlined. Better guarantee than MP_NOINLINE for -flto.
|
||||
__asm volatile ("");
|
||||
volatile int stack_dummy;
|
||||
return MP_STATE_THREAD(stack_top) - (char *)&stack_dummy;
|
||||
|
@ -28,7 +28,7 @@
|
||||
#define MICROPY_INCLUDED_PY_STREAM_H
|
||||
|
||||
#include "py/obj.h"
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
#include "py/proto.h"
|
||||
#include "py/mperrno.h"
|
||||
|
||||
@ -69,7 +69,7 @@ struct mp_stream_seek_t {
|
||||
|
||||
// Stream protocol
|
||||
typedef struct _mp_stream_p_t {
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
MP_PROTOCOL_HEAD
|
||||
// On error, functions should return MP_STREAM_ERROR and fill in *errcode (values
|
||||
// are implementation-dependent, but will be exposed to user, e.g. via exception).
|
||||
@ -123,7 +123,7 @@ mp_uint_t mp_stream_rw(mp_obj_t stream, void *buf, mp_uint_t size, int *errcode,
|
||||
#define mp_stream_read_exactly(stream, buf, size, err) mp_stream_rw(stream, buf, size, err, MP_STREAM_RW_READ)
|
||||
|
||||
void mp_stream_write_adaptor(void *self, const char *buf, size_t len);
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
mp_obj_t mp_stream_flush(mp_obj_t self);
|
||||
|
||||
#if MICROPY_STREAMS_POSIX_API
|
||||
|
16
py/vm.c
16
py/vm.c
@ -195,7 +195,7 @@
|
||||
#define TRACE_TICK(current_ip, current_sp, is_exception)
|
||||
#endif // MICROPY_PY_SYS_SETTRACE
|
||||
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
STATIC mp_obj_t get_active_exception(mp_exc_stack_t *exc_sp, mp_exc_stack_t *exc_stack) {
|
||||
for (mp_exc_stack_t *e = exc_sp; e >= exc_stack; --e) {
|
||||
if (e->prev_exc != NULL) {
|
||||
@ -237,7 +237,7 @@ mp_vm_return_kind_t MICROPY_WRAP_MP_EXECUTE_BYTECODE(mp_execute_bytecode)(mp_cod
|
||||
#endif
|
||||
#if MICROPY_OPT_COMPUTED_GOTO
|
||||
#include "py/vmentrytable.h"
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
#if MICROPY_OPT_COMPUTED_GOTO_SAVE_SPACE
|
||||
#define ONE_TRUE_DISPATCH() one_true_dispatch : do { \
|
||||
TRACE(ip); \
|
||||
@ -328,7 +328,7 @@ outer_dispatch_loop:
|
||||
for (;;) {
|
||||
dispatch_loop:
|
||||
#if MICROPY_OPT_COMPUTED_GOTO
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
ONE_TRUE_DISPATCH();
|
||||
#else
|
||||
TRACE(ip);
|
||||
@ -1061,7 +1061,7 @@ unwind_jump:;
|
||||
}
|
||||
#endif
|
||||
SET_TOP(mp_call_method_n_kw(unum & 0xff, (unum >> 8) & 0xff, sp));
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
DISPATCH_WITH_PEND_EXC_CHECK();
|
||||
}
|
||||
|
||||
@ -1172,7 +1172,7 @@ unwind_return:
|
||||
ENTRY(MP_BC_RAISE_LAST): {
|
||||
MARK_EXC_IP_SELECTIVE();
|
||||
// search for the inner-most previous exception, to reraise it
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
mp_obj_t obj = get_active_exception(exc_sp, exc_stack);
|
||||
if (obj == MP_OBJ_NULL) {
|
||||
obj = mp_obj_new_exception_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("no active exception to reraise"));
|
||||
@ -1183,7 +1183,7 @@ unwind_return:
|
||||
ENTRY(MP_BC_RAISE_OBJ): {
|
||||
MARK_EXC_IP_SELECTIVE();
|
||||
mp_obj_t obj = mp_make_raise_obj(TOP());
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
#if MICROPY_CPYTHON_EXCEPTION_CHAIN
|
||||
mp_obj_t active_exception = get_active_exception(exc_sp, exc_stack);
|
||||
if (active_exception != MP_OBJ_NULL && active_exception != obj) {
|
||||
@ -1195,7 +1195,7 @@ unwind_return:
|
||||
|
||||
ENTRY(MP_BC_RAISE_FROM): {
|
||||
MARK_EXC_IP_SELECTIVE();
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
mp_obj_t cause = POP();
|
||||
mp_obj_t obj = mp_make_raise_obj(TOP());
|
||||
#if MICROPY_CPYTHON_EXCEPTION_CHAIN
|
||||
@ -1445,7 +1445,7 @@ unwind_loop:
|
||||
// - exceptions re-raised by END_FINALLY
|
||||
// - exceptions re-raised explicitly by "raise"
|
||||
if ( true
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
#if MICROPY_CONST_GENERATOREXIT_OBJ
|
||||
&& nlr.ret_val != &mp_const_GeneratorExit_obj
|
||||
#endif
|
||||
|
@ -51,7 +51,7 @@ void vstr_init(vstr_t *vstr, size_t alloc) {
|
||||
// Init the vstr so it allocs exactly enough ram to hold a null-terminated
|
||||
// string of the given length, and set the length.
|
||||
void vstr_init_len(vstr_t *vstr, size_t len) {
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
if (len == SIZE_MAX) {
|
||||
m_malloc_fail(len);
|
||||
}
|
||||
|
@ -34,7 +34,7 @@
|
||||
#define likely(x) __builtin_expect((x), 1)
|
||||
#endif
|
||||
|
||||
// CIRCUITPY avoid compiler warnings
|
||||
// CIRCUITPY-CHANGE: avoid compiler warnings
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wcast-align"
|
||||
void *memcpy(void *dst, const void *src, size_t n) {
|
||||
@ -75,7 +75,7 @@ void *memcpy(void *dst, const void *src, size_t n) {
|
||||
return dst;
|
||||
}
|
||||
|
||||
// CIRCUITPY extern
|
||||
// CIRCUITPY-CHANGE: extern
|
||||
extern void *__memcpy_chk(void *dest, const void *src, size_t len, size_t slen);
|
||||
void *__memcpy_chk(void *dest, const void *src, size_t len, size_t slen) {
|
||||
if (len > slen) {
|
||||
|
@ -40,7 +40,7 @@
|
||||
#define DEBUG_printf(...) (void)0
|
||||
#endif
|
||||
|
||||
// CIRCUITPY a number of changes
|
||||
// CIRCUITPY-CHANGE: a number of changes
|
||||
|
||||
#define READLINE_HIST_SIZE (MP_ARRAY_SIZE(MP_STATE_PORT(readline_hist)))
|
||||
|
||||
|
@ -26,7 +26,7 @@
|
||||
#ifndef MICROPY_INCLUDED_LIB_MP_READLINE_READLINE_H
|
||||
#define MICROPY_INCLUDED_LIB_MP_READLINE_READLINE_H
|
||||
|
||||
// CIRCUITPY: a number of changes
|
||||
// CIRCUITPY-CHANGE: a number of changes
|
||||
|
||||
#include "py/misc.h"
|
||||
|
||||
|
@ -36,7 +36,7 @@ void mp_hal_set_interrupt_char(int c) {
|
||||
mp_interrupt_char = c;
|
||||
}
|
||||
|
||||
// CIRCUITPY
|
||||
// CIRCUITPY-CHANGE
|
||||
// Check to see if we've been CTRL-C'ed by autoreload or the user.
|
||||
bool mp_hal_is_interrupted(void) {
|
||||
return MP_STATE_THREAD(mp_pending_exception) != MP_OBJ_FROM_PTR(NULL);
|
||||
|
@ -26,7 +26,7 @@
|
||||
#ifndef MICROPY_INCLUDED_LIB_UTILS_INTERRUPT_CHAR_H
|
||||
#define MICROPY_INCLUDED_LIB_UTILS_INTERRUPT_CHAR_H
|
||||
|
||||
// CIRCUITPY changes
|
||||
// CIRCUITPY-CHANGE: various changes
|
||||
#include <stdbool.h>
|
||||
|
||||
extern int mp_interrupt_char;
|
||||
|
@ -44,7 +44,7 @@
|
||||
#include "shared/runtime/pyexec.h"
|
||||
#include "genhdr/mpversion.h"
|
||||
|
||||
// CIRCUITPY multiple changes for atexit(), interrupts
|
||||
// CIRCUITPY-CHANGE: multiple changes for atexit(), interrupts
|
||||
|
||||
#if CIRCUITPY_ATEXIT
|
||||
#include "shared-module/atexit/__init__.h"
|
||||
|
@ -28,7 +28,7 @@
|
||||
|
||||
#include "py/obj.h"
|
||||
|
||||
// CIRCUITPY multiple changes
|
||||
// CIRCUITPY-CHANGE: multiple changes
|
||||
|
||||
typedef enum {
|
||||
PYEXEC_MODE_FRIENDLY_REPL,
|
||||
|
@ -35,7 +35,7 @@
|
||||
* implementation below can be used.
|
||||
*/
|
||||
|
||||
// CIRCUITPY changes
|
||||
// CIRCUITPY-CHANGE: changes
|
||||
// Send "cooked" string of given length, where every occurrence of
|
||||
// LF character is replaced with CR LF.
|
||||
void mp_hal_stdout_tx_strn_cooked(const char *str, size_t len) {
|
||||
|
@ -37,11 +37,11 @@ class Cud():
|
||||
def __floordiv__(self, other):
|
||||
print("__floordiv__ called")
|
||||
|
||||
# CIRCUITPY
|
||||
# CIRCUITPY-CHANGE
|
||||
def __index__(self, other):
|
||||
print("__index__ called")
|
||||
|
||||
# CIRCUITPY
|
||||
# CIRCUITPY-CHANGE
|
||||
def __inv__(self):
|
||||
print("__inv__ called")
|
||||
|
||||
|
@ -125,7 +125,7 @@ try:
|
||||
except:
|
||||
print('struct.error')
|
||||
|
||||
# CIRCUITPY
|
||||
# CIRCUITPY-CHANGE
|
||||
# check padding bytes
|
||||
print(struct.pack("xb", 3))
|
||||
# Make sure pack doesn't reuse a larger value and error
|
||||
|
@ -13,7 +13,7 @@ except AttributeError:
|
||||
print(True)
|
||||
|
||||
try:
|
||||
# CIRCUITPY
|
||||
# CIRCUITPY-CHANGE
|
||||
print(sys.implementation.name in ('cpython', 'micropython', 'circuitpython'))
|
||||
except AttributeError:
|
||||
# Effectively skip subtests
|
||||
|
@ -4,7 +4,7 @@ except ImportError:
|
||||
print("SKIP")
|
||||
raise SystemExit
|
||||
|
||||
# CIRCUITPY provides __await()__
|
||||
# CIRCUITPY-CHANGE: CircuitPython provides __await__()
|
||||
async def foo():
|
||||
return 42
|
||||
|
||||
|
@ -8,7 +8,7 @@ except ImportError:
|
||||
raise SystemExit
|
||||
|
||||
|
||||
# CIRCUITPY provides __await__()
|
||||
# CIRCUITPY-CHANGE: CircuitPython provides __await__()
|
||||
async def foo():
|
||||
return 42
|
||||
|
||||
|
@ -7,7 +7,7 @@ except ImportError:
|
||||
raise SystemExit
|
||||
|
||||
|
||||
# CIRCUITPY provides __await__()
|
||||
# CIRCUITPY-CHANGE: CircuitPython provides __await__()
|
||||
async def foo():
|
||||
return 42
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user