diff --git a/include/MicroPython/libmp.h b/include/MicroPython/libmp.h index d8bc1148c..54aa6d5b4 100644 --- a/include/MicroPython/libmp.h +++ b/include/MicroPython/libmp.h @@ -4,6 +4,7 @@ #include "mpconfig.h" #include "qstr.h" #include "obj.h" +#include "objmodule.h" #include "std.h" #include "nlr.h" #include "misc.h" @@ -22,6 +23,7 @@ #include "pyexec.h" #include "pendsv.h" #include "ff.h" +#include "map.h" int libmp_init(); void libmp_do_repl(void); diff --git a/include/MicroPython/map.h b/include/MicroPython/map.h new file mode 100644 index 000000000..afebfda6e --- /dev/null +++ b/include/MicroPython/map.h @@ -0,0 +1,38 @@ +typedef struct _mp_map_elem_t { + mp_obj_t key; + mp_obj_t value; +} mp_map_elem_t; + +typedef struct _mp_map_t { + machine_uint_t all_keys_are_qstrs : 1; + machine_uint_t table_is_fixed_array : 1; + machine_uint_t used : (8 * sizeof(machine_uint_t) - 2); + machine_uint_t alloc; + mp_map_elem_t *table; +} mp_map_t; + +typedef struct _mp_set_t { + machine_uint_t alloc; + machine_uint_t used; + mp_obj_t *table; +} mp_set_t; + +typedef enum _mp_map_lookup_kind_t { + MP_MAP_LOOKUP, // 0 + MP_MAP_LOOKUP_ADD_IF_NOT_FOUND, // 1 + MP_MAP_LOOKUP_REMOVE_IF_FOUND, // 2 + MP_MAP_LOOKUP_FIRST = 4, +} mp_map_lookup_kind_t; + +int get_doubling_prime_greater_or_equal_to(int x); +void mp_map_init(mp_map_t *map, int n); +void mp_map_init_fixed_table(mp_map_t *map, int n, const mp_obj_t *table); +mp_map_t *mp_map_new(int n); +void mp_map_deinit(mp_map_t *map); +void mp_map_free(mp_map_t *map); +mp_map_elem_t* mp_map_lookup(mp_map_t *map, mp_obj_t index, mp_map_lookup_kind_t lookup_kind); +void mp_map_clear(mp_map_t *map); + +void mp_set_init(mp_set_t *set, int n); +mp_obj_t mp_set_lookup(mp_set_t *set, mp_obj_t index, mp_map_lookup_kind_t lookup_kind); +void mp_set_clear(mp_set_t *set); diff --git a/include/MicroPython/mpconfig.h b/include/MicroPython/mpconfig.h index 5b13c4648..09cc37913 100644 --- a/include/MicroPython/mpconfig.h +++ b/include/MicroPython/mpconfig.h @@ -125,10 +125,16 @@ typedef double mp_float_t; #define MICROPY_PATH_MAX (512) #endif -// Additional builtin function definitions - see runtime.c:builtin_table for format. +// Additional builtin function definitions - see builtintables.c:builtin_object_table for format. #ifndef MICROPY_EXTRA_BUILTINS #define MICROPY_EXTRA_BUILTINS #endif + +// Additional builtin module definitions - see builtintables.c:builtin_module_table for format. +#ifndef MICROPY_EXTRA_BUILTIN_MODULES +#define MICROPY_EXTRA_BUILTIN_MODULES +#endif + /*****************************************************************************/ /* Miscellaneous settings */ diff --git a/include/MicroPython/obj.h b/include/MicroPython/obj.h index 1daa94344..b52b5a0c7 100644 --- a/include/MicroPython/obj.h +++ b/include/MicroPython/obj.h @@ -175,7 +175,6 @@ struct _mp_obj_type_t { abs float complex hash bool int none str equal int str - get_array_n tuple list unpack seq list tuple */ @@ -184,26 +183,39 @@ struct _mp_obj_type_t { typedef struct _mp_obj_type_t mp_obj_type_t; // Constant types, globally accessible - extern const mp_obj_type_t mp_type_type; + +// Exceptions extern const mp_obj_type_t mp_type_BaseException; +extern const mp_obj_type_t mp_type_ArithmeticError; extern const mp_obj_type_t mp_type_AssertionError; extern const mp_obj_type_t mp_type_AttributeError; +extern const mp_obj_type_t mp_type_BufferError; +extern const mp_obj_type_t mp_type_EOFError; +extern const mp_obj_type_t mp_type_Exception; +extern const mp_obj_type_t mp_type_FloatingPointError; +extern const mp_obj_type_t mp_type_GeneratorExit; +extern const mp_obj_type_t mp_type_IOError; 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_KeyError; +extern const mp_obj_type_t mp_type_LookupError; +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_SyntaxError; -extern const mp_obj_type_t mp_type_TypeError; -extern const mp_obj_type_t mp_type_ValueError; -extern const mp_obj_type_t mp_type_OverflowError; -extern const mp_obj_type_t mp_type_OSError; extern const mp_obj_type_t mp_type_NotImplementedError; +extern const mp_obj_type_t mp_type_OSError; +extern const mp_obj_type_t mp_type_OverflowError; +extern const mp_obj_type_t mp_type_RuntimeError; extern const mp_obj_type_t mp_type_StopIteration; +extern const mp_obj_type_t mp_type_SyntaxError; +extern const mp_obj_type_t mp_type_SystemError; +extern const mp_obj_type_t mp_type_TypeError; +extern const mp_obj_type_t mp_type_UnboundLocalError; +extern const mp_obj_type_t mp_type_ValueError; +extern const mp_obj_type_t mp_type_ZeroDivisionError; // Constant objects, globally accessible - extern const mp_obj_t mp_const_none; extern const mp_obj_t mp_const_false; extern const mp_obj_t mp_const_true; @@ -266,10 +278,14 @@ mp_float_t mp_obj_get_float(mp_obj_t self_in); void mp_obj_get_complex(mp_obj_t self_in, mp_float_t *real, mp_float_t *imag); #endif //qstr mp_obj_get_qstr(mp_obj_t arg); -mp_obj_t *mp_obj_get_array_fixed_n(mp_obj_t o, machine_int_t n); +void mp_obj_get_array(mp_obj_t o, uint *len, mp_obj_t **items); +void mp_obj_get_array_fixed_n(mp_obj_t o, uint len, mp_obj_t **items); uint mp_get_index(const mp_obj_type_t *type, machine_uint_t len, mp_obj_t index, bool is_slice); mp_obj_t mp_obj_len_maybe(mp_obj_t o_in); /* may return NULL */ +// object +extern const mp_obj_type_t mp_type_object; + // none extern const mp_obj_type_t none_type; @@ -285,6 +301,9 @@ void mp_obj_cell_set(mp_obj_t self_in, mp_obj_t obj); extern const mp_obj_type_t int_type; // For long int, returns value truncated to machine_int_t machine_int_t mp_obj_int_get(mp_obj_t self_in); +#if MICROPY_ENABLE_FLOAT +mp_float_t mp_obj_int_as_float(mp_obj_t self_in); +#endif // Will rains exception if value doesn't fit into machine_int_t machine_int_t mp_obj_int_get_checked(mp_obj_t self_in); @@ -366,7 +385,7 @@ void mp_obj_slice_get(mp_obj_t self_in, machine_int_t *start, machine_int_t *sto extern const mp_obj_type_t zip_type; // array -extern const mp_obj_type_t array_type; +extern const mp_obj_type_t mp_type_array; uint mp_obj_array_len(mp_obj_t self_in); mp_obj_t mp_obj_new_bytearray_by_ref(uint n, void *items); @@ -403,8 +422,6 @@ typedef struct _mp_obj_module_t { struct _mp_map_t *globals; } mp_obj_module_t; extern const mp_obj_type_t mp_type_module; -mp_obj_t mp_obj_new_module(qstr module_name); -mp_obj_t mp_obj_module_get(qstr module_name); struct _mp_map_t *mp_obj_module_get_globals(mp_obj_t self_in); // staticmethod and classmethod types; defined here so we can make const versions diff --git a/include/MicroPython/objmodule.h b/include/MicroPython/objmodule.h new file mode 100644 index 000000000..270551da4 --- /dev/null +++ b/include/MicroPython/objmodule.h @@ -0,0 +1,4 @@ +void mp_module_init(void); +void mp_module_deinit(void); +mp_obj_t mp_module_get(qstr module_name); +void mp_module_register(qstr qstr, mp_obj_t module); diff --git a/include/MicroPython/qstrdefs.generated.h b/include/MicroPython/qstrdefs.generated.h index 3220fed8b..36017bb4d 100644 --- a/include/MicroPython/qstrdefs.generated.h +++ b/include/MicroPython/qstrdefs.generated.h @@ -1,200 +1,247 @@ // This file was automatically generated by makeqstrdata.py -Q(__build_class__, (const byte*)"\x01\x06\x0f\x00" "__build_class__") -Q(__class__, (const byte*)"\x92\x03\x09\x00" "__class__") -Q(__doc__, (const byte*)"\xb2\x02\x07\x00" "__doc__") -Q(__import__, (const byte*)"\x17\x04\x0a\x00" "__import__") -Q(__init__, (const byte*)"\x30\x03\x08\x00" "__init__") -Q(__locals__, (const byte*)"\xfa\x03\x0a\x00" "__locals__") -Q(__main__, (const byte*)"\x21\x03\x08\x00" "__main__") -Q(__module__, (const byte*)"\x02\x04\x0a\x00" "__module__") -Q(__name__, (const byte*)"\x1d\x03\x08\x00" "__name__") -Q(__next__, (const byte*)"\x3b\x03\x08\x00" "__next__") -Q(__qualname__, (const byte*)"\xd0\x04\x0c\x00" "__qualname__") -Q(__repl_print__, (const byte*)"\xbb\x05\x0e\x00" "__repl_print__") -Q(__bool__, (const byte*)"\x28\x03\x08\x00" "__bool__") -Q(__len__, (const byte*)"\xbb\x02\x07\x00" "__len__") -Q(__getitem__, (const byte*)"\x6b\x04\x0b\x00" "__getitem__") -Q(__setitem__, (const byte*)"\x77\x04\x0b\x00" "__setitem__") -Q(__add__, (const byte*)"\xa5\x02\x07\x00" "__add__") -Q(__sub__, (const byte*)"\xc6\x02\x07\x00" "__sub__") -Q(__repr__, (const byte*)"\x35\x03\x08\x00" "__repr__") -Q(__str__, (const byte*)"\xd5\x02\x07\x00" "__str__") -Q(micropython, (const byte*)"\xbc\x04\x0b\x00" "micropython") -Q(byte_code, (const byte*)"\xae\x03\x09\x00" "byte_code") -Q(native, (const byte*)"\x87\x02\x06\x00" "native") -Q(viper, (const byte*)"\x26\x02\x05\x00" "viper") -Q(asm_thumb, (const byte*)"\xc0\x03\x09\x00" "asm_thumb") -Q(Ellipsis, (const byte*)"\x45\x03\x08\x00" "Ellipsis") -Q(StopIteration, (const byte*)"\x55\x05\x0d\x00" "StopIteration") -Q(BaseException, (const byte*)"\x2a\x05\x0d\x00" "BaseException") -Q(AssertionError, (const byte*)"\xc2\x05\x0e\x00" "AssertionError") -Q(AttributeError, (const byte*)"\xbe\x05\x0e\x00" "AttributeError") -Q(ImportError, (const byte*)"\x85\x04\x0b\x00" "ImportError") -Q(IndentationError, (const byte*)"\x87\x06\x10\x00" "IndentationError") -Q(IndexError, (const byte*)"\x02\x04\x0a\x00" "IndexError") -Q(KeyError, (const byte*)"\x33\x03\x08\x00" "KeyError") -Q(NameError, (const byte*)"\x8b\x03\x09\x00" "NameError") -Q(NotImplementedError, (const byte*)"\xaf\x07\x13\x00" "NotImplementedError") -Q(OSError, (const byte*)"\xac\x02\x07\x00" "OSError") -Q(SyntaxError, (const byte*)"\x91\x04\x0b\x00" "SyntaxError") -Q(TypeError, (const byte*)"\xac\x03\x09\x00" "TypeError") -Q(ValueError, (const byte*)"\x07\x04\x0a\x00" "ValueError") -Q(OverflowError, (const byte*)"\x5e\x05\x0d\x00" "OverflowError") -Q(NoneType, (const byte*)"\x32\x03\x08\x00" "NoneType") -Q(abs, (const byte*)"\x36\x01\x03\x00" "abs") -Q(all, (const byte*)"\x39\x01\x03\x00" "all") -Q(any, (const byte*)"\x48\x01\x03\x00" "any") -Q(array, (const byte*)"\x1f\x02\x05\x00" "array") -Q(bool, (const byte*)"\xac\x01\x04\x00" "bool") -Q(bytearray, (const byte*)"\xd3\x03\x09\x00" "bytearray") -Q(bytes, (const byte*)"\x27\x02\x05\x00" "bytes") -Q(callable, (const byte*)"\x30\x03\x08\x00" "callable") -Q(chr, (const byte*)"\x3d\x01\x03\x00" "chr") -Q(classmethod, (const byte*)"\x97\x04\x0b\x00" "classmethod") -Q(collections, (const byte*)"\x9f\x04\x0b\x00" "collections") -Q(complex, (const byte*)"\xf8\x02\x07\x00" "complex") -Q(dict, (const byte*)"\xa4\x01\x04\x00" "dict") -Q(dir, (const byte*)"\x3f\x01\x03\x00" "dir") -Q(divmod, (const byte*)"\x83\x02\x06\x00" "divmod") -Q(enumerate, (const byte*)"\xc6\x03\x09\x00" "enumerate") -Q(eval, (const byte*)"\xa8\x01\x04\x00" "eval") -Q(exec, (const byte*)"\xa5\x01\x04\x00" "exec") -Q(filter, (const byte*)"\x86\x02\x06\x00" "filter") -Q(float, (const byte*)"\x16\x02\x05\x00" "float") -Q(hash, (const byte*)"\xa4\x01\x04\x00" "hash") -Q(id, (const byte*)"\xcd\x00\x02\x00" "id") -Q(int, (const byte*)"\x4b\x01\x03\x00" "int") -Q(isinstance, (const byte*)"\x31\x04\x0a\x00" "isinstance") -Q(issubclass, (const byte*)"\x3c\x04\x0a\x00" "issubclass") -Q(iter, (const byte*)"\xb4\x01\x04\x00" "iter") -Q(len, (const byte*)"\x3f\x01\x03\x00" "len") -Q(list, (const byte*)"\xbc\x01\x04\x00" "list") -Q(map, (const byte*)"\x3e\x01\x03\x00" "map") -Q(max, (const byte*)"\x46\x01\x03\x00" "max") -Q(min, (const byte*)"\x44\x01\x03\x00" "min") -Q(namedtuple, (const byte*)"\x2f\x04\x0a\x00" "namedtuple") -Q(next, (const byte*)"\xbf\x01\x04\x00" "next") -Q(ord, (const byte*)"\x45\x01\x03\x00" "ord") -Q(path, (const byte*)"\xad\x01\x04\x00" "path") -Q(pow, (const byte*)"\x56\x01\x03\x00" "pow") -Q(print, (const byte*)"\x2d\x02\x05\x00" "print") -Q(range, (const byte*)"\x0d\x02\x05\x00" "range") -Q(repr, (const byte*)"\xb9\x01\x04\x00" "repr") -Q(set, (const byte*)"\x4c\x01\x03\x00" "set") -Q(sorted, (const byte*)"\x91\x02\x06\x00" "sorted") -Q(staticmethod, (const byte*)"\x09\x05\x0c\x00" "staticmethod") -Q(sum, (const byte*)"\x55\x01\x03\x00" "sum") -Q(super, (const byte*)"\x2f\x02\x05\x00" "super") -Q(str, (const byte*)"\x59\x01\x03\x00" "str") -Q(sys, (const byte*)"\x5f\x01\x03\x00" "sys") -Q(tuple, (const byte*)"\x2a\x02\x05\x00" "tuple") -Q(type, (const byte*)"\xc2\x01\x04\x00" "type") -Q(zip, (const byte*)"\x53\x01\x03\x00" "zip") -Q(append, (const byte*)"\x78\x02\x06\x00" "append") -Q(pop, (const byte*)"\x4f\x01\x03\x00" "pop") -Q(sort, (const byte*)"\xc8\x01\x04\x00" "sort") -Q(join, (const byte*)"\xb0\x01\x04\x00" "join") -Q(strip, (const byte*)"\x32\x02\x05\x00" "strip") -Q(format, (const byte*)"\x89\x02\x06\x00" "format") -Q(key, (const byte*)"\x49\x01\x03\x00" "key") -Q(reverse, (const byte*)"\xfc\x02\x07\x00" "reverse") -Q(bound_method, (const byte*)"\xf8\x04\x0c\x00" "bound_method") -Q(closure, (const byte*)"\xfd\x02\x07\x00" "closure") -Q(dict_view, (const byte*)"\xbe\x03\x09\x00" "dict_view") -Q(function, (const byte*)"\x66\x03\x08\x00" "function") -Q(generator, (const byte*)"\xc7\x03\x09\x00" "generator") -Q(iterator, (const byte*)"\x6a\x03\x08\x00" "iterator") -Q(module, (const byte*)"\x86\x02\x06\x00" "module") -Q(slice, (const byte*)"\x10\x02\x05\x00" "slice") -Q(math, (const byte*)"\xaa\x01\x04\x00" "math") -Q(pi, (const byte*)"\xd9\x00\x02\x00" "pi") -Q(sqrt, (const byte*)"\xca\x01\x04\x00" "sqrt") -Q(exp, (const byte*)"\x4d\x01\x03\x00" "exp") -Q(expm1, (const byte*)"\xeb\x01\x05\x00" "expm1") -Q(log, (const byte*)"\x42\x01\x03\x00" "log") -Q(log2, (const byte*)"\x74\x01\x04\x00" "log2") -Q(log10, (const byte*)"\xa3\x01\x05\x00" "log10") -Q(cosh, (const byte*)"\xad\x01\x04\x00" "cosh") -Q(sinh, (const byte*)"\xb2\x01\x04\x00" "sinh") -Q(tanh, (const byte*)"\xab\x01\x04\x00" "tanh") -Q(acosh, (const byte*)"\x0e\x02\x05\x00" "acosh") -Q(asinh, (const byte*)"\x13\x02\x05\x00" "asinh") -Q(atanh, (const byte*)"\x0c\x02\x05\x00" "atanh") -Q(cos, (const byte*)"\x45\x01\x03\x00" "cos") -Q(sin, (const byte*)"\x4a\x01\x03\x00" "sin") -Q(tan, (const byte*)"\x43\x01\x03\x00" "tan") -Q(acos, (const byte*)"\xa6\x01\x04\x00" "acos") -Q(asin, (const byte*)"\xab\x01\x04\x00" "asin") -Q(atan, (const byte*)"\xa4\x01\x04\x00" "atan") -Q(atan2, (const byte*)"\xd6\x01\x05\x00" "atan2") -Q(mem_total, (const byte*)"\xc2\x03\x09\x00" "mem_total") -Q(mem_current, (const byte*)"\xa1\x04\x0b\x00" "mem_current") -Q(mem_peak, (const byte*)"\x3f\x03\x08\x00" "mem_peak") -Q(_lt_module_gt_, (const byte*)"\x00\x03\x08\x00" "") -Q(_lt_lambda_gt_, (const byte*)"\xdb\x02\x08\x00" "") -Q(_lt_listcomp_gt_, (const byte*)"\xe5\x03\x0a\x00" "") -Q(_lt_dictcomp_gt_, (const byte*)"\xcd\x03\x0a\x00" "") -Q(_lt_setcomp_gt_, (const byte*)"\x75\x03\x09\x00" "") -Q(_lt_genexpr_gt_, (const byte*)"\x73\x03\x09\x00" "") -Q(_lt_string_gt_, (const byte*)"\x11\x03\x08\x00" "") -Q(_lt_stdin_gt_, (const byte*)"\x9c\x02\x07\x00" "") -Q(help, (const byte*)"\xa9\x01\x04\x00" "help") -Q(pyb, (const byte*)"\x4b\x01\x03\x00" "pyb") -Q(info, (const byte*)"\xac\x01\x04\x00" "info") -Q(sd_test, (const byte*)"\xf6\x02\x07\x00" "sd_test") -Q(stop, (const byte*)"\xc6\x01\x04\x00" "stop") -Q(standby, (const byte*)"\xf5\x02\x07\x00" "standby") -Q(source_dir, (const byte*)"\x2f\x04\x0a\x00" "source_dir") -Q(main, (const byte*)"\xa5\x01\x04\x00" "main") -Q(sync, (const byte*)"\xbd\x01\x04\x00" "sync") -Q(gc, (const byte*)"\xca\x00\x02\x00" "gc") -Q(repl_info, (const byte*)"\xbe\x03\x09\x00" "repl_info") -Q(delay, (const byte*)"\x0f\x02\x05\x00" "delay") -Q(udelay, (const byte*)"\x84\x02\x06\x00" "udelay") -Q(switch, (const byte*)"\x92\x02\x06\x00" "switch") -Q(SW, (const byte*)"\xaa\x00\x02\x00" "SW") -Q(servo, (const byte*)"\x2f\x02\x05\x00" "servo") -Q(pwm, (const byte*)"\x54\x01\x03\x00" "pwm") -Q(accel, (const byte*)"\xf8\x01\x05\x00" "accel") -Q(accel_read, (const byte*)"\xf3\x03\x0a\x00" "accel_read") -Q(accel_mode, (const byte*)"\xfc\x03\x0a\x00" "accel_mode") -Q(hid, (const byte*)"\x35\x01\x03\x00" "hid") -Q(time, (const byte*)"\xaf\x01\x04\x00" "time") -Q(rand, (const byte*)"\xa5\x01\x04\x00" "rand") -Q(Led, (const byte*)"\x15\x01\x03\x00" "Led") -Q(LCD, (const byte*)"\xd3\x00\x03\x00" "LCD") -Q(Servo, (const byte*)"\x0f\x02\x05\x00" "Servo") -Q(SD, (const byte*)"\x97\x00\x02\x00" "SD") -Q(SDcard, (const byte*)"\x31\x02\x06\x00" "SDcard") -Q(I2C, (const byte*)"\xbe\x00\x03\x00" "I2C") -Q(gpio, (const byte*)"\xaf\x01\x04\x00" "gpio") -Q(gpio_in, (const byte*)"\xe5\x02\x07\x00" "gpio_in") -Q(gpio_out, (const byte*)"\x66\x03\x08\x00" "gpio_out") -Q(Usart, (const byte*)"\x0f\x02\x05\x00" "Usart") -Q(ADC, (const byte*)"\xc8\x00\x03\x00" "ADC") -Q(ADC_all, (const byte*)"\x60\x02\x07\x00" "ADC_all") -Q(Audio, (const byte*)"\xf2\x01\x05\x00" "Audio") -Q(open, (const byte*)"\xb2\x01\x04\x00" "open") -Q(File, (const byte*)"\x80\x01\x04\x00" "File") -Q(0_colon__slash_, (const byte*)"\x99\x00\x03\x00" "0:/") -Q(0_colon__slash_src, (const byte*)"\xe1\x01\x06\x00" "0:/src") -Q(0_colon__slash_lib, (const byte*)"\xd0\x01\x06\x00" "0:/lib") -Q(Pin, (const byte*)"\x27\x01\x03\x00" "Pin") -Q(PinMap, (const byte*)"\x45\x02\x06\x00" "PinMap") -Q(PinAF, (const byte*)"\xae\x01\x05\x00" "PinAF") -Q(PinNamed, (const byte*)"\x0c\x03\x08\x00" "PinNamed") -Q(Exti, (const byte*)"\x9a\x01\x04\x00" "Exti") -Q(ExtiMeta, (const byte*)"\x21\x03\x08\x00" "ExtiMeta") -Q(rtc_info, (const byte*)"\x54\x03\x08\x00" "rtc_info") -Q(millis, (const byte*)"\x8a\x02\x06\x00" "millis") -Q(PULL_NONE, (const byte*)"\xcc\x02\x09\x00" "PULL_NONE") -Q(PULL_UP, (const byte*)"\x41\x02\x07\x00" "PULL_UP") -Q(PULL_DOWN, (const byte*)"\xd4\x02\x09\x00" "PULL_DOWN") -Q(PUSH_PULL, (const byte*)"\xdc\x02\x09\x00" "PUSH_PULL") -Q(OPEN_DRAIN, (const byte*)"\xff\x02\x0a\x00" "OPEN_DRAIN") -Q(Image, (const byte*)"\xe3\x01\x05\x00" "Image") -Q(Imlib, (const byte*)"\xed\x01\x05\x00" "Imlib") -Q(Sensor, (const byte*)"\x7a\x02\x06\x00" "Sensor") -Q(Cascade, (const byte*)"\xa4\x02\x07\x00" "Cascade") -Q(Clock, (const byte*)"\xec\x01\x05\x00" "Clock") +Q(__build_class__, (const byte*)"\x42\x88\x0f\x00" "__build_class__") +Q(__class__, (const byte*)"\x2b\xc5\x09\x00" "__class__") +Q(__doc__, (const byte*)"\x2d\xac\x07\x00" "__doc__") +Q(__import__, (const byte*)"\x38\x3e\x0a\x00" "__import__") +Q(__init__, (const byte*)"\x5f\xa5\x08\x00" "__init__") +Q(__locals__, (const byte*)"\x7b\x6a\x0a\x00" "__locals__") +Q(__main__, (const byte*)"\x8e\x13\x08\x00" "__main__") +Q(__module__, (const byte*)"\xff\x30\x0a\x00" "__module__") +Q(__name__, (const byte*)"\xe2\x38\x08\x00" "__name__") +Q(__next__, (const byte*)"\x02\x73\x08\x00" "__next__") +Q(__qualname__, (const byte*)"\x6b\x00\x0c\x00" "__qualname__") +Q(__repl_print__, (const byte*)"\x00\xbb\x0e\x00" "__repl_print__") +Q(__bool__, (const byte*)"\x2b\x65\x08\x00" "__bool__") +Q(__len__, (const byte*)"\xe2\xb0\x07\x00" "__len__") +Q(__getitem__, (const byte*)"\x26\x39\x0b\x00" "__getitem__") +Q(__setitem__, (const byte*)"\x32\x3e\x0b\x00" "__setitem__") +Q(__add__, (const byte*)"\xc4\x82\x07\x00" "__add__") +Q(__sub__, (const byte*)"\x21\x09\x07\x00" "__sub__") +Q(__repr__, (const byte*)"\x10\x0b\x08\x00" "__repr__") +Q(__str__, (const byte*)"\xd0\xcd\x07\x00" "__str__") +Q(micropython, (const byte*)"\x0b\x7c\x0b\x00" "micropython") +Q(byte_code, (const byte*)"\x9d\x04\x09\x00" "byte_code") +Q(native, (const byte*)"\x84\x0b\x06\x00" "native") +Q(viper, (const byte*)"\x5d\x23\x05\x00" "viper") +Q(asm_thumb, (const byte*)"\x43\x6d\x09\x00" "asm_thumb") +Q(Ellipsis, (const byte*)"\xf0\xe0\x08\x00" "Ellipsis") +Q(StopIteration, (const byte*)"\xea\x1c\x0d\x00" "StopIteration") +Q(BaseException, (const byte*)"\x07\x92\x0d\x00" "BaseException") +Q(ArithmeticError, (const byte*)"\x2d\x8c\x0f\x00" "ArithmeticError") +Q(AssertionError, (const byte*)"\x97\x5a\x0e\x00" "AssertionError") +Q(AttributeError, (const byte*)"\x21\xde\x0e\x00" "AttributeError") +Q(BufferError, (const byte*)"\x1d\x59\x0b\x00" "BufferError") +Q(EOFError, (const byte*)"\x91\xbf\x08\x00" "EOFError") +Q(Exception, (const byte*)"\xf2\x29\x09\x00" "Exception") +Q(FileExistsError, (const byte*)"\x5b\x14\x0f\x00" "FileExistsError") +Q(FileNotFoundError, (const byte*)"\x78\x89\x11\x00" "FileNotFoundError") +Q(FloatingPointError, (const byte*)"\x01\x34\x12\x00" "FloatingPointError") +Q(GeneratorExit, (const byte*)"\x16\x62\x0d\x00" "GeneratorExit") +Q(IOError, (const byte*)"\xbb\xc4\x07\x00" "IOError") +Q(ImportError, (const byte*)"\x20\x9c\x0b\x00" "ImportError") +Q(IndentationError, (const byte*)"\x5c\x20\x10\x00" "IndentationError") +Q(IndexError, (const byte*)"\x83\xad\x0a\x00" "IndexError") +Q(KeyError, (const byte*)"\xea\x00\x08\x00" "KeyError") +Q(LookupError, (const byte*)"\xff\x69\x0b\x00" "LookupError") +Q(MemoryError, (const byte*)"\xdc\x83\x0b\x00" "MemoryError") +Q(NameError, (const byte*)"\xba\x2d\x09\x00" "NameError") +Q(NotImplementedError, (const byte*)"\xc6\x98\x13\x00" "NotImplementedError") +Q(OSError, (const byte*)"\xa1\x65\x07\x00" "OSError") +Q(OverflowError, (const byte*)"\x81\xe1\x0d\x00" "OverflowError") +Q(RuntimeError, (const byte*)"\x61\xf1\x0c\x00" "RuntimeError") +Q(SyntaxError, (const byte*)"\x94\x8f\x0b\x00" "SyntaxError") +Q(SystemError, (const byte*)"\xf8\x5d\x0b\x00" "SystemError") +Q(TypeError, (const byte*)"\x25\x96\x09\x00" "TypeError") +Q(UnboundLocalError, (const byte*)"\x99\x22\x11\x00" "UnboundLocalError") +Q(ValueError, (const byte*)"\x96\x87\x0a\x00" "ValueError") +Q(ZeroDivisionError, (const byte*)"\xb6\x27\x11\x00" "ZeroDivisionError") +Q(None, (const byte*)"\x6f\xd1\x04\x00" "None") +Q(False, (const byte*)"\x38\x6f\x05\x00" "False") +Q(True, (const byte*)"\x13\x17\x04\x00" "True") +Q(object, (const byte*)"\x90\x8d\x06\x00" "object") +Q(NoneType, (const byte*)"\x17\x68\x08\x00" "NoneType") +Q(abs, (const byte*)"\x95\x32\x03\x00" "abs") +Q(all, (const byte*)"\x44\x33\x03\x00" "all") +Q(any, (const byte*)"\x13\x33\x03\x00" "any") +Q(args, (const byte*)"\xc2\xc6\x04\x00" "args") +Q(array, (const byte*)"\x7c\x72\x05\x00" "array") +Q(bool, (const byte*)"\xeb\x3c\x04\x00" "bool") +Q(bytearray, (const byte*)"\x76\xa3\x09\x00" "bytearray") +Q(bytes, (const byte*)"\x5c\xb2\x05\x00" "bytes") +Q(callable, (const byte*)"\x0d\x70\x08\x00" "callable") +Q(chr, (const byte*)"\xdc\x4c\x03\x00" "chr") +Q(classmethod, (const byte*)"\xb4\x8c\x0b\x00" "classmethod") +Q(collections, (const byte*)"\xe0\xc8\x0b\x00" "collections") +Q(complex, (const byte*)"\xc5\x9d\x07\x00" "complex") +Q(dict, (const byte*)"\x3f\xfc\x04\x00" "dict") +Q(dir, (const byte*)"\xfa\x1e\x03\x00" "dir") +Q(divmod, (const byte*)"\xb8\x04\x06\x00" "divmod") +Q(enumerate, (const byte*)"\x71\xba\x09\x00" "enumerate") +Q(eval, (const byte*)"\x9b\xa6\x04\x00" "eval") +Q(exec, (const byte*)"\x1e\xc0\x04\x00" "exec") +Q(filter, (const byte*)"\x25\xbe\x06\x00" "filter") +Q(float, (const byte*)"\x35\x44\x05\x00" "float") +Q(hash, (const byte*)"\xb7\x70\x04\x00" "hash") +Q(id, (const byte*)"\x28\x6f\x02\x00" "id") +Q(int, (const byte*)"\x16\x53\x03\x00" "int") +Q(isinstance, (const byte*)"\xb6\xbe\x0a\x00" "isinstance") +Q(issubclass, (const byte*)"\xb5\x7f\x0a\x00" "issubclass") +Q(iter, (const byte*)"\x8f\x21\x04\x00" "iter") +Q(len, (const byte*)"\x62\x40\x03\x00" "len") +Q(list, (const byte*)"\x27\x1d\x04\x00" "list") +Q(map, (const byte*)"\xb9\x43\x03\x00" "map") +Q(max, (const byte*)"\xb1\x43\x03\x00" "max") +Q(min, (const byte*)"\xaf\x42\x03\x00" "min") +Q(namedtuple, (const byte*)"\x1e\x16\x0a\x00" "namedtuple") +Q(next, (const byte*)"\x42\x88\x04\x00" "next") +Q(ord, (const byte*)"\x1c\x5e\x03\x00" "ord") +Q(path, (const byte*)"\x88\xce\x04\x00" "path") +Q(pow, (const byte*)"\x2d\x73\x03\x00" "pow") +Q(print, (const byte*)"\x54\xc6\x05\x00" "print") +Q(range, (const byte*)"\x1a\x5e\x05\x00" "range") +Q(repr, (const byte*)"\xd0\xf7\x04\x00" "repr") +Q(set, (const byte*)"\x27\x8f\x03\x00" "set") +Q(sorted, (const byte*)"\x5e\x15\x06\x00" "sorted") +Q(staticmethod, (const byte*)"\x62\xaf\x0c\x00" "staticmethod") +Q(sum, (const byte*)"\x2e\x8d\x03\x00" "sum") +Q(super, (const byte*)"\xc4\xb2\x05\x00" "super") +Q(str, (const byte*)"\x50\x8d\x03\x00" "str") +Q(sys, (const byte*)"\xbc\x8e\x03\x00" "sys") +Q(tuple, (const byte*)"\xfd\x41\x05\x00" "tuple") +Q(type, (const byte*)"\x9d\x7f\x04\x00" "type") +Q(value, (const byte*)"\x4e\x34\x05\x00" "value") +Q(zip, (const byte*)"\xe6\xac\x03\x00" "zip") +Q(append, (const byte*)"\x6b\x97\x06\x00" "append") +Q(pop, (const byte*)"\x2a\x73\x03\x00" "pop") +Q(sort, (const byte*)"\xbf\x9d\x04\x00" "sort") +Q(join, (const byte*)"\xa7\x5c\x04\x00" "join") +Q(strip, (const byte*)"\x29\x1e\x05\x00" "strip") +Q(format, (const byte*)"\x26\x33\x06\x00" "format") +Q(key, (const byte*)"\x32\x6d\x03\x00" "key") +Q(reverse, (const byte*)"\x25\x2a\x07\x00" "reverse") +Q(bound_method, (const byte*)"\x97\xa2\x0c\x00" "bound_method") +Q(closure, (const byte*)"\x74\xca\x07\x00" "closure") +Q(dict_view, (const byte*)"\x2d\xa9\x09\x00" "dict_view") +Q(function, (const byte*)"\x27\x02\x08\x00" "function") +Q(generator, (const byte*)"\x96\xc3\x09\x00" "generator") +Q(iterator, (const byte*)"\x47\xbe\x08\x00" "iterator") +Q(module, (const byte*)"\xbf\x99\x06\x00" "module") +Q(slice, (const byte*)"\xb5\xf4\x05\x00" "slice") +Q(math, (const byte*)"\x35\xbb\x04\x00" "math") +Q(e, (const byte*)"\xc0\xb5\x01\x00" "e") +Q(pi, (const byte*)"\x1c\x70\x02\x00" "pi") +Q(sqrt, (const byte*)"\x21\x44\x04\x00" "sqrt") +Q(exp, (const byte*)"\xc8\x24\x03\x00" "exp") +Q(expm1, (const byte*)"\x74\x72\x05\x00" "expm1") +Q(log, (const byte*)"\x21\x3f\x03\x00" "log") +Q(log2, (const byte*)"\x73\x23\x04\x00" "log2") +Q(log10, (const byte*)"\x40\x91\x05\x00" "log10") +Q(cosh, (const byte*)"\xd2\xdb\x04\x00" "cosh") +Q(sinh, (const byte*)"\xb9\xa6\x04\x00" "sinh") +Q(tanh, (const byte*)"\xd6\xa1\x04\x00" "tanh") +Q(acosh, (const byte*)"\x13\xa3\x05\x00" "acosh") +Q(asinh, (const byte*)"\x38\x8f\x05\x00" "asinh") +Q(atanh, (const byte*)"\x97\x81\x05\x00" "atanh") +Q(cos, (const byte*)"\x7a\x4c\x03\x00" "cos") +Q(sin, (const byte*)"\xb1\x90\x03\x00" "sin") +Q(tan, (const byte*)"\xfe\x61\x03\x00" "tan") +Q(acos, (const byte*)"\x1b\xa0\x04\x00" "acos") +Q(asin, (const byte*)"\x50\xe5\x04\x00" "asin") +Q(atan, (const byte*)"\x1f\xbe\x04\x00" "atan") +Q(atan2, (const byte*)"\xcd\x81\x05\x00" "atan2") +Q(ceil, (const byte*)"\x06\xb0\x04\x00" "ceil") +Q(copysign, (const byte*)"\x33\x14\x08\x00" "copysign") +Q(fabs, (const byte*)"\x93\x12\x04\x00" "fabs") +Q(fmod, (const byte*)"\xe5\x44\x04\x00" "fmod") +Q(floor, (const byte*)"\x7d\x46\x05\x00" "floor") +Q(isfinite, (const byte*)"\xa6\xab\x08\x00" "isfinite") +Q(isinf, (const byte*)"\x3e\x11\x05\x00" "isinf") +Q(isnan, (const byte*)"\x9e\x03\x05\x00" "isnan") +Q(trunc, (const byte*)"\x5b\x99\x05\x00" "trunc") +Q(modf, (const byte*)"\x25\xc0\x04\x00" "modf") +Q(frexp, (const byte*)"\x1c\x98\x05\x00" "frexp") +Q(ldexp, (const byte*)"\x40\x6f\x05\x00" "ldexp") +Q(degrees, (const byte*)"\x02\x41\x07\x00" "degrees") +Q(radians, (const byte*)"\x87\x3f\x07\x00" "radians") +Q(erf, (const byte*)"\x94\x23\x03\x00" "erf") +Q(erfc, (const byte*)"\x77\x96\x04\x00" "erfc") +Q(gamma, (const byte*)"\x02\x90\x05\x00" "gamma") +Q(lgamma, (const byte*)"\xce\x6c\x06\x00" "lgamma") +Q(mem_total, (const byte*)"\xfd\x6a\x09\x00" "mem_total") +Q(mem_current, (const byte*)"\x16\xba\x0b\x00" "mem_current") +Q(mem_peak, (const byte*)"\x40\x25\x08\x00" "mem_peak") +Q(_lt_module_gt_, (const byte*)"\xbd\x94\x08\x00" "") +Q(_lt_lambda_gt_, (const byte*)"\x80\x8c\x08\x00" "") +Q(_lt_listcomp_gt_, (const byte*)"\xd4\x15\x0a\x00" "") +Q(_lt_dictcomp_gt_, (const byte*)"\xcc\x8d\x0a\x00" "") +Q(_lt_setcomp_gt_, (const byte*)"\x54\x51\x09\x00" "") +Q(_lt_genexpr_gt_, (const byte*)"\x34\x6a\x09\x00" "") +Q(_lt_string_gt_, (const byte*)"\x52\x53\x08\x00" "") +Q(_lt_stdin_gt_, (const byte*)"\xe3\x63\x07\x00" "") +Q(help, (const byte*)"\x94\x5c\x04\x00" "help") +Q(pyb, (const byte*)"\xee\x71\x03\x00" "pyb") +Q(info, (const byte*)"\xeb\xb3\x04\x00" "info") +Q(sd_test, (const byte*)"\x9b\x4d\x07\x00" "sd_test") +Q(stop, (const byte*)"\x9d\x36\x04\x00" "stop") +Q(standby, (const byte*)"\xd2\xd9\x07\x00" "standby") +Q(source_dir, (const byte*)"\xd8\x4e\x0a\x00" "source_dir") +Q(main, (const byte*)"\xce\xb7\x04\x00" "main") +Q(sync, (const byte*)"\xa2\x62\x04\x00" "sync") +Q(gc, (const byte*)"\x61\x6e\x02\x00" "gc") +Q(repl_info, (const byte*)"\xbf\x37\x09\x00" "repl_info") +Q(delay, (const byte*)"\x50\x4c\x05\x00" "delay") +Q(udelay, (const byte*)"\x25\xaf\x06\x00" "udelay") +Q(switch, (const byte*)"\xb7\x3d\x06\x00" "switch") +Q(SW, (const byte*)"\xe1\x74\x02\x00" "SW") +Q(servo, (const byte*)"\x78\xda\x05\x00" "servo") +Q(pwm, (const byte*)"\x2f\x70\x03\x00" "pwm") +Q(accel, (const byte*)"\xcd\x8f\x05\x00" "accel") +Q(accel_read, (const byte*)"\x80\x08\x0a\x00" "accel_read") +Q(accel_mode, (const byte*)"\x11\x83\x0a\x00" "accel_mode") +Q(hid, (const byte*)"\xe0\x4f\x03\x00" "hid") +Q(time, (const byte*)"\xf0\xc1\x04\x00" "time") +Q(rand, (const byte*)"\x9c\x0a\x04\x00" "rand") +Q(Led, (const byte*)"\x88\xe0\x03\x00" "Led") +Q(LCD, (const byte*)"\xce\xdc\x03\x00" "LCD") +Q(Servo, (const byte*)"\x98\xd9\x05\x00" "Servo") +Q(SD, (const byte*)"\xf2\x74\x02\x00" "SD") +Q(SDcard, (const byte*)"\xc6\x0b\x06\x00" "SDcard") +Q(I2C, (const byte*)"\x5d\xdf\x03\x00" "I2C") +Q(gpio, (const byte*)"\x54\xd8\x04\x00" "gpio") +Q(gpio_in, (const byte*)"\xac\xa3\x07\x00" "gpio_in") +Q(gpio_out, (const byte*)"\xe5\x32\x08\x00" "gpio_out") +Q(Usart, (const byte*)"\xc4\xc9\x05\x00" "Usart") +Q(ADC, (const byte*)"\x63\xb6\x03\x00" "ADC") +Q(ADC_all, (const byte*)"\xfd\x74\x07\x00" "ADC_all") +Q(Audio, (const byte*)"\x73\x12\x05\x00" "Audio") +Q(open, (const byte*)"\xd1\x3a\x04\x00" "open") +Q(File, (const byte*)"\xa3\x97\x04\x00" "File") +Q(0_colon__slash_, (const byte*)"\xc0\x69\x03\x00" "0:/") +Q(0_colon__slash_src, (const byte*)"\xe2\xe4\x06\x00" "0:/src") +Q(0_colon__slash_lib, (const byte*)"\x87\xbf\x06\x00" "0:/lib") +Q(Pin, (const byte*)"\x12\x14\x03\x00" "Pin") +Q(PinMap, (const byte*)"\x2e\x8d\x06\x00" "PinMap") +Q(PinAF, (const byte*)"\x35\x58\x05\x00" "PinAF") +Q(PinNamed, (const byte*)"\x51\xca\x08\x00" "PinNamed") +Q(Exti, (const byte*)"\x05\x42\x04\x00" "Exti") +Q(ExtiMeta, (const byte*)"\x18\xfc\x08\x00" "ExtiMeta") +Q(rtc_info, (const byte*)"\x71\x1a\x08\x00" "rtc_info") +Q(millis, (const byte*)"\x5b\x21\x06\x00" "millis") +Q(PULL_NONE, (const byte*)"\x55\xb5\x09\x00" "PULL_NONE") +Q(PULL_UP, (const byte*)"\xba\x5e\x07\x00" "PULL_UP") +Q(PULL_DOWN, (const byte*)"\xad\xfb\x09\x00" "PULL_DOWN") +Q(PUSH_PULL, (const byte*)"\x81\x5e\x09\x00" "PUSH_PULL") +Q(OPEN_DRAIN, (const byte*)"\x5e\x48\x0a\x00" "OPEN_DRAIN") +Q(led, (const byte*)"\x68\x40\x03\x00" "led") +Q(RED, (const byte*)"\x96\x06\x03\x00" "RED") +Q(GREEN, (const byte*)"\xde\x98\x05\x00" "GREEN") +Q(BLUE, (const byte*)"\x3b\x3b\x04\x00" "BLUE") +Q(on, (const byte*)"\x64\x6f\x02\x00" "on") +Q(off, (const byte*)"\x8a\x5c\x03\x00" "off") +Q(toggle, (const byte*)"\xb7\x43\x06\x00" "toggle") +Q(Image, (const byte*)"\x62\xa0\x05\x00" "Image") +Q(Imlib, (const byte*)"\x66\xcd\x05\x00" "Imlib") +Q(Sensor, (const byte*)"\x33\xd0\x06\x00" "Sensor") +Q(Cascade, (const byte*)"\xf7\x46\x07\x00" "Cascade") +Q(Clock, (const byte*)"\x4d\x86\x05\x00" "Clock") diff --git a/include/MicroPython/runtime.h b/include/MicroPython/runtime.h index 7215cc889..3980e50cc 100644 --- a/include/MicroPython/runtime.h +++ b/include/MicroPython/runtime.h @@ -12,6 +12,7 @@ mp_obj_t rt_get_cell(mp_obj_t cell); void rt_set_cell(mp_obj_t cell, mp_obj_t val); void rt_store_name(qstr qstr, mp_obj_t obj); void rt_store_global(qstr qstr, mp_obj_t obj); +void rt_delete_name(qstr qstr); mp_obj_t rt_unary_op(int op, mp_obj_t arg); mp_obj_t rt_binary_op(int op, mp_obj_t lhs, mp_obj_t rhs); mp_obj_t rt_make_function_from_id(int unique_code_id, mp_obj_t def_args); diff --git a/lib/libmp.a b/lib/libmp.a index 257526d92..1f7f5adfe 100644 Binary files a/lib/libmp.a and b/lib/libmp.a differ diff --git a/src/py/py_imlib.c b/src/py/py_imlib.c index 152e8de38..879bda6b6 100644 --- a/src/py/py_imlib.c +++ b/src/py/py_imlib.c @@ -90,7 +90,7 @@ mp_obj_t py_imlib_draw_rectangle(mp_obj_t image_obj, mp_obj_t rectangle_obj) struct image *image; mp_obj_t *array; - array = mp_obj_get_array_fixed_n(rectangle_obj, 4); + mp_obj_get_array_fixed_n(rectangle_obj, 4, &array); r.x = mp_obj_get_int(array[0]); r.y = mp_obj_get_int(array[1]); r.w = mp_obj_get_int(array[2]); @@ -113,7 +113,7 @@ mp_obj_t py_imlib_draw_circle(mp_obj_t image_obj, mp_obj_t c_obj, mp_obj_t r_obj image = py_image_cobj(image_obj); /* center */ - array = mp_obj_get_array_fixed_n(c_obj, 2); + mp_obj_get_array_fixed_n(c_obj, 2, &array); cx = mp_obj_get_int(array[0]); cy = mp_obj_get_int(array[1]); @@ -132,7 +132,7 @@ mp_obj_t py_imlib_threshold(mp_obj_t image_obj, mp_obj_t color_obj, mp_obj_t thr PY_ASSERT_TRUE(sensor.pixformat == PIXFORMAT_RGB565); mp_obj_t *col_obj; - col_obj = mp_obj_get_array_fixed_n(color_obj, 3); + mp_obj_get_array_fixed_n(color_obj, 3, &col_obj); color.r = mp_obj_get_int(col_obj[0]); color.g = mp_obj_get_int(col_obj[1]); color.b = mp_obj_get_int(col_obj[2]); @@ -272,7 +272,7 @@ mp_obj_t py_imlib_save_template(mp_obj_t image_obj, mp_obj_t rectangle_obj, mp_o const char *path = mp_obj_str_get_str(path_obj); - array = mp_obj_get_array_fixed_n(rectangle_obj, 4); + mp_obj_get_array_fixed_n(rectangle_obj, 4, &array); r.x = mp_obj_get_int(array[0]); r.y = mp_obj_get_int(array[1]); r.w = mp_obj_get_int(array[2]);