comp.lang.ada
 help / color / mirror / Atom feed
* What does this error mean and how do I correct this?
@ 2023-09-01 21:04 richardthiebaud
  2023-09-01 21:41 ` Luke A. Guest
  0 siblings, 1 reply; 7+ messages in thread
From: richardthiebaud @ 2023-09-01 21:04 UTC (permalink / raw)


in the following program:

with Gtk.Enums; use Gtk.Enums;
with Gtk.Main;
with Gtk.Window;
with Gdk;
with Gdk.Event;
with Glib;
with Glib.Object;

procedure test1 is
    Win       : Gtk.Window.Gtk_Window;
    function Handler
      (Self  : access Glib.Object.GObject_Record'Class;
       Event : Gdk.Event.Gdk_Event_Button) return Boolean is
    begin
       Gtk.Main.Main_Quit;
       return True;
    end Handler;
    --
    --  defined in gtk-widget.ads
    --
    --  type Cb_GObject_Gdk_Event_Button_Boolean is not null access function
    --  (Self  : access Glib.Object.GObject_Record'Class;
    --   Event : Gdk.Event.Gdk_Event_Button) return Boolean;

begin  -- Gtk.Init;
    Gtk.Main.Init;
    Gtk.Window.Gtk_New (Window => Win, The_Type => 
Gtk.Enums.Window_Toplevel);
    Win.Set_Position (Win_Pos_Center);
    Gtk.Window.Set_Title (Window => Win, Title => "Editor");
    Gtk.Window.Show_All (Win);
    Win.On_Button_Press_Event     <------------ line that gets the error
       (Call =>  Handler'Access,
        After => False,
        Slot =>  Win);
    Gtk.Main.Main;
end test1;

I get the compiler error message:

test1.adb:32:17: subprogram must not be deeper than access type

What does this mean and how can I correct it?

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

* Re: What does this error mean and how do I correct this?
  2023-09-01 21:04 What does this error mean and how do I correct this? richardthiebaud
@ 2023-09-01 21:41 ` Luke A. Guest
  2023-09-01 21:44   ` Luke A. Guest
  0 siblings, 1 reply; 7+ messages in thread
From: Luke A. Guest @ 2023-09-01 21:41 UTC (permalink / raw)


Handler needs to be in a package you with.

On 01/09/2023 22:04, richardthiebaud wrote:
> in the following program:
> 
> with Gtk.Enums; use Gtk.Enums;
> with Gtk.Main;
> with Gtk.Window;
> with Gdk;
> with Gdk.Event;
> with Glib;
> with Glib.Object;
> 
> procedure test1 is
>     Win       : Gtk.Window.Gtk_Window;
>     function Handler
>       (Self  : access Glib.Object.GObject_Record'Class;
>        Event : Gdk.Event.Gdk_Event_Button) return Boolean is
>     begin
>        Gtk.Main.Main_Quit;
>        return True;
>     end Handler;
>     --
>     --  defined in gtk-widget.ads
>     --
>     --  type Cb_GObject_Gdk_Event_Button_Boolean is not null access 
> function
>     --  (Self  : access Glib.Object.GObject_Record'Class;
>     --   Event : Gdk.Event.Gdk_Event_Button) return Boolean;
> 
> begin  -- Gtk.Init;
>     Gtk.Main.Init;
>     Gtk.Window.Gtk_New (Window => Win, The_Type => 
> Gtk.Enums.Window_Toplevel);
>     Win.Set_Position (Win_Pos_Center);
>     Gtk.Window.Set_Title (Window => Win, Title => "Editor");
>     Gtk.Window.Show_All (Win);
>     Win.On_Button_Press_Event     <------------ line that gets the error
>        (Call =>  Handler'Access,
>         After => False,
>         Slot =>  Win);
>     Gtk.Main.Main;
> end test1;
> 
> I get the compiler error message:
> 
> test1.adb:32:17: subprogram must not be deeper than access type
> 
> What does this mean and how can I correct it?

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

* Re: What does this error mean and how do I correct this?
  2023-09-01 21:41 ` Luke A. Guest
@ 2023-09-01 21:44   ` Luke A. Guest
  2023-09-01 22:51     ` richardthiebaud
  0 siblings, 1 reply; 7+ messages in thread
From: Luke A. Guest @ 2023-09-01 21:44 UTC (permalink / raw)


On 01/09/2023 22:41, Luke A. Guest wrote:
> Handler needs to be in a package you with.
> 

