Skip to content

Commit

Permalink
(demos) Source code gardening
Browse files Browse the repository at this point in the history
  • Loading branch information
zertovitch committed Jan 6, 2025
1 parent ccf99fb commit 49e0093
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
9 changes: 7 additions & 2 deletions demo/data_exchange_simple/exchange_hac_side_simple.adb
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,21 @@ procedure Exchange_HAC_Side_Simple is
i : Integer := 1234;

begin

--
-- Communication by VM variables.
-- Communication by VM variables (primitive).
--

HAT.Put_Line
(" HAC: VM Variable = [" &
Get_VM_Variable ("Demo_Variable") & ']');
Set_VM_Variable ("Demo_Variable", "String from HAC");

--
-- Communication by callbacks.
-- Communication by callbacks (typed).
--

In_Out_Callback (i);
HAT.Put_Line (" HAC: after callback, variable i has value:" & i'Image);

end Exchange_HAC_Side_Simple;
16 changes: 13 additions & 3 deletions demo/data_exchange_simple/exchange_native_side_simple.adb
Original file line number Diff line number Diff line change
Expand Up @@ -23,35 +23,45 @@ procedure Exchange_Native_Side_Simple is

BD : HAC_Sys.Builder.Build_Data;

procedure Run is
procedure Run_with_HAC is
post_mortem : Post_Mortem_Data;
begin

Interpret_on_Current_IO (BD, 1, "", post_mortem);

if Is_Exception_Raised (post_mortem.Unhandled) then
Put_Line (Current_Error, "HAC VM: raised " & Image (post_mortem.Unhandled));
Put_Line (Current_Error, Message (post_mortem.Unhandled));
end if;
end Run;

end Run_with_HAC;

begin

Register_All_Callbacks (BD);
Ada.Directories.Set_Directory ("data_exchange_simple");

for i in Positive loop
New_Line;
Put_Line
("Native: Run #" & i'Image &
" --------------------------------------------------------");

BD.Build_Main_from_File ("exchange_hac_side_simple.adb");

if BD.Build_Successful then
Set_Global_VM_Variable (BD, "String from Native");
Put_Line
("Native: VM variable (pre vitam) is: " &
Get_Global_VM_Variable (BD));
Run;

Run_with_HAC;

Put_Line
("Native: VM variable (post mortem) is: " &
Get_Global_VM_Variable (BD));
end if;
delay 1.5;
end loop;

end Exchange_Native_Side_Simple;
4 changes: 4 additions & 0 deletions src/apps/hac_mini.adb
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@ begin
if Argument_Count = 0 then
Put_Line (Current_Error, "Usage: hac_mini main.adb");
else

BD.Build_Main_from_File (Argument (1));

if BD.Build_Successful then

Interpret_on_Current_IO (BD, 1, "", post_mortem);

if Is_Exception_Raised (post_mortem.Unhandled) then
Put_Line (Current_Error, "HAC VM: raised " & Image (post_mortem.Unhandled));
Put_Line (Current_Error, Message (post_mortem.Unhandled));
Expand Down

0 comments on commit 49e0093

Please sign in to comment.