Re: Interface implementation in language bindings



On Fri, 2005-02-25 at 17:21 -0500, Owen Taylor wrote:
> The ideal situation is that someone, using a language binding
> to GTK+ could just do:
> 
>  class Foo (GtkWidget, GtkCellLayout):
>    def start_editing (event):
>      [....]
> 
> (There is a bit of a problem here in that most languages don't
> allow sufficient customization of class initialization to 
> actually allow such a simple syntax, so mentally add whatever 
> extra syntax or hacks are necessary)
> 
> The problem with the above is that hooking 
> 
> struct _GtkCellEditableIface
> {
>   GTypeInterface g_iface;
> 
>   [...]
> 
>   /* virtual table */
>   void (* start_editing) (GtkCellEditable *cell_editable,
>                           GdkEvent        *event);
> };
> 
> into a language binding is hard because we need to assign something
> to the 'start_editing' vtable pointer. How we fix this once we have
> introspection information inside GTK+?
> 

[snip]

> You could similarly have a g_type_register_generic() to
> handle virtual method overriding in derivation.

	Another thing that might be worth considering when it comes to
derivation is how to expose the notion of class properties - e.g. a
GtkAction sub-class may need to set menu_item_type/toolbar_item_type
when deriving:

  class MyAction (GtkAction):
      menu_item_type = MyMenuItem
      toolbar_item_type = MyToolItem

      def __init__ (self):
          ....

	It seems like you'd need for classes to register their class
properties, implement set_class_property(), allow derived classes to set
properties after class initialization and prior to the first
instantiation ...

Cheers,
Mark.




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