On Mon, 8 Mar 2010 11:57:35 +0530 (IST)
"Noufal Ibrahim" <[email protected]> wrote:
> Hello everyone,
> I have some code that's calling fcntl.ioctl. I need to pass a nested
> structure as the 3rd argument of the function. Something like this
>
> typedef struct coordinates{
> int x;
> int y;
> } coordinates;
>
> typedef struct point{
> int amp;
> coordinates* coord;
> } point;
>
> How would I do this? I need to allocate a point structure and then a
> coordinate structure and link them up together via the coord member of
> point, fill them up with values and pass it to the fcntl.ioctl. The
> actual IOCTL implementation will do the indirection to read out the
> data.
>
> I can't use ctypes since I'm working on an embedded system with an ARM
> core that doesn't have ctypes. The struct module doesn't seem to help
> due to the indirection.
>
> Any ideas? I'm personally planning to write a small C extension that
> creates the structure based on a specification in memory and then
> passes that to the IOCTL call directly but that looks like some work. I
> was also told to take a look at Cython which basically seems to be an
> easy way of doing what I'm planning. Is there a quicker/easier way?
>
> Thanks.
If your point is to implement a type (point) in C, for performance certainly,
and reuse it from a dynamic language, then I'm not sure python is the best
choice (*). Python programmers code in python e basta. C-python bindings are
far from beeing simplistic.
http://wiki.cython.org/WrappingCorCpp
Denis
(*) Lua instead is well-known for this kind of stuff; especially on particuliar
hardware like ARM. Lua's own implementation is 100% plain ANSI C standard and
Lua-C bindings are probably as straightforward as they can be.
http://lua-users.org/wiki/BindingCodeToLua
--
________________________________
la vita e estrany
spir.wikidot.com
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor