2014-05-03 18:27:38 -04:00
|
|
|
/*
|
|
|
|
* This file is part of the Micro Python project, http://micropython.org/
|
|
|
|
*
|
|
|
|
* The MIT License (MIT)
|
|
|
|
*
|
|
|
|
* Copyright (c) 2013, 2014 Damien P. George
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
* THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
2014-03-25 10:18:18 -04:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include "mpconfig.h"
|
2014-06-21 15:43:22 -04:00
|
|
|
#include "misc.h"
|
2014-03-25 10:18:18 -04:00
|
|
|
#include "qstr.h"
|
|
|
|
#include "obj.h"
|
|
|
|
#include "builtin.h"
|
|
|
|
#include "builtintables.h"
|
|
|
|
#include "objarray.h"
|
|
|
|
|
2014-04-05 17:36:42 -04:00
|
|
|
STATIC const mp_map_elem_t mp_builtin_object_table[] = {
|
2014-03-25 10:18:18 -04:00
|
|
|
// built-in core functions
|
2014-04-05 17:36:42 -04:00
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR___build_class__), (mp_obj_t)&mp_builtin___build_class___obj },
|
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR___import__), (mp_obj_t)&mp_builtin___import___obj },
|
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR___repl_print__), (mp_obj_t)&mp_builtin___repl_print___obj },
|
2014-03-25 10:18:18 -04:00
|
|
|
|
|
|
|
// built-in types
|
2014-04-05 17:36:42 -04:00
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_bool), (mp_obj_t)&mp_type_bool },
|
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_bytes), (mp_obj_t)&mp_type_bytes },
|
2014-06-27 13:39:09 -04:00
|
|
|
#if MICROPY_PY_BUILTINS_BYTEARRAY
|
2014-04-08 15:09:14 -04:00
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_bytearray), (mp_obj_t)&mp_type_bytearray },
|
2014-06-27 13:39:09 -04:00
|
|
|
#endif
|
2014-06-19 18:48:35 -04:00
|
|
|
#if MICROPY_PY_BUILTINS_COMPLEX
|
2014-04-05 17:36:42 -04:00
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_complex), (mp_obj_t)&mp_type_complex },
|
2014-03-25 10:18:18 -04:00
|
|
|
#endif
|
2014-04-05 17:36:42 -04:00
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_dict), (mp_obj_t)&mp_type_dict },
|
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_enumerate), (mp_obj_t)&mp_type_enumerate },
|
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_filter), (mp_obj_t)&mp_type_filter },
|
2014-06-01 08:32:54 -04:00
|
|
|
#if MICROPY_PY_BUILTINS_FLOAT
|
2014-04-05 17:36:42 -04:00
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_float), (mp_obj_t)&mp_type_float },
|
2014-05-10 09:02:17 -04:00
|
|
|
#endif
|
2014-06-01 08:32:54 -04:00
|
|
|
#if MICROPY_PY_BUILTINS_FROZENSET
|
2014-05-10 09:02:17 -04:00
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_frozenset), (mp_obj_t)&mp_type_frozenset },
|
2014-03-25 10:18:18 -04:00
|
|
|
#endif
|
2014-04-05 17:36:42 -04:00
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_int), (mp_obj_t)&mp_type_int },
|
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_list), (mp_obj_t)&mp_type_list },
|
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_map), (mp_obj_t)&mp_type_map },
|
2014-10-23 08:34:35 -04:00
|
|
|
#if MICROPY_PY_BUILTINS_MEMORYVIEW
|
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_memoryview), (mp_obj_t)&mp_type_memoryview },
|
|
|
|
#endif
|
2014-04-05 17:36:42 -04:00
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_object), (mp_obj_t)&mp_type_object },
|
2014-06-01 08:32:54 -04:00
|
|
|
#if MICROPY_PY_BUILTINS_PROPERTY
|
2014-04-13 13:59:45 -04:00
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_property), (mp_obj_t)&mp_type_property },
|
|
|
|
#endif
|
2014-04-17 13:18:55 -04:00
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_range), (mp_obj_t)&mp_type_range },
|
2014-08-12 13:33:40 -04:00
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_reversed), (mp_obj_t)&mp_type_reversed },
|
2014-06-01 08:46:47 -04:00
|
|
|
#if MICROPY_PY_BUILTINS_SET
|
2014-04-05 17:36:42 -04:00
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_set), (mp_obj_t)&mp_type_set },
|
2014-06-01 08:46:47 -04:00
|
|
|
#endif
|
2014-04-05 17:36:42 -04:00
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_str), (mp_obj_t)&mp_type_str },
|
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_super), (mp_obj_t)&mp_type_super },
|
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_tuple), (mp_obj_t)&mp_type_tuple },
|
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_type), (mp_obj_t)&mp_type_type },
|
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_zip), (mp_obj_t)&mp_type_zip },
|
|
|
|
|
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_classmethod), (mp_obj_t)&mp_type_classmethod },
|
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_staticmethod), (mp_obj_t)&mp_type_staticmethod },
|
2014-03-25 10:18:18 -04:00
|
|
|
|
2014-03-29 09:15:08 -04:00
|
|
|
// built-in objects
|
2014-04-05 17:36:42 -04:00
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_Ellipsis), (mp_obj_t)&mp_const_ellipsis_obj },
|
2014-03-29 09:15:08 -04:00
|
|
|
|
2014-03-25 10:18:18 -04:00
|
|
|
// built-in user functions
|
2014-04-05 17:36:42 -04:00
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_abs), (mp_obj_t)&mp_builtin_abs_obj },
|
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_all), (mp_obj_t)&mp_builtin_all_obj },
|
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_any), (mp_obj_t)&mp_builtin_any_obj },
|
2014-04-15 17:03:55 -04:00
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_bin), (mp_obj_t)&mp_builtin_bin_obj },
|
2014-04-05 17:36:42 -04:00
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_callable), (mp_obj_t)&mp_builtin_callable_obj },
|
2014-10-25 16:59:14 -04:00
|
|
|
#if MICROPY_PY_BUILTINS_COMPILE
|
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_compile), (mp_obj_t)&mp_builtin_compile_obj },
|
|
|
|
#endif
|
2014-04-05 17:36:42 -04:00
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_chr), (mp_obj_t)&mp_builtin_chr_obj },
|
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_dir), (mp_obj_t)&mp_builtin_dir_obj },
|
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_divmod), (mp_obj_t)&mp_builtin_divmod_obj },
|
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_eval), (mp_obj_t)&mp_builtin_eval_obj },
|
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_exec), (mp_obj_t)&mp_builtin_exec_obj },
|
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_getattr), (mp_obj_t)&mp_builtin_getattr_obj },
|
2014-04-05 18:00:46 -04:00
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_globals), (mp_obj_t)&mp_builtin_globals_obj },
|
2014-05-11 12:05:42 -04:00
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_hasattr), (mp_obj_t)&mp_builtin_hasattr_obj },
|
2014-04-05 17:36:42 -04:00
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_hash), (mp_obj_t)&mp_builtin_hash_obj },
|
2014-04-15 07:42:52 -04:00
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_hex), (mp_obj_t)&mp_builtin_hex_obj },
|
2014-04-05 17:36:42 -04:00
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_id), (mp_obj_t)&mp_builtin_id_obj },
|
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_isinstance), (mp_obj_t)&mp_builtin_isinstance_obj },
|
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_issubclass), (mp_obj_t)&mp_builtin_issubclass_obj },
|
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_iter), (mp_obj_t)&mp_builtin_iter_obj },
|
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_len), (mp_obj_t)&mp_builtin_len_obj },
|
2014-04-05 18:00:46 -04:00
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_locals), (mp_obj_t)&mp_builtin_locals_obj },
|
2014-04-05 17:36:42 -04:00
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_max), (mp_obj_t)&mp_builtin_max_obj },
|
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_min), (mp_obj_t)&mp_builtin_min_obj },
|
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_next), (mp_obj_t)&mp_builtin_next_obj },
|
2014-04-15 17:03:55 -04:00
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_oct), (mp_obj_t)&mp_builtin_oct_obj },
|
2014-04-05 17:36:42 -04:00
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_ord), (mp_obj_t)&mp_builtin_ord_obj },
|
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_pow), (mp_obj_t)&mp_builtin_pow_obj },
|
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_print), (mp_obj_t)&mp_builtin_print_obj },
|
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_repr), (mp_obj_t)&mp_builtin_repr_obj },
|
2014-10-31 07:28:50 -04:00
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_round), (mp_obj_t)&mp_builtin_round_obj },
|
2014-04-05 17:36:42 -04:00
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_sorted), (mp_obj_t)&mp_builtin_sorted_obj },
|
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_sum), (mp_obj_t)&mp_builtin_sum_obj },
|
2014-03-25 10:18:18 -04:00
|
|
|
|
|
|
|
// built-in exceptions
|
2014-04-05 17:36:42 -04:00
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_BaseException), (mp_obj_t)&mp_type_BaseException },
|
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_ArithmeticError), (mp_obj_t)&mp_type_ArithmeticError },
|
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_AssertionError), (mp_obj_t)&mp_type_AssertionError },
|
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_AttributeError), (mp_obj_t)&mp_type_AttributeError },
|
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_EOFError), (mp_obj_t)&mp_type_EOFError },
|
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_Exception), (mp_obj_t)&mp_type_Exception },
|
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_GeneratorExit), (mp_obj_t)&mp_type_GeneratorExit },
|
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_ImportError), (mp_obj_t)&mp_type_ImportError },
|
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_IndentationError), (mp_obj_t)&mp_type_IndentationError },
|
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_IndexError), (mp_obj_t)&mp_type_IndexError },
|
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_KeyError), (mp_obj_t)&mp_type_KeyError },
|
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_LookupError), (mp_obj_t)&mp_type_LookupError },
|
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_MemoryError), (mp_obj_t)&mp_type_MemoryError },
|
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_NameError), (mp_obj_t)&mp_type_NameError },
|
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_NotImplementedError), (mp_obj_t)&mp_type_NotImplementedError },
|
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_OSError), (mp_obj_t)&mp_type_OSError },
|
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_OverflowError), (mp_obj_t)&mp_type_OverflowError },
|
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_RuntimeError), (mp_obj_t)&mp_type_RuntimeError },
|
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_StopIteration), (mp_obj_t)&mp_type_StopIteration },
|
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_SyntaxError), (mp_obj_t)&mp_type_SyntaxError },
|
2014-08-16 09:32:06 -04:00
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_SystemExit), (mp_obj_t)&mp_type_SystemExit },
|
2014-04-05 17:36:42 -04:00
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_TypeError), (mp_obj_t)&mp_type_TypeError },
|
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_ValueError), (mp_obj_t)&mp_type_ValueError },
|
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_ZeroDivisionError), (mp_obj_t)&mp_type_ZeroDivisionError },
|
2014-03-25 10:18:18 -04:00
|
|
|
// Somehow CPython managed to have OverflowError not inherit from ValueError ;-/
|
|
|
|
// TODO: For MICROPY_CPYTHON_COMPAT==0 use ValueError to avoid exc proliferation
|
|
|
|
|
|
|
|
// Extra builtins as defined by a port
|
2014-05-21 15:32:59 -04:00
|
|
|
MICROPY_PORT_BUILTINS
|
2014-04-05 17:36:42 -04:00
|
|
|
};
|
2014-03-25 10:18:18 -04:00
|
|
|
|
2014-04-05 17:36:42 -04:00
|
|
|
const mp_obj_dict_t mp_builtin_object_dict_obj = {
|
|
|
|
.base = {&mp_type_dict},
|
|
|
|
.map = {
|
|
|
|
.all_keys_are_qstrs = 1,
|
|
|
|
.table_is_fixed_array = 1,
|
2014-06-19 12:54:34 -04:00
|
|
|
.used = MP_ARRAY_SIZE(mp_builtin_object_table),
|
|
|
|
.alloc = MP_ARRAY_SIZE(mp_builtin_object_table),
|
2014-04-05 17:36:42 -04:00
|
|
|
.table = (mp_map_elem_t*)mp_builtin_object_table,
|
|
|
|
},
|
2014-03-25 10:18:18 -04:00
|
|
|
};
|
|
|
|
|
2014-09-17 18:17:26 -04:00
|
|
|
STATIC const mp_obj_module_t mp_module_builtins = {
|
|
|
|
.base = { &mp_type_module },
|
|
|
|
.name = MP_QSTR_builtins,
|
|
|
|
.globals = (mp_obj_dict_t*)&mp_builtin_object_dict_obj,
|
|
|
|
};
|
|
|
|
|
2014-04-05 17:36:42 -04:00
|
|
|
STATIC const mp_map_elem_t mp_builtin_module_table[] = {
|
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR___main__), (mp_obj_t)&mp_module___main__ },
|
2014-09-17 18:17:26 -04:00
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_builtins), (mp_obj_t)&mp_module_builtins },
|
2014-04-05 17:36:42 -04:00
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_micropython), (mp_obj_t)&mp_module_micropython },
|
2014-03-25 10:18:18 -04:00
|
|
|
|
2014-06-27 13:39:09 -04:00
|
|
|
#if MICROPY_PY_ARRAY
|
2014-04-05 17:36:42 -04:00
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_array), (mp_obj_t)&mp_module_array },
|
2014-06-27 13:39:09 -04:00
|
|
|
#endif
|
2014-05-24 18:03:12 -04:00
|
|
|
#if MICROPY_PY_IO
|
2014-06-11 18:22:25 -04:00
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR__io), (mp_obj_t)&mp_module_io },
|
2014-04-03 07:57:53 -04:00
|
|
|
#endif
|
2014-05-24 18:03:12 -04:00
|
|
|
#if MICROPY_PY_COLLECTIONS
|
2014-04-13 03:17:04 -04:00
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR__collections), (mp_obj_t)&mp_module_collections },
|
2014-04-26 05:31:15 -04:00
|
|
|
#endif
|
2014-05-24 18:03:12 -04:00
|
|
|
#if MICROPY_PY_STRUCT
|
2014-04-09 20:45:38 -04:00
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_struct), (mp_obj_t)&mp_module_struct },
|
|
|
|
#endif
|
2014-03-25 10:18:18 -04:00
|
|
|
|
2014-06-03 08:43:20 -04:00
|
|
|
#if MICROPY_PY_BUILTINS_FLOAT
|
2014-06-03 08:33:38 -04:00
|
|
|
#if MICROPY_PY_MATH
|
2014-04-05 17:36:42 -04:00
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_math), (mp_obj_t)&mp_module_math },
|
2014-06-03 08:33:38 -04:00
|
|
|
#endif
|
2014-05-24 18:03:12 -04:00
|
|
|
#if MICROPY_PY_CMATH
|
2014-04-17 12:11:03 -04:00
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_cmath), (mp_obj_t)&mp_module_cmath },
|
|
|
|
#endif
|
2014-06-03 08:43:20 -04:00
|
|
|
#endif
|
2014-05-24 18:03:12 -04:00
|
|
|
#if MICROPY_PY_SYS
|
2014-04-12 23:43:18 -04:00
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_sys), (mp_obj_t)&mp_module_sys },
|
2014-04-13 08:05:16 -04:00
|
|
|
#endif
|
2014-05-24 18:03:12 -04:00
|
|
|
#if MICROPY_PY_GC && MICROPY_ENABLE_GC
|
2014-05-05 19:16:43 -04:00
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_gc), (mp_obj_t)&mp_module_gc },
|
|
|
|
#endif
|
2014-03-25 10:18:18 -04:00
|
|
|
|
2014-06-27 20:03:47 -04:00
|
|
|
// extmod modules
|
|
|
|
|
|
|
|
#if MICROPY_PY_UCTYPES
|
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_uctypes), (mp_obj_t)&mp_module_uctypes },
|
|
|
|
#endif
|
2014-10-12 11:16:34 -04:00
|
|
|
#if MICROPY_PY_UZLIB
|
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_uzlib), (mp_obj_t)&mp_module_uzlib },
|
|
|
|
#endif
|
2014-09-17 17:56:34 -04:00
|
|
|
#if MICROPY_PY_UJSON
|
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_ujson), (mp_obj_t)&mp_module_ujson },
|
|
|
|
#endif
|
2014-09-12 11:48:07 -04:00
|
|
|
#if MICROPY_PY_URE
|
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_ure), (mp_obj_t)&mp_module_ure },
|
|
|
|
#endif
|
2014-10-22 13:37:18 -04:00
|
|
|
#if MICROPY_PY_UHEAPQ
|
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_uheapq), (mp_obj_t)&mp_module_uheapq },
|
|
|
|
#endif
|
2014-11-21 18:19:13 -05:00
|
|
|
#if MICROPY_PY_UHASHLIB
|
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_uhashlib), (mp_obj_t)&mp_module_uhashlib },
|
|
|
|
#endif
|
2014-11-28 23:19:30 -05:00
|
|
|
#if MICROPY_PY_UBINASCII
|
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_ubinascii), (mp_obj_t)&mp_module_ubinascii },
|
|
|
|
#endif
|
2014-06-27 20:03:47 -04:00
|
|
|
|
2014-03-25 10:18:18 -04:00
|
|
|
// extra builtin modules as defined by a port
|
2014-05-21 15:32:59 -04:00
|
|
|
MICROPY_PORT_BUILTIN_MODULES
|
2014-03-25 10:18:18 -04:00
|
|
|
};
|
|
|
|
|
2014-04-05 17:36:42 -04:00
|
|
|
const mp_obj_dict_t mp_builtin_module_dict_obj = {
|
|
|
|
.base = {&mp_type_dict},
|
|
|
|
.map = {
|
|
|
|
.all_keys_are_qstrs = 1,
|
|
|
|
.table_is_fixed_array = 1,
|
2014-06-19 12:54:34 -04:00
|
|
|
.used = MP_ARRAY_SIZE(mp_builtin_module_table),
|
|
|
|
.alloc = MP_ARRAY_SIZE(mp_builtin_module_table),
|
2014-04-05 17:36:42 -04:00
|
|
|
.table = (mp_map_elem_t*)mp_builtin_module_table,
|
|
|
|
},
|
|
|
|
};
|
2014-10-12 06:46:04 -04:00
|
|
|
|
|
|
|
#if MICROPY_MODULE_WEAK_LINKS
|
|
|
|
STATIC const mp_map_elem_t mp_builtin_module_weak_links_table[] = {
|
|
|
|
MICROPY_PORT_BUILTIN_MODULE_WEAK_LINKS
|
|
|
|
};
|
|
|
|
|
|
|
|
const mp_obj_dict_t mp_builtin_module_weak_links_dict_obj = {
|
|
|
|
.base = {&mp_type_dict},
|
|
|
|
.map = {
|
|
|
|
.all_keys_are_qstrs = 1,
|
|
|
|
.table_is_fixed_array = 1,
|
|
|
|
.used = MP_ARRAY_SIZE(mp_builtin_module_weak_links_table),
|
|
|
|
.alloc = MP_ARRAY_SIZE(mp_builtin_module_weak_links_table),
|
|
|
|
.table = (mp_map_elem_t*)mp_builtin_module_weak_links_table,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
#endif
|