[gtkada] Ada interfaces vs. GLib interfaces

Dmitry A. Kazakov mailbox at dmitry-kazakov.de
Mon Jul 1 20:40:20 CEST 2013


On Mon, 1 Jul 2013 16:05:49 +0200, you wrote:

>> 6.a It made many things tagged, but for reasons I don't understand it does
>> not use Ada 2005 interfaces. As the result in old code you will have to add
>> a lot of explicit conversions which weren't needed before. E.g.
> 
> Reason is for backward compatibility and for those people who do not want to
> move to Ada05 (and there are plenty of them).

But it is not Ada 95 already. E.g. not null constraint is Ada 2005. No
honest Ada 95 compiler will compile it.

> Also Ada interfaces are a
> different beast from the Glib interfaces altogether.

Right. Neither T'Class is GObject_Class or Ada type is GType. That does not
prevent us from using T'Class instead of GObject_Class.

Why should it be different with interfaces?

   type Gtk_Tree_Model_Record is interface;
   type Gtk_Tree_Model is access all Gtk_Tree_Model_Record'Class;
   function Get_Iter_First  (Model : not null access Gtk_Tree_Model_Record) 
      return Gtk_Tree_Iter is abstract;
   ...

   type Gtk_List_Store_Record is
      new GObject_Record
      and Gtk_Tree_Model_Record with private;
   overriding
   function Get_Iter_First  (Model : not null access Gtk_List_Store_Record) 
      return Gtk_Tree_Iter;
   ...

Note that Gtk_Tree_Model_Record will not be a descendant of GInterface.
Should we needed such an object somewhere we could add a primitive
operation to Gtk_Tree_Model_Record returning an such object:

   function Get_Interface  (Model : not null access Gtk_Tree_Model_Record) 
      return GInterface is abstract;

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de


More information about the gtkada mailing list