aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2018-11-12 00:56:19 +0100
committerGitHub <noreply@github.com>2018-11-12 00:56:19 +0100
commit5f2df88b63e50d23914e97ec778861a52abdeaad (patch)
tree23a720832fb9de901538ca03819946df679ff2cd /Parser/asdl_c.py
parentcloses bpo-35204: Disable thread and memory sanitizers for address_in_range()... (diff)
downloadcpython-5f2df88b63e50d23914e97ec778861a52abdeaad.tar.gz
cpython-5f2df88b63e50d23914e97ec778861a52abdeaad.tar.bz2
cpython-5f2df88b63e50d23914e97ec778861a52abdeaad.zip
bpo-35177: Add dependencies between header files (GH-10361)
* ast.h now includes Python-ast.h and node.h * parsetok.h now includes node.h and grammar.h * symtable.h now includes Python-ast.h * Modify asdl_c.py to enhance Python-ast.h: * Add #ifndef/#define Py_PYTHON_AST_H to be able to include the header twice * Add "extern { ... }" for C++ * Undefine "Yield" macro conflicting with winbase.h * Remove "#undef Yield" from C files, it's now done in Python-ast.h * Remove now useless includes in C files
Diffstat (limited to 'Parser/asdl_c.py')
-rw-r--r--Parser/asdl_c.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/Parser/asdl_c.py b/Parser/asdl_c.py
index 4c280a96c3..6a8262c73b 100644
--- a/Parser/asdl_c.py
+++ b/Parser/asdl_c.py
@@ -1239,7 +1239,16 @@ def main(srcfile, dump_module=False):
if H_FILE:
with open(H_FILE, "w") as f:
f.write(auto_gen_msg)
- f.write('#include "asdl.h"\n\n')
+ f.write('#ifndef Py_PYTHON_AST_H\n')
+ f.write('#define Py_PYTHON_AST_H\n')
+ f.write('#ifdef __cplusplus\n')
+ f.write('extern "C" {\n')
+ f.write('#endif\n')
+ f.write('\n')
+ f.write('#include "asdl.h"\n')
+ f.write('\n')
+ f.write('#undef Yield /* undefine macro conflicting with winbase.h */\n')
+ f.write('\n')
c = ChainOfVisitors(TypeDefVisitor(f),
StructVisitor(f),
PrototypeVisitor(f),
@@ -1248,6 +1257,11 @@ def main(srcfile, dump_module=False):
f.write("PyObject* PyAST_mod2obj(mod_ty t);\n")
f.write("mod_ty PyAST_obj2mod(PyObject* ast, PyArena* arena, int mode);\n")
f.write("int PyAST_Check(PyObject* obj);\n")
+ f.write('\n')
+ f.write('#ifdef __cplusplus\n')
+ f.write('}\n')
+ f.write('#endif\n')
+ f.write('#endif /* !Py_PYTHON_AST_H */\n')
if C_FILE:
with open(C_FILE, "w") as f: