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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,3332d83c4f455808 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!postnews.google.com!f16g2000cwb.googlegroups.com!not-for-mail From: "Jerry" Newsgroups: comp.lang.ada Subject: Re: How to use Annex G.3 Vectors and Matrices in bindings to C arrays Date: 13 Nov 2006 03:20:02 -0800 Organization: http://groups.google.com Message-ID: <1163416802.221321.170270@f16g2000cwb.googlegroups.com> References: <1163303134.998680.268570@h54g2000cwb.googlegroups.com> NNTP-Posting-Host: 67.40.87.12 Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" X-Trace: posting.google.com 1163416806 11148 127.0.0.1 (13 Nov 2006 11:20:06 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 13 Nov 2006 11:20:06 +0000 (UTC) User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en-US) AppleWebKit/420+ (KHTML, like Gecko, Safari/420) OmniWeb/v607.5,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: f16g2000cwb.googlegroups.com; posting-host=67.40.87.12; posting-account=Ax24hA0AAABV39UFqUVhb0kauOuAbI3T Xref: g2news2.google.com comp.lang.ada:7424 Date: 2006-11-13T03:20:02-08:00 List-Id: Jeffrey R. Carter wrote: > Jerry wrote: > > > > I wonder if I am incorrect in believing that the binding to C-arrays > > need aliased components. Like I said, the reason for that is a little > > fuzzy to me right now. But I do know that if I remove the aliased > > component requirement from Long_Float_Array_1D the binding will not > > compile. > > What is the error message that you get? Are you taking 'access of > components of such arrays? > I'm afraid I'll have to apologize for not being accurate in my initial post. Indeed, I am not having any problems (as I erroneously claimed) with 1D arrays. The problem arises with 2D arrays, about which I pestered the list earlier. With further apologies for posting a bit more code that I would like, the following is a typical binding that I made in which it was necessary to gain access to 2D C arrays. procedure Mesh_3D_Base_Contour (x, y : Long_Float_Array_1D; -- surface definition points z : in out Long_Float_Array_2D; -- height of surface at definition points Options : Integer; Contour_Levels : Long_Float_Array_1D) is -- levels at which to draw contours package PL_Float_Pointers_Local is new Interfaces.C.Pointers (Index => Integer, Element => Long_Float, Element_Array => Long_Float_Array_1D, Default_Terminator => 0.0); use type PL_Float_Pointers_Local.Pointer; -- as in RM B.3.2 type PL_Float_Pointer_Array_Local is array (Integer range <>) of PL_Float_Pointers_Local.Pointer; -- array of pointers to Long_Floats which represent the first element of each row of z in C-land Index_Of_First_Column : Integer := z'First(2); z_As_Pointers : PL_Float_Pointer_Array_Local (z'range(1)); procedure plmeshc_local(x : PL_Float_Array; y : PL_Float_Array; z : PL_Float_Pointer_Array_Local; nx : Integer; ny : Integer; opt : Integer; clevel : PL_Float_Array; nlevel : PLINT); pragma Import(C, plmeshc_local, "c_plmeshc"); begin for Index in z'range(1) loop z_As_Pointers(Index) := z(Index, Index_Of_First_Column)'access; end loop; plmeshc_local(x, y, z_As_Pointers, x'Length, y'Length, Options, Contour_Levels, Contour_Levels'Length); -- pass z_As_Pointers here rather than z end Mesh_3D_Base_Contour; The related array definitions are: type Long_Float_Array_1D is array (Integer range <>) of aliased Long_Float; type Long_Float_Array_2D is array (Integer range <>, Integer range <>) of aliased Long_Float; The "thin" binding Ada procedure plmeshc is defined: procedure plmeshc(x : PL_Float_Array; y : PL_Float_Array; z : PL_Float_Array_2D; nx : PLINT; ny : PLINT; opt : PLINT; clevel : PL_Float_Array; nlevel : PLINT); pragma Import(C, plmeshc, "c_plmeshc"); And the original C procedure is defined as here: http://plplot.sourceforge.net/docbook-manual/plplot-html-5.6.1/plmeshc.html So it appears that I need to use access variables to mimic the 2D C arrays, but the Annex G.3 Matrix definitions do not have aliased elements. So, if you re-read my original post and substitute "2D" for "1D" my original questions still stand. Jerry