Re: define-struct



Mike Kestner wrote:

I have cobbled together a struct definition extractor since I was tiring of hardcoding struct defs for Gtk#. It doesn't yet deal with embedded unions or structures, but then again, neither does the defs spec. :-) It also barfs on non-typedef'd function pointer fields. (/me checks his defs spec for function pointers). There's only one structure that does this in the gdk headers though, so perhaps that's an oversite that I can clean and try to sneak past the API freeze police.

The script and a set of defs for the gdk structures can be found in mono cvs in the codegen directory of the gtk-sharp module. The defs file has a few hand edits to work around the union and function pointer things. I also have a script that generates signal and property defs from source, although I understand those have been handled elsewhere already. My props extractor embraces and extends the defs format by adding a (doc-string "...") expression to the def. This is so trivial to extract that it could probably be added to the spec at this point.

Could you give some examples of the structs you want to use (define-struct ...) for? I have found that most of the structs that are not registered with the gtype system often map nicely to native types in python (such as GdkPoint to a 2-tuple).

One other definition we probably need to add is a (define-pointer ...) one. Sonething like:
 (define-pointer CTreeNode
   (in-module "Gtk")
   (c-name "GtkCTreeNode")
   (gtype-id "GTK_TYPE_CTREE_NODE")
 )

This is to cover types that are derived from G_TYPE_POINTER. These types don't have any copy/free functions, so are not handled quite the same as G_TYPE_BOXED types.

As for putting the complete doc strings in the defs file, what do others think about this? I have some reservations about it, as they could become quite large. Also, it is trivial to match up extracted doc strings with defs without human intervention (I do this in the docgen.py script distributed with pygtk).

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]