[Pyrex] numeric C pointer argument and python integer argument

Lenard Lindstrom len-l at telus.net
Wed Apr 9 18:02:06 CEST 2008


Daniele Pianu wrote:
> I've a C function like this
>
> void Socket_getRemoteAddr 
> <file:///home/daniele/.HRI/Proxy/HRI/Libraries/Socket/2.0/doc/html/Socket_8h.html#74523edd41cdf2247e109cc58429ca30> 
> (Socket 
> <file:///home/daniele/.HRI/Proxy/HRI/Libraries/Socket/2.0/doc/html/structSocket.html> 
> *self, char *serverHostAddr, int bufferSize, int *serverPortNo)
>
> and I want to wrap it on this python method
>
> def setRemoteAddr( self, serverHostAddr, serverPortNo )
>
> serverPortNo is a python integer, and it must reflect modifications 
> done on the relative C argument (serverPortNo). How can I do it in pyrex?
>
The usual way is to return the changed value as a value of the function:

def setRemoteAddr(...., int serverPortNo):
    ....
    Socket_getRemoteAddr(...., &serverPortNo)
    ....
    return serverPortNo

-- 
Lenard Lindstrom
<len-l at telus.net>




More information about the Pyrex mailing list