Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: (from stdlib-sig) ctypes or struct from an h file

Reply
Thread Tools

Re: (from stdlib-sig) ctypes or struct from an h file

 
 
Diez B. Roggisch
Guest
Posts: n/a
 
      10-18-2009
Yuvgoog Greenle schrieb:
> Is there a way that Python and C can have a shared definition for a
> binary data structure?
>
> It could be nice if:
> 1. struct or ctypes had a function that could parse a .h/.c/.cpp file
> to auto-generate constructors
> or
> 2. a ctypes definition could be exported to a .h file.
>
> So my question is - is there a way to do this in the std-lib or even pypi?
>
>
> --yuv
>
>
> ps If this doesn't exist, then I'm probably going to open a project
> and would like some tips/ideas.



gccxml can be used to do this, there is a ctypes utilities module that
works with the output of gccxml.

Diez
 
Reply With Quote
 
 
 
 
geremy condra
Guest
Posts: n/a
 
      10-18-2009
On Sun, Oct 18, 2009 at 4:13 PM, Diez B. Roggisch <(E-Mail Removed)> wrote:
> Yuvgoog Greenle schrieb:
>>
>> Is there a way that Python and C can have a shared definition for a
>> binary data structure?
>>
>> It could be nice if:
>> 1. struct or ctypes had a function that could parse a .h/.c/.cpp file
>> to auto-generate constructors
>> or
>> 2. a ctypes definition could be exported to a .h file.
>>
>> So my question is - is there a way to do this in the std-lib or even pypi?
>>
>>
>> --yuv
>>
>>
>> ps If this doesn't exist, then I'm probably going to open a project
>> and would like some tips/ideas.

>
>
> gccxml can be used to do this, there is a ctypes utilities module that works
> with the output of gccxml.
>
> Diez
> --
> http://mail.python.org/mailman/listinfo/python-list
>


Found this: http://starship.python.net/crew/thel...d/codegen.html
which I take to be the module you're talking about. From the docs it doesn't
appear to have worked with gccxml since before 0.6, which is more than 5
years old. Am I at the wrong place?

Geremy Condra
 
Reply With Quote
 
 
 
 
Diez B. Roggisch
Guest
Posts: n/a
 
      10-18-2009
geremy condra schrieb:
> On Sun, Oct 18, 2009 at 4:13 PM, Diez B. Roggisch <(E-Mail Removed)> wrote:
>> Yuvgoog Greenle schrieb:
>>> Is there a way that Python and C can have a shared definition for a
>>> binary data structure?
>>>
>>> It could be nice if:
>>> 1. struct or ctypes had a function that could parse a .h/.c/.cpp file
>>> to auto-generate constructors
>>> or
>>> 2. a ctypes definition could be exported to a .h file.
>>>
>>> So my question is - is there a way to do this in the std-lib or even pypi?
>>>
>>>
>>> --yuv
>>>
>>>
>>> ps If this doesn't exist, then I'm probably going to open a project
>>> and would like some tips/ideas.

>>
>> gccxml can be used to do this, there is a ctypes utilities module that works
>> with the output of gccxml.
>>
>> Diez
>> --
>> http://mail.python.org/mailman/listinfo/python-list
>>

>
> Found this: http://starship.python.net/crew/thel...d/codegen.html
> which I take to be the module you're talking about. From the docs it doesn't
> appear to have worked with gccxml since before 0.6, which is more than 5
> years old. Am I at the wrong place?


Nope, that's it. I don't understand what you mean with "since before
0.6" - all I can say is I got it working last year with a GCC 3.X or 4.x
project.

Diez
 
Reply With Quote
 
exarkun@twistedmatrix.com
Guest
Posts: n/a
 
      10-18-2009
On 08:13 pm, http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
>Yuvgoog Greenle schrieb:
>>Is there a way that Python and C can have a shared definition for a
>>binary data structure?
>>
>>It could be nice if:
>>1. struct or ctypes had a function that could parse a .h/.c/.cpp file
>>to auto-generate constructors
>>or
>>2. a ctypes definition could be exported to a .h file.
>>
>>So my question is - is there a way to do this in the std-lib or even
>>pypi?
>>
>>
>>--yuv
>>
>>
>>ps If this doesn't exist, then I'm probably going to open a project
>>and would like some tips/ideas.

>
>
>gccxml can be used to do this, there is a ctypes utilities module that
>works with the output of gccxml.
>
>Diez
>--
>http://mail.python.org/mailman/listinfo/python-list


ctypes_configure can do this, too, doesn't require gccxml, and works
with non-gcc compilers.

Jean-Paul
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can *common* struct-members of 2 different struct-types, that are thesame for the first common members, be accessed via pointer cast to either struct-type? John Reye C Programming 28 05-08-2012 12:24 AM
WindowsXP/ CTypes - How to convert ctypes array to a string? dudeja.rajat@gmail.com Python 0 08-19-2008 10:20 AM
ctypes: return a pointer to a struct Jack Python 6 04-25-2008 03:50 AM
RE: [ctypes-users] [Ann] ctypes 0.9.0 released Henk Punt Python 0 07-23-2004 10:34 PM
struct my_struct *p = (struct my_struct *)malloc(sizeof(struct my_struct)); Chris Fogelklou C Programming 36 04-20-2004 08:27 AM



Advertisments