Guido van Rossum | f70e43a | 1991-02-19 12:39:46 +0000 | [diff] [blame] | 1 | |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 2 | /* Function object interface */ |
| 3 | |
Fred Drake | ea9cb5a | 2000-07-09 00:20:36 +0000 | [diff] [blame] | 4 | #ifndef Py_FUNCOBJECT_H |
| 5 | #define Py_FUNCOBJECT_H |
| 6 | #ifdef __cplusplus |
| 7 | extern "C" { |
| 8 | #endif |
| 9 | |
Guido van Rossum | 2583165 | 1993-05-19 14:50:45 +0000 | [diff] [blame] | 10 | typedef struct { |
Fred Drake | ea9cb5a | 2000-07-09 00:20:36 +0000 | [diff] [blame] | 11 | PyObject_HEAD |
| 12 | PyObject *func_code; |
| 13 | PyObject *func_globals; |
| 14 | PyObject *func_defaults; |
Jeremy Hylton | 64949cb | 2001-01-25 20:06:59 +0000 | [diff] [blame] | 15 | PyObject *func_closure; |
Fred Drake | ea9cb5a | 2000-07-09 00:20:36 +0000 | [diff] [blame] | 16 | PyObject *func_doc; |
| 17 | PyObject *func_name; |
Barry Warsaw | d6a9e84 | 2001-01-15 20:40:19 +0000 | [diff] [blame] | 18 | PyObject *func_dict; |
Fred Drake | 6a1c87d | 2001-03-23 04:17:58 +0000 | [diff] [blame] | 19 | PyObject *func_weakreflist; |
Jeremy Hylton | 4f0dcc9 | 2003-01-31 18:33:18 +0000 | [diff] [blame] | 20 | PyObject *func_module; |
Guido van Rossum | caa6380 | 1995-01-12 11:45:45 +0000 | [diff] [blame] | 21 | } PyFunctionObject; |
Guido van Rossum | 2583165 | 1993-05-19 14:50:45 +0000 | [diff] [blame] | 22 | |
Mark Hammond | 91a681d | 2002-08-12 07:21:58 +0000 | [diff] [blame] | 23 | PyAPI_DATA(PyTypeObject) PyFunction_Type; |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 24 | |
Guido van Rossum | caa6380 | 1995-01-12 11:45:45 +0000 | [diff] [blame] | 25 | #define PyFunction_Check(op) ((op)->ob_type == &PyFunction_Type) |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 26 | |
Mark Hammond | 91a681d | 2002-08-12 07:21:58 +0000 | [diff] [blame] | 27 | PyAPI_FUNC(PyObject *) PyFunction_New(PyObject *, PyObject *); |
| 28 | PyAPI_FUNC(PyObject *) PyFunction_GetCode(PyObject *); |
| 29 | PyAPI_FUNC(PyObject *) PyFunction_GetGlobals(PyObject *); |
Jeremy Hylton | 4f0dcc9 | 2003-01-31 18:33:18 +0000 | [diff] [blame] | 30 | PyAPI_FUNC(PyObject *) PyFunction_GetModule(PyObject *); |
Mark Hammond | 91a681d | 2002-08-12 07:21:58 +0000 | [diff] [blame] | 31 | PyAPI_FUNC(PyObject *) PyFunction_GetDefaults(PyObject *); |
| 32 | PyAPI_FUNC(int) PyFunction_SetDefaults(PyObject *, PyObject *); |
| 33 | PyAPI_FUNC(PyObject *) PyFunction_GetClosure(PyObject *); |
| 34 | PyAPI_FUNC(int) PyFunction_SetClosure(PyObject *, PyObject *); |
Guido van Rossum | a330996 | 1993-07-28 09:05:47 +0000 | [diff] [blame] | 35 | |
Guido van Rossum | ba0d061 | 1998-07-10 15:47:08 +0000 | [diff] [blame] | 36 | /* Macros for direct access to these values. Type checks are *not* |
| 37 | done, so use with care. */ |
| 38 | #define PyFunction_GET_CODE(func) \ |
| 39 | (((PyFunctionObject *)func) -> func_code) |
| 40 | #define PyFunction_GET_GLOBALS(func) \ |
| 41 | (((PyFunctionObject *)func) -> func_globals) |
Jeremy Hylton | 4f0dcc9 | 2003-01-31 18:33:18 +0000 | [diff] [blame] | 42 | #define PyFunction_GET_MODULE(func) \ |
| 43 | (((PyFunctionObject *)func) -> func_module) |
Guido van Rossum | ba0d061 | 1998-07-10 15:47:08 +0000 | [diff] [blame] | 44 | #define PyFunction_GET_DEFAULTS(func) \ |
| 45 | (((PyFunctionObject *)func) -> func_defaults) |
Jeremy Hylton | 64949cb | 2001-01-25 20:06:59 +0000 | [diff] [blame] | 46 | #define PyFunction_GET_CLOSURE(func) \ |
| 47 | (((PyFunctionObject *)func) -> func_closure) |
Guido van Rossum | ba0d061 | 1998-07-10 15:47:08 +0000 | [diff] [blame] | 48 | |
Tim Peters | 6d6c1a3 | 2001-08-02 04:15:00 +0000 | [diff] [blame] | 49 | /* The classmethod and staticmethod types lives here, too */ |
Mark Hammond | 91a681d | 2002-08-12 07:21:58 +0000 | [diff] [blame] | 50 | PyAPI_DATA(PyTypeObject) PyClassMethod_Type; |
| 51 | PyAPI_DATA(PyTypeObject) PyStaticMethod_Type; |
Tim Peters | 6d6c1a3 | 2001-08-02 04:15:00 +0000 | [diff] [blame] | 52 | |
Mark Hammond | 91a681d | 2002-08-12 07:21:58 +0000 | [diff] [blame] | 53 | PyAPI_FUNC(PyObject *) PyClassMethod_New(PyObject *); |
| 54 | PyAPI_FUNC(PyObject *) PyStaticMethod_New(PyObject *); |
Tim Peters | 6d6c1a3 | 2001-08-02 04:15:00 +0000 | [diff] [blame] | 55 | |
Guido van Rossum | a330996 | 1993-07-28 09:05:47 +0000 | [diff] [blame] | 56 | #ifdef __cplusplus |
| 57 | } |
| 58 | #endif |
| 59 | #endif /* !Py_FUNCOBJECT_H */ |