comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Issue with GNAT GPL 2009 and GtkAda
Date: Fri, 26 Jun 2009 21:50:32 +0200
Date: 2009-06-26T21:50:32+02:00	[thread overview]
Message-ID: <1vhj7stehejgf.g8k491cjoq7t$.dlg@40tude.net> (raw)
In-Reply-To: 4a452109$0$31437$426a34cc@news.free.fr

On Fri, 26 Jun 2009 21:27:04 +0200, Damien Carbonne wrote:

> Dmitry A. Kazakov a �crit :
>>> If this is true, it means that using in/out/in out modes is almost 
>>> impossible in the code I write if this code must be mixed with code from 
>>> third party libraries (like GtkAda) that use access almost everywhere. sad.
>> 
>> No, GtkAda does not use controlled or tagged types when it talks to Gtk.
>> Such types should not have C convention. Instead of that GtkAda associates
>> a C type with each tagged Ada one, which serves as a proxy. The address of
>> this C object can be obtained using the Get_Object call. You will often
>> find it in the implementation of GtkAda subroutines.
> 
> Of course, but I did not meant use of access types to interface C API.
> Just some examples from Gtk.Tree_Model:
> 
>     function Get_Iter_First
>       (Tree_Model : access Gtk_Tree_Model_Record) return Gtk_Tree_Iter;
> 
>     function Get_Path
>       (Tree_Model : access Gtk_Tree_Model_Record;
>        Iter       : Gtk_Tree_Iter) return Gtk_Tree_Path;
> 
>     procedure Next
>       (Tree_Model : access Gtk_Tree_Model_Record;
>        Iter       : in out Gtk_Tree_Iter);
> 
> Why use access everywhere ? In the case of functions, one could argue 
> that "in out" is not possible. But aren't there any cases where in is 
> sufficient for functions ? And for procedures ? Why not write what this:
>     procedure Next
>       (Tree_Model : in [out] Gtk_Tree_Model_Record;
>        Iter       : in out Gtk_Tree_Iter);
> 
> One obvious issue is that modes must be guessed from comments in 
> original C code, or from the C code itself. Thys may be hard to find 
> automatically.

The reason for that (as I can guess) is that GtkAda tries to mimic Gtk. So
that you call Get_Iter_First using Gtk_Tree_Model rather than
Gtk_Tree_Model_Record. Since Gtk_Tree_Model is an access type,
Get_Iter_First must deal with access Gtk_Tree_Model_Record in order to
become a primitive operation.

If I designed GtkAda I would probably tried to make it thicker hiding Gtk
reference counting behind Ada controlled types. Note that this would be
extremely tedious to do, because Ada lacks any means for building related
hierarchies of types. E.g. of handles (Gtk_Tree_Model) and objects they
refer to (Gtk_Tree_Model_Record).

The only way that works more or less automatic in Ada is anonymous access
types *because* of implicit conversion of pointers (named to anonymous).

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



  reply	other threads:[~2009-06-26 19:50 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-23 21:52 Issue with GNAT GPL 2009 and GtkAda Damien Carbonne
2009-06-24  7:40 ` Dmitry A. Kazakov
2009-06-24 10:15 ` Stephen Leake
2009-06-25  9:06   ` Stephen Leake
2009-06-25  9:39     ` Dmitry A. Kazakov
2009-06-25 19:02       ` Damien Carbonne
2009-06-26  9:31         ` Stephen Leake
2009-06-26 11:18           ` Niklas Holsti
2009-06-26 16:29             ` Damien Carbonne
2009-06-26 17:28               ` Dmitry A. Kazakov
2009-06-26 19:27                 ` Damien Carbonne
2009-06-26 19:50                   ` Dmitry A. Kazakov [this message]
2009-06-26 21:51             ` Randy Brukardt
2009-06-27 11:11               ` Stephen Leake
2009-06-27 17:04                 ` Robert A Duff
2009-06-30 11:11                   ` Stephen Leake
2009-06-30 18:10                     ` Robert A Duff
2009-06-29 22:11                 ` Randy Brukardt
2009-06-30 11:13                   ` Stephen Leake
2009-06-30 15:26                     ` Adam Beneschan
2009-06-30 15:59               ` Adam Beneschan
2009-06-30 23:11                 ` Randy Brukardt
2009-06-27  9:56             ` Stephen Leake
2009-06-26 21:03           ` Damien Carbonne
2009-06-27 11:21             ` Stephen Leake
2009-06-27 12:25               ` Damien Carbonne
2009-06-27 12:35                 ` Damien Carbonne
2009-06-29 22:15                   ` Randy Brukardt
2009-07-01 19:22                     ` Damien Carbonne
2009-06-30  0:48             ` Adam Beneschan
2009-06-30 11:18               ` Stephen Leake
2009-06-25 20:49       ` Randy Brukardt
2009-06-26  7:20         ` Dmitry A. Kazakov
2009-06-26  8:17           ` Georg Bauhaus
2009-06-26  8:52             ` Dmitry A. Kazakov
2009-06-26 21:38               ` Randy Brukardt
2009-06-27  7:47                 ` Dmitry A. Kazakov
2009-06-29 21:59                   ` Randy Brukardt
2009-06-30  8:31                     ` Dmitry A. Kazakov
2009-06-26 21:31           ` Randy Brukardt
2009-06-27  7:53             ` Dmitry A. Kazakov
2009-06-26  8:39       ` Alex R. Mosteo
2009-06-26  9:07         ` Dmitry A. Kazakov
2009-06-27  9:53           ` Stephen Leake
2009-06-26 21:40         ` Randy Brukardt
2009-06-29 10:04           ` Alex R. Mosteo
2009-06-26  9:02       ` Stephen Leake
2009-06-26  9:14         ` Dmitry A. Kazakov
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox