[Pyrex] How to call C function in one Pyrex module from another Pyrex module?

Michal Pasternak michal at pasternak.w.lub.pl
Sat Jun 5 20:02:49 CEST 2004


Hi, my case is relativley simple, I suppose, that I'm making a very simple
error somewhere... basically (all files in the same directory), 
Pyrex 0.9.2.1 on Python 2.3.3 with threads on FreeBSD 5.2.1-RC 
(gcc (GCC) 3.3.3 [FreeBSD] 20031106):

	membuf.pxd:
	
		cdef class MemoryBuffer:
			...
			cdef char* buf
			cdef char *C_getaddr(MemoryBuffer self)
			
	membuf.pyx:
	
		cdef class MemoryBuffer:
			...
			cdef char *C_getaddr(MemoryBuffer self):
				# return a pointer to internal buffer structure
				return self.buf


	foobar.pyx:
	
		cimport membuf
		import membuf
		
		cdef class Foobar:
		
			def doSomething(Foobar self, membuf.MemoryBuffer buf):
			
				cdef char *b
				
				# this won't work (buf will be cast to None)
				b = buf.C_getaddr()
				
				# this won't work also:
				b = membuf.MemoryBuffer.C_getaddr(buf)
				

What am I doing wrong? I suppose I've messed up imports somehow, so Pyrex
thinks, that both calls in foobar.pyx are undefined... what will be the
correct version? Thanks in advance!

-- 
Michal Pasternak :: http://pasternak.w.lub.pl :: http://winsrc.sf.net

"Frankly, any company would look bad if their corporate e-mail was available
for anyone to read," -- Jim Dose of Ritual Entertainment. 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.copyleft.no/pipermail/pyrex/attachments/20040605/7170e350/attachment.bin


More information about the Pyrex mailing list