kstueve
2011-12-12 16:09:42 UTC
While writing a Cython wrapper for primesieve (http://code.google.com/
p/primesieve/) I have been unable to wrap the generatePrimes function
because of the function pointer argument.
I get "Cannot convert 'void' to Python object" on the last line
below. Please help me. I have been reading the Cython tutorials and
Googling, but haven't found an example that demonstrates this case.
cdef extern from "primesieve/PrimeSieve.h":
cdef cppclass PrimeSieve:
PrimeSieve()
#Prime number generation methods (32-bit & 64-bit ).
void generatePrimes(uint32_t, uint32_t, void (*callback)
(uint32_t))
void generatePrimes(uint32_t, uint32_t, void (*callback)
(uint32_t, void*), void* cbObj)
void generatePrimes(uint64_t, uint64_t, void (*callback)
(uint64_t))
void generatePrimes(uint64_t, uint64_t, void (*callback)
(uint64_t, void*), void* cbObj)
cdef class primesieve:
def __cinit__(self):
self.thisptr = new PrimeSieve()
def __dealloc__(self):
del self.thisptr
cdef generatePrimes(self, uint32_t startNumber, uint32_t
stopNumber, function callback):
return self.thisptr.generatePrimes(startNumber, stopNumber,
callback)
p/primesieve/) I have been unable to wrap the generatePrimes function
because of the function pointer argument.
I get "Cannot convert 'void' to Python object" on the last line
below. Please help me. I have been reading the Cython tutorials and
Googling, but haven't found an example that demonstrates this case.
cdef extern from "primesieve/PrimeSieve.h":
cdef cppclass PrimeSieve:
PrimeSieve()
#Prime number generation methods (32-bit & 64-bit ).
void generatePrimes(uint32_t, uint32_t, void (*callback)
(uint32_t))
void generatePrimes(uint32_t, uint32_t, void (*callback)
(uint32_t, void*), void* cbObj)
void generatePrimes(uint64_t, uint64_t, void (*callback)
(uint64_t))
void generatePrimes(uint64_t, uint64_t, void (*callback)
(uint64_t, void*), void* cbObj)
cdef class primesieve:
def __cinit__(self):
self.thisptr = new PrimeSieve()
def __dealloc__(self):
del self.thisptr
cdef generatePrimes(self, uint32_t startNumber, uint32_t
stopNumber, function callback):
return self.thisptr.generatePrimes(startNumber, stopNumber,
callback)
--
To post to this group, send an email to sage-***@googlegroups.com
To unsubscribe from this group, send an email to sage-devel+***@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org
To post to this group, send an email to sage-***@googlegroups.com
To unsubscribe from this group, send an email to sage-devel+***@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org