Passing a C Struct and accessing/modifying its values

Justin Shaw wyojustin at hotmail.com
Fri Dec 27 07:27:08 EST 2002


"Lance Duivenbode" <huku at iinet.net.au> wrote in message
news:3E0C37A8.6090901 at iinet.net.au...
> Hi,
>
> I'm currently writing a multiple game log parser in C that's called
> Multistat (http://multistat.sourceforge.net). Multistat is a flexible
> plugin based application, and given this I would like to be able to
> create a plugin (or plugins) that will allow parsing etc to be done by
> scripting languages (i.e. python and perl for the moment).
>
> To do this I need to pass C structure that contains pointers and other C
> structures. Can python do this or do I have to serialize the data into
> XML or some other meta-language first? I've attached the header file
> that contains the structs (I'm interested in the GameData, PlayerData,
> and TeamData structs - NOTE: These all contain or are part of linked
lists).
>
> Thanks,
>
> Lance
>
>
Lance,

You need SWIG.  The Simplified Wrapper Interface Generator.  Just ignore the
"Simplified" part.  I have used this at work to deal C pointers and
structures but do not have the details infront of me.  Just have a look at
www.swig.org, and be prepared for a steep learning curve.  Bottom line is it
really works for Perl, Python, and Ruby to name a few.






More information about the Python-list mailing list