blob: c8e97fdc0d6562f67294ecc0126c0130fc5dd096 [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;
Guido van Rossumcaa63801995-01-12 11:45:45 +000019} PyFunctionObject;
Guido van Rossum25831651993-05-19 14:50:45 +000020
Guido van Rossum051ab121995-02-27 10:17:52 +000021extern DL_IMPORT(PyTypeObject) PyFunction_Type;
Guido van Rossum85a5fbb1990-10-14 12:07:46 +000022
Guido van Rossumcaa63801995-01-12 11:45:45 +000023#define PyFunction_Check(op) ((op)->ob_type == &PyFunction_Type)
Guido van Rossum85a5fbb1990-10-14 12:07:46 +000024
Fred Drakeea9cb5a2000-07-09 00:20:36 +000025extern DL_IMPORT(PyObject *) PyFunction_New(PyObject *, PyObject *);
26extern DL_IMPORT(PyObject *) PyFunction_GetCode(PyObject *);
27extern DL_IMPORT(PyObject *) PyFunction_GetGlobals(PyObject *);
28extern DL_IMPORT(PyObject *) PyFunction_GetDefaults(PyObject *);
29extern DL_IMPORT(int) PyFunction_SetDefaults(PyObject *, PyObject *);
Jeremy Hylton64949cb2001-01-25 20:06:59 +000030extern DL_IMPORT(PyObject *) PyFunction_GetClosure(PyObject *);
31extern DL_IMPORT(int) PyFunction_SetClosure(PyObject *, PyObject *);
Guido van Rossuma3309961993-07-28 09:05:47 +000032
Guido van Rossumba0d0611998-07-10 15:47:08 +000033/* Macros for direct access to these values. Type checks are *not*
34 done, so use with care. */
35#define PyFunction_GET_CODE(func) \
36 (((PyFunctionObject *)func) -> func_code)
37#define PyFunction_GET_GLOBALS(func) \
38 (((PyFunctionObject *)func) -> func_globals)
39#define PyFunction_GET_DEFAULTS(func) \
40 (((PyFunctionObject *)func) -> func_defaults)
Jeremy Hylton64949cb2001-01-25 20:06:59 +000041#define PyFunction_GET_CLOSURE(func) \
42 (((PyFunctionObject *)func) -> func_closure)
Guido van Rossumba0d0611998-07-10 15:47:08 +000043
Guido van Rossuma3309961993-07-28 09:05:47 +000044#ifdef __cplusplus
45}
46#endif
47#endif /* !Py_FUNCOBJECT_H */