Re: signal/properties/enums/flags defs



On 10 Oct 2001, Murray Cumming wrote:

> On Wed, 2001-10-10 at 17:31, James Henstridge wrote:
> > > >
> > > > Probably the best way to structure this tool would be to put all these
> > > > helper functions for outputing defs into a small static library, then have
> > > > a script that scans for a list of types in a library, outputs a small
> > > > program and links it against the helper library and the lib being scanned,
> > > > and then runs the resulting program.
> > >
> > > Couldn't you just use the libary from h2defs.py?
> >
> > The idea is that the functions that extract the defs information would be
> > put into a small library (say libdefsextract.a), and have a single entry
> > point like write_defs(GType type).
> >
> > We then have a script (be it python, perl, sh+sed, whatever), which scans
> > headers to find *_TYPE_* variables/macros in the headers.  It writes out a
> > small program like this (this example uses gtk):
> >   #include <gtk/gtk.h>
> >   int
> >   main()
> >   {
> >       write_defs(GTK_TYPE_OBJECT);
> >       write_defs(GTK_TYPE_WIDGET);
> >       write_defs(GTK_TYPE_WIDGET_FLAGS);
> >       ...
> >       return 0;
> >   }
> >
> > It would then compile this program:
> >   gcc writedefs.c -ldefsextract `pkg-config --cflags --libs gtk+-2.0` \
> >      -o writedefs
> >
> > And finally runs the writedefs script (then cleans up the temporary
> > program it created).
> >
> > So essentially, you could just call the script, and it will scan for
> > types, compile the program that extracts the info, and then prints it to
> > stdout.
> >
>
> I meant, can't you just call C or C++ functions from python directly?
> Why go to the bother of creating C/C++ code, compiling it, and executing
> it?

The program needs to be linked against the library being scanned (in the
above example, gtk+), and possibly call an initialisation function (the
above example should have a gtk_init() call at the top).

James.

-- 
Email: james daa com au
WWW:   http://www.daa.com.au/~james/






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]