>> begin  -- Gtk.Init;
>>     Gtk.Main.Init;
>>     Gtk.Window.Gtk_New (Window => Win, The_Type => 
>> Gtk.Enums.Window_Toplevel);
>>     Win.Set_Position (Win_Pos_Center);
>>     Gtk.Window.Set_Title (Window => Win, Title => "Editor");
>>     Gtk.Window.Show_All (Win);
>>     Win.On_Button_Press_Event     <------------ line that gets the error
>>        (Call =>  Handler'Access,
>>         After => False,
>>         Slot =>  Win);
>>     Gtk.Main.Main;
>> end test1;
>>
>> I get the compiler error message:
>>
>> test1.adb:32:17: subprogram must not be deeper than access type

Ada doesn't like 'access types to be in an area that can go out of scope 
iirc. You can get around it with unchecked_access, but if you put 
handler into a package of it's own, it's at library level and is 
available to grab the access of.

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

* Re: What does this error mean and how do I correct this?
  2023-09-01 21:44   ` Luke A. Guest
@ 2023-09-01 22:51     ` richardthiebaud
  2023-09-03 14:06       ` Simon Wright
  0 siblings, 1 reply; 7+ messages in thread
From: richardthiebaud @ 2023-09-01 22:51 UTC (permalink / raw)


On 9/1/23 17:44, Luke A. Guest wrote:
> On 01/09/2023 22:41, Luke A. Guest wrote:
>> Handler needs to be in a package you with.
>>
> 
>>> begin  -- Gtk.Init;
....;
>>>
>>> test1.adb:32:17: subprogram must not be deeper than access type
> 
> Ada doesn't like 'access types to be in an area that can go out of scope 
> iirc. You can get around it with unchecked_access, but if you put 
> handler into a package of it's own, it's at library level and is 
> available to grab the access of.
> 
That worked, thanks. Under gtkada, must procedures that handle events 
always be in their own package?

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

* Re: What does this error mean and how do I correct this?
  2023-09-01 22:51     ` richardthiebaud
@ 2023-09-03 14:06       ` Simon Wright
  2023-09-03 15:22         ` Luke A. Guest
  2023-09-03 18:44         ` Simon Wright
  0 siblings, 2 replies; 7+ messages in thread
From: Simon Wright @ 2023-09-03 14:06 UTC (permalink / raw)


richardthiebaud <thiebauddick2@aol.com> writes:

> Under gtkada, must procedures that handle events always be in their
> own package?

In general, they'd need to be in _a_ package. You could group related
event handlers in a package.

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

* Re: What does this error mean and how do I correct this?
  2023-09-03 14:06       ` Simon Wright
@ 2023-09-03 15:22         ` Luke A. Guest
  2023-09-03 18:44         ` Simon Wright
  1 sibling, 0 replies; 7+ messages in thread
From: Luke A. Guest @ 2023-09-03 15:22 UTC (permalink / raw)


On 03/09/2023 15:06, Simon Wright wrote:
> richardthiebaud <thiebauddick2@aol.com> writes:
> 
>> Under gtkada, must procedures that handle events always be in their
>> own package?
> 
> In general, they'd need to be in _a_ package. You could group related
> event handlers in a package.

It's because what is beteen this:

procedure test1 is

and

begin -- test1

is on the stack and therefore not in permanent memory.


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

* Re: What does this error mean and how do I correct this?
  2023-09-03 14:06       ` Simon Wright
  2023-09-03 15:22         ` Luke A. Guest
@ 2023-09-03 18:44         ` Simon Wright
  1 sibling, 0 replies; 7+ messages in thread
From: Simon Wright @ 2023-09-03 18:44 UTC (permalink / raw)


Simon Wright <simon@pushface.org> writes:

> richardthiebaud <thiebauddick2@aol.com> writes:
>
>> Under gtkada, must procedures that handle events always be in their
>> own package?
>
> In general, they'd need to be in _a_ package. You could group related
> event handlers in a package.

I mean, if you had handlers for button A press & button A release they
could be grouped in one package. Int might make more sense for button B
event handlers to be grouped in another package. All depends on the
application 

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

end of thread, other threads:[~2023-09-03 18:44 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-01 21:04 What does this error mean and how do I correct this? richardthiebaud
2023-09-01 21:41 ` Luke A. Guest
2023-09-01 21:44   ` Luke A. Guest
2023-09-01 22:51     ` richardthiebaud
2023-09-03 14:06       ` Simon Wright
2023-09-03 15:22         ` Luke A. Guest
2023-09-03 18:44         ` Simon Wright

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