comp.lang.ada
 help / color / mirror / Atom feed
* Help! (How to do this (C) in Ada?
@ 1999-05-13  0:00 byhoe
  1999-05-13  0:00 ` Hyman Rosen
  1999-05-16  0:00 ` Robert Dewar
  0 siblings, 2 replies; 6+ messages in thread
From: byhoe @ 1999-05-13  0:00 UTC (permalink / raw)


I am puzzle with the following C code:

#define InheritLayout ((Boolean (*)())_Inherit)


How can I implement the above in Ada?

Anyone? Please help.

Thanks in advance.


--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---




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

* Re: Help! (How to do this (C) in Ada?
  1999-05-13  0:00 Help! (How to do this (C) in Ada? byhoe
@ 1999-05-13  0:00 ` Hyman Rosen
  1999-05-14  0:00   ` dennison
  1999-05-16  0:00 ` Robert Dewar
  1 sibling, 1 reply; 6+ messages in thread
From: Hyman Rosen @ 1999-05-13  0:00 UTC (permalink / raw)


byhoe@my-dejanews.com writes:
> I am puzzle with the following C code:
> #define InheritLayout ((Boolean (*)())_Inherit)
> How can I implement the above in Ada?

In C, this is a typecast of the value of _Inherit (whatever that is)
into a pointer to a function which takes no arguments and returns a
Boolean (whatever that is). I don't know Ada myself, but my guess
would be that in Ada you declare a type which is access to the correct
type of function, then use unchecked_conversion to convert _Inherit to
that type.

I suspect you will get better information on how to use a more
Ada-appropriate style if you describe your actual design and what
it is meant to accomplish.




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

* Re: Help! (How to do this (C) in Ada?
  1999-05-13  0:00 ` Hyman Rosen
@ 1999-05-14  0:00   ` dennison
  1999-05-14  0:00     ` Hyman Rosen
  0 siblings, 1 reply; 6+ messages in thread
From: dennison @ 1999-05-14  0:00 UTC (permalink / raw)


In article <t7aev8ejp4.fsf@calumny.jyacc.com>,
  Hyman Rosen <hymie@prolifics.com> wrote:
> byhoe@my-dejanews.com writes:
> > I am puzzle with the following C code:
> > #define InheritLayout ((Boolean (*)())_Inherit)
> > How can I implement the above in Ada?
>
> In C, this is a typecast of the value of _Inherit (whatever that is)
> into a pointer to a function which takes no arguments and returns a
> Boolean (whatever that is). I don't know Ada myself, but my guess
> would be that in Ada you declare a type which is access to the correct
> type of function, then use unchecked_conversion to convert _Inherit to
> that type.

You probably wouldn't need unchecked conversion, since the types would
be the same. But then again, if you are somewhat carful about how you
define your types, you might not need this conversion routine at all.

--
T.E.D.


--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---




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

* Re: Help! (How to do this (C) in Ada?
  1999-05-14  0:00   ` dennison
@ 1999-05-14  0:00     ` Hyman Rosen
  0 siblings, 0 replies; 6+ messages in thread
From: Hyman Rosen @ 1999-05-14  0:00 UTC (permalink / raw)


dennison@telepath.com writes:
> You probably wouldn't need unchecked conversion, since the types would
> be the same. But then again, if you are somewhat carful about how you
> define your types, you might not need this conversion routine at all.

If I recall the circumstances in which this type of code is used
(Xt widgets have a lot of this), _Inherit won't be a function.
It will be some integer value such as 1.




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

* Re: Help! (How to do this (C) in Ada?
  1999-05-13  0:00 Help! (How to do this (C) in Ada? byhoe
  1999-05-13  0:00 ` Hyman Rosen
@ 1999-05-16  0:00 ` Robert Dewar
  1999-05-17  0:00   ` byhoe
  1 sibling, 1 reply; 6+ messages in thread
From: Robert Dewar @ 1999-05-16  0:00 UTC (permalink / raw)


In article <7heg6m$43a$1@nnrp1.deja.com>,
  byhoe@my-dejanews.com wrote:
> I am puzzle with the following C code:
>
> #define InheritLayout ((Boolean (*)())_Inherit)
>
> How can I implement the above in Ada?
>
> Anyone? Please help.
>
> Thanks in advance.

This is much too low a level question. Any idea of translating
individual C statements into Ada is in the general case flawed,
though it may make sense in the context of a particular binding.
You need to give more context for why you are asking the
above question, and explain what the symbols mean. For example,
one assumes Boolean is what you might guess, but from what
you gave, it might itself be a fancy macro, especially since
you are not using the standard C style of all upper case for
macro names!



--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---




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

* Re: Help! (How to do this (C) in Ada?
  1999-05-16  0:00 ` Robert Dewar
@ 1999-05-17  0:00   ` byhoe
  0 siblings, 0 replies; 6+ messages in thread
From: byhoe @ 1999-05-17  0:00 UTC (permalink / raw)


In article <7hmc99$jrm$1@nnrp1.deja.com>,
  Robert Dewar <robert_dewar@my-dejanews.com> wrote:
> In article <7heg6m$43a$1@nnrp1.deja.com>,
>   byhoe@my-dejanews.com wrote:
> > I am puzzle with the following C code:
> >
> > #define InheritLayout ((Boolean (*)())_Inherit)
> >
> > How can I implement the above in Ada?
> >
> > Anyone? Please help.
> >
> > Thanks in advance.
>
> This is much too low a level question. Any idea of translating
> individual C statements into Ada is in the general case flawed,
> though it may make sense in the context of a particular binding.
> You need to give more context for why you are asking the
> above question, and explain what the symbols mean. For example,
> one assumes Boolean is what you might guess, but from what
> you gave, it might itself be a fancy macro, especially since
> you are not using the standard C style of all upper case for
> macro names!



In fact, I found this line in one of the code extension to the X11
library. There is an identical line which can be found in X11, Xaw's
FormP.h. I don't understand why this line is duplicated in the third
party library but I believe there is its usage somewhere which I cannot
find any instances.

_Inherit can be traced to be identical to _XtInherit which is declare in
X11's IntrinsicP.h as:

extern void _XtInherit (void);

(The same in my third party library but without the Xt, eg, _Inherit.)


--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---




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

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

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-05-13  0:00 Help! (How to do this (C) in Ada? byhoe
1999-05-13  0:00 ` Hyman Rosen
1999-05-14  0:00   ` dennison
1999-05-14  0:00     ` Hyman Rosen
1999-05-16  0:00 ` Robert Dewar
1999-05-17  0:00   ` byhoe

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