comp.lang.ada
 help / color / mirror / Atom feed
From: "Jerry" <lanceboyle@qwest.net>
Subject: Re: How to use Annex G.3 Vectors and Matrices in bindings to C arrays
Date: 13 Nov 2006 21:28:30 -0800
Date: 2006-11-13T21:28:30-08:00	[thread overview]
Message-ID: <1163482110.776976.152950@b28g2000cwb.googlegroups.com> (raw)
In-Reply-To: 4558cc70$1_4@news.bluewin.ch


Gautier wrote:
> Yves Bailly:
>
> > So I'm not sure if it's actually possible to correctly pass nD arrays to
> > C code... Back again to my OpenGL code, I did things like this:
> > type Vector is array(1..3) of Float;
> > pragma Convention(C, Vector);
> > type Matrix is array(1..3) of Vector;
> > pragma Convention(C, Matrix);
> > ...and it worked quite well.
> >
> > But maybe this pragma works for nD arrays? I'm quite interested in the
> > answer (I'll test this as soon as I have some time).
>
> This is at least mentioned in the B.1 annex (verse 2), with exactly the
> example of a nD array's storage.
>
But that works only for constrained arrays--see my reply to Yves for
more detail. The whole problem with interfacing to 2D C arrays is that
they are constructed as arrays of pointers to other arrays. In Ada, we
can mimic this with an unconstrained array of access variables to other
other unconstrained arrays of Long_Floats--therein lies the nastiness.

> BTW, in my OpenGL code (GLOBE_3D.Math, body) there is...
>
>    type Matrix_44 is array(0..3,0..3) of aliased Real; -- for GL.MultMatrix
>    pragma Convention(Fortran, Matrix_44);  -- GL stores matrices columnwise
> 
Jerry




  reply	other threads:[~2006-11-14  5:28 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-12  3:45 How to use Annex G.3 Vectors and Matrices in bindings to C arrays Jerry
2006-11-12  8:45 ` Yves Bailly
2006-11-13 10:48   ` Jerry
2006-11-12 19:39 ` Jeffrey R. Carter
2006-11-13  7:09   ` tmoran
2006-11-13 11:20   ` Jerry
2006-11-13 17:42     ` Yves Bailly
2006-11-13 19:50       ` Gautier
2006-11-14  5:28         ` Jerry [this message]
2006-11-14  5:18       ` Jerry
2006-11-13 19:09     ` Jeffrey R. Carter
2006-11-14  7:31       ` Jerry
2006-11-14  7:54       ` Jerry
replies disabled

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