From 8ab6f9067412d9f73fe88d42d81c0b4c4f1fd20b Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Thu, 25 Dec 2014 23:29:19 +0200 Subject: [PATCH] py: Move to guarded includes for compile.h and related headers. --- py/compile.h | 8 ++++++++ py/emit.h | 6 ++++++ py/emitglue.h | 4 ++++ py/lexer.h | 4 ++++ py/parse.h | 4 ++++ py/runtime0.h | 4 ++++ 6 files changed, 30 insertions(+) diff --git a/py/compile.h b/py/compile.h index cef20efce..9d612da53 100644 --- a/py/compile.h +++ b/py/compile.h @@ -23,6 +23,12 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ +#ifndef __MICROPY_INCLUDED_PY_COMPILE_H__ +#define __MICROPY_INCLUDED_PY_COMPILE_H__ + +#include "py/lexer.h" +#include "py/parse.h" +#include "py/emitglue.h" // These must fit in 8 bits; see scope.h enum { @@ -38,3 +44,5 @@ mp_obj_t mp_compile(mp_parse_node_t pn, qstr source_file, uint emit_opt, bool is // this is implemented in runtime.c mp_obj_t mp_parse_compile_execute(mp_lexer_t *lex, mp_parse_input_kind_t parse_input_kind, mp_obj_dict_t *globals, mp_obj_dict_t *locals); + +#endif // __MICROPY_INCLUDED_PY_COMPILE_H__ diff --git a/py/emit.h b/py/emit.h index 1f1798fdf..8b9b368c2 100644 --- a/py/emit.h +++ b/py/emit.h @@ -33,6 +33,10 @@ * 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 @@ -195,3 +199,5 @@ extern const emit_inline_asm_method_table_t emit_inline_thumb_method_table; emit_inline_asm_t *emit_inline_thumb_new(mp_uint_t max_num_labels); void emit_inline_thumb_free(emit_inline_asm_t *emit); + +#endif // __MICROPY_INCLUDED_PY_EMIT_H__ diff --git a/py/emitglue.h b/py/emitglue.h index fd55af26a..60ccd6740 100644 --- a/py/emitglue.h +++ b/py/emitglue.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_EMITGLUE_H__ +#define __MICROPY_INCLUDED_PY_EMITGLUE_H__ // These variables and functions glue the code emitters to the runtime. @@ -59,3 +61,5 @@ void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, void mp_obj_t mp_make_function_from_raw_code(mp_raw_code_t *rc, mp_obj_t def_args, mp_obj_t def_kw_args); mp_obj_t mp_make_closure_from_raw_code(mp_raw_code_t *rc, mp_uint_t n_closed_over, const mp_obj_t *args); + +#endif // __MICROPY_INCLUDED_PY_EMITGLUE_H__ diff --git a/py/lexer.h b/py/lexer.h index c2f621d4c..7f8d93b1e 100644 --- a/py/lexer.h +++ b/py/lexer.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_LEXER_H__ +#define __MICROPY_INCLUDED_PY_LEXER_H__ /* lexer.h -- simple tokeniser for Micro Python * @@ -186,3 +188,5 @@ mp_import_stat_t mp_import_stat(const char *path); mp_lexer_t *mp_lexer_new_from_file(const char *filename); extern mp_uint_t mp_optimise_value; + +#endif // __MICROPY_INCLUDED_PY_LEXER_H__ diff --git a/py/parse.h b/py/parse.h index 45645951a..400622318 100644 --- a/py/parse.h +++ b/py/parse.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_PARSE_H__ +#define __MICROPY_INCLUDED_PY_PARSE_H__ struct _mp_lexer_t; @@ -93,3 +95,5 @@ typedef enum { // returns MP_PARSE_NODE_NULL on error, and then parse_error_kind_out is valid mp_parse_node_t mp_parse(struct _mp_lexer_t *lex, mp_parse_input_kind_t input_kind, mp_parse_error_kind_t *parse_error_kind_out); + +#endif // __MICROPY_INCLUDED_PY_PARSE_H__ diff --git a/py/runtime0.h b/py/runtime0.h index b6db1dd85..dc4a526d1 100644 --- a/py/runtime0.h +++ b/py/runtime0.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_RUNTIME0_H__ +#define __MICROPY_INCLUDED_PY_RUNTIME0_H__ // taken from python source, Include/code.h // These must fit in 8 bits; see scope.h @@ -152,3 +154,5 @@ typedef enum { } mp_fun_kind_t; extern void *const mp_fun_table[MP_F_NUMBER_OF]; + +#endif // __MICROPY_INCLUDED_PY_RUNTIME0_H__