comp.lang.ada
 help / color / mirror / Atom feed
From: beser@tron.UUCP (Eric Beser)
Subject: Re: MOTIF BINDING
Date: 17 Sep 90 11:59:10 GMT	[thread overview]
Message-ID: <642@tron.UUCP> (raw)
In-Reply-To: 9009060654.AA09349@ajpo.sei.cmu.edu

In article <9009060654.AA09349@ajpo.sei.cmu.edu>, GBODSO1@NUSVM.BITNET (HC Eng) writes:

> a Motif binding.  (Please note that I am very new to Ada.)  In the OSF Motif
> toolkit, widgets are treated as objects and callbacks are passed as subprogram
> pointers.  I am dying to know how this could be implemented in Ada since Ada
> does not have a subprogram type.
> Presently I am coding my own "Motif" toolkit in Ada for the IBM RS/6000 and
> the stumbling block is the lack of the subprogram type (see Ada LI65).  I am
> solving the problem very unsatisfactorily by making the interface layer call
> a procedure CALLBACK(W) where W is the widget being activated.  Inside CALLBACK
> is a giant IF and ELSIF block to cater for every widget declared in my program.

At the last SigAda meeting in California, the discussion of callbacks in
X bindings was interesting, and highly compiler independent. There are
other ways to do what you want to do instead of the IF .. ELSIF block.
If the compiler supports it, procedure'Address could point to the head
of the procedure. However that is not often guaranteed. Task types may
be used, and in fact are used in some implementations of XT toolkit. If
there is an "Ada way" of doing things, this would fit the bill.

There are compiler specific pragmas (i.e. Meridian's pragma
call_in_Place) that generate code acceptable to callback, so that
procedure'address will actually work the way you want it to. 

The only other way to pass procedures as arguments are as action
procedures in generics. Your generic instantiation can call a C-level
interface procedure which calls your callback procedure. What you would
do is pass the address of the callback procedure to this interface
procedure that uses the C indirect calling mechanism.

I am developing a large reusable library for use by the Air Force, and
would be curious to see your results.

Eric Beser
Westinghouse Aerospace Software Engineering
(301) - 765 - 1010

      reply	other threads:[~1990-09-17 11:59 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1990-09-10 15:32 MOTIF BINDING HC Eng
1990-09-17 11:59 ` Eric Beser [this message]
replies disabled

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