blob: 672e029e49de447d8fe5cc3874d03a8a7ed0d80f [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*/
57
58extern PyObject *
59PyCObject_FromVoidPtr Py_PROTO((void *cobj, void (*destruct)(void*)));
60
61/* Retrieve a pointer to a C object from a PyCObject. */
62extern void *
63PyCObject_AsVoidPtr Py_PROTO((PyObject *));
64
Guido van Rossume0e69621997-01-22 20:48:48 +000065/* Import a pointer to a C object from a module using a PyCObject. */
66extern void *
67PyCObject_Import Py_PROTO((char *module_name, char *cobject_name));
68
Guido van Rossum77654a71996-01-12 00:44:03 +000069#ifdef __cplusplus
70}
71#endif
72#endif /* !Py_COBJECT_H */