]>
Commit | Line | Data |
---|---|---|
4710c53d | 1 | /*\r |
2 | CObjects are marked Pending Deprecation as of Python 2.7.\r | |
3 | The full schedule for 2.x is as follows:\r | |
4 | - CObjects are marked Pending Deprecation in Python 2.7.\r | |
5 | - CObjects will be marked Deprecated in Python 2.8\r | |
6 | (if there is one).\r | |
7 | - CObjects will be removed in Python 2.9 (if there is one).\r | |
8 | \r | |
9 | Additionally, for the Python 3.x series:\r | |
10 | - CObjects were marked Deprecated in Python 3.1.\r | |
11 | - CObjects will be removed in Python 3.2.\r | |
12 | \r | |
13 | You should switch all use of CObjects to capsules. Capsules\r | |
14 | have a safer and more consistent API. For more information,\r | |
15 | see Include/pycapsule.h, or read the "Capsules" topic in\r | |
16 | the "Python/C API Reference Manual".\r | |
17 | \r | |
18 | Python 2.7 no longer uses CObjects itself; all objects which\r | |
19 | were formerly CObjects are now capsules. Note that this change\r | |
20 | does not by itself break binary compatibility with extensions\r | |
21 | built for previous versions of Python--PyCObject_AsVoidPtr()\r | |
22 | has been changed to also understand capsules.\r | |
23 | \r | |
24 | */\r | |
25 | \r | |
26 | /* original file header comment follows: */\r | |
27 | \r | |
28 | /* C objects to be exported from one extension module to another.\r | |
29 | \r | |
30 | C objects are used for communication between extension modules.\r | |
31 | They provide a way for an extension module to export a C interface\r | |
32 | to other extension modules, so that extension modules can use the\r | |
33 | Python import mechanism to link to one another.\r | |
34 | \r | |
35 | */\r | |
36 | \r | |
37 | #ifndef Py_COBJECT_H\r | |
38 | #define Py_COBJECT_H\r | |
39 | #ifdef __cplusplus\r | |
40 | extern "C" {\r | |
41 | #endif\r | |
42 | \r | |
43 | PyAPI_DATA(PyTypeObject) PyCObject_Type;\r | |
44 | \r | |
45 | #define PyCObject_Check(op) (Py_TYPE(op) == &PyCObject_Type)\r | |
46 | \r | |
47 | /* Create a PyCObject from a pointer to a C object and an optional\r | |
48 | destructor function. If the second argument is non-null, then it\r | |
49 | will be called with the first argument if and when the PyCObject is\r | |
50 | destroyed.\r | |
51 | \r | |
52 | */\r | |
53 | PyAPI_FUNC(PyObject *) PyCObject_FromVoidPtr(\r | |
54 | void *cobj, void (*destruct)(void*));\r | |
55 | \r | |
56 | \r | |
57 | /* Create a PyCObject from a pointer to a C object, a description object,\r | |
58 | and an optional destructor function. If the third argument is non-null,\r | |
59 | then it will be called with the first and second arguments if and when \r | |
60 | the PyCObject is destroyed.\r | |
61 | */\r | |
62 | PyAPI_FUNC(PyObject *) PyCObject_FromVoidPtrAndDesc(\r | |
63 | void *cobj, void *desc, void (*destruct)(void*,void*));\r | |
64 | \r | |
65 | /* Retrieve a pointer to a C object from a PyCObject. */\r | |
66 | PyAPI_FUNC(void *) PyCObject_AsVoidPtr(PyObject *);\r | |
67 | \r | |
68 | /* Retrieve a pointer to a description object from a PyCObject. */\r | |
69 | PyAPI_FUNC(void *) PyCObject_GetDesc(PyObject *);\r | |
70 | \r | |
71 | /* Import a pointer to a C object from a module using a PyCObject. */\r | |
72 | PyAPI_FUNC(void *) PyCObject_Import(char *module_name, char *cobject_name);\r | |
73 | \r | |
74 | /* Modify a C object. Fails (==0) if object has a destructor. */\r | |
75 | PyAPI_FUNC(int) PyCObject_SetVoidPtr(PyObject *self, void *cobj);\r | |
76 | \r | |
77 | \r | |
78 | typedef struct {\r | |
79 | PyObject_HEAD\r | |
80 | void *cobject;\r | |
81 | void *desc;\r | |
82 | void (*destructor)(void *);\r | |
83 | } PyCObject;\r | |
84 | \r | |
85 | \r | |
86 | #ifdef __cplusplus\r | |
87 | }\r | |
88 | #endif\r | |
89 | #endif /* !Py_COBJECT_H */\r |