annotate Include/symtable.h @ 78069:a8aa77458e12 3.2

Add c_size_t and c_ssize_t to the ctypes summary table.
author Antoine Pitrou <solipsis@pitrou.net>
date Thu, 12 Jul 2012 20:31:50 +0200
parents 3c9232a684ae
children b6fe63c914e4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 64861
diff changeset
1 #ifndef Py_LIMITED_API
16421
aa844711463a Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2 #ifndef Py_SYMTABLE_H
aa844711463a Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
3 #define Py_SYMTABLE_H
36739
796d150e45a9 No need to export PySTEntry_New, it is only used in symtable.c
Neal Norwitz <nnorwitz@gmail.com>
parents: 36227
diff changeset
4
16421
aa844711463a Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
5 #ifdef __cplusplus
aa844711463a Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
6 extern "C" {
aa844711463a Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
7 #endif
aa844711463a Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
8
41464
060c79f6d919 Hide list comp variables and support set comprehensions
Nick Coghlan <ncoghlan@gmail.com>
parents: 40965
diff changeset
9 /* XXX(ncoghlan): This is a weird mix of public names and interpreter internal
060c79f6d919 Hide list comp variables and support set comprehensions
Nick Coghlan <ncoghlan@gmail.com>
parents: 40965
diff changeset
10 * names.
060c79f6d919 Hide list comp variables and support set comprehensions
Nick Coghlan <ncoghlan@gmail.com>
parents: 40965
diff changeset
11 */
060c79f6d919 Hide list comp variables and support set comprehensions
Nick Coghlan <ncoghlan@gmail.com>
parents: 40965
diff changeset
12
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32121
diff changeset
13 typedef enum _block_type { FunctionBlock, ClassBlock, ModuleBlock }
35793
914ec0afa51c Do not pollute name block_ty, prefix with _Py_
Neal Norwitz <nnorwitz@gmail.com>
parents: 35779
diff changeset
14 _Py_block_ty;
16421
aa844711463a Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
15
16539
a47d93ef103a Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 16428
diff changeset
16 struct _symtable_entry;
16421
aa844711463a Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
17
aa844711463a Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
18 struct symtable {
67151
66d8446a019b Issue #9738: Document encodings of AST, compiler, parser and PyRun functions
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66664
diff changeset
19 const char *st_filename; /* name of file being compiled,
66d8446a019b Issue #9738: Document encodings of AST, compiler, parser and PyRun functions
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66664
diff changeset
20 decoded from the filesystem encoding */
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 48725
diff changeset
21 struct _symtable_entry *st_cur; /* current symbol table entry */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 48725
diff changeset
22 struct _symtable_entry *st_top; /* symbol table entry for module */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 48725
diff changeset
23 PyObject *st_blocks; /* dict: map AST node addresses
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 48725
diff changeset
24 * to symbol table entries */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 48725
diff changeset
25 PyObject *st_stack; /* list: stack of namespace info */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 48725
diff changeset
26 PyObject *st_global; /* borrowed ref to st_top->st_symbols */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 48725
diff changeset
27 int st_nblocks; /* number of blocks used */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 48725
diff changeset
28 PyObject *st_private; /* name of current class or NULL */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 48725
diff changeset
29 PyFutureFeatures *st_future; /* module's future features */
16421
aa844711463a Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
30 };
aa844711463a Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
31
16539
a47d93ef103a Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 16428
diff changeset
32 typedef struct _symtable_entry {
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 48725
diff changeset
33 PyObject_HEAD
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 48725
diff changeset
34 PyObject *ste_id; /* int: key in ste_table->st_blocks */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 48725
diff changeset
35 PyObject *ste_symbols; /* dict: variable names to flags */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 48725
diff changeset
36 PyObject *ste_name; /* string: name of current block */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 48725
diff changeset
37 PyObject *ste_varnames; /* list of variable names */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 48725
diff changeset
38 PyObject *ste_children; /* list of child blocks */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 48725
diff changeset
39 _Py_block_ty ste_type; /* module, class, or function */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 48725
diff changeset
40 int ste_unoptimized; /* false if namespace is optimized */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 48725
diff changeset
41 int ste_nested; /* true if block is nested */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 48725
diff changeset
42 unsigned ste_free : 1; /* true if block has free variables */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 48725
diff changeset
43 unsigned ste_child_free : 1; /* true if a child block has free vars,
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 48725
diff changeset
44 including free refs to globals */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 48725
diff changeset
45 unsigned ste_generator : 1; /* true if namespace is a generator */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 48725
diff changeset
46 unsigned ste_varargs : 1; /* true if block has varargs */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 48725
diff changeset
47 unsigned ste_varkeywords : 1; /* true if block has varkeywords */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 48725
diff changeset
48 unsigned ste_returns_value : 1; /* true if namespace uses return with
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 48725
diff changeset
49 an argument */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 48725
diff changeset
50 int ste_lineno; /* first line of block */
64861
861c35cef7aa add column offset to all syntax errors
Benjamin Peterson <benjamin@python.org>
parents: 63114
diff changeset
51 int ste_col_offset; /* offset of first line of block */
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 48725
diff changeset
52 int ste_opt_lineno; /* lineno of last exec or import * */
64861
861c35cef7aa add column offset to all syntax errors
Benjamin Peterson <benjamin@python.org>
parents: 63114
diff changeset
53 int ste_opt_col_offset; /* offset of last exec or import * */
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 48725
diff changeset
54 int ste_tmpname; /* counter for listcomp temp vars */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 48725
diff changeset
55 struct symtable *ste_table;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32121
diff changeset
56 } PySTEntryObject;
16539
a47d93ef103a Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 16428
diff changeset
57
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32121
diff changeset
58 PyAPI_DATA(PyTypeObject) PySTEntry_Type;
16539
a47d93ef103a Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 16428
diff changeset
59
44351
86a2679dca46 #1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT.
Christian Heimes <christian@cheimes.de>
parents: 42334
diff changeset
60 #define PySTEntry_Check(op) (Py_TYPE(op) == &PySTEntry_Type)
16539
a47d93ef103a Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 16428
diff changeset
61
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32121
diff changeset
62 PyAPI_FUNC(int) PyST_GetScope(PySTEntryObject *, PyObject *);
16539
a47d93ef103a Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 16428
diff changeset
63
67151
66d8446a019b Issue #9738: Document encodings of AST, compiler, parser and PyRun functions
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66664
diff changeset
64 PyAPI_FUNC(struct symtable *) PySymtable_Build(
66d8446a019b Issue #9738: Document encodings of AST, compiler, parser and PyRun functions
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66664
diff changeset
65 mod_ty mod,
66d8446a019b Issue #9738: Document encodings of AST, compiler, parser and PyRun functions
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66664
diff changeset
66 const char *filename, /* decoded from the filesystem encoding */
66d8446a019b Issue #9738: Document encodings of AST, compiler, parser and PyRun functions
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66664
diff changeset
67 PyFutureFeatures *future);
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32121
diff changeset
68 PyAPI_FUNC(PySTEntryObject *) PySymtable_Lookup(struct symtable *, void *);
16421
aa844711463a Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
69
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32121
diff changeset
70 PyAPI_FUNC(void) PySymtable_Free(struct symtable *);
16421
aa844711463a Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
71
aa844711463a Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
72 /* Flags for def-use information */
aa844711463a Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
73
aa844711463a Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
74 #define DEF_GLOBAL 1 /* global stmt */
aa844711463a Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
75 #define DEF_LOCAL 2 /* assignment in code block */
aa844711463a Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
76 #define DEF_PARAM 2<<1 /* formal parameter */
40965
30e5cb3a55ac Provisional implementation of PEP 3104.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 39782
diff changeset
77 #define DEF_NONLOCAL 2<<2 /* nonlocal stmt */
30e5cb3a55ac Provisional implementation of PEP 3104.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 39782
diff changeset
78 #define USE 2<<3 /* name is used */
54918
0704f15b4682 Merged revisions 73376,73393,73398,73400,73404-73405,73409,73419-73421,73432,73457,73460,73485-73486,73488-73489,73501-73502,73513-73514 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 48725
diff changeset
79 #define DEF_FREE 2<<4 /* name used but not defined in nested block */
0704f15b4682 Merged revisions 73376,73393,73398,73400,73404-73405,73409,73419-73421,73432,73457,73460,73485-73486,73488-73489,73501-73502,73513-73514 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 48725
diff changeset
80 #define DEF_FREE_CLASS 2<<5 /* free variable from class's method */
0704f15b4682 Merged revisions 73376,73393,73398,73400,73404-73405,73409,73419-73421,73432,73457,73460,73485-73486,73488-73489,73501-73502,73513-73514 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 48725
diff changeset
81 #define DEF_IMPORT 2<<6 /* assignment occurred via import */
16421
aa844711463a Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
82
16866
3a411d41eeb4 add DEF_BOUND
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 16799
diff changeset
83 #define DEF_BOUND (DEF_LOCAL | DEF_PARAM | DEF_IMPORT)
3a411d41eeb4 add DEF_BOUND
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 16799
diff changeset
84
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32121
diff changeset
85 /* GLOBAL_EXPLICIT and GLOBAL_IMPLICIT are used internally by the symbol
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 48725
diff changeset
86 table. GLOBAL is returned from PyST_GetScope() for either of them.
40965
30e5cb3a55ac Provisional implementation of PEP 3104.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 39782
diff changeset
87 It is stored in ste_symbols at bits 12-15.
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32121
diff changeset
88 */
41464
060c79f6d919 Hide list comp variables and support set comprehensions
Nick Coghlan <ncoghlan@gmail.com>
parents: 40965
diff changeset
89 #define SCOPE_OFFSET 11
40965
30e5cb3a55ac Provisional implementation of PEP 3104.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 39782
diff changeset
90 #define SCOPE_MASK (DEF_GLOBAL | DEF_LOCAL | DEF_PARAM | DEF_NONLOCAL)
16421
aa844711463a Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
91
aa844711463a Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
92 #define LOCAL 1
aa844711463a Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
93 #define GLOBAL_EXPLICIT 2
aa844711463a Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
94 #define GLOBAL_IMPLICIT 3
aa844711463a Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
95 #define FREE 4
aa844711463a Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
96 #define CELL 5
aa844711463a Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
97
39782
c94f37054f19 Patch #1550800: make exec a function.
Georg Brandl <georg@python.org>
parents: 38673
diff changeset
98 /* The following two names are used for the ste_unoptimized bit field */
16781
5a1230de436a Preliminary support for future nested scopes
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 16539
diff changeset
99 #define OPT_IMPORT_STAR 1
39782
c94f37054f19 Patch #1550800: make exec a function.
Georg Brandl <georg@python.org>
parents: 38673
diff changeset
100 #define OPT_TOPLEVEL 2 /* top-level names, including eval and exec */
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32121
diff changeset
101
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32121
diff changeset
102 #define GENERATOR 1
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32121
diff changeset
103 #define GENERATOR_EXPRESSION 2
16781
5a1230de436a Preliminary support for future nested scopes
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 16539
diff changeset
104
16421
aa844711463a Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
105 #ifdef __cplusplus
aa844711463a Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
106 }
aa844711463a Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
107 #endif
aa844711463a Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
108 #endif /* !Py_SYMTABLE_H */
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 64861
diff changeset
109 #endif /* Py_LIMITED_API */