Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / tools / src / nas,5.n2.os.2 / lib / python / include / python2.4 / funcobject.h
CommitLineData
86530b38
AT
1#ifndef Py_FUNCOBJECT_H
2#define Py_FUNCOBJECT_H
3#ifdef __cplusplus
4extern "C" {
5#endif
6
7/* Function objects and code objects should not be confused with each other:
8 *
9 * Function objects are created by the execution of the 'def' statement.
10 * They reference a code object in their func_code attribute, which is a
11 * purely syntactic object, i.e. nothing more than a compiled version of some
12 * source code lines. There is one code object per source code "fragment",
13 * but each code object can be referenced by zero or many function objects
14 * depending only on how many times the 'def' statement in the source was
15 * executed so far.
16 */
17
18typedef struct {
19 PyObject_HEAD
20 PyObject *func_code; /* A code object */
21 PyObject *func_globals; /* A dictionary (other mappings won't do) */
22 PyObject *func_defaults; /* NULL or a tuple */
23 PyObject *func_closure; /* NULL or a tuple of cell objects */
24 PyObject *func_doc; /* The __doc__ attribute, can be anything */
25 PyObject *func_name; /* The __name__ attribute, a string object */
26 PyObject *func_dict; /* The __dict__ attribute, a dict or NULL */
27 PyObject *func_weakreflist; /* List of weak references */
28 PyObject *func_module; /* The __module__ attribute, can be anything */
29
30 /* Invariant:
31 * func_closure contains the bindings for func_code->co_freevars, so
32 * PyTuple_Size(func_closure) == PyCode_GetNumFree(func_code)
33 * (func_closure may be NULL if PyCode_GetNumFree(func_code) == 0).
34 */
35} PyFunctionObject;
36
37PyAPI_DATA(PyTypeObject) PyFunction_Type;
38
39#define PyFunction_Check(op) ((op)->ob_type == &PyFunction_Type)
40
41PyAPI_FUNC(PyObject *) PyFunction_New(PyObject *, PyObject *);
42PyAPI_FUNC(PyObject *) PyFunction_GetCode(PyObject *);
43PyAPI_FUNC(PyObject *) PyFunction_GetGlobals(PyObject *);
44PyAPI_FUNC(PyObject *) PyFunction_GetModule(PyObject *);
45PyAPI_FUNC(PyObject *) PyFunction_GetDefaults(PyObject *);
46PyAPI_FUNC(int) PyFunction_SetDefaults(PyObject *, PyObject *);
47PyAPI_FUNC(PyObject *) PyFunction_GetClosure(PyObject *);
48PyAPI_FUNC(int) PyFunction_SetClosure(PyObject *, PyObject *);
49
50/* Macros for direct access to these values. Type checks are *not*
51 done, so use with care. */
52#define PyFunction_GET_CODE(func) \
53 (((PyFunctionObject *)func) -> func_code)
54#define PyFunction_GET_GLOBALS(func) \
55 (((PyFunctionObject *)func) -> func_globals)
56#define PyFunction_GET_MODULE(func) \
57 (((PyFunctionObject *)func) -> func_module)
58#define PyFunction_GET_DEFAULTS(func) \
59 (((PyFunctionObject *)func) -> func_defaults)
60#define PyFunction_GET_CLOSURE(func) \
61 (((PyFunctionObject *)func) -> func_closure)
62
63/* The classmethod and staticmethod types lives here, too */
64PyAPI_DATA(PyTypeObject) PyClassMethod_Type;
65PyAPI_DATA(PyTypeObject) PyStaticMethod_Type;
66
67PyAPI_FUNC(PyObject *) PyClassMethod_New(PyObject *);
68PyAPI_FUNC(PyObject *) PyStaticMethod_New(PyObject *);
69
70#ifdef __cplusplus
71}
72#endif
73#endif /* !Py_FUNCOBJECT_H */