py: Move to guarded includes, everywhere in py/ core.

Addresses issue #1022.
crypto-aes
Damien George 8 years ago
parent db1ac360c3
commit 51dfcb4bb7

@ -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

@ -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 {

@ -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)

@ -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)

@ -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__

@ -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

@ -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__

@ -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__

@ -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

@ -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)

@ -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

@ -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

@ -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__))

@ -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

@ -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)

@ -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 {

@ -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;

@ -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

@ -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;

@ -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;

@ -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__

@ -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)

@ -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.

@ -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)

@ -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;

@ -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);

@ -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.

@ -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

@ -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>

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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__

@ -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__

@ -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)) {

@ -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

@ -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);

@ -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;

@ -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;

@ -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;

@ -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;

@ -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

@ -24,19 +24,14 @@
* THE SOFTWARE.
*/
#include <stdbool.h>
#include <string.h>
#include <assert.h>
#include "mpconfig.h"
#include