comp.lang.ada
 help / color / mirror / Atom feed
* generic procedure'address or pragma convention?
@ 1996-04-06  0:00 tmoran
  1996-04-06  0:00 ` Robert Dewar
  0 siblings, 1 reply; 4+ messages in thread
From: tmoran @ 1996-04-06  0:00 UTC (permalink / raw)


Is it likely that a compiler will support OS callbacks to a procedure
declared in a generic package body?  If not, is there some reasonably
portable trick to get the effect?




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

* Re: generic procedure'address or pragma convention?
  1996-04-06  0:00 generic procedure'address or pragma convention? tmoran
@ 1996-04-06  0:00 ` Robert Dewar
  0 siblings, 0 replies; 4+ messages in thread
From: Robert Dewar @ 1996-04-06  0:00 UTC (permalink / raw)


tmoran said

"Is it likely that a compiler will support OS callbacks to a procedure
declared in a generic package body?  If not, is there some reasonably
portable trick to get the effect?"

Can you be a little more explicit in what you want to do? Clearly you
cannot call a procedure in a generic package body, only in an instance
of this body. What problem are you trying to solve here?





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

* Re: generic procedure'address or pragma convention?
  1996-04-07  0:00 tmoran
@ 1996-04-06  0:00 ` Robert Dewar
  0 siblings, 0 replies; 4+ messages in thread
From: Robert Dewar @ 1996-04-06  0:00 UTC (permalink / raw)


tmoran says:

"I tried something like this in Alsys Personal ActivAda and they complain
about 'pragma call_in(actual_WndProc)' because it's not library level.
I tried their 'enter_callback;' stuff and it crashed.  The Ada 95 RM
says pragma convention may be restricted to library units. I can
certainly see that you can't straightforwardly generate link names
for generic instantiations, but they aren't necessary here.  And handling
code-sharing generics could take some cleverness.  That's why I asked
if its 'likely' that a compiler would support this sort of thing."

Well of course exactly what Convention pragmas are supported is indeed
implementation dependent. I would think that it is likely that an Ada 95
compiler would support your proposed usage. GNAT certainly does (of
course that does not prove that all Ada 95 compilers will, you will
have to check this compiler by compiler).





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

* Re: generic procedure'address or pragma convention?
@ 1996-04-07  0:00 tmoran
  1996-04-06  0:00 ` Robert Dewar
  0 siblings, 1 reply; 4+ messages in thread
From: tmoran @ 1996-04-07  0:00 UTC (permalink / raw)


>>Is it likely that a compiler will support OS callbacks to a procedure
>>declared in a generic package body?  If not, is there some reasonably
>>portable trick to get the effect?
>
>Can you be a little more explicit in what you want to do? Clearly you
>cannot call a procedure in a generic package body, only in an instance
>of this body. What problem are you trying to solve here?

  I would like to create something similar to:
generic
  with function a_WndProc(param_block:in parameters)
  return boolean
  is default_WndProc;
package Window is
..
package body Window is
  this_window:my_data_structure;
..
  procedure actual_WndProc(... -- parameters as per Windows or OS/2
  pragma convention (or whatever's appropriate if using Ada 83)
    -- various stuff, including making param_block from OS parameters
    if a_WndProc(param_block) ...
  end actual_WndProc;
..
  procedure create_window(...
  ...
    -- OS call to create a window, including passing
    -- actual_WndProc'address for a callback

The problem I'm trying to solve is to make an Ada version of
Microsoft Foundation Classes editor_window.do_something(...  style,
rather than the normal Ada's do_something(editor_window,...
by using generics.

I tried something like this in Alsys Personal ActivAda and they complain
about 'pragma call_in(actual_WndProc)' because it's not library level.
I tried their 'enter_callback;' stuff and it crashed.  The Ada 95 RM
says pragma convention may be restricted to library units. I can
certainly see that you can't straightforwardly generate link names
for generic instantiations, but they aren't necessary here.  And handling
code-sharing generics could take some cleverness.  That's why I asked
if its 'likely' that a compiler would support this sort of thing.




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

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

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-04-06  0:00 generic procedure'address or pragma convention? tmoran
1996-04-06  0:00 ` Robert Dewar
  -- strict thread matches above, loose matches on Subject: below --
1996-04-07  0:00 tmoran
1996-04-06  0:00 ` Robert Dewar

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