Mercurial > cpython-lru_cache-weakref
annotate Include/funcobject.h @ 64158:ea0decd2acfb
Fix typo
| author | Éric Araujo <merwok@netwok.org> |
|---|---|
| date | Wed, 18 Aug 2010 22:35:23 +0000 |
| parents | 86a2679dca46 |
| children | 62b61abd02b8 |
| rev | line source |
|---|---|
| 145 | 1 |
| 6 | 2 /* Function object interface */ |
| 3 | |
|
13444
5709ddba423c
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
4 #ifndef Py_FUNCOBJECT_H |
|
5709ddba423c
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
5 #define Py_FUNCOBJECT_H |
|
5709ddba423c
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
6 #ifdef __cplusplus |
|
5709ddba423c
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
7 extern "C" { |
|
5709ddba423c
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
8 #endif |
|
5709ddba423c
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
9 |
|
33856
60c60dc75c77
Wrote down the invariants of some common objects whose structure is
Armin Rigo <arigo@tunes.org>
parents:
27559
diff
changeset
|
10 /* Function objects and code objects should not be confused with each other: |
|
60c60dc75c77
Wrote down the invariants of some common objects whose structure is
Armin Rigo <arigo@tunes.org>
parents:
27559
diff
changeset
|
11 * |
|
60c60dc75c77
Wrote down the invariants of some common objects whose structure is
Armin Rigo <arigo@tunes.org>
parents:
27559
diff
changeset
|
12 * Function objects are created by the execution of the 'def' statement. |
| 42832 | 13 * They reference a code object in their __code__ attribute, which is a |
|
33856
60c60dc75c77
Wrote down the invariants of some common objects whose structure is
Armin Rigo <arigo@tunes.org>
parents:
27559
diff
changeset
|
14 * purely syntactic object, i.e. nothing more than a compiled version of some |
|
60c60dc75c77
Wrote down the invariants of some common objects whose structure is
Armin Rigo <arigo@tunes.org>
parents:
27559
diff
changeset
|
15 * source code lines. There is one code object per source code "fragment", |
|
60c60dc75c77
Wrote down the invariants of some common objects whose structure is
Armin Rigo <arigo@tunes.org>
parents:
27559
diff
changeset
|
16 * but each code object can be referenced by zero or many function objects |
|
60c60dc75c77
Wrote down the invariants of some common objects whose structure is
Armin Rigo <arigo@tunes.org>
parents:
27559
diff
changeset
|
17 * depending only on how many times the 'def' statement in the source was |
|
60c60dc75c77
Wrote down the invariants of some common objects whose structure is
Armin Rigo <arigo@tunes.org>
parents:
27559
diff
changeset
|
18 * executed so far. |
|
60c60dc75c77
Wrote down the invariants of some common objects whose structure is
Armin Rigo <arigo@tunes.org>
parents:
27559
diff
changeset
|
19 */ |
|
60c60dc75c77
Wrote down the invariants of some common objects whose structure is
Armin Rigo <arigo@tunes.org>
parents:
27559
diff
changeset
|
20 |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
21 typedef struct { |
|
13444
5709ddba423c
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
22 PyObject_HEAD |
| 42832 | 23 PyObject *func_code; /* A code object, the __code__ attribute */ |
|
33856
60c60dc75c77
Wrote down the invariants of some common objects whose structure is
Armin Rigo <arigo@tunes.org>
parents:
27559
diff
changeset
|
24 PyObject *func_globals; /* A dictionary (other mappings won't do) */ |
|
60c60dc75c77
Wrote down the invariants of some common objects whose structure is
Armin Rigo <arigo@tunes.org>
parents:
27559
diff
changeset
|
25 PyObject *func_defaults; /* NULL or a tuple */ |
|
40215
1cce0526d9b0
Jiwon Seo's PEP 3102 implementation.
Guido van Rossum <guido@python.org>
parents:
33856
diff
changeset
|
26 PyObject *func_kwdefaults; /* NULL or a dict */ |
|
33856
60c60dc75c77
Wrote down the invariants of some common objects whose structure is
Armin Rigo <arigo@tunes.org>
parents:
27559
diff
changeset
|
27 PyObject *func_closure; /* NULL or a tuple of cell objects */ |
|
60c60dc75c77
Wrote down the invariants of some common objects whose structure is
Armin Rigo <arigo@tunes.org>
parents:
27559
diff
changeset
|
28 PyObject *func_doc; /* The __doc__ attribute, can be anything */ |
|
60c60dc75c77
Wrote down the invariants of some common objects whose structure is
Armin Rigo <arigo@tunes.org>
parents:
27559
diff
changeset
|
29 PyObject *func_name; /* The __name__ attribute, a string object */ |
|
60c60dc75c77
Wrote down the invariants of some common objects whose structure is
Armin Rigo <arigo@tunes.org>
parents:
27559
diff
changeset
|
30 PyObject *func_dict; /* The __dict__ attribute, a dict or NULL */ |
|
60c60dc75c77
Wrote down the invariants of some common objects whose structure is
Armin Rigo <arigo@tunes.org>
parents:
27559
diff
changeset
|
31 PyObject *func_weakreflist; /* List of weak references */ |
|
60c60dc75c77
Wrote down the invariants of some common objects whose structure is
Armin Rigo <arigo@tunes.org>
parents:
27559
diff
changeset
|
32 PyObject *func_module; /* The __module__ attribute, can be anything */ |
|
40529
54cd47788811
PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents:
40215
diff
changeset
|
33 PyObject *func_annotations; /* Annotations, a dict or NULL */ |
|
33856
60c60dc75c77
Wrote down the invariants of some common objects whose structure is
Armin Rigo <arigo@tunes.org>
parents:
27559
diff
changeset
|
34 |
|
60c60dc75c77
Wrote down the invariants of some common objects whose structure is
Armin Rigo <arigo@tunes.org>
parents:
27559
diff
changeset
|
35 /* Invariant: |
|
60c60dc75c77
Wrote down the invariants of some common objects whose structure is
Armin Rigo <arigo@tunes.org>
parents:
27559
diff
changeset
|
36 * func_closure contains the bindings for func_code->co_freevars, so |
|
60c60dc75c77
Wrote down the invariants of some common objects whose structure is
Armin Rigo <arigo@tunes.org>
parents:
27559
diff
changeset
|
37 * PyTuple_Size(func_closure) == PyCode_GetNumFree(func_code) |
|
60c60dc75c77
Wrote down the invariants of some common objects whose structure is
Armin Rigo <arigo@tunes.org>
parents:
27559
diff
changeset
|
38 * (func_closure may be NULL if PyCode_GetNumFree(func_code) == 0). |
|
60c60dc75c77
Wrote down the invariants of some common objects whose structure is
Armin Rigo <arigo@tunes.org>
parents:
27559
diff
changeset
|
39 */ |
|
2129
05360cd616ae
The great renaming, phase two: all header files have been updated to
Guido van Rossum <guido@python.org>
parents:
2073
diff
changeset
|
40 } PyFunctionObject; |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
41 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
18933
diff
changeset
|
42 PyAPI_DATA(PyTypeObject) PyFunction_Type; |
| 6 | 43 |
|
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:
42832
diff
changeset
|
44 #define PyFunction_Check(op) (Py_TYPE(op) == &PyFunction_Type) |
| 6 | 45 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
18933
diff
changeset
|
46 PyAPI_FUNC(PyObject *) PyFunction_New(PyObject *, PyObject *); |
|
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
18933
diff
changeset
|
47 PyAPI_FUNC(PyObject *) PyFunction_GetCode(PyObject *); |
|
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
18933
diff
changeset
|
48 PyAPI_FUNC(PyObject *) PyFunction_GetGlobals(PyObject *); |
|
27559
faabd9867fb8
Provide __module__ attributes for functions defined in C and Python.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
24752
diff
changeset
|
49 PyAPI_FUNC(PyObject *) PyFunction_GetModule(PyObject *); |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
18933
diff
changeset
|
50 PyAPI_FUNC(PyObject *) PyFunction_GetDefaults(PyObject *); |
|
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
18933
diff
changeset
|
51 PyAPI_FUNC(int) PyFunction_SetDefaults(PyObject *, PyObject *); |
|
40215
1cce0526d9b0
Jiwon Seo's PEP 3102 implementation.
Guido van Rossum <guido@python.org>
parents:
33856
diff
changeset
|
52 PyAPI_FUNC(PyObject *) PyFunction_GetKwDefaults(PyObject *); |
|
1cce0526d9b0
Jiwon Seo's PEP 3102 implementation.
Guido van Rossum <guido@python.org>
parents:
33856
diff
changeset
|
53 PyAPI_FUNC(int) PyFunction_SetKwDefaults(PyObject *, PyObject *); |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
18933
diff
changeset
|
54 PyAPI_FUNC(PyObject *) PyFunction_GetClosure(PyObject *); |
|
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
18933
diff
changeset
|
55 PyAPI_FUNC(int) PyFunction_SetClosure(PyObject *, PyObject *); |
|
40529
54cd47788811
PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents:
40215
diff
changeset
|
56 PyAPI_FUNC(PyObject *) PyFunction_GetAnnotations(PyObject *); |
|
54cd47788811
PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents:
40215
diff
changeset
|
57 PyAPI_FUNC(int) PyFunction_SetAnnotations(PyObject *, PyObject *); |
|
1329
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
58 |
|
8658
1e93fa021405
Add macros for direct access to the members of CFunction objects.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
59 /* Macros for direct access to these values. Type checks are *not* |
|
1e93fa021405
Add macros for direct access to the members of CFunction objects.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
60 done, so use with care. */ |
|
1e93fa021405
Add macros for direct access to the members of CFunction objects.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
61 #define PyFunction_GET_CODE(func) \ |
|
1e93fa021405
Add macros for direct access to the members of CFunction objects.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
62 (((PyFunctionObject *)func) -> func_code) |
|
1e93fa021405
Add macros for direct access to the members of CFunction objects.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
63 #define PyFunction_GET_GLOBALS(func) \ |
|
1e93fa021405
Add macros for direct access to the members of CFunction objects.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
64 (((PyFunctionObject *)func) -> func_globals) |
|
27559
faabd9867fb8
Provide __module__ attributes for functions defined in C and Python.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
24752
diff
changeset
|
65 #define PyFunction_GET_MODULE(func) \ |
|
faabd9867fb8
Provide __module__ attributes for functions defined in C and Python.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
24752
diff
changeset
|
66 (((PyFunctionObject *)func) -> func_module) |
|
8658
1e93fa021405
Add macros for direct access to the members of CFunction objects.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
67 #define PyFunction_GET_DEFAULTS(func) \ |
|
1e93fa021405
Add macros for direct access to the members of CFunction objects.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
68 (((PyFunctionObject *)func) -> func_defaults) |
|
40215
1cce0526d9b0
Jiwon Seo's PEP 3102 implementation.
Guido van Rossum <guido@python.org>
parents:
33856
diff
changeset
|
69 #define PyFunction_GET_KW_DEFAULTS(func) \ |
|
1cce0526d9b0
Jiwon Seo's PEP 3102 implementation.
Guido van Rossum <guido@python.org>
parents:
33856
diff
changeset
|
70 (((PyFunctionObject *)func) -> func_kwdefaults) |
|
16257
fd8c7203251f
PEP 227 implementation
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
15894
diff
changeset
|
71 #define PyFunction_GET_CLOSURE(func) \ |
|
fd8c7203251f
PEP 227 implementation
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
15894
diff
changeset
|
72 (((PyFunctionObject *)func) -> func_closure) |
|
40529
54cd47788811
PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents:
40215
diff
changeset
|
73 #define PyFunction_GET_ANNOTATIONS(func) \ |
|
54cd47788811
PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents:
40215
diff
changeset
|
74 (((PyFunctionObject *)func) -> func_annotations) |
|
8658
1e93fa021405
Add macros for direct access to the members of CFunction objects.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
75 |
|
18933
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
17169
diff
changeset
|
76 /* The classmethod and staticmethod types lives here, too */ |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
18933
diff
changeset
|
77 PyAPI_DATA(PyTypeObject) PyClassMethod_Type; |
|
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
18933
diff
changeset
|
78 PyAPI_DATA(PyTypeObject) PyStaticMethod_Type; |
|
18933
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
17169
diff
changeset
|
79 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
18933
diff
changeset
|
80 PyAPI_FUNC(PyObject *) PyClassMethod_New(PyObject *); |
|
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
18933
diff
changeset
|
81 PyAPI_FUNC(PyObject *) PyStaticMethod_New(PyObject *); |
|
18933
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
17169
diff
changeset
|
82 |
|
1329
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
83 #ifdef __cplusplus |
|
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
84 } |
|
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
85 #endif |
|
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
86 #endif /* !Py_FUNCOBJECT_H */ |
