aboutsummaryrefslogtreecommitdiffstats
path: root/translate/grt/grt-stacks.ads
diff options
context:
space:
mode:
Diffstat (limited to 'translate/grt/grt-stacks.ads')
-rw-r--r--translate/grt/grt-stacks.ads21
1 files changed, 20 insertions, 1 deletions
diff --git a/translate/grt/grt-stacks.ads b/translate/grt/grt-stacks.ads
index 920012cba..30b9f05b7 100644
--- a/translate/grt/grt-stacks.ads
+++ b/translate/grt/grt-stacks.ads
@@ -16,8 +16,24 @@
-- Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-- 02111-1307, USA.
with System; use System;
+with Ada.Unchecked_Conversion;
package Grt.Stacks is
+ -- Instance is the parameter of the process procedure.
+ -- This is in fact a fully opaque type whose content is private to the
+ -- process.
+ type Instance is limited private;
+ type Instance_Acc is access all Instance;
+ pragma Convention (C, Instance_Acc);
+
+ -- A process is identified by a procedure having a single private
+ -- parameter (its instance).
+ type Proc_Acc is access procedure (Self : Instance_Acc);
+ pragma Convention (C, Proc_Acc);
+
+ function To_Address is new Ada.Unchecked_Conversion
+ (Instance_Acc, System.Address);
+
type Stack_Type is new Address;
Null_Stack : constant Stack_Type := Stack_Type (Null_Address);
@@ -28,7 +44,8 @@ package Grt.Stacks is
-- Create a new stack, which on first execution will call FUNC with
-- an argument ARG.
- function Stack_Create (Func : Address; Arg : Address) return Stack_Type;
+ function Stack_Create (Func : Proc_Acc; Arg : Instance_Acc)
+ return Stack_Type;
-- Resume stack TO and save the current context to the stack pointed by
-- CUR.
@@ -50,6 +67,8 @@ package Grt.Stacks is
procedure Error_Null_Access;
pragma No_Return (Error_Null_Access);
private
+ type Instance is null record;
+
pragma Import (C, Stack_Init, "grt_stack_init");
pragma Import (C, Stack_Create, "grt_stack_create");
pragma Import (C, Stack_Switch, "grt_stack_switch");