PageRenderTime 52ms CodeModel.GetById 42ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/Include/classobject.h

http://unladen-swallow.googlecode.com/
C++ Header | 84 lines | 53 code | 15 blank | 16 comment | 3 complexity | 8595b37bbfbbda172fa013c590a5bd91 MD5 | raw file
 1
 2/* Class object interface */
 3
 4/* Revealing some structures (not for general use) */
 5
 6#ifndef Py_CLASSOBJECT_H
 7#define Py_CLASSOBJECT_H
 8#ifdef __cplusplus
 9extern "C" {
10#endif
11
12typedef struct {
13    PyObject_HEAD
14    PyObject	*cl_bases;	/* A tuple of class objects */
15    PyObject	*cl_dict;	/* A dictionary */
16    PyObject	*cl_name;	/* A string */
17    /* The following three are functions or NULL */
18    PyObject	*cl_getattr;
19    PyObject	*cl_setattr;
20    PyObject	*cl_delattr;
21} PyClassObject;
22
23typedef struct {
24    PyObject_HEAD
25    PyClassObject *in_class;	/* The class object */
26    PyObject	  *in_dict;	/* A dictionary */
27    PyObject	  *in_weakreflist; /* List of weak references */
28} PyInstanceObject;
29
30/* If you change this, update Util/PyTypeBuilder.h accordingly. */
31typedef struct PyMethodObject {
32    PyObject_HEAD
33    PyObject *im_func;   /* The callable object implementing the method */
34    PyObject *im_self;   /* The instance it is bound to, or NULL */
35    PyObject *im_class;  /* The class that asked for the method */
36    PyObject *im_weakreflist; /* List of weak references */
37} PyMethodObject;
38
39PyAPI_DATA(PyTypeObject) PyClass_Type, PyInstance_Type, PyMethod_Type;
40
41#define PyClass_Check(op) ((op)->ob_type == &PyClass_Type)
42#define PyInstance_Check(op) ((op)->ob_type == &PyInstance_Type)
43#define PyMethod_Check(op) ((op)->ob_type == &PyMethod_Type)
44
45PyAPI_FUNC(PyObject *) PyClass_New(PyObject *, PyObject *, PyObject *);
46PyAPI_FUNC(PyObject *) PyInstance_New(PyObject *, PyObject *,
47                                            PyObject *);
48PyAPI_FUNC(PyObject *) PyInstance_NewRaw(PyObject *, PyObject *);
49PyAPI_FUNC(PyObject *) PyMethod_New(PyObject *, PyObject *, PyObject *);
50
51PyAPI_FUNC(PyObject *) PyMethod_Function(PyObject *);
52PyAPI_FUNC(PyObject *) PyMethod_Self(PyObject *);
53PyAPI_FUNC(PyObject *) PyMethod_Class(PyObject *);
54PyAPI_FUNC(int) _PyMethod_ShouldBind(PyObject *, PyObject *);
55
56/* Look up attribute with name (a string) on instance object pinst, using
57 * only the instance and base class dicts.  If a descriptor is found in
58 * a class dict, the descriptor is returned without calling it.
59 * Returns NULL if nothing found, else a borrowed reference to the
60 * value associated with name in the dict in which name was found.
61 * The point of this routine is that it never calls arbitrary Python
62 * code, so is always "safe":  all it does is dict lookups.  The function
63 * can't fail, never sets an exception, and NULL is not an error (it just
64 * means "not found").
65 */
66PyAPI_FUNC(PyObject *) _PyInstance_Lookup(PyObject *pinst, PyObject *name);
67
68/* Macros for direct access to these values. Type checks are *not*
69   done, so use with care. */
70#define PyMethod_GET_FUNCTION(meth) \
71        (((PyMethodObject *)meth) -> im_func)
72#define PyMethod_GET_SELF(meth) \
73	(((PyMethodObject *)meth) -> im_self)
74#define PyMethod_GET_CLASS(meth) \
75	(((PyMethodObject *)meth) -> im_class)
76
77PyAPI_FUNC(int) PyClass_IsSubclass(PyObject *, PyObject *);
78
79PyAPI_FUNC(int) PyMethod_ClearFreeList(void);
80
81#ifdef __cplusplus
82}
83#endif
84#endif /* !Py_CLASSOBJECT_H */