|
1 | 1 | #ifndef Py_COMPILE_H |
2 | 2 | #define Py_COMPILE_H |
3 | 3 |
|
4 | | -#ifndef Py_LIMITED_API |
5 | | - |
6 | 4 | #ifdef __cplusplus |
7 | 5 | extern "C" { |
8 | 6 | #endif |
9 | 7 |
|
10 | | -/* Public interface */ |
11 | | -#define PyCF_MASK (CO_FUTURE_DIVISION | CO_FUTURE_ABSOLUTE_IMPORT | \ |
12 | | - CO_FUTURE_WITH_STATEMENT | CO_FUTURE_PRINT_FUNCTION | \ |
13 | | - CO_FUTURE_UNICODE_LITERALS | CO_FUTURE_BARRY_AS_BDFL | \ |
14 | | - CO_FUTURE_GENERATOR_STOP | CO_FUTURE_ANNOTATIONS) |
15 | | -#define PyCF_MASK_OBSOLETE (CO_NESTED) |
16 | | - |
17 | | -/* bpo-39562: CO_FUTURE_ and PyCF_ constants must be kept unique. |
18 | | - PyCF_ constants can use bits from 0x0100 to 0x10000. |
19 | | - CO_FUTURE_ constants use bits starting at 0x20000. */ |
20 | | -#define PyCF_SOURCE_IS_UTF8 0x0100 |
21 | | -#define PyCF_DONT_IMPLY_DEDENT 0x0200 |
22 | | -#define PyCF_ONLY_AST 0x0400 |
23 | | -#define PyCF_IGNORE_COOKIE 0x0800 |
24 | | -#define PyCF_TYPE_COMMENTS 0x1000 |
25 | | -#define PyCF_ALLOW_TOP_LEVEL_AWAIT 0x2000 |
26 | | -#define PyCF_COMPILE_MASK (PyCF_ONLY_AST | PyCF_ALLOW_TOP_LEVEL_AWAIT | \ |
27 | | - PyCF_TYPE_COMMENTS | PyCF_DONT_IMPLY_DEDENT) |
28 | | - |
29 | 8 | #ifndef Py_LIMITED_API |
30 | | -typedef struct { |
31 | | - int cf_flags; /* bitmask of CO_xxx flags relevant to future */ |
32 | | - int cf_feature_version; /* minor Python version (PyCF_ONLY_AST) */ |
33 | | -} PyCompilerFlags; |
34 | | - |
35 | | -#define _PyCompilerFlags_INIT \ |
36 | | - (PyCompilerFlags){.cf_flags = 0, .cf_feature_version = PY_MINOR_VERSION} |
| 9 | +# include "cpython/compile.h" |
37 | 10 | #endif |
38 | 11 |
|
39 | | -/* Future feature support */ |
40 | | - |
41 | | -typedef struct { |
42 | | - int ff_features; /* flags set by future statements */ |
43 | | - int ff_lineno; /* line number of last future statement */ |
44 | | -} PyFutureFeatures; |
45 | | - |
46 | | -#define FUTURE_NESTED_SCOPES "nested_scopes" |
47 | | -#define FUTURE_GENERATORS "generators" |
48 | | -#define FUTURE_DIVISION "division" |
49 | | -#define FUTURE_ABSOLUTE_IMPORT "absolute_import" |
50 | | -#define FUTURE_WITH_STATEMENT "with_statement" |
51 | | -#define FUTURE_PRINT_FUNCTION "print_function" |
52 | | -#define FUTURE_UNICODE_LITERALS "unicode_literals" |
53 | | -#define FUTURE_BARRY_AS_BDFL "barry_as_FLUFL" |
54 | | -#define FUTURE_GENERATOR_STOP "generator_stop" |
55 | | -#define FUTURE_ANNOTATIONS "annotations" |
56 | | - |
57 | | -struct _mod; /* Declare the existence of this type */ |
58 | | -#define PyAST_Compile(mod, s, f, ar) PyAST_CompileEx(mod, s, f, -1, ar) |
59 | | -PyAPI_FUNC(PyCodeObject *) PyAST_CompileEx( |
60 | | - struct _mod *mod, |
61 | | - const char *filename, /* decoded from the filesystem encoding */ |
62 | | - PyCompilerFlags *flags, |
63 | | - int optimize, |
64 | | - PyArena *arena); |
65 | | -PyAPI_FUNC(PyCodeObject *) PyAST_CompileObject( |
66 | | - struct _mod *mod, |
67 | | - PyObject *filename, |
68 | | - PyCompilerFlags *flags, |
69 | | - int optimize, |
70 | | - PyArena *arena); |
71 | | -PyAPI_FUNC(PyFutureFeatures *) PyFuture_FromAST( |
72 | | - struct _mod * mod, |
73 | | - const char *filename /* decoded from the filesystem encoding */ |
74 | | - ); |
75 | | -PyAPI_FUNC(PyFutureFeatures *) PyFuture_FromASTObject( |
76 | | - struct _mod * mod, |
77 | | - PyObject *filename |
78 | | - ); |
79 | | - |
80 | | -/* _Py_Mangle is defined in compile.c */ |
81 | | -PyAPI_FUNC(PyObject*) _Py_Mangle(PyObject *p, PyObject *name); |
82 | | - |
83 | | -#define PY_INVALID_STACK_EFFECT INT_MAX |
84 | | -PyAPI_FUNC(int) PyCompile_OpcodeStackEffect(int opcode, int oparg); |
85 | | -PyAPI_FUNC(int) PyCompile_OpcodeStackEffectWithJump(int opcode, int oparg, int jump); |
86 | | - |
87 | | -typedef struct { |
88 | | - int optimize; |
89 | | - int ff_features; |
90 | | -} _PyASTOptimizeState; |
91 | | - |
92 | | -PyAPI_FUNC(int) _PyAST_Optimize(struct _mod *, PyArena *arena, _PyASTOptimizeState *state); |
93 | | - |
94 | 12 | #ifdef __cplusplus |
95 | 13 | } |
96 | 14 | #endif |
97 | 15 |
|
98 | | -#endif /* !Py_LIMITED_API */ |
99 | | - |
100 | 16 | /* These definitions must match corresponding definitions in graminit.h. */ |
101 | 17 | #define Py_single_input 256 |
102 | 18 | #define Py_file_input 257 |
|
0 commit comments