Skip to content

bpo-35177: Add dependencies between header files #10361

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Include/Python-ast.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Include/ast.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
extern "C" {
#endif

#include "Python-ast.h" /* mod_ty */
#include "node.h" /* node */

PyAPI_FUNC(int) PyAST_Validate(mod_ty);
PyAPI_FUNC(mod_ty) PyAST_FromNode(
const node *n,
Expand Down
5 changes: 4 additions & 1 deletion Include/parsetok.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@

/* Parser-tokenizer link interface */

#ifndef Py_LIMITED_API
#ifndef Py_PARSETOK_H
#define Py_PARSETOK_H
#ifdef __cplusplus
extern "C" {
#endif

#include "grammar.h" /* grammar */
#include "node.h" /* node */

typedef struct {
int error;
#ifndef PGEN
Expand Down
5 changes: 3 additions & 2 deletions Include/symtable.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#ifndef Py_LIMITED_API
#ifndef Py_SYMTABLE_H
#define Py_SYMTABLE_H

#ifdef __cplusplus
extern "C" {
#endif

#include "Python-ast.h" /* mod_ty */

/* XXX(ncoghlan): This is a weird mix of public names and interpreter internal
* names.
*/
Expand Down Expand Up @@ -115,4 +116,4 @@ PyAPI_FUNC(void) PySymtable_Free(struct symtable *);
}
#endif
#endif /* !Py_SYMTABLE_H */
#endif /* Py_LIMITED_API */
#endif /* !Py_LIMITED_API */
5 changes: 2 additions & 3 deletions Modules/parsermodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,14 @@

#include "Python.h" /* general Python API */
#include "Python-ast.h" /* mod_ty */
#include "ast.h"
#include "graminit.h" /* symbols defined in the grammar */
#include "node.h" /* internal parser structure */
#include "errcode.h" /* error codes for PyNode_*() */
#include "token.h" /* token definitions */
/* ISTERMINAL() / ISNONTERMINAL() */
#include "grammar.h"
#include "parsetok.h"
/* ISTERMINAL() / ISNONTERMINAL() */
#undef Yield
#include "ast.h"

extern grammar _PyParser_Grammar; /* From graminit.c */

Expand Down
16 changes: 15 additions & 1 deletion Parser/asdl_c.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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:
Expand Down
1 change: 0 additions & 1 deletion Python/ast_opt.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* AST Optimizer */
#include "Python.h"
#include "Python-ast.h"
#include "node.h"
#include "ast.h"


Expand Down
11 changes: 2 additions & 9 deletions Python/bltinmodule.c
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
/* Built-in functions */

#include "Python.h"
#include "Python-ast.h"
#include "pycore_state.h"

#include "node.h"
#include "code.h"

#include "asdl.h"
#include "ast.h"

#include <ctype.h>
#include "ast.h"
#include "pycore_state.h"

_Py_IDENTIFIER(__builtins__);
_Py_IDENTIFIER(__dict__);
Expand Down
1 change: 0 additions & 1 deletion Python/compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include "Python.h"

#include "Python-ast.h"
#include "node.h"
#include "ast.h"
#include "code.h"
#include "symtable.h"
Expand Down
1 change: 0 additions & 1 deletion Python/import.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include "Python.h"

#include "Python-ast.h"
#undef Yield /* undefine macro conflicting with winbase.h */
#include "pycore_hash.h"
#include "pycore_lifecycle.h"
#include "pycore_mem.h"
Expand Down
1 change: 0 additions & 1 deletion Python/pylifecycle.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include "Python.h"

#include "Python-ast.h"
#undef Yield /* undefine macro conflicting with winbase.h */
#include "pycore_context.h"
#include "pycore_hamt.h"
#include "pycore_lifecycle.h"
Expand Down
1 change: 0 additions & 1 deletion Python/pythonrun.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include "Python.h"

#include "Python-ast.h"
#undef Yield /* undefine macro conflicting with winbase.h */
#include "pycore_state.h"
#include "grammar.h"
#include "node.h"
Expand Down
5 changes: 0 additions & 5 deletions Python/symtable.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
#include "Python.h"
#include "pycore_state.h"
#ifdef Yield
#undef Yield /* undefine conflicting macro from winbase.h */
#endif
#include "Python-ast.h"
#include "code.h"
#include "symtable.h"
#include "structmember.h"

Expand Down