diff options
author | Victor Stinner <vstinner@python.org> | 2021-03-23 23:51:50 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-23 23:51:50 (GMT) |
commit | a81fca6ec8e0f748f8eafa12fb12cf9e12df465c (patch) | |
tree | 955b952d9953f5ba3ed487512ac9f67267ddd4f4 /Include | |
parent | f0a6fde8827d5d4f7a1c741ab1a8b206b66ffd57 (diff) | |
download | cpython-a81fca6ec8e0f748f8eafa12fb12cf9e12df465c.zip cpython-a81fca6ec8e0f748f8eafa12fb12cf9e12df465c.tar.gz cpython-a81fca6ec8e0f748f8eafa12fb12cf9e12df465c.tar.bz2 |
bpo-43244: Add pycore_compile.h header file (GH-25000)
Remove the compiler functions using "struct _mod" type, because the
public AST C API was removed:
* PyAST_Compile()
* PyAST_CompileEx()
* PyAST_CompileObject()
* PyFuture_FromAST()
* PyFuture_FromASTObject()
These functions were undocumented and excluded from the limited C API.
Rename functions:
* PyAST_CompileObject() => _PyAST_Compile()
* PyFuture_FromASTObject() => _PyFuture_FromAST()
Moreover, _PyFuture_FromAST() is no longer exported (replace
PyAPI_FUNC() with extern). _PyAST_Compile() remains exported for
test_peg_generator.
Remove also compatibility functions:
* PyAST_Compile()
* PyAST_CompileEx()
* PyFuture_FromAST()
Diffstat (limited to 'Include')
-rw-r--r-- | Include/cpython/compile.h | 34 | ||||
-rw-r--r-- | Include/internal/pycore_compile.h | 40 |
2 files changed, 40 insertions, 34 deletions
diff --git a/Include/cpython/compile.h b/Include/cpython/compile.h index 59ba1ed..a202c0b 100644 --- a/Include/cpython/compile.h +++ b/Include/cpython/compile.h @@ -47,40 +47,6 @@ typedef struct { #define FUTURE_GENERATOR_STOP "generator_stop" #define FUTURE_ANNOTATIONS "annotations" -struct _mod; // Type defined in pycore_ast.h - -#define PyAST_Compile(mod, s, f, ar) PyAST_CompileEx(mod, s, f, -1, ar) -PyAPI_FUNC(PyCodeObject *) PyAST_CompileEx( - struct _mod *mod, - const char *filename, /* decoded from the filesystem encoding */ - PyCompilerFlags *flags, - int optimize, - PyArena *arena); -PyAPI_FUNC(PyCodeObject *) PyAST_CompileObject( - struct _mod *mod, - PyObject *filename, - PyCompilerFlags *flags, - int optimize, - PyArena *arena); -PyAPI_FUNC(PyFutureFeatures *) PyFuture_FromAST( - struct _mod * mod, - const char *filename /* decoded from the filesystem encoding */ - ); -PyAPI_FUNC(PyFutureFeatures *) PyFuture_FromASTObject( - struct _mod * mod, - PyObject *filename - ); - -/* _Py_Mangle is defined in compile.c */ -PyAPI_FUNC(PyObject*) _Py_Mangle(PyObject *p, PyObject *name); - #define PY_INVALID_STACK_EFFECT INT_MAX PyAPI_FUNC(int) PyCompile_OpcodeStackEffect(int opcode, int oparg); PyAPI_FUNC(int) PyCompile_OpcodeStackEffectWithJump(int opcode, int oparg, int jump); - -typedef struct { - int optimize; - int ff_features; -} _PyASTOptimizeState; - -PyAPI_FUNC(int) _PyAST_Optimize(struct _mod *, PyArena *arena, _PyASTOptimizeState *state); diff --git a/Include/internal/pycore_compile.h b/Include/internal/pycore_compile.h new file mode 100644 index 0000000..f6caec3 --- /dev/null +++ b/Include/internal/pycore_compile.h @@ -0,0 +1,40 @@ +#ifndef Py_INTERNAL_COMPILE_H +#define Py_INTERNAL_COMPILE_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +struct _mod; // Type defined in pycore_ast.h + +// Export the symbol for test_peg_generator (built as a library) +PyAPI_FUNC(PyCodeObject*) _PyAST_Compile( + struct _mod *mod, + PyObject *filename, + PyCompilerFlags *flags, + int optimize, + PyArena *arena); +extern PyFutureFeatures* _PyFuture_FromAST( + struct _mod * mod, + PyObject *filename + ); + +extern PyObject* _Py_Mangle(PyObject *p, PyObject *name); + +typedef struct { + int optimize; + int ff_features; +} _PyASTOptimizeState; + +extern int _PyAST_Optimize( + struct _mod *, + PyArena *arena, + _PyASTOptimizeState *state); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_COMPILE_H */ |