blob: 758c76dcb9d1e0dcd15c5a5ed668b0d4e4f58349 [file] [log] [blame]
Guido van Rossumf70e43a1991-02-19 12:39:46 +00001
Guido van Rossum85a5fbb1990-10-14 12:07:46 +00002/* Function object interface */
3
Fred Drakeea9cb5a2000-07-09 00:20:36 +00004#ifndef Py_FUNCOBJECT_H
5#define Py_FUNCOBJECT_H
6#ifdef __cplusplus
7extern "C" {
8#endif
9
Guido van Rossum25831651993-05-19 14:50:45 +000010typedef struct {
Fred Drakeea9cb5a2000-07-09 00:20:36 +000011 PyObject_HEAD
12 PyObject *func_code;
13 PyObject *func_globals;
14 PyObject *func_defaults;
Jeremy Hylton64949cb2001-01-25 20:06:59 +000015 PyObject *func_closure;
Fred Drakeea9cb5a2000-07-09 00:20:36 +000016 PyObject *func_doc;
17 PyObject *func_name;
Barry Warsawd6a9e842001-01-15 20:40:19 +000018 PyObject *func_dict;
Fred Drake6a1c87d2001-03-23 04:17:58 +000019 PyObject *func_weakreflist;
Jeremy Hylton4f0dcc92003-01-31 18:33:18 +000020 PyObject *func_module;
Guido van Rossumcaa63801995-01-12 11:45:45 +000021} PyFunctionObject;
Guido van Rossum25831651993-05-19 14:50:45 +000022
Mark Hammond91a681d2002-08-12 07:21:58 +000023PyAPI_DATA(PyTypeObject) PyFunction_Type;
Guido van Rossum85a5fbb1990-10-14 12:07:46 +000024
Guido van Rossumcaa63801995-01-12 11:45:45 +000025#define PyFunction_Check(op) ((op)->ob_type == &PyFunction_Type)
Guido van Rossum85a5fbb1990-10-14 12:07:46 +000026
Mark Hammond91a681d2002-08-12 07:21:58 +000027PyAPI_FUNC(PyObject *) PyFunction_New(PyObject *, PyObject *);
28PyAPI_FUNC(PyObject *) PyFunction_GetCode(PyObject *);
29PyAPI_FUNC(PyObject *) PyFunction_GetGlobals(PyObject *);
Jeremy Hylton4f0dcc92003-01-31 18:33:18 +000030PyAPI_FUNC(PyObject *) PyFunction_GetModule(PyObject *);
Mark Hammond91a681d2002-08-12 07:21:58 +000031PyAPI_FUNC(PyObject *) PyFunction_GetDefaults(PyObject *);
32PyAPI_FUNC(int) PyFunction_SetDefaults(PyObject *, PyObject *);
33PyAPI_FUNC(PyObject *) PyFunction_GetClosure(PyObject *);
34PyAPI_FUNC(int) PyFunction_SetClosure(PyObject *, PyObject *);
Guido van Rossuma3309961993-07-28 09:05:47 +000035
Guido van Rossumba0d0611998-07-10 15:47:08 +000036/* 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 Hylton4f0dcc92003-01-31 18:33:18 +000042#define PyFunction_GET_MODULE(func) \
43 (((PyFunctionObject *)func) -> func_module)
Guido van Rossumba0d0611998-07-10 15:47:08 +000044#define PyFunction_GET_DEFAULTS(func) \
45 (((PyFunctionObject *)func) -> func_defaults)
Jeremy Hylton64949cb2001-01-25 20:06:59 +000046#define PyFunction_GET_CLOSURE(func) \
47 (((PyFunctionObject *)func) -> func_closure)
Guido van Rossumba0d0611998-07-10 15:47:08 +000048
Tim Peters6d6c1a32001-08-02 04:15:00 +000049/* The classmethod and staticmethod types lives here, too */
Mark Hammond91a681d2002-08-12 07:21:58 +000050PyAPI_DATA(PyTypeObject) PyClassMethod_Type;
51PyAPI_DATA(PyTypeObject) PyStaticMethod_Type;
Tim Peters6d6c1a32001-08-02 04:15:00 +000052
Mark Hammond91a681d2002-08-12 07:21:58 +000053PyAPI_FUNC(PyObject *) PyClassMethod_New(PyObject *);
54PyAPI_FUNC(PyObject *) PyStaticMethod_New(PyObject *);
Tim Peters6d6c1a32001-08-02 04:15:00 +000055
Guido van Rossuma3309961993-07-28 09:05:47 +000056#ifdef __cplusplus
57}
58#endif
59#endif /* !Py_FUNCOBJECT_H */