blob: 49c54509a0ed7372713f7dcf35b70b7f911ffe19 [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/***********************************************************
Guido van Rossumfd71b9e2000-06-30 23:50:40 +00008Copyright (c) 2000, BeOpen.com.
9Copyright (c) 1995-2000, Corporation for National Research Initiatives.
10Copyright (c) 1990-1995, Stichting Mathematisch Centrum.
11All rights reserved.
Guido van Rossum77654a71996-01-12 00:44:03 +000012
Guido van Rossumfd71b9e2000-06-30 23:50:40 +000013See the file "Misc/COPYRIGHT" for information on usage and
14redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
Guido van Rossum77654a71996-01-12 00:44:03 +000015******************************************************************/
16
17/* C objects to be exported from one extension module to another.
18
19 C objects are used for communication between extension modules.
20 They provide a way for an extension module to export a C interface
21 to other extension modules, so that extension modules can use the
22 Python import mechanism to link to one another.
23
24*/
25
26extern DL_IMPORT(PyTypeObject) PyCObject_Type;
27
28#define PyCObject_Check(op) ((op)->ob_type == &PyCObject_Type)
29
30/* Create a PyCObject from a pointer to a C object and an optional
31 destrutor function. If the second argument is non-null, then it
32 will be called with the first argument if and when the PyCObject is
33 destroyed.
34
35*/
Guido van Rossum43466ec1998-12-04 18:48:25 +000036extern DL_IMPORT(PyObject *)
Guido van Rossum77654a71996-01-12 00:44:03 +000037PyCObject_FromVoidPtr Py_PROTO((void *cobj, void (*destruct)(void*)));
38
Guido van Rossum1f844491997-10-21 19:48:35 +000039
40/* Create a PyCObject from a pointer to a C object, a description object,
41 and an optional destrutor function. If the third argument is non-null,
42 then it will be called with the first and second arguments if and when
43 the PyCObject is destroyed.
44*/
Guido van Rossum43466ec1998-12-04 18:48:25 +000045extern DL_IMPORT(PyObject *)
Guido van Rossum1f844491997-10-21 19:48:35 +000046PyCObject_FromVoidPtrAndDesc Py_PROTO((void *cobj, void *desc,
47 void (*destruct)(void*,void*)));
48
Guido van Rossum77654a71996-01-12 00:44:03 +000049/* Retrieve a pointer to a C object from a PyCObject. */
Guido van Rossum43466ec1998-12-04 18:48:25 +000050extern DL_IMPORT(void *)
Guido van Rossum77654a71996-01-12 00:44:03 +000051PyCObject_AsVoidPtr Py_PROTO((PyObject *));
52
Guido van Rossum1f844491997-10-21 19:48:35 +000053/* Retrieve a pointer to a description object from a PyCObject. */
Guido van Rossum43466ec1998-12-04 18:48:25 +000054extern DL_IMPORT(void *)
Guido van Rossum1f844491997-10-21 19:48:35 +000055PyCObject_GetDesc Py_PROTO((PyObject *));
56
Guido van Rossume0e69621997-01-22 20:48:48 +000057/* Import a pointer to a C object from a module using a PyCObject. */
Guido van Rossum43466ec1998-12-04 18:48:25 +000058extern DL_IMPORT(void *)
Guido van Rossume0e69621997-01-22 20:48:48 +000059PyCObject_Import Py_PROTO((char *module_name, char *cobject_name));
60
Guido van Rossum77654a71996-01-12 00:44:03 +000061#ifdef __cplusplus
62}
63#endif
64#endif /* !Py_COBJECT_H */