comp.lang.ada
 help / color / mirror / Atom feed
From: Stephen Leake <Stephen.Leake@gsfc.nasa.gov>
Subject: Re: Generic package vs GTK callbacks.
Date: 2000/02/01
Date: 2000-02-01T23:09:37+00:00	[thread overview]
Message-ID: <uu2jsseuq.fsf@gsfc.nasa.gov> (raw)
In-Reply-To: 38955D00.FBBBA05D@mail.utexas.edu

"Bobby D. Bryant" <bdbryant@mail.utexas.edu> writes:

> I have a generic package that I want to instantiate at some arbitrary
> depth in my code, so I can prompt for some user values before I
> instantiate it.  <snip>
> 
> The problem arises because after instantiation I want to "talk to" the
> instantiated with GTK callbacks. <snip>
> 
> However, if I declare the callback functions within the declaration part
> of the procedure that instantiates the package, GNAT complains with the
> familiar "subprogram must not be deeper than access type". 
> <snip>

> Is there a trick for working around this kind of problem?

Unfortunately, you can't use 'Unchecked_Access for subprograms (RM
13.10 (5)). However, if you are using GNAT, you can try
'Unrestricted_Access. As the GNAT Reference Manual says, "this is a
user-beware attribute"; you can get dangling references and other
problems. From your description, I think you would be ok. Make sure
you put in comments that "prove" you won't get dangling references;
you need to understand when Gtk saves pointers, and when it frees them
(usually when the associated object is "destroyed"). Good luck - I've
just started using Gtk, and find it very confusing on this point.

For a totally different approach, if you are on Win32, try using my
Windex system (http://users.erols.com/leakstan/Stephe/Ada/windex.html)
instead of Gtk. Windex takes a totally different approach to handling
windows events; instead of requiring library-level "callbacks", you
can define a local tagged window type and override the window event
handler functions. I haven't needed to do this yet, but you can.

Windex is _not_ as powerful as Gtk (yet), but this is one situation
where it appears to be better :).

-- Stephe




  reply	other threads:[~2000-02-01  0:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-01-31  0:00 Generic package vs GTK callbacks Bobby D. Bryant
2000-02-01  0:00 ` Stephen Leake [this message]
2000-02-01  0:00   ` Bobby D. Bryant
replies disabled

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