comp.lang.ada
 help / color / mirror / Atom feed
* X11Ada - Is Unchecked_Conversion commonly required?
@ 1997-07-14  0:00 James Thomas
  1997-07-17  0:00 ` Jon S Anthony
  0 siblings, 1 reply; 2+ messages in thread
From: James Thomas @ 1997-07-14  0:00 UTC (permalink / raw)



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.

-- 
jct  <jaimie.thomas@lmco.com>
     <jaimiethomas@earthlink.net>

"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




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: X11Ada - Is Unchecked_Conversion commonly required?
  1997-07-14  0:00 X11Ada - Is Unchecked_Conversion commonly required? James Thomas
@ 1997-07-17  0:00 ` Jon S Anthony
  0 siblings, 0 replies; 2+ messages in thread
From: Jon S Anthony @ 1997-07-17  0:00 UTC (permalink / raw)



In article <33CAE473.4079@earthlink.net> James Thomas <jaimiethomas@earthlink.net> writes:

> 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).


> 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,


> 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).


> 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.


> 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




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1997-07-17  0:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-07-14  0:00 X11Ada - Is Unchecked_Conversion commonly required? James Thomas
1997-07-17  0:00 ` Jon S Anthony

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