1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120 | -- SPDX-FileCopyrightText: 2020 Max Reznik <reznikmm@gmail.com>
--
-- SPDX-License-Identifier: MIT
----------------------------------------------------------------
with Ada.Containers.Hashed_Maps;
with Ada.Exceptions;
with League.JSON.Objects;
with League.Stream_Element_Vectors;
with League.String_Vectors;
with League.Strings;
with Spawn.Processes;
with Jupyter.Kernels;
package Ada_Kernels is
type Kernel is limited new Jupyter.Kernels.Kernel with private;
procedure Initialize
(Self : in out Kernel'Class;
Top_Dir : League.Strings.Universal_String;
Error : out League.Strings.Universal_String);
private
type Gprbuild_Options is record
Path : League.Strings.Universal_String;
Gargs : League.String_Vectors.Universal_String_Vector;
Cargs : League.String_Vectors.Universal_String_Vector;
Largs : League.String_Vectors.Universal_String_Vector;
Bargs : League.String_Vectors.Universal_String_Vector;
end record;
procedure Append
(Args : in out League.String_Vectors.Universal_String_Vector;
Option : Gprbuild_Options);
type Session is limited new Jupyter.Kernels.Session
and Spawn.Processes.Process_Listener
with record
Gprbuild : Gprbuild_Options;
Gnatchop : League.Strings.Universal_String;
Process : Spawn.Processes.Process;
Directory : League.Strings.Universal_String;
-- Each session has its own directory
IO_Pub : Jupyter.Kernels.IO_Pub_Access;
Stdout : League.Stream_Element_Vectors.Stream_Element_Vector;
Stderr : League.Stream_Element_Vectors.Stream_Element_Vector;
Service : League.Stream_Element_Vectors.Stream_Element_Vector;
Injected : Boolean := False;
Finished : Boolean := True;
Ready : Boolean := True; -- Driver's ready to get next Command
Clauses : League.String_Vectors.Universal_String_Vector;
Runs : League.String_Vectors.Universal_String_Vector;
end record;
overriding procedure Execute
(Self : aliased in out Session;
IO_Pub : not null Jupyter.Kernels.IO_Pub_Access;
Execution_Counter : Positive;
Code : League.Strings.Universal_String;
Silent : Boolean;
User_Expressions : League.JSON.Objects.JSON_Object;
Allow_Stdin : Boolean;
Stop_On_Error : Boolean;
Expression_Values : out League.JSON.Objects.JSON_Object;
Error : in out Jupyter.Kernels.Execution_Error);
overriding procedure Standard_Output_Available (Self : in out Session);
overriding procedure Standard_Error_Available (Self : in out Session);
overriding procedure Finished
(Self : in out Session;
Exit_Code : Integer);
overriding procedure Error_Occurred
(Self : in out Session;
Process_Error : Integer);
overriding procedure Exception_Occurred
(Self : in out Session;
Occurrence : Ada.Exceptions.Exception_Occurrence);
type Session_Access is access all Session;
function Hash (Value : Positive) return Ada.Containers.Hash_Type is
(Ada.Containers.Hash_Type'Mod (Value));
package Session_Maps is new Ada.Containers.Hashed_Maps
(Key_Type => Positive,
Element_Type => Session_Access,
Hash => Hash,
Equivalent_Keys => "=");
type Kernel is limited new Jupyter.Kernels.Kernel with record
Top_Dir : League.Strings.Universal_String;
Gprbuild : League.Strings.Universal_String;
Gnatchop : League.Strings.Universal_String;
Driver : League.Strings.Universal_String;
Map : Session_Maps.Map;
Last_Id : Natural := 0;
end record;
overriding procedure Kernel_Info
(Self : aliased in out Kernel;
Result : out League.JSON.Objects.JSON_Object);
overriding procedure Create_Session
(Self : aliased in out Kernel;
Session_Id : Positive;
Result : out Jupyter.Kernels.Session_Access);
overriding function Get_Session
(Self : aliased in out Kernel;
Session_Id : Positive) return Jupyter.Kernels.Session_Access;
end Ada_Kernels;
|