Meeting on irc.gnome.org:#gtk-devel Meeting started May 17 2005 16:02 EDT In attendence: Matthias Clasen (mclasen), Jonathan Blandford (jrb), Maciej Katafiasz (mathrick), Johan Dahlin (jdahlin), Owen Taylor (owen), ok, I didn't post an agenda but I think we could talk about the current state of the introspection stuff (sorry about the UTC mess-up, btw) jrb: did you get a "working binding" going ? mclasen: jdahlin did, but he's a code horder mclasen: and he won't let me play with his toys heh does current spec allow for any sort of default argument specification? it doesn't seem so mathrick: no, it doesn't mclasen: that's gonna be needed and python's keyword arguments will be fun, as jdahlin said mathrick: I don't see why keyword arguments are particularly relevant to binding a C library mclasen: are you familiar with python's positional vs. keyword aguments distinction? mclasen: it is I mean, there are no keyword arguments in C, so it should be possible to do a binding without introducing them jrb: I'm not a horder any longer, it's all in cvs mathrick: I assume they're similar to keyword arguments in lisp/scheme dialects... mclasen: there's 3 possible argument classes, actually mclasen: what I have working is module, class and method generation, working on invokation mclasen: positional, keyword, and additional keyword I have a couple of things on my wishlist mathrick: additional is like rest ? mclasen: like, def some_func(arg1, arg2, arg3, *args, **kw_args) mclasen: a global registry, which we talked about a couple of days ago mathrick: we can ignore * and ** since the introspection doesn't support that mclasen: yes, but there's also *args, which is like rest, and **kw_args, which is variable, but contains dict of keyword -> value mapping jdahlin: well, question is, can we do that * is similar to va_list in C, ** is similar, but you receive the arguments in a hash table jdahlin: at least * is interesting for variac args s/variac/variadic/ we're not going to support variadic functions in the metadata, I think mclasen: **kwargs is useful for example in here: http://pygtk.org/pygtk2reference/class-gtktreeviewcolumn.html#method-gtktreeviewcolumn--set-attributes we should at least get some useful convention mclasen: default arguments is also high on the wishlist func("name", val, "name2", val2, NULL) seems to be established mapping for that default arguments may be a good testcase for annotations glade_xml_new is a good example for that, you usally send in NULL on at least one of the arguments mclasen: yeah mclasen: I'll get typed anno proposal ready tomorrow, if nothing bad happens mathrick: GTK+ never uses that for keyword arguments where the keywords are part of the API owen: yes, that was meant for **kwargs mapping into C owen: which are by definition unknown mathrick: I don't think mapping g_object_new() to keyword arguments in the intropsection data makes sense owen: hmm> ? owen: I didn't get you mathrick: That's the kind of thing that has to be done by hand... the introspection data can't handle *everything* that you might want to do in an ideal language binding owen: nah, compare gtk_tree_view_column_set_attributes () with gtk.TreeViewColumn.set_attributes() mathrick: Not sure what you are arguing owen: there's very clear mapping of dict (**kwargs) into "keyword", value..., NULL pairs mathrick: You are missing the fact that the *type* of the value needs to be determined at runtime, by a method specific to the interface owen: hmm mathrick: That seems overambitious for introspection to encode (it is awfully convenient, though) owen: jrb is right :) mathrick: I think we are assuming that language bindings will frequently add a bit of convenience API over what we can introspect I agree with owen, it's not so difficult to do this in language bindings owen: dunno, if function is truly variadic, it's gonna have to validate input itself anyway jdahlin: you mean hand-crafted? We'll always require extra glue/integration for each language mathrick: If this sequence of bytes on the stack is a not a pointer to a GObject, then return an error? mathrick: How are you going to implement that? humm so, coming back to default values. Does it sound reasonable to do them as annotations, or should we add them to the core metadata ? mclasen: annotations sound fine mclasen: is annotation lookup going to be constant time? what's the tradeoff one vs the other? what kind of annotations? owen: bsearch sorry, I must have missed something. what default values are we thinking of encoding? Are we doing anything other than NULLs? mclasen: blech mlcasen: default values need to be looked up every time that you invoke a function. Though I suppose you could cache the pointer to the annotation... owen: alternatively, store a direct link to the annotations in each blob owen: yeah, it should be cacheable or simply make default values part of the argblob mclasen: if we using annotations for things that are needed invoke time, then I think they need constant-time lookup. If they are only used for "documentation", then it doesnt' matter jdahlin: what's the current strategy of pybank, does it def methods for introspected functions, or looks them up at invoke time? mathrick: currently it does it at creation time, I can't see why it shouldn't class creation time jdahlin: ok, so we can easily cache default values I suppose other dynamic languages can do that too owen: if we are really serious about constant-time lookup going from function name -> call, we need hashes to look up functions, in addition of the current arrays mclasen: dunno, are there any languages so dynamic that they couldn't cache that info? mclasen: bsearch might be OK for initial lookup if it's cacheable. But I could imagine spending a lot of time bsearching for a larger program owen: bsearching would require to sort the entries in the directory/functions in an interface. We don't do that currently mclasen: Linear scan? Hmm. I think it's unpleasant if you have to populate the entire interface the first time you hit any function in it. owen: so we should probably sort the arrays mclasen: either that or add a hash table ...or both or both would that be a single hash table, or one per interface ? There are two lookup operations 1. find an interface/function in the blob 2. find a function in an interface/object currently you have to loop over the directory for the first, and loop over the list of functions in an interface for the second You could argue either way. You need the interface blob in any case to do anything with the function blob, so a single hash table lookup to get to the funcion blob doesn't help? owen: there is g_base_info_get_container() which allows you to get the "containing" blob, so in theory you can navigate back from the function info to the interface but it is going to be a challenge to make that work when directly jumping to the function blob since there is no "parent" link in the metadata How do you even know how to look up the function blob? You'd have to have the interface name to look something up in the global hash table you would probably have to use a qualified name like Gtk.Widget.show, not just show What I'm sayting is that you already have the Gtk.Widget class object before you check to see if it has a show method So, the only real justification for a global hash table wwould be if it was more compact or convenient in the metadata format ok, so I want to work on implementing the struct layout pieces of the metadata in the parser this week (as an excuse for not looking into the scary scanner task...) Do we have a good idea for generating the struct offset information at build time ? Keeping arch-dependent xml files around for all arches is clearly suboptimal mclasen: we could define the entire struct in order and imply the offsets from that I think you have to include everything that could influence struct packing mclasen: though it sounds a little fragile all the field types and any nesting in the structure mclasen: one sucky idea is to generate structs field-by-field and print sizeof() will be slow as hell with gazillion of gcc invocations one could try to generate code which uses G_STRUCT_OFFSET a lot... yes mathrick: the logic for determining struct offsets for different architecutres isn't *that* complex. I think ORBit has it doesn't libffi do part of that too? it has sucky docs for sure owen: if we can steal from ORBit, it's good. We will need to have it for dynamic languages anyway, come to think of it mathrick: All structures must have type set to FFI_TYPE_STRUCT. You may set size and alignment to 0. These will be calculated and reset to the appropriate values by ffi_prep_cif() but inside compiler-generated C code, we can simply use G_STRUCT_OFFSET mathrick: Well, the point of including it in the intropsection is os that dynamic languages *don't* have to calculate mathrick: wouldn't that require the header, and defeat the purpose (er, what owen said) owen: depends on how much of infrastructure we want to put inside core introspection and how much to delegate to bindings jrb: the idea with G_STRUCT_OFFSET would be to generate code at build time which uses G_STRUCT_OFFSET to dump the offsets mclasen: ah -- I thouht mathrick was proposing to use it in conjunction w/ introspection in the bindings no, only at build time ok, I'll have to leave soon i'm currently trying to get through the unmilestoned bugs, btw help with triaging them would be welcome Help clearing off some of the milestoned bugs would be appreciated to, of course. We're past 1100 total and not looking back... is that including enhancements ? the number on the "last weeks bug activity" report is more like 900 mclasen: Yes. That's everything. Most of those 900 are enhancemnts too, of course Meeting ended May 17, 17:26 EDT