diff options
Diffstat (limited to 'py')
126 files changed, 529 insertions, 816 deletions
diff --git a/py/argcheck.c b/py/argcheck.c index 4bc0629b12..f9a4eb7f46 100644 --- a/py/argcheck.c +++ b/py/argcheck.c @@ -27,12 +27,8 @@ #include <stdlib.h> #include <assert.h> -#include "mpconfig.h" -#include "nlr.h" -#include "misc.h" -#include "qstr.h" -#include "obj.h" -#include "runtime.h" +#include "py/nlr.h" +#include "py/runtime.h" void mp_arg_check_num(mp_uint_t n_args, mp_uint_t n_kw, mp_uint_t n_args_min, mp_uint_t n_args_max, bool takes_kw) { // TODO maybe take the function name as an argument so we can print nicer error messages diff --git a/py/asmarm.c b/py/asmarm.c index 51852df5f4..0ca88fd97c 100644 --- a/py/asmarm.c +++ b/py/asmarm.c @@ -29,13 +29,13 @@ #include <assert.h> #include <string.h> -#include "mpconfig.h" -#include "misc.h" -#include "asmarm.h" +#include "py/mpconfig.h" // wrapper around everything in this file #if MICROPY_EMIT_ARM +#include "py/asmarm.h" + #define SIGNED_FIT24(x) (((x) & 0xff800000) == 0) || (((x) & 0xff000000) == 0xff000000) struct _asm_arm_t { diff --git a/py/asmthumb.c b/py/asmthumb.c index 7ae6862b51..14ba5a6fcd 100644 --- a/py/asmthumb.c +++ b/py/asmthumb.c @@ -28,13 +28,13 @@ #include <assert.h> #include <string.h> -#include "mpconfig.h" -#include "misc.h" -#include "asmthumb.h" +#include "py/mpconfig.h" // wrapper around everything in this file #if MICROPY_EMIT_THUMB || MICROPY_EMIT_INLINE_THUMB +#include "py/asmthumb.h" + #define UNSIGNED_FIT8(x) (((x) & 0xffffff00) == 0) #define UNSIGNED_FIT16(x) (((x) & 0xffff0000) == 0) #define SIGNED_FIT8(x) (((x) & 0xffffff80) == 0) || (((x) & 0xffffff80) == 0xffffff80) diff --git a/py/asmx64.c b/py/asmx64.c index 54f541ffb9..ded778fe09 100644 --- a/py/asmx64.c +++ b/py/asmx64.c @@ -29,13 +29,12 @@ #include <assert.h> #include <string.h> -#include "mpconfig.h" -#include "misc.h" +#include "py/mpconfig.h" // wrapper around everything in this file #if MICROPY_EMIT_X64 -#include "asmx64.h" +#include "py/asmx64.h" /* all offsets are measured in multiples of 8 bytes */ #define WORD_SIZE (8) diff --git a/py/asmx86.c b/py/asmx86.c index f0dc1e60f5..29ceaf8f87 100644 --- a/py/asmx86.c +++ b/py/asmx86.c @@ -29,13 +29,12 @@ #include <assert.h> #include <string.h> -#include "mpconfig.h" -#include "misc.h" +#include "py/mpconfig.h" // wrapper around everything in this file #if MICROPY_EMIT_X86 -#include "asmx86.h" +#include "py/asmx86.h" /* all offsets are measured in multiples of 4 bytes */ #define WORD_SIZE (4) @@ -29,17 +29,9 @@ #include <string.h> #include <assert.h> -#include "mpconfig.h" -#include "nlr.h" -#include "misc.h" -#include "qstr.h" -#include "obj.h" -#include "objtuple.h" -#include "objfun.h" -#include "runtime0.h" -#include "runtime.h" -#include "bc.h" -#include "stackctrl.h" +#include "py/nlr.h" +#include "py/objfun.h" +#include "py/bc.h" #if 0 // print debugging info #define DEBUG_PRINT (1) @@ -23,6 +23,11 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ +#ifndef __MICROPY_INCLUDED_PY_BC_H__ +#define __MICROPY_INCLUDED_PY_BC_H__ + +#include "py/runtime.h" +#include "py/obj.h" // Exception stack entry typedef struct _mp_exc_stack { @@ -61,3 +66,5 @@ const byte *mp_bytecode_print_str(const byte *ip); #define MP_TAGPTR_TAG0(x) ((mp_uint_t)(x) & 1) #define MP_TAGPTR_TAG1(x) ((mp_uint_t)(x) & 2) #define MP_TAGPTR_MAKE(ptr, tag) ((void*)((mp_uint_t)(ptr) | (tag))) + +#endif // __MICROPY_INCLUDED_PY_BC_H__ @@ -23,6 +23,8 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ +#ifndef __MICROPY_INCLUDED_PY_BC0_H__ +#define __MICROPY_INCLUDED_PY_BC0_H__ // Micro Python byte-codes. // The comment at the end of the line (if it exists) tells the arguments to the byte-code. @@ -118,3 +120,5 @@ #define MP_BC_STORE_FAST_MULTI (0xc0) // + N(16) #define MP_BC_UNARY_OP_MULTI (0xd0) // + op(5) #define MP_BC_BINARY_OP_MULTI (0xd5) // + op(35) + +#endif // __MICROPY_INCLUDED_PY_BC0_H__ diff --git a/py/binary.c b/py/binary.c index e4dac31e96..69818e5361 100644 --- a/py/binary.c +++ b/py/binary.c @@ -30,12 +30,8 @@ #include <string.h> #include <assert.h> -#include "mpconfig.h" -#include "misc.h" -#include "qstr.h" -#include "obj.h" -#include "smallint.h" -#include "binary.h" +#include "py/binary.h" +#include "py/smallint.h" // Helpers to work with binary-encoded data diff --git a/py/binary.h b/py/binary.h index dc9d3f6808..a0ccbd5f43 100644 --- a/py/binary.h +++ b/py/binary.h @@ -23,6 +23,10 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ +#ifndef __MICROPY_INCLUDED_PY_BINARY_H__ +#define __MICROPY_INCLUDED_PY_BINARY_H__ + +#include "py/obj.h" // Use special typecode to differentiate repr() of bytearray vs array.array('B') // (underlyingly they're same). @@ -36,3 +40,5 @@ mp_obj_t mp_binary_get_val(char struct_type, char val_type, byte **ptr); void mp_binary_set_val(char struct_type, char val_type, mp_obj_t val_in, byte **ptr); long long mp_binary_get_int(mp_uint_t size, bool is_signed, bool big_endian, const byte *src); void mp_binary_set_int(mp_uint_t val_sz, bool big_endian, byte *dest, mp_uint_t val); + +#endif // __MICROPY_INCLUDED_PY_BINARY_H__ diff --git a/py/builtin.h b/py/builtin.h index 70f1633791..14dc273246 100644 --- a/py/builtin.h +++ b/py/builtin.h @@ -23,6 +23,10 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ +#ifndef __MICROPY_INCLUDED_PY_BUILTIN_H__ +#define __MICROPY_INCLUDED_PY_BUILTIN_H__ + +#include "py/obj.h" mp_obj_t mp_builtin___import__(mp_uint_t n_args, const mp_obj_t *args); mp_obj_t mp_builtin_open(mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kwargs); @@ -101,3 +105,5 @@ extern const mp_obj_module_t mp_module_ure; extern const mp_obj_module_t mp_module_uheapq; extern const mp_obj_module_t mp_module_uhashlib; extern const mp_obj_module_t mp_module_ubinascii; + +#endif // __MICROPY_INCLUDED_PY_BUILTIN_H__ diff --git a/py/builtinevex.c b/py/builtinevex.c index bb15fd4d0f..9bca4a0f53 100644 --- a/py/builtinevex.c +++ b/py/builtinevex.c @@ -26,20 +26,11 @@ #include <stdint.h> -#include "mpconfig.h" -#include "nlr.h" -#include "misc.h" -#include "qstr.h" -#include "lexer.h" -#include "lexerunix.h" -#include "parse.h" -#include "obj.h" -#include "objfun.h" -#include "parsehelper.h" -#include "compile.h" -#include "runtime0.h" -#include "runtime.h" -#include "builtin.h" +#include "py/nlr.h" +#include "py/objfun.h" +#include "py/compile.h" +#include "py/runtime.h" +#include "py/builtin.h" #if MICROPY_PY_BUILTINS_COMPILE diff --git a/py/builtinimport.c b/py/builtinimport.c index fd804ee356..4dc02bdc22 100644 --- a/py/builtinimport.c +++ b/py/builtinimport.c @@ -25,25 +25,15 @@ * THE SOFTWARE. */ -#include <stdint.h> #include <stdio.h> #include <string.h> #include <assert.h> -#include "mpconfig.h" -#include "nlr.h" -#include "misc.h" -#include "qstr.h" -#include "lexer.h" -#include "lexerunix.h" -#include "parse.h" -#include "obj.h" -#include "objmodule.h" -#include "parsehelper.h" -#include "compile.h" -#include "runtime0.h" -#include "runtime.h" -#include "builtin.h" +#include "py/nlr.h" +#include "py/compile.h" +#include "py/objmodule.h" +#include "py/runtime.h" +#include "py/builtin.h" #if 0 // print debugging info #define DEBUG_PRINT (1) diff --git a/py/compile.c b/py/compile.c index 66e2996c44..b2ba01cc9d 100644 --- a/py/compile.c +++ b/py/compile.c @@ -31,26 +31,18 @@ #include <assert.h> #include <math.h> -#include "mpconfig.h" -#include "misc.h" -#include "qstr.h" -#include "lexer.h" -#include "parse.h" -#include "runtime0.h" -#include "obj.h" -#include "emitglue.h" -#include "scope.h" -#include "emit.h" -#include "compile.h" -#include "runtime.h" -#include "builtin.h" -#include "smallint.h" +#include "py/scope.h" +#include "py/emit.h" +#include "py/compile.h" +#include "py/smallint.h" +#include "py/runtime.h" +#include "py/builtin.h" // TODO need to mangle __attr names typedef enum { #define DEF_RULE(rule, comp, kind, ...) PN_##rule, -#include "grammar.h" +#include "py/grammar.h" #undef DEF_RULE PN_maximum_number_of, PN_string, // special node for non-interned string @@ -2937,7 +2929,7 @@ STATIC compile_function_t compile_function[] = { #define nc NULL #define c(f) compile_##f #define DEF_RULE(rule, comp, kind, ...) comp, -#include "grammar.h" +#include "py/grammar.h" #undef nc #undef c #undef DEF_RULE @@ -24,6 +24,13 @@ * THE SOFTWARE. */ +#ifndef __MICROPY_INCLUDED_PY_EMIT_H__ +#define __MICROPY_INCLUDED_PY_EMIT_H__ + +#include "py/lexer.h" +#include "py/scope.h" +#include "py/runtime0.h" + /* Notes on passes: * We don't know exactly the opcodes in pass 1 because they depend on the * closing over of variables (LOAD_CLOSURE, BUILD_TUPLE, MAKE_CLOSURE), which @@ -33,10 +40,6 @@ * This is problematic for some emitters (x64) since they need to know the maximum * stack size to compile the entry to the function, and this affects code size. */ -#ifndef __MICROPY_INCLUDED_PY_EMIT_H__ -#define __MICROPY_INCLUDED_PY_EMIT_H__ - -#include "py/runtime0.h" typedef enum { MP_PASS_SCOPE = 1, // work out id's and their kind, and number of labels diff --git a/py/emitbc.c b/py/emitbc.c index f55a16634a..3914a9dcbf 100644 --- a/py/emitbc.c +++ b/py/emitbc.c @@ -30,17 +30,8 @@ #include <string.h> #include <assert.h> -#include "mpconfig.h" -#include "misc.h" -#include "qstr.h" -#include "lexer.h" -#include "parse.h" -#include "obj.h" -#include "emitglue.h" -#include "scope.h" -#include "runtime0.h" -#include "emit.h" -#include "bc0.h" +#include "py/emit.h" +#include "py/bc0.h" #if !MICROPY_EMIT_CPYTHON diff --git a/py/emitcommon.c b/py/emitcommon.c index e199bc6e9c..4d909839ad 100644 --- a/py/emitcommon.c +++ b/py/emitcommon.c @@ -28,16 +28,7 @@ #include <stdint.h> #include <assert.h> -#include "mpconfig.h" -#include "misc.h" -#include "qstr.h" -#include "lexer.h" -#include "parse.h" -#include "runtime0.h" -#include "obj.h" -#include "emitglue.h" -#include "scope.h" -#include "emit.h" +#include "py/emit.h" #define EMIT(fun, ...) (emit_method_table->fun(emit, __VA_ARGS__)) diff --git a/py/emitcpy.c b/py/emitcpy.c index bcf8a22c3a..a1e8e95c8c 100644 --- a/py/emitcpy.c +++ b/py/emitcpy.c @@ -30,16 +30,7 @@ #include <string.h> #include <assert.h> -#include "mpconfig.h" -#include "misc.h" -#include "qstr.h" -#include "lexer.h" -#include "parse.h" -#include "obj.h" -#include "emitglue.h" -#include "scope.h" -#include "runtime0.h" -#include "emit.h" +#include "py/emit.h" // wrapper around everything in this file #if MICROPY_EMIT_CPYTHON diff --git a/py/emitglue.c b/py/emitglue.c index 5d51ba2a68..65d131125f 100644 --- a/py/emitglue.c +++ b/py/emitglue.c @@ -30,14 +30,9 @@ #include <string.h> #include <assert.h> -#include "mpconfig.h" -#include "misc.h" -#include "qstr.h" -#include "obj.h" -#include "runtime0.h" -#include "runtime.h" -#include "emitglue.h" -#include "bc.h" +#include "py/emitglue.h" +#include "py/runtime0.h" +#include "py/bc.h" #if 0 // print debugging info #define DEBUG_PRINT (1) diff --git a/py/emitglue.h b/py/emitglue.h index 60ccd67406..6e7e72ef5a 100644 --- a/py/emitglue.h +++ b/py/emitglue.h @@ -26,6 +26,8 @@ #ifndef __MICROPY_INCLUDED_PY_EMITGLUE_H__ #define __MICROPY_INCLUDED_PY_EMITGLUE_H__ +#include "py/obj.h" + // These variables and functions glue the code emitters to the runtime. typedef enum { diff --git a/py/emitinlinethumb.c b/py/emitinlinethumb.c index 4cf880fab7..669929b0d1 100644 --- a/py/emitinlinethumb.c +++ b/py/emitinlinethumb.c @@ -30,23 +30,14 @@ #include <stdarg.h> #include <assert.h> -#include "mpconfig.h" -#include "misc.h" -#include "qstr.h" -#include "lexer.h" -#include "parse.h" -#include "obj.h" -#include "emitglue.h" -#include "scope.h" -#include "runtime0.h" -#include "emit.h" -#include "asmthumb.h" +#include "py/emit.h" +#include "py/asmthumb.h" #if MICROPY_EMIT_INLINE_THUMB typedef enum { #define DEF_RULE(rule, comp, kind, ...) PN_##rule, -#include "grammar.h" +#include "py/grammar.h" #undef DEF_RULE PN_maximum_number_of, } pn_kind_t; diff --git a/py/emitnative.c b/py/emitnative.c index c8f8cd8f24..494f89093d 100644 --- a/py/emitnative.c +++ b/py/emitnative.c @@ -42,24 +42,12 @@ // for x in l[0:8]: can be compiled into a native loop if l has pointer type -#include <stdbool.h> -#include <stdint.h> #include <stdio.h> #include <string.h> #include <assert.h> -#include "mpconfig.h" -#include "nlr.h" -#include "misc.h" -#include "qstr.h" -#include "lexer.h" -#include "parse.h" -#include "obj.h" -#include "emitglue.h" -#include "scope.h" -#include "runtime0.h" -#include "emit.h" -#include "runtime.h" +#include "py/nlr.h" +#include "py/emit.h" #if 0 // print debugging info #define DEBUG_PRINT (1) @@ -78,7 +66,7 @@ // x64 specific stuff -#include "asmx64.h" +#include "py/asmx64.h" #define EXPORT_FUN(name) emit_native_x64_##name @@ -163,7 +151,7 @@ // x86 specific stuff -#include "asmx86.h" +#include "py/asmx86.h" STATIC byte mp_f_n_args[MP_F_NUMBER_OF] = { [MP_F_CONVERT_OBJ_TO_NATIVE] = 2, @@ -295,7 +283,7 @@ STATIC byte mp_f_n_args[MP_F_NUMBER_OF] = { // thumb specific stuff -#include "asmthumb.h" +#include "py/asmthumb.h" #define EXPORT_FUN(name) emit_native_thumb_##name @@ -378,7 +366,7 @@ STATIC byte mp_f_n_args[MP_F_NUMBER_OF] = { // ARM specific stuff -#include "asmarm.h" +#include "py/asmarm.h" #define EXPORT_FUN(name) emit_native_arm_##name diff --git a/py/emitpass1.c b/py/emitpass1.c index 9e471ef59f..8878b562e3 100644 --- a/py/emitpass1.c +++ b/py/emitpass1.c @@ -24,20 +24,9 @@ * THE SOFTWARE. */ -#include <stdlib.h> -#include <stdint.h> #include <assert.h> -#include "mpconfig.h" -#include "misc.h" -#include "qstr.h" -#include "lexer.h" -#include "parse.h" -#include "obj.h" -#include "emitglue.h" -#include "scope.h" -#include "runtime0.h" -#include "emit.h" +#include "py/emit.h" struct _emit_t { scope_t *scope; diff --git a/py/formatfloat.c b/py/formatfloat.c index d1b12cdd5b..e73215a7a8 100644 --- a/py/formatfloat.c +++ b/py/formatfloat.c @@ -42,10 +42,11 @@ #include <stdlib.h> #include <stdint.h> -#include "mpconfig.h" +#include "py/mpconfig.h" #if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT -#include "formatfloat.h" + +#include "py/formatfloat.h" // 1 sign bit, 8 exponent bits, and 23 mantissa bits. // exponent values 0 and 255 are reserved, exponent can be 1 to 254. @@ -63,7 +64,7 @@ static const float g_neg_pow[] = { 1e-32, 1e-16, 1e-8, 1e-4, 1e-2, 1e-1 }; -int format_float(float f, char *buf, size_t buf_size, char fmt, int prec, char sign) { +int mp_format_float(float f, char *buf, size_t buf_size, char fmt, int prec, char sign) { char *s = buf; int buf_remaining = buf_size - 1; diff --git a/py/formatfloat.h b/py/formatfloat.h index 3b963df414..1eb2c1e46f 100644 --- a/py/formatfloat.h +++ b/py/formatfloat.h @@ -23,5 +23,9 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ +#ifndef __MICROPY_INCLUDED_PY_FORMATFLOAT_H__ +#define __MICROPY_INCLUDED_PY_FORMATFLOAT_H__ -int format_float(float f, char *buf, size_t bufSize, char fmt, int prec, char sign); +int mp_format_float(float f, char *buf, size_t bufSize, char fmt, int prec, char sign); + +#endif // __MICROPY_INCLUDED_PY_FORMATFLOAT_H__ @@ -27,16 +27,10 @@ #include <assert.h> #include <stdio.h> #include <string.h> -#include <stdbool.h> -#include <stdint.h> -#include "mpconfig.h" -#include "misc.h" -#include "gc.h" - -#include "qstr.h" -#include "obj.h" -#include "runtime.h" +#include "py/gc.h" +#include "py/obj.h" +#include "py/runtime.h" #if MICROPY_ENABLE_GC @@ -23,6 +23,13 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ +#ifndef __MICROPY_INCLUDED_PY_GC_H__ +#define __MICROPY_INCLUDED_PY_GC_H__ + +#include <stdint.h> + +#include "py/mpconfig.h" +#include "py/misc.h" void gc_init(void *start, void *end); @@ -60,3 +67,5 @@ typedef struct _gc_info_t { void gc_info(gc_info_t *info); void gc_dump_info(void); void gc_dump_alloc_table(void); + +#endif // __MICROPY_INCLUDED_PY_GC_H__ diff --git a/py/lexer.c b/py/lexer.c index bc1b8babf3..ce6aa783a2 100644 --- a/py/lexer.c +++ b/py/lexer.c @@ -24,18 +24,10 @@ * THE SOFTWARE. */ -/* lexer.c -- simple tokeniser for Python implementation - */ - -#include <stdbool.h> -#include <stdint.h> #include <stdio.h> #include <assert.h> -#include "mpconfig.h" -#include "misc.h" -#include "qstr.h" -#include "lexer.h" +#include "py/lexer.h" #define TAB_SIZE (8) diff --git a/py/lexer.h b/py/lexer.h index 7f8d93b1ea..c2d2b678a0 100644 --- a/py/lexer.h +++ b/py/lexer.h @@ -26,6 +26,11 @@ #ifndef __MICROPY_INCLUDED_PY_LEXER_H__ #define __MICROPY_INCLUDED_PY_LEXER_H__ +#include <stdint.h> + +#include "py/mpconfig.h" +#include "py/qstr.h" + /* lexer.h -- simple tokeniser for Micro Python * * Uses (byte) length instead of null termination. diff --git a/py/lexerstr.c b/py/lexerstr.c index c3456b9bd2..cab3ed3612 100644 --- a/py/lexerstr.c +++ b/py/lexerstr.c @@ -24,12 +24,7 @@ * THE SOFTWARE. */ -#include <stdint.h> - -#include "mpconfig.h" -#include "misc.h" -#include "qstr.h" -#include "lexer.h" +#include "py/lexer.h" typedef struct _mp_lexer_str_buf_t { mp_uint_t free_len; // if > 0, src_beg will be freed when done by: m_free(src_beg, free_len) diff --git a/py/lexerunix.c b/py/lexerunix.c index 8e3241ad01..b5abbc8fe5 100644 --- a/py/lexerunix.c +++ b/py/lexerunix.c @@ -24,8 +24,7 @@ * THE SOFTWARE. */ -#include "mpconfig.h" -#include "misc.h" +#include "py/mpconfig.h" #if MICROPY_HELPER_LEXER_UNIX @@ -36,9 +35,7 @@ #include <sys/stat.h> #include <sys/types.h> -#include "qstr.h" -#include "lexer.h" -#include "lexerunix.h" +#include "py/lexer.h" typedef struct _mp_lexer_file_buf_t { int fd; diff --git a/py/lexerunix.h b/py/lexerunix.h deleted file mode 100644 index 12c3e8712b..0000000000 --- a/py/lexerunix.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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. - */ - -mp_lexer_t *mp_lexer_new_from_file(const char *filename); - -void mp_import_set_directory(const char *dir); diff --git a/py/malloc.c b/py/malloc.c index 451e480e8e..10e3566e8e 100644 --- a/py/malloc.c +++ b/py/malloc.c @@ -27,10 +27,9 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <stdint.h> -#include "mpconfig.h" -#include "misc.h" +#include "py/mpconfig.h" +#include "py/misc.h" #if 0 // print debugging info #define DEBUG_printf DEBUG_printf @@ -47,7 +46,7 @@ STATIC size_t peak_bytes_allocated = 0; #endif #if MICROPY_ENABLE_GC -#include "gc.h" +#include "py/gc.h" // We redirect standard alloc functions to GC heap - just for the rest of // this module. In the rest of micropython source, system malloc can be @@ -28,11 +28,9 @@ #include <stdlib.h> #include <assert.h> -#include "mpconfig.h" -#include "misc.h" -#include "qstr.h" -#include "obj.h" -#include "runtime0.h" +#include "py/mpconfig.h" +#include "py/misc.h" +#include "py/obj.h" // Fixed empty map. Useful when need to call kw-receiving functions // without any keywords from C, etc. diff --git a/py/modarray.c b/py/modarray.c index 360fe8a5f1..e251b06880 100644 --- a/py/modarray.c +++ b/py/modarray.c @@ -24,11 +24,7 @@ * THE SOFTWARE. */ -#include "mpconfig.h" -#include "misc.h" -#include "qstr.h" -#include "obj.h" -#include "builtin.h" +#include "py/builtin.h" #if MICROPY_PY_ARRAY diff --git a/py/modbuiltins.c b/py/modbuiltins.c index 7ac22fc49f..4a1446d233 100644 --- a/py/modbuiltins.c +++ b/py/modbuiltins.c @@ -27,18 +27,14 @@ #include <stdio.h> #include <assert.h> -#include "mpconfig.h" -#include "nlr.h" -#include "misc.h" -#include "qstr.h" -#include "obj.h" -#include "objstr.h" -#include "smallint.h" -#include "runtime0.h" -#include "runtime.h" -#include "builtin.h" -#include "stream.h" -#include "pfenv.h" +#include "py/nlr.h" +#include "py/smallint.h" +#include "py/objstr.h" +#include "py/runtime0.h" +#include "py/runtime.h" +#include "py/builtin.h" +#include "py/stream.h" +#include "py/pfenv.h" #if MICROPY_PY_BUILTINS_FLOAT #include <math.h> diff --git a/py/modcmath.c b/py/modcmath.c index 7514a8c029..59fa76ee68 100644 --- a/py/modcmath.c +++ b/py/modcmath.c @@ -24,16 +24,12 @@ * THE SOFTWARE. */ -#include <math.h> - -#include "mpconfig.h" -#include "misc.h" -#include "qstr.h" -#include "obj.h" -#include "builtin.h" +#include "py/builtin.h" #if MICROPY_PY_BUILTINS_FLOAT && MICROPY_PY_CMATH +#include <math.h> + /// \module cmath - mathematical functions for complex numbers /// /// The `cmath` module provides some basic mathematical funtions for diff --git a/py/modcollections.c b/py/modcollections.c index 8035b72d59..9fcbe879f2 100644 --- a/py/modcollections.c +++ b/py/modcollections.c @@ -24,11 +24,7 @@ * THE SOFTWARE. */ -#include "mpconfig.h" -#include "misc.h" -#include "qstr.h" -#include "obj.h" -#include "builtin.h" +#include "py/builtin.h" #if MICROPY_PY_COLLECTIONS diff --git a/py/modgc.c b/py/modgc.c index 8c9be70688..e3cbe72f9d 100644 --- a/py/modgc.c +++ b/py/modgc.c @@ -24,14 +24,8 @@ * THE SOFTWARE. */ -#include <stdint.h> - -#include "mpconfig.h" -#include "misc.h" -#include "qstr.h" -#include "obj.h" -#include "runtime.h" -#include "gc.h" +#include "py/obj.h" +#include "py/gc.h" #if MICROPY_PY_GC && MICROPY_ENABLE_GC diff --git a/py/modio.c b/py/modio.c index 6a273b39b7..30f766b407 100644 --- a/py/modio.c +++ b/py/modio.c @@ -24,11 +24,7 @@ * THE SOFTWARE. */ -#include "mpconfig.h" -#include "misc.h" -#include "qstr.h" -#include "obj.h" -#include "builtin.h" +#include "py/builtin.h" #if MICROPY_PY_IO diff --git a/py/modmath.c b/py/modmath.c index b922f3e490..38ed390ddf 100644 --- a/py/modmath.c +++ b/py/modmath.c @@ -24,16 +24,12 @@ * THE SOFTWARE. */ -#include <math.h> - -#include "mpconfig.h" -#include "misc.h" -#include "qstr.h" -#include "obj.h" -#include "builtin.h" +#include "py/builtin.h" #if MICROPY_PY_BUILTINS_FLOAT && MICROPY_PY_MATH +#include <math.h> + /// \module math - mathematical functions /// /// The `math` module provides some basic mathematical funtions for diff --git a/py/modmicropython.c b/py/modmicropython.c index 1701417579..035956ffcc 100644 --- a/py/modmicropython.c +++ b/py/modmicropython.c @@ -24,15 +24,11 @@ * THE SOFTWARE. */ -#include <stdint.h> #include <stdio.h> -#include "mpconfig.h" -#include "misc.h" -#include "qstr.h" -#include "obj.h" -#include "builtin.h" -#include "stackctrl.h" -#include "gc.h" + +#include "py/builtin.h" +#include "py/stackctrl.h" +#include "py/gc.h" // Various builtins specific to MicroPython runtime, // living in micropython module diff --git a/py/modstruct.c b/py/modstruct.c index f29c8c1f96..114135dfd1 100644 --- a/py/modstruct.c +++ b/py/modstruct.c @@ -27,15 +27,11 @@ #include <assert.h> #include <string.h> -#include "mpconfig.h" -#include "misc.h" -#include "qstr.h" -#include "obj.h" -#include "builtin.h" -#include "objtuple.h" -#include "objstr.h" -#include "binary.h" -#include "parsenum.h" + +#include "py/builtin.h" +#include "py/objtuple.h" +#include "py/binary.h" +#include "py/parsenum.h" #if MICROPY_PY_STRUCT diff --git a/py/modsys.c b/py/modsys.c index 06bd4c80e1..51bd6bfbb4 100644 --- a/py/modsys.c +++ b/py/modsys.c @@ -24,22 +24,14 @@ * THE SOFTWARE. */ -#include <stdint.h> - -#include "mpconfig.h" -#include "nlr.h" -#include "misc.h" -#include "qstr.h" -#include "obj.h" -#include "builtin.h" -#include "runtime.h" -#include "objlist.h" -#include "objtuple.h" -#include "objstr.h" -#include "mpz.h" -#include "objint.h" -#include "pfenv.h" -#include "stream.h" +#include "py/nlr.h" +#include "py/builtin.h" +#include "py/objlist.h" +#include "py/objtuple.h" +#include "py/objstr.h" +#include "py/objint.h" +#include "py/pfenv.h" +#include "py/stream.h" #if MICROPY_PY_SYS @@ -24,15 +24,10 @@ * THE SOFTWARE. */ -#include <stdint.h> -#include <stdbool.h> -#include <stdlib.h> #include <string.h> #include <assert.h> -#include "mpconfig.h" -#include "misc.h" -#include "mpz.h" +#include "py/mpz.h" #if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_MPZ @@ -23,6 +23,13 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ +#ifndef __MICROPY_INCLUDED_PY_MPZ_H__ +#define __MICROPY_INCLUDED_PY_MPZ_H__ + +#include <stdint.h> + +#include "py/mpconfig.h" +#include "py/misc.h" // This mpz module implements arbitrary precision integers. // @@ -131,3 +138,5 @@ mp_float_t mpz_as_float(const mpz_t *z); #endif mp_uint_t mpz_as_str_size(const mpz_t *i, mp_uint_t base, const char *prefix, char comma); mp_uint_t mpz_as_str_inpl(const mpz_t *z, mp_uint_t base, const char *prefix, char base_char, char comma, char *str); + +#endif // __MICROPY_INCLUDED_PY_MPZ_H__ diff --git a/py/nativeglue.c b/py/nativeglue.c index 05fadb7b0d..d52eeaeaa5 100644 --- a/py/nativeglue.c +++ b/py/nativeglue.c @@ -28,14 +28,10 @@ #include <string.h> #include <assert.h> -#include "mpconfig.h" -#include "nlr.h" -#include "misc.h" -#include "qstr.h" -#include "obj.h" -#include "runtime0.h" -#include "runtime.h" -#include "emitglue.h" +#include "py/nlr.h" +#include "py/runtime0.h" +#include "py/runtime.h" +#include "py/emitglue.h" #if MICROPY_EMIT_NATIVE @@ -23,6 +23,8 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ +#ifndef __MICROPY_INCLUDED_PY_NLR_H__ +#define __MICROPY_INCLUDED_PY_NLR_H__ // non-local return // exception handling, basically a stack of setjmp/longjmp buffers @@ -31,6 +33,8 @@ #include <setjmp.h> #include <assert.h> +#include "py/mpconfig.h" + typedef struct _nlr_buf_t nlr_buf_t; struct _nlr_buf_t { // the entries here must all be machine word size @@ -91,3 +95,5 @@ void nlr_jump_fail(void *val); nlr_jump(_val); \ } while (0) #endif + +#endif // __MICROPY_INCLUDED_PY_NLR_H__ diff --git a/py/nlrsetjmp.c b/py/nlrsetjmp.c index cb5acb757b..176138db04 100644 --- a/py/nlrsetjmp.c +++ b/py/nlrsetjmp.c @@ -24,10 +24,7 @@ * THE SOFTWARE. */ -#include <setjmp.h> -#include <stdio.h> -#include "mpconfig.h" -#include "nlr.h" +#include "py/nlr.h" #if MICROPY_NLR_SETJMP @@ -29,17 +29,13 @@ #include <stdarg.h> #include <assert.h> -#include "mpconfig.h" -#include "nlr.h" -#include "misc.h" -#include "qstr.h" -#include "obj.h" -#include "objtype.h" -#include "mpz.h" -#include "objint.h" -#include "runtime0.h" -#include "runtime.h" -#include "stackctrl.h" +#include "py/nlr.h" +#include "py/obj.h" +#include "py/objtype.h" +#include "py/objint.h" +#include "py/runtime0.h" +#include "py/runtime.h" +#include "py/stackctrl.h" mp_obj_type_t *mp_obj_get_type(mp_const_obj_t o_in) { if (MP_OBJ_IS_SMALL_INT(o_in)) { diff --git a/py/objarray.c b/py/objarray.c index cb8e03e451..19705afc02 100644 --- a/py/objarray.c +++ b/py/objarray.c @@ -29,14 +29,10 @@ #include <assert.h> #include <stdint.h> -#include "mpconfig.h" -#include "nlr.h" -#include "misc.h" -#include "qstr.h" -#include "obj.h" -#include "runtime0.h" -#include "runtime.h" -#include "binary.h" +#include "py/nlr.h" +#include "py/runtime0.h" +#include "py/runtime.h" +#include "py/binary.h" #if MICROPY_PY_ARRAY || MICROPY_PY_BUILTINS_BYTEARRAY || MICROPY_PY_BUILTINS_MEMORYVIEW diff --git a/py/objarray.h b/py/objarray.h deleted file mode 100644 index 730f67641b..0000000000 --- a/py/objarray.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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. - */ - -mp_obj_t mp_obj_new_bytearray(mp_uint_t n, void *items); diff --git a/py/objbool.c b/py/objbool.c index 47c91357ff..6dd9e7f9f8 100644 --- a/py/objbool.c +++ b/py/objbool.c @@ -26,13 +26,9 @@ #include <stdlib.h> -#include "mpconfig.h" -#include "nlr.h" -#include "misc.h" -#include "qstr.h" -#include "obj.h" -#include "runtime0.h" -#include "runtime.h" +#include "py/obj.h" +#include "py/runtime0.h" +#include "py/runtime.h" typedef struct _mp_obj_bool_t { mp_obj_base_t base; diff --git a/py/objboundmeth.c b/py/objboundmeth.c index 66af5df0a9..e451ce4c13 100644 --- a/py/objboundmeth.c +++ b/py/objboundmeth.c @@ -26,12 +26,8 @@ #include <string.h> -#include "mpconfig.h" -#include "nlr.h" -#include "misc.h" -#include "qstr.h" -#include "obj.h" -#include "runtime.h" +#include "py/obj.h" +#include "py/runtime.h" typedef struct _mp_obj_bound_meth_t { mp_obj_base_t base; diff --git a/py/objcell.c b/py/objcell.c index 29280e851b..b2d42001bc 100644 --- a/py/objcell.c +++ b/py/objcell.c @@ -24,12 +24,7 @@ * THE SOFTWARE. */ -#include "mpconfig.h" -#include "nlr.h" -#include "misc.h" -#include "qstr.h" -#include "obj.h" -#include "runtime.h" +#include "py/obj.h" typedef struct _mp_obj_cell_t { mp_obj_base_t base; diff --git a/py/objclosure.c b/py/objclosure.c index d563206b62..853f0930c0 100644 --- a/py/objclosure.c +++ b/py/objclosure.c @@ -26,13 +26,8 @@ #include <string.h> -#include "mpconfig.h" -#include "nlr.h" -#include "misc.h" -#include "qstr.h" -#include "obj.h" -#include "objtuple.h" -#include "runtime.h" +#include "py/obj.h" +#include "py/runtime.h" typedef struct _mp_obj_closure_t { mp_obj_base_t base; diff --git a/py/objcomplex.c b/py/objcomplex.c index 2768a01e65..9e158fac69 100644 --- a/py/objcomplex.c +++ b/py/objcomplex.c @@ -28,21 +28,18 @@ #include <stdio.h> #include <assert.h> -#include "mpconfig.h" -#include "nlr.h" -#include "misc.h" -#include "qstr.h" -#include "obj.h" -#include "parsenum.h" -#include "runtime0.h" -#include "runtime.h" +#include "py/nlr.h" +#include "py/obj.h" +#include "py/parsenum.h" +#include "py/runtime0.h" +#include "py/runtime.h" #if MICROPY_PY_BUILTINS_COMPLEX #include <math.h> #if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT -#include "formatfloat.h" +#include "py/formatfloat.h" #endif typedef struct _mp_obj_complex_t { @@ -58,12 +55,12 @@ STATIC void complex_print(void (*print)(void *env, const char *fmt, ...), void * #if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT char buf[16]; if (o->real == 0) { - format_float(o->imag, buf, sizeof(buf), 'g', 7, '\0'); + mp_format_float(o->imag, buf, sizeof(buf), 'g', 7, '\0'); print(env, "%sj", buf); } else { - format_float(o->real, buf, sizeof(buf), 'g', 7, '\0'); + mp_format_float(o->real, buf, sizeof(buf), 'g', 7, '\0'); print(env, "(%s+", buf); - format_float(o->imag, buf, sizeof(buf), 'g', 7, '\0'); + mp_format_float(o->imag, buf, sizeof(buf), 'g', 7, '\0'); print(env, "%sj)", buf); } #else diff --git a/py/objdict.c b/py/objdict.c index 2f4ae70830..63b3cfb329 100644 --- a/py/objdict.c +++ b/py/objdict.c @@ -24,19 +24,14 @@ * THE SOFTWARE. */ -#include <stdbool.h> #include <string.h> #include <assert.h> -#include "mpconfig.h" -#include "nlr.h" -#include "misc.h" -#include "qstr.h" -#include "obj.h" -#include "objtuple.h" -#include "runtime0.h" -#include "runtime.h" -#include "builtin.h" +#include "py/nlr.h" +#include "py/obj.h" +#include "py/runtime0.h" +#include "py/runtime.h" +#include "py/builtin.h" STATIC mp_obj_t dict_update(mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kwargs); diff --git a/py/objenumerate.c b/py/objenumerate.c index 0d96712df6..209af82312 100644 --- a/py/objenumerate.c +++ b/py/objenumerate.c @@ -27,11 +27,7 @@ #include <stdlib.h> #include <assert.h> -#include "mpconfig.h" -#include "misc.h" -#include "qstr.h" -#include "obj.h" -#include "runtime.h" +#include "py/runtime.h" typedef struct _mp_obj_enumerate_t { mp_obj_base_t base; diff --git a/py/objexcept.c b/py/objexcept.c index 4b8d6ea08b..a60cbb82ed 100644 --- a/py/objexcept.c +++ b/py/objexcept.c @@ -28,20 +28,13 @@ #include <stdarg.h> #include <assert.h> #include <stdio.h> -#include <stdint.h> - -#include "mpconfig.h" -#include "nlr.h" -#include "misc.h" -#include "qstr.h" -#include "obj.h" -#include "objlist.h" -#include "objstr.h" -#include "objtuple.h" -#include "objtype.h" -#include "runtime.h" -#include "runtime0.h" -#include "gc.h" + +#include "py/nlr.h" +#include "py/objlist.h" +#include "py/objstr.h" +#include "py/objtuple.h" +#include "py/objtype.h" +#include "py/gc.h" typedef struct _mp_obj_exception_t { mp_obj_base_t base; diff --git a/py/objfilter.c b/py/objfilter.c index 38af316740..98200f2608 100644 --- a/py/objfilter.c +++ b/py/objfilter.c @@ -24,15 +24,8 @@ * THE SOFTWARE. */ -#include <stdlib.h> -#include <assert.h> - -#include "mpconfig.h" -#include "nlr.h" -#include "misc.h" -#include "qstr.h" -#include "obj.h" -#include "runtime.h" +#include "py/nlr.h" +#include "py/runtime.h" typedef struct _mp_obj_filter_t { mp_obj_base_t base; diff --git a/py/objfloat.c b/py/objfloat.c index b75d0e4ba9..86b672007e 100644 --- a/py/objfloat.c +++ b/py/objfloat.c @@ -30,26 +30,22 @@ #include <assert.h> #include <math.h> -#include "mpconfig.h" -#include "nlr.h" -#include "misc.h" -#include "qstr.h" -#include "obj.h" -#include "parsenum.h" -#include "runtime0.h" -#include "runtime.h" +#include "py/nlr.h" +#include "py/parsenum.h" +#include "py/runtime0.h" +#include "py/runtime.h" #if MICROPY_PY_BUILTINS_FLOAT #if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT -#include "formatfloat.h" +#include "py/formatfloat.h" #endif STATIC void float_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t o_in, mp_print_kind_t kind) { mp_obj_float_t *o = o_in; #if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT char buf[16]; - format_float(o->value, buf, sizeof(buf), 'g', 7, '\0'); + mp_format_float(o->value, buf, sizeof(buf), 'g', 7, '\0'); print(env, "%s", buf); if (strchr(buf, '.') == NULL && strchr(buf, 'e') == NULL) { // Python floats always have decimal point diff --git a/py/objfun.c b/py/objfun.c index 5f95a015bc..b86d6f8dc6 100644 --- a/py/objfun.c +++ b/py/objfun.c @@ -25,21 +25,16 @@ * THE SOFTWARE. */ -#include <stdbool.h> #include <string.h> #include <assert.h> -#include "mpconfig.h" -#include "nlr.h" -#include "misc.h" -#include "qstr.h" -#include "obj.h" -#include "objtuple.h" -#include "objfun.h" -#include "runtime0.h" -#include "runtime.h" -#include "bc.h" -#include "stackctrl.h" +#include "py/nlr.h" +#include "py/objtuple.h" +#include "py/objfun.h" +#include "py/runtime0.h" +#include "py/runtime.h" +#include "py/bc.h" +#include "py/stackctrl.h" #if 0 // print debugging info #define DEBUG_PRINT (1) diff --git a/py/objfun.h b/py/objfun.h index e23fe8d529..a5b9f2b5fd 100644 --- a/py/objfun.h +++ b/py/objfun.h @@ -23,6 +23,10 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ +#ifndef __MICROPY_INCLUDED_PY_OBJFUN_H__ +#define __MICROPY_INCLUDED_PY_OBJFUN_H__ + +#include "py/obj.h" typedef struct _mp_obj_fun_bc_t { mp_obj_base_t base; @@ -41,3 +45,5 @@ typedef struct _mp_obj_fun_bc_t { // - a single slot for kw args dict (if it takes them) mp_obj_t extra_args[]; } mp_obj_fun_bc_t; + +#endif // __MICROPY_INCLUDED_PY_OBJFUN_H__ diff --git a/py/objgenerator.c b/py/objgenerator.c index 646ae4fdd4..1b06975c96 100644 --- a/py/objgenerator.c +++ b/py/objgenerator.c @@ -28,15 +28,12 @@ #include <stdlib.h> #include <assert.h> -#include "mpconfig.h" -#include "nlr.h" -#include "misc.h" -#include "qstr.h" -#include "obj.h" -#include "runtime.h" -#include "bc.h" -#include "objgenerator.h" -#include "objfun.h" +#include "py/nlr.h" +#include "py/obj.h" +#include "py/runtime.h" +#include "py/bc.h" +#include "py/objgenerator.h" +#include "py/objfun.h" /******************************************************************************/ /* generator wrapper */ diff --git a/py/objgenerator.h b/py/objgenerator.h index d0066de4e1..d1b9be4780 100644 --- a/py/objgenerator.h +++ b/py/objgenerator.h @@ -23,5 +23,12 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ +#ifndef __MICROPY_INCLUDED_PY_OBJGENERATOR_H__ +#define __MICROPY_INCLUDED_PY_OBJGENERATOR_H__ + +#include "py/obj.h" +#include "py/runtime.h" mp_vm_return_kind_t mp_obj_gen_resume(mp_obj_t self_in, mp_obj_t send_val, mp_obj_t throw_val, mp_obj_t *ret_val); + +#endif // __MICROPY_INCLUDED_PY_OBJGENERATOR_H__ diff --git a/py/objgetitemiter.c b/py/objgetitemiter.c index 75b9d1c568..2b0f7bb052 100644 --- a/py/objgetitemiter.c +++ b/py/objgetitemiter.c @@ -26,12 +26,8 @@ #include <stdlib.h> -#include "mpconfig.h" -#include "nlr.h" -#include "misc.h" -#include "qstr.h" -#include "obj.h" -#include "runtime.h" +#include "py/nlr.h" +#include "py/runtime.h" // this is a wrapper object that is turns something that has a __getitem__ method into an iterator diff --git a/py/objint.c b/py/objint.c index 0aa281edd1..c272fd4a74 100644 --- a/py/objint.c +++ b/py/objint.c @@ -25,22 +25,16 @@ */ #include <stdlib.h> -#include <stdint.h> #include <assert.h> #include <string.h> -#include "mpconfig.h" -#include "nlr.h" -#include "misc.h" -#include "qstr.h" -#include "obj.h" -#include "parsenum.h" -#include "smallint.h" -#include "mpz.h" -#include "objint.h" -#include "objstr.h" -#include "runtime0.h" -#include "runtime.h" +#include "py/nlr.h" +#include "py/parsenum.h" +#include "py/smallint.h" +#include "py/objint.h" +#include "py/objstr.h" +#include "py/runtime0.h" +#include "py/runtime.h" #if MICROPY_PY_BUILTINS_FLOAT #include <math.h> diff --git a/py/objint.h b/py/objint.h index 70d182ba7d..fff325df84 100644 --- a/py/objint.h +++ b/py/objint.h @@ -23,6 +23,11 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ +#ifndef __MICROPY_INCLUDED_PY_OBJINT_H__ +#define __MICROPY_INCLUDED_PY_OBJINT_H__ + +#include "py/mpz.h" +#include "py/obj.h" typedef struct _mp_obj_int_t { mp_obj_base_t base; @@ -45,3 +50,5 @@ bool mp_obj_int_is_positive(mp_obj_t self_in); mp_obj_t mp_obj_int_unary_op(mp_uint_t op, mp_obj_t o_in); mp_obj_t mp_obj_int_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); mp_obj_t mp_obj_int_binary_op_extra_cases(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); + +#endif // __MICROPY_INCLUDED_PY_OBJINT_H__ diff --git a/py/objint_longlong.c b/py/objint_longlong.c index 5f48b71340..394ae111ad 100644 --- a/py/objint_longlong.c +++ b/py/objint_longlong.c @@ -26,19 +26,13 @@ */ #include <stdlib.h> -#include <stdint.h> #include <string.h> -#include "mpconfig.h" -#include "nlr.h" -#include "misc.h" -#include "qstr.h" -#include "obj.h" -#include "smallint.h" -#include "mpz.h" -#include "objint.h" -#include "runtime0.h" -#include "runtime.h" +#include "py/nlr.h" +#include "py/smallint.h" +#include "py/objint.h" +#include "py/runtime0.h" +#include "py/runtime.h" #if MICROPY_PY_BUILTINS_FLOAT #include <math.h> diff --git a/py/objint_mpz.c b/py/objint_mpz.c index 1dc1def33d..554ec96579 100644 --- a/py/objint_mpz.c +++ b/py/objint_mpz.c @@ -24,22 +24,16 @@ * THE SOFTWARE. */ -#include <stdint.h> #include <string.h> #include <stdio.h> #include <assert.h> -#include "mpconfig.h" -#include "nlr.h" -#include "misc.h" -#include "qstr.h" -#include "parsenumbase.h" -#include "obj.h" -#include "smallint.h" -#include "mpz.h" -#include "objint.h" -#include "runtime0.h" -#include "runtime.h" +#include "py/nlr.h" +#include "py/parsenumbase.h" +#include "py/smallint.h" +#include "py/objint.h" +#include "py/runtime0.h" +#include "py/runtime.h" #if MICROPY_PY_BUILTINS_FLOAT #include <math.h> diff --git a/py/objlist.c b/py/objlist.c index 3e5355719e..911ddb98ab 100644 --- a/py/objlist.c +++ b/py/objlist.c @@ -27,14 +27,10 @@ #include <string.h> #include <assert.h> -#include "mpconfig.h" -#include "nlr.h" -#include "misc.h" -#include "qstr.h" -#include "obj.h" -#include "runtime0.h" -#include "runtime.h" -#include "objlist.h" +#include "py/nlr.h" +#include "py/objlist.h" +#include "py/runtime0.h" +#include "py/runtime.h" STATIC mp_obj_t mp_obj_new_list_iterator(mp_obj_list_t *list, mp_uint_t cur); STATIC mp_obj_list_t *list_new(mp_uint_t n); diff --git a/py/objlist.h b/py/objlist.h index 05a4c8d3ab..443ede5743 100644 --- a/py/objlist.h +++ b/py/objlist.h @@ -23,6 +23,10 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ +#ifndef __MICROPY_INCLUDED_PY_OBJLIST_H__ +#define __MICROPY_INCLUDED_PY_OBJLIST_H__ + +#include "py/obj.h" typedef struct _mp_obj_list_t { mp_obj_base_t base; @@ -30,3 +34,5 @@ typedef struct _mp_obj_list_t { mp_uint_t len; mp_obj_t *items; } mp_obj_list_t; + +#endif // __MICROPY_INCLUDED_PY_OBJLIST_H__ diff --git a/py/objmap.c b/py/objmap.c index f7d7b01c3a..ea62bb512f 100644 --- a/py/objmap.c +++ b/py/objmap.c @@ -27,12 +27,8 @@ #include <stdlib.h> #include <assert.h> -#include "mpconfig.h" -#include "nlr.h" -#include "misc.h" -#include "qstr.h" -#include "obj.h" -#include "runtime.h" +#include "py/nlr.h" +#include "py/runtime.h" typedef struct _mp_obj_map_t { mp_obj_base_t base; diff --git a/py/objmodule.c b/py/objmodule.c index 5ffb368bf5..2e53bf0521 100644 --- a/py/objmodule.c +++ b/py/objmodule.c @@ -27,14 +27,10 @@ #include <stdlib.h> #include <assert.h> -#include "mpconfig.h" -#include "nlr.h" -#include "misc.h" -#include "qstr.h" -#include "obj.h" -#include "objmodule.h" -#include "runtime.h" -#include "builtin.h" +#include "py/nlr.h" +#include "py/objmodule.h" +#include "py/runtime.h" +#include "py/builtin.h" STATIC mp_map_t mp_loaded_modules_map; // TODO: expose as sys.modules diff --git a/py/objmodule.h b/py/objmodule.h index f4ccedee57..138f942c21 100644 --- a/py/objmodule.h +++ b/py/objmodule.h @@ -23,8 +23,14 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ +#ifndef __MICROPY_INCLUDED_PY_OBJMODULE_H__ +#define __MICROPY_INCLUDED_PY_OBJMODULE_H__ + +#include "py/obj.h" 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); + +#endif // __MICROPY_INCLUDED_PY_OBJMODULE_H__ diff --git a/py/objnamedtuple.c b/py/objnamedtuple.c index c0510081c3..320467eed5 100644 --- a/py/objnamedtuple.c +++ b/py/objnamedtuple.c @@ -27,13 +27,9 @@ #include <string.h> -#include "mpconfig.h" -#include "misc.h" -#include "nlr.h" -#include "qstr.h" -#include "obj.h" -#include "objtuple.h" -#include "runtime.h" +#include "py/nlr.h" +#include "py/objtuple.h" +#include "py/runtime.h" #if MICROPY_PY_COLLECTIONS diff --git a/py/objnone.c b/py/objnone.c index 01536dcb34..387fb58cb6 100644 --- a/py/objnone.c +++ b/py/objnone.c @@ -26,12 +26,9 @@ #include <stdlib.h> -#include "mpconfig.h" -#include "nlr.h" -#include "misc.h" -#include "qstr.h" -#include "obj.h" -#include "runtime0.h" +#include "py/nlr.h" +#include "py/obj.h" +#include "py/runtime0.h" typedef struct _mp_obj_none_t { mp_obj_base_t base; diff --git a/py/objobject.c b/py/objobject.c index 551ccf76ea..5bbe02b328 100644 --- a/py/objobject.c +++ b/py/objobject.c @@ -26,12 +26,9 @@ #include <stdlib.h> -#include "mpconfig.h" -#include "nlr.h" -#include "misc.h" -#include "qstr.h" -#include "obj.h" -#include "runtime0.h" +#include "py/nlr.h" +#include "py/obj.h" +#include "py/runtime0.h" mp_obj_t instance_make_new(mp_obj_t self_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args); diff --git a/py/objproperty.c b/py/objproperty.c index c83ca2dbb0..75cc1458ea 100644 --- a/py/objproperty.c +++ b/py/objproperty.c @@ -27,12 +27,8 @@ #include <stdlib.h> #include <assert.h> -#include "mpconfig.h" -#include "nlr.h" -#include "misc.h" -#include "qstr.h" -#include "obj.h" -#include "runtime.h" +#include "py/nlr.h" +#include "py/runtime.h" #if MICROPY_PY_BUILTINS_PROPERTY diff --git a/py/objrange.c b/py/objrange.c index 702413f2a9..2a8388b172 100644 --- a/py/objrange.c +++ b/py/objrange.c @@ -26,13 +26,9 @@ #include <stdlib.h> -#include "mpconfig.h" -#include "nlr.h" -#include "misc.h" -#include "qstr.h" -#include "obj.h" -#include "runtime0.h" -#include "runtime.h" +#include "py/nlr.h" +#include "py/runtime0.h" +#include "py/runtime.h" /******************************************************************************/ /* range iterator */ diff --git a/py/objreversed.c b/py/objreversed.c index aa73f37710..b614958611 100644 --- a/py/objreversed.c +++ b/py/objreversed.c @@ -27,12 +27,8 @@ #include <stdlib.h> #include <assert.h> -#include "mpconfig.h" -#include "nlr.h" -#include "misc.h" -#include "qstr.h" -#include "obj.h" -#include "runtime.h" +#include "py/nlr.h" +#include "py/runtime.h" typedef struct _mp_obj_reversed_t { mp_obj_base_t base; diff --git a/py/objset.c b/py/objset.c index 1069cd5eac..54009a1f53 100644 --- a/py/objset.c +++ b/py/objset.c @@ -28,14 +28,10 @@ #include <string.h> #include <assert.h> -#include "mpconfig.h" -#include "nlr.h" -#include "misc.h" -#include "qstr.h" -#include "obj.h" -#include "runtime.h" -#include "runtime0.h" -#include "builtin.h" +#include "py/nlr.h" +#include "py/runtime.h" +#include "py/runtime0.h" +#include "py/builtin.h" #if MICROPY_PY_BUILTINS_SET diff --git a/py/objslice.c b/py/objslice.c index c99b9d08db..3f090dc237 100644 --- a/py/objslice.c +++ b/py/objslice.c @@ -27,12 +27,9 @@ #include <stdlib.h> #include <assert.h> -#include "mpconfig.h" -#include "nlr.h" -#include "misc.h" -#include "qstr.h" -#include "obj.h" -#include "runtime0.h" +#include "py/nlr.h" +#include "py/obj.h" +#include "py/runtime0.h" /******************************************************************************/ /* ellipsis object, a singleton */ diff --git a/py/objstr.c b/py/objstr.c index 3d9fd6f5e8..5976e36e71 100644 --- a/py/objstr.c +++ b/py/objstr.c @@ -25,21 +25,16 @@ * THE SOFTWARE. */ -#include <stdbool.h> #include <string.h> #include <assert.h> -#include "mpconfig.h" -#include "nlr.h" -#include "misc.h" -#include "unicode.h" -#include "qstr.h" -#include "obj.h" -#include "runtime0.h" -#include "runtime.h" -#include "pfenv.h" -#include "objstr.h" -#include "objlist.h" +#include "py/nlr.h" +#include "py/unicode.h" +#include "py/objstr.h" +#include "py/objlist.h" +#include "py/runtime0.h" +#include "py/runtime.h" +#include "py/pfenv.h" STATIC mp_obj_t str_modulo_format(mp_obj_t pattern, mp_uint_t n_args, const mp_obj_t *args, mp_obj_t dict); diff --git a/py/objstr.h b/py/objstr.h index 9bc0600852..8894c267e3 100644 --- a/py/objstr.h +++ b/py/objstr.h @@ -23,6 +23,10 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ +#ifndef __MICROPY_INCLUDED_PY_OBJSTR_H__ +#define __MICROPY_INCLUDED_PY_OBJSTR_H__ + +#include "py/obj.h" typedef struct _mp_obj_str_t { mp_obj_base_t base; @@ -85,3 +89,5 @@ MP_DECLARE_CONST_FUN_OBJ(str_isalpha_obj); MP_DECLARE_CONST_FUN_OBJ(str_isdigit_obj); MP_DECLARE_CONST_FUN_OBJ(str_isupper_obj); MP_DECLARE_CONST_FUN_OBJ(str_islower_obj); + +#endif // __MICROPY_INCLUDED_PY_OBJSTR_H__ diff --git a/py/objstringio.c b/py/objstringio.c index e5abc0526f..eca8522eef 100644 --- a/py/objstringio.c +++ b/py/objstringio.c @@ -28,14 +28,10 @@ #include <stdio.h> #include <string.h> -#include "mpconfig.h" -#include "nlr.h" -#include "misc.h" -#include "qstr.h" -#include "obj.h" -#include "runtime.h" -#include "stream.h" -#include "objstr.h" +#include "py/nlr.h" +#include "py/objstr.h" +#include "py/runtime.h" +#include "py/stream.h" #if MICROPY_PY_IO diff --git a/py/objstrunicode.c b/py/objstrunicode.c index 2c8d02491f..fd3678722c 100644 --- a/py/objstrunicode.c +++ b/py/objstrunicode.c @@ -25,20 +25,15 @@ * THE SOFTWARE. */ -#include <stdbool.h> #include <string.h> #include <assert.h> -#include "mpconfig.h" -#include "nlr.h" -#include "misc.h" -#include "qstr.h" -#include "obj.h" -#include "runtime0.h" -#include "runtime.h" -#include "pfenv.h" -#include "objstr.h" -#include "objlist.h" +#include "py/nlr.h" +#include "py/objstr.h" +#include "py/objlist.h" +#include "py/runtime0.h" +#include "py/runtime.h" +#include "py/pfenv.h" #if MICROPY_PY_BUILTINS_STR_UNICODE diff --git a/py/objtuple.c b/py/objtuple.c index 2793e4838d..1f2eeb380d 100644 --- a/py/objtuple.c +++ b/py/objtuple.c @@ -27,14 +27,10 @@ #include <string.h> #include <assert.h> -#include "mpconfig.h" -#include "nlr.h" -#include "misc.h" -#include "qstr.h" -#include "obj.h" -#include "runtime0.h" -#include "runtime.h" -#include "objtuple.h" +#include "py/nlr.h" +#include "py/objtuple.h" +#include "py/runtime0.h" +#include "py/runtime.h" STATIC mp_obj_t mp_obj_new_tuple_iterator(mp_obj_tuple_t *tuple, mp_uint_t cur); diff --git a/py/objtuple.h b/py/objtuple.h index 43b3826bf5..4cac487557 100644 --- a/py/objtuple.h +++ b/py/objtuple.h @@ -23,6 +23,10 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ +#ifndef __MICROPY_INCLUDED_PY_OBJTUPLE_H__ +#define __MICROPY_INCLUDED_PY_OBJTUPLE_H__ + +#include "py/obj.h" typedef struct _mp_obj_tuple_t { mp_obj_base_t base; @@ -35,3 +39,5 @@ mp_obj_t mp_obj_tuple_unary_op(mp_uint_t op, mp_obj_t self_in); mp_obj_t mp_obj_tuple_binary_op(mp_uint_t op, mp_obj_t lhs, mp_obj_t rhs); mp_obj_t mp_obj_tuple_subscr(mp_obj_t base, mp_obj_t index, mp_obj_t value); mp_obj_t mp_obj_tuple_getiter(mp_obj_t o_in); + +#endif // __MICROPY_INCLUDED_PY_OBJTUPLE_H__ diff --git a/py/objtype.c b/py/objtype.c index 2970e92767..b5890c4726 100644 --- a/py/objtype.c +++ b/py/objtype.c @@ -30,14 +30,10 @@ #include <string.h> #include <assert.h> -#include "mpconfig.h" -#include "nlr.h" -#include "misc.h" -#include "qstr.h" -#include "obj.h" -#include "runtime0.h" -#include "runtime.h" -#include "objtype.h" +#include "py/nlr.h" +#include "py/objtype.h" +#include "py/runtime0.h" +#include "py/runtime.h" #if 0 // print debugging info #define DEBUG_PRINT (1) diff --git a/py/objtype.h b/py/objtype.h index dd2e44a799..8adbbc33b5 100644 --- a/py/objtype.h +++ b/py/objtype.h @@ -23,6 +23,10 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ +#ifndef __MICROPY_INCLUDED_PY_OBJTYPE_H__ +#define __MICROPY_INCLUDED_PY_OBJTYPE_H__ + +#include "py/obj.h" // instance object // creating an instance of a class makes one of these objects @@ -36,3 +40,5 @@ typedef struct _mp_obj_instance_t { // these need to be exposed so mp_obj_is_callable can work correctly bool mp_obj_instance_is_callable(mp_obj_t self_in); mp_obj_t mp_obj_instance_call(mp_obj_t self_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args); + +#endif // __MICROPY_INCLUDED_PY_OBJTYPE_H__ diff --git a/py/objzip.c b/py/objzip.c index 738131f920..e1bf92737a 100644 --- a/py/objzip.c +++ b/py/objzip.c @@ -27,12 +27,8 @@ #include <stdlib.h> #include <assert.h> -#include "mpconfig.h" -#include "misc.h" -#include "qstr.h" -#include "obj.h" -#include "objtuple.h" -#include "runtime.h" +#include "py/objtuple.h" +#include "py/runtime.h" typedef struct _mp_obj_zip_t { mp_obj_base_t base; diff --git a/py/opmethods.c b/py/opmethods.c index ea930c28a3..80a953fb89 100644 --- a/py/opmethods.c +++ b/py/opmethods.c @@ -24,14 +24,8 @@ * THE SOFTWARE. */ -#include "mpconfig.h" -#include "nlr.h" -#include "misc.h" -#include "qstr.h" -#include "obj.h" -#include "runtime.h" -#include "runtime0.h" -#include "builtin.h" +#include "py/runtime0.h" +#include "py/builtin.h" STATIC mp_obj_t op_getitem(mp_obj_t self_in, mp_obj_t key_in) { mp_obj_type_t *type = mp_obj_get_type(self_in); diff --git a/py/parse.c b/py/parse.c index ae1fe65e75..c7c85e0357 100644 --- a/py/parse.c +++ b/py/parse.c @@ -30,13 +30,10 @@ #include <assert.h> #include <string.h> -#include "mpconfig.h" -#include "misc.h" -#include "qstr.h" -#include "lexer.h" -#include "parsenumbase.h" -#include "parse.h" -#include "smallint.h" +#include "py/lexer.h" +#include "py/parse.h" +#include "py/parsenum.h" +#include "py/smallint.h" #define RULE_ACT_ARG_MASK (0x0f) #define RULE_ACT_KIND_MASK (0x30) @@ -69,7 +66,7 @@ typedef struct _rule_t { enum { #define DEF_RULE(rule, comp, kind, ...) RULE_##rule, -#include "grammar.h" +#include "py/grammar.h" #undef DEF_RULE RULE_maximum_number_of, RULE_string, // special node for non-interned string @@ -91,7 +88,7 @@ enum { #else #define DEF_RULE(rule, comp, kind, ...) static const rule_t rule_##rule = { RULE_##rule, kind, { __VA_ARGS__ } }; #endif -#include "grammar.h" +#include "py/grammar.h" #undef or #undef and #undef list @@ -105,7 +102,7 @@ enum { STATIC const rule_t *rules[] = { #define DEF_RULE(rule, comp, kind, ...) &rule_##rule, -#include "grammar.h" +#include "py/grammar.h" #undef DEF_RULE }; diff --git a/py/parse.h b/py/parse.h index 4006223181..4e7f2b9d19 100644 --- a/py/parse.h +++ b/py/parse.h @@ -26,6 +26,10 @@ #ifndef __MICROPY_INCLUDED_PY_PARSE_H__ #define __MICROPY_INCLUDED_PY_PARSE_H__ +#include <stdint.h> + +#include "py/mpconfig.h" + struct _mp_lexer_t; // a mp_parse_node_t is: diff --git a/py/parsehelper.c b/py/parsehelper.c index f304710673..904268109b 100644 --- a/py/parsehelper.c +++ b/py/parsehelper.c @@ -26,16 +26,9 @@ // these functions are separate from parse.c to keep parser independent of mp_obj_t -#include <stdint.h> #include <stdio.h> -#include "mpconfig.h" -#include "misc.h" -#include "qstr.h" -#include "lexer.h" -#include "parse.h" -#include "obj.h" -#include "parsehelper.h" +#include "py/parsehelper.h" #define STR_MEMORY "parser could not allocate enough memory" #define STR_UNEXPECTED_INDENT "unexpected indent" diff --git a/py/parsehelper.h b/py/parsehelper.h index 4a95f22fa2..1763809bad 100644 --- a/py/parsehelper.h +++ b/py/parsehelper.h @@ -28,6 +28,7 @@ #include "py/lexer.h" #include "py/parse.h" +#include "py/obj.h" void mp_parse_show_exception(mp_lexer_t *lex, mp_parse_error_kind_t parse_error_kind); mp_obj_t mp_parse_make_exception(mp_lexer_t *lex, mp_parse_error_kind_t parse_error_kind); diff --git a/py/parsenum.c b/py/parsenum.c index bb88eb729b..4706fef819 100644 --- a/py/parsenum.c +++ b/py/parsenum.c @@ -27,15 +27,9 @@ #include <stdbool.h> #include <stdlib.h> -#include "mpconfig.h" -#include "misc.h" -#include "qstr.h" -#include "nlr.h" -#include "obj.h" -#include "parsenumbase.h" -#include "parsenum.h" -#include "smallint.h" -#include "runtime.h" +#include "py/nlr.h" +#include "py/parsenum.h" +#include "py/smallint.h" #if MICROPY_PY_BUILTINS_FLOAT #include <math.h> diff --git a/py/parsenum.h b/py/parsenum.h index 5164d50016..a769bdd835 100644 --- a/py/parsenum.h +++ b/py/parsenum.h @@ -23,6 +23,14 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ +#ifndef __MICROPY_INCLUDED_PY_PARSENUM_H__ +#define __MICROPY_INCLUDED_PY_PARSENUM_H__ +#include "py/mpconfig.h" +#include "py/obj.h" + +mp_uint_t mp_parse_num_base(const char *str, mp_uint_t len, mp_uint_t *base); mp_obj_t mp_parse_num_integer(const char *restrict str, mp_uint_t len, mp_uint_t base); mp_obj_t mp_parse_num_decimal(const char *str, mp_uint_t len, bool allow_imag, bool force_complex); + +#endif // __MICROPY_INCLUDED_PY_PARSENUM_H__ diff --git a/py/parsenumbase.c b/py/parsenumbase.c index f552c5e378..5574b3b9b5 100644 --- a/py/parsenumbase.c +++ b/py/parsenumbase.c @@ -24,9 +24,7 @@ * THE SOFTWARE. */ -#include "mpconfig.h" -#include "misc.h" -#include "parsenumbase.h" +#include "py/parsenum.h" // find real radix base, and strip preceding '0x', '0o' and '0b' // puts base in *base, and returns number of bytes to skip the prefix diff --git a/py/parsenumbase.h b/py/parsenumbase.h index 177f14451d..f8953ec835 100644 --- a/py/parsenumbase.h +++ b/py/parsenumbase.h @@ -23,5 +23,11 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ +#ifndef __MICROPY_INCLUDED_PY_PARSENUM_H__ +#define __MICROPY_INCLUDED_PY_PARSENUM_H__ + +#include "py/mpconfig.h" mp_uint_t mp_parse_num_base(const char *str, mp_uint_t len, mp_uint_t *base); + +#endif // __MICROPY_INCLUDED_PY_PARSENUM_H__ diff --git a/py/pfenv.c b/py/pfenv.c index 965636aea0..698f3b16cb 100644 --- a/py/pfenv.c +++ b/py/pfenv.c @@ -27,20 +27,15 @@ #include <stdint.h> #include <string.h> -#include "mpconfig.h" -#include "misc.h" -#include "qstr.h" -#include "obj.h" -#include "mpz.h" -#include "objint.h" -#include "pfenv.h" +#include "py/objint.h" +#include "py/pfenv.h" #if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_DOUBLE #include <stdio.h> #endif #if MICROPY_PY_BUILTINS_FLOAT -#include "formatfloat.h" +#include "py/formatfloat.h" #endif static const char pad_spaces[] = " "; @@ -331,7 +326,7 @@ int pfenv_print_float(const pfenv_t *pfenv, mp_float_t f, char fmt, int flags, c } int len; #if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT - len = format_float(f, buf, sizeof(buf), fmt, prec, sign); + len = mp_format_float(f, buf, sizeof(buf), fmt, prec, sign); #elif MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_DOUBLE char fmt_buf[6]; char *fmt_s = fmt_buf; diff --git a/py/pfenv.h b/py/pfenv.h index 98c1885f35..074c0012f8 100644 --- a/py/pfenv.h +++ b/py/pfenv.h @@ -23,6 +23,10 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ +#ifndef __MICROPY_INCLUDED_PY_PFENV_H__ +#define __MICROPY_INCLUDED_PY_PFENV_H__ + +#include "py/obj.h" #define PF_FLAG_LEFT_ADJUST (0x001) #define PF_FLAG_SHOW_SIGN (0x002) @@ -55,3 +59,5 @@ int pfenv_printf(const pfenv_t *pfenv, const char *fmt, ...); // Wrapper for system printf void printf_wrapper(void *env, const char *fmt, ...); + +#endif // __MICROPY_INCLUDED_PY_PFENV_H__ diff --git a/py/pfenv_printf.c b/py/pfenv_printf.c index c0e826a5d2..39bf321ce3 100644 --- a/py/pfenv_printf.c +++ b/py/pfenv_printf.c @@ -25,19 +25,13 @@ */ #include <assert.h> -#include <stdio.h> -#include <stdint.h> #include <string.h> #include <stdarg.h> -#include "mpconfig.h" -#include "misc.h" -#include "qstr.h" -#include "obj.h" -#include "pfenv.h" +#include "py/pfenv.h" #if MICROPY_PY_BUILTINS_FLOAT -#include "formatfloat.h" +#include "py/formatfloat.h" #endif int pfenv_vprintf(const pfenv_t *pfenv, const char *fmt, va_list args) { @@ -26,12 +26,9 @@ #include <assert.h> #include <string.h> -#include <stdint.h> -#include "mpconfig.h" -#include "misc.h" -#include "qstr.h" -#include "gc.h" +#include "py/qstr.h" +#include "py/gc.h" // 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 diff --git a/py/qstrdefs.h b/py/qstrdefs.h index e91d360703..b8eacc68c7 100644 --- a/py/qstrdefs.h +++ b/py/qstrdefs.h @@ -24,7 +24,8 @@ * THE SOFTWARE. */ -#include "mpconfig.h" +#include "py/mpconfig.h" + // All the qstr definitions in this file are available as constants. // That is, they are in ROM and you can reference them simply as MP_QSTR_xxxx. @@ -24,9 +24,7 @@ * THE SOFTWARE. */ -#include "mpconfig.h" -#include "misc.h" -#include "repl.h" +#include "py/repl.h" #if MICROPY_HELPER_REPL @@ -23,7 +23,14 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ +#ifndef __MICROPY_INCLUDED_PY_REPL_H__ +#define __MICROPY_INCLUDED_PY_REPL_H__ + +#include "py/mpconfig.h" +#include "py/misc.h" #if MICROPY_HELPER_REPL bool mp_repl_continue_with_input(const char *input); #endif + +#endif // __MICROPY_INCLUDED_PY_REPL_H__ diff --git a/py/runtime.c b/py/runtime.c index 505c8e31af..c4c73dfe41 100644 --- a/py/runtime.c +++ b/py/runtime.c @@ -24,33 +24,24 @@ * THE SOFTWARE. */ -#include <stdint.h> #include <stdio.h> #include <string.h> #include <assert.h> -#include "mpconfig.h" -#include "nlr.h" -#include "misc.h" -#include "qstr.h" -#include "obj.h" -#include "objtuple.h" -#include "objlist.h" -#include "objmodule.h" -#include "parsenum.h" -#include "runtime0.h" -#include "runtime.h" -#include "emitglue.h" -#include "builtin.h" -#include "bc.h" -#include "smallint.h" -#include "objgenerator.h" -#include "lexer.h" -#include "parse.h" -#include "parsehelper.h" -#include "compile.h" -#include "stackctrl.h" -#include "gc.h" +#include "py/nlr.h" +#include "py/parsehelper.h" +#include "py/parsenum.h" +#include "py/compile.h" +#include "py/objtuple.h" +#include "py/objlist.h" +#include "py/objmodule.h" +#include "py/objgenerator.h" +#include "py/smallint.h" +#include "py/runtime0.h" +#include "py/runtime.h" +#include "py/builtin.h" +#include "py/stackctrl.h" +#include "py/gc.h" #if 0 // print debugging info #define DEBUG_PRINT (1) diff --git a/py/scope.c b/py/scope.c index 05606ffcce..4739ac3236 100644 --- a/py/scope.c +++ b/py/scope.c @@ -24,17 +24,9 @@ * THE SOFTWARE. */ -#include <stdbool.h> -#include <stdint.h> #include <assert.h> -#include "mpconfig.h" -#include "misc.h" -#include "qstr.h" -#include "obj.h" -#include "parse.h" -#include "emitglue.h" -#include "scope.h" +#include "py/scope.h" scope_t *scope_new(scope_kind_t kind, mp_parse_node_t pn, qstr source_file, mp_uint_t emit_options) { scope_t *scope = m_new0(scope_t, 1); diff --git a/py/scope.h b/py/scope.h index 903a32a79a..6d74b17d28 100644 --- a/py/scope.h +++ b/py/scope.h @@ -23,6 +23,11 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ +#ifndef __MICROPY_INCLUDED_PY_SCOPE_H__ +#define __MICROPY_INCLUDED_PY_SCOPE_H__ + +#include "py/parse.h" +#include "py/emitglue.h" enum { ID_INFO_KIND_GLOBAL_IMPLICIT, @@ -77,3 +82,5 @@ id_info_t *scope_find_global(scope_t *scope, qstr qstr); id_info_t *scope_find_local_in_parent(scope_t *scope, qstr qstr); void scope_close_over_in_parents(scope_t *scope, qstr qstr); void scope_print_info(scope_t *s); + +#endif // __MICROPY_INCLUDED_PY_SCOPE_H__ diff --git a/py/sequence.c b/py/sequence.c index 8cc7519be8..0e76ccc027 100644 --- a/py/sequence.c +++ b/py/sequence.c @@ -25,17 +25,12 @@ * THE SOFTWARE. */ -#include <assert.h> -#include <stdbool.h> #include <string.h> -#include "mpconfig.h" -#include "nlr.h" -#include "misc.h" -#include "qstr.h" -#include "obj.h" -#include "runtime0.h" -#include "runtime.h" +#include "py/nlr.h" +#include "py/obj.h" +#include "py/runtime0.h" +#include "py/runtime.h" // Helpers for sequence types diff --git a/py/showbc.c b/py/showbc.c index 4a765499cf..e2151c5a5c 100644 --- a/py/showbc.c +++ b/py/showbc.c @@ -27,13 +27,9 @@ #include <stdio.h> #include <assert.h> -#include "mpconfig.h" -#include "misc.h" -#include "qstr.h" -#include "obj.h" -#include "runtime.h" -#include "bc0.h" -#include "bc.h" +#include "py/bc0.h" +#include "py/bc.h" + extern const qstr mp_binary_op_method_name[]; #if MICROPY_DEBUG_PRINTERS diff --git a/py/smallint.c b/py/smallint.c index 3a06c40a9f..4c42ee0cc9 100644 --- a/py/smallint.c +++ b/py/smallint.c @@ -24,11 +24,7 @@ * THE SOFTWARE. */ -#include "mpconfig.h" -#include "misc.h" -#include "qstr.h" -#include "obj.h" -#include "smallint.h" +#include "py/smallint.h" bool mp_small_int_mul_overflow(mp_int_t x, mp_int_t y) { // Check for multiply overflow; see CERT INT32-C diff --git a/py/smallint.h b/py/smallint.h index 26a12874ef..980be42f3d 100644 --- a/py/smallint.h +++ b/py/smallint.h @@ -23,6 +23,11 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ +#ifndef __MICROPY_INCLUDED_PY_SMALLINT_H__ +#define __MICROPY_INCLUDED_PY_SMALLINT_H__ + +#include "py/mpconfig.h" +#include "py/misc.h" // Functions for small integer arithmetic @@ -34,3 +39,5 @@ bool mp_small_int_mul_overflow(mp_int_t x, mp_int_t y); mp_int_t mp_small_int_modulo(mp_int_t dividend, mp_int_t divisor); mp_int_t mp_small_int_floor_divide(mp_int_t num, mp_int_t denom); + +#endif // __MICROPY_INCLUDED_PY_SMALLINT_H__ diff --git a/py/stackctrl.c b/py/stackctrl.c index 0ba43c28c7..31336ec699 100644 --- a/py/stackctrl.c +++ b/py/stackctrl.c @@ -24,13 +24,9 @@ * THE SOFTWARE. */ -#include "mpconfig.h" -#include "misc.h" -#include "nlr.h" -#include "qstr.h" -#include "obj.h" -#include "runtime.h" -#include "stackctrl.h" +#include "py/nlr.h" +#include "py/obj.h" +#include "py/stackctrl.h" // Stack top at the start of program char *stack_top; diff --git a/py/stackctrl.h b/py/stackctrl.h index 4ed67774f8..bd18f21426 100644 --- a/py/stackctrl.h +++ b/py/stackctrl.h @@ -23,6 +23,10 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ +#ifndef __MICROPY_INCLUDED_PY_STACKCTRL_H__ +#define __MICROPY_INCLUDED_PY_STACKCTRL_H__ + +#include "py/mpconfig.h" void mp_stack_ctrl_init(void); mp_uint_t mp_stack_usage(void); @@ -39,3 +43,5 @@ void mp_stack_check(void); #define MP_STACK_CHECK() #endif + +#endif // __MICROPY_INCLUDED_PY_STACKCTRL_H__ diff --git a/py/stream.c b/py/stream.c index db7e5657fd..c57b7981aa 100644 --- a/py/stream.c +++ b/py/stream.c @@ -27,14 +27,10 @@ #include <string.h> -#include "mpconfig.h" -#include "nlr.h" -#include "misc.h" -#include "qstr.h" -#include "obj.h" -#include "objstr.h" -#include "runtime.h" -#include "stream.h" +#include "py/nlr.h" +#include "py/objstr.h" +#include "py/stream.h" + #if MICROPY_STREAMS_NON_BLOCK #include <errno.h> #if defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR) diff --git a/py/stream.h b/py/stream.h index df71685353..f9c77aac6e 100644 --- a/py/stream.h +++ b/py/stream.h @@ -23,6 +23,10 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ +#ifndef __MICROPY_INCLUDED_PY_STREAM_H__ +#define __MICROPY_INCLUDED_PY_STREAM_H__ + +#include "py/obj.h" MP_DECLARE_CONST_FUN_OBJ(mp_stream_read_obj); MP_DECLARE_CONST_FUN_OBJ(mp_stream_readinto_obj); @@ -36,3 +40,5 @@ MP_DECLARE_CONST_FUN_OBJ(mp_stream_seek_obj); mp_obj_t mp_stream_unbuffered_iter(mp_obj_t self); mp_obj_t mp_stream_write(mp_obj_t self_in, const void *buf, mp_uint_t len); + +#endif // __MICROPY_INCLUDED_PY_STREAM_H__ diff --git a/py/unicode.c b/py/unicode.c index 3951c2f8bb..a83e3ac06a 100644 --- a/py/unicode.c +++ b/py/unicode.c @@ -26,9 +26,7 @@ #include <stdint.h> -#include "mpconfig.h" -#include "misc.h" -#include "unicode.h" +#include "py/unicode.h" // attribute flags #define FL_PRINT (0x01) diff --git a/py/unicode.h b/py/unicode.h index 283a7d044d..89c28ed0ec 100644 --- a/py/unicode.h +++ b/py/unicode.h @@ -1 +1,34 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 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. + */ +#ifndef __MICROPY_INCLUDED_PY_UNICODE_H__ +#define __MICROPY_INCLUDED_PY_UNICODE_H__ + +#include "py/mpconfig.h" +#include "py/misc.h" + mp_uint_t utf8_ptr_to_index(const byte *s, const byte *ptr); + +#endif // __MICROPY_INCLUDED_PY_UNICODE_H__ @@ -29,16 +29,11 @@ #include <string.h> #include <assert.h> -#include "mpconfig.h" -#include "nlr.h" -#include "misc.h" -#include "qstr.h" -#include "obj.h" -#include "emitglue.h" -#include "runtime.h" -#include "bc0.h" -#include "bc.h" -#include "objgenerator.h" +#include "py/nlr.h" +#include "py/emitglue.h" +#include "py/runtime.h" +#include "py/bc0.h" +#include "py/bc.h" #if 0 #define TRACE(ip) printf("sp=" INT_FMT " ", sp - code_state->sp); mp_bytecode_print2(ip, 1); @@ -110,7 +105,7 @@ mp_vm_return_kind_t mp_execute_bytecode(mp_code_state *code_state, volatile mp_o #define MARK_EXC_IP_GLOBAL() { code_state->ip = ip; } /* stores ip pointing to last opcode */ #endif #if MICROPY_OPT_COMPUTED_GOTO - #include "vmentrytable.h" + #include "py/vmentrytable.h" #define DISPATCH() do { \ TRACE(ip); \ MARK_EXC_IP_GLOBAL(); \ diff --git a/py/vmentrytable.h b/py/vmentrytable.h index d3de975882..2926c0d7cd 100644 --- a/py/vmentrytable.h +++ b/py/vmentrytable.h @@ -28,7 +28,7 @@ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Winitializer-overrides" #endif // __clang__ - + static void* entry_table[256] = { [0 ... 255] = &&entry_default, [MP_BC_LOAD_CONST_FALSE] = &&entry_MP_BC_LOAD_CONST_FALSE, @@ -24,13 +24,13 @@ * THE SOFTWARE. */ -#include <stdbool.h> #include <stdio.h> #include <stdarg.h> #include <string.h> #include <assert.h> -#include "mpconfig.h" -#include "misc.h" + +#include "py/mpconfig.h" +#include "py/misc.h" // returned value is always at least 1 greater than argument #define ROUND_ALLOC(a) (((a) & ((~0) - 7)) + 8) diff --git a/py/warning.c b/py/warning.c index c7461c0f54..4cce177664 100644 --- a/py/warning.c +++ b/py/warning.c @@ -23,17 +23,12 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include <stdint.h> + #include <stdarg.h> #include <stdio.h> -#include "mpconfig.h" -#include "misc.h" -#include "qstr.h" -#include "obj.h" -#include "compile.h" -#include "scope.h" -#include "emit.h" +#include "py/obj.h" +#include "py/emit.h" #if MICROPY_WARNINGS |