On Tue, Sep 29, 2009 at 16:27:56 +0300, Vlad Grecescu wrote: > On Tue, Sep 29, 2009 at 4:12 PM, John Carr <[email protected]> wrote: > > the valac entry point hacked to run my code and then some code to > > generate the ctypes bindings. > > Hmm.. someone should step up with a GModule-like proposition for the > vala compiler 'driver'. You are not the only one doing this.
The minimal driver is some 40 lines or so for me. It's mostly the same as in valac, but not exactly, so most of the code can't be reused anyway. Perhaps loading of packages and handling of dependencies. > On Tue, Sep 29, 2009 at 1:36 PM, pancake <[email protected]> wrote: > > Should I use libvala?like valadoc does? > > Maybe not. Somebody here on the mailing list maybe has information of > using GObjectIntrospection[1] directly. I am currently writing a test driver which supports both and I didn't like the quality of gobject-introspection. For one thing, it's limited to glib-based code, while vala is not. For another, it seems to suffer from lack of real use. If you were content with gobject-only stuff, it would make sense to look at what is done in GObjectIntrospection[1] and PyGObject[2] have done so far (PyGObject contains experimental gir-based dynamic bindings) and try to help them out. If not, I suggest going with libvala and trying to be independent of the vala profile. You will still have to depend on existing glib/gobject bindings for things derived from gobject. It might also be interesting to look at Swig[3] and consider creating a front-end for it. That way you would, at cost of additional compilation step, quickly get support for many target languages. > > Is there any example code iterating over > > methods, namespaces, arguments of signatures, etc..? > > Citing from memory (since I'm at work), in vala's valacompiler.vala > you have the CodeContext which has a "context.root" of type Namespace. > > Namespaces can contain nested namespaces > foreach (var ns in context.root.get_namespaces ()) > ... > Each Vala.Namespace can contain Classes, Structs, free Methods. > (get_classes (), get_structs () etc.) > Each Vala.Class can contain (inner) Classes, Structs, member Methods > (get_methods () etc.) Yes (that's correct), but no (you don't want to walk it manually). The preferred method of iterating over it is using the visitor patter with CodeVisitor-derived classes (which is what the vala compiler itself does as well). You can have a look at the vtg (Vala Toys for gEdit)[4] or valadate[5] -- they also use libvala. > The important part is to get the _cname_ in the end, for your python FFI. Just be prepared that handling all the types (simpletype, struct, compact class, GTypeInstance-based class, GObject-based class, few special ones like GValue) will be quite tedious work. > [1] http://live.gnome.org/GObjectIntrospection [2] http://live.gnome.org/PyGObject [3] http://www.swig.org/ [4] http://code.google.com/p/vtg [5] http://gitorious.org/valadate -- Jan 'Bulb' Hudec <[email protected]> _______________________________________________ Vala-list mailing list [email protected] http://mail.gnome.org/mailman/listinfo/vala-list
