[Pyrex] numeric C pointer argument and python integer argument

Lenard Lindstrom len-l at telus.net
Thu Apr 10 01:37:05 CEST 2008


One way is to create a new Python container type that wraps the C int 
array. The other is to copy values between the int array and some 
existing Python container type, such as a list.

Lenard


Daniele Pianu wrote:
> And if the c pointer points to a vector of numeric values and not a 
> single int? Is there any way to manage that in pyrex?
>
> 2008/4/9, Lenard Lindstrom <len-l at telus.net <mailto:len-l at telus.net>>:
>
>     Daniele Pianu wrote:
>     > I've a C function like this
>     >
>     > void Socket_getRemoteAddr(Socket *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
>




More information about the Pyrex mailing list