Hi-
okay, thanks, that looks useful.  It worked for me on a simple example, but
when I tried a big set of libraries (my reason for wanting an automated
solution), it got a syntax error on:

#define UNRRDU_DECLARE(C) UNRRDU_EXPORT unrrduCmd unrrdu_##C##Cmd;

so I'm guessing it doesn't support the ## syntax for gluing symbol names
together?

Gordon

On Fri, Oct 10, 2008 at 7:13 PM, Alex Holkner <[EMAIL PROTECTED]>wrote:

>
> On 10/11/08, Gordon Kindlmann <[EMAIL PROTECTED]> wrote:
> > Hello,
> >
> > I want to use a collection of C libraries in python via ctypes and a
> ctypes
> > code generator.  I have no problem using ctypes to call functions in the
> > library,  but I have to set up the argtypes and restype arguments for
> each
> > function, which is a pain given that there are hundreds of functions
> > involved.  There are also C structs used for state and parameter passing,
> > and I don't want to have to manually create in ctypes (via "class
> > blah(Structure): ...") a Python mirror to each and every field.
> >
> > I know that ctypeslib should be the right tool for the job:
> >
> > http://starship.python.net/crew/theller/wiki/CodeGenerator
> >
> >
> > However, my version of either gcc or gccxml is leading to xml output that
> > can't be correctly parsed by the xml2py part of ctypeslib.  The argtypes
> and
> > restype stuff is set for all the functions, but the python declaration of
> > the structs is empty ("class blah(Structure):   pass").
> >
> > On the ctypes-users mailing list, Thomas Heller warned that ctypeslib is
> not
> > really maintained anymore, and wasn't surprised that recent versions of
> > gccxml led to this problem.  He suggested that some part of pyglet might
> > also be able to do python code generation for ctypes, which brings me
> here.
> >
> > I know that this isn't the main purpose of pyglet, but I've searched
> around
> > some and can't find an answer to this: is there a way to use pyglet, or
> > something associated with pyglet, to generate Python class definitions of
> C
> > structs, by parsing C headers?
>
> Yes, it's called wraptypes, and its in the tools/ directory of a
> pyglet trunk svn checkout.  Note that wraptypes can't parse *every* C
> header -- it's built only to be good enough for what pyglet needs --
> but it should suit most purposes.
>
> Alex.
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pyglet-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pyglet-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to