summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--py/argcheck.c8
-rw-r--r--py/asmarm.c6
-rw-r--r--py/asmthumb.c6
-rw-r--r--py/asmx64.c5
-rw-r--r--py/asmx86.c5
-rw-r--r--py/bc.c14
-rw-r--r--py/bc.h7
-rw-r--r--py/bc0.h4
-rw-r--r--py/binary.c8
-rw-r--r--py/binary.h6
-rw-r--r--py/builtin.h6
-rw-r--r--py/builtinevex.c19
-rw-r--r--py/builtinimport.c20
-rw-r--r--py/compile.c24
-rw-r--r--py/emit.h11
-rw-r--r--py/emitbc.c13
-rw-r--r--py/emitcommon.c11
-rw-r--r--py/emitcpy.c11
-rw-r--r--py/emitglue.c11
-rw-r--r--py/emitglue.h2
-rw-r--r--py/emitinlinethumb.c15
-rw-r--r--py/emitnative.c24
-rw-r--r--py/emitpass1.c13
-rw-r--r--py/formatfloat.c7
-rw-r--r--py/formatfloat.h6
-rw-r--r--py/gc.c12
-rw-r--r--py/gc.h9
-rw-r--r--py/lexer.c10
-rw-r--r--py/lexer.h5
-rw-r--r--py/lexerstr.c7
-rw-r--r--py/lexerunix.c7
-rw-r--r--py/lexerunix.h29
-rw-r--r--py/malloc.c7
-rw-r--r--py/map.c8
-rw-r--r--py/modarray.c6
-rw-r--r--py/modbuiltins.c20
-rw-r--r--py/modcmath.c10
-rw-r--r--py/modcollections.c6
-rw-r--r--py/modgc.c10
-rw-r--r--py/modio.c6
-rw-r--r--py/modmath.c10
-rw-r--r--py/modmicropython.c12
-rw-r--r--py/modstruct.c14
-rw-r--r--py/modsys.c24
-rw-r--r--py/mpz.c7
-rw-r--r--py/mpz.h9
-rw-r--r--py/nativeglue.c12
-rw-r--r--py/nlr.h6
-rw-r--r--py/nlrsetjmp.c5
-rw-r--r--py/obj.c18
-rw-r--r--py/objarray.c12
-rw-r--r--py/objarray.h27
-rw-r--r--py/objbool.c10
-rw-r--r--py/objboundmeth.c8
-rw-r--r--py/objcell.c7
-rw-r--r--py/objclosure.c9
-rw-r--r--py/objcomplex.c21
-rw-r--r--py/objdict.c15
-rw-r--r--py/objenumerate.c6
-rw-r--r--py/objexcept.c21
-rw-r--r--py/objfilter.c11
-rw-r--r--py/objfloat.c16
-rw-r--r--py/objfun.c19
-rw-r--r--py/objfun.h6
-rw-r--r--py/objgenerator.c15
-rw-r--r--py/objgenerator.h7
-rw-r--r--py/objgetitemiter.c8
-rw-r--r--py/objint.c20
-rw-r--r--py/objint.h7
-rw-r--r--py/objint_longlong.c16
-rw-r--r--py/objint_mpz.c18
-rw-r--r--py/objlist.c12
-rw-r--r--py/objlist.h6
-rw-r--r--py/objmap.c8
-rw-r--r--py/objmodule.c12
-rw-r--r--py/objmodule.h6
-rw-r--r--py/objnamedtuple.c10
-rw-r--r--py/objnone.c9
-rw-r--r--py/objobject.c9
-rw-r--r--py/objproperty.c8
-rw-r--r--py/objrange.c10
-rw-r--r--py/objreversed.c8
-rw-r--r--py/objset.c12
-rw-r--r--py/objslice.c9
-rw-r--r--py/objstr.c19
-rw-r--r--py/objstr.h6
-rw-r--r--py/objstringio.c12
-rw-r--r--py/objstrunicode.c17
-rw-r--r--py/objtuple.c12
-rw-r--r--py/objtuple.h6
-rw-r--r--py/objtype.c12
-rw-r--r--py/objtype.h6
-rw-r--r--py/objzip.c8
-rw-r--r--py/opmethods.c10
-rw-r--r--py/parse.c17
-rw-r--r--py/parse.h4
-rw-r--r--py/parsehelper.c9
-rw-r--r--py/parsehelper.h1
-rw-r--r--py/parsenum.c12
-rw-r--r--py/parsenum.h8
-rw-r--r--py/parsenumbase.c4
-rw-r--r--py/parsenumbase.h6
-rw-r--r--py/pfenv.c13
-rw-r--r--py/pfenv.h6
-rw-r--r--py/pfenv_printf.c10
-rw-r--r--py/qstr.c7
-rw-r--r--py/qstrdefs.h3
-rw-r--r--py/repl.c4
-rw-r--r--py/repl.h7
-rw-r--r--py/runtime.c37
-rw-r--r--py/scope.c10
-rw-r--r--py/scope.h7
-rw-r--r--py/sequence.c13
-rw-r--r--py/showbc.c10
-rw-r--r--py/smallint.c6
-rw-r--r--py/smallint.h7
-rw-r--r--py/stackctrl.c10
-rw-r--r--py/stackctrl.h6
-rw-r--r--py/stream.c12
-rw-r--r--py/stream.h6
-rw-r--r--py/unicode.c4
-rw-r--r--py/unicode.h33
-rw-r--r--py/vm.c17
-rw-r--r--py/vmentrytable.h2
-rw-r--r--py/vstr.c6
-rw-r--r--py/warning.c11
-rw-r--r--unix-cpy/main.c1
-rw-r--r--unix/modsocket.c1
128 files changed, 529 insertions, 818 deletions
diff --git a/py/argcheck.c b/py/argcheck.c
index 4bc0629b1..f9a4eb7f4 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 51852df5f..0ca88fd97 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 7ae6862b5..14ba5a6fc 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 54f541ffb..ded778fe0 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 f0dc1e60f..29ceaf8f8 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)
diff --git a/py/bc.c b/py/bc.c
index bbc9a207d..6aa20172f 100644
--- a/py/bc.c
+++ b/py/bc.c
@@ -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)
diff --git a/py/bc.h b/py/bc.h
index ad16f9c9d..45c63f356 100644
--- a/py/bc.h
+++ b/py/bc.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_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__
diff --git a/py/bc0.h b/py/bc0.h
index 0b1091759..42b8b6280 100644
--- a/py/bc0.h
+++ b/py/bc0.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 e4dac31e9..69818e536 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 dc9d3f680..a0ccbd5f4 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 70f163379..14dc27324 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 bb15fd4d0..9bca4a0f5 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 fd804ee35..4dc02bdc2 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 66e2996c4..b2ba01cc9 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
diff --git a/py/emit.h b/py/emit.h
index f039770a5..49bb76ead 100644
--- a/py/emit.h
+++ b/py/emit.h
@@ -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 f55a16634..3914a9dcb 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 e199bc6e9..4d909839a 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 bcf8a22c3..a1e8e95c8 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 5d51ba2a6..65d131125 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 60ccd6740..6e7e72ef5 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 4cf880fab..669929b0d 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 c8f8cd8f2..494f89093 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 9e471ef59..8878b562e 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 d1b12cdd5..e73215a7a 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 3b963df41..1eb2c1e46 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__
diff --git a/py/gc.c b/py/gc.c
index 4d9334056..8404281e4 100644
--- a/py/gc.c
+++ b/py/gc.c
@@ -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
diff --git a/py/gc.h b/py/gc.h
index 69fe83752..c698c7d21 100644
--- a/py/gc.h
+++ b/py/gc.h
@@ -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 bc1b8babf..ce6aa783a 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 7f8d93b1e..c2d2b678a 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 c3456b9bd..cab3ed361 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 8e3241ad0..b5abbc8fe 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 12c3e8712..000000000
--- 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 451e480e8..10e3566e8 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
diff --git a/py/map.c b/py/map.c
index 22580de82..c88e6e56e 100644
--- a/py/map.c
+++ b/py/map.c
@@ -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 360fe8a5f..e251b0688 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 7ac22fc49..4a1446d23 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 7514a8c02..59fa76ee6 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 8035b72d5..9fcbe879f 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 8c9be7068..e3cbe72f9 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 6a273b39b..30f766b40 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 b922f3e49..38ed390dd 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 170141757..035956ffc 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 f29c8c1f9..114135dfd 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 06bd4c80e..51bd6bfbb 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
diff --git a/py/mpz.c b/py/mpz.c
index 6213b4a57..a25ba9e7d 100644
--- a/py/mpz.c
+++ b/py/mpz.c
@@ -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
diff --git a/py/mpz.h b/py/mpz.h
index 3ae9efe42..e1d71bf4a 100644
--- a/py/mpz.h
+++ b/py/mpz.h
@@ -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 05fadb7b0..d52eeaeaa 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
diff --git a/py/nlr.h b/py/nlr.h
index 93eaa78b7..ae9ca1a77 100644
--- a/py/nlr.h
+++ b/py/nlr.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_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 cb5acb757..176138db0 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
diff --git a/py/obj.c b/py/obj.c
index d2801a396..0caf10074 100644
--- a/py/obj.c
+++ b/py/obj.c
@@ -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 cb8e03e45..19705afc0 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 730f67641..000000000
--- 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 47c91357f..6dd9e7f9f 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 66af5df0a..e451ce4c1 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 29280e851..b2d42001b 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 d563206b6..853f0930c 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 2768a01e6..9e158fac6 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 2f4ae7083..63b3cfb32 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 0d96712df..209af8231 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 4b8d6ea08..a60cbb82e 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 38af31674..98200f260 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 b75d0e4ba..86b672007 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 5f95a015b..b86d6f8dc 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 e23fe8d52..a5b9f2b5f 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 646ae4fdd..1b06975c9 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 d0066de4e..d1b9be478 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 75b9d1c56..2b0f7bb05 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 0aa281edd..c272fd4a7 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 70d182ba7..fff325df8 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 5f48b7134..394ae111a 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 1dc1def33..554ec9657 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 3e5355719..911ddb98a 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 05a4c8d3a..443ede574 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 f7d7b01c3..ea62bb512 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 5ffb368bf..2e53bf052 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 f4ccedee5..138f942c2 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 c0510081c..320467eed 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 01536dcb3..387fb58cb 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 551ccf76e..5bbe02b32 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 c83ca2dbb..75cc1458e 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 702413f2a..2a8388b17 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 aa73f3771..b61495861 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 1069cd5ea..54009a1f5 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 c99b9d08d..3f090dc23 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 3d9fd6f5e..5976e36e7 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 9bc060085..8894c267e 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 e5abc0526..eca8522ee 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 2c8d02491..fd3678722 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 2793e4838..1f2eeb380 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 43b3826bf..4cac48755 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 2970e9276..b5890c472 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 dd2e44a79..8adbbc33b 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 738131f92..e1bf92737 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 ea930c28a..80a953fb8 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 ae1fe65e7..c7c85e035 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 400622318..4e7f2b9d1 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 f30471067..904268109 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 4a95f22fa..1763809ba 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 bb88eb729..4706fef81 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 5164d5001..a769bdd83 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 f552c5e37..5574b3b9b 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 177f14451..f8953ec83 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 965636aea..698f3b16c 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 98c1885f3..074c0012f 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 c0e826a5d..39bf321ce 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) {
diff --git a/py/qstr.c b/py/qstr.c
index e08de2eba..1bca8a10d 100644
--- a/py/qstr.c
+++ b/py/qstr.c
@@ -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 e91d36070..b8eacc68c 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.
diff --git a/py/repl.c b/py/repl.c
index 6bd880d92..c6b3e60ae 100644
--- a/py/repl.c
+++ b/py/repl.c
@@ -24,9 +24,7 @@
* THE SOFTWARE.
*/
-#include "mpconfig.h"
-#include "misc.h"
-#include "repl.h"
+#include "py/repl.h"
#if MICROPY_HELPER_REPL
diff --git a/py/repl.h b/py/repl.h
index 92688f9f9..db9256017 100644
--- a/py/repl.h
+++ b/py/repl.h
@@ -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 505c8e31a..c4c73dfe4 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 05606ffcc..4739ac323 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 903a32a79..6d74b17d2 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 8cc7519be..0e76ccc02 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 4a765499c..e2151c5a5 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 3a06c40a9..4c42ee0cc 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 26a12874e..980be42f3 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 0ba43c28c..31336ec69 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 4ed67774f..bd18f2142 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 db7e5657f..c57b7981a 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 df7168535..f9c77aac6 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 3951c2f8b..a83e3ac06 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 283a7d044..89c28ed0e 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__
diff --git a/py/vm.c b/py/vm.c
index b82a1eda5..b0f778352 100644
--- a/py/vm.c
+++ b/py/vm.c
@@ -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 d3de97588..2926c0d7c 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,
diff --git a/py/vstr.c b/py/vstr.c
index 03b03d0a3..e87aef9e4 100644
--- a/py/vstr.c
+++ b/py/vstr.c
@@ -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 c7461c0f5..4cce17766 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
diff --git a/unix-cpy/main.c b/unix-cpy/main.c
index 81f39ed27..002e26af8 100644
--- a/unix-cpy/main.c
+++ b/unix-cpy/main.c
@@ -34,7 +34,6 @@
#include "misc.h"
#include "qstr.h"
#include "lexer.h"
-#include "lexerunix.h"
#include "parse.h"
#include "obj.h"
#include "parsehelper.h"
diff --git a/unix/modsocket.c b/unix/modsocket.c
index f844d3b35..402695d65 100644
--- a/unix/modsocket.c
+++ b/unix/modsocket.c
@@ -44,7 +44,6 @@
#include "qstr.h"
#include "obj.h"
#include "objtuple.h"
-#include "objarray.h"
#include "objstr.h"
#include "runtime.h"
#include "stream.h"