7 Apr 2010 19:06
C++ Wrapper Confusion
SevenThunders <mattcbro <at> earthlink.net>
2010-04-07 17:06:54 GMT
2010-04-07 17:06:54 GMT
I am trying to wrap an existing C++ class in cython. I've had some success in the past wrapping a C library, however I find the state of the C++ documentation rather confusing. I believe there have been some prior posts on this issue. My first question is what wrapping syntax is actually suported in Cython 0.12.1? The online documentation for version 0.12 has the 'older' syntax here, http://docs.cython.org/src/userguide/wrapping_CPlusPlus.html . Some earlier posts suggest that this is deprecated and that we should use the rather terse discussion here: http://wiki.cython.org/WrappingCPlusPlus Although the effort to provide C++ support is greatly appreciated, there are a few things missing from this documentation. There is no discussion about how to define the extension class and some issues are missing, like how do you handle pass by reference. The syntax for that seems inconsistent. Right now I just want to know what's actually supported in my version of Cython 0.12.1. I tried the new syntax and immediately got a syntax error in this little code snippet: cdef extern from "gpumat.h" : ctypedef struct dim3 ctypedef enum MatrixType : Realmatrix = 0 Complexmatrix=1 Cuppermatrix = 2 ctypedef struct gpumat void fromgpu(gpumat gin, float *hval)(Continue reading)
diff -r b442fb71c1de Cython/Compiler/ExprNodes.py
--- a/Cython/Compiler/ExprNodes.py Sat Mar 20 18:07:43 2010 +0100
+++ b/Cython/Compiler/ExprNodes.py Fri Apr 09 22:55:08 2010 -0300
<at> <at> -6287,14 +6287,14 <at> <at>
""",
impl = """
static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list) {
- PyObject *__import__ = 0;
+ PyObject *py__import__ = 0;
PyObject *empty_list = 0;
PyObject *module = 0;
PyObject *global_dict = 0;
PyObject *empty_dict = 0;
RSS Feed