]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-43244: Add pycore_ast.h header file (GH-24908)
authorVictor Stinner <vstinner@python.org>
Wed, 17 Mar 2021 22:50:50 +0000 (23:50 +0100)
committerGitHub <noreply@github.com>
Wed, 17 Mar 2021 22:50:50 +0000 (23:50 +0100)
Move _PyAST_GetDocString() and _PyAST_ExprAsUnicode() functions the
internal C API: from Include/ast.h to a new
Include/internal/pycore_ast.h header file. Don't export these
functions anymore: replace PyAPI_FUNC() with extern.

Remove also unused includes.

Include/ast.h
Include/internal/pycore_ast.h [new file with mode: 0644]
Makefile.pre.in
PCbuild/pythoncore.vcxproj
PCbuild/pythoncore.vcxproj.filters
Python/ast_opt.c
Python/compile.c
Python/future.c

index 434ee18dd91b2a7a5c6463c3299390c4b2fb5f5b..2f19b1a870dac1ee758221c39caba937d5d1301d 100644 (file)
@@ -9,14 +9,6 @@ extern "C" {
 
 PyAPI_FUNC(int) PyAST_Validate(mod_ty);
 
-/* _PyAST_ExprAsUnicode is defined in ast_unparse.c */
-PyAPI_FUNC(PyObject *) _PyAST_ExprAsUnicode(expr_ty);
-
-/* Return the borrowed reference to the first literal string in the
-   sequence of statements or NULL if it doesn't start from a literal string.
-   Doesn't set exception. */
-PyAPI_FUNC(PyObject *) _PyAST_GetDocString(asdl_stmt_seq *);
-
 #ifdef __cplusplus
 }
 #endif
diff --git a/Include/internal/pycore_ast.h b/Include/internal/pycore_ast.h
new file mode 100644 (file)
index 0000000..38c9212
--- /dev/null
@@ -0,0 +1,25 @@
+#ifndef Py_INTERNAL_AST_H
+#define Py_INTERNAL_AST_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef Py_BUILD_CORE
+#  error "this header requires Py_BUILD_CORE define"
+#endif
+
+#include "Python-ast.h"           // expr_ty
+
+/* _PyAST_ExprAsUnicode is defined in ast_unparse.c */
+extern PyObject* _PyAST_ExprAsUnicode(expr_ty);
+
+/* Return the borrowed reference to the first literal string in the
+   sequence of statements or NULL if it doesn't start from a literal string.
+   Doesn't set exception. */
+extern PyObject* _PyAST_GetDocString(asdl_stmt_seq *);
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* !Py_INTERNAL_AST_H */
+
index ee93ab6ca150eab301e83c7a6386d443e6498fe4..5ad304e30d022910aea284eab77f71f87dd72c9a 100644 (file)
@@ -1135,6 +1135,7 @@ PYTHON_HEADERS= \
                \
                $(srcdir)/Include/internal/pycore_abstract.h \
                $(srcdir)/Include/internal/pycore_accu.h \
+               $(srcdir)/Include/internal/pycore_ast.h \
                $(srcdir)/Include/internal/pycore_ast_state.h \
                $(srcdir)/Include/internal/pycore_atomic.h \
                $(srcdir)/Include/internal/pycore_atomic_funcs.h \
index 655c831ed5ff6ee5b3944a4cfbf5c8ab3e3c109a..37c60af4f74d7e9ad2b412d1c2409b35775102dd 100644 (file)
     <ClInclude Include="..\Include\import.h" />
     <ClInclude Include="..\Include\internal\pycore_abstract.h" />
     <ClInclude Include="..\Include\internal\pycore_accu.h" />
+    <ClInclude Include="..\Include\internal\pycore_ast.h" />
     <ClInclude Include="..\Include\internal\pycore_ast_state.h" />
     <ClInclude Include="..\Include\internal\pycore_atomic.h" />
     <ClInclude Include="..\Include\internal\pycore_atomic_funcs.h" />
index fba4af536fec9065bfe35726b91e5640e3d8d144..76894079890fd78ea85b377b9f3e430000bef209 100644 (file)
     <ClInclude Include="..\Include\internal\pycore_accu.h">
       <Filter>Include\internal</Filter>
     </ClInclude>
+    <ClInclude Include="..\Include\internal\pycore_ast.h">
+      <Filter>Include\internal</Filter>
+    </ClInclude>
     <ClInclude Include="..\Include\internal\pycore_ast_state.h">
       <Filter>Include\internal</Filter>
     </ClInclude>
index 6ad00dcf93cbdf3196934abd1070509aad96a031..c76b428f97298d8403858b66aa72c74d97c5d5c4 100644 (file)
@@ -1,7 +1,6 @@
 /* AST Optimizer */
 #include "Python.h"
-#include "Python-ast.h"
-#include "ast.h"
+#include "pycore_ast.h"           // _PyAST_GetDocString()
 
 
 static int
index a1260aadd62e421b8c6e48a38fe8de009e2ecbc2..6ef5d5f69896c59a86e5ccf6d2c86b4d9e62b38e 100644 (file)
  */
 
 #include "Python.h"
+#include "pycore_ast.h"           // _PyAST_GetDocString()
 #include "pycore_pymem.h"         // _PyMem_IsPtrFreed()
 #include "pycore_long.h"          // _PyLong_GetZero()
 
-#include "Python-ast.h"
-#include "ast.h"
-#include "code.h"
-#include "symtable.h"
+#include "symtable.h"             // struct symtable
 #define NEED_OPCODE_JUMP_TABLES
-#include "opcode.h"
-#include "wordcode_helpers.h"
+#include "opcode.h"               // EXTENDED_ARG
+#include "wordcode_helpers.h"     // instrsize()
+
 
 #define DEFAULT_BLOCK_SIZE 16
 #define DEFAULT_BLOCKS 8
index 4b73eb641290528d9c6accd429192b9dce30c116..37e7a22f81c2bb4b70accf8acf594033fc8e1faa 100644 (file)
@@ -1,9 +1,5 @@
 #include "Python.h"
-#include "Python-ast.h"
-#include "token.h"
-#include "code.h"
-#include "symtable.h"
-#include "ast.h"
+#include "pycore_ast.h"           // _PyAST_GetDocString()
 
 #define UNDEFINED_FUTURE_FEATURE "future feature %.100s is not defined"
 #define ERR_LATE_FUTURE \