|
|
DataMuseum.dkPresents historical artifacts from the history of: Rational R1000/400 Tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about Rational R1000/400 Tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: B T
Length: 2444 (0x98c)
Types: TextFile
Names: »B«
└─⟦a7d1ea751⟧ Bits:30000550 8mm tape, Rational 1000, !users!projects 94_04_11
└─⟦129cab021⟧ »DATA«
└─⟦this⟧
└─⟦f64eaa120⟧ Bits:30000752 8mm tape, Rational 1000, !projects 93 02 16
└─⟦6f12a12be⟧ »DATA«
└─⟦this⟧
└─⟦2f6cfab89⟧ Bits:30000547 8mm tape, Rational 1000, !projects 94-01-04
└─⟦d65440be7⟧ »DATA«
└─⟦this⟧
with Callback;
with System;
with Text_Io;
procedure Callback_Test is
-- These variables are stored here so that they will be active
-- when the C routine gets around to using them.
-- Alternatively these variables could be encapsulated in a package
-- specification. They should NOT be put into Register_the_subprogram
-- because they would cease to exist when that subprogram finishes.
Some_Descriptor : Callback.Function_Descriptor_Type;
Some_Subprogram_Value : System.Subprogram_Value;
-- This is the Ada subprogram to be called from C.
function Ada_Function (A, B, C, D : Integer) return Integer is
begin
Text_Io.Put_Line (" Ada_function was called.");
Text_Io.Put_Line (" The parameters are: ");
Text_Io.Put_Line (" A=" & Integer'Image (A));
Text_Io.Put_Line (" B=" & Integer'Image (B));
Text_Io.Put_Line (" C=" & Integer'Image (C));
Text_Io.Put_Line (" D=" & Integer'Image (D));
Text_Io.Put_Line (" Ada_function returning 27");
return 27;
end Ada_Function;
-- This procedure sets up a subprogram descriptor and passes the
-- result to a C routine. The C routine will store this value
-- in a global variable (known only to C). At a later point
-- Call_ada_from_C can be called to execute the Ada subprogram.
procedure Register_The_Subprogram is
procedure Register_Subprogram (Descriptor : System.Address);
pragma Interface (C, Register_Subprogram);
begin
Some_Subprogram_Value := Ada_Function'Subprogram_Value;
Some_Descriptor := Call_Back.Ada_To_C (Some_Subprogram_Value);
Register_Subprogram (Some_Descriptor'Address);
end Register_The_Subprogram;
-- This is a C routine which invokes the Ada subprogram that
-- was registered by Register_the_subprogram.
procedure Call_Ada_From_C;
pragma Interface (C, Call_Ada_From_C);
begin
Text_Io.Put_Line ("====> Example starts");
Register_The_Subprogram;
Text_Io.Put_Line (" Ada_function has been registered with the C program");
Text_Io.Put_Line (" Calling the C routine" &
"(which should call Ada_function)...");
Call_Ada_From_C; -- Execute Ada_function via a call to C.
Text_Io.Put_Line (" ...returned from the C routine");
Text_Io.Put_Line ("====> Example over");
end Callback_Test;
pragma Main;