Skip to content

Commit 8ab6f90

Browse files
committed
py: Move to guarded includes for compile.h and related headers.
1 parent 343266e commit 8ab6f90

6 files changed

Lines changed: 30 additions & 0 deletions

File tree

py/compile.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@
2323
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2424
* THE SOFTWARE.
2525
*/
26+
#ifndef __MICROPY_INCLUDED_PY_COMPILE_H__
27+
#define __MICROPY_INCLUDED_PY_COMPILE_H__
28+
29+
#include "py/lexer.h"
30+
#include "py/parse.h"
31+
#include "py/emitglue.h"
2632

2733
// These must fit in 8 bits; see scope.h
2834
enum {
@@ -38,3 +44,5 @@ mp_obj_t mp_compile(mp_parse_node_t pn, qstr source_file, uint emit_opt, bool is
3844

3945
// this is implemented in runtime.c
4046
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);
47+
48+
#endif // __MICROPY_INCLUDED_PY_COMPILE_H__

py/emit.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@
3333
* This is problematic for some emitters (x64) since they need to know the maximum
3434
* stack size to compile the entry to the function, and this affects code size.
3535
*/
36+
#ifndef __MICROPY_INCLUDED_PY_EMIT_H__
37+
#define __MICROPY_INCLUDED_PY_EMIT_H__
38+
39+
#include "py/runtime0.h"
3640

3741
typedef enum {
3842
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;
195199

196200
emit_inline_asm_t *emit_inline_thumb_new(mp_uint_t max_num_labels);
197201
void emit_inline_thumb_free(emit_inline_asm_t *emit);
202+
203+
#endif // __MICROPY_INCLUDED_PY_EMIT_H__

py/emitglue.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2424
* THE SOFTWARE.
2525
*/
26+
#ifndef __MICROPY_INCLUDED_PY_EMITGLUE_H__
27+
#define __MICROPY_INCLUDED_PY_EMITGLUE_H__
2628

2729
// These variables and functions glue the code emitters to the runtime.
2830

@@ -59,3 +61,5 @@ void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, void
5961

6062
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);
6163
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);
64+
65+
#endif // __MICROPY_INCLUDED_PY_EMITGLUE_H__

py/lexer.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2424
* THE SOFTWARE.
2525
*/
26+
#ifndef __MICROPY_INCLUDED_PY_LEXER_H__
27+
#define __MICROPY_INCLUDED_PY_LEXER_H__
2628

2729
/* lexer.h -- simple tokeniser for Micro Python
2830
*
@@ -186,3 +188,5 @@ mp_import_stat_t mp_import_stat(const char *path);
186188
mp_lexer_t *mp_lexer_new_from_file(const char *filename);
187189

188190
extern mp_uint_t mp_optimise_value;
191+
192+
#endif // __MICROPY_INCLUDED_PY_LEXER_H__

py/parse.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2424
* THE SOFTWARE.
2525
*/
26+
#ifndef __MICROPY_INCLUDED_PY_PARSE_H__
27+
#define __MICROPY_INCLUDED_PY_PARSE_H__
2628

2729
struct _mp_lexer_t;
2830

@@ -93,3 +95,5 @@ typedef enum {
9395

9496
// returns MP_PARSE_NODE_NULL on error, and then parse_error_kind_out is valid
9597
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);
98+
99+
#endif // __MICROPY_INCLUDED_PY_PARSE_H__

py/runtime0.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2424
* THE SOFTWARE.
2525
*/
26+
#ifndef __MICROPY_INCLUDED_PY_RUNTIME0_H__
27+
#define __MICROPY_INCLUDED_PY_RUNTIME0_H__
2628

2729
// taken from python source, Include/code.h
2830
// These must fit in 8 bits; see scope.h
@@ -152,3 +154,5 @@ typedef enum {
152154
} mp_fun_kind_t;
153155

154156
extern void *const mp_fun_table[MP_F_NUMBER_OF];
157+
158+
#endif // __MICROPY_INCLUDED_PY_RUNTIME0_H__

0 commit comments

Comments
 (0)