comp.lang.ada
 help / color / mirror / Atom feed
From: tmoran@bix.com
Subject: Re: generic procedure'address or pragma convention?
Date: 1996/04/07
Date: 1996-04-07T00:00:00+00:00	[thread overview]
Message-ID: <4k74lg$ni9@news2.delphi.com> (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.




             reply	other threads:[~1996-04-07  0:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-04-07  0:00 tmoran [this message]
1996-04-06  0:00 ` generic procedure'address or pragma convention? Robert Dewar
  -- strict thread matches above, loose matches on Subject: below --
1996-04-06  0:00 tmoran
1996-04-06  0:00 ` Robert Dewar
replies disabled

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