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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,43b6c5f649185450 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-01-04 08:13:18 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!arclight.uoregon.edu!wn14feed!worldnet.att.net!bgtnsc04-news.ops.worldnet.att.net.POSTED!not-for-mail Reply-To: "James S. Rogers" From: "James S. Rogers" Newsgroups: comp.lang.ada References: <_BAR9.4055$FF4.251139@newsb.telia.net> Subject: Re: generic type identification X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Message-ID: Date: Sat, 04 Jan 2003 16:13:18 GMT NNTP-Posting-Host: 12.86.37.112 X-Complaints-To: abuse@worldnet.att.net X-Trace: bgtnsc04-news.ops.worldnet.att.net 1041696798 12.86.37.112 (Sat, 04 Jan 2003 16:13:18 GMT) NNTP-Posting-Date: Sat, 04 Jan 2003 16:13:18 GMT Organization: AT&T Worldnet Xref: archiver1.google.com comp.lang.ada:32530 Date: 2003-01-04T16:13:18+00:00 List-Id: "David Holm" wrote in message news:_BAR9.4055$FF4.251139@newsb.telia.net... > tmoran@acm.org wrote: > It is a thick binding to OpenGL. In case you have never seen the OpenGL API > it has one procedure for every type you can access it with. > For instance, glVertex has 24 different declarations depending on whether > you use (C) floats, doubles, integers, shorts etc and whether your send it > an array of 2, 3 or 4 coordinates with any of these types. > I was hoping to be able to create one interface for this in Ada (possibly by > using generic instead of overloading every procedure). But then I would > need to be able to identify which type is used in a call to say > AdaGL.Primitives.Vertex(some array) so that I know which binding to the C > library I should convert the parameters to and then call. > > Perhaps I could go with something like this? > http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=8903101703. AA04518%40ti.com > Another possibility is to create an abstract tagged type with one function and one procedure. The function will take a primitive (float, integer, etc.) and convert it to the corresponding tagged type. The procedure will take an instance of the tagged type and call the appropriate OpenGL binding. type GL_Binding is abstract tagged null record; procedure Access_GL(Item : GL_Binding) is abstract; Each package creating a concrete instance of the tagged type GL_Binding would also define a function (basically a constructor) creating an instance of that concrete tagged type from the appropriate scalar type. type GL_Integer_Binding is new GL_Binding with record Value : Integer; end record; procedure Access_GL(Item : GL_Integer_Binding); function Create(Item : Integer) return GL_Integer_Binding; Do this for each numeric type you need to bind. Calling the appropriate binding is then very simple. Pixel_Location : Integer; Access_GL(Create(Pixel_Location)); Jim Rogers