blob: 6b1e389b7ce762257c00da142a174170130fa78d [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;
Guido van Rossumcaa63801995-01-12 11:45:45 +000020} PyFunctionObject;
Guido van Rossum25831651993-05-19 14:50:45 +000021
Guido van Rossum051ab121995-02-27 10:17:52 +000022extern DL_IMPORT(PyTypeObject) PyFunction_Type;
Guido van Rossum85a5fbb1990-10-14 12:07:46 +000023
Guido van Rossumcaa63801995-01-12 11:45:45 +000024#define PyFunction_Check(op) ((op)->ob_type == &PyFunction_Type)
Guido van Rossum85a5fbb1990-10-14 12:07:46 +000025
Fred Drakeea9cb5a2000-07-09 00:20:36 +000026extern DL_IMPORT(PyObject *) PyFunction_New(PyObject *, PyObject *);
27extern DL_IMPORT(PyObject *) PyFunction_GetCode(PyObject *);
28extern DL_IMPORT(PyObject *) PyFunction_GetGlobals(PyObject *);
29extern DL_IMPORT(PyObject *) PyFunction_GetDefaults(PyObject *);
30extern DL_IMPORT(int) PyFunction_SetDefaults(PyObject *, PyObject *);
Jeremy Hylton64949cb2001-01-25 20:06:59 +000031extern DL_IMPORT(PyObject *) PyFunction_GetClosure(PyObject *);
32extern DL_IMPORT(int) PyFunction_SetClosure(PyObject *, PyObject *);
Guido van Rossuma3309961993-07-28 09:05:47 +000033
Guido van Rossumba0d0611998-07-10 15:47:08 +000034/* Macros for direct access to these values. Type checks are *not*
35 done, so use with care. */
36#define PyFunction_GET_CODE(func) \
37 (((PyFunctionObject *)func) -> func_code)
38#define PyFunction_GET_GLOBALS(func) \
39 (((PyFunctionObject *)func) -> func_globals)
40#define PyFunction_GET_DEFAULTS(func) \
41 (((PyFunctionObject *)func) -> func_defaults)
Jeremy Hylton64949cb2001-01-25 20:06:59 +000042#define PyFunction_GET_CLOSURE(func) \
43 (((PyFunctionObject *)func) -> func_closure)
Guido van Rossumba0d0611998-07-10 15:47:08 +000044
Tim Peters6d6c1a32001-08-02 04:15:00 +000045/* The classmethod and staticmethod types lives here, too */
46extern DL_IMPORT(PyTypeObject) PyClassMethod_Type;
47extern DL_IMPORT(PyTypeObject) PyStaticMethod_Type;
48
49extern DL_IMPORT(PyObject *) PyClassMethod_New(PyObject *);
50extern DL_IMPORT(PyObject *) PyStaticMethod_New(PyObject *);
51
Guido van Rossuma3309961993-07-28 09:05:47 +000052#ifdef __cplusplus
53}
54#endif
55#endif /* !Py_FUNCOBJECT_H */