37#define PyCartesian_Type_NUM 0
39#define PyCartesian_GetNative_NUM 1
40#define PyCartesian_GetNative_RETURN Cartesian_t*
41#define PyCartesian_GetNative_PROTO (PyCartesian*)
43#define PyCartesian_New_NUM 2
44#define PyCartesian_New_RETURN PyCartesian*
45#define PyCartesian_New_PROTO (Cartesian_t*)
47#define PyCartesian_API_pointers 3
49#define PyCartesian_CAPSULE_NAME "_cartesian._C_API"
51#ifdef PYCARTESIAN_MODULE
53extern PyTypeObject PyCartesian_Type;
56#define PyCartesian_Check(op) ((op)->ob_type == &PyCartesian_Type)
66static void **PyCartesian_API;
72#define PyCartesian_GetNative \
73 (*(PyCartesian_GetNative_RETURN (*)PyCartesian_GetNative_PROTO) PyCartesian_API[PyCartesian_GetNative_NUM])
82#define PyCartesian_New \
83 (*(PyCartesian_New_RETURN (*)PyCartesian_New_PROTO) PyCartesian_API[PyCartesian_New_NUM])
88#define PyCartesian_Check(op) \
89 (Py_TYPE(op) == &PyCartesian_Type)
91#define PyCartesian_Type (*(PyTypeObject*)PyCartesian_API[PyCartesian_Type_NUM])
96#define import_pycartesian() \
97 PyCartesian_API = (void **)PyCapsule_Import(PyCartesian_CAPSULE_NAME, 1);
104#define PyCartesian_Check(op) \
105 ((op)->ob_type == (PyTypeObject *)PyCartesian_API[PyCartesian_Type_NUM])
114 PyObject *c_api_object;
116 module = PyImport_ImportModule("_cartesian");
117 if (module == NULL) {
121 c_api_object = PyObject_GetAttrString(module,
"_C_API");
122 if (c_api_object == NULL) {
126#if PY_MAJOR_VERSION < 3
127 PyCartesian_API = (
void **)PyCObject_AsVoidPtr(c_api_object);
129 PyCartesian_API = (
void **)PyCapsule_New((
void *)c_api_object, NULL, NULL);
136 Py_DECREF(c_api_object);
Defines the functions available when working with cartesian products.
#define PyCartesian_GetNative
Returns a pointer to the internal cartesian, remember to release the reference when done with the obj...
Definition pycartesian.h:72
#define PyCartesian_New_RETURN
return type for New
Definition pycartesian.h:44
#define import_pycartesian()
Imports the PyArea module (like import _area in python).
Definition pycartesian.h:96
#define PyCartesian_New_PROTO
arguments for New
Definition pycartesian.h:45
#define PyCartesian_GetNative_PROTO
arguments for GetNative
Definition pycartesian.h:41
#define PyCartesian_GetNative_RETURN
return type for GetNative
Definition pycartesian.h:40
#define PyCartesian_New
Creates a new cartesian instance.
Definition pycartesian.h:82
A cartesian product.
Definition pycartesian.h:32
PyObject_HEAD Cartesian_t * cartesian
the cartesian product
Definition pycartesian.h:34
Represents the cartesian product.
Definition cartesian.c:41