Guido van Rossum | 77654a7 | 1996-01-12 00:44:03 +0000 | [diff] [blame] | 1 | #ifndef Py_COBJECT_H |
| 2 | #define Py_COBJECT_H |
| 3 | #ifdef __cplusplus |
| 4 | extern "C" { |
| 5 | #endif |
| 6 | |
| 7 | /*********************************************************** |
| 8 | Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam, |
| 9 | The Netherlands. |
| 10 | |
| 11 | All Rights Reserved |
| 12 | |
Guido van Rossum | d266eb4 | 1996-10-25 14:44:06 +0000 | [diff] [blame] | 13 | Permission to use, copy, modify, and distribute this software and its |
| 14 | documentation for any purpose and without fee is hereby granted, |
Guido van Rossum | 77654a7 | 1996-01-12 00:44:03 +0000 | [diff] [blame] | 15 | provided that the above copyright notice appear in all copies and that |
Guido van Rossum | d266eb4 | 1996-10-25 14:44:06 +0000 | [diff] [blame] | 16 | both that copyright notice and this permission notice appear in |
Guido van Rossum | 77654a7 | 1996-01-12 00:44:03 +0000 | [diff] [blame] | 17 | supporting documentation, and that the names of Stichting Mathematisch |
Guido van Rossum | d266eb4 | 1996-10-25 14:44:06 +0000 | [diff] [blame] | 18 | Centrum or CWI or Corporation for National Research Initiatives or |
| 19 | CNRI not be used in advertising or publicity pertaining to |
| 20 | distribution of the software without specific, written prior |
| 21 | permission. |
Guido van Rossum | 77654a7 | 1996-01-12 00:44:03 +0000 | [diff] [blame] | 22 | |
Guido van Rossum | d266eb4 | 1996-10-25 14:44:06 +0000 | [diff] [blame] | 23 | While CWI is the initial source for this software, a modified version |
| 24 | is made available by the Corporation for National Research Initiatives |
| 25 | (CNRI) at the Internet address ftp://ftp.python.org. |
| 26 | |
| 27 | STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH |
| 28 | REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF |
| 29 | MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH |
| 30 | CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL |
| 31 | DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 32 | PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 33 | TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 34 | PERFORMANCE OF THIS SOFTWARE. |
Guido van Rossum | 77654a7 | 1996-01-12 00:44:03 +0000 | [diff] [blame] | 35 | |
| 36 | ******************************************************************/ |
| 37 | |
| 38 | /* C objects to be exported from one extension module to another. |
| 39 | |
| 40 | C objects are used for communication between extension modules. |
| 41 | They provide a way for an extension module to export a C interface |
| 42 | to other extension modules, so that extension modules can use the |
| 43 | Python import mechanism to link to one another. |
| 44 | |
| 45 | */ |
| 46 | |
| 47 | extern DL_IMPORT(PyTypeObject) PyCObject_Type; |
| 48 | |
| 49 | #define PyCObject_Check(op) ((op)->ob_type == &PyCObject_Type) |
| 50 | |
| 51 | /* Create a PyCObject from a pointer to a C object and an optional |
| 52 | destrutor function. If the second argument is non-null, then it |
| 53 | will be called with the first argument if and when the PyCObject is |
| 54 | destroyed. |
| 55 | |
| 56 | */ |
Guido van Rossum | 43466ec | 1998-12-04 18:48:25 +0000 | [diff] [blame] | 57 | extern DL_IMPORT(PyObject *) |
Guido van Rossum | 77654a7 | 1996-01-12 00:44:03 +0000 | [diff] [blame] | 58 | PyCObject_FromVoidPtr Py_PROTO((void *cobj, void (*destruct)(void*))); |
| 59 | |
Guido van Rossum | 1f84449 | 1997-10-21 19:48:35 +0000 | [diff] [blame] | 60 | |
| 61 | /* Create a PyCObject from a pointer to a C object, a description object, |
| 62 | and an optional destrutor function. If the third argument is non-null, |
| 63 | then it will be called with the first and second arguments if and when |
| 64 | the PyCObject is destroyed. |
| 65 | */ |
Guido van Rossum | 43466ec | 1998-12-04 18:48:25 +0000 | [diff] [blame] | 66 | extern DL_IMPORT(PyObject *) |
Guido van Rossum | 1f84449 | 1997-10-21 19:48:35 +0000 | [diff] [blame] | 67 | PyCObject_FromVoidPtrAndDesc Py_PROTO((void *cobj, void *desc, |
| 68 | void (*destruct)(void*,void*))); |
| 69 | |
Guido van Rossum | 77654a7 | 1996-01-12 00:44:03 +0000 | [diff] [blame] | 70 | /* Retrieve a pointer to a C object from a PyCObject. */ |
Guido van Rossum | 43466ec | 1998-12-04 18:48:25 +0000 | [diff] [blame] | 71 | extern DL_IMPORT(void *) |
Guido van Rossum | 77654a7 | 1996-01-12 00:44:03 +0000 | [diff] [blame] | 72 | PyCObject_AsVoidPtr Py_PROTO((PyObject *)); |
| 73 | |
Guido van Rossum | 1f84449 | 1997-10-21 19:48:35 +0000 | [diff] [blame] | 74 | /* Retrieve a pointer to a description object from a PyCObject. */ |
Guido van Rossum | 43466ec | 1998-12-04 18:48:25 +0000 | [diff] [blame] | 75 | extern DL_IMPORT(void *) |
Guido van Rossum | 1f84449 | 1997-10-21 19:48:35 +0000 | [diff] [blame] | 76 | PyCObject_GetDesc Py_PROTO((PyObject *)); |
| 77 | |
Guido van Rossum | e0e6962 | 1997-01-22 20:48:48 +0000 | [diff] [blame] | 78 | /* Import a pointer to a C object from a module using a PyCObject. */ |
Guido van Rossum | 43466ec | 1998-12-04 18:48:25 +0000 | [diff] [blame] | 79 | extern DL_IMPORT(void *) |
Guido van Rossum | e0e6962 | 1997-01-22 20:48:48 +0000 | [diff] [blame] | 80 | PyCObject_Import Py_PROTO((char *module_name, char *cobject_name)); |
| 81 | |
Guido van Rossum | 77654a7 | 1996-01-12 00:44:03 +0000 | [diff] [blame] | 82 | #ifdef __cplusplus |
| 83 | } |
| 84 | #endif |
| 85 | #endif /* !Py_COBJECT_H */ |