X11Ada - Is Unchecked_Conversion commonly required? 
Author Message
 X11Ada - Is Unchecked_Conversion commonly required?

I've recently inherited a workload from a former associate who was
converting source code to use GNAT Ada95 with the Intermetrics X
bindings (he had been using Telesoft Ada 83 w/ their bindings).

What I've noticed is an apparent requirement to use Unchecked_Conversion
an *awful* lot. Examples (I'll try to keep these succinct)follow. What I
need to know is this - Am I just missing something here - or is this
prevalent use of UC really needed with the Intermetrics bindings?

1. When calling XtOpenDisplay, and passing X.Args.Argc to the argc
parameter, it is necessary (?) to use UC to convert the type of the
object to the type of the formal (X.Int_Access), although this is *not*
required for many other Intrinsics functions which take an argc
parameter (they use a type which is compatible with X.Args.Argc).

2. More commonly - it is not uncommon to pass a widget to XtAddCallback
as the "closure" parameter.  This was done rather simply when using
Telesoft's bindings, w/o using UC.  However, the type Widget in
Intermetrics' bindings is declared private, so UC appears to be
the only way to go ("closure" is of type XtPointer).

3. When using old-style args (not Va args), which is still required
for some subprograms, it is necessary to use UC to stuff data into
the XtArg.  UC was not needed in Telesoft's bindings.

I am finding more examples every day.  I am new to Ada 95 (but I'm an
Ada 83 veteran) and I've already learned about general access types,
aliased views and the like.  However, UC seems to be the only answer
in many cases.

--


"The greatest glory of the American Revolution was that it combined in
one indissoluble bond, the principles of civil government and
Christianity."
                                           - John Quincy Adams



Fri, 31 Dec 1999 03:00:00 GMT  
 X11Ada - Is Unchecked_Conversion commonly required?

Quote:

> What I've noticed is an apparent requirement to use Unchecked_Conversion
> an *awful* lot. Examples (I'll try to keep these succinct)follow. What I
> need to know is this - Am I just missing something here - or is this
> prevalent use of UC really needed with the Intermetrics bindings?

Unknown - you don't give enough information.  However, I can say this:
In my use of these bindings, I have not needed to use UC except for
the typical use in a callback structure (where X/Motif does not give
enough information to be able to do anything otherwise - in C/C++
these typically have a cast to the correct type).

Quote:
> 1. When calling XtOpenDisplay, and passing X.Args.Argc to the argc
> parameter, it is necessary (?) to use UC to convert the type of the

No, pass the 'Access of this argument:

       Argc              => X.Args.Argc'Access,

Quote:
> 2. More commonly - it is not uncommon to pass a widget to XtAddCallback
> as the "closure" parameter.  This was done rather simply when using
> Telesoft's bindings, w/o using UC.

This is an example of callback "data", so UC will be needed.  I'm sure
UC was used in this context too - just under the covers.  Note that
the Intermetric bindings are "thin" (a Good Thing, IMO).

Quote:
> 3. When using old-style args (not Va args), which is still required
> for some subprograms, it is necessary to use UC to stuff data into
> the XtArg.  UC was not needed in Telesoft's bindings.

Haven't done this, but that is probably true.

Quote:
> I am finding more examples every day.  I am new to Ada 95 (but I'm an

The rule of thumb would be, anywhere the X/Motif docs (say the O'Reily
books) say to cast, you will probably need to UC, as these are thin
bindings and directly reflect the C level semantics.  As I say, I
think this is a good thing as it doesn't pretend that the underlying
SW is anything but your typical C rubbish.  Plus, you can use the C
references pretty much verbatim - no need for extraneous documentation
for how the thick bindings work.

/Jon
--
Jon Anthony
OMI, Belmont, MA 02178
617.484.3383
"Nightmares - Ha!  The way my life's been going lately,
 Who'd notice?"  -- Londo Mollari



Mon, 03 Jan 2000 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. asSymbol -- Commonly Used at Runtime?

2. COMMONLY USED ALGORITHMS

3. Most Commonly Used Languages

4. Commonly used assemblers???

5. Commonly Used Interrupts

6. What are the commonly used design methods.

7. Req. for Packages of commonly used functions

8. Most commonly used version of PHP

9. Unchecked_Conversion

10. x11ada mouse ?

11. Unchecked_Conversion on different sized types -- problem?

12. Questions about Unchecked_Conversion

 

 
Powered by phpBB® Forum Software