<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1400" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Hello,</FONT></DIV>
<DIV><FONT face=Arial size=2>I am new to the list, so my two points here might
have been raised before.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>A quick point first. Often we are defining some
functions which do not take any parameters, or in case of methods do not use the
self parameter at all. In these cases, I think it should be easy to
suppress the call to PyArg_ParseTupleAndKeywords in the resulting C code.
It would speed up repetitive calls to tiny C functions.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>My second point is that often we want to wrap a C
library which basically defines some data structure<BR>and some functions.<BR>In
the C header file, we might have something
like<BR>//----------------------<BR>// module.h<BR>typedef struct {<BR>
int blah1;<BR> int blah2;<BR>} MyStruct;</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>void init(*MyStruct);<BR>void
dothis(*MyStruct);<BR>//----------------------</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Then what we typically want to do in the pyx file
is:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>cdef from "module.h":<BR> ctypedef struct
MyStruct<BR> void init(*MyStruct)<BR> void
dothis(*MyStruct)</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>cdef class MyClass:<BR> cdef MyStruct
thisstruct<BR> def init(self):<BR>
init(&self.thistruct)<BR> def dothis(self):<BR>
dothis(&self.thistruct)</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>However this is currently not possible: the pyrexc
compiler fails the compilation with a "variable type MyStruct is incomplete",
because he does not know the size of the MyStruct. However it should be
noted that the resulting C (should the pyrexc not complain) could be easily
compiled. From the header file, the C compiler knows the size of Mystruct.
<BR>Currently one way to overcome this is to duplicate the structure declaration
outside of the cdef from "module.h" and with a different name:<BR>ctypedef
struct MyStruct1:<BR> int blah1<BR> int blah2</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>which then creates several problem:<BR> +
when doing this, then we need to do some explicit casting each time we use
it:<BR> def dothis(self):<BR>
dothis(<MyStruct*>&self.thisstruct)<BR> + if the structure
changes in the C file, we need to duplicate it correctly here</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Are you aware of other method to overcome this? I
guess modifying pyrexc would be the better way to go, unless it creates some
other problems I cannot think of.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Regards,</FONT></DIV>
<DIV><FONT face=Arial size=2>Serge Barbosa Da Torre</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV></BODY></HTML>