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=-2.1 required=5.0 tests=BAYES_00,HELO_NO_DOMAIN, MAILING_LIST_MULTI,RDNS_NONE autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,5d708145f98f6273 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2004-04-13 15:03:58 PST Path: archiver1.google.com!news1.google.com!news.glorb.com!news.cs.univ-paris8.fr!proxad.net!usenet-fr.net!enst.fr!melchior!cuivre.fr.eu.org!melchior.frmug.org!not-for-mail From: zhenglonggen Newsgroups: comp.lang.ada Subject: Re: Access type conversions, how? Date: Tue, 13 Apr 2004 22:57:12 +0800 Organization: Cuivre, Argent, Or Message-ID: References: NNTP-Posting-Host: lovelace.ada-france.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Trace: melchior.cuivre.fr.eu.org 1081893603 75758 212.85.156.195 (13 Apr 2004 22:00:03 GMT) X-Complaints-To: usenet@melchior.cuivre.fr.eu.org NNTP-Posting-Date: Tue, 13 Apr 2004 22:00:03 +0000 (UTC) To: comp.lang.ada@ada-france.org Return-Path: X-Originating-IP: [202.102.97.4] User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.9) Gecko/20020408 X-Accept-Language: zh-cn, en-us, en X-Virus-Scanned: by amavisd-new-20030616-p7 (Debian) at ada-france.org X-BeenThere: comp.lang.ada@ada-france.org X-Mailman-Version: 2.1.4 Precedence: list List-Id: "Gateway to the comp.lang.ada Usenet newsgroup" List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Xref: archiver1.google.com comp.lang.ada:7062 Date: 2004-04-13T22:57:12+08:00 Luke A. Guest wrote: >Hi, > >We have the following in our GL package: > >package C renames Interfaces.C; >... >type GLfloat is new C.C_float; >... >type GLfloatPtr is access all GLfloat; >... >procedure glMultMatrixf(M : in GLfloatPtr); > >Now, in my code, I've created a Matrix package which has as it's type: > >type Object is array(Integer range 0 .. 15) of aliased Float; >Now, I've made it aliased because I want to pass this to glMultMatrixf, >but for some reason I cannot work out exactly how to do it. > >I've tried all sorts, like: > >GL.glMultMatrixf(M(M'First)'Unchecked_Access); -- Wrong type > The following code works: with Ada.Text_Io; use Ada.Text_Io; with System; use System; with Interfaces.C; use Interfaces.C; procedure Test_access2address is type GLFloat is new C_Float; type GLFloat_Ptr is access all GLFloat; type Object is array(0..15) of aliased GLFloat; type Object_Ptr is access all Object; function Access2address(An_Object_Ptr:Object_Ptr) return GLFloat_Ptr is A_GLfloat:aliased GLFloat; for A_GLFloat'Address use An_Object_Ptr(1)'Address; begin return A_GLfloat'Unchecked_Access; end; procedure Test(A_Float:GLFloat_Ptr) is begin Put_Line("the first element is "&GLfloat'Image(A_Float.all)); end; My_Object:aliased Object; begin My_Object(1):=0.001; Test(Access2address(My_Object'Access)); end;