Mercurial > cpython-lru_cache-weakref
annotate Include/funcobject.h @ 49955:878d40468c4e legacy-trunk
Issue #4384: Added logging integration with warnings module using captureWarnings(). This change includes a NullHandler which does nothing; it will be of use to library developers who want to avoid the "No handlers could be found for logger XXX" message which can appear if the library user doesn't configure logging.
| author | Vinay Sajip <vinay_sajip@yahoo.co.uk> |
|---|---|
| date | Wed, 03 Dec 2008 23:22:58 +0000 |
| parents | 26384b8180c7 |
| children |
| 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. |
|
60c60dc75c77
Wrote down the invariants of some common objects whose structure is
Armin Rigo <arigo@tunes.org>
parents:
27559
diff
changeset
|
13 * They reference a code object in their func_code attribute, which is a |
|
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 |
|
33856
60c60dc75c77
Wrote down the invariants of some common objects whose structure is
Armin Rigo <arigo@tunes.org>
parents:
27559
diff
changeset
|
23 PyObject *func_code; /* A code object */ |
|
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 */ |
|
60c60dc75c77
Wrote down the invariants of some common objects whose structure is
Armin Rigo <arigo@tunes.org>
parents:
27559
diff
changeset
|
26 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
|
27 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
|
28 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
|
29 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
|
30 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
|
31 PyObject *func_module; /* The __module__ 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
|
32 |
|
60c60dc75c77
Wrote down the invariants of some common objects whose structure is
Armin Rigo <arigo@tunes.org>
parents:
27559
diff
changeset
|
33 /* Invariant: |
|
60c60dc75c77
Wrote down the invariants of some common objects whose structure is
Armin Rigo <arigo@tunes.org>
parents:
27559
diff
changeset
|
34 * 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
|
35 * 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
|
36 * (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
|
37 */ |
|
2129
05360cd616ae
The great renaming, phase two: all header files have been updated to
Guido van Rossum <guido@python.org>
parents:
2073
diff
changeset
|
38 } PyFunctionObject; |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
39 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
18933
diff
changeset
|
40 PyAPI_DATA(PyTypeObject) PyFunction_Type; |
| 6 | 41 |
|
44350
26384b8180c7
#1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT. Macros for b/w compatibility are available.
Christian Heimes <christian@cheimes.de>
parents:
42333
diff
changeset
|
42 #define PyFunction_Check(op) (Py_TYPE(op) == &PyFunction_Type) |
| 6 | 43 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
18933
diff
changeset
|
44 PyAPI_FUNC(PyObject *) PyFunction_New(PyObject *, PyObject *); |
|
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
18933
diff
changeset
|
45 PyAPI_FUNC(PyObject *) PyFunction_GetCode(PyObject *); |
|
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
18933
diff
changeset
|
46 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
|
47 PyAPI_FUNC(PyObject *) PyFunction_GetModule(PyObject *); |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
18933
diff
changeset
|
48 PyAPI_FUNC(PyObject *) PyFunction_GetDefaults(PyObject *); |
|
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
18933
diff
changeset
|
49 PyAPI_FUNC(int) PyFunction_SetDefaults(PyObject *, PyObject *); |
|
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
18933
diff
changeset
|
50 PyAPI_FUNC(PyObject *) PyFunction_GetClosure(PyObject *); |
|
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
18933
diff
changeset
|
51 PyAPI_FUNC(int) PyFunction_SetClosure(PyObject *, PyObject *); |
|
1329
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
52 |
|
8658
1e93fa021405
Add macros for direct access to the members of CFunction objects.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
53 /* 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
|
54 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
|
55 #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
|
56 (((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
|
57 #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
|
58 (((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
|
59 #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
|
60 (((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
|
61 #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
|
62 (((PyFunctionObject *)func) -> func_defaults) |
|
16257
fd8c7203251f
PEP 227 implementation
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
15894
diff
changeset
|
63 #define PyFunction_GET_CLOSURE(func) \ |
|
fd8c7203251f
PEP 227 implementation
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
15894
diff
changeset
|
64 (((PyFunctionObject *)func) -> func_closure) |
|
8658
1e93fa021405
Add macros for direct access to the members of CFunction objects.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
65 |
|
18933
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
17169
diff
changeset
|
66 /* 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
|
67 PyAPI_DATA(PyTypeObject) PyClassMethod_Type; |
|
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
18933
diff
changeset
|
68 PyAPI_DATA(PyTypeObject) PyStaticMethod_Type; |
|
18933
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
17169
diff
changeset
|
69 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
18933
diff
changeset
|
70 PyAPI_FUNC(PyObject *) PyClassMethod_New(PyObject *); |
|
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
18933
diff
changeset
|
71 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
|
72 |
|
1329
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
73 #ifdef __cplusplus |
|
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
74 } |
|
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
75 #endif |
|
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
76 #endif /* !Py_FUNCOBJECT_H */ |
