comp.lang.ada
 help / color / mirror / Atom feed
From: David Holm <david@realityrift.com>
Subject: Re: generic type identification
Date: Sun, 05 Jan 2003 03:28:20 GMT
Date: 2003-01-05T03:28:20+00:00	[thread overview]
Message-ID: <oDNR9.4572$LY2.262334@newsc.telia.net> (raw)
In-Reply-To: yKDR9.27314$p_6.2274825@bgtnsc04-news.ops.worldnet.att.net

James S. Rogers wrote:
> 
> 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

In this case I'd rather create a couple of overloaded procedures as the idea 
of the thick binding is to make it easier to access OpenGL from Ada.
This method would just make it harder since it would require one extra call 
for each time you pass values to OpenGL.

//David Holm



  reply	other threads:[~2003-01-05  3:28 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-01-04  1:50 generic type identification David Holm
2003-01-04  2:04 ` chris.danx
2003-01-04  5:39 ` tmoran
2003-01-04 12:39   ` David Holm
2003-01-04 16:13     ` James S. Rogers
2003-01-05  3:28       ` David Holm [this message]
2003-01-05 10:03         ` Gautier
2003-01-04 19:27     ` tmoran
2003-01-05  3:25       ` David Holm
2003-01-05  5:42         ` tmoran
2003-01-06 17:56     ` Stephen Leake
replies disabled

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