From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,65b902127ca8a604 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!netnews.web.de!npeer.de.kpn-eurorings.net!npeer-ng0.de.kpn-eurorings.net!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Issue with GNAT GPL 2009 and GtkAda Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <4A414EBB.8060204@free.fr> <1avd65rn49abv$.krcxo2gdzb16$.dlg@40tude.net> <4a43c9ce$0$420$426a74cc@news.free.fr> <4a44ae4e$0$6295$4f793bc4@news.tdc.fi> <4a44f758$0$1538$426a74cc@news.free.fr> <3d07k0r3scol$.l2mvcomfxk1c$.dlg@40tude.net> <4a452109$0$31437$426a34cc@news.free.fr> Date: Fri, 26 Jun 2009 21:50:32 +0200 Message-ID: <1vhj7stehejgf.g8k491cjoq7t$.dlg@40tude.net> NNTP-Posting-Date: 26 Jun 2009 21:50:32 CEST NNTP-Posting-Host: b6490422.newsspool4.arcor-online.net X-Trace: DXC=?0a?T5iUVg0L2C_`koXfC54IUKMZ;PMVKQWM;iL=h=AJK2P> X-Complaints-To: usenet-abuse@arcor.de Xref: g2news2.google.com comp.lang.ada:6648 Date: 2009-06-26T21:50:32+02:00 List-Id: 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