blob: 59790747fba28922bbfd4c87370c2aa61fa84f35 [file] [log] [blame]
Guido van Rossum77654a71996-01-12 00:44:03 +00001#ifndef Py_COBJECT_H
2#define Py_COBJECT_H
3#ifdef __cplusplus
4extern "C" {
5#endif
6
7/***********************************************************
8Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam,
9The Netherlands.
10
11 All Rights Reserved
12
Guido van Rossumd266eb41996-10-25 14:44:06 +000013Permission to use, copy, modify, and distribute this software and its
14documentation for any purpose and without fee is hereby granted,
Guido van Rossum77654a71996-01-12 00:44:03 +000015provided that the above copyright notice appear in all copies and that
Guido van Rossumd266eb41996-10-25 14:44:06 +000016both that copyright notice and this permission notice appear in
Guido van Rossum77654a71996-01-12 00:44:03 +000017supporting documentation, and that the names of Stichting Mathematisch
Guido van Rossumd266eb41996-10-25 14:44:06 +000018Centrum or CWI or Corporation for National Research Initiatives or
19CNRI not be used in advertising or publicity pertaining to
20distribution of the software without specific, written prior
21permission.
Guido van Rossum77654a71996-01-12 00:44:03 +000022
Guido van Rossumd266eb41996-10-25 14:44:06 +000023While CWI is the initial source for this software, a modified version
24is made available by the Corporation for National Research Initiatives
25(CNRI) at the Internet address ftp://ftp.python.org.
26
27STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH
28REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
29MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH
30CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
31DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
32PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
33TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
34PERFORMANCE OF THIS SOFTWARE.
Guido van Rossum77654a71996-01-12 00:44:03 +000035
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
47extern 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 Rossum77654a71996-01-12 00:44:03 +000057extern PyObject *
58PyCObject_FromVoidPtr Py_PROTO((void *cobj, void (*destruct)(void*)));
59
Guido van Rossum1f844491997-10-21 19:48:35 +000060
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*/
66extern PyObject *
67PyCObject_FromVoidPtrAndDesc Py_PROTO((void *cobj, void *desc,
68 void (*destruct)(void*,void*)));
69
Guido van Rossum77654a71996-01-12 00:44:03 +000070/* Retrieve a pointer to a C object from a PyCObject. */
71extern void *
72PyCObject_AsVoidPtr Py_PROTO((PyObject *));
73
Guido van Rossum1f844491997-10-21 19:48:35 +000074/* Retrieve a pointer to a description object from a PyCObject. */
75extern void *
76PyCObject_GetDesc Py_PROTO((PyObject *));
77
Guido van Rossume0e69621997-01-22 20:48:48 +000078/* Import a pointer to a C object from a module using a PyCObject. */
79extern void *
80PyCObject_Import Py_PROTO((char *module_name, char *cobject_name));
81
Guido van Rossum77654a71996-01-12 00:44:03 +000082#ifdef __cplusplus
83}
84#endif
85#endif /* !Py_COBJECT_H */