repo_name
stringlengths 9
74
| language
stringclasses 1
value | length_bytes
int64 11
9.34M
| extension
stringclasses 2
values | content
stringlengths 11
9.34M
|
---|---|---|---|---|
AdaCore/training_material | Ada | 16,593 | adb | -----------------------------------------------------------------------
-- Ada Labs --
-- --
-- Copyright (C) 2008-2013, AdaCore --
-- --
-- Labs is free software; you can redistribute it and/or modify it --
-- under the terms of the GNU General Public License as published by --
-- the Free Software Foundation; either version 2 of the License, or --
-- (at your option) any later version. --
-- --
-- This program is distributed in the hope that it will be useful, --
-- but WITHOUT ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --
-- General Public License for more details. You should have received --
-- a copy of the GNU General Public License along with this program; --
-- if not, write to the Free Software Foundation, Inc., 59 Temple --
-- Place - Suite 330, Boston, MA 02111-1307, USA. --
-----------------------------------------------------------------------
with Display.Kernel; use Display.Kernel;
with GL_gl_h; use GL_gl_h;
with Display.Basic.Fonts; use Display.Basic.Fonts;
with Display.Basic.Utils; use Display.Basic.Utils;
with Interfaces.C; use Interfaces.C;
with SDL_SDL_events_h; use SDL_SDL_events_h;
with SDL_SDL_video_h; use SDL_SDL_video_h;
with Display.Basic.GLFonts; use Display.Basic.GLFonts;
package body Display.Basic is
function Is_Killed return Boolean is
begin
return Is_Stopped;
end Is_Killed;
-- procedure Poll_Events is
-- E : aliased SDL_Event;
-- begin
-- while SDL_PollEvent (E'Access) /= 0 loop
-- case unsigned (E.c_type) is
-- when SDL_SDL_events_h.SDL_Quit =>
-- Killed := True;
-- SDL_SDL_h.SDL_Quit;
-- when SDL_SDL_events_h.SDL_MOUSEBUTTONDOWN =>
-- Internal_Cursor.Position := (Integer(E.motion.x), Integer(E.motion.y));
-- Internal_Cursor.Pressed := True;
-- when SDL_SDL_events_h.SDL_MOUSEBUTTONUP =>
-- Internal_Cursor.Position := (Integer(E.motion.x), Integer(E.motion.y));
-- Internal_Cursor.Pressed := False;
--
-- when others =>
-- null;
-- end case;
-- end loop;
-- end Poll_Events;
--
-- function At_End return Boolean is
-- begin
-- return Display.Kernel.At_End;
-- end At_End;
----------
-- Draw --
----------
type Windows_Array is array (Window_ID) of OpenGL_Surface;
Nb_Windows : Integer := 0;
Stored_Windows : Windows_Array;
function Create_Window (Width : Integer; Height : Integer; Name : String) return Window_ID is
Current_Id : Window_ID;
begin
if Nb_Windows = Windows_Array'Length then
raise Too_Many_Windows;
end if;
Current_Id := Window_ID (Integer (Window_ID'First) + Nb_Windows);
Stored_Windows(Current_Id) := Display.Kernel.Create_Window (Width, Height, Name);
Nb_Windows := Nb_Windows + 1;
return Current_Id;
end Create_Window;
procedure Swap_Buffers(Window : Window_ID; Erase : Boolean := True) is
begin
Display.Kernel.Swap_Buffers(Stored_Windows(Window));
end Swap_Buffers;
procedure Swap_Copy_Buffers(Window : Window_ID) is
begin
-- to be implemented properly
Display.Kernel.Swap_Buffers(Stored_Windows(Window));
end Swap_Copy_Buffers;
function Get_Zoom_Factor(Canvas : Canvas_ID) return Float is
begin
return Get_Internal_Canvas(Canvas).Zoom_Factor;
end Get_Zoom_Factor;
procedure Set_Zoom_Factor (Canvas : Canvas_ID; ZF : Float) is
C : T_Internal_Canvas := Get_Internal_Canvas(Canvas);
begin
Display.Basic.Utils.Set_Zoom_Factor(Canvas, ZF);
UpdateProjection(Canvas);
end Set_Zoom_Factor;
function Get_Canvas(Window : Window_ID) return Canvas_ID is
begin
return Stored_Windows(Window).Canvas;
end Get_Canvas;
procedure Set_Color(Color : RGBA_T) is
begin
glColor3d (double(Color.R) / 255.0,
double(Color.G) / 255.0,
double(Color.B) / 255.0);
end Set_Color;
procedure Fill(Canvas : Canvas_ID; Color: RGBA_T)
is
begin
raise Display_Error;
end Fill;
procedure Draw_Sphere (Canvas : Canvas_ID; Position : Point_3d; Radius : Float; Color: RGBA_T) is
IC : T_Internal_Canvas := Get_Internal_Canvas (Canvas);
begin
glPushMatrix;
glTranslated
(GLdouble (Position.X - (Float(IC.Center.X) * (1.0/IC.Zoom_Factor))),
GLdouble (Position.Y - (Float(IC.Center.Y) * (1.0/IC.Zoom_Factor))),
GLdouble (Position.Z));
Set_Color (Color);
if Radius < 0.1 then
Disable_3d_Light(Canvas_ID'First);
glBegin(GL_POINTS);
glVertex2i(0, 0);
glEnd;
Enable_3d_Light(Canvas_ID'First);
else
Display.Kernel.Draw_Sphere(Radius, Color);
end if;
glPopMatrix;
end Draw_Sphere;
procedure Draw_Sphere (Canvas : Canvas_ID; Position: Screen_Point; Radius : Integer; Color: RGBA_T) is
begin
raise Display_Error;
end Draw_Sphere;
procedure Draw_Circle (Canvas : Canvas_ID; Position: Point_3d; Radius : Float; Color: RGBA_T) is
IC : T_Internal_Canvas := Get_Internal_Canvas(Canvas);
begin
glPushMatrix;
glTranslated
(GLdouble (Position.X - (Float(IC.Center.X) * (1.0/IC.Zoom_Factor))),
GLdouble (Position.Y - (Float(IC.Center.Y) * (1.0/IC.Zoom_Factor))),
GLdouble (Position.Z));
Set_Color (Color);
Disable_3d_Light(Canvas);
glShadeModel(GL_SMOOTH);
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);
glHint(GL_POINT_SMOOTH_HINT, GL_NICEST);
glEnable(GL_LINE_SMOOTH);
glEnable(GL_POLYGON_SMOOTH);
glEnable(GL_POINT_SMOOTH);
DrawDisk(InnerRadius => Radius,
OuterRadius => Radius + 1.0,
VSlices => 40,
HSlices => 40,
Color => Color);
Enable_3d_Light (Canvas);
glPopMatrix;
end Draw_Circle;
procedure Draw_Circle (Canvas : Canvas_ID; Position: Screen_Point; Radius : Integer; Color: RGBA_T) is
begin
raise Display_Error;
end Draw_Circle;
procedure Draw_Line (Canvas : Canvas_ID; P1: Point_3d; P2 : Point_3d; Color: RGBA_T) is
begin
raise Display_Error;
end Draw_Line;
procedure Draw_Line (Canvas : Canvas_ID; P1: Screen_Point; P2 : Screen_Point; Color: RGBA_T) is
begin
raise Display_Error;
end Draw_Line;
procedure Draw_Text (Canvas : Canvas_ID; Position: Point_3d; Text : String; Color: RGBA_T; Bg_Color : RGBA_T := Black; Wrap: Boolean := True) is
-- S : access SDL_Surface;
--Format : UInt32;
IC : T_Internal_Canvas := Get_Internal_Canvas(Canvas);
Cursor : Screen_Point := (0, 0);
Font : BMP_Font := Font8x8;
w : Integer := Char_Size (Font).X;
h : Integer := Char_Size (Font).Y;
begin
glPushMatrix;
-- glTranslated
-- (GLdouble (Position.X),
-- GLdouble (Position.Y),
-- GLdouble (Position.Z));
glTranslated
(GLdouble (Position.X - (Float(IC.Center.X) * (1.0/IC.Zoom_Factor))),
GLdouble (Position.Y - (Float(IC.Center.Y) * (1.0/IC.Zoom_Factor))),
GLdouble (Position.Z));
glScalef(1.0/IC.Zoom_Factor,
1.0/IC.Zoom_Factor,
1.0/IC.Zoom_Factor);
--glMatrixMode(GL_PROJECTION);
--glPushMatrix;
--glLoadIdentity;
-- glOrtho(0.0, double(IC.Surface.w),
-- double(IC.Surface.h), 0.0, 0.0, 1.0);
Disable_3d_Light(Canvas);
glDisable(GL_DEPTH_TEST);
glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
-- glBlendFunc(GL_SRC_ALPHA, GL_ONE);--_MINUS_SRC_ALPHA);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
Set_Color (Color);
for C of Text loop
glBindTexture(GL_TEXTURE_2D, getCharTexture(C));
glBegin(GL_QUADS);
glTexCoord2f(0.0, 1.0); glVertex3f(Float(Cursor.X), Float(Cursor.Y), 0.0);
glTexCoord2f(0.0, 0.0); glVertex3f(Float(Cursor.X), Float(Cursor.Y) + Float(h), 0.0);
glTexCoord2f(1.0, 0.0); glVertex3f(Float(Cursor.X) + Float(w), Float(Cursor.Y) + Float(h), 0.0);
glTexCoord2f(1.0, 1.0); glVertex3f(Float(Cursor.X) + Float(w), Float(Cursor.Y), 0.0);
glEnd;
if Cursor.X + Char_Size (Font).X > Integer(IC.Surface.w) then
if Wrap then
Cursor.Y := Cursor.Y + h;
Cursor.X := 0;
else
exit;
end if;
else
Cursor.X := Cursor.X + w;
end if;
end loop;
glDisable(GL_TEXTURE_2D);
glDisable(GL_BLEND);
glEnable(GL_DEPTH_TEST);
Enable_3d_Light(Canvas);
-- glPopMatrix;
-- glMatrixMode(GL_MODELVIEW);
-- glLoadIdentity;
glPopMatrix;
end Draw_Text;
procedure Draw_Text (Canvas : Canvas_ID; Position: Screen_Point; Text : String; Color: RGBA_T; Bg_Color : RGBA_T := Black; Wrap: Boolean := True) is
--Format : UInt32 := SDL_PIXELFORMAT_RGBA32;
IC : T_Internal_Canvas := Get_Internal_Canvas(Canvas);
Cursor : Screen_Point := Position;
Font : BMP_Font := Font8x8;
w : Integer := Char_Size (Font).X;
h : Integer := Char_Size (Font).Y;
begin
Disable_3d_Light(Canvas);
glDisable(GL_DEPTH_TEST);
glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
-- glBlendFunc(GL_SRC_ALPHA, GL_ONE);--_MINUS_SRC_ALPHA);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glMatrixMode(GL_PROJECTION);
glPushMatrix;
glLoadIdentity;
glOrtho(0.0, double(IC.Surface.w),
double(IC.Surface.h), 0.0, 0.0, 1.0);
Set_Color (Color);
for C of Text loop
glBindTexture(GL_TEXTURE_2D, getCharTexture(C));
glBegin(GL_QUADS);
glTexCoord2f(0.0, 0.0); glVertex3f(Float(Cursor.X), Float(Cursor.Y), 0.0);
glTexCoord2f(0.0, 1.0); glVertex3f(Float(Cursor.X), Float(Cursor.Y) + Float(h), 0.0);
glTexCoord2f(1.0, 1.0); glVertex3f(Float(Cursor.X) + Float(w), Float(Cursor.Y) + Float(h), 0.0);
glTexCoord2f(1.0, 0.0); glVertex3f(Float(Cursor.X) + Float(w), Float(Cursor.Y), 0.0);
glEnd;
if Cursor.X + Char_Size (Font).X > Integer(IC.Surface.w) then
if Wrap then
Cursor.Y := Cursor.Y + h;
Cursor.X := 0;
else
exit;
end if;
else
Cursor.X := Cursor.X + w;
end if;
end loop;
glPopMatrix;
glMatrixMode(GL_MODELVIEW);
glLoadIdentity;
glDisable(GL_TEXTURE_2D);
glDisable(GL_BLEND);
glEnable(GL_DEPTH_TEST);
Enable_3d_Light(Canvas);
end Draw_Text;
procedure Draw_Rect (Canvas : Canvas_ID; Position : Point_3d; Width, Height : Float; Color : RGBA_T) is
begin
null;
-- raise Display_Error;
end Draw_Rect;
procedure Draw_Rect (Canvas : Canvas_ID; Position : Screen_Point; Width, Height : Integer; Color : RGBA_T) is
C : T_Internal_Canvas := Get_Internal_Canvas(Canvas);
begin
glMatrixMode(GL_PROJECTION);
glPushMatrix;
glLoadIdentity;
glOrtho(0.0, double(C.Surface.w),
double(C.Surface.h), 0.0, 0.0, 1.0);
Disable_3d_Light (Canvas);
Set_Color (Color);
glRecti(int (Position.X),
int (Position.Y),
int (Position.X + Width),
int (Position.Y + Height));
Enable_3d_Light (Canvas);
glPopMatrix;
glMatrixMode(GL_MODELVIEW);
glLoadIdentity;
end Draw_Rect;
procedure Draw_Fill_Rect (Canvas : Canvas_ID; Position : Point_3d; Width, Height : Float; Color : RGBA_T) is
begin
raise Display_Error;
end Draw_Fill_Rect;
procedure Draw_Fill_Rect (Canvas : Canvas_ID; Position : Screen_Point; Width, Height : Integer; Color : RGBA_T) is
C : T_Internal_Canvas := Get_Internal_Canvas(Canvas);
begin
glMatrixMode(GL_PROJECTION);
glPushMatrix;
glLoadIdentity;
glOrtho(0.0, double(C.Surface.w),
double(C.Surface.h), 0.0, 0.0, 1.0);
Disable_3d_Light (Canvas);
Set_Color (Color);
glRecti(int (Position.X),
int (Position.Y),
int (Position.X + Width),
int (Position.Y + Height));
Enable_3d_Light (Canvas);
glPopMatrix;
glMatrixMode(GL_MODELVIEW);
glLoadIdentity;
end Draw_Fill_Rect;
procedure Set_Pixel (Canvas : Canvas_ID; Position : Screen_Point; Color : RGBA_T) is
begin
raise Display_Error;
end Set_Pixel;
function Get_Text_Size(Text : String) return Screen_Point is
begin
return String_Size (Font8x8, Text);
end Get_Text_Size;
function Scale (Canvas: T_Internal_Canvas; L : Float) return Integer is (Integer (L * Canvas.Zoom_Factor));
procedure Set_Center (Canvas : Canvas_ID; Position : Point_3d) is
C : T_Internal_Canvas := Get_Internal_Canvas(Canvas);
begin
Display.Basic.Utils.Set_Center(Canvas, (Scale(C, Position.X), Scale(C, Position.Y)));
end Set_Center;
procedure Set_Center (Canvas : Canvas_ID; Position : Screen_Point) is
begin
Display.Basic.Utils.Set_Center(Canvas, Position);
end Set_Center;
function Get_Center (Canvas : Canvas_ID) return Screen_Point is
begin
return Display.Basic.Utils.Get_Center(Canvas);
end Get_Center;
function Get_Cursor_Status return Cursor_T is
begin
return Get_Internal_Cursor;
end Get_Cursor_Status;
function To_Point3d (Canvas : Canvas_ID; P : Screen_Point) return Point_3d is
C : T_Internal_Canvas := Get_Internal_Canvas(Canvas);
begin
return (Float(P.X - Integer(C.Surface.w / 2) - C.Center.X),
Float(Integer(C.Surface.h / 2) - C.Center.Y - P.Y),
0.0);
end To_Point3d;
function To_Screen_Point (Canvas : Canvas_ID; P : Point_3d) return Screen_Point is
C : T_Internal_Canvas := Get_Internal_Canvas(Canvas);
begin
return Screen_Point'(X => Integer (C.Zoom_Factor * P.X) + Integer(C.Surface.w / 2) - C.Center.X,
Y => Integer(C.Surface.h / 2) + C.Center.Y - Integer (C.Zoom_Factor * P.Y));
end To_Screen_Point;
function Get_Canvas_Size(Canvas : Canvas_ID) return Screen_Point is
C : T_Internal_Canvas := Get_Internal_Canvas(Canvas);
begin
return Screen_Point'(Integer(C.Surface.w), Integer(C.Surface.h));
end Get_Canvas_Size;
procedure Set_3d_Light (Canvas : Canvas_ID;
Position : Point_3d;
Diffuse_Color : RGBA_T;
Ambient_Color : RGBA_T) is
type GLFloat_Array is array (Natural range <>) of aliased GLfloat;
light_position : aliased GLFloat_Array
:= (Position.X, Position.Y, Position.Z, 1.0);
light_diffuse : aliased GLFloat_Array
:= (Float (Diffuse_Color.R) / 255.0,
Float (Diffuse_Color.G) / 255.0,
Float (Diffuse_Color.B) / 255.0, 1.0);
light_ambient : aliased GLFloat_Array :=
(Float (Ambient_Color.R) / 255.0,
Float (Ambient_Color.G) / 255.0,
Float (Ambient_Color.B) / 255.0, 1.0);
IC : T_Internal_Canvas := Get_Internal_Canvas (Canvas);
begin
glPushMatrix;
glTranslated
(GLdouble (- (Float(IC.Center.X) * (1.0/IC.Zoom_Factor))),
GLdouble (- (Float(IC.Center.Y) * (1.0/IC.Zoom_Factor))),
GLdouble (0.0));
glLightfv (GL_LIGHT0, GL_POSITION, light_position (0)'Access);
glLightfv (GL_LIGHT0, GL_DIFFUSE, light_diffuse (0)'Access);
glLightfv (GL_LIGHT0, GL_AMBIENT, light_ambient (0)'Access);
glPopMatrix;
end Set_3d_Light;
procedure Enable_3d_Light (Canvas : Canvas_ID) is
begin
glEnable (GL_LIGHTING);
glEnable (GL_LIGHT0);
end Enable_3d_Light;
procedure Disable_3d_Light (Canvas : Canvas_ID) is
begin
glDisable (GL_LIGHTING);
glDisable (GL_LIGHT0);
end Disable_3d_Light;
end Display.Basic;
|
reznikmm/matreshka | Ada | 6,413 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with League.Holders;
with AMF.CMOF.Associations;
with AMF.CMOF.Properties;
with AMF.Elements;
with AMF.Extents;
package AMF.Listeners is
pragma Preelaborate;
type Abstract_Listener is limited interface;
type Listener_Access is access all Abstract_Listener'Class;
not overriding procedure Facility_Start
(Self : not null access Abstract_Listener) is null;
not overriding procedure Facility_Shutdown
(Self : not null access Abstract_Listener) is null;
not overriding procedure Transaction_Start
(Self : not null access Abstract_Listener) is null;
not overriding procedure Transaction_Commit
(Self : not null access Abstract_Listener) is null;
not overriding procedure Transaction_Rollback
(Self : not null access Abstract_Listener) is null;
not overriding procedure Extent_Create
(Self : not null access Abstract_Listener;
Extent : not null AMF.Extents.Extent_Access) is null;
not overriding procedure Extent_Remove
(Self : not null access Abstract_Listener;
Extent : not null AMF.Extents.Extent_Access) is null;
not overriding procedure Instance_Create
(Self : not null access Abstract_Listener;
Element : not null AMF.Elements.Element_Access) is null;
not overriding procedure Instance_Remove
(Self : not null access Abstract_Listener;
Element : not null AMF.Elements.Element_Access) is null;
not overriding procedure Attribute_Add
(Self : not null access Abstract_Listener;
Property : not null AMF.CMOF.Properties.CMOF_Property_Access;
Position : AMF.Optional_Integer;
Old_Value : League.Holders.Holder;
New_Value : League.Holders.Holder) is null;
not overriding procedure Attribute_Remove
(Self : not null access Abstract_Listener;
Property : not null AMF.CMOF.Properties.CMOF_Property_Access;
Position : AMF.Optional_Integer;
Old_Value : League.Holders.Holder;
New_Value : League.Holders.Holder) is null;
not overriding procedure Attribute_Set
(Self : not null access Abstract_Listener;
Element : not null AMF.Elements.Element_Access;
Property : not null AMF.CMOF.Properties.CMOF_Property_Access;
Position : AMF.Optional_Integer;
Old_Value : League.Holders.Holder;
New_Value : League.Holders.Holder) is null;
-- Called when attribute value is changed.
not overriding procedure Link_Add
(Self : not null access Abstract_Listener;
Association : not null AMF.CMOF.Associations.CMOF_Association_Access;
First_Element : not null AMF.Elements.Element_Access;
Second_Element : not null AMF.Elements.Element_Access) is null;
-- Called when link between two elements is created.
not overriding procedure Link_Remove
(Self : not null access Abstract_Listener) is null;
procedure Register_Listener (Listener : not null Listener_Access);
procedure Register_Instance_Listener
(Listener : not null Listener_Access;
Instance : not null AMF.Elements.Element_Access);
end AMF.Listeners;
|
reznikmm/matreshka | Ada | 7,421 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- XML Processor --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2010-2013, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Ada.Unchecked_Deallocation;
package body Matreshka.Internals.XML.Namespace_Scopes is
procedure Free is
new Ada.Unchecked_Deallocation (Mapping_Array, Mapping_Array_Access);
procedure Free is
new Ada.Unchecked_Deallocation (Scope_Array, Scope_Array_Access);
----------
-- Bind --
----------
procedure Bind
(Self : in out Namespace_Scope;
Prefix : Symbol_Identifier;
Namespace : Symbol_Identifier)
is
Old_Scopes : Scope_Array_Access;
Old_Mappings : Mapping_Array_Access;
begin
if Self.Scopes (Self.Last).Count /= 0 then
Self.Scopes (Self.Last).Count := Self.Scopes (Self.Last).Count - 1;
Self.Last := Self.Last + 1;
if Self.Last > Self.Scopes'Last then
-- Reallocate scopes vector when necessary.
Old_Scopes := Self.Scopes;
Self.Scopes := new Scope_Array (1 .. Old_Scopes'Last + 8);
Self.Scopes (Old_Scopes'Range) := Old_Scopes.all;
Free (Old_Scopes);
end if;
Self.Scopes (Self.Last) :=
(0,
Self.Scopes (Self.Last - 1).Last + 1,
Self.Scopes (Self.Last - 1).Last);
end if;
-- Sanity check: be sure that prefix is not mapped twice in the same
-- scope.
for J in Self.Scopes (Self.Last).First
.. Self.Scopes (Self.Last).Last
loop
if Self.Mappings (J).Prefix = Prefix then
raise Program_Error;
end if;
end loop;
Self.Scopes (Self.Last).Last := Self.Scopes (Self.Last).Last + 1;
if Self.Scopes (Self.Last).Last > Self.Mappings'Last then
-- Reallocate mappings vector when necessary.
Old_Mappings := Self.Mappings;
Self.Mappings := new Mapping_Array (1 .. Old_Mappings'Last + 8);
Self.Mappings (Old_Mappings'Range) := Old_Mappings.all;
Free (Old_Mappings);
end if;
Self.Mappings (Self.Scopes (Self.Last).Last) := (Prefix, Namespace);
end Bind;
--------------
-- Finalize --
--------------
procedure Finalize (Self : in out Namespace_Scope) is
begin
Free (Self.Mappings);
Free (Self.Scopes);
end Finalize;
----------------
-- Initialize --
----------------
procedure Initialize (Self : in out Namespace_Scope) is
begin
Self.Mappings := new Mapping_Array (1 .. 8);
Self.Mappings (1) := (Symbol_xml, Symbol_xml_NS);
Self.Mappings (2) := (Symbol_xmlns, Symbol_xmlns_NS);
Self.Scopes := new Scope_Array (1 .. 8);
Self.Scopes (1) := (0, 1, 2);
Self.Last := 1;
end Initialize;
---------------
-- Pop_Scope --
---------------
procedure Pop_Scope
(Self : in out Namespace_Scope;
On_Unmap : not null access procedure (Prefix : Symbol_Identifier)) is
begin
if Self.Scopes (Self.Last).Count /= 0 then
Self.Scopes (Self.Last).Count := Self.Scopes (Self.Last).Count - 1;
else
for J
in Self.Scopes (Self.Last).First .. Self.Scopes (Self.Last).Last
loop
On_Unmap (Self.Mappings (J).Prefix);
end loop;
Self.Last := Self.Last - 1;
end if;
end Pop_Scope;
----------------
-- Push_Scope --
----------------
procedure Push_Scope (Self : in out Namespace_Scope) is
begin
Self.Scopes (Self.Last).Count := Self.Scopes (Self.Last).Count + 1;
end Push_Scope;
-----------
-- Reset --
-----------
procedure Reset (Self : in out Namespace_Scope) is
begin
Finalize (Self);
Initialize (Self);
end Reset;
-------------
-- Resolve --
-------------
function Resolve
(Self : Namespace_Scope;
Prefix : Symbol_Identifier) return Symbol_Identifier is
begin
for J in reverse 1 .. Self.Scopes (Self.Last).Last loop
if Self.Mappings (J).Prefix = Prefix then
return Self.Mappings (J).Namespace;
end if;
end loop;
return No_Symbol;
end Resolve;
end Matreshka.Internals.XML.Namespace_Scopes;
|
reznikmm/matreshka | Ada | 7,743 | adb | -- Copyright (c) 1990 Regents of the University of California.
-- All rights reserved.
--
-- The primary authors of ayacc were David Taback and Deepak Tolani.
-- Enhancements were made by Ronald J. Schmalz.
--
-- Send requests for ayacc information to [email protected]
-- Send bug reports for ayacc to [email protected]
--
-- Redistribution and use in source and binary forms are permitted
-- provided that the above copyright notice and this paragraph are
-- duplicated in all such forms and that any documentation,
-- advertising materials, and other materials related to such
-- distribution and use acknowledge that the software was developed
-- by the University of California, Irvine. The name of the
-- University may not be used to endorse or promote products derived
-- from this software without specific prior written permission.
-- THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
-- IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
-- WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-- Module : symbol_info_body.ada
-- Component of : ayacc
-- Version : 1.2
-- Date : 11/21/86 12:37:23
-- SCCS File : disk21~/rschm/hasee/sccs/ayacc/sccs/sxsymbol_info_body.ada
-- $Header: symbol_info_body.a,v 0.1 86/04/01 15:13:25 ada Exp $
-- $Log: symbol_info_body.a,v $
-- Revision 0.1 86/04/01 15:13:25 ada
-- This version fixes some minor bugs with empty grammars
-- and $$ expansion. It also uses vads5.1b enhancements
-- such as pragma inline.
--
--
-- Revision 0.0 86/02/19 18:46:56 ada
--
-- These files comprise the initial version of Ayacc
-- designed and implemented by David Taback and Deepak Tolani.
-- Ayacc has been compiled and tested under the Verdix Ada compiler
-- version 4.06 on a vax 11/750 running Unix 4.2BSD.
--
with Text_IO;
package body Symbol_Info is
SCCS_ID : constant String := "@(#) symbol_info_body.ada, Version 1.2";
Rcs_ID : constant String := "$Header: symbol_info_body.a,v 0.1 86/04/01 15:13:25 ada Exp $";
type Nullables_Array is array (Grammar_Symbol range <>) of Boolean;
type Nullables_Array_Pointer is access Nullables_Array;
Nullables : Nullables_Array_Pointer;
--
-- initializes the elements of the array pointed to by
-- NULLABLES to false if they cannot derive the empty
-- string and TRUE if they can derive the empty string.
--
procedure Find_Nullables is
Sym_Position : Natural;
Nonterminal_Sym : Grammar_Symbol;
RHS_Sym : Grammar_Symbol;
No_More_Added : Boolean;
Rule_Length : Natural;
begin
--& Verdix 4.06 bug
--& nullables.all := (nullables.all'range => false);
--& bug fix
for S in Nullables.all'range loop
Nullables(S) := False;
end loop;
--& end bug fix
-- First determine the symbols that are trivially nullable.
for R in First_Rule..Last_Rule loop
if Length_of(R) = 0 then
Nullables(Get_LHS(R)) := True;
end if;
end loop;
loop
No_More_Added := True;
for R in First_Rule..Last_Rule loop
Nonterminal_Sym := Get_LHS(R);
if not Nullables(Nonterminal_Sym) then
Sym_Position := 1;
Rule_Length := Length_of(R);
while Sym_Position <= Rule_Length loop
RHS_Sym := Get_RHS(R, Sym_Position);
exit when Is_Terminal(RHS_Sym) or else
not Nullables(RHS_Sym);
Sym_Position := Sym_Position + 1;
end loop;
if Sym_Position > Rule_Length then
Nullables(Nonterminal_Sym) := True;
No_More_Added := False;
end if;
end if;
end loop;
exit when No_More_Added;
end loop;
end Find_Nullables;
function Is_Nullable(Sym: Grammar_Symbol) return Boolean is
begin
return Nullables(Sym);
end Is_Nullable;
procedure Make_Rules_Null_Position is
Null_Position : Integer;
RHS_Sym : Grammar_Symbol;
begin
for R in First_Rule..Last_Rule loop
Null_Position := Length_of(R);
while Null_Position /= 0 loop
RHS_Sym := Get_RHS(R, Null_Position);
if Is_Terminal(RHS_Sym) or else not Nullables(RHS_Sym) then
exit;
end if;
Null_Position := Null_Position - 1;
end loop;
Set_Null_Pos(R, Null_Position);
end loop;
end Make_Rules_Null_Position;
procedure Find_Rule_Yields is
use Text_IO; -- To report undefined nonterminals
Found_Undefined_Nonterminal: Boolean := False;
Current_Index : Yield_Index;
begin
-- First initialize the arrays to the correct size --
Nonterminal_Yield := new Rule_Array
(Yield_Index(First_Rule)..Yield_Index(Last_Rule));
Nonterminal_Yield_Index := new Offset_Array
(First_Symbol(Nonterminal)..Last_Symbol(Nonterminal) + 1);
Current_Index := Yield_Index(First_Rule);
for Sym in First_Symbol(Nonterminal)..Last_Symbol(Nonterminal) loop
Nonterminal_Yield_Index(Sym) := Current_Index;
for R in First_Rule..Last_Rule loop
if Get_LHS(R) = Sym then
Nonterminal_Yield(Current_Index) := R;
Current_Index := Current_Index + 1;
end if;
end loop;
if Nonterminal_Yield_Index(Sym) = Current_Index then
Found_Undefined_Nonterminal := True;
Put_Line ("Ayacc: Nonterminal " & Get_Symbol_Name(Sym) &
" does not appear on the " &
"left hand side of any rule.");
end if;
end loop;
Nonterminal_Yield_Index(Last_Symbol(Nonterminal) + 1) := Current_Index;
-- So you can easily determine the end of the list in loops
-- bye comparing the index to the index of sym+1.
if Found_Undefined_Nonterminal then
raise Undefined_Nonterminal;
end if;
end Find_Rule_Yields;
-- First detect nonterminals that can't be derived from the start symbol.
-- Then detect nonterminals that don't derive any token string.
--
-- NOTE: We should use Digraph to do this stuff when we
-- have time to put it in.
procedure Check_Grammar is
use Text_IO; -- to report errors
type Nonterminal_Array is array (Grammar_Symbol range <>) of Boolean;
Ok : Nonterminal_Array
(First_Symbol(Nonterminal)..Last_Symbol(Nonterminal));
More : Boolean;
I : Natural;
Rule_Length : Natural;
Found_Error : Boolean := False;
RHS_Sym, LHS_Sym: Grammar_Symbol;
Bad_Grammar : exception; -- Move this somewhere else!!!
begin
-- check if each nonterminal is deriveable from the start symbol --
-- To be added! We should use digraph for this
-- check if each nonterminal can derive a terminal string. --
--& Verdix 4.06 bug
--& ok := (ok'range => false);
--& bug fix
for S in Ok'range loop
Ok(S) := False;
end loop;
--& end bug fix
More := True;
while More loop
More := False;
for R in First_Rule..Last_Rule loop
LHS_Sym := Get_LHS(R);
if not Ok(LHS_Sym) then
I := 1;
Rule_Length := Length_of(R);
while I <= Rule_Length loop
RHS_Sym := Get_RHS(R, I);
if Is_Nonterminal(RHS_Sym) and then
not Ok(RHS_Sym)
then
exit;
end if;
I := I + 1;
end loop;
if I > Rule_Length then -- nonterminal can derive terminals
Ok(LHS_Sym) := True;
More := True;
end if;
end if;
end loop;
end loop;
for J in Ok'range loop
if not Ok(J) then
Put_Line ("Ayacc: Nonterminal " & Get_Symbol_Name(J) &
" does not derive a terminal string");
Found_Error := True;
end if;
end loop;
if Found_Error then
raise Bad_Grammar;
end if;
end Check_Grammar;
procedure Initialize is
begin
Nullables := new Nullables_Array
(First_Symbol(Nonterminal) .. Last_Symbol(Nonterminal));
Find_Rule_Yields;
Check_Grammar;
Find_Nullables;
Make_Rules_Null_Position;
end Initialize;
end Symbol_Info;
|
ekoeppen/STM32_Generic_Ada_Drivers | Ada | 5,059 | adb | with STM32_SVD; use STM32_SVD;
with STM32_SVD.NVIC; use STM32_SVD.NVIC;
with STM32_SVD.SCB; use STM32_SVD.SCB;
with STM32_SVD.PWR; use STM32_SVD.PWR;
with STM32_SVD.EXTI; use STM32_SVD.EXTI;
with STM32_SVD.RCC; use STM32_SVD.RCC;
with STM32_SVD.RTC; use STM32_SVD.RTC;
package body STM32GD.RTC is
Days_Per_Month : constant array (0 .. 12) of Natural := (
0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
procedure Unlock is
begin
RTC_Periph.WPR.KEY := 16#CA#;
RTC_Periph.WPR.KEY := 16#53#;
end Unlock;
procedure Lock is
begin
RTC_Periph.WPR.KEY := 16#FF#;
end Lock;
procedure Read (Date_Time : out Date_Time_Type) is
begin
Date_Time.Day := Natural(RTC_Periph.DR.DU) + Natural(RTC_Periph.DR.DT) * 10;
Date_Time.Month := Natural(RTC_Periph.DR.MU) + Natural(RTC_Periph.DR.MT) * 10;
Date_Time.Year := Natural(RTC_Periph.DR.YU) + Natural(RTC_Periph.DR.YT) * 10;
Date_Time.Hour := Natural(RTC_Periph.TR.HU) + Natural(RTC_Periph.TR.HT) * 10;
Date_Time.Minute := Natural(RTC_Periph.TR.MNU) + Natural(RTC_Periph.TR.MNT) * 10;
Date_Time.Second := Natural(RTC_Periph.TR.SU) + Natural(RTC_Periph.TR.ST) * 10;
end Read;
procedure Print (Date_Time : Date_Time_Type) is
begin
-- Put (Integer'Image (Date_Time.Year));
-- Put (Integer'Image (Date_Time.Month));
-- Put (Integer'Image (Date_Time.Day));
-- Put (Integer'Image (Date_Time.Hour));
-- Put (Integer'Image (Date_Time.Minute));
-- Put_Line (Integer'Image (Date_Time.Second));
null;
end Print;
procedure Add_Seconds (Date_Time : in out Date_Time_Type ;
Second_Delta : Second_Delta_Type) is
Total_Seconds : Natural;
begin
Total_Seconds :=
Date_Time.Second +
Date_Time.Minute * 60 +
Date_Time.Hour * 60 * 60 + Second_Delta;
Date_Time.Second := Total_Seconds mod 60;
Date_Time.Minute := Total_Seconds mod (60 * 60) / 60;
Date_Time.Hour := Total_Seconds / 3600;
if Total_Seconds / (60 * 60) > Hour_Type'Last then
Total_Seconds := Total_Seconds - Hour_Type'Last * (60 * 60);
end if;
Date_Time.Hour := Total_Seconds / (60 * 60);
end Add_Seconds;
procedure Add_Minutes (Date_Time : in out Date_Time_Type ;
Minute_Delta : Minute_Delta_Type) is
Total_Minutes : Natural;
begin
Total_Minutes := Date_Time.Minute + Date_Time.Hour * 60 + Minute_Delta;
Date_Time.Minute := Total_Minutes mod 60;
if Total_Minutes / 60 > Hour_Type'Last then
Total_Minutes := Total_Minutes - Hour_Type'Last * 60;
end if;
Date_Time.Hour := Total_Minutes / 60;
end Add_Minutes;
procedure Set_Alarm (Date_Time : Date_Time_Type) is
begin
Unlock;
RTC_Periph.ISR.ALRAF := 0;
RTC_Periph.CR.ALRAE := 0;
while RTC_Periph.ISR.ALRAWF = 0 loop
null;
end loop;
RTC_Periph.ALRMAR := (
MSK1 => 0,
ST => UInt3 (Date_Time.Second / 10),
SU => UInt4 (Date_Time.Second mod 10),
MSK2 => 0,
MNT => UInt3 (Date_Time.Minute / 10),
MNU => UInt4 (Date_Time.Minute mod 10),
MSK3 => 0,
PM => 0,
HT => UInt2 (Date_Time.Hour / 10),
HU => UInt4 (Date_Time.Hour mod 10),
MSK4 => 1, WDSEL => 0, DT => 0, DU => 0);
RTC_Periph.CR.ALRAE := 1;
RTC_Periph.CR.ALRAIE := 1;
Lock;
EXTI_Periph.EMR.EM.Arr (17) := 1;
EXTI_Periph.RTSR.RT.Arr (17) := 1;
end Set_Alarm;
procedure Clear_Alarm is
ICPR : UInt32;
begin
ICPR := NVIC_Periph.ICPR;
ICPR := ICPR or 2 ** 3;
NVIC_Periph.ICPR := ICPR;
EXTI_Periph.PR.PIF.Arr (17) := 1;
Unlock;
RTC_Periph.ISR.ALRAF := 0;
RTC_Periph.CR.ALRAE := 0;
RTC_Periph.CR.ALRAIE := 0;
Lock;
end Clear_Alarm;
procedure Init is
use STM32GD.Clock;
begin
RCC_Periph.APB1ENR.PWREN := 1;
PWR_Periph.CR.DBP := 1;
case Clock is
when LSE => RCC_Periph.CSR.RTCSEL := 2#01#;
pragma Compile_Time_Error (Clock = LSE and not Clock_Tree.LSE_Enabled, "LSE not enabled for RTC");
when LSI => RCC_Periph.CSR.RTCSEL := 2#10#;
pragma Compile_Time_Error (Clock = LSI and not Clock_Tree.LSI_Enabled, "LSE not enabled for RTC");
when others =>
pragma Compile_Time_Error (Clock /= LSI and Clock /= LSE, "RTC clock needs to be LSI or LSE");
end case;
RCC_Periph.CSR.RTCEN := 1;
end Init;
function To_Seconds (Date_Time : Date_Time_Type) return Natural is
begin
return Date_Time.Second +
Date_Time.Minute * 60 +
Date_Time.Hour * 60 * 60 +
(Date_Time.Day - 1) * 24 * 60 * 60 +
Days_Per_Month (Date_Time.Month - 1) * 24 * 60 * 60 +
Date_Time.Year * 365 * 24 * 60 * 60;
end To_Seconds;
procedure Wait_For_Alarm is
begin
SCB.SCB_Periph.SCR.SEVEONPEND := 1;
STM32GD.Wait_For_Event;
Clear_Alarm;
end Wait_For_Alarm;
end STM32GD.RTC;
|
osannolik/ada-canopen | Ada | 10,717 | ads | with ACO.Messages;
with ACO.OD_Types;
with ACO.Utils.Byte_Order;
with Interfaces;
with System;
package ACO.SDO_Commands is
use Interfaces;
use ACO.Messages;
use ACO.OD_Types;
use ACO.Utils.Byte_Order;
type Unsigned_3 is mod 2 ** 3 with Size => 3;
type Unsigned_2 is mod 2 ** 2 with Size => 2;
subtype Abort_Code_Type is Interfaces.Unsigned_32;
Download_Initiate_Req : constant := 1;
Download_Initiate_Conf : constant := 3;
Download_Segment_Req : constant := 0;
Download_Segment_Conf : constant := 1;
Upload_Initiate_Req : constant := 2;
Upload_Initiate_Conf : constant := 2;
Upload_Segment_Req : constant := 3;
Upload_Segment_Conf : constant := 0;
Abort_Req : constant := 4;
function Get_CS (Msg : Message) return Unsigned_3 is
(Unsigned_3 (Shift_Right (Msg.Data (0), 5) and 2#111#));
function Get_Index (Msg : Message) return Entry_Index is
((Object => Swap_Bus (Octets_2 (Msg.Data (1 .. 2))),
Sub => Msg.Data (3)));
-- function Index_To_Bus (Index : Object_Index) return Data_Array is
-- (Data_Array (Octets_2' (Swap_Bus (Unsigned_16 (Index)))));
type Download_Initiate_Cmd (As_Raw : Boolean := False) is record
case As_Raw is
when True =>
Raw : Data_Array (0 .. 7);
when False =>
Command : Unsigned_3;
Nof_No_Data : Unsigned_2;
Is_Expedited : Boolean;
Is_Size_Indicated : Boolean;
Index : Unsigned_16;
Subindex : Unsigned_8;
Data : Data_Array (0 .. 3);
end case;
end record
with Unchecked_Union, Size => 64, Bit_Order => System.Low_Order_First;
for Download_Initiate_Cmd use record
Raw at 0 range 0 .. 63;
Data at 0 range 32 .. 63;
Subindex at 0 range 24 .. 31;
Index at 0 range 8 .. 23;
Command at 0 range 5 .. 7;
Nof_No_Data at 0 range 2 .. 3;
Is_Expedited at 0 range 1 .. 1;
Is_Size_Indicated at 0 range 0 .. 0;
end record;
function Get_Data_Size (Cmd : Download_Initiate_Cmd) return Natural is
(if Cmd.Is_Expedited then 4 - Natural (Cmd.Nof_No_Data) else
Natural (Swap_Bus (Octets_4 (Cmd.Data))));
function Convert
(Msg : Message) return Download_Initiate_Cmd
is
((As_Raw => True, Raw => Msg.Data));
subtype Expedited_Data is Data_Array (0 .. 3);
function Create
(Index : Entry_Index;
Data : Data_Array)
return Download_Initiate_Cmd
with Pre => Data'Length <= Expedited_Data'Length;
function Create
(Index : Entry_Index;
Size : Natural)
return Download_Initiate_Cmd;
subtype Segment_Data is Data_Array (0 .. 6);
type Download_Segment_Cmd (As_Raw : Boolean := False) is record
case As_Raw is
when True =>
Raw : Data_Array (0 .. 7);
when False =>
Command : Unsigned_3;
Toggle : Boolean;
Nof_No_Data : Unsigned_3;
Is_Complete : Boolean;
Data : Segment_Data;
end case;
end record
with Unchecked_Union, Size => 64, Bit_Order => System.Low_Order_First;
for Download_Segment_Cmd use record
Raw at 0 range 0 .. 63;
Data at 0 range 8 .. 63;
Command at 0 range 5 .. 7;
Toggle at 0 range 4 .. 4;
Nof_No_Data at 0 range 1 .. 3;
Is_Complete at 0 range 0 .. 0;
end record;
function Convert
(Msg : Message) return Download_Segment_Cmd
is
((As_Raw => True, Raw => Msg.Data));
function Create
(Toggle : Boolean;
Is_Complete : Boolean;
Data : Data_Array)
return Download_Segment_Cmd
with Pre => Data'Length <= Segment_Data'Length;
type Download_Initiate_Resp (As_Raw : Boolean := False) is record
case As_Raw is
when True =>
Raw : Data_Array (0 .. 7) := (others => 0);
when False =>
Command : Unsigned_3;
Index : Unsigned_16;
Subindex : Unsigned_8;
end case;
end record
with Unchecked_Union, Size => 64, Bit_Order => System.Low_Order_First;
for Download_Initiate_Resp use record
Raw at 0 range 0 .. 63;
Subindex at 0 range 24 .. 31;
Index at 0 range 8 .. 23;
Command at 0 range 5 .. 7;
end record;
function Convert
(Msg : Message) return Download_Initiate_Resp
is
((As_Raw => True, Raw => Msg.Data));
function Create
(Index : Entry_Index)
return Download_Initiate_Resp;
type Download_Segment_Resp (As_Raw : Boolean := False) is record
case As_Raw is
when True =>
Raw : Data_Array (0 .. 7) := (others => 0);
when False =>
Command : Unsigned_3;
Toggle : Boolean;
end case;
end record
with Unchecked_Union, Size => 64, Bit_Order => System.Low_Order_First;
for Download_Segment_Resp use record
Raw at 0 range 0 .. 63;
Command at 0 range 5 .. 7;
Toggle at 0 range 4 .. 4;
end record;
function Convert
(Msg : Message) return Download_Segment_Resp
is
((As_Raw => True, Raw => Msg.Data));
function Create
(Toggle : Boolean)
return Download_Segment_Resp;
type Abort_Cmd (As_Raw : Boolean := False) is record
case As_Raw is
when True =>
Raw : Data_Array (0 .. 7) := (others => 0);
when False =>
Command : Unsigned_3;
Index : Unsigned_16;
Subindex : Unsigned_8;
Code : Unsigned_32;
end case;
end record
with Unchecked_Union, Size => 64, Bit_Order => System.Low_Order_First;
for Abort_Cmd use record
Raw at 0 range 0 .. 63;
Code at 0 range 32 .. 63;
Subindex at 0 range 24 .. 31;
Index at 0 range 8 .. 23;
Command at 0 range 5 .. 7;
end record;
function Convert
(Msg : Message) return Abort_Cmd
is
((As_Raw => True, Raw => Msg.Data));
function Create
(Index : Entry_Index;
Code : Abort_Code_Type)
return Abort_Cmd;
function Code (Cmd : Abort_Cmd) return Abort_Code_Type
is
(Abort_Code_Type (Unsigned_32' (Swap_Bus (Cmd.Code))));
type Upload_Initiate_Cmd (As_Raw : Boolean := False) is record
case As_Raw is
when True =>
Raw : Data_Array (0 .. 7) := (others => 0);
when False =>
Command : Unsigned_3;
Index : Unsigned_16;
Subindex : Unsigned_8;
end case;
end record
with Unchecked_Union, Size => 64, Bit_Order => System.Low_Order_First;
for Upload_Initiate_Cmd use record
Raw at 0 range 0 .. 63;
Subindex at 0 range 24 .. 31;
Index at 0 range 8 .. 23;
Command at 0 range 5 .. 7;
end record;
function Convert
(Msg : Message) return Upload_Initiate_Cmd
is
((As_Raw => True, Raw => Msg.Data));
function Create
(Index : Entry_Index)
return Upload_Initiate_Cmd;
type Upload_Initiate_Resp (As_Raw : Boolean := False) is record
case As_Raw is
when True =>
Raw : Data_Array (0 .. 7);
when False =>
Command : Unsigned_3;
Nof_No_Data : Unsigned_2;
Is_Expedited : Boolean;
Is_Size_Indicated : Boolean;
Index : Unsigned_16;
Subindex : Unsigned_8;
Data : Data_Array (0 .. 3);
end case;
end record
with Unchecked_Union, Size => 64, Bit_Order => System.Low_Order_First;
for Upload_Initiate_Resp use record
Raw at 0 range 0 .. 63;
Data at 0 range 32 .. 63;
Subindex at 0 range 24 .. 31;
Index at 0 range 8 .. 23;
Command at 0 range 5 .. 7;
Nof_No_Data at 0 range 2 .. 3;
Is_Expedited at 0 range 1 .. 1;
Is_Size_Indicated at 0 range 0 .. 0;
end record;
function Get_Data_Size (Cmd : Upload_Initiate_Resp) return Natural is
(if Cmd.Is_Expedited then 4 - Natural (Cmd.Nof_No_Data) else
Natural (Swap_Bus (Octets_4 (Cmd.Data))));
function Convert
(Msg : Message) return Upload_Initiate_Resp
is
((As_Raw => True, Raw => Msg.Data));
function Create
(Index : Entry_Index;
Data : Data_Array)
return Upload_Initiate_Resp
with Pre => Data'Length <= Expedited_Data'Length;
function Create
(Index : Entry_Index;
Size : Natural)
return Upload_Initiate_Resp;
type Upload_Segment_Cmd (As_Raw : Boolean := False) is record
case As_Raw is
when True =>
Raw : Data_Array (0 .. 7) := (others => 0);
when False =>
Command : Unsigned_3;
Toggle : Boolean;
end case;
end record
with Unchecked_Union, Size => 64, Bit_Order => System.Low_Order_First;
for Upload_Segment_Cmd use record
Raw at 0 range 0 .. 63;
Command at 0 range 5 .. 7;
Toggle at 0 range 4 .. 4;
end record;
function Convert
(Msg : Message) return Upload_Segment_Cmd
is
((As_Raw => True, Raw => Msg.Data));
function Create
(Toggle : Boolean)
return Upload_Segment_Cmd;
type Upload_Segment_Resp (As_Raw : Boolean := False) is record
case As_Raw is
when True =>
Raw : Data_Array (0 .. 7);
when False =>
Command : Unsigned_3;
Toggle : Boolean;
Nof_No_Data : Unsigned_3;
Is_Complete : Boolean;
Data : Segment_Data;
end case;
end record
with Unchecked_Union, Size => 64, Bit_Order => System.Low_Order_First;
for Upload_Segment_Resp use record
Raw at 0 range 0 .. 63;
Data at 0 range 8 .. 63;
Command at 0 range 5 .. 7;
Toggle at 0 range 4 .. 4;
Nof_No_Data at 0 range 1 .. 3;
Is_Complete at 0 range 0 .. 0;
end record;
function Convert
(Msg : Message) return Upload_Segment_Resp
is
((As_Raw => True, Raw => Msg.Data));
function Create
(Toggle : Boolean;
Is_Complete : Boolean;
Data : Data_Array)
return Upload_Segment_Resp
with Pre => Data'Length <= Segment_Data'Length;
end ACO.SDO_Commands;
|
sungyeon/drake | Ada | 999 | adb | with System.Formatting;
with System.Long_Long_Integer_Types;
package body System.Wid_LLU is
use type Unsigned_Types.Long_Long_Unsigned;
subtype Word_Unsigned is Long_Long_Integer_Types.Word_Unsigned;
subtype Long_Long_Unsigned is Long_Long_Integer_Types.Long_Long_Unsigned;
-- implementation
function Width_Long_Long_Unsigned (
Lo, Hi : Unsigned_Types.Long_Long_Unsigned)
return Natural is
begin
if Lo > Hi then
return 0;
else
declare
Digits_Width : Natural;
begin
if Unsigned_Types.Long_Long_Unsigned'Size <=
Standard'Word_Size
then
Digits_Width := Formatting.Digits_Width (Word_Unsigned (Hi));
else
Digits_Width :=
Formatting.Digits_Width (Long_Long_Unsigned (Hi));
end if;
return Digits_Width + 1; -- sign
end;
end if;
end Width_Long_Long_Unsigned;
end System.Wid_LLU;
|
reznikmm/matreshka | Ada | 4,673 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Visitors;
with ODF.DOM.Form_Button_Elements;
package Matreshka.ODF_Form.Button_Elements is
type Form_Button_Element_Node is
new Matreshka.ODF_Form.Abstract_Form_Element_Node
and ODF.DOM.Form_Button_Elements.ODF_Form_Button
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Form_Button_Element_Node;
overriding function Get_Local_Name
(Self : not null access constant Form_Button_Element_Node)
return League.Strings.Universal_String;
overriding procedure Enter_Node
(Self : not null access Form_Button_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
overriding procedure Leave_Node
(Self : not null access Form_Button_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
overriding procedure Visit_Node
(Self : not null access Form_Button_Element_Node;
Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
end Matreshka.ODF_Form.Button_Elements;
|
DrenfongWong/tkm-rpc | Ada | 401 | ads | with Ada.Unchecked_Conversion;
package Tkmrpc.Request.Cfg.Tkm_Version.Convert is
function To_Request is new Ada.Unchecked_Conversion (
Source => Tkm_Version.Request_Type,
Target => Request.Data_Type);
function From_Request is new Ada.Unchecked_Conversion (
Source => Request.Data_Type,
Target => Tkm_Version.Request_Type);
end Tkmrpc.Request.Cfg.Tkm_Version.Convert;
|
optikos/oasis | Ada | 1,527 | ads | -- Copyright (c) 2019 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Program.Elements.Constraints;
with Program.Elements.Expressions;
with Program.Lexical_Elements;
package Program.Elements.Simple_Expression_Ranges is
pragma Pure (Program.Elements.Simple_Expression_Ranges);
type Simple_Expression_Range is
limited interface and Program.Elements.Constraints.Constraint;
type Simple_Expression_Range_Access is
access all Simple_Expression_Range'Class with Storage_Size => 0;
not overriding function Lower_Bound
(Self : Simple_Expression_Range)
return not null Program.Elements.Expressions.Expression_Access
is abstract;
not overriding function Upper_Bound
(Self : Simple_Expression_Range)
return not null Program.Elements.Expressions.Expression_Access
is abstract;
type Simple_Expression_Range_Text is limited interface;
type Simple_Expression_Range_Text_Access is
access all Simple_Expression_Range_Text'Class with Storage_Size => 0;
not overriding function To_Simple_Expression_Range_Text
(Self : aliased in out Simple_Expression_Range)
return Simple_Expression_Range_Text_Access is abstract;
not overriding function Double_Dot_Token
(Self : Simple_Expression_Range_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
end Program.Elements.Simple_Expression_Ranges;
|
charlie5/cBound | Ada | 1,618 | ads | -- This file is generated by SWIG. Please do not modify by hand.
--
with Interfaces;
with Interfaces.C;
with Interfaces.C.Pointers;
package xcb.xcb_glx_get_integerv_request_t is
-- Item
--
type Item is record
major_opcode : aliased Interfaces.Unsigned_8;
minor_opcode : aliased Interfaces.Unsigned_8;
length : aliased Interfaces.Unsigned_16;
context_tag : aliased xcb.xcb_glx_context_tag_t;
pname : aliased Interfaces.Unsigned_32;
end record;
-- Item_Array
--
type Item_Array is
array
(Interfaces.C
.size_t range <>) of aliased xcb.xcb_glx_get_integerv_request_t
.Item;
-- Pointer
--
package C_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_glx_get_integerv_request_t.Item,
Element_Array => xcb.xcb_glx_get_integerv_request_t.Item_Array,
Default_Terminator => (others => <>));
subtype Pointer is C_Pointers.Pointer;
-- Pointer_Array
--
type Pointer_Array is
array
(Interfaces.C
.size_t range <>) of aliased xcb.xcb_glx_get_integerv_request_t
.Pointer;
-- Pointer_Pointer
--
package C_Pointer_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_glx_get_integerv_request_t.Pointer,
Element_Array => xcb.xcb_glx_get_integerv_request_t.Pointer_Array,
Default_Terminator => null);
subtype Pointer_Pointer is C_Pointer_Pointers.Pointer;
end xcb.xcb_glx_get_integerv_request_t;
|
sungyeon/drake | Ada | 4,211 | ads | pragma License (Unrestricted);
-- implementation unit required by compiler
with Ada.Real_Time;
with System.Parameters;
with System.Task_Info;
with System.Tasks;
package System.Tasking.Stages is
-- required for task by compiler (s-tassta.ads)
procedure Create_Task (
Priority : Integer; -- range -1 .. Any_Priority'Last;
Size : Parameters.Size_Type;
Secondary_Stack_Size : Parameters.Size_Type;
Task_Info : System.Task_Info.Task_Info_Type;
CPU : Integer;
Relative_Deadline : Ada.Real_Time.Time_Span;
Domain : Dispatching_Domain_Access;
Num_Entries : Task_Entry_Index;
Master : Master_Level;
State : Task_Procedure_Access;
Discriminants : Address; -- discriminants and Task_Id
Elaborated : not null Tasks.Boolean_Access;
Chain : in out Activation_Chain;
Task_Image : String;
Created_Task : out Task_Id);
-- (optionally?) required for task by compiler (s-tassta.ads)
procedure Complete_Activation;
procedure Complete_Task;
-- required for task by compiler (s-tassta.ads)
procedure Activate_Tasks (
Chain_Access : not null access Activation_Chain);
-- required for dynamic allocation of task by compiler (s-tassta.ads)
procedure Expunge_Unactivated_Tasks (Chain : in out Activation_Chain) is
null;
pragma Inline (Expunge_Unactivated_Tasks);
-- [gcc-7] can not skip calling null procedure
-- required for dynamic deallocation of task by compiler (s-tassta.ads)
procedure Free_Task (T : Task_Id);
-- required for built-in-place of task by compiler (s-tassta.ads)
procedure Move_Activation_Chain (
From, To : Activation_Chain_Access;
New_Master : Master_ID);
-- required for abort statement by compiler (s-tassta.ads)
procedure Abort_Tasks (Tasks : Task_List);
-- required for 'Terminated by compiler (s-tassta.ads)
function Terminated (T : Task_Id) return Boolean;
-- task type be expanded below:
--
-- _chain : aliased Activation_Chain;
-- xE : aliased Boolean := False;
-- xZ : Size_Type := Unspecified_Size;
-- type xV (... discriminants ...) is limited record
-- _task_id : Task_Id;
-- end record;
-- procedure xvip (
-- _init : in out xV;
-- _master : Master_Id;
-- _chain : in out Activation_Chain;
-- _task_name : String;
-- ... discriminant parameters ...);
-- procedure xt (_task : access xV);
--
-- xE := True;
-- x1 : xV (... discriminants ...);
-- _master : constant Master_Id := Current_Master.all;
-- xS : String := ...task name...;
-- Activate_Tasks (_chain'Access);
--
-- by -fdump-tree-all, task type be expanded below:
--
-- /* initialization */
-- xvip (
-- struct xV &_init,
-- system__tasking__master_id _master,
-- struct system__tasking__activation_chain & _chain,
-- struct _task_name,
-- ... discriminant parameters ...)
-- {
-- ... store discriminant parameters into _init ...
-- _init->_task_id = 0B;
-- _init->_task_id = system.tasking.stages.create_task (
-- -1, /* priority */
-- xZ, /* size */
-- 2, /* pragma Task_Info */
-- -1, /* CPU */
-- 0, /* deadline */
-- 0, /* entry count */
-- _master,
-- xt, /* task body */
-- _init,
-- &xE, /* in out, elaboration flag */
-- _chain, /* Activation_Chain */
-- _task_name,
-- &_init->_task_id, /* out */
-- 0); /* entry names */
-- }
--
-- /* body */
-- xt (struct xV * const _task)
-- {
-- if(_task == 0) { .gnat_rcheck_00 (...location...) };
-- try
-- {
-- system.soft_links.abort_undefer ();
-- system.tasking.stages.complete_activation ();
-- ... user code ...
-- }
-- finally
-- {
-- system.soft_links.abort_defer ();
-- system.tasking.stages.complete_task ();
-- system.soft_links.abort_undefer ();
-- }
-- }
-- GDB knows, but hard to implement.
-- procedure Task_Wrapper (Self_ID : Task_Id);
end System.Tasking.Stages;
|
reznikmm/matreshka | Ada | 3,618 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.Elements.Generic_Hash;
function AMF.DG.Radial_Gradients.Hash is
new AMF.Elements.Generic_Hash (DG_Radial_Gradient, DG_Radial_Gradient_Access);
|
sungyeon/drake | Ada | 910 | ads | pragma License (Unrestricted);
-- implementation unit required by compiler
package System.Val_Enum is
pragma Pure;
-- required for Enum'Value by compiler (s-valenu.ads)
function Value_Enumeration_8 (
Names : String;
Indexes : Address;
Num : Natural;
Str : String)
return Natural;
function Value_Enumeration_16 (
Names : String;
Indexes : Address;
Num : Natural;
Str : String)
return Natural;
function Value_Enumeration_32 (
Names : String;
Indexes : Address;
Num : Natural;
Str : String)
return Natural;
pragma Pure_Function (Value_Enumeration_8);
pragma Pure_Function (Value_Enumeration_16);
pragma Pure_Function (Value_Enumeration_32);
-- helper
procedure Trim (S : String; First : out Positive; Last : out Natural);
procedure To_Upper (S : in out String);
end System.Val_Enum;
|
stcarrez/ada-el | Ada | 4,237 | adb | -----------------------------------------------------------------------
-- el-methods-proc_1 -- Procedure Binding with 1 argument
-- Copyright (C) 2010, 2011, 2012, 2021 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Beans.Objects;
package body EL.Methods.Proc_1 is
use EL.Expressions;
-- ------------------------------
-- Returns True if the method is a valid method which accepts the arguments
-- defined by the package instantiation.
-- ------------------------------
function Is_Valid (Method : in EL.Expressions.Method_Info) return Boolean is
begin
if Method.Binding = null then
return False;
else
return Method.Binding.all in Binding'Class;
end if;
end Is_Valid;
-- ------------------------------
-- Execute the method describe by the method binding object.
-- The method signature is:
--
-- procedure F (Obj : in out <Bean>;
-- Param : in out Param1_Type);
--
-- where <Bean> inherits from <b>Readonly_Bean</b>
-- (See <b>Bind</b> package)
--
-- Raises <b>Invalid_Method</b> if the method referenced by
-- the method expression does not exist or does not match
-- the signature.
-- ------------------------------
procedure Execute (Method : in EL.Expressions.Method_Info;
Param : in out Param1_Type) is
begin
if Method.Binding = null then
raise EL.Expressions.Invalid_Method with "Method not found";
end if;
-- If the binding has the wrong type, we are trying to invoke
-- a method with a different signature.
if not (Method.Binding.all in Binding'Class) then
raise EL.Expressions.Invalid_Method
with "Invalid signature for method '" & Method.Binding.Name.all & "'";
end if;
declare
Proxy : constant Binding_Access := Binding (Method.Binding.all)'Access;
begin
Proxy.Method (Util.Beans.Objects.To_Bean (Method.Object), Param);
end;
end Execute;
-- ------------------------------
-- Execute the method describe by the method expression
-- and with the given context. The method signature is:
--
-- procedure F (Obj : in out <Bean>;
-- Param : in Param1_Type);
--
-- where <Bean> inherits from <b>Readonly_Bean</b>
-- (See <b>Bind</b> package)
--
-- Raises <b>Invalid_Method</b> if the method referenced by
-- the method expression does not exist or does not match
-- the signature.
-- ------------------------------
procedure Execute (Method : in EL.Expressions.Method_Expression'Class;
Param : in out Param1_Type;
Context : in EL.Contexts.ELContext'Class) is
Info : constant Method_Info := Method.Get_Method_Info (Context);
begin
Execute (Info, Param);
end Execute;
-- ------------------------------
-- Proxy for the binding.
-- The proxy declares the binding definition that links
-- the name to the function and it implements the necessary
-- object conversion to translate the <b>Readonly_Bean</b>
-- object to the target object type.
-- ------------------------------
package body Bind is
procedure Method_Access (O : access Util.Beans.Basic.Readonly_Bean'Class;
P1 : in out Param1_Type) is
Object : constant access Bean := Bean (O.all)'Access;
begin
Method (Object.all, P1);
end Method_Access;
end Bind;
end EL.Methods.Proc_1;
|
jhumphry/auto_counters | Ada | 1,410 | ads | -- flyweights_lists_spec.ads
-- A specification package that summarises the requirements for list packages
-- used in the Flyweights hashtables
-- Copyright (c) 2016, James Humphry
--
-- Permission to use, copy, modify, and/or distribute this software for any
-- purpose with or without fee is hereby granted, provided that the above
-- copyright notice and this permission notice appear in all copies.
--
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
-- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
-- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
-- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
-- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
-- OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-- PERFORMANCE OF THIS SOFTWARE.
pragma Profile (No_Implementation_Extensions);
generic
type Element_Access is private;
type List is private;
Empty_List : List;
with procedure Insert (L : in out List;
E : in out Element_Access);
with procedure Increment (L : in out List;
E : in Element_Access);
with procedure Remove (L : in out List;
Data_Ptr : in Element_Access);
package Flyweights_Lists_Spec is
end Flyweights_Lists_Spec;
|
zhmu/ananas | Ada | 5,790 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT LIBRARY COMPONENTS --
-- --
-- ADA.CONTAINERS.FUNCTIONAL_BASE --
-- --
-- S p e c --
-- --
-- Copyright (C) 2016-2022, Free Software Foundation, Inc. --
-- --
-- This specification is derived from the Ada Reference Manual for use with --
-- GNAT. The copyright notice above, and the license provisions that follow --
-- apply solely to the contents of the part following the private keyword. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
------------------------------------------------------------------------------
-- Functional containers are neither controlled nor limited. This is safe, as
-- no primitives are provided to modify them.
-- Memory allocated inside functional containers is never reclaimed.
pragma Ada_2012;
private generic
type Index_Type is (<>);
-- To avoid Constraint_Error being raised at run time, Index_Type'Base
-- should have at least one more element at the low end than Index_Type.
type Element_Type (<>) is private;
with function "=" (Left, Right : Element_Type) return Boolean is <>;
package Ada.Containers.Functional_Base with SPARK_Mode => Off is
subtype Extended_Index is Index_Type'Base range
Index_Type'Pred (Index_Type'First) .. Index_Type'Last;
type Container is private;
function "=" (C1 : Container; C2 : Container) return Boolean;
-- Return True if C1 and C2 contain the same elements at the same position
function Length (C : Container) return Count_Type;
-- Number of elements stored in C
function Get (C : Container; I : Index_Type) return Element_Type;
-- Access to the element at index I in C
function Set
(C : Container;
I : Index_Type;
E : Element_Type) return Container;
-- Return a new container which is equal to C except for the element at
-- index I, which is set to E.
function Add
(C : Container;
I : Index_Type;
E : Element_Type) return Container;
-- Return a new container that is C with E inserted at index I
function Remove (C : Container; I : Index_Type) return Container;
-- Return a new container that is C without the element at index I
function Find (C : Container; E : Element_Type) return Extended_Index;
-- Return the first index for which the element stored in C is I. If there
-- are no such indexes, return Extended_Index'First.
--------------------
-- Set Operations --
--------------------
function "<=" (C1 : Container; C2 : Container) return Boolean;
-- Return True if every element of C1 is in C2
function Num_Overlaps (C1 : Container; C2 : Container) return Count_Type;
-- Return the number of elements that are in both C1 and C2
function Union (C1 : Container; C2 : Container) return Container;
-- Return a container which is C1 plus all the elements of C2 that are not
-- in C1.
function Intersection (C1 : Container; C2 : Container) return Container;
-- Return a container which is C1 minus all the elements that are also in
-- C2.
private
subtype Positive_Count_Type is Count_Type range 1 .. Count_Type'Last;
type Element_Access is access all Element_Type;
type Element_Array is
array (Positive_Count_Type range <>) of Element_Access;
type Element_Array_Access_Base is access Element_Array;
subtype Element_Array_Access is not null Element_Array_Access_Base;
Empty_Element_Array_Access : constant Element_Array_Access :=
new Element_Array'(1 .. 0 => null);
type Array_Base is record
Max_Length : Count_Type;
Elements : Element_Array_Access;
end record;
type Array_Base_Access is not null access Array_Base;
function Content_Init (L : Count_Type := 0) return Array_Base_Access;
-- Used to initialize the content of an array base with length L
type Container is record
Length : Count_Type := 0;
Base : Array_Base_Access := Content_Init;
end record;
end Ada.Containers.Functional_Base;
|
gitter-badger/libAnne | Ada | 534 | ads | with Numerics;
use Numerics;
package Generics.Mathematics with Pure is
--@Description Provides generic versions of functions used in Mathematics
--@Version 1.0
generic
type Integer_Type is range <>;
function Greatest_Common_Divisor(A, B : in Integer_Type) return Integer_Type;
--Calculates the greatest common divisor of A and B
generic
type Integer_Type is range <>;
function Least_Common_Multiple(A, B : in Integer_Type) return Integer_Type;
--Calculates the least common multiple of A and B
end Generics.Mathematics;
|
Sawchord/Ada_Drivers_Library | Ada | 9,127 | adb | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2018, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of STMicroelectronics nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
package body Native.SPI is
function Configure (Device : String;
Conf : SPI_Configuration;
Status : out HAL.SPI.SPI_Status)
return SPI_Port is
File : File_Id;
Ret : Interfaces.C.int;
begin
-- Open file
-- TODO: Make Mode_Flags an enum (in ioctl.ads?)
File := Open (Device, 8#02#, 777);
if (Integer(Err_No) /= 0) then
Status := Err_Error;
return SPI_Port'(File_Desc => -1, Config => Conf);
end if;
-- Set the mode of the SPI Device
declare
Mode : HAL.UInt8;
begin
case Conf.Clock_Phase is
when P1Edge => Mode := 2#0000#;
when P2Edge => Mode := 2#0001#;
end case;
if Conf.Clock_Polarity = Low then
Mode := Mode or 2#0010#;
end if;
-- NOTE: Many devices do not support LSB_First
if Conf.First_Bit = LSB then
Mode := Mode or 2#1000#;
end if;
Ret := Ioctl (File, SPI_MODE(Write), Mode'Address);
end;
if Integer(Ret) /= 0 then
Status := Err_Error;
return SPI_Port'(File_Desc => -1, Config => Conf);
end if;
-- Set Bits per Word
-- NOTE: Many devices (e.g. RPI) do not support 16 bits per word
-- We simulate 16 bits per word by transmitting 2 8 bit words.
declare
BPW : HAL.UInt8 := 8;
begin
Ret := Ioctl (File, SPI_BITS_PER_WORD(Write), BPW'Address);
end;
if Integer (Ret) /= 0 then
Status := Err_Error;
return SPI_Port'(File_Desc => -1, Config => Conf);
end if;
-- Set the Baudrate
-- NOTE: Untested
declare
Baud : HAL.Uint32 := HAL.UInt32(Conf.Baud_Rate);
begin
Ret := Ioctl (File, SPI_MAX_SPEED_HZ(Write), Baud'Address);
end;
if Integer (Ret) /= 0 then
Status := Err_Error;
return SPI_Port'(File_Desc => -1, Config => Conf);
end if;
Status := HAL.SPI.Ok;
return SPI_Port'(File_Desc => File, Config => Conf);
end Configure;
overriding
function Data_Size (This : SPI_Port) return HAL.SPI.SPI_Data_Size is
begin
return This.Config.Data_Size;
end Data_Size;
overriding
procedure Transmit
(This : in out SPI_Port;
Data : HAL.SPI.SPI_Data_8b;
Status : out HAL.SPI.SPI_Status;
Timeout : Natural := 1000) is
Ret : Size;
begin
-- TODO: Check whether HAL should deselect CS after every transfer, or
-- keep CS active during the transfer
-- Check if provided data matches configuration
if (This.Data_Size /= HAL.SPI.Data_Size_8b) then
Status := HAL.SPI.Err_Error;
return;
end if;
Ret := Write (This.File_Desc, Data'Address, Data'Length);
if Integer (ret) /= Data'Length then
Status := Err_Error;
else
Status := Ok;
end if;
end Transmit;
overriding
procedure Transmit
(This : in out SPI_Port;
Data : in HAL.SPI.SPI_Data_16b;
Status : out HAL.SPI.SPI_Status;
Timeout : Natural := 1000) is
Ret : Size;
begin
-- This Function can only transmit in little endian.
-- Is this the desired behaviour?
-- Check if provided data matches configuration
if (This.Data_Size /= HAL.SPI.Data_Size_16b) then
Status := HAL.SPI.Err_Error;
return;
end if;
Ret := Write (This.File_Desc, Data'Address, 2 * Data'Length);
if Integer (ret) /= 2 * Data'Length then
Status := Err_Error;
else
Status := Ok;
end if;
end Transmit;
overriding
procedure Receive
(This : in out SPI_Port;
Data : out HAL.SPI.SPI_Data_8b;
Status : out HAL.SPI.SPI_Status;
Timeout : Natural := 1000) is
Ret : Size;
begin
if (This.Data_Size /= HAL.SPI.Data_Size_8b) then
Status := HAL.SPI.Err_Error;
return;
end if;
Ret := Read (This.File_Desc, Data'Address, Data'Length);
if Integer (ret) /= Data'Length then
Status := Err_Error;
else
Status := Ok;
end if;
end Receive;
procedure Receive
(This : in out SPI_Port;
Data : out HAL.SPI.SPI_Data_16b;
Status : out HAL.SPI.SPI_Status;
Timeout : Natural := 1000) is
Ret : Size;
begin
if (This.Data_Size /= HAL.SPI.Data_Size_16b) then
Status := HAL.SPI.Err_Error;
return;
end if;
Ret := Read (This.File_Desc, Data'Address, 2 * Data'Length);
if Integer (ret) /= 2 * Data'Length then
Status := Err_Error;
else
Status := Ok;
end if;
end Receive;
-- private functions
procedure Transceive
(This : in out SPI_Port;
Out_Data : out HAL.SPI.SPI_Data_16b;
In_Data : in HAL.SPI.SPI_Data_16b;
Mode : Tranceive_Mode;
Status : out HAL.SPI.SPI_Status) is
Tx_Buf : HAL.UInt16 := 0;
Rx_Buf : HAL.UInt16 := 0;
pragma Warnings (Off, "types for unchecked conversion have different sizes");
function Address_To_UInt64
is new Ada.Unchecked_Conversion(Source => System.Address,
Target => HAL.UInt64);
pragma Warnings (On, "types for unchecked conversion have different sizes");
Loop_Begin : Integer;
Loop_End : Integer;
begin
if Mode = Transmit then
Loop_Begin := In_Data'First;
Loop_End := In_Data'Last;
else
Loop_Begin := Out_Data'First;
Loop_End := Out_Data'Last;
end if;
for I in Loop_Begin..Loop_End loop
if Mode = Transmit or Mode = Transceive then
Tx_Buf := In_Data(I);
end if;
declare
Transmission : SPI_IOC_Transfer :=
(Tx_Buf => Address_To_UInt64 (Tx_Buf'Address),
Rx_Buf => Address_To_UInt64 (Rx_Buf'Address),
Len => 2,
Speed_Hz => Hal.Uint32 (This.Config.Baud_Rate),
Delay_Usecs => 0,
Bits_Per_Word => 8,
Cs_Change => 0,
Tx_Nbits => 0,
Rx_Nbits => 0,
Pad => 0);
Ret : Interfaces.C.int;
begin
Ret := Ioctl (This.File_Desc, SPI_TRANSFER(1),
Transmission'Address);
if Integer (Ret) /= 2 then
Status := Err_Error;
return;
end if;
end;
if Mode = Receive or Mode = Transceive then
Out_Data(I) := Rx_Buf;
end if;
end loop;
Status := Ok;
end Transceive;
end Native.SPI;
|
AaronC98/PlaneSystem | Ada | 5,106 | ads | ------------------------------------------------------------------------------
-- Ada Web Server --
-- --
-- Copyright (C) 2003-2012, AdaCore --
-- --
-- This library is free software; you can redistribute it and/or modify --
-- it under terms of the GNU General Public License as published by the --
-- Free Software Foundation; either version 3, or (at your option) any --
-- later version. This library is distributed in the hope that it will be --
-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- --
-- --
-- --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- --
-- --
-- --
-- --
-- --
-- --
------------------------------------------------------------------------------
with AWS.Log;
package AWS.Server.Log is
------------------
-- Standard Log --
------------------
procedure Start
(Web_Server : in out HTTP;
Split_Mode : AWS.Log.Split_Mode := AWS.Log.None;
Filename_Prefix : String := "";
Auto_Flush : Boolean := False);
-- Activate server's logging activity. See AWS.Log. If Auto_Flush is True
-- the file will be flushed after all written data.
procedure Start
(Web_Server : in out HTTP;
Callback : AWS.Log.Callback;
Name : String);
-- Activate the Web_Server access log and direct all data to the Callback.
-- The Name String is returned when the Name function is called. It is a
-- simple identifier, that serves no other purpose than to give the
-- Callback a label.
function Name (Web_Server : HTTP) return String;
-- Return the name of the Log or an empty string if one is not active. If
-- an external writer is used to handle the access log, then the name of
-- that writer is returned. See the Start procedure for starting the access
-- log with a Callback.
procedure Stop (Web_Server : in out HTTP);
-- Stop server's logging activity. See AWS.Log
function Is_Active (Web_Server : HTTP) return Boolean;
-- Returns True if the Web Server log has been activated
procedure Flush (Web_Server : in out HTTP);
-- Flush the server log.
-- Note that error log does not need to be flushed because it is always
-- flushed by default. If a Callback procedure is used to handle the log
-- data, then calling Flush does nothing.
---------------
-- Error Log --
---------------
procedure Start_Error
(Web_Server : in out HTTP;
Split_Mode : AWS.Log.Split_Mode := AWS.Log.None;
Filename_Prefix : String := "");
-- Activate server's logging activity. See AWS.Log
procedure Start_Error
(Web_Server : in out HTTP;
Callback : AWS.Log.Callback;
Name : String);
-- Activate the Web_Server error log and direct all data to the Callback.
-- The Name String is returned when the Error_Name function is called. It
-- is a simple identifier, that serves no other purpose than to give the
-- Callback a label.
function Error_Name (Web_Server : HTTP) return String;
-- Return the name of the Error Log or an empty string if one is not
-- active. If a Callback is used to handle the error log, then the name of
-- the Callback is returned. See the Start_Error procedure for starting the
-- error log with a Callback.
procedure Stop_Error (Web_Server : in out HTTP);
-- Stop server's logging activity. See AWS.Log
function Is_Error_Active (Web_Server : HTTP) return Boolean;
-- Returns True if the Web Server error log has been activated
end AWS.Server.Log;
|
egustafson/sandbox | Ada | 1,397 | adb | with Ada.Text_IO, Ada.Integer_Text_IO;
use Ada.Text_IO, Ada.Integer_Text_IO;
procedure Error is
-- Note: If Constrained_Integer is constrained to 0
-- .. Integer'Last then Constraint_Error is raised when
-- Result1 is calculated. It appears to me that the
-- boundry check is occurring after the calculation
-- completed and doesn't check the signs of the terms
-- vs. the results. Similar results occur with addition.
subtype Constrained_Integer is Integer
range Integer'First .. Integer'Last;
subtype Small_Integer is Integer range 0 .. 1000;
Multiplicand1 : Integer;
Multiplicand2 : Integer;
Result1 : Constrained_Integer;
Result2 : Small_Integer;
begin
Multiplicand1 := 2;
Multiplicand2 := Constrained_Integer'Last;
-- Constraint_Error should get raised with this
-- statement.
Result1 := Multiplicand1 * Multiplicand2;
Put("The result of multiplying ");
Put(Multiplicand1);
Put(" and ");
Put(Multiplicand2);
Put(" is ");
Put(Result1);
Put_Line(".");
Flush;
Multiplicand2 := Small_Integer'Last;
-- Constraint_Error should get raised with this
-- statement.
Result2 := Multiplicand1 * Multiplicand2;
Put("The result of multiplying ");
Put(Multiplicand1);
Put(" and ");
Put(Multiplicand2);
Put(" is ");
Put(Result2);
Put_Line(".");
Flush;
end Error;
|
BrickBot/Bound-T-H8-300 | Ada | 16,101 | ads | -- Loops (decl)
--
-- A component of the Bound-T Worst-Case Execution Time Tool.
--
-------------------------------------------------------------------------------
-- Copyright (c) 1999 .. 2015 Tidorum Ltd
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
--
-- 1. Redistributions of source code must retain the above copyright notice, this
-- list of conditions and the following disclaimer.
-- 2. Redistributions in binary form must reproduce the above copyright notice,
-- this list of conditions and the following disclaimer in the documentation
-- and/or other materials provided with the distribution.
--
-- This software is provided by the copyright holders and contributors "as is" and
-- any express or implied warranties, including, but not limited to, the implied
-- warranties of merchantability and fitness for a particular purpose are
-- disclaimed. In no event shall the copyright owner or contributors be liable for
-- any direct, indirect, incidental, special, exemplary, or consequential damages
-- (including, but not limited to, procurement of substitute goods or services;
-- loss of use, data, or profits; or business interruption) however caused and
-- on any theory of liability, whether in contract, strict liability, or tort
-- (including negligence or otherwise) arising in any way out of the use of this
-- software, even if advised of the possibility of such damage.
--
-- Other modules (files) of this software composition should contain their
-- own copyright statements, which may have different copyright and usage
-- conditions. The above conditions apply to this file.
-------------------------------------------------------------------------------
--
-- $Revision: 1.31 $
-- $Date: 2015/10/24 19:36:50 $
--
-- $Log: loops.ads,v $
-- Revision 1.31 2015/10/24 19:36:50 niklas
-- Moved to free licence.
--
-- Revision 1.30 2009-03-20 18:19:30 niklas
-- BT-CH-0164: Assertion context identified by source-line number.
--
-- Revision 1.29 2008/01/14 20:27:28 niklas
-- BT-CH-0106: Loops.Max_Depth and other changes in Loops.
--
-- Revision 1.28 2006/10/30 23:09:06 niklas
-- BT-CH-0033.
--
-- Revision 1.27 2006/05/27 21:34:20 niklas
-- Renamed function Loop_Index to Index, for brevity, as
-- part of BT-CH-0020.
--
-- Revision 1.26 2005/09/20 09:56:36 niklas
-- Added function Exits_At_End.
--
-- Revision 1.25 2005/09/03 11:50:30 niklas
-- BT-CH-0006.
--
-- Revision 1.24 2005/08/08 20:15:48 niklas
-- Added function Sorted_By_Address.
--
-- Revision 1.23 2005/08/08 17:39:00 niklas
-- Added the operator "<" to test loop containment.
-- Added the function Root_Loops.
--
-- Revision 1.22 2005/02/16 21:11:47 niklas
-- BT-CH-0002.
--
-- Revision 1.21 2004/04/28 19:34:04 niklas
-- Made the Irreducible exception public, for higher-level handling.
-- Added support for Eternal loops.
-- Added function Forward_Edges returning step-edge list.
-- Reimplemented the Loop_Members function to return a reference (access)
-- to a heap-allocated node-set rather than a node-set as such.
-- Clarified the structure of the Loops function.
--
-- Revision 1.20 2001/03/21 20:24:13 holsti
-- Removed Loop_Ref_T. Renamed Loops_Ref_T to Loops_Ref.
--
-- Revision 1.19 2001/03/09 13:40:05 holsti
-- Edges_From added.
--
-- Revision 1.18 2001/03/06 09:15:35 holsti
-- Exit_Edges and Loop_Headed added.
--
-- Revision 1.17 2000/12/28 12:23:52 holsti
-- Add_Loops added.
--
-- Revision 1.16 2000/12/22 13:34:20 sihvo
-- Added Steps_In.
--
-- Revision 1.15 2000/12/05 15:44:02 holsti
-- The term "loop neck" replaces the overloaded "loop entry".
-- Decoder.Stack_Height_Cell replaces deleted Arithmetic function.
--
-- Revision 1.14 2000/09/19 12:08:40 langback
-- Added the function Loop_Index
--
-- Revision 1.13 2000/09/05 12:25:40 langback
-- Updated Loops_Contained_In. Renamed the second instance of
-- Containing_Loops to Containing_Loop, since it returns maximally
-- one loop after latest update.
--
-- Revision 1.12 2000/08/04 13:35:46 langback
-- Interface to Containing_Loops (one instance) and Loops_Contained_In
-- slightly modified
--
-- Revision 1.11 2000/08/04 11:18:00 langback
-- Added Loops_Ref_T type. Added Is_Loop_Head function.
--
-- Revision 1.10 2000/07/17 21:00:55 holsti
-- Internal_Edges and Repeat_Edges added.
--
-- Revision 1.9 2000/07/16 18:39:54 holsti
-- Forward_Edges added.
--
-- Revision 1.8 2000/07/14 20:37:49 holsti
-- Moved Calculator-dependent parts to Loops.Slim.
--
-- Revision 1.7 2000/07/05 10:04:47 langback
-- Change of the definition of the Loops_T type.
--
-- Revision 1.6 2000/07/04 12:06:26 holsti
-- Renamed several types.
--
-- Revision 1.5 2000/06/28 15:07:20 langback
-- Added Loop_Index_T.
-- Added functions returning the Head node of a loop and Loop and Entry
-- edges of a given loop head.
--
-- Revision 1.4 2000/06/13 12:34:48 langback
-- First version with CVS headers included.
-- Still a preliminary version.
--
with Flow;
with Processor;
package Loops is
-- In this package, the following terminology is used:
--
-- "Flow-graph" always means "basic-block flow-graph".
--
-- "Node" means a "basic block".
--
-- The "entry node" is the first node in the flow graph (the
-- basic block that contains the entry step of the subprogram).
type Loop_T is private;
--
-- One loop within a subprogram.
-- Because "loop" is a reserved word, an object of this
-- type will often be called "Luup" instead of "Loop".
type Loop_List_T is array (Positive range <>) of Loop_T;
--
-- Array of loops in unspecified order as compared to the type
-- Loops_T defined below.
type Loop_Count_T is new Natural;
--
-- A number of loops, for example the number of loops in a subprogram.
subtype Loop_Index_T is Loop_Count_T range 1 .. Loop_Count_T'Last;
--
-- Identifies one loop within a subprogram.
-- The loops are numbered so that the number of an inner loop
-- is always smaller than the number of the outer loops that contain it.
subtype Poss_Loop_Index_T is Loop_Count_T;
--
-- A loop index, or zero to mean "no loop".
No_Loop_Index : constant Poss_Loop_Index_T :=
Poss_Loop_Index_T'Pred (Loop_Index_T'First);
--
-- An "index" that means "no loop".
type Loops_T is array (Loop_Index_T range <>) of Loop_T;
--
-- The loops of a flow graph.
-- Ordered from inner loops to outer loops.
type Loops_Ref is access Loops_T;
Irreducible : exception;
--
-- Raised if the loop-finder detects that the structure of the
-- given control-flow graph is not reducible, which means that
-- a loop structure cannot be found (in this implementation).
--
-- In a reducible flow-graph, each loop has a single "head node"
-- that is the only point of entry into the loop body. Moreover,
-- two loops are either completely separate (no nodes in common)
-- or one is completely nested within the other.
-- PROVIDED OPERATIONS:
function Loops (Flow_Graph : in Flow.Graph_T)
return Loops_T;
--
-- Returns the loops in the given flow graph, if the graph is
-- reducible. Otherwise, raises Irreducible
function Head_Node (Item : Loop_T) return Flow.Node_T;
--
-- The head node of the loop.
function Head_Step (Item : Loop_T) return Flow.Step_T;
--
-- The head step of the loop, which is the first step in the
-- head node.
function Head_Address (Item : Loop_T) return Processor.Code_Address_T;
--
-- The prime address of the Head_Step of the loop.
function Members (Item : Loop_T) return Flow.Node_Set_Ref;
--
-- The members of the loop (including the head node).
function Contains (
Luup : Loop_T;
Node : Flow.Node_T)
return Boolean;
--
-- Whether the loop contains the node (including nested loops).
-- A loop is considered to contain its loop head as well as the
-- other nodes in the loop.
function Max_Depth (Luups : Loops_T) return Natural;
--
-- The maximum depth of containment in the given set of Luups.
-- If there are no loops, the depth is zero.
-- If there are no nested loops, the depth is one.
-- When there are loops within loops, the depth is greater than one.
-- The depth does not depend on the total number of loops, only
-- on the number of containment levels.
function Entry_Edges (
Into : Loop_T;
Within : Flow.Graph_T)
return Flow.Edge_List_T;
--
-- The edges that enter the loop (head) from outside the loop.
function Pre_Head_Steps (
Before : Loop_T;
Within : Flow.Graph_T)
return Flow.Step_List_T;
--
-- The steps from which the loop can be entered, from outside
-- the loop. That is, the source steps of the Entry_Edges.
function Neck_Edges (
Into : Loop_T;
Within : Flow.Graph_T)
return Flow.Edge_List_T;
--
-- The edges from the loop head into the loop's body.
-- Note that the head node is also considered part of the
-- loop body, so the result may contain edges from the head
-- to itself.
function Internal_Edges (
Inside : Loop_T;
Within : Flow.Graph_T)
return Flow.Edge_List_T;
--
-- The forward edges that are internal to the loop, which
-- means all edges between nodes contained in the loop
-- except for the repeat edges (edges from a node in the
-- loop to the loop-head).
function Edges_From (
Node : Flow.Node_T;
Into : Loop_T;
Within : Flow.Graph_T)
return Flow.Edge_List_T;
--
-- The edges from the given node to some node within the
-- given loop. The given node may or may not also be
-- in the given loop.
function Repeat_Edges (
Repeating : Loop_T;
Within : Flow.Graph_T)
return Flow.Edge_List_T;
--
-- The repeat-edges of the loop, which are the edges from
-- a node within the loop (including the loop-head) to the
-- loop-head.
function Exit_Edges (
Exiting : Loop_T;
Within : Flow.Graph_T)
return Flow.Edge_List_T;
--
-- The exit-edges of the loop, which are the edges from
-- a node within the loop (including the loop-head) to some
-- node outside the loop.
function Eternal (Luup : Loop_T) return Boolean;
--
-- Whether the loop is eternal, in other words it has no
-- exit edges.
procedure Mark_As_Eternal (Luup : in out Loop_T);
--
-- Marks the Luup as eternal, overriding whatever property
-- the Luup had when created. This operation is used when we
-- discover that all the Luup's exit edges are in fact infeasible
-- under some computation model.
function Exits_At_End (
Luup : Loop_T;
Within : Flow.Graph_T)
return Boolean;
--
-- Whether all exits from the Luup occur at the end of the Luup.
-- The condition here is that for any exit edge, all the other
-- edges with the same source node as the exit edge are either
-- exit edges or repeat edges in this Luup. This is (more or less)
-- the same as the common term "bottom-test loop".
function Forward_Edges (
Within : Flow.Graph_T;
Avoiding : Loops_T)
return Flow.Edge_List_T;
--
-- The forward edges in the graph, defined as any edge that
-- is not a loop-repeat edge.
function Forward_Edges (
Within : Flow.Graph_T;
Avoiding : Loops_T)
return Flow.Step_Edge_List_T;
--
-- The forward step-edges in the graph, defined as any step-edge
-- that is not a loop-repeat edge.
function All_Loops (From : Loops_T) return Loop_List_T;
--
-- Returns all the loops in the loop-structure, as a list.
-- The list order is undefined in principle, but is from
-- inner to outer in practice.
function Head_Steps (Loops : Loop_List_T) return Flow.Step_List_T;
--
-- The head steps of the given Loops. The head-step of a loop is
-- the first step in the Head_Node of the loop.
function "<" (Left : Loop_T; Right : Loop_T) return Boolean;
--
-- Whether the Left loop is contained in the Right loop (and they
-- are not the same loop).
function Containing_Loops (
Loops : Loop_List_T;
Node : Flow.Node_T)
return Loop_List_T;
--
-- Return references to all the Loops that contain the given Node.
-- The result is listed in top-down containment order, assuming
-- that the given Loops list is in bottom-up containment order.
-- The given Loops list need not contain all the loops in the
-- relevant flow-graph.
function Containing_Loop (
Loops : Loops_T;
Luup : Loop_T)
return Loop_List_T;
--
-- Return references to the loop on the next level higher
-- that contains the parameter loop, if such a loop exists.
-- ("next higher level" means that the returned loop contains
-- the loop "Luup", but does not contain any other loop that
-- contains "Luup".)
-- Return empty if such a loop does not exist.
function Root_Loops (Loops : Loops_T)
return Loop_List_T;
--
-- The root loops, that is, the outermost loops that are not
-- contained in any other loops and thus form the roots of
-- the loop forest.
function Loops_Contained_In (
Loops : Loops_T;
Luup : Loop_T)
return Loop_List_T;
--
-- Return references to the loops on the next level lower
-- that are contained in the parameter loop, if such loops exists.
-- ("next lower level" means that the returned loops are contained in
-- the loop "Luup", but are not contained in any other loops that are
-- contained in "Luup".)
--
-- Return empty if such loops do not exist.
function Is_Loop_Head (
Loops : Loops_T;
Node : Flow.Node_T)
return Boolean;
--
-- Whether the Node is a loop head (for some loop of all
-- the loops in Loops).
function Loop_Headed (
By : Flow.Node_T;
Among : Loops_T)
return Loop_T;
--
-- The loop headed by the given node, which is assumed to be
-- a loop-head of one of the given loops.
-- If this assumption is false, Constraint_Error is raised.
function Index (Luup : Loop_T)
return Loop_Index_T;
--
-- Return the index value of a given loop.
function Loop_Index (Luup : Loop_T)
return Loop_Index_T
renames Index;
--
-- Deprecated synonym for the Index function.
function Steps_In (
Luup : Loop_T;
Within : Flow.Graph_T)
return Flow.Step_List_T;
--
-- All steps within the given loop.
function Sorted_By_Address (List : Loop_List_T)
return Loop_List_T;
--
-- The given List, sorted into ascending order by the step-tag
-- of the loop-head step. This usually means sorting into increasing
-- code address, but it depends on Processor."<" for Flow_State_T,
-- which is used in Flow."<" for Step_Tag_T.
private
type Loop_T is record
Index : Loop_Index_T;
Head : Flow.Node_T;
Members : Flow.Node_Set_Ref;
Card : Flow.Node_Count_T;
Eternal : Boolean;
Depth : Positive;
Outer : Poss_Loop_Index_T;
end record;
--
-- One loop in the flow graph.
--
-- Index
-- The identifying index of the loop (its index in a Loops_T).
-- Increasing index order corresponds to the inner-to-outer
-- containment order.
-- Head
-- The head node.
-- Members
-- The set of nodes that form the loop.
-- The Head node is included, as are the nodes of inner loops
-- if any.
-- Card
-- The number of Members (cardinality).
-- Eternal
-- Whether the loop is (structurally) eternal, meaning that it
-- has no exit edges at all.
-- Depth
-- The nesting depth of the loop. One for an outermost loop,
-- greater than one for inner loops.
-- Outer
-- The identifying index of the (next, containing) outer loop
-- if Depth > 1. No_Loop_Index for an outermost loop.
end Loops;
|
Letractively/ada-ado | Ada | 2,903 | adb | -----------------------------------------------------------------------
-- ADO Drivers -- Database Drivers
-- Copyright (C) 2010, 2011, 2012, 2013 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Log.Loggers;
with Ada.IO_Exceptions;
with ADO.Queries.Loaders;
package body ADO.Drivers is
use Util.Log;
Log : constant Loggers.Logger := Loggers.Create ("ADO.Drivers");
-- Global configuration properties (loaded by Initialize).
Global_Config : Util.Properties.Manager;
-- ------------------------------
-- Initialize the drivers and the library by reading the property file
-- and configure the runtime with it.
-- ------------------------------
procedure Initialize (Config : in String) is
begin
Log.Info ("Initialize using property file {0}", Config);
begin
Util.Properties.Load_Properties (Global_Config, Config);
exception
when Ada.IO_Exceptions.Name_Error =>
Log.Error ("Configuration file '{0}' does not exist", Config);
end;
Initialize (Global_Config);
end Initialize;
-- ------------------------------
-- Initialize the drivers and the library and configure the runtime with the given properties.
-- ------------------------------
procedure Initialize (Config : in Util.Properties.Manager'Class) is
begin
Global_Config := Util.Properties.Manager (Config);
-- Configure the XML query loader.
ADO.Queries.Loaders.Initialize (Global_Config.Get ("ado.queries.paths", ".;db"),
Global_Config.Get ("ado.queries.load", "false") = "true");
-- Initialize the drivers.
ADO.Drivers.Initialize;
end Initialize;
-- ------------------------------
-- Get the global configuration property identified by the name.
-- If the configuration property does not exist, returns the default value.
-- ------------------------------
function Get_Config (Name : in String;
Default : in String := "") return String is
begin
return Global_Config.Get (Name, Default);
end Get_Config;
-- Initialize the drivers which are available.
procedure Initialize is separate;
end ADO.Drivers;
|
charlie5/aIDE | Ada | 7,049 | adb | with
aIDE.Palette.of_pragmas,
aIDE.GUI,
Glib,
glib.Error,
gtk.Builder,
gtk.Handlers,
Ada.Containers;
with Ada.Text_IO; use Ada.Text_IO;
package body aIDE.Editor.of_pragma
is
use gtk.Builder,
Glib,
glib.Error;
function on_name_Entry_leave (the_Entry : access Gtk_Entry_Record'Class;
Self : in aIDE.Editor.of_pragma.view) return Boolean
is
the_Text : constant String := the_Entry.Get_Text;
begin
Self.Target.Name_is (the_Text);
return False;
end on_name_Entry_leave;
package Entry_return_Callbacks is new Gtk.Handlers.User_Return_Callback (Gtk_Entry_Record,
Boolean,
aIDE.Editor.of_pragma.view);
function on_procedure_Label_clicked (the_Label : access Gtk_Label_Record'Class;
Self : in aIDE.Editor.of_pragma.view) return Boolean
is
begin
return False;
end on_procedure_Label_clicked;
package Label_return_Callbacks is new Gtk.Handlers.User_Return_Callback (Gtk_Label_Record,
Boolean,
aIDE.Editor.of_pragma.view);
procedure on_choose_Button_clicked (the_Button : access Gtk_Button_Record'Class;
Self : in aIDE.Editor.of_pragma.view)
is
begin
put_Line ("YAY YAY");
aIDE.GUI.show_pragma_Palette (Invoked_by => Self.all'Access,
Target => Self.Target);
end on_choose_Button_clicked;
package Button_return_Callbacks is new Gtk.Handlers.User_Callback (Gtk_Button_Record,
-- Boolean,
aIDE.Editor.of_pragma.view);
package body Forge
is
function new_Editor (the_Pragma : in AdaM.a_Pragma.view) return View
is
Self : constant Editor.of_pragma.view := new Editor.of_pragma.item;
the_Builder : Gtk_Builder;
Error : aliased GError;
Result : Guint;
pragma Unreferenced (Result);
begin
Gtk_New (the_Builder);
Result := the_Builder.add_from_File ("glade/editor/pragma_editor.glade", Error'Access);
if Error /= null then
Error_free (Error);
end if;
Self.top_Frame := gtk_Frame (the_Builder.get_Object ("top_Frame"));
Self.top_Box := gtk_Box (the_Builder.get_Object ("top_Box"));
Self.choose_Button := gtk_Button (the_Builder.get_Object ("choose_pragma_Button"));
Self.arguments_Box := gtk_Box (the_Builder.get_Object ("arguments_Box"));
-- Self.block_Alignment := gtk_Alignment (the_Builder.get_Object ("block_Alignment"));
-- Self.context_Alignment := gtk_Alignment (the_Builder.get_Object ("context_Alignment"));
Self.open_parenthesis_Label := gtk_Label (the_Builder.get_Object ("open_parenthesis_Label"));
Self.close_parenthesis_Label := gtk_Label (the_Builder.get_Object ("close_parenthesis_Label"));
-- Self.name_Entry := gtk_Entry (the_Builder.get_Object ("name_Entry"));
-- Entry_return_Callbacks.Connect (Self.name_Entry,
-- "focus-out-event",
-- on_name_Entry_leave'Access,
-- Self);
-- Label_return_Callbacks.Connect (Self.procedure_Label,
-- "button-release-event",
-- on_procedure_Label_clicked'Access,
-- Self);
Button_return_Callbacks.Connect (Self.choose_Button,
"clicked",
on_choose_Button_clicked'Access,
Self);
Self.Target := the_Pragma;
-- Self.context_Editor := aIDE.Editor.of_context.Forge.to_context_Editor (Self.Subprogram.Context);
-- Self.context_Editor.top_Widget.Reparent (new_Parent => Self.context_Alignment);
--
-- Self.block_Editor := aIDE.Editor.of_block.Forge.to_block_Editor (Self.Subprogram.Block);
-- Self.block_Editor.top_Widget.Reparent (new_Parent => Self.block_Alignment);
Self.freshen;
return Self;
end new_Editor;
end Forge;
procedure destroy_Callback (Widget : not null access Gtk.Widget.Gtk_Widget_Record'Class)
is
begin
Widget.destroy;
end destroy_Callback;
overriding
procedure freshen (Self : in out Item)
is
use AdaM;
use type Ada.Containers.Count_Type;
Args : constant text_Lines := Self.Target.Arguments;
begin
Self.arguments_Box.forEach (destroy_Callback'Access);
Self.choose_Button.set_Label (String (Self.Target.Name));
if Args.Length = 0
then
Self. open_parenthesis_Label.hide;
Self.close_parenthesis_Label.hide;
else
Self. open_parenthesis_Label.show;
Self.close_parenthesis_Label.show;
for Each of Args
loop
declare
new_Entry : constant gtk_Entry := Gtk_Entry_New;
Arg : constant String := +Each;
begin
-- put_Line ("ZZZZZZZZZZZZZZZZZ " & (+Each));
new_Entry.set_Width_chars (Arg'Length);
new_Entry.set_Text (Arg);
Self.arguments_Box.pack_Start (new_Entry);
-- Expand => True,
-- Fill => True,
-- Padding => 0);
end;
end loop;
Self.arguments_Box.show_All;
end if;
-- Self.top_Frame.Show_All;
-- Self.top_Widget.show_All;
-- Self.name_Entry.Set_Text (+Self.Target.Name);
-- Self.context_Editor.Context_is (Self.Subprogram.Context);
-- Self. block_Editor.Target_is (Self.Subprogram.Block);
end freshen;
function Target (Self : in Item) return AdaM.a_Pragma.view
is
begin
return Self.Target;
end Target;
procedure Target_is (Self : in out Item; Now : in AdaM.a_Pragma.view)
is
begin
Self.Target := Now;
Self.freshen;
end Target_is;
overriding
function top_Widget (Self : in Item) return gtk.Widget.Gtk_Widget
is
begin
-- return gtk.Widget.Gtk_Widget (Self.top_Frame);
return gtk.Widget.Gtk_Widget (Self.top_Box);
end top_Widget;
end aIDE.Editor.of_pragma;
|
reznikmm/slimp | Ada | 12,013 | adb | -- Copyright (c) 2019 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Ada.Numerics.Discrete_Random;
with Ada.Streams.Stream_IO;
with League.JSON.Arrays;
with League.JSON.Documents;
with League.JSON.Values;
with League.String_Vectors;
with Slim.Menu_Commands.Play_File_Commands;
with Slim.Menu_Commands.Play_Radio_Commands;
package body Slim.Menu_Models.JSON is
function Read_File
(File : League.Strings.Universal_String)
return League.JSON.Documents.JSON_Document;
function Play_Recursive
(Self : JSON_Menu_Model'Class;
Object : League.JSON.Objects.JSON_Object)
return Slim.Menu_Commands.Menu_Command_Access;
-------------------
-- Enter_Command --
-------------------
overriding function Enter_Command
(Self : JSON_Menu_Model;
Path : Menu_Path) return Slim.Menu_Commands.Menu_Command_Access
is
String : League.Strings.Universal_String;
Object : League.JSON.Objects.JSON_Object;
Item : League.JSON.Arrays.JSON_Array :=
Self.Root.Value (Self.Nested).To_Array;
begin
for J in 1 .. Path.Length loop
Object := Item.Element (Path.List (J)).To_Object;
if Object.Contains (Self.Playlist) then
-- Delegate Enter_Command to playlist model
String := Object.Value (Self.Playlist).To_String;
return Self.Playlists (String).all.Enter_Command
((Length => Path.Length - J,
List => Path.List (J + 1 .. Path.Length)));
elsif J = Path.Length then
if not Object.Contains (Self.URL) then
return null;
end if;
return
new Slim.Menu_Commands.Play_Radio_Commands.Play_Radio_Command'
(Player => Self.Player,
URL => Object.Value (Self.URL).To_String);
else
Item := Object.Value (Self.Nested).To_Array;
end if;
end loop;
return null;
end Enter_Command;
----------------
-- Initialize --
----------------
procedure Initialize
(Self : in out JSON_Menu_Model'Class;
File : League.Strings.Universal_String)
is
procedure Read_Playlists
(Path : Menu_Path;
Object : League.JSON.Objects.JSON_Object);
--------------------
-- Read_Playlists --
--------------------
procedure Read_Playlists
(Path : Menu_Path;
Object : League.JSON.Objects.JSON_Object) is
begin
if Object.Contains (Self.Playlist) then
declare
Root : constant League.Strings.Universal_String :=
Object.Value (Self.Path).To_String;
Label : constant League.Strings.Universal_String :=
Object.Value (Self.Label).To_String;
Value : constant League.Strings.Universal_String :=
Object.Value (Self.Playlist).To_String;
Next : constant Play_List_Access := new
Slim.Menu_Models.Play_Lists.Play_List_Menu_Model
(Self.Player);
begin
Next.Initialize (Label => Label, Root => Root, File => Value);
Self.Playlists.Insert (Value, Next);
end;
elsif Object.Contains (Self.Nested) then
declare
List : constant League.JSON.Arrays.JSON_Array :=
Object.Value (Self.Nested).To_Array;
Next : Menu_Path := (Path.Length + 1, Path.List & 1);
begin
for J in 1 .. List.Length loop
Next.List (Next.Length) := J;
Read_Playlists (Next, List.Element (J).To_Object);
end loop;
end;
end if;
end Read_Playlists;
Document : constant League.JSON.Documents.JSON_Document :=
Read_File (File);
begin
Self.Root := Document.To_JSON_Object;
Self.Nested := League.Strings.To_Universal_String ("nested");
Self.Label := League.Strings.To_Universal_String ("label");
Self.URL := League.Strings.To_Universal_String ("url");
Self.Path := League.Strings.To_Universal_String ("path");
Self.Playlist := League.Strings.To_Universal_String ("playlist");
Read_Playlists (Menu_Models.Root (Self), Self.Root);
end Initialize;
----------------
-- Item_Count --
----------------
overriding function Item_Count
(Self : JSON_Menu_Model;
Path : Slim.Menu_Models.Menu_Path)
return Natural
is
String : League.Strings.Universal_String;
Object : League.JSON.Objects.JSON_Object;
Item : League.JSON.Arrays.JSON_Array :=
Self.Root.Value (Self.Nested).To_Array;
Result : Natural;
begin
for J in 1 .. Path.Length loop
Object := Item.Element (Path.List (J)).To_Object;
if Object.Contains (Self.Playlist) then
-- Delegate Item_Count to playlist model
String := Object.Value (Self.Playlist).To_String;
Result := Self.Playlists (String).all.Item_Count
((Length => Path.Length - J,
List => Path.List (J + 1 .. Path.Length)));
return Result;
else
Item := Object.Value (Self.Nested).To_Array;
end if;
end loop;
return Item.Length;
end Item_Count;
-----------
-- Label --
-----------
overriding function Label
(Self : JSON_Menu_Model; Path : Slim.Menu_Models.Menu_Path)
return League.Strings.Universal_String
is
String : League.Strings.Universal_String;
Object : League.JSON.Objects.JSON_Object;
Item : League.JSON.Arrays.JSON_Array :=
Self.Root.Value (Self.Nested).To_Array;
begin
for J in 1 .. Path.Length loop
Object := Item.Element (Path.List (J)).To_Object;
if Object.Contains (Self.Playlist) then
-- Delegate Label to playlist model
String := Object.Value (Self.Playlist).To_String;
String := Self.Playlists (String).all.Label
((Length => Path.Length - J,
List => Path.List (J + 1 .. Path.Length)));
return String;
elsif J = Path.Length then
String := Object.Value (Self.Label).To_String;
return String;
else
Item := Object.Value (Self.Nested).To_Array;
end if;
end loop;
return String;
end Label;
------------------
-- Play_Command --
------------------
overriding function Play_Command
(Self : JSON_Menu_Model;
Path : Menu_Path) return Slim.Menu_Commands.Menu_Command_Access
is
String : League.Strings.Universal_String;
Object : League.JSON.Objects.JSON_Object;
Item : League.JSON.Arrays.JSON_Array :=
Self.Root.Value (Self.Nested).To_Array;
begin
for J in 1 .. Path.Length loop
Object := Item.Element (Path.List (J)).To_Object;
if Object.Contains (Self.Playlist) then
-- Delegate Play_Command to playlist model
String := Object.Value (Self.Playlist).To_String;
return Self.Playlists (String).all.Play_Command
((Length => Path.Length - J,
List => Path.List (J + 1 .. Path.Length)));
elsif J = Path.Length then
if not Object.Contains (Self.URL) then
return Play_Recursive (Self, Object);
end if;
return
new Slim.Menu_Commands.Play_Radio_Commands.Play_Radio_Command'
(Player => Self.Player,
URL => Object.Value (Self.URL).To_String);
else
Item := Object.Value (Self.Nested).To_Array;
end if;
end loop;
return null;
end Play_Command;
--------------------
-- Play_Recursive --
--------------------
function Play_Recursive
(Self : JSON_Menu_Model'Class;
Object : League.JSON.Objects.JSON_Object)
return Slim.Menu_Commands.Menu_Command_Access
is
procedure Collect (Object : League.JSON.Objects.JSON_Object);
procedure Shuffle
(Origin_Paths : League.String_Vectors.Universal_String_Vector;
Origin_Titles : League.String_Vectors.Universal_String_Vector;
Paths : out League.String_Vectors.Universal_String_Vector;
Titles : out League.String_Vectors.Universal_String_Vector);
-------------
-- Shuffle --
-------------
procedure Shuffle
(Origin_Paths : League.String_Vectors.Universal_String_Vector;
Origin_Titles : League.String_Vectors.Universal_String_Vector;
Paths : out League.String_Vectors.Universal_String_Vector;
Titles : out League.String_Vectors.Universal_String_Vector)
is
package Randoms is new Ada.Numerics.Discrete_Random (Positive);
Generator : Randoms.Generator;
Map : array (1 .. Origin_Paths.Length) of Positive;
Last : Natural := Map'Last;
Index : Positive;
begin
Randoms.Reset (Generator);
for J in Map'Range loop
Map (J) := J;
end loop;
while Last > 0 loop
Index := (Randoms.Random (Generator) mod Last) + 1;
Paths.Append (Origin_Paths (Map (Index)));
Titles.Append (Origin_Titles (Map (Index)));
Map (Index) := Map (Last);
Last := Last - 1;
end loop;
end Shuffle;
Relative_Path_List : League.String_Vectors.Universal_String_Vector;
Title_List : League.String_Vectors.Universal_String_Vector;
-------------
-- Collect --
-------------
procedure Collect (Object : League.JSON.Objects.JSON_Object) is
String : League.Strings.Universal_String;
List : constant League.JSON.Arrays.JSON_Array :=
Object.Value (Self.Nested).To_Array;
begin
if Object.Contains (Self.Playlist) then
-- Delegate Collect to playlist model
String := Object.Value (Self.Playlist).To_String;
Self.Playlists (String).all.Collect
(Relative_Path_List, Title_List);
return;
end if;
for J in 1 .. List.Length loop
Collect (List (J).To_Object);
end loop;
end Collect;
begin
Collect (Object);
if Relative_Path_List.Is_Empty then
return null;
end if;
declare
use Slim.Menu_Commands.Play_File_Commands;
Result : constant Play_File_Command_Access :=
new Play_File_Command (Self.Player);
begin
Shuffle
(Relative_Path_List,
Title_List,
Result.Relative_Path_List,
Result.Title_List);
return Slim.Menu_Commands.Menu_Command_Access (Result);
end;
end Play_Recursive;
---------------
-- Read_File --
---------------
function Read_File
(File : League.Strings.Universal_String)
return League.JSON.Documents.JSON_Document
is
Input : Ada.Streams.Stream_IO.File_Type;
begin
Ada.Streams.Stream_IO.Open
(Input, Ada.Streams.Stream_IO.In_File, File.To_UTF_8_String);
declare
Size : constant Ada.Streams.Stream_Element_Count :=
Ada.Streams.Stream_Element_Count
(Ada.Streams.Stream_IO.Size (Input));
Buffer : Ada.Streams.Stream_Element_Array (1 .. Size);
Last : Ada.Streams.Stream_Element_Count;
begin
Ada.Streams.Stream_IO.Read (Input, Buffer, Last);
return Result : constant League.JSON.Documents.JSON_Document :=
League.JSON.Documents.From_JSON (Buffer (1 .. Last))
do
Ada.Streams.Stream_IO.Close (Input);
end return;
end;
end Read_File;
end Slim.Menu_Models.JSON;
|
anshumang/cp-snucl | Ada | 253 | adb | -- RUN: %llvmgcc -S %s
procedure Array_Ref is
type A is array (Natural range <>, Natural range <>) of Boolean;
type A_Access is access A;
function Get (X : A_Access) return Boolean is
begin
return X (0, 0);
end;
begin
null;
end;
|
reznikmm/matreshka | Ada | 4,719 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Visitors;
with ODF.DOM.Table_First_Row_Elements;
package Matreshka.ODF_Table.First_Row_Elements is
type Table_First_Row_Element_Node is
new Matreshka.ODF_Table.Abstract_Table_Element_Node
and ODF.DOM.Table_First_Row_Elements.ODF_Table_First_Row
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Table_First_Row_Element_Node;
overriding function Get_Local_Name
(Self : not null access constant Table_First_Row_Element_Node)
return League.Strings.Universal_String;
overriding procedure Enter_Node
(Self : not null access Table_First_Row_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
overriding procedure Leave_Node
(Self : not null access Table_First_Row_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
overriding procedure Visit_Node
(Self : not null access Table_First_Row_Element_Node;
Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
end Matreshka.ODF_Table.First_Row_Elements;
|
zhmu/ananas | Ada | 9,814 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- E L I S T S --
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2022, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING3. If not, go to --
-- http://www.gnu.org/licenses for a complete copy of the license. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This package provides facilities for manipulating lists of nodes (see
-- package Atree for format and implementation of tree nodes). Separate list
-- elements are allocated to represent elements of these lists, so it is
-- possible for a given node to be on more than one element list at a time.
-- See also package Nlists, which provides another form that is threaded
-- through the nodes themselves (using the Link field), which is more time
-- and space efficient, but a node can be only one such list.
-- WARNING: There is a C version of this package. Any changes to this
-- source file must be properly reflected in the C header file elists.h
with Types; use Types;
with System;
package Elists is
-- An element list is represented by a header that is allocated in the
-- Elist header table. This header contains pointers to the first and
-- last elements in the list, or to No_Elmt if the list is empty.
-- The elements in the list each contain a pointer to the next element
-- and a pointer to the referenced node. Putting a node into an element
-- list causes no change at all to the node itself, so a node may be
-- included in multiple element lists, and the nodes thus included may
-- or may not be elements of node lists (see package Nlists).
procedure Initialize;
-- Initialize allocation of element list tables. Called at the start of
-- compiling each new main source file.
procedure Lock;
-- Lock tables used for element lists before calling backend
procedure Unlock;
-- Unlock list tables, in cases where the back end needs to modify them
function Last_Elist_Id return Elist_Id;
-- Returns Id of last allocated element list header
function Elists_Address return System.Address;
-- Return address of Elists table (used in Back_End for Gigi call)
function Num_Elists return Nat;
-- Number of currently allocated element lists
function Last_Elmt_Id return Elmt_Id;
-- Returns Id of last allocated list element
function Elmts_Address return System.Address;
-- Return address of Elmts table (used in Back_End for Gigi call)
function Node (Elmt : Elmt_Id) return Node_Or_Entity_Id;
pragma Inline (Node);
-- Returns the value of a given list element. Returns Empty if Elmt
-- is set to No_Elmt.
function New_Elmt_List return Elist_Id;
-- Creates a new empty element list. Typically this is used to initialize
-- a field in some other node which points to an element list where the
-- list is then subsequently filled in using Append calls.
function New_Elmt_List (Elmt1 : Node_Or_Entity_Id) return Elist_Id;
function New_Elmt_List
(Elmt1 : Node_Or_Entity_Id;
Elmt2 : Node_Or_Entity_Id) return Elist_Id;
function New_Elmt_List
(Elmt1 : Node_Or_Entity_Id;
Elmt2 : Node_Or_Entity_Id;
Elmt3 : Node_Or_Entity_Id) return Elist_Id;
function New_Elmt_List
(Elmt1 : Node_Or_Entity_Id;
Elmt2 : Node_Or_Entity_Id;
Elmt3 : Node_Or_Entity_Id;
Elmt4 : Node_Or_Entity_Id) return Elist_Id;
-- Create a new element list containing the given arguments.
function First_Elmt (List : Elist_Id) return Elmt_Id;
pragma Inline (First_Elmt);
-- Obtains the first element of the given element list or, if the list has
-- no items, then No_Elmt is returned.
function Last_Elmt (List : Elist_Id) return Elmt_Id;
pragma Inline (Last_Elmt);
-- Obtains the last element of the given element list or, if the list has
-- no items, then No_Elmt is returned.
function List_Length (List : Elist_Id) return Nat;
-- Returns number of elements in given List (zero if List = No_Elist)
function Next_Elmt (Elmt : Elmt_Id) return Elmt_Id;
pragma Inline (Next_Elmt);
-- This function returns the next element on an element list. The argument
-- must be a list element other than No_Elmt. Returns No_Elmt if the given
-- element is the last element of the list.
procedure Next_Elmt (Elmt : in out Elmt_Id);
pragma Inline (Next_Elmt);
-- Next_Elmt (Elmt) is equivalent to Elmt := Next_Elmt (Elmt)
function Is_Empty_Elmt_List (List : Elist_Id) return Boolean;
pragma Inline (Is_Empty_Elmt_List);
-- This function determines if a given tree id references an element list
-- that contains no items.
procedure Append_Elmt (N : Node_Or_Entity_Id; To : Elist_Id);
-- Appends N at the end of To, allocating a new element. N must be a
-- non-empty node or entity Id, and To must be an Elist (not No_Elist).
procedure Append_New_Elmt (N : Node_Or_Entity_Id; To : in out Elist_Id);
pragma Inline (Append_New_Elmt);
-- Like Append_Elmt if Elist_Id is not No_List, but if Elist_Id is No_List,
-- then first assigns it an empty element list and then does the append.
procedure Append_Unique_Elmt (N : Node_Or_Entity_Id; To : Elist_Id);
-- Like Append_Elmt, except that a check is made to see if To already
-- contains N and if so the call has no effect.
procedure Prepend_Elmt (N : Node_Or_Entity_Id; To : Elist_Id);
-- Appends N at the beginning of To, allocating a new element
procedure Prepend_Unique_Elmt (N : Node_Or_Entity_Id; To : Elist_Id);
-- Like Prepend_Elmt, except that a check is made to see if To already
-- contains N and if so the call has no effect.
procedure Insert_Elmt_After (N : Node_Or_Entity_Id; Elmt : Elmt_Id);
-- Add a new element (N) right after the pre-existing element Elmt
-- It is invalid to call this subprogram with Elmt = No_Elmt.
function New_Copy_Elist (List : Elist_Id) return Elist_Id;
-- Replicate the contents of a list. Internal list nodes are not shared and
-- order of elements is preserved.
procedure Replace_Elmt (Elmt : Elmt_Id; New_Node : Node_Or_Entity_Id);
pragma Inline (Replace_Elmt);
-- Causes the given element of the list to refer to New_Node, the node
-- which was previously referred to by Elmt is effectively removed from
-- the list and replaced by New_Node.
procedure Remove (List : Elist_Id; N : Node_Or_Entity_Id);
-- Remove a node or an entity from a list. If the list does not contain the
-- item in question, the routine has no effect.
procedure Remove_Elmt (List : Elist_Id; Elmt : Elmt_Id);
-- Removes Elmt from the given list. The node itself is not affected,
-- but the space used by the list element may be (but is not required
-- to be) freed for reuse in a subsequent Append_Elmt call.
procedure Remove_Last_Elmt (List : Elist_Id);
-- Removes the last element of the given list. The node itself is not
-- affected, but the space used by the list element may be (but is not
-- required to be) freed for reuse in a subsequent Append_Elmt call.
function Contains (List : Elist_Id; N : Node_Or_Entity_Id) return Boolean;
-- Perform a sequential search to determine whether the given list contains
-- a node or an entity.
function No (List : Elist_Id) return Boolean;
pragma Inline (No);
-- Tests given Id for equality with No_Elist. This allows notations like
-- "if No (Statements)" as opposed to "if Statements = No_Elist".
function Present (List : Elist_Id) return Boolean;
pragma Inline (Present);
-- Tests given Id for inequality with No_Elist. This allows notations like
-- "if Present (Statements)" as opposed to "if Statements /= No_Elist".
function No (Elmt : Elmt_Id) return Boolean;
pragma Inline (No);
-- Tests given Id for equality with No_Elmt. This allows notations like
-- "if No (Operation)" as opposed to "if Operation = No_Elmt".
function Present (Elmt : Elmt_Id) return Boolean;
pragma Inline (Present);
-- Tests given Id for inequality with No_Elmt. This allows notations like
-- "if Present (Operation)" as opposed to "if Operation /= No_Elmt".
end Elists;
|
Fabien-Chouteau/Ada_Drivers_Library | Ada | 8,391 | ads | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2015-2017, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with System;
package HAL.Filesystem is
type Status_Code is
(OK,
Non_Empty_Directory,
Disk_Error, -- A hardware error occurred in the low level disk I/O
Disk_Full,
Internal_Error,
Drive_Not_Ready,
No_Such_File,
No_Such_Path,
Not_Mounted, -- The mount point is invalid
Invalid_Name,
Access_Denied,
Already_Exists,
Invalid_Object_Entry,
Write_Protected,
Invalid_Drive,
No_Filesystem, -- The volume is not a FAT volume
Locked,
Too_Many_Open_Files, -- All available handles are used
Invalid_Parameter,
Input_Output_Error,
No_MBR_Found,
No_Partition_Found,
No_More_Entries,
Read_Only_File_System,
Operation_Not_Permitted);
type File_Mode is (Read_Only, Write_Only, Read_Write);
type Seek_Mode is
(
-- Seek from the beginning of the file, forward
From_Start,
-- Seek from the end of the file, backward
From_End,
-- Seek from the current position, forward
Forward,
-- Seek from the current position, backward
Backward);
type File_Size is new HAL.UInt64;
-- Modern fs all support 64-bit file size. Only old or limited ones support
-- max 32-bit (FAT in particular). So let's see big and not limit ourselves
-- in this API with 32-bit only.
type Filesystem_Driver is limited interface;
type Any_Filesystem_Driver is access all Filesystem_Driver'Class;
type Directory_Handle is limited interface;
type Any_Directory_Handle is access all Directory_Handle'Class;
type File_Handle is limited interface;
type Any_File_Handle is access all File_Handle'Class;
type Node_Handle is interface;
type Any_Node_Handle is access all Node_Handle'Class;
---------------------------
-- Directory operations --
---------------------------
function Open
(This : in out Filesystem_Driver;
Path : String;
Handle : out Any_Directory_Handle)
return Status_Code is abstract;
-- Open a new Directory Handle at the given Filesystem_Driver Path
function Create_File (This : in out Filesystem_Driver;
Path : String)
return Status_Code is abstract;
function Unlink (This : in out Filesystem_Driver;
Path : String)
return Status_Code is abstract;
-- Remove the regular file located at Path in the This filesystem_Driver
function Remove_Directory (This : in out Filesystem_Driver;
Path : String)
return Status_Code is abstract;
-- Remove the directory located at Path in the This filesystem_Driver
function Get_FS
(This : Directory_Handle) return Any_Filesystem_Driver
is abstract;
-- Return the filesystem_Driver the handle belongs to.
function Root_Node
(This : in out Filesystem_Driver;
As : String;
Handle : out Any_Node_Handle)
return Status_Code is abstract;
-- Open a new Directory Handle at the given Filesystem_Driver Path
function Read
(This : in out Directory_Handle;
Handle : out Any_Node_Handle)
return Status_Code is abstract;
-- Reads the next directory entry. If no such entry is there, an error
-- code is returned in Status.
procedure Reset (This : in out Directory_Handle) is abstract;
-- Resets the handle to the first node
procedure Close (This : in out Directory_Handle) is abstract;
-- Closes the handle, and free the associated resources.
---------------------
-- Node operations --
---------------------
function Get_FS (This : Node_Handle) return Any_Filesystem_Driver is abstract;
function Basename (This : Node_Handle) return String is abstract;
function Is_Read_Only (This : Node_Handle) return Boolean is abstract;
function Is_Hidden (This : Node_Handle) return Boolean is abstract;
function Is_Subdirectory (This : Node_Handle) return Boolean is abstract;
function Is_Symlink (This : Node_Handle) return Boolean is abstract;
function Size (This : Node_Handle) return File_Size is abstract;
procedure Close (This : in out Node_Handle) is abstract;
---------------------
-- File operations --
---------------------
function Open
(This : in out Filesystem_Driver;
Path : String;
Mode : File_Mode;
Handle : out Any_File_Handle)
return Status_Code is abstract;
-- Open a new File Handle at the given Filesystem_Driver Path
function Open
(This : Node_Handle;
Name : String;
Mode : File_Mode;
Handle : out Any_File_Handle)
return Status_Code is abstract
with Pre'Class => Is_Subdirectory (This);
function Get_FS
(This : in out File_Handle) return Any_Filesystem_Driver is abstract;
function Size
(This : File_Handle) return File_Size is abstract;
function Mode
(This : File_Handle) return File_Mode is abstract;
function Read
(This : in out File_Handle;
Addr : System.Address;
Length : in out File_Size)
return Status_Code is abstract
with Pre'Class => Mode (This) in Read_Only | Read_Write;
function Write
(This : in out File_Handle;
Addr : System.Address;
Length : File_Size)
return Status_Code is abstract
with
Pre'Class => Mode (This) in Write_Only | Read_Write;
function Offset
(This : File_Handle)
return File_Size is abstract;
function Flush
(This : in out File_Handle)
return Status_Code is abstract;
function Seek
(This : in out File_Handle;
Origin : Seek_Mode;
Amount : in out File_Size)
return Status_Code is abstract;
procedure Close (This : in out File_Handle) is abstract;
-------------------
-- FS operations --
-------------------
procedure Close (This : in out Filesystem_Driver) is abstract;
end HAL.Filesystem;
|
x0id/swagger-codegen | Ada | 7,711 | ads | -- Swagger Petstore
-- This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.
--
-- OpenAPI spec version: 1.0.0
-- Contact: [email protected]
--
-- NOTE: This package is auto generated by the swagger code generator 2.3.0-SNAPSHOT.
-- https://github.com/swagger-api/swagger-codegen.git
-- Do not edit the class manually.
with Swagger.Streams;
with Ada.Containers.Vectors;
package Samples.Petstore.Models is
-- ------------------------------
-- An uploaded response
-- Describes the result of uploading an image resource
-- ------------------------------
type ApiResponse_Type is
record
Code : Integer;
P_Type : Swagger.UString;
Message : Swagger.UString;
end record;
package ApiResponse_Type_Vectors is
new Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => ApiResponse_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in ApiResponse_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in ApiResponse_Type_Vectors.Vector);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out ApiResponse_Type);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out ApiResponse_Type_Vectors.Vector);
-- ------------------------------
-- Pet category
-- A category for a pet
-- ------------------------------
type Category_Type is
record
Id : Swagger.Long;
Name : Swagger.UString;
end record;
package Category_Type_Vectors is
new Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => Category_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in Category_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in Category_Type_Vectors.Vector);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out Category_Type);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out Category_Type_Vectors.Vector);
-- ------------------------------
-- Pet Tag
-- A tag for a pet
-- ------------------------------
type Tag_Type is
record
Id : Swagger.Long;
Name : Swagger.UString;
end record;
package Tag_Type_Vectors is
new Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => Tag_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in Tag_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in Tag_Type_Vectors.Vector);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out Tag_Type);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out Tag_Type_Vectors.Vector);
-- ------------------------------
-- a User
-- A User who is purchasing from the pet store
-- ------------------------------
type User_Type is
record
Id : Swagger.Long;
Username : Swagger.UString;
First_Name : Swagger.UString;
Last_Name : Swagger.UString;
Email : Swagger.UString;
Password : Swagger.UString;
Phone : Swagger.UString;
User_Status : Integer;
end record;
package User_Type_Vectors is
new Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => User_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in User_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in User_Type_Vectors.Vector);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out User_Type);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out User_Type_Vectors.Vector);
-- ------------------------------
-- Pet Order
-- An order for a pets from the pet store
-- ------------------------------
type Order_Type is
record
Id : Swagger.Long;
Pet_Id : Swagger.Long;
Quantity : Integer;
Ship_Date : Swagger.Datetime;
Status : Swagger.UString;
Complete : Boolean;
end record;
package Order_Type_Vectors is
new Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => Order_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in Order_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in Order_Type_Vectors.Vector);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out Order_Type);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out Order_Type_Vectors.Vector);
-- ------------------------------
-- a Pet
-- A pet for sale in the pet store
-- ------------------------------
type Pet_Type is
record
Id : Swagger.Long;
Category : Samples.Petstore.Models.Category_Type;
Name : Swagger.UString;
Photo_Urls : Swagger.UString_Vectors.Vector;
Tags : Samples.Petstore.Models.Tag_Type_Vectors.Vector;
Status : Swagger.UString;
end record;
package Pet_Type_Vectors is
new Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => Pet_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in Pet_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in Pet_Type_Vectors.Vector);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out Pet_Type);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out Pet_Type_Vectors.Vector);
end Samples.Petstore.Models;
|
reznikmm/matreshka | Ada | 5,460 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.Generic_Collections;
package AMF.UMLDI.UML_Typed_Element_Labels.Collections is
pragma Preelaborate;
package UMLDI_UML_Typed_Element_Label_Collections is
new AMF.Generic_Collections
(UMLDI_UML_Typed_Element_Label,
UMLDI_UML_Typed_Element_Label_Access);
type Set_Of_UMLDI_UML_Typed_Element_Label is
new UMLDI_UML_Typed_Element_Label_Collections.Set with null record;
Empty_Set_Of_UMLDI_UML_Typed_Element_Label : constant Set_Of_UMLDI_UML_Typed_Element_Label;
type Ordered_Set_Of_UMLDI_UML_Typed_Element_Label is
new UMLDI_UML_Typed_Element_Label_Collections.Ordered_Set with null record;
Empty_Ordered_Set_Of_UMLDI_UML_Typed_Element_Label : constant Ordered_Set_Of_UMLDI_UML_Typed_Element_Label;
type Bag_Of_UMLDI_UML_Typed_Element_Label is
new UMLDI_UML_Typed_Element_Label_Collections.Bag with null record;
Empty_Bag_Of_UMLDI_UML_Typed_Element_Label : constant Bag_Of_UMLDI_UML_Typed_Element_Label;
type Sequence_Of_UMLDI_UML_Typed_Element_Label is
new UMLDI_UML_Typed_Element_Label_Collections.Sequence with null record;
Empty_Sequence_Of_UMLDI_UML_Typed_Element_Label : constant Sequence_Of_UMLDI_UML_Typed_Element_Label;
private
Empty_Set_Of_UMLDI_UML_Typed_Element_Label : constant Set_Of_UMLDI_UML_Typed_Element_Label
:= (UMLDI_UML_Typed_Element_Label_Collections.Set with null record);
Empty_Ordered_Set_Of_UMLDI_UML_Typed_Element_Label : constant Ordered_Set_Of_UMLDI_UML_Typed_Element_Label
:= (UMLDI_UML_Typed_Element_Label_Collections.Ordered_Set with null record);
Empty_Bag_Of_UMLDI_UML_Typed_Element_Label : constant Bag_Of_UMLDI_UML_Typed_Element_Label
:= (UMLDI_UML_Typed_Element_Label_Collections.Bag with null record);
Empty_Sequence_Of_UMLDI_UML_Typed_Element_Label : constant Sequence_Of_UMLDI_UML_Typed_Element_Label
:= (UMLDI_UML_Typed_Element_Label_Collections.Sequence with null record);
end AMF.UMLDI.UML_Typed_Element_Labels.Collections;
|
pchapin/augusta | Ada | 3,449 | adb | ---------------------------------------------------------------------------
-- FILE : augusta-wide_wide_characters-handling.adb
-- SUBJECT : Body of wide wide character handling package.
-- AUTHOR : (C) Copyright 2013 by the Augusta Contributors
--
-- Please send comments or bug reports to
--
-- Peter C. Chapin <[email protected]>
---------------------------------------------------------------------------
package body Augusta.Wide_Wide_Characters.Handling is
function Character_Set_Version return String is
begin
raise Not_Implemented;
return "TODO";
end Character_Set_Version;
function Is_Control(Item : in Wide_Wide_Character) return Boolean is
begin
raise Not_Implemented;
return False;
end Is_Control;
function Is_Letter(Item : in Wide_Wide_Character) return Boolean is
begin
raise Not_Implemented;
return False;
end Is_Letter;
function Is_Lower(Item : in Wide_Wide_Character) return Boolean is
begin
raise Not_Implemented;
return False;
end Is_Lower;
function Is_Upper(Item : in Wide_Wide_Character) return Boolean is
begin
raise Not_Implemented;
return False;
end Is_Upper;
function Is_Digit(Item : in Wide_Wide_Character) return Boolean is
begin
raise Not_Implemented;
return False;
end Is_Digit;
function Is_Hexadecimal_Digit(Item : in Wide_Wide_Character) return Boolean is
begin
raise Not_Implemented;
return False;
end Is_Hexadecimal_Digit;
function Is_Alphanumeric(Item : in Wide_Wide_Character) return Boolean is
begin
raise Not_Implemented;
return False;
end Is_Alphanumeric;
function Is_Special(Item : in Wide_Wide_Character) return Boolean is
begin
raise Not_Implemented;
return False;
end Is_Special;
function Is_Line_Terminator(Item : in Wide_Wide_Character) return Boolean is
begin
raise Not_Implemented;
return False;
end Is_Line_Terminator;
function Is_Mark(Item : in Wide_Wide_Character) return Boolean is
begin
raise Not_Implemented;
return False;
end Is_Mark;
function Is_Other_Format(Item : in Wide_Wide_Character) return Boolean is
begin
raise Not_Implemented;
return False;
end Is_Other_Format;
function Is_Punctuation_Connector(Item : in Wide_Wide_Character) return Boolean is
begin
raise Not_Implemented;
return False;
end Is_Punctuation_Connector;
function Is_Space(Item : in Wide_Wide_Character) return Boolean is
begin
raise Not_Implemented;
return False;
end Is_Space;
function Is_Graphic(Item : in Wide_Wide_Character) return Boolean is
begin
raise Not_Implemented;
return False;
end Is_Graphic;
function To_Lower(Item : in Wide_Wide_Character) return Wide_Wide_Character is
begin
raise Not_Implemented;
return ' ';
end To_Lower;
function To_Upper(Item : in Wide_Wide_Character) return Wide_Wide_Character is
begin
raise Not_Implemented;
return ' ';
end To_Upper;
function To_Lower(Item : in Wide_Wide_String) return Wide_Wide_String is
begin
raise Not_Implemented;
return "";
end To_Lower;
function To_Upper(Item : in Wide_Wide_String) return Wide_Wide_String is
begin
raise Not_Implemented;
return "";
end To_Upper;
end Augusta.Wide_Wide_Characters.Handling;
|
zhmu/ananas | Ada | 308 | ads | package Lto20_Pkg is
type Arr is private;
Null_Arr : constant Arr;
procedure Proc (A : Arr);
private
type Obj;
type Handle is access Obj;
Null_Handle : constant Handle := null;
type Arr is array (1 .. 2) of Handle;
Null_Arr : constant Arr := (others => Null_Handle);
end Lto20_Pkg;
|
godunko/adawebpack | Ada | 3,166 | ads | ------------------------------------------------------------------------------
-- --
-- AdaWebPack --
-- --
------------------------------------------------------------------------------
-- Copyright © 2020, Vadim Godunko --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
------------------------------------------------------------------------------
with Web.DOM.Documents;
with Web.HTML.Elements;
with Web.Strings;
package Web.HTML.Documents is
type Document is new Web.DOM.Documents.Document with null record;
function Get_Element_By_Id
(Self : Document'Class;
Element_Id : Web.Strings.Web_String)
return Web.HTML.Elements.HTML_Element;
-- Conventional overloading of Get_Element_By_Id.
end Web.HTML.Documents;
|
fnarenji/BoiteMaker | Ada | 2,547 | ads | with point_list;
use point_list;
with point;
use point;
package petit_poucet is
-- Un petit poucet est un objet possèdant un jeu de coordonées
-- et qui enregistre chacun des mouvements qu'il réalise
-- permettant ensuite de récupérer l'historique de ses mouvements
type petit_poucet_t is
record
-- historique des points du petit poucet
start_node : node_ptr;
-- historique des points du petit poucet
curr_node : node_ptr;
-- position de départ du petit poucet
start_pos : point_t;
-- position courrante du petit poucet
curr_pos : point_t;
end record;
-- Instancie un petit poucet
function get_petit_poucet(start_pos : point_t) return petit_poucet_t;
-- Obtient les points laissés par le petit poucet
function get_points(poucet : petit_poucet_t) return node_ptr;
-- Deplace le petit poucet de delta_x vers la gauche
-- Garantit: 0 <= coords <= infini
-- Exception: invalid_pos si coords < 0
procedure mv_l(poucet : in out petit_poucet_t; delta_x : float);
-- procedure mv_l(poucet : in out petit_poucet_t; delta_x : integer);
-- Deplace le petit poucet de delta_x vers la droite
-- Garantit: 0 <= coords <= infini
-- Exception: invalid_pos si coords < 0
procedure mv_r(poucet : in out petit_poucet_t; delta_x : float);
-- procedure mv_r(poucet : in out petit_poucet_t; delta_x : integer);
-- Deplace le petit poucet de delta_y vers le haut
-- Garantit: 0 <= coords <= infini
-- Exception: invalid_pos si coords < 0
procedure mv_u(poucet : in out petit_poucet_t; delta_y : float);
-- procedure mv_u(poucet : in out petit_poucet_t; delta_y : integer);
-- Deplace le petit poucet de delta_y vers le bas
-- Garantit: 0 <= coords <= infini
-- Exception: invalid_pos si coords < 0
procedure mv_d(poucet : in out petit_poucet_t; delta_y : float);
-- procedure mv_d(poucet : in out petit_poucet_t; delta_y : integer);
-- Type décrivant un pointeur de fonction
-- vers une procédure de mv de poucet
type mv_poucet_ptr is access procedure (poucet : in out petit_poucet_t; delta_axis : float);
-- Constantes de pointeurs vers les mv_* du poucet
mv_l_ptr : constant mv_poucet_ptr := mv_l'access;
mv_r_ptr : constant mv_poucet_ptr := mv_r'access;
mv_u_ptr : constant mv_poucet_ptr := mv_u'access;
mv_d_ptr : constant mv_poucet_ptr := mv_d'access;
end petit_poucet;
|
reznikmm/matreshka | Ada | 6,958 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Db.Schema_Definition_Elements is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Db_Schema_Definition_Element_Node is
begin
return Self : Db_Schema_Definition_Element_Node do
Matreshka.ODF_Db.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Db_Prefix);
end return;
end Create;
----------------
-- Enter_Node --
----------------
overriding procedure Enter_Node
(Self : not null access Db_Schema_Definition_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then
ODF.DOM.Visitors.Abstract_ODF_Visitor'Class
(Visitor).Enter_Db_Schema_Definition
(ODF.DOM.Db_Schema_Definition_Elements.ODF_Db_Schema_Definition_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Enter_Node (Visitor, Control);
end if;
end Enter_Node;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Db_Schema_Definition_Element_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Schema_Definition_Element;
end Get_Local_Name;
----------------
-- Leave_Node --
----------------
overriding procedure Leave_Node
(Self : not null access Db_Schema_Definition_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then
ODF.DOM.Visitors.Abstract_ODF_Visitor'Class
(Visitor).Leave_Db_Schema_Definition
(ODF.DOM.Db_Schema_Definition_Elements.ODF_Db_Schema_Definition_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Leave_Node (Visitor, Control);
end if;
end Leave_Node;
----------------
-- Visit_Node --
----------------
overriding procedure Visit_Node
(Self : not null access Db_Schema_Definition_Element_Node;
Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Iterator in ODF.DOM.Iterators.Abstract_ODF_Iterator'Class then
ODF.DOM.Iterators.Abstract_ODF_Iterator'Class
(Iterator).Visit_Db_Schema_Definition
(Visitor,
ODF.DOM.Db_Schema_Definition_Elements.ODF_Db_Schema_Definition_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Visit_Node (Iterator, Visitor, Control);
end if;
end Visit_Node;
begin
Matreshka.DOM_Documents.Register_Element
(Matreshka.ODF_String_Constants.Db_URI,
Matreshka.ODF_String_Constants.Schema_Definition_Element,
Db_Schema_Definition_Element_Node'Tag);
end Matreshka.ODF_Db.Schema_Definition_Elements;
|
ekoeppen/STM32_Generic_Ada_Drivers | Ada | 4,918 | adb | with STM32_SVD.GPIO; use STM32_SVD.GPIO;
with STM32_SVD.SCB; use STM32_SVD.SCB;
with STM32_SVD.RCC; use STM32_SVD.RCC;
with STM32_SVD.EXTI; use STM32_SVD.EXTI;
with STM32_SVD.NVIC; use STM32_SVD.NVIC;
with STM32_SVD.SYSCFG; use STM32_SVD.SYSCFG;
with STM32GD.GPIO.Port;
package body STM32GD.GPIO.Pin is
type Port_Periph_Access is access all GPIO_Peripheral;
function Index return Natural is begin return GPIO_Pin'Pos (Pin); end Index;
function Pin_Mask return UInt16 is begin return GPIO_Pin'Enum_Rep (Pin); end Pin_Mask;
function Port_Periph return Port_Periph_Access is begin
return (if Port = Port_A then STM32_SVD.GPIO.GPIOA_Periph'Access
elsif Port = Port_B then STM32_SVD.GPIO.GPIOB_Periph'Access
elsif Port = Port_C then STM32_SVD.GPIO.GPIOC_Periph'Access
elsif Port = Port_D then STM32_SVD.GPIO.GPIOD_Periph'Access
else STM32_SVD.GPIO.GPIOF_Periph'Access); end Port_Periph;
procedure Enable is
begin
case Port is
when Port_A => RCC_Periph.AHBENR.IOPAEN := 1;
when Port_B => RCC_Periph.AHBENR.IOPBEN := 1;
when Port_C => RCC_Periph.AHBENR.IOPCEN := 1;
when Port_D => RCC_Periph.AHBENR.IOPDEN := 1;
when Port_F => RCC_Periph.AHBENR.IOPFEN := 1;
end case;
end Enable;
procedure Disable is
begin
case Port is
when Port_A => RCC_Periph.AHBENR.IOPAEN := 0;
when Port_B => RCC_Periph.AHBENR.IOPBEN := 0;
when Port_C => RCC_Periph.AHBENR.IOPCEN := 0;
when Port_D => RCC_Periph.AHBENR.IOPDEN := 0;
when Port_F => RCC_Periph.AHBENR.IOPFEN := 0;
end case;
end Disable;
procedure Init is
begin
if Mode /= Mode_In then
Set_Mode (Mode);
end if;
if Pull_Resistor /= Floating then
Set_Pull_Resistor (Pull_Resistor);
end if;
if Alternate_Function /= 0 then
Configure_Alternate_Function (Alternate_Function);
end if;
end Init;
procedure Set_Mode (Mode : Pin_IO_Modes) is
begin
Port_Periph.MODER.Arr (Index) := Pin_IO_Modes'Enum_Rep (Mode);
end Set_Mode;
procedure Set_Type (Pin_Type : Pin_Output_Types) is
begin
Port_Periph.OTYPER.OT.Arr (Index) := Pin_Output_Types'Enum_Rep (Pin_Type);
end Set_Type;
function Get_Pull_Resistor return Internal_Pin_Resistors is
begin
if Port_Periph.PUPDR.Arr (Index) = 0 then
return Floating;
elsif Port_Periph.PUPDR.Arr (Index) = 1 then
return Pull_Up;
else
return Pull_Down;
end if;
end Get_Pull_Resistor;
procedure Set_Pull_Resistor (Pull : Internal_Pin_Resistors) is
begin
Port_Periph.PUPDR.Arr (Index) := Internal_Pin_Resistors'Enum_Rep (Pull);
end Set_Pull_Resistor;
function Is_Set return Boolean is
begin
return (Port_Periph.IDR.IDR.Val and Pin_Mask) = Pin_Mask;
end Is_Set;
procedure Set is
begin
Port_Periph.BSRR.BS.Val := GPIO_Pin'Enum_Rep (Pin);
end Set;
procedure Clear is
begin
Port_Periph.BRR.BR.Val := GPIO_Pin'Enum_Rep (Pin);
end Clear;
procedure Toggle is
begin
Port_Periph.ODR.ODR.Val := Port_Periph.ODR.ODR.Val xor GPIO_Pin'Enum_Rep (Pin);
end Toggle;
procedure Configure_Alternate_Function (AF : GPIO_Alternate_Function) is
begin
if Index < 8 then
Port_Periph.AFRL.Arr (Index) := UInt4 (AF);
else
Port_Periph.AFRH.Arr (Index) := UInt4 (AF);
end if;
end Configure_Alternate_Function;
procedure Connect_External_Interrupt
is
Port_Id : constant UInt4 := GPIO_Port'Enum_Rep (Port);
begin
case Index is
when 0 .. 3 =>
SYSCFG_Periph.EXTICR1.EXTI.Arr (Index) := Port_Id;
when 4 .. 7 =>
SYSCFG_Periph.EXTICR2.EXTI.Arr (Index) := Port_Id;
when 8 .. 11 =>
SYSCFG_Periph.EXTICR3.EXTI.Arr (Index) := Port_Id;
when 12 .. 15 =>
SYSCFG_Periph.EXTICR4.EXTI.Arr (Index) := Port_Id;
when others =>
raise Program_Error;
end case;
end Connect_External_Interrupt;
procedure Wait_For_Trigger is
begin
loop
STM32GD.Wait_For_Event;
exit when Triggered;
end loop;
Clear_Trigger;
end Wait_For_Trigger;
procedure Clear_Trigger is
begin
EXTI_Periph.PR.PR.Arr (Index) := 1;
NVIC_Periph.ICPR := 2 ** 5;
end Clear_Trigger;
function Triggered return Boolean is
begin
return EXTI_Periph.PR.PR.Arr (Index) = 1;
end Triggered;
procedure Configure_Trigger (Rising : Boolean := False; Falling : Boolean := False) is
begin
Connect_External_Interrupt;
if Rising then
EXTI_Periph.RTSR.TR.Arr (Index) := 1;
end if;
if Falling then
EXTI_Periph.FTSR.TR.Arr (Index) := 1;
end if;
EXTI_Periph.EMR.MR.Arr (Index) := 1;
end Configure_Trigger;
end STM32GD.GPIO.Pin;
|
zrmyers/VulkanAda | Ada | 1,851 | ads | --------------------------------------------------------------------------------
-- MIT License
--
-- Copyright (c) 2021 Zane Myers
--
-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to deal
-- in the Software without restriction, including without limitation the rights
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions:
--
-- The above copyright notice and this permission notice shall be included in all
-- copies or substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-- SOFTWARE.
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--< @group Vulkan Math Basic Types
--------------------------------------------------------------------------------
--< @summary
--< This package provides a single precision floating point matrix with 4 rows
--< and 3 columns.
--------------------------------------------------------------------------------
package Vulkan.Math.Dmat4x3.Test is
-- Test Harness for Mat4x3 regression tests
procedure Test_Dmat4x3;
end Vulkan.Math.Dmat4x3.Test;
|
AdaCore/Ada_Drivers_Library | Ada | 10,083 | ads | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2015-2016, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- This file accompanied the original distribution of the Hershey fonts,
-- via the Usenet :
--
-- This distribution is made possible through the collective encouragement of
-- the Usenet Font Consortium, a mailing list that sprang to life to get this
-- accomplished and that will now most likely disappear into the mists of
-- time... Thanks are especially due to Jim Hurt, who provided the packed
-- font data for the distribution, along with a lot of other help.
--
-- This file describes the Hershey Fonts in general, along with a description
-- of the other files in this distribution and a simple re-distribution
-- restriction.
--
-- USE RESTRICTION: This distribution of the Hershey Fonts may be used by
-- anyone for any purpose, commercial or otherwise, providing that:
-- 1. The following acknowledgements must be distributed with the font data:
-- - The Hershey Fonts were originally created by Dr. A. V. Hershey while
-- working at the U. S. National Bureau of Standards.
-- - The format of the Font data in this distribution was originally
-- created by:
-- James Hurt
-- Cognition, Inc.
-- 900 Technology Park Drive
-- Billerica, MA 01821
-- (mit-eddie!ci-dandelion!hurt)
-- 2. The font data in this distribution may be converted into any other
-- format *EXCEPT* the format distributed by the U.S. NTIS (which
-- organization holds the rights to the distribution and use of the font
-- data in that particular format). Not that anybody would really *want*
-- to use their format... each point is described in eight UInt8s as
-- "xxx yyy:", where xxx and yyy are the coordinate values as ASCII
-- numbers.
--
-- *PLEASE* be reassured: The legal implications of NTIS' attempt to control
-- a particular form of the Hershey Fonts *are* troubling. HOWEVER: We have
-- been endlessly and repeatedly assured by NTIS that they do not care what
-- we do with our version of the font data, they do not want to know about
-- it, they understand that we are distributing this information all over the
-- world, etc etc etc... but because it isn't in their *exact* distribution
-- format, they just don't care!!! So go ahead and use the data with a
-- clear conscience! (If you feel bad about it, take a smaller deduction
-- for something on your taxes next week...)
package Hershey_Fonts.FuturaL is
pragma Warnings (Off);
Desc : aliased constant String :=
"12345 1JZ" &
"12345 9MWRFRT RRYQZR[SZRY" &
"12345 6JZNFNM RVFVM" &
"12345 12H]SBLb RYBRb RLOZO RKUYU" &
"12345 27H\PBP_ RTBT_ RYIWGTFPFMGKIKKLMMNOOUQWRXSYUYXWZT[P[MZKX" &
"12345 32F^[FI[ RNFPHPJOLMMKMIKIIJGLFNFPGSHVHYG[F RWTUUTWTYV[X[Z" &
"Z[X[VYTWT" &
"12345 35E_\O\N[MZMYNXPVUTXRZP[L[JZIYHWHUISJRQNRMSKSIRGPFNGMIMKN" &
"NPQUXWZY[[[\Z\Y" &
"12345 8MWRHQGRFSGSIRKQL" &
"12345 11KYVBTDRGPKOPOTPYR]T`Vb" &
"12345 11KYNBPDRGTKUPUTTYR]P`Nb" &
"12345 9JZRLRX RMOWU RWOMU" &
"12345 6E_RIR[ RIR[R" &
"12345 8NVSWRXQWRVSWSYQ[" &
"12345 3E_IR[R" &
"12345 6NVRVQWRXSWRV" &
"12345 3G][BIb" &
"12345 18H\QFNGLJKOKRLWNZQ[S[VZXWYRYOXJVGSFQF" &
"12345 5H\NJPISFS[" &
"12345 15H\LKLJMHNGPFTFVGWHXJXLWNUQK[Y[" &
"12345 16H\MFXFRNUNWOXPYSYUXXVZS[P[MZLYKW" &
"12345 7H\UFKTZT RUFU[" &
"12345 18H\WFMFLOMNPMSMVNXPYSYUXXVZS[P[MZLYKW" &
"12345 24H\XIWGTFRFOGMJLOLTMXOZR[S[VZXXYUYTXQVOSNRNOOMQLT" &
"12345 6H\YFO[ RKFYF" &
"12345 30H\PFMGLILKMMONSOVPXRYTYWXYWZT[P[MZLYKWKTLRNPQOUNWMXKXIW" &
"GTFPF" &
"12345 24H\XMWPURRSQSNRLPKMKLLINGQFRFUGWIXMXRWWUZR[P[MZLX" &
"12345 12NVROQPRQSPRO RRVQWRXSWRV" &
"12345 14NVROQPRQSPRO RSWRXQWRVSWSYQ[" &
"12345 4F^ZIJRZ[" &
"12345 6E_IO[O RIU[U" &
"12345 4F^JIZRJ[" &
"12345 21I[LKLJMHNGPFTFVGWHXJXLWNVORQRT RRYQZR[SZRY" &
"12345 56E`WNVLTKQKOLNMMPMSNUPVSVUUVS RQKOMNPNSOUPV RWKVSVUXVZV\" &
"T]Q]O\L[JYHWGTFQFNGLHJJILHOHRIUJWLYNZQ[T[WZYYZX RXKWSWUXV" &
"12345 9I[RFJ[ RRFZ[ RMTWT" &
"12345 24G\KFK[ RKFTFWGXHYJYLXNWOTP RKPTPWQXRYTYWXYWZT[K[" &
"12345 19H]ZKYIWGUFQFOGMILKKNKSLVMXOZQ[U[WZYXZV" &
"12345 16G\KFK[ RKFRFUGWIXKYNYSXVWXUZR[K[" &
"12345 12H[LFL[ RLFYF RLPTP RL[Y[" &
"12345 9HZLFL[ RLFYF RLPTP" &
"12345 23H]ZKYIWGUFQFOGMILKKNKSLVMXOZQ[U[WZYXZVZS RUSZS" &
"12345 9G]KFK[ RYFY[ RKPYP" &
"12345 3NVRFR[" &
"12345 11JZVFVVUYTZR[P[NZMYLVLT" &
"12345 9G\KFK[ RYFKT RPOY[" &
"12345 6HYLFL[ RL[X[" &
"12345 12F^JFJ[ RJFR[ RZFR[ RZFZ[" &
"12345 9G]KFK[ RKFY[ RYFY[" &
"12345 22G]PFNGLIKKJNJSKVLXNZP[T[VZXXYVZSZNYKXIVGTFPF" &
"12345 14G\KFK[ RKFTFWGXHYJYMXOWPTQKQ" &
"12345 25G]PFNGLIKKJNJSKVLXNZP[T[VZXXYVZSZNYKXIVGTFPF RSWY]" &
"12345 17G\KFK[ RKFTFWGXHYJYLXNWOTPKP RRPY[" &
"12345 21H\YIWGTFPFMGKIKKLMMNOOUQWRXSYUYXWZT[P[MZKX" &
"12345 6JZRFR[ RKFYF" &
"12345 11G]KFKULXNZQ[S[VZXXYUYF" &
"12345 6I[JFR[ RZFR[" &
"12345 12F^HFM[ RRFM[ RRFW[ R\FW[" &
"12345 6H\KFY[ RYFK[" &
"12345 7I[JFRPR[ RZFRP" &
"12345 9H\YFK[ RKFYF RK[Y[" &
"12345 12KYOBOb RPBPb ROBVB RObVb" &
"12345 3KYKFY^" &
"12345 12KYTBTb RUBUb RNBUB RNbUb" &
"12345 6JZRDJR RRDZR" &
"12345 3I[Ib[b" &
"12345 8NVSKQMQORPSORNQO" &
"12345 18I\XMX[ RXPVNTMQMONMPLSLUMXOZQ[T[VZXX" &
"12345 18H[LFL[ RLPNNPMSMUNWPXSXUWXUZS[P[NZLX" &
"12345 15I[XPVNTMQMONMPLSLUMXOZQ[T[VZXX" &
"12345 18I\XFX[ RXPVNTMQMONMPLSLUMXOZQ[T[VZXX" &
"12345 18I[LSXSXQWOVNTMQMONMPLSLUMXOZQ[T[VZXX" &
"12345 9MYWFUFSGRJR[ ROMVM" &
"12345 23I\XMX]W`VaTbQbOa RXPVNTMQMONMPLSLUMXOZQ[T[VZXX" &
"12345 11I\MFM[ RMQPNRMUMWNXQX[" &
"12345 9NVQFRGSFREQF RRMR[" &
"12345 12MWRFSGTFSERF RSMS^RaPbNb" &
"12345 9IZMFM[ RWMMW RQSX[" &
"12345 3NVRFR[" &
"12345 19CaGMG[ RGQJNLMOMQNRQR[ RRQUNWMZM\N]Q][" &
"12345 11I\MMM[ RMQPNRMUMWNXQX[" &
"12345 18I\QMONMPLSLUMXOZQ[T[VZXXYUYSXPVNTMQM" &
"12345 18H[LMLb RLPNNPMSMUNWPXSXUWXUZS[P[NZLX" &
"12345 18I\XMXb RXPVNTMQMONMPLSLUMXOZQ[T[VZXX" &
"12345 9KXOMO[ ROSPPRNTMWM" &
"12345 18J[XPWNTMQMNNMPNRPSUTWUXWXXWZT[Q[NZMX" &
"12345 9MYRFRWSZU[W[ ROMVM" &
"12345 11I\MMMWNZP[S[UZXW RXMX[" &
"12345 6JZLMR[ RXMR[" &
"12345 12G]JMN[ RRMN[ RRMV[ RZMV[" &
"12345 6J[MMX[ RXMM[" &
"12345 10JZLMR[ RXMR[P_NaLbKb" &
"12345 9J[XMM[ RMMXM RM[X[" &
"12345 40KYTBRCQDPFPHQJRKSMSOQQ RRCQEQGRISJTLTNSPORSTTVTXSZR[Q]Q" &
"_Ra RQSSUSWRYQZP\P^Q`RaTb" &
"12345 3NVRBRb" &
"12345 40KYPBRCSDTFTHSJRKQMQOSQ RRCSESGRIQJPLPNQPURQTPVPXQZR[S]S" &
"_Ra RSSQUQWRYSZT\T^S`RaPb" &
"12345 24F^IUISJPLONOPPTSVTXTZS[Q RISJQLPNPPQTTVUXUZT[Q[O" &
"12345 35JZJFJ[K[KFLFL[M[MFNFN[O[OFPFP[Q[QFRFR[S[SFTFT[U[UFVFV[W" &
"[WFXFX[Y[YFZFZ[";
Font : Font_Desc := Desc'Access;
pragma Warnings (On);
end Hershey_Fonts.FuturaL;
|
MinimSecure/unum-sdk | Ada | 818 | adb | -- Copyright 2008-2016 Free Software Foundation, Inc.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
with Pck; use Pck;
procedure Foo is
D : Data := (1, 2, 3, 4, 5, 6);
begin
Call_Me (D);
end Foo;
|
twdroeger/ada-awa | Ada | 11,997 | ads | -----------------------------------------------------------------------
-- AWA.Jobs.Models -- AWA.Jobs.Models
-----------------------------------------------------------------------
-- File generated by ada-gen DO NOT MODIFY
-- Template used: templates/model/package-spec.xhtml
-- Ada Generator: https://ada-gen.googlecode.com/svn/trunk Revision 1095
-----------------------------------------------------------------------
-- Copyright (C) 2019 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
pragma Warnings (Off);
with ADO.Sessions;
with ADO.Objects;
with ADO.Statements;
with ADO.SQL;
with ADO.Schemas;
with Ada.Calendar;
with Ada.Containers.Vectors;
with Ada.Strings.Unbounded;
with Util.Beans.Objects;
with Util.Beans.Objects.Enums;
with Util.Beans.Basic.Lists;
with AWA.Events.Models;
with AWA.Users.Models;
pragma Warnings (On);
package AWA.Jobs.Models is
pragma Style_Checks ("-mr");
type Job_Status_Type is (SCHEDULED, RUNNING, CANCELED, FAILED, TERMINATED);
for Job_Status_Type use (SCHEDULED => 0, RUNNING => 1, CANCELED => 2, FAILED => 3, TERMINATED => 4);
package Job_Status_Type_Objects is
new Util.Beans.Objects.Enums (Job_Status_Type);
type Nullable_Job_Status_Type is record
Is_Null : Boolean := True;
Value : Job_Status_Type;
end record;
type Job_Ref is new ADO.Objects.Object_Ref with null record;
-- --------------------
-- The job is associated with a dispatching queue.
-- --------------------
-- Create an object key for Job.
function Job_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key;
-- Create an object key for Job from a string.
-- Raises Constraint_Error if the string cannot be converted into the object key.
function Job_Key (Id : in String) return ADO.Objects.Object_Key;
Null_Job : constant Job_Ref;
function "=" (Left, Right : Job_Ref'Class) return Boolean;
-- Set the job identifier
procedure Set_Id (Object : in out Job_Ref;
Value : in ADO.Identifier);
-- Get the job identifier
function Get_Id (Object : in Job_Ref)
return ADO.Identifier;
-- Set the job status
procedure Set_Status (Object : in out Job_Ref;
Value : in AWA.Jobs.Models.Job_Status_Type);
-- Get the job status
function Get_Status (Object : in Job_Ref)
return AWA.Jobs.Models.Job_Status_Type;
-- Set the job name
procedure Set_Name (Object : in out Job_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String);
procedure Set_Name (Object : in out Job_Ref;
Value : in String);
-- Get the job name
function Get_Name (Object : in Job_Ref)
return Ada.Strings.Unbounded.Unbounded_String;
function Get_Name (Object : in Job_Ref)
return String;
-- Set the job start date
procedure Set_Start_Date (Object : in out Job_Ref;
Value : in ADO.Nullable_Time);
-- Get the job start date
function Get_Start_Date (Object : in Job_Ref)
return ADO.Nullable_Time;
-- Set the job creation date
procedure Set_Create_Date (Object : in out Job_Ref;
Value : in Ada.Calendar.Time);
-- Get the job creation date
function Get_Create_Date (Object : in Job_Ref)
return Ada.Calendar.Time;
-- Set the job finish date
procedure Set_Finish_Date (Object : in out Job_Ref;
Value : in ADO.Nullable_Time);
-- Get the job finish date
function Get_Finish_Date (Object : in Job_Ref)
return ADO.Nullable_Time;
-- Set the job progress indicator
procedure Set_Progress (Object : in out Job_Ref;
Value : in Integer);
-- Get the job progress indicator
function Get_Progress (Object : in Job_Ref)
return Integer;
-- Set the job parameters
procedure Set_Parameters (Object : in out Job_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String);
procedure Set_Parameters (Object : in out Job_Ref;
Value : in String);
-- Get the job parameters
function Get_Parameters (Object : in Job_Ref)
return Ada.Strings.Unbounded.Unbounded_String;
function Get_Parameters (Object : in Job_Ref)
return String;
-- Set the job result
procedure Set_Results (Object : in out Job_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String);
procedure Set_Results (Object : in out Job_Ref;
Value : in String);
-- Get the job result
function Get_Results (Object : in Job_Ref)
return Ada.Strings.Unbounded.Unbounded_String;
function Get_Results (Object : in Job_Ref)
return String;
--
function Get_Version (Object : in Job_Ref)
return Integer;
-- Set the job priority
procedure Set_Priority (Object : in out Job_Ref;
Value : in Integer);
-- Get the job priority
function Get_Priority (Object : in Job_Ref)
return Integer;
--
procedure Set_User (Object : in out Job_Ref;
Value : in AWA.Users.Models.User_Ref'Class);
--
function Get_User (Object : in Job_Ref)
return AWA.Users.Models.User_Ref'Class;
--
procedure Set_Event (Object : in out Job_Ref;
Value : in AWA.Events.Models.Message_Ref'Class);
--
function Get_Event (Object : in Job_Ref)
return AWA.Events.Models.Message_Ref'Class;
--
procedure Set_Session (Object : in out Job_Ref;
Value : in AWA.Users.Models.Session_Ref'Class);
--
function Get_Session (Object : in Job_Ref)
return AWA.Users.Models.Session_Ref'Class;
-- Load the entity identified by 'Id'.
-- Raises the NOT_FOUND exception if it does not exist.
procedure Load (Object : in out Job_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier);
-- Load the entity identified by 'Id'.
-- Returns True in <b>Found</b> if the object was found and False if it does not exist.
procedure Load (Object : in out Job_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier;
Found : out Boolean);
-- Find and load the entity.
overriding
procedure Find (Object : in out Job_Ref;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean);
-- Save the entity. If the entity does not have an identifier, an identifier is allocated
-- and it is inserted in the table. Otherwise, only data fields which have been changed
-- are updated.
overriding
procedure Save (Object : in out Job_Ref;
Session : in out ADO.Sessions.Master_Session'Class);
-- Delete the entity.
overriding
procedure Delete (Object : in out Job_Ref;
Session : in out ADO.Sessions.Master_Session'Class);
overriding
function Get_Value (From : in Job_Ref;
Name : in String) return Util.Beans.Objects.Object;
-- Table definition
JOB_TABLE : constant ADO.Schemas.Class_Mapping_Access;
-- Internal method to allocate the Object_Record instance
overriding
procedure Allocate (Object : in out Job_Ref);
-- Copy of the object.
procedure Copy (Object : in Job_Ref;
Into : in out Job_Ref);
private
JOB_NAME : aliased constant String := "awa_job";
COL_0_1_NAME : aliased constant String := "id";
COL_1_1_NAME : aliased constant String := "status";
COL_2_1_NAME : aliased constant String := "name";
COL_3_1_NAME : aliased constant String := "start_date";
COL_4_1_NAME : aliased constant String := "create_date";
COL_5_1_NAME : aliased constant String := "finish_date";
COL_6_1_NAME : aliased constant String := "progress";
COL_7_1_NAME : aliased constant String := "parameters";
COL_8_1_NAME : aliased constant String := "results";
COL_9_1_NAME : aliased constant String := "version";
COL_10_1_NAME : aliased constant String := "priority";
COL_11_1_NAME : aliased constant String := "user_id";
COL_12_1_NAME : aliased constant String := "event_id";
COL_13_1_NAME : aliased constant String := "session_id";
JOB_DEF : aliased constant ADO.Schemas.Class_Mapping :=
(Count => 14,
Table => JOB_NAME'Access,
Members => (
1 => COL_0_1_NAME'Access,
2 => COL_1_1_NAME'Access,
3 => COL_2_1_NAME'Access,
4 => COL_3_1_NAME'Access,
5 => COL_4_1_NAME'Access,
6 => COL_5_1_NAME'Access,
7 => COL_6_1_NAME'Access,
8 => COL_7_1_NAME'Access,
9 => COL_8_1_NAME'Access,
10 => COL_9_1_NAME'Access,
11 => COL_10_1_NAME'Access,
12 => COL_11_1_NAME'Access,
13 => COL_12_1_NAME'Access,
14 => COL_13_1_NAME'Access)
);
JOB_TABLE : constant ADO.Schemas.Class_Mapping_Access
:= JOB_DEF'Access;
Null_Job : constant Job_Ref
:= Job_Ref'(ADO.Objects.Object_Ref with null record);
type Job_Impl is
new ADO.Objects.Object_Record (Key_Type => ADO.Objects.KEY_INTEGER,
Of_Class => JOB_DEF'Access)
with record
Status : AWA.Jobs.Models.Job_Status_Type;
Name : Ada.Strings.Unbounded.Unbounded_String;
Start_Date : ADO.Nullable_Time;
Create_Date : Ada.Calendar.Time;
Finish_Date : ADO.Nullable_Time;
Progress : Integer;
Parameters : Ada.Strings.Unbounded.Unbounded_String;
Results : Ada.Strings.Unbounded.Unbounded_String;
Version : Integer;
Priority : Integer;
User : AWA.Users.Models.User_Ref;
Event : AWA.Events.Models.Message_Ref;
Session : AWA.Users.Models.Session_Ref;
end record;
type Job_Access is access all Job_Impl;
overriding
procedure Destroy (Object : access Job_Impl);
overriding
procedure Find (Object : in out Job_Impl;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean);
overriding
procedure Load (Object : in out Job_Impl;
Session : in out ADO.Sessions.Session'Class);
procedure Load (Object : in out Job_Impl;
Stmt : in out ADO.Statements.Query_Statement'Class;
Session : in out ADO.Sessions.Session'Class);
overriding
procedure Save (Object : in out Job_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
procedure Create (Object : in out Job_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
overriding
procedure Delete (Object : in out Job_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
procedure Set_Field (Object : in out Job_Ref'Class;
Impl : out Job_Access);
end AWA.Jobs.Models;
|
reznikmm/matreshka | Ada | 3,777 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2013, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with ODF.Constants;
package body Matreshka.ODF_Attributes.Style.Country_Asian is
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Style_Country_Asian_Node)
return League.Strings.Universal_String is
begin
return ODF.Constants.Country_Asian_Name;
end Get_Local_Name;
end Matreshka.ODF_Attributes.Style.Country_Asian;
|
tum-ei-rcs/StratoX | Ada | 344 | ads | -- Project: MART - Modular Airborne Real-Time Testbed
-- System: Emergency Recovery System
-- Authors: Markus Neumair (Original C-Code)
-- Emanuel Regnath ([email protected]) (Ada Port)
--
-- Module Description:
-- @summary Top-level driver for the Barometer HMC5883L-01BA03
package HMC5883L with SPARK_Mode is
end HMC5883L;
|
optikos/oasis | Ada | 4,787 | ads | -- Copyright (c) 2019 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Program.Lexical_Elements;
with Program.Elements.Choice_Parameter_Specifications;
with Program.Element_Vectors;
with Program.Elements.Exception_Handlers;
with Program.Element_Visitors;
package Program.Nodes.Exception_Handlers is
pragma Preelaborate;
type Exception_Handler is
new Program.Nodes.Node
and Program.Elements.Exception_Handlers.Exception_Handler
and Program.Elements.Exception_Handlers.Exception_Handler_Text
with private;
function Create
(When_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Choice_Parameter : Program.Elements.Choice_Parameter_Specifications
.Choice_Parameter_Specification_Access;
Choices : not null Program.Element_Vectors.Element_Vector_Access;
Arrow_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Statements : not null Program.Element_Vectors.Element_Vector_Access)
return Exception_Handler;
type Implicit_Exception_Handler is
new Program.Nodes.Node
and Program.Elements.Exception_Handlers.Exception_Handler
with private;
function Create
(Choice_Parameter : Program.Elements.Choice_Parameter_Specifications
.Choice_Parameter_Specification_Access;
Choices : not null Program.Element_Vectors
.Element_Vector_Access;
Statements : not null Program.Element_Vectors
.Element_Vector_Access;
Is_Part_Of_Implicit : Boolean := False;
Is_Part_Of_Inherited : Boolean := False;
Is_Part_Of_Instance : Boolean := False)
return Implicit_Exception_Handler
with Pre =>
Is_Part_Of_Implicit or Is_Part_Of_Inherited or Is_Part_Of_Instance;
private
type Base_Exception_Handler is
abstract new Program.Nodes.Node
and Program.Elements.Exception_Handlers.Exception_Handler
with record
Choice_Parameter : Program.Elements.Choice_Parameter_Specifications
.Choice_Parameter_Specification_Access;
Choices : not null Program.Element_Vectors
.Element_Vector_Access;
Statements : not null Program.Element_Vectors
.Element_Vector_Access;
end record;
procedure Initialize (Self : aliased in out Base_Exception_Handler'Class);
overriding procedure Visit
(Self : not null access Base_Exception_Handler;
Visitor : in out Program.Element_Visitors.Element_Visitor'Class);
overriding function Choice_Parameter
(Self : Base_Exception_Handler)
return Program.Elements.Choice_Parameter_Specifications
.Choice_Parameter_Specification_Access;
overriding function Choices
(Self : Base_Exception_Handler)
return not null Program.Element_Vectors.Element_Vector_Access;
overriding function Statements
(Self : Base_Exception_Handler)
return not null Program.Element_Vectors.Element_Vector_Access;
overriding function Is_Exception_Handler_Element
(Self : Base_Exception_Handler)
return Boolean;
type Exception_Handler is
new Base_Exception_Handler
and Program.Elements.Exception_Handlers.Exception_Handler_Text
with record
When_Token : not null Program.Lexical_Elements.Lexical_Element_Access;
Arrow_Token : not null Program.Lexical_Elements.Lexical_Element_Access;
end record;
overriding function To_Exception_Handler_Text
(Self : aliased in out Exception_Handler)
return Program.Elements.Exception_Handlers.Exception_Handler_Text_Access;
overriding function When_Token
(Self : Exception_Handler)
return not null Program.Lexical_Elements.Lexical_Element_Access;
overriding function Arrow_Token
(Self : Exception_Handler)
return not null Program.Lexical_Elements.Lexical_Element_Access;
type Implicit_Exception_Handler is
new Base_Exception_Handler
with record
Is_Part_Of_Implicit : Boolean;
Is_Part_Of_Inherited : Boolean;
Is_Part_Of_Instance : Boolean;
end record;
overriding function To_Exception_Handler_Text
(Self : aliased in out Implicit_Exception_Handler)
return Program.Elements.Exception_Handlers.Exception_Handler_Text_Access;
overriding function Is_Part_Of_Implicit
(Self : Implicit_Exception_Handler)
return Boolean;
overriding function Is_Part_Of_Inherited
(Self : Implicit_Exception_Handler)
return Boolean;
overriding function Is_Part_Of_Instance
(Self : Implicit_Exception_Handler)
return Boolean;
end Program.Nodes.Exception_Handlers;
|
Heziode/lsystem-editor | Ada | 1,786 | adb | -------------------------------------------------------------------------------
-- LSE -- L-System Editor
-- Author: Heziode
--
-- License:
-- MIT License
--
-- Copyright (c) 2018 Quentin Dauprat (Heziode) <[email protected]>
--
-- Permission is hereby granted, free of charge, to any person obtaining a
-- copy of this software and associated documentation files (the "Software"),
-- to deal in the Software without restriction, including without limitation
-- the rights to use, copy, modify, merge, publish, distribute, sublicense,
-- and/or sell copies of the Software, and to permit persons to whom the
-- Software is furnished to do so, subject to the following conditions:
--
-- The above copyright notice and this permission notice shall be included in
-- all copies or substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-- DEALINGS IN THE SOFTWARE.
-------------------------------------------------------------------------------
with Ada.Text_IO;
package body LSE.Model.Grammar.Symbol is
function Get_Representation (This : Instance) return Character
is
begin
return This.Representation;
end Get_Representation;
procedure Put (This : Instance)
is
use Ada.Text_IO;
begin
Put_Line ("Representation: " & This.Representation);
end Put;
end LSE.Model.Grammar.Symbol;
|
reznikmm/matreshka | Ada | 4,647 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Presentation.Action_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Presentation_Action_Attribute_Node is
begin
return Self : Presentation_Action_Attribute_Node do
Matreshka.ODF_Presentation.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Presentation_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Presentation_Action_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Action_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Presentation_URI,
Matreshka.ODF_String_Constants.Action_Attribute,
Presentation_Action_Attribute_Node'Tag);
end Matreshka.ODF_Presentation.Action_Attributes;
|
aogrcs/etherscope | Ada | 5,790 | adb | -----------------------------------------------------------------------
-- etheroscope -- Ether Oscope main program
-- Copyright (C) 2016 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with System;
with Interfaces;
with Ada.Real_Time;
with STM32.Button;
with STM32.Board;
with STM32.RNG.Interrupts;
with STM32.Eth;
with STM32.SDRAM;
with HAL.Bitmap;
with Net;
with Net.Buffers;
with UI.Buttons;
with EtherScope.Display;
with EtherScope.Receiver;
with EtherScope.Stats;
-- The main EtherScope task must run at a lower priority as it takes care
-- of displaying results on the screen while the EtherScope receiver's task
-- waits for packets and analyzes them. All the hardware initialization must
-- be done here because STM32.SDRAM is not protected against concurrent accesses.
procedure Etheroscope with Priority => System.Priority'First is
use type Interfaces.Unsigned_32;
use type UI.Buttons.Button_Index;
use type Ada.Real_Time.Time;
use type Ada.Real_Time.Time_Span;
-- Reserve 32 network buffers.
NET_BUFFER_SIZE : constant Interfaces.Unsigned_32 := Net.Buffers.NET_ALLOC_SIZE * 32;
-- Display refresh period.
REFRESH_PERIOD : constant Ada.Real_Time.Time_Span := Ada.Real_Time.Milliseconds (500);
-- Display refresh deadline.
Refresh_Deadline : Ada.Real_Time.Time;
-- Current display mode.
Mode : UI.Buttons.Button_Event := EtherScope.Display.B_ETHER;
Button_Changed : Boolean := False;
-- Display the Ethernet graph (all traffic).
Graph_Mode : EtherScope.Stats.Graph_Kind := EtherScope.Stats.G_ETHERNET;
begin
STM32.RNG.Interrupts.Initialize_RNG;
STM32.Button.Initialize;
-- Initialize the display and draw the main/fixed frames in both buffers.
EtherScope.Display.Initialize;
EtherScope.Display.Draw_Frame (STM32.Board.Display.Get_Hidden_Buffer (1));
STM32.Board.Display.Update_Layer (1);
EtherScope.Display.Draw_Frame (STM32.Board.Display.Get_Hidden_Buffer (1));
-- Initialize the Ethernet driver.
STM32.Eth.Initialize_RMII;
-- Static IP interface, default netmask and no gateway.
-- (In fact, this is not really necessary for using the receiver in promiscus mode)
EtherScope.Receiver.Ifnet.Ip := (192, 168, 1, 1);
-- STMicroelectronics OUI = 00 81 E1
EtherScope.Receiver.Ifnet.Mac := (0, 16#81#, 16#E1#, 5, 5, 1);
-- Setup some receive buffers and initialize the Ethernet driver.
Net.Buffers.Add_Region (STM32.SDRAM.Reserve (Amount => NET_BUFFER_SIZE), NET_BUFFER_SIZE);
EtherScope.Receiver.Ifnet.Initialize;
Refresh_Deadline := Ada.Real_Time.Clock + REFRESH_PERIOD;
-- Loop to retrieve the analysis and display them.
loop
declare
Action : UI.Buttons.Button_Event;
Now : constant Ada.Real_Time.Time := Ada.Real_Time.Clock;
Buffer : constant HAL.Bitmap.Bitmap_Buffer'Class := STM32.Board.Display.Get_Hidden_Buffer (1);
begin
-- We updated the buttons in the previous layer and
-- we must update them in the second one.
if Button_Changed then
EtherScope.Display.Draw_Buttons (Buffer);
Button_Changed := False;
end if;
-- Check for a button being pressed.
UI.Buttons.Get_Event (Buffer => Buffer,
Touch => STM32.Board.Touch_Panel,
List => EtherScope.Display.Buttons,
Event => Action);
if Action /= UI.Buttons.NO_EVENT then
Mode := Action;
UI.Buttons.Set_Active (EtherScope.Display.Buttons, Action, Button_Changed);
-- Update the buttons in the first layer.
if Button_Changed then
EtherScope.Display.Draw_Buttons (Buffer);
end if;
end if;
-- Refresh the display only every 500 ms or when the display state is changed.
if Refresh_Deadline <= Now or Button_Changed then
case Mode is
when EtherScope.Display.B_ETHER =>
EtherScope.Display.Display_Devices (Buffer);
Graph_Mode := EtherScope.Stats.G_ETHERNET;
when EtherScope.Display.B_IPv4 =>
EtherScope.Display.Display_Protocols (Buffer);
Graph_Mode := EtherScope.Stats.G_ETHERNET;
when EtherScope.Display.B_IGMP =>
EtherScope.Display.Display_Groups (Buffer);
Graph_Mode := EtherScope.Stats.G_UDP;
when EtherScope.Display.B_TCP =>
EtherScope.Display.Display_TCP (Buffer);
Graph_Mode := EtherScope.Stats.G_TCP;
when others =>
null;
end case;
EtherScope.Display.Refresh_Graphs (Buffer, Graph_Mode);
EtherScope.Display.Display_Summary (Buffer);
STM32.Board.Display.Update_Layer (1);
Refresh_Deadline := Refresh_Deadline + REFRESH_PERIOD;
end if;
delay until Now + Ada.Real_Time.Milliseconds (100);
end;
end loop;
end Etheroscope;
|
kjseefried/coreland-cgbc | Ada | 2,207 | adb | with BHT_Support;
with Test;
procedure T_BHT_08 is
TC : Test.Context_t;
package BST4 renames BHT_Support.String_Tables4;
Called : Boolean;
Correct_Value : Boolean;
Correct_Key : Boolean;
Expected_Key : BHT_Support.Key_Type4 := "ZZZZ";
Exists : Boolean;
Expected_Value : constant Natural := 1;
Changed_Value : constant Natural := 13;
Inserted : Boolean;
procedure Process
(Key : in BHT_Support.Key_Type4;
Data : in out Natural) is
begin
Called := True;
Correct_Key := Key = Expected_Key;
Correct_Value := Data = Expected_Value;
Data := Changed_Value;
end Process;
procedure Modify is new BST4.Modify_Element (Process);
begin
Test.Initialize
(Test_Context => TC,
Program => "t_bht_08",
Test_DB => "TEST_DB",
Test_Results => "TEST_RESULTS");
BST4.Insert
(Container => BHT_Support.Map,
Key => BHT_Support.Keys (1),
Element => Expected_Value,
Inserted => Inserted);
pragma Assert (Inserted);
Called := False;
Modify
(Container => BHT_Support.Map,
Key => "BBBB",
Exists => Exists);
Test.Check
(Test_Context => TC,
Test => 24,
Condition => Called = False,
Statement => "Called = False");
Test.Check
(Test_Context => TC,
Test => 25,
Condition => Exists = False,
Statement => "Exists = False");
Correct_Value := False;
Correct_Key := False;
Expected_Key := BHT_Support.Keys (1);
Modify
(Container => BHT_Support.Map,
Key => BHT_Support.Keys (1),
Exists => Exists);
Test.Check
(Test_Context => TC,
Test => 26,
Condition => Called,
Statement => "Called");
Test.Check
(Test_Context => TC,
Test => 27,
Condition => Exists,
Statement => "Exists");
Test.Check
(Test_Context => TC,
Test => 28,
Condition => Correct_Key,
Statement => "Correct_Key");
Test.Check
(Test_Context => TC,
Test => 29,
Condition => Correct_Value,
Statement => "Correct_Value");
end T_BHT_08;
|
reznikmm/matreshka | Ada | 3,750 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- XML Processor --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2013, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Nodes;
package XML.DOM.Nodes.Character_Datas.Texts.Internals is
pragma Preelaborate;
function Create
(Node : Matreshka.DOM_Nodes.Text_Access)
return XML.DOM.Nodes.Character_Datas.Texts.DOM_Text;
function Wrap
(Node : Matreshka.DOM_Nodes.Text_Access)
return XML.DOM.Nodes.Character_Datas.Texts.DOM_Text;
end XML.DOM.Nodes.Character_Datas.Texts.Internals;
|
tum-ei-rcs/StratoX | Ada | 37 | ads | ../../../../software/lib/profiler.ads |
reznikmm/matreshka | Ada | 4,057 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with ODF.DOM.Text_Use_Chart_Objects_Attributes;
package Matreshka.ODF_Text.Use_Chart_Objects_Attributes is
type Text_Use_Chart_Objects_Attribute_Node is
new Matreshka.ODF_Text.Abstract_Text_Attribute_Node
and ODF.DOM.Text_Use_Chart_Objects_Attributes.ODF_Text_Use_Chart_Objects_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Text_Use_Chart_Objects_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Text_Use_Chart_Objects_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Text.Use_Chart_Objects_Attributes;
|
Rodeo-McCabe/orka | Ada | 3,502 | adb | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2017 onox <[email protected]>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
package body Orka.glTF.Meshes is
function Create_Primitive
(Object : Types.JSON_Value) return Primitive
is
Attributes : constant Types.JSON_Value := Object.Get ("attributes");
Indices : constant Long_Integer := Object.Get ("indices", Undefined).Value;
Material : constant Long_Integer := Object.Get ("material", Undefined).Value;
Mode : constant Long_Integer := Object.Get ("mode", 4).Value;
Mode_Kind : Primitive_Mode;
Attribute_Accessors : Attribute_Maps.Map;
begin
case Mode is
when 0 =>
Mode_Kind := GL.Types.Points;
when 1 =>
Mode_Kind := GL.Types.Lines;
when 2 =>
Mode_Kind := GL.Types.Line_Loop;
when 3 =>
Mode_Kind := GL.Types.Line_Strip;
when 4 =>
Mode_Kind := GL.Types.Triangles;
when 5 =>
Mode_Kind := GL.Types.Triangle_Strip;
when 6 =>
Mode_Kind := GL.Types.Triangle_Fan;
when others =>
raise Constraint_Error with "Invalid primitive.mode";
end case;
for Attribute of Attributes loop
Attribute_Accessors.Insert (Attribute.Value,
Natural (Long_Integer'(Attributes.Get (Attribute.Value).Value)));
end loop;
-- TODO primitive.indices: When defined, the accessor must contain
-- indices: the bufferView referenced by the accessor should have a
-- target equal to 34963 (ELEMENT_ARRAY_BUFFER); componentType must
-- be 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT) or 5125 (UNSIGNED_INT)
return Result : Primitive do
Result.Attributes := Attribute_Accessors;
Result.Indices := Natural_Optional (Indices);
Result.Material := Natural_Optional (Material);
Result.Mode := Mode_Kind;
end return;
end Create_Primitive;
function Create_Primitives
(Primitives : Types.JSON_Value) return Primitive_Vectors.Vector
is
Result : Primitive_Vectors.Vector (Capacity => Primitives.Length);
begin
for Primitive of Primitives loop
Result.Append (Create_Primitive (Primitive));
end loop;
return Result;
end Create_Primitives;
function Create_Mesh
(Object : Types.JSON_Value) return Mesh is
begin
return Result : Mesh do
Result.Primitives := Create_Primitives (Object.Get ("primitives"));
Result.Name := SU.To_Unbounded_String (Object.Get ("name").Value);
end return;
end Create_Mesh;
function Get_Meshes
(Meshes : Types.JSON_Value) return Mesh_Vectors.Vector
is
Result : Mesh_Vectors.Vector (Capacity => Meshes.Length);
begin
for Mesh of Meshes loop
Result.Append (Create_Mesh (Mesh));
end loop;
return Result;
end Get_Meshes;
end Orka.glTF.Meshes;
|
zhmu/ananas | Ada | 355 | adb | -- { dg-do compile }
-- { dg-options "-O2 -gnatn" }
package body Opt23 is
procedure Proc (Driver : Rec) is
R : Path;
begin
for I in Driver.Step'Range loop
R := Get (Driver, 1, Driver.Step (I));
R := Get (Driver, 2, Driver.Step (I));
R := Get (Driver, 3, Driver.Step (I));
end loop;
end;
end Opt23;
|
AdaCore/ada-traits-containers | Ada | 1,189 | ads | --
-- Copyright (C) 2015-2016, AdaCore
--
-- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
--
-- Unbounded controlled lists of unconstrained elements
pragma Ada_2012;
with Ada.Finalization;
with Conts.Elements.Indefinite;
with Conts.Lists.Generics;
with Conts.Lists.Storage.Unbounded;
generic
type Element_Type (<>) is private;
with procedure Free (E : in out Element_Type) is null;
package Conts.Lists.Indefinite_Unbounded is
pragma Assertion_Policy
(Pre => Suppressible, Ghost => Suppressible, Post => Ignore);
package Elements is new Conts.Elements.Indefinite
(Element_Type, Free => Free, Pool => Conts.Global_Pool);
package Storage is new Conts.Lists.Storage.Unbounded
(Elements => Elements.Traits,
Container_Base_Type => Ada.Finalization.Controlled,
Pool => Conts.Global_Pool);
package Lists is new Conts.Lists.Generics (Storage.Traits);
subtype Cursor is Lists.Cursor;
subtype List is Lists.List;
subtype Constant_Returned is Elements.Traits.Constant_Returned;
package Cursors renames Lists.Cursors;
package Maps renames Lists.Maps;
end Conts.Lists.Indefinite_Unbounded;
|
charlie5/lace | Ada | 1,364 | ads | with
ada.unchecked_Conversion;
package openGL.Culler.frustum
--
-- Provides a frustrum culler.
--
is
type Item is new Culler.Item with private;
type View is access all Item'Class;
---------
--- Forge
--
procedure define (Self : in out Item);
--------------
--- Attributes
--
overriding
procedure add (Self : in out Item; the_Visual : in Visual.view);
overriding
procedure rid (Self : in out Item; the_Visual : in Visual.view);
overriding
function object_Count (Self : in Item) return Natural;
overriding
function cull (Self : in Item; the_Visuals : in Visual.views;
camera_Frustum : in openGL.frustum.Plane_array;
camera_Site : in Vector_3) return Visual.views;
function vanish_point_size_Min (Self : in Item'Class) return Real;
procedure vanish_point_size_Min_is (Self : in out Item'Class; Now : in Real);
--
-- Visuals whose projected size falls below this minimum will not be displayed.
private
type Item is new Culler.item with
record
countDown : Natural := 0;
frame_Count : Natural := 0;
vanish_point_size_Min : safe_Real;
end record;
end openGL.Culler.frustum;
|
nerilex/ada-util | Ada | 6,372 | adb | -----------------------------------------------------------------------
-- Util.Concurrent.Fifos -- Concurrent Fifo Queues
-- Copyright (C) 2012, 2014, 2015 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Unchecked_Deallocation;
package body Util.Concurrent.Fifos is
-- ------------------------------
-- Put the element in the queue.
-- ------------------------------
procedure Enqueue (Into : in out Fifo;
Item : in Element_Type;
Wait : in Duration := FOREVER) is
begin
if Wait < 0.0 then
Into.Buffer.Enqueue (Item);
else
select
Into.Buffer.Enqueue (Item);
or
delay Wait;
raise Timeout;
end select;
end if;
end Enqueue;
-- ------------------------------
-- Get an element from the queue.
-- Wait until one element gets available.
-- ------------------------------
procedure Dequeue (From : in out Fifo;
Item : out Element_Type;
Wait : in Duration := FOREVER) is
begin
if Wait < 0.0 then
From.Buffer.Dequeue (Item);
else
select
From.Buffer.Dequeue (Item);
or
delay Wait;
raise Timeout;
end select;
end if;
end Dequeue;
-- ------------------------------
-- Get the number of elements in the queue.
-- ------------------------------
function Get_Count (From : in Fifo) return Natural is
begin
return From.Buffer.Get_Count;
end Get_Count;
-- ------------------------------
-- Set the queue size.
-- ------------------------------
procedure Set_Size (Into : in out Fifo;
Capacity : in Positive) is
begin
Into.Buffer.Set_Size (Capacity);
end Set_Size;
-- ------------------------------
-- Initializes the queue.
-- ------------------------------
overriding
procedure Initialize (Object : in out Fifo) is
begin
Object.Buffer.Set_Size (Default_Size);
end Initialize;
-- ------------------------------
-- Release the queue elements.
-- ------------------------------
overriding
procedure Finalize (Object : in out Fifo) is
begin
if Clear_On_Dequeue then
while Object.Get_Count > 0 loop
declare
Unused : Element_Type;
begin
Object.Dequeue (Unused);
end;
end loop;
end if;
Object.Buffer.Set_Size (0);
end Finalize;
-- Queue of objects.
protected body Protected_Fifo is
-- ------------------------------
-- Put the element in the queue.
-- If the queue is full, wait until some room is available.
-- ------------------------------
entry Enqueue (Item : in Element_Type) when Count < Elements'Length is
begin
Elements (Last) := Item;
Last := Last + 1;
if Last > Elements'Last then
if Clear_On_Dequeue then
Last := Elements'First + 1;
else
Last := Elements'First;
end if;
end if;
Count := Count + 1;
end Enqueue;
-- ------------------------------
-- Get an element from the queue.
-- Wait until one element gets available.
-- ------------------------------
entry Dequeue (Item : out Element_Type) when Count > 0 is
begin
Count := Count - 1;
Item := Elements (First);
-- For the clear on dequeue mode, erase the queue element.
-- If the element holds some storage or a reference, this gets cleared here.
-- The element used to clear is at index 0 (which does not exist if Clear_On_Dequeue
-- is false). There is no overhead when this is not used
-- (ie, instantiation/compile time flag).
if Clear_On_Dequeue then
Elements (First) := Elements (0);
end if;
First := First + 1;
if First > Elements'Last then
if Clear_On_Dequeue then
First := Elements'First + 1;
else
First := Elements'First;
end if;
end if;
end Dequeue;
-- ------------------------------
-- Get the number of elements in the queue.
-- ------------------------------
function Get_Count return Natural is
begin
return Count;
end Get_Count;
-- ------------------------------
-- Set the queue size.
-- ------------------------------
procedure Set_Size (Capacity : in Natural) is
procedure Free is new Ada.Unchecked_Deallocation (Element_Array, Element_Array_Access);
First_Pos : Natural := 1;
begin
if Clear_On_Dequeue then
First_Pos := 0;
end if;
if Capacity = 0 then
Free (Elements);
elsif Elements = null then
Elements := new Element_Array (First_Pos .. Capacity);
else
declare
New_Array : constant Element_Array_Access
:= new Element_Array (First_Pos .. Capacity);
begin
if Capacity > Elements'Length then
New_Array (First_Pos .. Elements'Last) := Elements (First_Pos .. Elements'Last);
else
New_Array (First_Pos .. Capacity) := Elements (First_Pos .. Capacity);
end if;
Free (Elements);
Elements := New_Array;
end;
end if;
end Set_Size;
end Protected_Fifo;
end Util.Concurrent.Fifos;
|
kontena/ruby-packer | Ada | 3,530 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding --
-- --
-- Terminal_Interface.Curses.Text_IO.Float_IO --
-- --
-- S P E C --
-- --
------------------------------------------------------------------------------
-- Copyright (c) 1998-2003,2009 Free Software Foundation, Inc. --
-- --
-- Permission is hereby granted, free of charge, to any person obtaining a --
-- copy of this software and associated documentation files (the --
-- "Software"), to deal in the Software without restriction, including --
-- without limitation the rights to use, copy, modify, merge, publish, --
-- distribute, distribute with modifications, sublicense, and/or sell --
-- copies of the Software, and to permit persons to whom the Software is --
-- furnished to do so, subject to the following conditions: --
-- --
-- The above copyright notice and this permission notice shall be included --
-- in all copies or substantial portions of the Software. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. --
-- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, --
-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR --
-- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR --
-- THE USE OR OTHER DEALINGS IN THE SOFTWARE. --
-- --
-- Except as contained in this notice, the name(s) of the above copyright --
-- holders shall not be used in advertising or otherwise to promote the --
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
------------------------------------------------------------------------------
-- Author: Juergen Pfeifer, 1996
-- Version Control:
-- $Revision: 1.12 $
-- Binding Version 01.00
------------------------------------------------------------------------------
generic
type Num is digits <>;
package Terminal_Interface.Curses.Text_IO.Float_IO is
Default_Fore : Field := 2;
Default_Aft : Field := Num'Digits - 1;
Default_Exp : Field := 3;
procedure Put
(Win : Window;
Item : Num;
Fore : Field := Default_Fore;
Aft : Field := Default_Aft;
Exp : Field := Default_Exp);
procedure Put
(Item : Num;
Fore : Field := Default_Fore;
Aft : Field := Default_Aft;
Exp : Field := Default_Exp);
private
pragma Inline (Put);
end Terminal_Interface.Curses.Text_IO.Float_IO;
|
AaronC98/PlaneSystem | Ada | 12,995 | adb | ------------------------------------------------------------------------------
-- Ada Web Server --
-- --
-- Copyright (C) 2002-2015, AdaCore --
-- --
-- This library is free software; you can redistribute it and/or modify --
-- it under terms of the GNU General Public License as published by the --
-- Free Software Foundation; either version 3, or (at your option) any --
-- later version. This library is distributed in the hope that it will be --
-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- --
-- --
-- --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- --
-- --
-- --
-- --
-- --
-- --
------------------------------------------------------------------------------
pragma Ada_2012;
with AWS.Containers.Memory_Streams;
with AWS.Default;
with AWS.Translator;
package body AWS.Net.Buffered is
CRLF : constant Stream_Element_Array :=
Translator.To_Stream_Element_Array (ASCII.CR & ASCII.LF);
Input_Limit : Positive := AWS.Default.Input_Line_Size_Limit with Atomic;
function Is_Empty
(C : not null access constant Read_Cache) return Boolean
is
(C.First > C.Last) with Inline_Always;
-- Returns true if the read-cache is empty
procedure Read (Socket : Socket_Type'Class)
with Pre => Socket.C.R_Cache /= null;
-- Refill the read-cache
function Get_Read_Cache
(Socket : Socket_Type'Class)
return not null access Read_Cache with Inline;
-- Get the socket read cache, create the cache if it is not created
function Get_Write_Cache
(Socket : Socket_Type'Class)
return not null access Write_Cache with Inline;
-- Get the socket write cache, create the cache if it is not created
-----------
-- Flush --
-----------
procedure Flush (Socket : Socket_Type'Class) is
C : Write_Cache_Access renames Socket.C.W_Cache;
begin
if C = null then
return;
end if;
if C.Last > 0 then
Send (Socket, C.Buffer (1 .. C.Last));
C.Last := 0;
end if;
end Flush;
--------------
-- Get_Char --
--------------
function Get_Char (Socket : Socket_Type'Class) return Character is
C : constant not null access Read_Cache := Get_Read_Cache (Socket);
Char : Character;
begin
if Is_Empty (C) then
Read (Socket);
end if;
Char := Character'Val (C.Buffer (C.First));
C.First := C.First + 1;
return Char;
end Get_Char;
---------------------
-- Get_Input_Limit --
---------------------
function Get_Input_Limit return Stream_Element_Offset is
begin
return Stream_Element_Offset (Input_Limit);
end Get_Input_Limit;
--------------
-- Get_Line --
--------------
function Get_Line (Socket : Socket_Type'Class) return String is
Line : constant String := Read_Until (Socket, "" & ASCII.LF, True);
begin
if Line'Length > 0 and then Line (Line'Last) = ASCII.LF then
if Line'Length > 1 and then Line (Line'Last - 1) = ASCII.CR then
return Line (Line'First .. Line'Last - 2);
else
return Line (Line'First .. Line'Last - 1);
end if;
else
return Line;
end if;
end Get_Line;
--------------------
-- Get_Read_Cache --
--------------------
function Get_Read_Cache
(Socket : Socket_Type'Class) return not null access Read_Cache is
begin
if Socket.C.R_Cache = null then
Socket.C.R_Cache := new Read_Cache (R_Cache_Size);
end if;
return Socket.C.R_Cache;
end Get_Read_Cache;
---------------------
-- Get_Write_Cache --
---------------------
function Get_Write_Cache
(Socket : Socket_Type'Class) return not null access Write_Cache is
begin
if Socket.C.W_Cache = null then
Socket.C.W_Cache := new Write_Cache (W_Cache_Size);
end if;
return Socket.C.W_Cache;
end Get_Write_Cache;
--------------
-- New_Line --
--------------
procedure New_Line (Socket : Socket_Type'Class) is
begin
Write (Socket, CRLF);
end New_Line;
---------------
-- Peek_Char --
---------------
function Peek_Char (Socket : Socket_Type'Class) return Character is
C : constant not null access Read_Cache := Get_Read_Cache (Socket);
begin
if Is_Empty (C) then
Read (Socket);
end if;
return Character'Val (Natural (C.Buffer (C.First)));
end Peek_Char;
---------
-- Put --
---------
procedure Put (Socket : Socket_Type'Class; Item : String) is
begin
Write (Socket, Translator.To_Stream_Element_Array (Item));
end Put;
--------------
-- Put_Line --
--------------
procedure Put_Line (Socket : Socket_Type'Class; Item : String) is
begin
Write (Socket, Translator.To_Stream_Element_Array (Item) & CRLF);
end Put_Line;
----------
-- Read --
----------
procedure Read (Socket : Socket_Type'Class) is
C : constant not null access Read_Cache := Socket.C.R_Cache;
begin
Receive (Socket, C.Buffer, C.Last);
-- Reset C.First only after successful Receive, the buffer would
-- remain empty on timeout this way.
C.First := C.Buffer'First;
end Read;
procedure Read
(Socket : Socket_Type'Class;
Data : out Stream_Element_Array;
Last : out Stream_Element_Offset)
is
C : constant not null access Read_Cache := Get_Read_Cache (Socket);
begin
Flush (Socket);
if Is_Empty (C) then
if Data'Length < C.Buffer'Length then
-- If Data fit in the cache, fill it
Read (Socket);
else
-- Otherwise read the socket directly
Receive (Socket, Data, Last);
return;
end if;
end if;
Read_Buffer (Socket, Data, Last);
-- Data could remain in internal socket buffer, if there is some
-- space on the buffer, read the socket.
if Last < Data'Last and then Pending (Socket) > 0 then
Receive (Socket, Data (Last + 1 .. Data'Last), Last);
end if;
end Read;
function Read
(Socket : Socket_Type'Class;
Max : Stream_Element_Count := 4096) return Stream_Element_Array
is
Buffer : Stream_Element_Array (1 .. Max);
Last : Stream_Element_Offset;
begin
Read (Socket, Buffer, Last);
return Buffer (1 .. Last);
end Read;
procedure Read
(Socket : Socket_Type'Class; Data : out Stream_Element_Array)
is
Last : Stream_Element_Offset;
First : Stream_Element_Offset := Data'First;
begin
loop
Read (Socket, Data (First .. Data'Last), Last);
exit when Last = Data'Last;
First := Last + 1;
end loop;
end Read;
-----------------
-- Read_Buffer --
-----------------
procedure Read_Buffer
(Socket : Socket_Type'Class;
Data : out Stream_Element_Array;
Last : out Stream_Element_Offset)
is
C : Read_Cache_Access renames Socket.C.R_Cache;
begin
if C = null then
Last := Last_Index (Data'First, Count => 0);
else
declare
C_Last : constant Stream_Element_Offset :=
Stream_Element_Offset'Min
(C.Last, C.First + Data'Length - 1);
begin
Last := Data'First + C_Last - C.First;
Data (Data'First .. Last) := C.Buffer (C.First .. C_Last);
C.First := C_Last + 1;
end;
end if;
end Read_Buffer;
----------------
-- Read_Until --
----------------
function Read_Until
(Socket : Socket_Type'Class;
Delimiter : Stream_Element_Array;
Wait : Boolean := True) return Stream_Element_Array
is
use Containers.Memory_Streams;
function Buffered return Stream_Element_Array with Inline;
procedure Finalize;
Finalizer : Utils.Finalizer (Finalize'Access) with Unreferenced;
Buffer : Stream_Type;
--------------
-- Buffered --
--------------
function Buffered return Stream_Element_Array is
Result : Stream_Element_Array (1 .. Size (Buffer));
Last : Stream_Element_Offset;
begin
Read (Buffer, Result, Last);
return Result;
end Buffered;
--------------
-- Finalize --
--------------
procedure Finalize is
begin
Close (Buffer);
end Finalize;
C : constant not null access Read_Cache := Get_Read_Cache (Socket);
J, K : Stream_Element_Offset;
begin
if Wait then
Flush (Socket);
end if;
J := C.First;
K := Delimiter'First;
loop
if J > C.Last then
if Wait then
Append (Buffer, C.Buffer (C.First .. C.Last));
if Size (Buffer) > Stream_Element_Offset (Input_Limit) then
raise Data_Overflow with
"Size" & Stream_Element_Offset'Image (Size (Buffer));
end if;
begin
Read (Socket);
exception
when E : Socket_Error =>
if Size (Buffer) = 0 or else Is_Timeout (Socket, E) then
raise;
else
C.First := 1;
C.Last := 0;
return Buffered;
end if;
end;
J := C.First;
else
return (1 .. 0 => 0);
end if;
end if;
if C.Buffer (J) = Delimiter (K) then
if K = Delimiter'Last then
K := C.First;
C.First := J + 1;
return Buffered & C.Buffer (K .. J);
else
K := K + 1;
end if;
J := J + 1;
elsif K = Delimiter'First then
J := J + 1;
else
K := Delimiter'First;
end if;
end loop;
end Read_Until;
function Read_Until
(Socket : Socket_Type'Class;
Delimiter : String;
Wait : Boolean := True) return String is
begin
return Translator.To_String
(Read_Until
(Socket, Translator.To_Stream_Element_Array (Delimiter), Wait));
end Read_Until;
---------------------
-- Set_Input_Limit --
---------------------
procedure Set_Input_Limit (Limit : Positive) is
begin
Input_Limit := Limit;
end Set_Input_Limit;
--------------
-- Shutdown --
--------------
procedure Shutdown (Socket : Socket_Type'Class) is
begin
begin
Flush (Socket);
exception
when Socket_Error =>
-- Ignore recent cache buffer send error
null;
end;
Net.Shutdown (Socket);
end Shutdown;
-----------
-- Write --
-----------
procedure Write
(Socket : Socket_Type'Class;
Item : Stream_Element_Array)
is
C : constant not null access Write_Cache :=
Get_Write_Cache (Socket);
Next_Last : constant Stream_Element_Offset := C.Last + Item'Length;
begin
if Next_Last > C.Max_Size then
Send (Socket, C.Buffer (1 .. C.Last));
Send (Socket, Item);
C.Last := 0;
else
C.Buffer (C.Last + 1 .. Next_Last) := Item;
C.Last := Next_Last;
end if;
end Write;
end AWS.Net.Buffered;
|
JeremyGrosser/Ada_Drivers_Library | Ada | 1,938 | ads | -- This package was generated by the Ada_Drivers_Library project wizard script
package ADL_Config is
Architecture : constant String := "ARM"; -- From board definition
Board : constant String := "STM32F769_Discovery"; -- From command line
CPU_Core : constant String := "ARM Cortex-M7F"; -- From mcu definition
Device_Family : constant String := "STM32F7"; -- From board definition
Device_Name : constant String := "STM32F769NIHx"; -- From board definition
Has_Ravenscar_Full_Runtime : constant String := "True"; -- From board definition
Has_Ravenscar_SFP_Runtime : constant String := "True"; -- From board definition
Has_ZFP_Runtime : constant String := "False"; -- From board definition
High_Speed_External_Clock : constant := 25000000; -- From board definition
Max_Mount_Name_Length : constant := 128; -- From default value
Max_Mount_Points : constant := 2; -- From default value
Max_Path_Length : constant := 1024; -- From default value
Number_Of_Interrupts : constant := 0; -- From default value
Runtime_Name : constant String := "ravenscar-sfp-stm32f769disco"; -- From default value
Runtime_Name_Suffix : constant String := "stm32f769disco"; -- From board definition
Runtime_Profile : constant String := "ravenscar-sfp"; -- From command line
Use_Startup_Gen : constant Boolean := False; -- From command line
Vendor : constant String := "STMicro"; -- From board definition
end ADL_Config;
|
damaki/libkeccak | Ada | 4,732 | adb | -------------------------------------------------------------------------------
-- Copyright (c) 2019, Daniel King
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
-- * Redistributions of source code must retain the above copyright
-- notice, this list of conditions and the following disclaimer.
-- * Redistributions in binary form must reproduce the above copyright
-- notice, this list of conditions and the following disclaimer in the
-- documentation and/or other materials provided with the distribution.
-- * The name of the copyright holder may not be used to endorse or promote
-- Products derived from this software without specific prior written
-- permission.
--
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
-- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-------------------------------------------------------------------------------
package body Keccak.Generic_Duplex
is
------------
-- Init --
------------
procedure Init (Ctx : out Context;
Capacity : in Positive)
is
begin
Init_State (Ctx.State);
Ctx.Rate := State_Size_Bits - Capacity;
end Init;
--------------
-- Duplex --
--------------
procedure Duplex (Ctx : in out Context;
In_Data : in Keccak.Types.Byte_Array;
In_Data_Bit_Length : in Natural;
Out_Data : out Keccak.Types.Byte_Array;
Out_Data_Bit_Length : in Natural)
is
Block : Keccak.Types.Byte_Array (0 .. (State_Size_Bits + 7) / 8 - 1) := (others => 0);
Num_Bytes : constant Natural := (In_Data_Bit_Length + 7) / 8;
begin
if Num_Bytes > 0 then
Block (0 .. Num_Bytes - 1)
:= In_Data (In_Data'First .. In_Data'First + (Num_Bytes - 1));
end if;
Pad (Block (0 .. ((Rate_Of (Ctx) + 7) / 8) - 1),
In_Data_Bit_Length,
Rate_Of (Ctx));
XOR_Bits_Into_State (Ctx.State,
Block (0 .. ((Ctx.Rate + 7) / 8) - 1),
Rate_Of (Ctx));
Permute (Ctx.State);
Extract_Bits (Ctx.State, Out_Data, Out_Data_Bit_Length);
end Duplex;
--------------------
-- Duplex_Blank --
--------------------
procedure Duplex_Blank (Ctx : in out Context;
Out_Data : out Keccak.Types.Byte_Array;
Out_Data_Bit_Length : in Natural)
is
Block : Keccak.Types.Byte_Array (0 .. (State_Size_Bits + 7) / 8 - 1) := (others => 0);
begin
Pad (Block (0 .. ((Rate_Of (Ctx) + 7) / 8) - 1),
0,
Rate_Of (Ctx));
XOR_Bits_Into_State (Ctx.State,
Block (0 .. ((Ctx.Rate + 7) / 8) - 1),
Rate_Of (Ctx));
Permute (Ctx.State);
Extract_Bits (Ctx.State, Out_Data, Out_Data_Bit_Length);
end Duplex_Blank;
-------------------
-- Duplex_Mute --
-------------------
procedure Duplex_Mute (Ctx : in out Context;
In_Data : in Keccak.Types.Byte_Array;
In_Data_Bit_Length : in Natural)
is
Block : Keccak.Types.Byte_Array (0 .. (State_Size_Bits + 7) / 8 - 1) := (others => 0);
Nb_Bytes : constant Natural := (In_Data_Bit_Length + 7) / 8;
begin
Block (0 .. Nb_Bytes - 1) :=
In_Data (In_Data'First .. In_Data'First + Nb_Bytes - 1);
Pad (Block (0 .. ((Rate_Of (Ctx) + 7) / 8) - 1),
In_Data_Bit_Length,
Rate_Of (Ctx));
XOR_Bits_Into_State (Ctx.State,
Block (0 .. ((Ctx.Rate + 7) / 8) - 1),
Rate_Of (Ctx));
Permute (Ctx.State);
end Duplex_Mute;
end Keccak.Generic_Duplex;
|
persan/AUnit-addons | Ada | 141 | ads | with AUnit.Test_Suites;
generic
with function Suite return AUnit.Test_Suites.Access_Test_Suite is <>;
procedure AUnit.Run.Generic_Runner;
|
AdaCore/libadalang | Ada | 116 | adb | package body Vectors is
procedure Clear (V : in out Vector) is
begin
null;
end Clear;
end Vectors;
|
reznikmm/matreshka | Ada | 3,774 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Attributes;
package ODF.DOM.Draw_Handle_Range_X_Minimum_Attributes is
pragma Preelaborate;
type ODF_Draw_Handle_Range_X_Minimum_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Draw_Handle_Range_X_Minimum_Attribute_Access is
access all ODF_Draw_Handle_Range_X_Minimum_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Draw_Handle_Range_X_Minimum_Attributes;
|
skordal/cupcake | Ada | 7,437 | adb | -- The Cupcake GUI Toolkit
-- (c) Kristian Klomsten Skordal 2012 <[email protected]>
-- Report bugs and issues on <http://github.com/skordal/cupcake/issues>
-- vim:ts=3:sw=3:et:si:sta
with Ada.Text_IO;
with Interfaces.C.Strings;
package body Cupcake.Backends.Cairo is
-- Procedure settings the current color, used by several subprograms below:
procedure Backend_Set_Color (Window_Data : in Backends.Window_Data_Pointer;
R, G, B : in Colors.Color_Component_Type);
pragma Import (C, Backend_Set_Color);
-- Gets the name of the backend:
function Get_Name (This : in Cairo_Backend) return String is
pragma Unreferenced (This);
begin
return "cairo";
end Get_Name;
-- Initializes the backend:
procedure Initialize (This : in out Cairo_Backend) is
function Backend_Initialize return Integer;
pragma Import (C, Backend_Initialize);
begin
if Backend_Initialize /= 1 then
raise Initialization_Error;
end if;
This.Initialized := True;
end Initialize;
-- Checks if the backend has been initialized:
function Is_Initialized (This : in Cairo_Backend) return Boolean is
begin
return This.Initialized;
end Is_Initialized;
-- Finalizes the backend:
procedure Finalize (This : in out Cairo_Backend) is
procedure Backend_Finalize;
pragma Import (C, Backend_Finalize);
begin
if This.Initialized then
Backend_Finalize;
This.Initialized := False;
elsif Debug_Mode then
Ada.Text_IO.Put_Line (
"[Cupcake.Backends.Cairo.Cairo_Backend.Finalize] "
& "Cannot finalize an uninitialized backend!");
end if;
end Finalize;
-- Enters the main loop:
procedure Enter_Main_Loop (This : in out Cairo_Backend) is
pragma Unreferenced (This);
procedure Backend_Main_Loop;
pragma Import (C, Backend_Main_Loop);
begin
Backend_Main_Loop;
end Enter_Main_Loop;
-- Exits the main loop:
procedure Exit_Main_Loop (This : in out Cairo_Backend) is
pragma Unreferenced (This);
procedure Backend_Main_Loop_Terminate;
pragma Import (C, Backend_Main_Loop_Terminate);
begin
Backend_Main_Loop_Terminate;
end Exit_Main_Loop;
-- Creates a new window:
function New_Window (This : in Cairo_Backend; Title : in String;
Size : in Primitives.Dimension;
Position : in Primitives.Point := (0, 0);
Parent : in Window_Data_Pointer := Null_Window_Data_Pointer)
return Window_Data_Pointer
is
use type Cupcake.Primitives.Point;
function Backend_Window_Create (
Parent : in Window_Data_Pointer;
Width, Height : in Positive) return Window_Data_Pointer;
pragma Import (C, Backend_Window_Create);
Retval : constant Window_Data_Pointer := Backend_Window_Create (
Parent, Size.Width, Size.Height);
begin
if Debug_Mode and then Position /= (0, 0) then
Ada.Text_IO.Put_Line (
"[Cupcake.Backends.Cairo.Cairo_Backend.New_Window] "
& "The position argument is currently ignored.");
end if;
This.Set_Window_Title (Retval, Title);
return Retval;
end New_Window;
-- Destroys a window:
procedure Destroy_Window (This : in out Cairo_Backend;
Window_Data : in out Window_Data_Pointer)
is
pragma Unreferenced (This);
procedure Backend_Window_Finalize (Window : in out Window_Data_Pointer);
pragma Import (C, Backend_Window_Finalize);
begin
Backend_Window_Finalize (Window_Data);
end Destroy_Window;
-- Gets the ID for a window:
function Get_Window_ID (This : in Cairo_Backend;
Window_Data : in Backends.Window_Data_Pointer)
return Backends.Window_ID_Type
is
pragma Unreferenced (This);
function Backend_Window_Get_ID (Window_Data : in Window_Data_Pointer)
return Backends.Window_ID_Type;
pragma Import (C, Backend_Window_Get_ID);
begin
return Backend_Window_Get_ID (Window_Data);
end Get_Window_ID;
-- Sets the title of a window:
procedure Set_Window_Title (This : in Cairo_Backend;
Window_Data : in Window_Data_Pointer;
Title : in String)
is
use Interfaces.C.Strings;
pragma Unreferenced (This);
procedure Backend_Window_Set_Title (Window_Data : in Window_Data_Pointer;
Title : in chars_ptr);
pragma Import (C, Backend_Window_Set_Title);
C_Title : chars_ptr := New_String (Title);
begin
Backend_Window_Set_Title (Window_Data, C_Title);
Free (C_Title);
end Set_Window_Title;
-- Sets the size of a window:
procedure Set_Window_Size (This : in Cairo_Backend;
Window_Data : in Window_Data_Pointer;
Size : in Primitives.Dimension) is
begin
Ada.Text_IO.Put_Line (
"[Cupcake.Backends.Cairo.Cairo_Backend.Set_Window_Size]"
& "This procedure has not yet been implemented in this backend");
end Set_Window_Size;
-- Sets the window visibility:
procedure Set_Window_Visibility (This : in Cairo_Backend;
Window_Data : in Window_Data_Pointer;
Visibility : in Boolean)
is
pragma Unreferenced (This);
procedure Backend_Window_Show (Window_Data : in Window_Data_Pointer);
pragma Import (C, Backend_Window_Show);
procedure Backend_Window_Close (Window_Data : in Window_Data_Pointer);
pragma Import (C, Backend_Window_Close);
begin
if Visibility then
Backend_Window_Show (Window_Data);
else
Backend_Window_Close (Window_Data);
end if;
end Set_Window_Visibility;
-- Draws a line:
procedure Draw_Line (This : in out Cairo_Backend;
Window_Data : in Window_Data_Pointer;
Origin, Destination : in Primitives.Point;
Color : in Colors.Color := Colors.BLACK;
Line_Width : in Float := 1.0)
is
pragma Unreferenced (This);
procedure Backend_Draw_Line (Window_Data : in Window_Data_Pointer;
X1, Y1, X2, Y2 : in Natural; Line_Width : in Float);
pragma Import (C, Backend_Draw_Line);
begin
Backend_Set_Color (Window_Data, Color.R, Color.G, Color.B);
Backend_Draw_Line (Window_Data, Origin.X, Origin.Y,
Destination.X, Destination.Y, Line_Width);
end Draw_Line;
-- Draws a circle:
procedure Draw_Circle (This : in out Cairo_Backend;
Window_Data : in Window_Data_Pointer;
Origin : in Primitives.Point;
Radius : in Float; Arc : in Float := 2.0 * Pi;
Color : in Colors.Color := Colors.BLACK; Line_Width : in Float := 1.0) is
pragma Unreferenced (This);
begin
Ada.Text_IO.Put_Line (
"[Cupcake.Backends.Cairo.Cairo_Backend.Draw_Circle] "
& "Not implemented!");
end Draw_Circle;
-- Fills an area:
procedure Fill_Area (This : in out Cairo_Backend;
Window_Data : in Window_Data_Pointer;
Area : in Primitives.Rectangle;
Color : in Colors.Color)
is
pragma Unreferenced (This);
procedure Backend_Fill_Rectangle (Window_Data : in Window_Data_Pointer;
X, Y, W, H : in Natural);
pragma Import (C, Backend_Fill_Rectangle);
begin
Backend_Set_Color (Window_Data, Color.R, Color.G, Color.B);
Backend_Fill_Rectangle (Window_Data, Area.Origin.X, Area.Origin.Y,
Area.Size.Width, Area.Size.Height);
end Fill_Area;
end Cupcake.Backends.Cairo;
|
zhmu/ananas | Ada | 6,297 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME LIBRARY COMPONENTS --
-- --
-- S Y S T E M . C O M P A R E _ A R R A Y _ S I G N E D _ 8 --
-- --
-- B o d y --
-- --
-- Copyright (C) 2002-2022, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with System.Address_Operations; use System.Address_Operations;
with Ada.Unchecked_Conversion;
package body System.Compare_Array_Signed_8 is
type Word is mod 2 ** 32;
-- Used to process operands by words
type Big_Words is array (Natural) of Word;
type Big_Words_Ptr is access Big_Words;
for Big_Words_Ptr'Storage_Size use 0;
-- Array type used to access by words
type Byte is range -128 .. +127;
for Byte'Size use 8;
-- Used to process operands by bytes
type Big_Bytes is array (Natural) of Byte;
type Big_Bytes_Ptr is access Big_Bytes;
for Big_Bytes_Ptr'Storage_Size use 0;
-- Array type used to access by bytes
function To_Big_Words is new
Ada.Unchecked_Conversion (System.Address, Big_Words_Ptr);
function To_Big_Bytes is new
Ada.Unchecked_Conversion (System.Address, Big_Bytes_Ptr);
----------------------
-- Compare_Array_S8 --
----------------------
function Compare_Array_S8
(Left : System.Address;
Right : System.Address;
Left_Len : Natural;
Right_Len : Natural) return Integer
is
Compare_Len : constant Natural := Natural'Min (Left_Len, Right_Len);
begin
-- If operands are non-aligned, or length is too short, go by bytes
if ModA (OrA (Left, Right), 4) /= 0 or else Compare_Len < 4 then
return Compare_Array_S8_Unaligned (Left, Right, Left_Len, Right_Len);
end if;
-- Here we can go by words
declare
LeftP : constant Big_Words_Ptr :=
To_Big_Words (Left);
RightP : constant Big_Words_Ptr :=
To_Big_Words (Right);
Words_To_Compare : constant Natural := Compare_Len / 4;
Bytes_Compared_As_Words : constant Natural := Words_To_Compare * 4;
begin
for J in 0 .. Words_To_Compare - 1 loop
if LeftP (J) /= RightP (J) then
return Compare_Array_S8_Unaligned
(AddA (Left, Address (4 * J)),
AddA (Right, Address (4 * J)),
4, 4);
end if;
end loop;
pragma Assert (Left_Len >= Bytes_Compared_As_Words);
pragma Assert (Right_Len >= Bytes_Compared_As_Words);
-- Left_Len and Right_Len are always greater or equal to
-- Bytes_Compared_As_Words because:
-- * Compare_Len is min (Left_Len, Right_Len)
-- * Words_To_Compare = Compare_Len / 4
-- * Bytes_Compared_As_Words = Words_To_Compare * 4
return Compare_Array_S8_Unaligned
(AddA (Left, Address (Bytes_Compared_As_Words)),
AddA (Right, Address (Bytes_Compared_As_Words)),
Left_Len - Bytes_Compared_As_Words,
Right_Len - Bytes_Compared_As_Words);
end;
end Compare_Array_S8;
--------------------------------
-- Compare_Array_S8_Unaligned --
--------------------------------
function Compare_Array_S8_Unaligned
(Left : System.Address;
Right : System.Address;
Left_Len : Natural;
Right_Len : Natural) return Integer
is
Compare_Len : constant Natural := Natural'Min (Left_Len, Right_Len);
LeftP : constant Big_Bytes_Ptr := To_Big_Bytes (Left);
RightP : constant Big_Bytes_Ptr := To_Big_Bytes (Right);
begin
for J in 0 .. Compare_Len - 1 loop
if LeftP (J) /= RightP (J) then
if LeftP (J) > RightP (J) then
return +1;
else
return -1;
end if;
end if;
end loop;
if Left_Len = Right_Len then
return 0;
elsif Left_Len > Right_Len then
return +1;
else
return -1;
end if;
end Compare_Array_S8_Unaligned;
end System.Compare_Array_Signed_8;
|
kqr/qweyboard | Ada | 1,722 | ads | with Unicode_Strings; use Unicode_Strings;
with Ada.Containers.Ordered_Sets;
package Qweyboard is
use Unbounded;
-- Letter keys declared in the order they're likely to appear in words
--
-- Quoted from patent, although not strictly followed here...
--
-- > For example, in English, the initial consonants of the syllable are
-- > ordered according to the following priority scheme or rule: "X, Z, S, B,
-- > P, G, QU, Q, C, D, T, V, W, F, J, H, K, L, M, R, N". The final consonants
-- > are sorted according to the following priority rules: "V, L, M, R, W, N,
-- > G, K, C, X, B, P, H, D, S, E, F, T, Y, Z", where the E is meant as a final
-- > mute "E" at the end of word
type Softkey is
(LZ, LS, LF, LC, LT, LP, LR, LJ, LK, LL, LN,
LE, LO, LI, MY, MA, MU, MAPO, RO, RI, RE,
RN, RL, RK, RJ, RR, RP, RT, RC, RF, RS, RZ,
-- Special keys that exist on the real hardware
MSHI, CAPI, NOSP,
-- Special keys we want (backspace, suspend and "no modifier pressed")
SUSP, NOKEY);
package Key_Sets is new Ada.Containers.Ordered_Sets (Element_Type => Softkey);
type Key_Event_Variant_Type is (Key_Press, Key_Release);
type Key_Event is record
Key : Softkey;
Key_Event_Variant : Key_Event_Variant_Type;
end record;
type Output_Variant is (Nothing, Syllable, Erase);
type Output (Variant : Output_Variant := Nothing) is record
case Variant is
when Nothing =>
null;
when Syllable =>
Text : Unbounded_Wide_Wide_String;
Continues_Word : Boolean;
when Erase =>
Amount : Positive;
end case;
end record;
end Qweyboard;
|
reznikmm/matreshka | Ada | 6,049 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2010-2015, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Ada.Streams;
with League;
with Matreshka.Atomics.Counters;
package Matreshka.Internals.Stream_Element_Vectors is
pragma Preelaborate;
use type Ada.Streams.Stream_Element_Offset;
type Shared_Stream_Element_Vector
(Size : Ada.Streams.Stream_Element_Offset) is limited
record
Counter : Matreshka.Atomics.Counters.Counter;
Length : Ada.Streams.Stream_Element_Offset := 0;
Value : Ada.Streams.Stream_Element_Array (0 .. Size);
end record;
type Shared_Stream_Element_Vector_Access is
access all Shared_Stream_Element_Vector;
Empty_Shared_Stream_Element_Vector :
aliased Shared_Stream_Element_Vector (-1);
procedure Reference (Item : Shared_Stream_Element_Vector_Access);
pragma Inline (Reference);
-- Increment reference counter. Change of reference counter of
-- Empty_Shared_Stream_Element_Vector object is prevented to provide
-- speedup and to allow to use it to initialize components of
-- Preelaborateable_Initialization types.
procedure Dereference (Item : in out Shared_Stream_Element_Vector_Access);
-- Decrement reference counter and free resources if it reach zero value.
-- Self is setted to null. Decrement of reference counter and deallocation
-- of Empty_Shared_Stream_Element_Vector object is prevented to provide
-- minor speedup and to allow use it to initialize components of
-- Preelaborateable_Initialization types.
function Allocate
(Size : Ada.Streams.Stream_Element_Offset)
return not null Shared_Stream_Element_Vector_Access;
-- Allocates new instance of stream element vector with specified size.
-- Actual size of the allocated object can be greater. Returns reference to
-- Empty_Shared_Stream_Element_Vector when Size is zero.
function Can_Be_Reused
(Self : not null Shared_Stream_Element_Vector_Access;
Size : Ada.Streams.Stream_Element_Offset) return Boolean
with Inline;
-- Returns True when specified shared stream element vecotr can be reused
-- safely. There are two criteria: reference counter must be one (it means
-- this object is not used anywhere); and size of the object is sufficient
-- to store at least specified amount of stream elements.
procedure Fill_Tail (Item : not null Shared_Stream_Element_Vector_Access);
-- Fill tail of internal array by zero elements to align data for 32-bits.
-- This is needed to compute reliable Hash value.
function Hash
(Item : not null Shared_Stream_Element_Vector_Access) return League.Hash_Type;
-- Returns hash value for the vector. MurmurHash2, by Austin Appleby is
-- used.
end Matreshka.Internals.Stream_Element_Vectors;
|
godunko/adawebpack | Ada | 2,970 | ads | ------------------------------------------------------------------------------
-- --
-- AdaWebPack --
-- --
------------------------------------------------------------------------------
-- Copyright © 2021, Vadim Godunko --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
------------------------------------------------------------------------------
with Web.HTML.Elements;
with Web.Strings;
package Web.HTML.Spans is
pragma Preelaborate;
type HTML_Span_Element is
new Web.HTML.Elements.HTML_Element with null record;
end Web.HTML.Spans;
|
docandrew/troodon | Ada | 11,448 | ads | pragma Ada_2012;
pragma Style_Checks (Off);
with Interfaces.C; use Interfaces.C;
with xcb;
with bits_stdint_uintn_h;
with xproto;
with xcb_xfixes;
with System;
package xcb_damage is
XCB_DAMAGE_MAJOR_VERSION : constant := 1; -- /usr/include/xcb/damage.h:23
XCB_DAMAGE_MINOR_VERSION : constant := 1; -- /usr/include/xcb/damage.h:24
XCB_DAMAGE_BAD_DAMAGE : constant := 0; -- /usr/include/xcb/damage.h:47
CONST_XCB_DAMAGE_QUERY_VERSION : constant := 0; -- /usr/include/xcb/damage.h:66
CONST_XCB_DAMAGE_CREATE : constant := 1; -- /usr/include/xcb/damage.h:93
CONST_XCB_DAMAGE_DESTROY : constant := 2; -- /usr/include/xcb/damage.h:109
CONST_XCB_DAMAGE_SUBTRACT : constant := 3; -- /usr/include/xcb/damage.h:122
CONST_XCB_DAMAGE_ADD : constant := 4; -- /usr/include/xcb/damage.h:137
XCB_DAMAGE_NOTIFY : constant := 0; -- /usr/include/xcb/damage.h:151
xcb_damage_id : aliased xcb.xcb_extension_t -- /usr/include/xcb/damage.h:26
with Import => True,
Convention => C,
External_Name => "xcb_damage_id";
subtype xcb_damage_damage_t is bits_stdint_uintn_h.uint32_t; -- /usr/include/xcb/damage.h:28
type xcb_damage_damage_iterator_t is record
data : access xcb_damage_damage_t; -- /usr/include/xcb/damage.h:34
c_rem : aliased int; -- /usr/include/xcb/damage.h:35
index : aliased int; -- /usr/include/xcb/damage.h:36
end record
with Convention => C_Pass_By_Copy; -- /usr/include/xcb/damage.h:33
type xcb_damage_report_level_t is
(XCB_DAMAGE_REPORT_LEVEL_RAW_RECTANGLES,
XCB_DAMAGE_REPORT_LEVEL_DELTA_RECTANGLES,
XCB_DAMAGE_REPORT_LEVEL_BOUNDING_BOX,
XCB_DAMAGE_REPORT_LEVEL_NON_EMPTY)
with Convention => C; -- /usr/include/xcb/damage.h:39
type xcb_damage_bad_damage_error_t is record
response_type : aliased bits_stdint_uintn_h.uint8_t; -- /usr/include/xcb/damage.h:53
error_code : aliased bits_stdint_uintn_h.uint8_t; -- /usr/include/xcb/damage.h:54
sequence : aliased bits_stdint_uintn_h.uint16_t; -- /usr/include/xcb/damage.h:55
end record
with Convention => C_Pass_By_Copy; -- /usr/include/xcb/damage.h:52
type xcb_damage_query_version_cookie_t is record
sequence : aliased unsigned; -- /usr/include/xcb/damage.h:62
end record
with Convention => C_Pass_By_Copy; -- /usr/include/xcb/damage.h:61
type xcb_damage_query_version_request_t is record
major_opcode : aliased bits_stdint_uintn_h.uint8_t; -- /usr/include/xcb/damage.h:72
minor_opcode : aliased bits_stdint_uintn_h.uint8_t; -- /usr/include/xcb/damage.h:73
length : aliased bits_stdint_uintn_h.uint16_t; -- /usr/include/xcb/damage.h:74
client_major_version : aliased bits_stdint_uintn_h.uint32_t; -- /usr/include/xcb/damage.h:75
client_minor_version : aliased bits_stdint_uintn_h.uint32_t; -- /usr/include/xcb/damage.h:76
end record
with Convention => C_Pass_By_Copy; -- /usr/include/xcb/damage.h:71
type xcb_damage_query_version_reply_t_array4341 is array (0 .. 15) of aliased bits_stdint_uintn_h.uint8_t;
type xcb_damage_query_version_reply_t is record
response_type : aliased bits_stdint_uintn_h.uint8_t; -- /usr/include/xcb/damage.h:83
pad0 : aliased bits_stdint_uintn_h.uint8_t; -- /usr/include/xcb/damage.h:84
sequence : aliased bits_stdint_uintn_h.uint16_t; -- /usr/include/xcb/damage.h:85
length : aliased bits_stdint_uintn_h.uint32_t; -- /usr/include/xcb/damage.h:86
major_version : aliased bits_stdint_uintn_h.uint32_t; -- /usr/include/xcb/damage.h:87
minor_version : aliased bits_stdint_uintn_h.uint32_t; -- /usr/include/xcb/damage.h:88
pad1 : aliased xcb_damage_query_version_reply_t_array4341; -- /usr/include/xcb/damage.h:89
end record
with Convention => C_Pass_By_Copy; -- /usr/include/xcb/damage.h:82
type xcb_damage_create_request_t_array1885 is array (0 .. 2) of aliased bits_stdint_uintn_h.uint8_t;
type xcb_damage_create_request_t is record
major_opcode : aliased bits_stdint_uintn_h.uint8_t; -- /usr/include/xcb/damage.h:99
minor_opcode : aliased bits_stdint_uintn_h.uint8_t; -- /usr/include/xcb/damage.h:100
length : aliased bits_stdint_uintn_h.uint16_t; -- /usr/include/xcb/damage.h:101
damage : aliased xcb_damage_damage_t; -- /usr/include/xcb/damage.h:102
drawable : aliased xproto.xcb_drawable_t; -- /usr/include/xcb/damage.h:103
level : aliased bits_stdint_uintn_h.uint8_t; -- /usr/include/xcb/damage.h:104
pad0 : aliased xcb_damage_create_request_t_array1885; -- /usr/include/xcb/damage.h:105
end record
with Convention => C_Pass_By_Copy; -- /usr/include/xcb/damage.h:98
type xcb_damage_destroy_request_t is record
major_opcode : aliased bits_stdint_uintn_h.uint8_t; -- /usr/include/xcb/damage.h:115
minor_opcode : aliased bits_stdint_uintn_h.uint8_t; -- /usr/include/xcb/damage.h:116
length : aliased bits_stdint_uintn_h.uint16_t; -- /usr/include/xcb/damage.h:117
damage : aliased xcb_damage_damage_t; -- /usr/include/xcb/damage.h:118
end record
with Convention => C_Pass_By_Copy; -- /usr/include/xcb/damage.h:114
type xcb_damage_subtract_request_t is record
major_opcode : aliased bits_stdint_uintn_h.uint8_t; -- /usr/include/xcb/damage.h:128
minor_opcode : aliased bits_stdint_uintn_h.uint8_t; -- /usr/include/xcb/damage.h:129
length : aliased bits_stdint_uintn_h.uint16_t; -- /usr/include/xcb/damage.h:130
damage : aliased xcb_damage_damage_t; -- /usr/include/xcb/damage.h:131
repair : aliased xcb_xfixes.xcb_xfixes_region_t; -- /usr/include/xcb/damage.h:132
parts : aliased xcb_xfixes.xcb_xfixes_region_t; -- /usr/include/xcb/damage.h:133
end record
with Convention => C_Pass_By_Copy; -- /usr/include/xcb/damage.h:127
type xcb_damage_add_request_t is record
major_opcode : aliased bits_stdint_uintn_h.uint8_t; -- /usr/include/xcb/damage.h:143
minor_opcode : aliased bits_stdint_uintn_h.uint8_t; -- /usr/include/xcb/damage.h:144
length : aliased bits_stdint_uintn_h.uint16_t; -- /usr/include/xcb/damage.h:145
drawable : aliased xproto.xcb_drawable_t; -- /usr/include/xcb/damage.h:146
region : aliased xcb_xfixes.xcb_xfixes_region_t; -- /usr/include/xcb/damage.h:147
end record
with Convention => C_Pass_By_Copy; -- /usr/include/xcb/damage.h:142
type xcb_damage_notify_event_t is record
response_type : aliased bits_stdint_uintn_h.uint8_t; -- /usr/include/xcb/damage.h:157
level : aliased bits_stdint_uintn_h.uint8_t; -- /usr/include/xcb/damage.h:158
sequence : aliased bits_stdint_uintn_h.uint16_t; -- /usr/include/xcb/damage.h:159
drawable : aliased xproto.xcb_drawable_t; -- /usr/include/xcb/damage.h:160
damage : aliased xcb_damage_damage_t; -- /usr/include/xcb/damage.h:161
timestamp : aliased xproto.xcb_timestamp_t; -- /usr/include/xcb/damage.h:162
area : aliased xproto.xcb_rectangle_t; -- /usr/include/xcb/damage.h:163
geometry : aliased xproto.xcb_rectangle_t; -- /usr/include/xcb/damage.h:164
end record
with Convention => C_Pass_By_Copy; -- /usr/include/xcb/damage.h:156
procedure xcb_damage_damage_next (i : access xcb_damage_damage_iterator_t) -- /usr/include/xcb/damage.h:176
with Import => True,
Convention => C,
External_Name => "xcb_damage_damage_next";
function xcb_damage_damage_end (i : xcb_damage_damage_iterator_t) return xcb.xcb_generic_iterator_t -- /usr/include/xcb/damage.h:188
with Import => True,
Convention => C,
External_Name => "xcb_damage_damage_end";
function xcb_damage_query_version
(c : access xcb.xcb_connection_t;
client_major_version : bits_stdint_uintn_h.uint32_t;
client_minor_version : bits_stdint_uintn_h.uint32_t) return xcb_damage_query_version_cookie_t -- /usr/include/xcb/damage.h:199
with Import => True,
Convention => C,
External_Name => "xcb_damage_query_version";
function xcb_damage_query_version_unchecked
(c : access xcb.xcb_connection_t;
client_major_version : bits_stdint_uintn_h.uint32_t;
client_minor_version : bits_stdint_uintn_h.uint32_t) return xcb_damage_query_version_cookie_t -- /usr/include/xcb/damage.h:215
with Import => True,
Convention => C,
External_Name => "xcb_damage_query_version_unchecked";
function xcb_damage_query_version_reply
(c : access xcb.xcb_connection_t;
cookie : xcb_damage_query_version_cookie_t;
e : System.Address) return access xcb_damage_query_version_reply_t -- /usr/include/xcb/damage.h:234
with Import => True,
Convention => C,
External_Name => "xcb_damage_query_version_reply";
function xcb_damage_create_checked
(c : access xcb.xcb_connection_t;
damage : xcb_damage_damage_t;
drawable : xproto.xcb_drawable_t;
level : bits_stdint_uintn_h.uint8_t) return xcb.xcb_void_cookie_t -- /usr/include/xcb/damage.h:250
with Import => True,
Convention => C,
External_Name => "xcb_damage_create_checked";
function xcb_damage_create
(c : access xcb.xcb_connection_t;
damage : xcb_damage_damage_t;
drawable : xproto.xcb_drawable_t;
level : bits_stdint_uintn_h.uint8_t) return xcb.xcb_void_cookie_t -- /usr/include/xcb/damage.h:264
with Import => True,
Convention => C,
External_Name => "xcb_damage_create";
function xcb_damage_destroy_checked (c : access xcb.xcb_connection_t; damage : xcb_damage_damage_t) return xcb.xcb_void_cookie_t -- /usr/include/xcb/damage.h:281
with Import => True,
Convention => C,
External_Name => "xcb_damage_destroy_checked";
function xcb_damage_destroy (c : access xcb.xcb_connection_t; damage : xcb_damage_damage_t) return xcb.xcb_void_cookie_t -- /usr/include/xcb/damage.h:293
with Import => True,
Convention => C,
External_Name => "xcb_damage_destroy";
function xcb_damage_subtract_checked
(c : access xcb.xcb_connection_t;
damage : xcb_damage_damage_t;
repair : xcb_xfixes.xcb_xfixes_region_t;
parts : xcb_xfixes.xcb_xfixes_region_t) return xcb.xcb_void_cookie_t -- /usr/include/xcb/damage.h:308
with Import => True,
Convention => C,
External_Name => "xcb_damage_subtract_checked";
function xcb_damage_subtract
(c : access xcb.xcb_connection_t;
damage : xcb_damage_damage_t;
repair : xcb_xfixes.xcb_xfixes_region_t;
parts : xcb_xfixes.xcb_xfixes_region_t) return xcb.xcb_void_cookie_t -- /usr/include/xcb/damage.h:322
with Import => True,
Convention => C,
External_Name => "xcb_damage_subtract";
function xcb_damage_add_checked
(c : access xcb.xcb_connection_t;
drawable : xproto.xcb_drawable_t;
region : xcb_xfixes.xcb_xfixes_region_t) return xcb.xcb_void_cookie_t -- /usr/include/xcb/damage.h:339
with Import => True,
Convention => C,
External_Name => "xcb_damage_add_checked";
function xcb_damage_add
(c : access xcb.xcb_connection_t;
drawable : xproto.xcb_drawable_t;
region : xcb_xfixes.xcb_xfixes_region_t) return xcb.xcb_void_cookie_t -- /usr/include/xcb/damage.h:352
with Import => True,
Convention => C,
External_Name => "xcb_damage_add";
end xcb_damage;
|
zhmu/ananas | Ada | 3,891 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- A D A . S E Q U E N T I A L _ I O . C _ S T R E A M S --
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-2022, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Interfaces.C_Streams; use Interfaces.C_Streams;
with System.File_IO;
with System.File_Control_Block;
with System.Sequential_IO;
with Ada.Unchecked_Conversion;
package body Ada.Sequential_IO.C_Streams is
package FIO renames System.File_IO;
package FCB renames System.File_Control_Block;
package SIO renames System.Sequential_IO;
subtype AP is FCB.AFCB_Ptr;
function To_FCB is new Ada.Unchecked_Conversion (File_Mode, FCB.File_Mode);
--------------
-- C_Stream --
--------------
function C_Stream (F : File_Type) return FILEs is
begin
FIO.Check_File_Open (AP (F));
return F.Stream;
end C_Stream;
----------
-- Open --
----------
procedure Open
(File : in out File_Type;
Mode : File_Mode;
C_Stream : FILEs;
Form : String := "";
Name : String := "")
is
Dummy_File_Control_Block : SIO.Sequential_AFCB;
pragma Warnings (Off, Dummy_File_Control_Block);
-- Yes, we know this is never assigned a value, only the tag
-- is used for dispatching purposes, so that's expected.
begin
FIO.Open (File_Ptr => AP (File),
Dummy_FCB => Dummy_File_Control_Block,
Mode => To_FCB (Mode),
Name => Name,
Form => Form,
Amethod => 'Q',
Creat => False,
Text => False,
C_Stream => C_Stream);
end Open;
end Ada.Sequential_IO.C_Streams;
|
MEDiCODEDEV/coinapi-sdk | Ada | 19,738 | ads | -- OMS _ REST API
-- OMS Project
--
-- The version of the OpenAPI document: v1
--
--
-- NOTE: This package is auto generated by OpenAPI-Generator 4.3.1.
-- https://openapi-generator.tech
-- Do not edit the class manually.
with Swagger.Streams;
with Ada.Containers.Vectors;
package .Models is
-- ------------------------------
-- Message
-- ------------------------------
type Messages_Type is
record
P_Type : Swagger.Nullable_UString;
Exchange_Id : Swagger.Nullable_UString;
Message : Swagger.Nullable_UString;
end record;
package Messages_Type_Vectors is
new Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => Messages_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in Messages_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in Messages_Type_Vectors.Vector);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out Messages_Type);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out Messages_Type_Vectors.Vector);
-- ------------------------------
-- Message info
-- ------------------------------
type MessagesInfo_Type is
record
P_Type : Swagger.Nullable_UString;
Exchange_Id : Swagger.Nullable_UString;
Error_Message : Swagger.Nullable_UString;
end record;
package MessagesInfo_Type_Vectors is
new Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => MessagesInfo_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in MessagesInfo_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in MessagesInfo_Type_Vectors.Vector);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out MessagesInfo_Type);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out MessagesInfo_Type_Vectors.Vector);
type TimeInForce_Type is
record
end record;
package TimeInForce_Type_Vectors is
new Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => TimeInForce_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in TimeInForce_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in TimeInForce_Type_Vectors.Vector);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out TimeInForce_Type);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out TimeInForce_Type_Vectors.Vector);
type CancelOrder_Type is
record
Exchange_Id : Swagger.Nullable_UString;
Exchange_Order_Id : Swagger.Nullable_UString;
Client_Order_Id : Swagger.Nullable_UString;
end record;
package CancelOrder_Type_Vectors is
new Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => CancelOrder_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in CancelOrder_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in CancelOrder_Type_Vectors.Vector);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out CancelOrder_Type);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out CancelOrder_Type_Vectors.Vector);
type CancelAllOrder_Type is
record
Exchange_Id : Swagger.Nullable_UString;
end record;
package CancelAllOrder_Type_Vectors is
new Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => CancelAllOrder_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in CancelAllOrder_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in CancelAllOrder_Type_Vectors.Vector);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out CancelAllOrder_Type);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out CancelAllOrder_Type_Vectors.Vector);
-- ------------------------------
-- Message ok
-- ------------------------------
type MessagesOk_Type is
record
P_Type : Swagger.Nullable_UString;
Exchange_Id : Swagger.Nullable_UString;
Message : Swagger.Nullable_UString;
end record;
package MessagesOk_Type_Vectors is
new Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => MessagesOk_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in MessagesOk_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in MessagesOk_Type_Vectors.Vector);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out MessagesOk_Type);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out MessagesOk_Type_Vectors.Vector);
type OrderStatus_Type is
record
end record;
package OrderStatus_Type_Vectors is
new Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => OrderStatus_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in OrderStatus_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in OrderStatus_Type_Vectors.Vector);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out OrderStatus_Type);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out OrderStatus_Type_Vectors.Vector);
type BalanceData_Type is
record
Id : Swagger.Nullable_UString;
Symbol_Exchange : Swagger.Nullable_UString;
Symbol_Coinapi : Swagger.Nullable_UString;
Balance : float;
Available : float;
Locked : float;
Update_Origin : Swagger.Nullable_UString;
end record;
package BalanceData_Type_Vectors is
new Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => BalanceData_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in BalanceData_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in BalanceData_Type_Vectors.Vector);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out BalanceData_Type);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out BalanceData_Type_Vectors.Vector);
type Balance_Type is
record
P_Type : Swagger.Nullable_UString;
Exchange_Name : Swagger.Nullable_UString;
Data : .Models.BalanceData_Type_Vectors.Vector;
end record;
package Balance_Type_Vectors is
new Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => Balance_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in Balance_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in Balance_Type_Vectors.Vector);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out Balance_Type);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out Balance_Type_Vectors.Vector);
type Order_Type is
record
P_Type : Swagger.Nullable_UString;
Exchange_Name : Swagger.Nullable_UString;
Data : .Models.OrderData_Type_Vectors.Vector;
end record;
package Order_Type_Vectors is
new Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => Order_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in Order_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in Order_Type_Vectors.Vector);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out Order_Type);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out Order_Type_Vectors.Vector);
type NewOrder_Type is
record
Exchange_Id : Swagger.Nullable_UString;
Client_Order_Id : Swagger.Nullable_UString;
Symbol_Exchange : Swagger.Nullable_UString;
Symbol_Coinapi : Swagger.Nullable_UString;
Amount_Order : Swagger.Number;
Price : Swagger.Number;
Side : Swagger.Nullable_UString;
Order_Type : Swagger.Nullable_UString;
Time_In_Force : .Models.TimeInForce_Type;
Expire_Time : Swagger.Nullable_Date;
Exec_Inst : Swagger.UString_Vectors.Vector;
end record;
package NewOrder_Type_Vectors is
new Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => NewOrder_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in NewOrder_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in NewOrder_Type_Vectors.Vector);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out NewOrder_Type);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out NewOrder_Type_Vectors.Vector);
type OrderLive_Type is
record
P_Type : Swagger.Nullable_UString;
Exchange_Id : Swagger.Nullable_UString;
Id : Swagger.Nullable_UString;
Client_Order_Id_Format_Exchange : Swagger.Nullable_UString;
Exchange_Order_Id : Swagger.Nullable_UString;
Amount_Open : Swagger.Number;
Amount_Filled : Swagger.Number;
Status : .Models.OrderStatus_Type;
Time_Order : Swagger.UString_Vectors.Vector_Vectors.Vector;
Error_Message : Swagger.Nullable_UString;
Client_Order_Id : Swagger.Nullable_UString;
Symbol_Exchange : Swagger.Nullable_UString;
Symbol_Coinapi : Swagger.Nullable_UString;
Amount_Order : Swagger.Number;
Price : Swagger.Number;
Side : Swagger.Nullable_UString;
Order_Type : Swagger.Nullable_UString;
Time_In_Force : .Models.TimeInForce_Type;
Expire_Time : Swagger.Nullable_Date;
Exec_Inst : Swagger.UString_Vectors.Vector;
end record;
package OrderLive_Type_Vectors is
new Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => OrderLive_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in OrderLive_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in OrderLive_Type_Vectors.Vector);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out OrderLive_Type);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out OrderLive_Type_Vectors.Vector);
type Position_Type is
record
P_Type : Swagger.Nullable_UString;
Exchange_Name : Swagger.Nullable_UString;
Data : .Models.PositionData_Type_Vectors.Vector;
end record;
package Position_Type_Vectors is
new Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => Position_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in Position_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in Position_Type_Vectors.Vector);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out Position_Type);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out Position_Type_Vectors.Vector);
-- ------------------------------
-- Create order validation error (response)
-- ------------------------------
type CreateOrder400_Type is
record
P_Type : Swagger.Nullable_UString;
Title : Swagger.Nullable_UString;
Status : Swagger.Number;
Trace_Id : Swagger.Nullable_UString;
Errors : Swagger.Nullable_UString;
end record;
package CreateOrder400_Type_Vectors is
new Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => CreateOrder400_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in CreateOrder400_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in CreateOrder400_Type_Vectors.Vector);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out CreateOrder400_Type);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out CreateOrder400_Type_Vectors.Vector);
type OrderData_Type is
record
Exchange_Id : Swagger.Nullable_UString;
Id : Swagger.Nullable_UString;
Client_Order_Id_Format_Exchange : Swagger.Nullable_UString;
Exchange_Order_Id : Swagger.Nullable_UString;
Amount_Open : Swagger.Number;
Amount_Filled : Swagger.Number;
Status : .Models.OrderStatus_Type;
Time_Order : Swagger.UString_Vectors.Vector_Vectors.Vector;
Error_Message : Swagger.Nullable_UString;
Client_Order_Id : Swagger.Nullable_UString;
Symbol_Exchange : Swagger.Nullable_UString;
Symbol_Coinapi : Swagger.Nullable_UString;
Amount_Order : Swagger.Number;
Price : Swagger.Number;
Side : Swagger.Nullable_UString;
Order_Type : Swagger.Nullable_UString;
Time_In_Force : .Models.TimeInForce_Type;
Expire_Time : Swagger.Nullable_Date;
Exec_Inst : Swagger.UString_Vectors.Vector;
end record;
package OrderData_Type_Vectors is
new Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => OrderData_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in OrderData_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in OrderData_Type_Vectors.Vector);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out OrderData_Type);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out OrderData_Type_Vectors.Vector);
type PositionData_Type is
record
Id : Swagger.Nullable_UString;
Symbol_Exchange : Swagger.Nullable_UString;
Symbol_Coinapi : Swagger.Nullable_UString;
Avg_Entry_Price : Swagger.Number;
Quantity : Swagger.Number;
Is_Buy : Swagger.Nullable_Boolean;
Unrealised_Pn_L : Swagger.Number;
Leverage : Swagger.Number;
Cross_Margin : Swagger.Nullable_Boolean;
Liquidation_Price : Swagger.Number;
Raw_Data : Swagger.Nullable_UString;
end record;
package PositionData_Type_Vectors is
new Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => PositionData_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in PositionData_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in PositionData_Type_Vectors.Vector);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out PositionData_Type);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out PositionData_Type_Vectors.Vector);
end .Models;
|
thorstel/Advent-of-Code-2018 | Ada | 2,379 | adb | with Ada.Text_IO; use Ada.Text_IO;
procedure Day05 is
function React (Unit1 : Character; Unit2 : Character) return Boolean is
Result : Boolean := False;
begin
if abs (Character'Pos (Unit1) - Character'Pos (Unit2)) = 32 then
Result := True;
end if;
return Result;
end React;
function Filter_Reactions (Polymer : String;
Ignore : Character) return String
is
Result : String (Polymer'Range);
Last : Natural := Result'First - 1;
I : Natural := Result'First;
begin
while I <= Polymer'Last loop
declare
Keep : Boolean := True;
begin
if Polymer (I) = Ignore or
abs (Character'Pos (Polymer (I)) - Character'Pos (Ignore)) = 32
then
I := I + 1;
else
if I < Polymer'Last then
if React (Polymer (I), Polymer (I + 1)) then
Keep := False;
end if;
end if;
if Keep then
Last := Last + 1;
Result (Last) := Polymer (I);
I := I + 1;
else
I := I + 2;
end if;
end if;
end;
end loop;
declare
New_Polymer : constant String := Result (Result'First .. Last);
begin
if Last = Polymer'Last then
return New_Polymer;
else
return Filter_Reactions (New_Polymer, Ignore);
end if;
end;
end Filter_Reactions;
Input_File : File_Type;
begin
Open (Input_File, In_File, "input.txt");
declare
Input : constant String := Get_Line (Input_File);
Minimum_Length : Natural;
Current_Length : Natural;
begin
-- Part 1
Minimum_Length := Filter_Reactions (Input, '_')'Length;
Put_Line ("Part 1 =" & Integer'Image (Minimum_Length));
-- Part 2
for C in Character'Pos ('a') .. Character'Pos ('z') loop
Current_Length := Filter_Reactions (Input, Character'Val (C))'Length;
if Current_Length < Minimum_Length then
Minimum_Length := Current_Length;
end if;
end loop;
Put_Line ("Part 2 =" & Integer'Image (Minimum_Length));
end;
Close (Input_File);
end Day05;
|
pchapin/acrypto | Ada | 1,921 | ads | ---------------------------------------------------------------------------
-- FILE : aco-crypto-algorithms-aes.ads
-- SUBJECT : Specification of a package holding the raw AES algorithm.
-- AUTHOR : (C) Copyright 2014 by Peter Chapin
--
-- This version only supports 128 bit keys.
--
-- Please send comments or bug reports to
--
-- Peter Chapin <[email protected]>
---------------------------------------------------------------------------
pragma SPARK_Mode(On);
package ACO.Crypto.Algorithms.AES is
type AES_Algorithm is private;
procedure Initialize
(B : out AES_Algorithm;
Key : in ACO.Octet_Array)
with
Depends => (B => Key),
Pre => Key'Length = 16;
procedure Encrypt
(B : in AES_Algorithm;
Block : in out ACO.Octet_Array)
with
Depends => (Block =>+ B),
Pre => Block'Length = 16;
procedure Decrypt
(B : in AES_Algorithm;
Block : in out ACO.Octet_Array)
with
Depends => (Block =>+ B),
Pre => Block'Length = 16;
private
Nb : constant := 4; -- Block size = 4*Nb = 16 bytes (128 bits).
Nk : constant := 4; -- Key size = 4*Nk = 16 bytes (128 bits).
Nr : constant := 10; -- Number of rounds = 10 for the 128 bit key.
subtype Round_Index_Type is Natural range 0 .. Nr;
subtype State_Row_Index_Type is Natural range 0 .. 3;
type State_Column_Index_Type is mod Nb; -- A modular type makes row shifting easier.
type State_Type is array(State_Row_Index_Type, State_Column_Index_Type) of ACO.Octet;
subtype Key_Row_Index_Type is Natural range 0 .. 3;
subtype Key_Column_Index_Type is Natural range 0 .. Nb*(Nr + 1) - 1;
type Expanded_Key_Type is array(Key_Row_Index_Type, Key_Column_Index_Type) of ACO.Octet;
type AES_Algorithm is
record
W : Expanded_Key_Type;
end record;
end ACO.Crypto.Algorithms.AES;
|
stcarrez/mat | Ada | 2,183 | adb | -----------------------------------------------------------------------
-- readline -- A simple readline binding
-- Copyright (C) 2014 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Interfaces.C;
with Interfaces.C.Strings;
with Ada.IO_Exceptions;
package body Readline is
pragma Linker_Options ("-lreadline");
function Readline (Prompt : in Interfaces.C.Strings.chars_ptr)
return Interfaces.C.Strings.chars_ptr;
pragma Import (C, Readline, "readline");
procedure Add_History (Line : in Interfaces.C.Strings.chars_ptr);
pragma Import (C, Add_History, "add_history");
-- ------------------------------
-- Print the prompt and a read a line from the terminal.
-- Raise the Ada.IO_Exceptions.End_Error when the EOF is reached.
-- ------------------------------
function Get_Line (Prompt : in String) return String is
use type Interfaces.C.Strings.chars_ptr;
P : Interfaces.C.Strings.chars_ptr := Interfaces.C.Strings.New_String (Prompt);
R : Interfaces.C.Strings.chars_ptr;
begin
R := Readline (P);
Interfaces.C.Strings.Free (P);
if R = Interfaces.C.Strings.Null_Ptr then
raise Ada.IO_Exceptions.End_Error;
end if;
declare
Result : constant String := Interfaces.C.Strings.Value (R);
begin
if Result'Length > 0 then
Add_History (R);
end if;
Interfaces.C.Strings.Free (R);
return Result;
end;
end Get_Line;
end Readline;
|
Heziode/ada-dotenv | Ada | 21,186 | adb | pragma Ada_2012;
with Ada.Command_Line;
with Ada.Directories;
with Ada.Environment_Variables;
with Ada.Strings;
with GNAT.Regpat;
package body Dotenv is
RE_INI_KEY_VAL : constant GNAT.Regpat.Pattern_Matcher := GNAT.Regpat.Compile ("^\s*([\w.-]+)\s*=\s*(.*)?\s*$");
RE_EXPANDED_VAL : constant GNAT.Regpat.Pattern_Matcher :=
GNAT.Regpat.Compile ("(.?\$(?:{(?:[a-zA-Z0-9_]+)?}|(?:[a-zA-Z0-9_]+)?))");
RE_EXPANDED_PART_VAL : constant GNAT.Regpat.Pattern_Matcher := GNAT.Regpat.Compile ("(.?)\${?([a-zA-Z0-9_]+)?}?");
--------------------------------------------------------------------------------------------------------------------
-- Inner sub-programs --
--------------------------------------------------------------------------------------------------------------------
-- Print a messange on the standard output.
-- Used for debug purpose.
-- @param Message The message to print
procedure Log (Message : String);
-- Open a file. By default, if file does not exist, it create it.
-- @param File The file container
-- @param Mode Mode to open the file
-- @param Path Location of the file
-- @param File_Form "Form" to pass to the file
-- @param Auto True if auto create the file if it does not exist, false otherwise
procedure Open_File (File : in out File_Type;
Mode : File_Mode;
Path : String;
File_Form : String := DEFAULT_FILE_FORM_VALUE;
Auto : Boolean := False);
function Get_Boolean_Environment_Variable (Name : String; Default_Value : Boolean) return Boolean;
pragma Inline (Get_Boolean_Environment_Variable);
-- Get a Key and Value from a Map, and set in Environment Variable.
-- @param C Cursor to a map
procedure Add_Environment_Variable (C : Cursor; Debug, Overwrite : Boolean);
---------
-- Log --
---------
procedure Log (Message : String) is
begin
Put_Line ("[dotenv][DEBUG] " & Message);
end Log;
---------------
-- Open_File --
---------------
procedure Open_File (File : in out File_Type;
Mode : File_Mode;
Path : String;
File_Form : String := DEFAULT_FILE_FORM_VALUE;
Auto : Boolean := False)
is
use Ada.Directories;
begin
if Exists (Path) then
Open (File, Mode, Path, File_Form);
else
if Auto then
Create (File, Mode, Path, File_Form);
else
raise Ada.Directories.Name_Error;
end if;
end if;
end Open_File;
--------------------------------------
-- Get_Boolean_Environment_Variable --
--------------------------------------
function Get_Boolean_Environment_Variable (Name : String; Default_Value : Boolean) return Boolean is
begin
if not Ada.Environment_Variables.Exists (Name) then
return Default_Value;
end if;
begin
return Boolean'Value (Ada.Environment_Variables.Value (Name));
exception
when Constraint_Error =>
return Default_Value;
end;
end Get_Boolean_Environment_Variable;
------------------------------
-- Add_Environment_Variable --
------------------------------
procedure Add_Environment_Variable (C : Cursor; Debug, Overwrite : Boolean) is
Key : constant String := To_String (Environment_Variable_Map.Key (C));
Value : constant String := To_String (Element (C));
begin
if not Ada.Environment_Variables.Exists (Key) or Overwrite then
Ada.Environment_Variables.Set (Key, Value);
elsif Debug then
Log (Key & " is already defined in environment variable and will not be overwritten.");
end if;
end Add_Environment_Variable;
--------------------------------------------------------------------------------------------------------------------
-- Outer sub-programs --
--------------------------------------------------------------------------------------------------------------------
-----------
-- Parse --
-----------
function Parse (File : File_Type; Debug : Boolean := DEFAULT_DEBUG_VALUE) return Map is
use GNAT.Regpat;
-- Given a Line, match the Key=Value pattern.
-- @param Search_In Line to analyze
-- @param Key Output key found
-- @param Value Output value found
-- @param Found True if the pattern is found, False otherwise
procedure Search_For_Pattern (Search_In : String;
Key, Value : out Unbounded_String;
Found : out Boolean);
-- Replace a Pattern by Replacement in S.
-- @param S String to process
-- @param Pattern Pattern to replace
-- @param Replacement New value
--
-- example: if S is "Mary had a XX lamb", then String_Replace(S, "X", "little");
-- will turn S into "Mary had a littlelittle lamb"
-- and String_Replace(S, "Y", "small"); will not change S
procedure String_Replace (S : in out Unbounded_String; Pattern, Replacement : String);
------------------------
-- Search_For_Pattern --
------------------------
procedure Search_For_Pattern (Search_In : String;
Key, Value : out Unbounded_String;
Found : out Boolean)
is
Result : Match_Array (0 .. 2);
begin
Match (RE_INI_KEY_VAL, Search_In, Result);
Found := not (Result (1) = No_Match);
if Found then
Key := To_Unbounded_String (Search_In (Result (1).First .. Result (1).Last));
if not (Result (2) = No_Match) then
Value := To_Unbounded_String (Search_In (Result (2).First .. Result (2).Last));
else
Value := To_Unbounded_String ("");
end if;
end if;
end Search_For_Pattern;
--------------------
-- String_Replace --
--------------------
procedure String_Replace (S : in out Unbounded_String; Pattern, Replacement : String) is
Index : Natural;
begin
loop
Index := Ada.Strings.Unbounded.Index (Source => S, Pattern => Pattern);
exit when Index = 0;
Replace_Slice (Source => S,
Low => Index,
High => Index + Pattern'Length - 1,
By => Replacement);
end loop;
end String_Replace;
Line : Unbounded_String := Null_Unbounded_String;
Result : Map := Empty_Map;
Idx : Natural := 0;
begin -- Parse
loop
Idx := Idx + 1;
exit when End_Of_File (File);
if End_Of_Line (File) then
Skip_Line (File);
elsif End_Of_Page (File) then
Skip_Page (File);
else
Line := To_Unbounded_String (Get_Line (File));
end if;
declare
Key : Unbounded_String := Null_Unbounded_String;
Value : Unbounded_String := Null_Unbounded_String;
Found : Boolean := False;
Is_Double_Quoted : Boolean := False;
Is_Single_Quoted : Boolean := False;
begin
Search_For_Pattern (Search_In => To_String (Line),
Key => Key,
Value => Value,
Found => Found);
if not Found then
if Debug then
Log ("did not match key and value when parsing line "
& To_String (Trim (To_Unbounded_String (Natural'Image (Idx)), Ada.Strings.Both))
& ": " & To_String (Line));
end if;
goto CONTINUE_NEXT_LINE;
end if;
if Length (Value) > 0 then
Is_Double_Quoted := Element (Value, 1) = '"' and Element (Value, Length (Value)) = '"';
Is_Single_Quoted := Element (Value, 1) = ''' and Element (Value, Length (Value)) = ''';
--- If single or double quoted, remove quotes
if Is_Double_Quoted or Is_Single_Quoted then
Value := Unbounded_Slice (Value, 2, Length (Value) - 1);
if Is_Double_Quoted then
String_Replace (S => Value,
Pattern => "\n",
Replacement => ASCII.LF & "");
end if;
else
Value := Trim (Value, Ada.Strings.Both);
end if;
end if;
if Result.Contains (Key) then
Result.Replace (Key, Value);
else
Result.Insert (Key, Value);
end if;
end;
<<CONTINUE_NEXT_LINE>>
end loop;
return Result;
end Parse;
-----------
-- Parse --
-----------
function Parse (Path : String; Debug : Boolean := DEFAULT_DEBUG_VALUE) return Map is
File : File_Type;
Result : Map := Empty_Map;
begin
Open_File (File => File,
Mode => In_File,
Path => Path);
Result := Parse (File, Debug);
Close (File);
return Result;
end Parse;
-------------------------
-- Interpolate_Element --
-------------------------
function Interpolate_Element (Env_Var : Map; Value : String; Overwrite : Boolean) return String is
use GNAT.Regpat;
-- Return the value corresponding to the Key. It looking in Env_Var and in Environment Variable.
-- Example: if we have the following environment variable:
-- - FIRSTNAME=John
-- Env_Var content:
-- - FIRSTNAME=Jane
-- If Overwrite is True, then the return will be: Jane
-- If Overwrite is False, then the return will be: John
-- @param Key Key of the paradize
-- @return Return the value corresponding to the Key or an empty String if Key is not found in Env_Var nor in
-- environments variables.
function Get_Value_Of (Key : String) return String;
------------------
-- Get_Value_Of --
------------------
function Get_Value_Of (Key : String) return String is
begin
if Env_Var.Contains (To_Unbounded_String (Key)) then
if Overwrite and Ada.Environment_Variables.Exists (Key) then
return Ada.Environment_Variables.Value (Key);
else
return To_String (Env_Var.Element (To_Unbounded_String (Key)));
end if;
elsif Ada.Environment_Variables.Exists (Key) then
return Ada.Environment_Variables.Value (Key);
end if;
return "";
end Get_Value_Of;
Found : Boolean := False;
Match, Str : Unbounded_String := Null_Unbounded_String;
Last_Index, First, Last : Integer := 0;
Result_Array : Match_Array (0 .. 1);
begin -- Interpolate_Element
if Value'Length = 0 then
return Value;
end if;
Str := To_Unbounded_String (Value);
Loop_Over_Values : loop
GNAT.Regpat.Match (RE_EXPANDED_VAL, To_String (Str), Result_Array, Last_Index, Length (Str));
Found := not (Result_Array (1) = No_Match);
if Found then
Match := Unbounded_Slice (Source => Str,
Low => Result_Array (1).First,
High => Result_Array (1).Last);
First := Result_Array (1).First;
Last := Result_Array (1).Last;
Last_Index := Result_Array (1).Last;
end if;
exit Loop_Over_Values when not Found or Last_Index >= Length (Str);
Match_Parts : declare
Part_Result : Unbounded_String := Null_Unbounded_String;
Part_Search_In : constant String := To_String (Match);
Part_Result_Array : Match_Array (0 .. 2);
Prefix : Unbounded_String := Null_Unbounded_String;
Origin_Size : Natural;
begin
GNAT.Regpat.Match (RE_EXPANDED_PART_VAL, Part_Search_In, Part_Result_Array);
Prefix := To_Unbounded_String (Part_Search_In (Part_Result_Array (1).First .. Part_Result_Array (1).Last));
if Prefix = "\"
then
Replace_Slice (Source => Str,
Low => First + Part_Result_Array (1).First - 1,
High => First + Part_Result_Array (1).Last - 1,
By => "");
else
Part_Result := To_Unbounded_String
(Get_Value_Of (Part_Search_In (Part_Result_Array (2).First .. Part_Result_Array (2).Last)));
Origin_Size := Length (Part_Result);
Part_Result := To_Unbounded_String (Interpolate_Element (Env_Var, To_String (Part_Result), Overwrite));
Replace_Slice (Source => Str,
Low => First + Length (Prefix),
High => Last,
By => To_String (Part_Result));
Last_Index := Length (Part_Result) - Origin_Size;
end if;
end Match_Parts;
end loop Loop_Over_Values;
return To_String (Str);
end Interpolate_Element;
-----------------
-- Interpolate --
-----------------
procedure Interpolate (Overwrite : Boolean;
Debug : Boolean;
Env_Var : in out Map)
is
-- Expand a value.
-- For example, if we have the following environment variables:
-- - FIRSTNAME=John
-- - LASTNAME=Doe
-- - HELLO=Hello ${FIRSTNAME} $LASTNAME
-- Then the value will be: Hello John Doe
-- @param C Cursor to a map
procedure Interpolation (C : Cursor);
-------------------
-- Interpolation --
-------------------
procedure Interpolation (C : Cursor) is
begin
Env_Var.Replace (Key => Environment_Variable_Map.Key (C),
New_Item => To_Unbounded_String
(Interpolate_Element (Env_Var, To_String (Element (C)), Overwrite)));
Add_Environment_Variable (C => C,
Debug => Debug,
Overwrite => Overwrite);
end Interpolation;
begin -- Interpolate
Env_Var.Iterate (Interpolation'Access);
end Interpolate;
------------
-- Config --
------------
procedure Config (Overwrite : Boolean;
Debug : Boolean;
Interpolate : Boolean;
Path : String := "";
File_Form : String := "")
is
use Ada.Command_Line, Ada.Directories;
Result : Map := Empty_Map;
-- Get a Key and Value from a Map, and set in Environment Variable.
-- @param C Cursor to a map
procedure Add_Environment_Variable (C : Cursor);
------------------------------
-- Add_Environment_Variable --
------------------------------
procedure Add_Environment_Variable (C : Cursor) is
begin
Add_Environment_Variable (C => C,
Debug => Debug,
Overwrite => Overwrite);
end Add_Environment_Variable;
File_Path : Unbounded_String := Null_Unbounded_String;
Form : Unbounded_String := To_Unbounded_String (File_Form);
File : File_Type;
begin -- Config
-- Get the config file that will be used
if Path'Length > 0 then
if Exists (Path) then
File_Path := To_Unbounded_String (Path);
else
raise Ada.Directories.Name_Error with "The following environment variable file does not exists: " & Path;
end if;
elsif Ada.Environment_Variables.Exists (DOTENV_CONFIG_PATH)
and then Ada.Environment_Variables.Value (DOTENV_CONFIG_PATH)'Length > 0
then
if Exists (Ada.Environment_Variables.Value (DOTENV_CONFIG_PATH)) then
File_Path := To_Unbounded_String (Ada.Environment_Variables.Value (DOTENV_CONFIG_PATH));
else
raise Ada.Directories.Name_Error with DOTENV_CONFIG_PATH & " environment variable provide a path to '"
& Ada.Environment_Variables.Value (DOTENV_CONFIG_PATH) & "' but there is no file at this location.";
end if;
elsif Exists (Compose (Current_Directory, DEFAULT_FILENAME)) then
File_Path := To_Unbounded_String (Compose (Current_Directory, DEFAULT_FILENAME));
elsif Exists (Compose (Containing_Directory (Command_Name), DEFAULT_FILENAME)) then
File_Path := To_Unbounded_String (Compose (Containing_Directory (Command_Name), DEFAULT_FILENAME));
else
-- No '.env' file found
raise Ada.Directories.Name_Error with "No '.env' file provived and there is no '.env' file in '" &
Current_Directory & "' nor in '" & Containing_Directory (Command_Name) & "'";
end if;
-- Get configuration via environment variable
-- File Form
if File_Form'Length > 0 then
Form := To_Unbounded_String (File_Form);
elsif Ada.Environment_Variables.Exists (DOTENV_CONFIG_FILE_FORM) then
Form := To_Unbounded_String (Ada.Environment_Variables.Value (DOTENV_CONFIG_FILE_FORM));
else
Form := To_Unbounded_String (DEFAULT_FILE_FORM_VALUE);
end if;
-- Load file and parse content
Open_File (File => File,
Mode => In_File,
Path => To_String (File_Path),
File_Form => To_String (Form));
Result := Parse (File, Debug);
Close (File);
-- Then, set environment variable
if Interpolate then
Dotenv.Interpolate (Overwrite => Overwrite,
Debug => Debug,
Env_Var => Result);
else
Result.Iterate (Add_Environment_Variable'Access);
end if;
end Config;
------------
-- Config --
------------
procedure Config (Path : String := "";
File_Form : String := "")
is
begin
Config (Overwrite => Get_Boolean_Environment_Variable (DOTENV_CONFIG_OVERWRITE, DEFAULT_OVERWRITE_VALUE),
Debug => Get_Boolean_Environment_Variable (DOTENV_CONFIG_DEBUG, DEFAULT_DEBUG_VALUE),
Interpolate => Get_Boolean_Environment_Variable (DOTENV_CONFIG_INTERPOLATE, DEFAULT_DEBUG_VALUE),
Path => Path,
File_Form => File_Form);
end Config;
----------------------
-- Config_Overwrite --
----------------------
procedure Config_Overwrite (Overwrite : Boolean;
Path : String := "";
File_Form : String := "")
is
begin
Config (Overwrite => Overwrite,
Debug => Get_Boolean_Environment_Variable (DOTENV_CONFIG_DEBUG, DEFAULT_DEBUG_VALUE),
Interpolate => Get_Boolean_Environment_Variable (DOTENV_CONFIG_INTERPOLATE, DEFAULT_DEBUG_VALUE),
Path => Path,
File_Form => File_Form);
end Config_Overwrite;
------------------
-- Config_Debug --
------------------
procedure Config_Debug (Debug : Boolean;
Path : String := "";
File_Form : String := "")
is
begin
Config (Overwrite => Get_Boolean_Environment_Variable (DOTENV_CONFIG_OVERWRITE, DEFAULT_OVERWRITE_VALUE),
Debug => Debug,
Interpolate => Get_Boolean_Environment_Variable (DOTENV_CONFIG_INTERPOLATE, DEFAULT_DEBUG_VALUE),
Path => Path,
File_Form => File_Form);
end Config_Debug;
------------------
-- Config_Debug --
------------------
procedure Config_Interpolate (Interpolate : Boolean;
Path : String := "";
File_Form : String := "")
is
begin
Config (Overwrite => Get_Boolean_Environment_Variable (DOTENV_CONFIG_OVERWRITE, DEFAULT_OVERWRITE_VALUE),
Debug => Get_Boolean_Environment_Variable (DOTENV_CONFIG_DEBUG, DEFAULT_DEBUG_VALUE),
Interpolate => Interpolate,
Path => Path,
File_Form => File_Form);
end Config_Interpolate;
end Dotenv;
|
reznikmm/matreshka | Ada | 7,273 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- XML Processor --
-- --
-- Tools Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2013-2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with League.Strings;
with League.String_Vectors;
with XML.Schema.Terms;
with XML.Schema.Type_Definitions;
with XSD2Ada.Analyzer;
with XSD_To_Ada.Writers;
with XML.Schema.Model_Groups;
package XSD2Ada.Encoder is
Payload_Type : League.Strings.Universal_String;
Elements_Name : League.String_Vectors.Universal_String_Vector;
Type_Elements_Name : League.String_Vectors.Universal_String_Vector;
Element_Name : XSD_To_Ada.Writers.Writer;
Type_Element_Name : XSD_To_Ada.Writers.Writer;
function Add_Indent
(Spaces_Count : Integer)
return League.Strings.Universal_String;
procedure Generate_Complex_Type
(XS_Term : XML.Schema.Terms.XS_Term;
Writer : in out XSD_To_Ada.Writers.Writer;
Element_Name : League.Strings.Universal_String;
Base_Name : League.Strings.Universal_String;
Min_Occurs : Boolean;
Max_Occurs : Boolean);
procedure Generate_Overriding_Procedure_Encode_Header
(Writer : in out XSD_To_Ada.Writers.Writer;
Spec_Writer : in out XSD_To_Ada.Writers.Writer;
Procedures_Name : League.Strings.Universal_String;
Tag_Vector : in out League.String_Vectors.Universal_String_Vector;
Namespace : League.Strings.Universal_String;
Is_AnyType : Boolean := False);
procedure Generate_Package_Header
(Payload_Writer : in out XSD_To_Ada.Writers.Writer);
procedure Generate_Procedure_Encode_Header
(Writer : in out XSD_To_Ada.Writers.Writer;
Spec_Writer : in out XSD_To_Ada.Writers.Writer;
Procedures_Name : League.Strings.Universal_String);
procedure Generate_Simple_Type
(Type_D : XML.Schema.Type_Definitions.XS_Type_Definition;
XS_Term : XML.Schema.Terms.XS_Term;
Writer : in out XSD_To_Ada.Writers.Writer;
Element_Name : League.Strings.Universal_String;
Base_Name : League.Strings.Universal_String;
Min_Occurs : Boolean;
Max_Occurs : Boolean);
procedure Print_Type_Definition
(Type_D : XML.Schema.Type_Definitions.XS_Type_Definition;
Encoder_Types : in out XSD_To_Ada.Writers.Writer;
Encoder_Spec_Types : in out XSD_To_Ada.Writers.Writer;
Writer : in out XSD_To_Ada.Writers.Writer;
Writer_types : in out XSD_To_Ada.Writers.Writer;
Spec_Writer : in out XSD_To_Ada.Writers.Writer;
Name : League.Strings.Universal_String;
Element_Name : League.Strings.Universal_String;
Tag_Vector : in out League.String_Vectors.Universal_String_Vector;
Namespace : League.Strings.Universal_String;
Choice : Boolean := False;
Is_Min_Occur : Boolean := False;
Is_Max_Occur : Boolean := False);
procedure Print_Model
(Model_Group : XML.Schema.Model_Groups.XS_Model_Group;
Writer : in out XSD_To_Ada.Writers.Writer;
Writer_types : in out XSD_To_Ada.Writers.Writer;
Name : League.Strings.Universal_String;
Element_Name : League.Strings.Universal_String;
Base_Name : League.Strings.Universal_String
:= League.Strings.Empty_Universal_String;
Choice : Boolean := False);
procedure Print_Type_Title
(Node_Vector : XSD2Ada.Analyzer.Items;
Encoder_Types : in out XSD_To_Ada.Writers.Writer;
Encoder_Spec_Types : in out XSD_To_Ada.Writers.Writer;
Encoder : in out XSD_To_Ada.Writers.Writer;
Encoder_Spec : in out XSD_To_Ada.Writers.Writer);
function Write_End_Element
(Name : League.Strings.Universal_String;
Namespace : League.Strings.Universal_String)
return League.Strings.Universal_String;
function Write_Start_Element
(Name : League.Strings.Universal_String;
Namespace : League.Strings.Universal_String)
return League.Strings.Universal_String;
end XSD2Ada.Encoder;
|
wanghai1988/tkimg | Ada | 4,276 | ads | ----------------------------------------------------------------
-- ZLib for Ada thick binding. --
-- --
-- Copyright (C) 2002-2003 Dmitriy Anisimkov --
-- --
-- Open source license information is in the zlib.ads file. --
----------------------------------------------------------------
-- $Id: zlib-streams.ads,v 1.1.1.1 2006/01/16 18:06:28 abrighto Exp $
package ZLib.Streams is
type Stream_Mode is (In_Stream, Out_Stream, Duplex);
type Stream_Access is access all Ada.Streams.Root_Stream_Type'Class;
type Stream_Type is
new Ada.Streams.Root_Stream_Type with private;
procedure Read
(Stream : in out Stream_Type;
Item : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset);
procedure Write
(Stream : in out Stream_Type;
Item : in Ada.Streams.Stream_Element_Array);
procedure Flush
(Stream : in out Stream_Type;
Mode : in Flush_Mode := Sync_Flush);
-- Flush the written data to the back stream,
-- all data placed to the compressor is flushing to the Back stream.
-- Should not be used untill necessary, becouse it is decreasing
-- compression.
function Read_Total_In (Stream : in Stream_Type) return Count;
pragma Inline (Read_Total_In);
-- Return total number of bytes read from back stream so far.
function Read_Total_Out (Stream : in Stream_Type) return Count;
pragma Inline (Read_Total_Out);
-- Return total number of bytes read so far.
function Write_Total_In (Stream : in Stream_Type) return Count;
pragma Inline (Write_Total_In);
-- Return total number of bytes written so far.
function Write_Total_Out (Stream : in Stream_Type) return Count;
pragma Inline (Write_Total_Out);
-- Return total number of bytes written to the back stream.
procedure Create
(Stream : out Stream_Type;
Mode : in Stream_Mode;
Back : in Stream_Access;
Back_Compressed : in Boolean;
Level : in Compression_Level := Default_Compression;
Strategy : in Strategy_Type := Default_Strategy;
Header : in Header_Type := Default;
Read_Buffer_Size : in Ada.Streams.Stream_Element_Offset
:= Default_Buffer_Size;
Write_Buffer_Size : in Ada.Streams.Stream_Element_Offset
:= Default_Buffer_Size);
-- Create the Comression/Decompression stream.
-- If mode is In_Stream then Write operation is disabled.
-- If mode is Out_Stream then Read operation is disabled.
-- If Back_Compressed is true then
-- Data written to the Stream is compressing to the Back stream
-- and data read from the Stream is decompressed data from the Back stream.
-- If Back_Compressed is false then
-- Data written to the Stream is decompressing to the Back stream
-- and data read from the Stream is compressed data from the Back stream.
-- !!! When the Need_Header is False ZLib-Ada is using undocumented
-- ZLib 1.1.4 functionality to do not create/wait for ZLib headers.
procedure Close (Stream : in out Stream_Type);
private
use Ada.Streams;
type Buffer_Access is access all Stream_Element_Array;
type Stream_Type
is new Root_Stream_Type with
record
Mode : Stream_Mode;
Buffer : Buffer_Access;
Rest_First : Stream_Element_Offset;
Rest_Last : Stream_Element_Offset;
-- Buffer for Read operation.
-- We need to have this buffer in the record
-- becouse not all read data from back stream
-- could be processed during the read operation.
Buffer_Size : Stream_Element_Offset;
-- Buffer size for write operation.
-- We do not need to have this buffer
-- in the record becouse all data could be
-- processed in the write operation.
Back : Stream_Access;
Reader : Filter_Type;
Writer : Filter_Type;
end record;
end ZLib.Streams;
|
persan/a-vulkan | Ada | 1,456 | ads | pragma Ada_2012;
pragma Style_Checks (Off);
with System;
package Vulkan.Low_Level.vulkan_fuchsia_h is
VULKAN_FUCHSIA_H_u : constant := 1; -- vulkan_fuchsia.h:2
VK_FUCHSIA_imagepipe_surface : constant := 1; -- vulkan_fuchsia.h:32
VK_FUCHSIA_IMAGEPIPE_SURFACE_SPEC_VERSION : constant := 1; -- vulkan_fuchsia.h:33
VK_FUCHSIA_IMAGEPIPE_SURFACE_EXTENSION_NAME : aliased constant String := "VK_FUCHSIA_imagepipe_surface" & ASCII.NUL; -- vulkan_fuchsia.h:34
--** Copyright (c) 2015-2019 The Khronos Group Inc.
--**
--** Licensed under the Apache License, Version 2.0 (the "License");
--** you may not use this file except in compliance with the License.
--** You may obtain a copy of the License at
--**
--** http://www.apache.org/licenses/LICENSE-2.0
--**
--** Unless required by applicable law or agreed to in writing, software
--** distributed under the License is distributed on an "AS IS" BASIS,
--** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
--** See the License for the specific language governing permissions and
--** limitations under the License.
--
--** This header is generated from the Khronos Vulkan XML API Registry.
--**
--
type VkImagePipeSurfaceCreateInfoFUCHSIA is record
pNext : System.Address; -- vulkan_fuchsia.h:38
end record
with Convention => C_Pass_By_Copy; -- vulkan_fuchsia.h:36
end Vulkan.Low_Level.vulkan_fuchsia_h;
|
dbanetto/uni | Ada | 2,828 | adb | with Register;
package body Pump with
Spark_Mode,
Refined_State =>
(Unit => (moneyDue, fuelkind),
State => (nozzleOut))
is
moneyDue : MoneyUnit := MoneyUnit (0.0);
nozzleOut : Boolean := False;
fuelkind : FuelType := Octane_91;
procedure Initialize is
begin
moneyDue := MoneyUnit (0.0);
nozzleOut := False;
fuelkind := Octane_91;
end Initialize;
----------------
-- LiftNozzle --
----------------
procedure LiftNozzle (fuel : FuelType) is
begin
if nozzleOut or (GetDebt > MoneyUnit(0.0) and fuel /= fuelkind) then
return;
end if;
nozzleOut := True;
fuelkind := fuel;
end LiftNozzle;
------------------
-- ReturnNozzle --
------------------
procedure ReturnNozzle is
begin
-- enforce pre-conditions
if not isNozzleOut and moneyDue /= MoneyUnit (0.0) then
return;
end if;
nozzleOut := False;
end ReturnNozzle;
--------------
-- PumpFuel --
--------------
procedure PumpFuelFull (tank : in out Vehicle.Tank) is
amount : FuelUnit := FuelUnit'Last;
begin
if not isNozzleOut then
return;
end if;
PumpFuel(tank, amount);
end PumpFuelFull;
procedure PumpFuel (tank : in out Vehicle.Tank ; amount : FuelUnit) is
-- shadow amount so we can edit it
actual_amount : FuelUnit := amount;
added_debt : MoneyUnit;
begin
-- enforce pre-conditions
if not isNozzleOut
or amount <= FuelUnit (0)
or Vehicle.IsFull (tank)
or Reservoir.isEmpty(fuelkind) then
return;
end if;
-- ensure that you do not over drain the reservoir
if Reservoir.GetVolume(fuelkind) < actual_amount then
actual_amount := Reservoir.GetVolume(fuelkind);
end if;
if actual_amount <= FuelUnit(0) then
return;
end if;
Vehicle.Fill (tank, actual_amount);
Reservoir.drain(fuelkind, actual_amount);
added_debt := MoneyUnit (Float(actual_amount) * Float(Register.GetPriceOfFuel(fuelkind)));
moneyDue := moneyDue + added_debt;
pragma Assert (added_debt >= MoneyUnit(0.0));
end PumpFuel;
---------
-- Pay --
---------
procedure Pay (amount : MoneyUnit) is
old_due : MoneyUnit;
begin
-- enforcing pre-conditions
if moneyDue < amount and Float(amount) < 0.0 then
return;
end if;
old_due := moneyDue;
moneyDue := moneyDue - amount;
pragma Assert ( old_due = moneyDue + amount);
end Pay;
--------------
-- Getters --
--------------
function isNozzleOut return Boolean is (nozzleOut);
function GetDebt return MoneyUnit is (moneyDue);
function GetCurrentFuelType return FuelType is (fuelkind);
end Pump;
|
ohenley/ada-util | Ada | 1,666 | ads | -----------------------------------------------------------------------
-- concurrency.tests -- Unit tests for concurrency package
-- Copyright (C) 2009, 2010, 2011, 2012 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Tests;
package Util.Concurrent.Tests is
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite);
type Test is new Util.Tests.Test with null record;
procedure Test_Increment (T : in out Test);
procedure Test_Decrement (T : in out Test);
procedure Test_Decrement_And_Test (T : in out Test);
procedure Test_Copy (T : in out Test);
-- Test concurrent pool
procedure Test_Pool (T : in out Test);
-- Test concurrent pool
procedure Test_Concurrent_Pool (T : in out Test);
-- Test fifo.
procedure Test_Fifo (T : in out Test);
-- Test concurrent aspects of fifo.
procedure Test_Concurrent_Fifo (T : in out Test);
-- Test concurrent arrays.
procedure Test_Array (T : in out Test);
end Util.Concurrent.Tests;
|
evgenijaZ/PP-labs | Ada | 1,066 | ads | generic
N : in Natural;
package DataOperations is
subtype Index is Positive range 1 .. N;
type Vector is array (Index) of Integer;
type Matrix is array (Index) of Vector;
procedure Input (a : out Integer);
procedure Generate (a : out Integer);
procedure FillWithOne (a : out Integer);
procedure Input (A : out Vector);
procedure Generate (A : out Vector);
procedure FillWithOne (A : out Vector);
procedure Input (MA : out Matrix);
procedure Generate (MA : out Matrix);
procedure FillWithOne (MA : out Matrix);
procedure Output (V : in Vector);
procedure Output (MA : in Matrix);
function Multiple
(A : in Integer;
MB : in Matrix;
From : Integer;
To : Integer) return Matrix;
function Multiple
(Left : in Matrix;
Right : in Matrix;
From : Integer;
To : Integer) return Matrix;
function Amount
(MA : in Matrix;
MB : in Matrix;
From : Integer;
To : Integer) return Matrix;
end DataOperations;
|
fmqa/simulatedannealing-ada | Ada | 1,375 | adb | with Ada.Characters.Latin_1;
with GNAT.Spitbol;
with Bitmaps.RGB;
package body Bitmaps.IO is
procedure Write_PPM_P6
(To : not null access Ada.Streams.Root_Stream_Type'Class;
Source : in Bitmaps.RGB.Image)
is
begin
-- Write P6 PPM type marker.
String'Write (To, "P6");
Character'Write (To, Ada.Characters.Latin_1.LF);
-- Write image dimensions.
String'Write (To, GNAT.Spitbol.S (Source.Width));
Character'Write (To, Ada.Characters.Latin_1.Space);
String'Write (To, GNAT.Spitbol.S (Source.Height));
Character'Write (To, Ada.Characters.Latin_1.LF);
-- Write maximum luminance value.
String'Write (To, GNAT.Spitbol.S (Integer (Luminance'Last)));
Character'Write (To, Ada.Characters.Latin_1.LF);
-- RGB component-wise output.
for Y in 0 .. Bitmaps.RGB.Max_Y (Source) loop
for X in 0 .. Bitmaps.RGB.Max_X (Source) loop
declare
Pxy : Bitmaps.RGB.Pixel := Bitmaps.RGB.Get_Pixel (Source, X, Y);
begin
Character'Write (To, Character'Val (Pxy.R));
Character'Write (To, Character'Val (Pxy.G));
Character'Write (To, Character'Val (Pxy.B));
end;
end loop;
end loop;
Character'Write (To, Ada.Characters.Latin_1.LF);
end Write_PPM_P6;
end Bitmaps.IO;
|
charlie5/lace | Ada | 432 | ads | with
openGL.Buffer.general;
package openGL.Buffer.texture_coords is new openGL.Buffer.general (base_Object => Buffer.array_Object,
Index => Index_t,
Element => Coordinate_2D,
Element_Array => Coordinates_2D);
|
reznikmm/matreshka | Ada | 3,724 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Attributes;
package ODF.DOM.Fo_Letter_Spacing_Attributes is
pragma Preelaborate;
type ODF_Fo_Letter_Spacing_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Fo_Letter_Spacing_Attribute_Access is
access all ODF_Fo_Letter_Spacing_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Fo_Letter_Spacing_Attributes;
|
zhmu/ananas | Ada | 6,202 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- A D A . T E X T _ I O . D E C I M A L _ I O --
-- --
-- B o d y --
-- --
-- Copyright (C) 2020-2022, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Interfaces;
with Ada.Text_IO.Decimal_Aux;
with System.Img_Decimal_32; use System.Img_Decimal_32;
with System.Img_Decimal_64; use System.Img_Decimal_64;
with System.Img_Decimal_128; use System.Img_Decimal_128;
with System.Val_Decimal_32; use System.Val_Decimal_32;
with System.Val_Decimal_64; use System.Val_Decimal_64;
with System.Val_Decimal_128; use System.Val_Decimal_128;
package body Ada.Text_IO.Decimal_IO is
subtype Int32 is Interfaces.Integer_32;
subtype Int64 is Interfaces.Integer_64;
subtype Int128 is Interfaces.Integer_128;
package Aux32 is new
Ada.Text_IO.Decimal_Aux
(Int32,
Scan_Decimal32,
Set_Image_Decimal32);
package Aux64 is new
Ada.Text_IO.Decimal_Aux
(Int64,
Scan_Decimal64,
Set_Image_Decimal64);
package Aux128 is new
Ada.Text_IO.Decimal_Aux
(Int128,
Scan_Decimal128,
Set_Image_Decimal128);
Need64 : constant Boolean := Num'Size > 32;
Need128 : constant Boolean := Num'Size > 64;
-- Throughout this generic body, we distinguish between the case where type
-- Int32 is acceptable, where type Int64 is acceptable and where an Int128
-- is needed. These boolean constants are used to test for these cases and
-- since it is a constant, only code for the relevant case will be included
-- in the instance.
Scale : constant Integer := Num'Scale;
---------
-- Get --
---------
procedure Get
(File : File_Type;
Item : out Num;
Width : Field := 0)
is
pragma Unsuppress (Range_Check);
begin
if Need128 then
Item := Num'Fixed_Value (Aux128.Get (File, Width, Scale));
elsif Need64 then
Item := Num'Fixed_Value (Aux64.Get (File, Width, Scale));
else
Item := Num'Fixed_Value (Aux32.Get (File, Width, Scale));
end if;
exception
when Constraint_Error => raise Data_Error;
end Get;
procedure Get
(Item : out Num;
Width : Field := 0)
is
begin
Get (Current_In, Item, Width);
end Get;
procedure Get
(From : String;
Item : out Num;
Last : out Positive)
is
pragma Unsuppress (Range_Check);
begin
if Need128 then
Item := Num'Fixed_Value (Aux128.Gets (From, Last, Scale));
elsif Need64 then
Item := Num'Fixed_Value (Aux64.Gets (From, Last, Scale));
else
Item := Num'Fixed_Value (Aux32.Gets (From, Last, Scale));
end if;
exception
when Constraint_Error => raise Data_Error;
end Get;
---------
-- Put --
---------
procedure Put
(File : File_Type;
Item : Num;
Fore : Field := Default_Fore;
Aft : Field := Default_Aft;
Exp : Field := Default_Exp)
is
begin
if Need128 then
Aux128.Put
(File, Int128'Integer_Value (Item), Fore, Aft, Exp, Scale);
elsif Need64 then
Aux64.Put
(File, Int64'Integer_Value (Item), Fore, Aft, Exp, Scale);
else
Aux32.Put
(File, Int32'Integer_Value (Item), Fore, Aft, Exp, Scale);
end if;
end Put;
procedure Put
(Item : Num;
Fore : Field := Default_Fore;
Aft : Field := Default_Aft;
Exp : Field := Default_Exp)
is
begin
Put (Current_Out, Item, Fore, Aft, Exp);
end Put;
procedure Put
(To : out String;
Item : Num;
Aft : Field := Default_Aft;
Exp : Field := Default_Exp)
is
begin
if Need128 then
Aux128.Puts (To, Int128'Integer_Value (Item), Aft, Exp, Scale);
elsif Need64 then
Aux64.Puts (To, Int64'Integer_Value (Item), Aft, Exp, Scale);
else
Aux32.Puts (To, Int32'Integer_Value (Item), Aft, Exp, Scale);
end if;
end Put;
end Ada.Text_IO.Decimal_IO;
|
stcarrez/ada-css | Ada | 30,105 | adb | -----------------------------------------------------------------------
-- css-analysis-rules -- CSS Analysis Rules
-- Copyright (C) 2017, 2023 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Unchecked_Deallocation;
with Util.Log.Loggers;
with Util.Strings;
with CSS.Core.Styles;
with CSS.Analysis.Rules.Types;
package body CSS.Analysis.Rules is
procedure Free is
new Ada.Unchecked_Deallocation (Rule_Type'Class, Rule_Type_Access);
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("CSS.Analysis.Rules");
-- ------------------------------
-- Get the source location of the rule definition.
-- ------------------------------
function Get_Location (Rule : in Rule_Type) return Location is
begin
return Rule.Loc;
end Get_Location;
-- ------------------------------
-- Set the min and max repeat for this rule.
-- ------------------------------
procedure Set_Repeat (Rule : in out Rule_Type;
Min : in Natural;
Max : in Natural;
Sep : in Boolean := False) is
begin
Rule.Min_Repeat := Min;
Rule.Max_Repeat := Max;
Rule.Comma_Sep := Sep;
end Set_Repeat;
-- ------------------------------
-- Append the <tt>New_Rule</tt> at end of the rule's list.
-- ------------------------------
procedure Append (Rule : in out Rule_Type;
New_Rule : in Rule_Type_Access) is
Tail : Rule_Type_Access := Rule.Next;
begin
if Tail = null then
Rule.Next := New_Rule;
else
while Tail.Next /= null loop
Tail := Tail.Next;
end loop;
Tail.Next := New_Rule;
end if;
end Append;
-- Print the rule definition to the print stream.
procedure Print (Rule : in Rule_Type;
Stream : in out CSS.Printer.File_Type'Class) is
begin
if Rule.Comma_Sep then
Stream.Print ("#");
if Rule.Min_Repeat /= 1 and then Rule.Max_Repeat /= 1 then
Stream.Print ("{");
Stream.Print (Util.Strings.Image (Rule.Min_Repeat));
if Rule.Min_Repeat /= Rule.Max_Repeat then
Stream.Print (",");
Stream.Print (Util.Strings.Image (Rule.Max_Repeat));
end if;
Stream.Print ("}");
end if;
elsif Rule.Min_Repeat = 0 and then Rule.Max_Repeat = 1 then
Stream.Print ("?");
elsif Rule.Min_Repeat = 1 and then Rule.Max_Repeat = Natural'Last then
Stream.Print ("+");
elsif Rule.Min_Repeat = 0 and then Rule.Max_Repeat = Natural'Last then
Stream.Print ("*");
elsif Rule.Min_Repeat /= 1 and then Rule.Max_Repeat /= 1 then
Stream.Print ("{");
Stream.Print (Util.Strings.Image (Rule.Min_Repeat));
if Rule.Min_Repeat /= Rule.Max_Repeat then
Stream.Print (",");
if Rule.Max_Repeat /= Natural'Last then
Stream.Print (Util.Strings.Image (Rule.Max_Repeat));
end if;
end if;
Stream.Print ("}");
end if;
end Print;
-- ------------------------------
-- Returns True if the two rules refer to the same rule definition.
-- ------------------------------
function Is_Rule (Rule1, Rule2 : access Rule_Type'Class) return Boolean is
begin
if Rule1 = Rule2 then
return True;
end if;
if Rule1.all in Definition_Rule_Type'Class then
return Is_Rule (Definition_Rule_Type'Class (Rule1.all).Rule, Rule2);
end if;
if Rule2.all in Definition_Rule_Type'Class then
return Is_Rule (Rule1, Definition_Rule_Type'Class (Rule2.all).Rule);
end if;
return False;
end Is_Rule;
-- ------------------------------
-- Check if the value matches the rule.
-- ------------------------------
function Match (Rule : in Rule_Type;
Value : in CSS.Core.Values.Value_Type) return Boolean is
pragma Unreferenced (Rule, Value);
begin
return False;
end Match;
-- ------------------------------
-- Check if the value matches the identifier defined by the rule.
-- ------------------------------
function Match (Rule : access Rule_Type;
Value : in CSS.Core.Values.Value_List;
Result : access Match_Result;
Pos : in Positive := 1) return Natural is
Count : constant Natural := Value.Get_Count;
Match_Count : Natural := 0;
begin
for I in Pos .. Count loop
if not Rule_Type'Class (Rule.all).Match (Value.Get_Value (I)) then
return Match_Count;
end if;
Match_Count := Match_Count + 1;
if Match_Count >= Rule.Max_Repeat then
return Match_Count;
end if;
end loop;
if Match_Count < Rule.Min_Repeat then
return 0;
end if;
return Match_Count;
end Match;
-- ------------------------------
-- Print the rule definition to the print stream.
-- ------------------------------
overriding
procedure Print (Rule : in Ident_Rule_Type;
Stream : in out CSS.Printer.File_Type'Class) is
begin
Stream.Print (Rule.Ident);
Rule_Type (Rule).Print (Stream);
end Print;
-- Check if the value matches the identifier defined by the rule.
overriding
function Match (Rule : in Ident_Rule_Type;
Value : in CSS.Core.Values.Value_Type) return Boolean is
begin
return CSS.Core.Values.To_String (Value) = Rule.Ident;
end Match;
-- ------------------------------
-- Find a rule that describes a property.
-- Returns the rule or null if there is no rule for the property.
-- ------------------------------
function Find_Property (Repository : in Repository_Type;
Name : in String) return Rule_Type_Access is
Pos : constant Rule_Maps.Cursor := Repository.Properties.Find (Name);
begin
if Rule_Maps.Has_Element (Pos) then
return Rule_Maps.Element (Pos);
else
Log.Info ("No property rule '{0}'", Name);
return null;
end if;
end Find_Property;
-- ------------------------------
-- Create a property rule and add it to the repository under the given name.
-- The rule is empty and is ready to be defined.
-- ------------------------------
procedure Create_Property (Repository : in out Repository_Type;
Name : in String;
Rule : in Rule_Type_Access) is
begin
if Repository.Properties.Contains (Name) then
Log.Error ("{0}: Property '{1}' is already defined",
CSS.Core.To_String (Rule.Loc), Name);
else
Log.Info ("Adding property '{0}'", Name);
Repository.Properties.Insert (Name, Rule);
Rule.Used := Rule.Used + 1;
end if;
end Create_Property;
-- ------------------------------
-- Create a rule definition and add it to the repository under the given name.
-- The rule definition is used by other rules to represent complex rules.
-- The rule is empty and is ready to be defined.
-- ------------------------------
procedure Create_Definition (Repository : in out Repository_Type;
Name : in String;
Rule : in Rule_Type_Access) is
begin
if Repository.Rules.Contains (Name) then
Log.Error ("{0}: Rule '{1}' is already defined",
CSS.Core.To_String (Rule.Loc), Name);
else
Log.Info ("Adding rule '{0}'", Name);
Repository.Rules.Insert (Name, Rule);
Rule.Used := Rule.Used + 1;
end if;
end Create_Definition;
-- Create a rule that describes an identifier;
function Create_Identifier (Name : in String;
Loc : in Location) return Rule_Type_Access is
Rule : constant Rule_Type_Access :=
new Ident_Rule_Type '(Ada.Finalization.Limited_Controlled with
Next => null, Len => Name'Length, Ident => Name, Loc => Loc, others => <>);
begin
Log.Debug ("Create rule identifier '{0}'", Name);
return Rule;
end Create_Identifier;
-- ------------------------------
-- Create a rule that describes either a definition or a pre-defined type.
-- ------------------------------
function Create_Definition (Repository : in out Repository_Type;
Name : in String;
Loc : in Location) return Rule_Type_Access is
Pos : Rule_Maps.Cursor := Repository.Types.Find (Name);
begin
if Rule_Maps.Has_Element (Pos) then
Log.Debug ("Create rule type '{0}'", Name);
return new Type_Rule_Type '(Ada.Finalization.Limited_Controlled with
Next => null, Len => 0, Rule => Rule_Maps.Element (Pos),
Loc => Loc, others => <>);
end if;
Pos := Repository.Rules.Find (Name);
if Rule_Maps.Has_Element (Pos) then
Log.Debug ("Create rule definition '{0}'", Name);
return new Definition_Rule_Type '(Ada.Finalization.Limited_Controlled with
Next => null, Len => Name'Length,
Ident => Name,
Rule => Rule_Maps.Element (Pos),
Loc => Loc, others => <>);
end if;
Log.Debug ("{0}: Create unknown rule definition '{1}'",
CSS.Core.To_String (Loc), Name);
declare
Rule : constant Definition_Rule_Type_Access
:= new Definition_Rule_Type '(Ada.Finalization.Limited_Controlled with
Next => null, Len => Name'Length,
Rule => null,
Ident => Name, Loc => Loc, others => <>);
begin
Repository.Deferred.Append (Rule);
return Rule.all'Access;
end;
end Create_Definition;
-- Check if the value matches the type.
overriding
function Match (Rule : in Type_Rule_Type;
Value : in CSS.Core.Values.Value_Type) return Boolean is
begin
return Rule.Rule.Match (Value);
end Match;
-- ------------------------------
-- Print the rule definition to the print stream.
-- ------------------------------
overriding
procedure Print (Rule : in Definition_Rule_Type;
Stream : in out CSS.Printer.File_Type'Class) is
begin
Stream.Print (Rule.Ident);
Rule_Type (Rule).Print (Stream);
end Print;
-- Check if the value matches the type.
overriding
function Match (Rule : in Definition_Rule_Type;
Value : in CSS.Core.Values.Value_Type) return Boolean is
begin
if Rule.Rule = null then
return False;
else
return Rule.Rule.Match (Value);
end if;
end Match;
overriding
function Match (Rule : access Definition_Rule_Type;
Value : in CSS.Core.Values.Value_List;
Result : access Match_Result;
Pos : in Positive := 1) return Natural is
N : Natural;
Repeat : Natural := 0;
Match_Count : Natural := 0;
begin
if Rule.Rule = null then
return 0;
else
while Repeat < Rule.Max_Repeat loop
N := Rule.Rule.Match (Value, Result, Pos + Match_Count);
exit when N = 0;
Match_Count := Match_Count + N;
Repeat := Repeat + 1;
end loop;
if Result /= null and then Match_Count /= 0 then
Result.List.Append ((Pos, Pos + Match_Count - 1, Rule.all'Access));
end if;
return Match_Count;
end if;
end Match;
-- ------------------------------
-- Print the rule definition to the print stream.
-- ------------------------------
overriding
procedure Print (Rule : in Group_Rule_Type;
Stream : in out CSS.Printer.File_Type'Class) is
List : Rule_Type_Access := Rule.List;
begin
if Rule.Kind = GROUP_PARAMS then
Stream.Print ("(");
else
Stream.Print ("[");
end if;
while List /= null loop
List.Print (Stream);
if List.Next /= null then
case Rule.Kind is
when GROUP_ONLY_ONE =>
Stream.Print (" | ");
when GROUP_DBAR =>
Stream.Print (" || ");
when GROUP_AND =>
Stream.Print (" && ");
when GROUP_PARAMS =>
Stream.Print (", ");
when GROUP_SEQ =>
Stream.Print (" ");
end case;
end if;
List := List.Next;
end loop;
if Rule.Kind = GROUP_PARAMS then
Stream.Print (")");
else
Stream.Print ("]");
end if;
Rule_Type (Rule).Print (Stream);
end Print;
-- Check if the value matches the rule.
overriding
function Match (Rule : in Group_Rule_Type;
Value : in CSS.Core.Values.Value_Type) return Boolean is
List : Rule_Type_Access := Rule.List;
begin
if Rule.Kind = GROUP_ONLY_ONE then
while List /= null loop
if List.Match (Value) then
return True;
end if;
List := List.Next;
end loop;
end if;
return False;
end Match;
-- Check if the value matches the identifier defined by the rule.
overriding
function Match (Group : access Group_Rule_Type;
Value : in CSS.Core.Values.Value_List;
Result : access Match_Result;
Pos : in Positive := 1) return Natural is
Count : constant Natural := Value.Get_Count;
Rule : Rule_Type_Access;
Match_Count : Natural := 0;
N : Natural;
Repeat : Natural := 0;
Cur_Pos : Positive := Pos;
begin
if Group.Kind = GROUP_ONLY_ONE then
loop
Rule := Group.List;
while Rule /= null loop
N := Rule.Match (Value, Result, Cur_Pos);
if N > 0 then
Repeat := Repeat + 1;
Match_Count := Match_Count + N;
Cur_Pos := Cur_Pos + N;
exit;
end if;
Rule := Rule.Next;
end loop;
if Rule = null or else Repeat = Group.Max_Repeat
or else Cur_Pos > Count
then
if Repeat < Group.Min_Repeat then
return 0;
end if;
if Repeat > Group.Max_Repeat then
return 0;
end if;
return Match_Count;
end if;
end loop;
elsif Group.Kind = GROUP_AND then
declare
M : Rule_Type_Access_Array (1 .. Group.Count);
I : Positive := 1;
begin
while Cur_Pos <= Count loop
N := 0;
Rule := Group.List;
while Rule /= null loop
if not (for some J in M'Range => M (J) = Rule) then
N := Rule.Match (Value, Result, Cur_Pos);
if N > 0 then
Cur_Pos := Cur_Pos + N;
M (I) := Rule;
I := I + 1;
exit;
end if;
end if;
Rule := Rule.Next;
end loop;
Match_Count := Match_Count + N;
exit when N = 0 or else I = M'Last + 1;
end loop;
Rule := Group.List;
while Rule /= null loop
if Rule.Min_Repeat > 0 and then
not (for some J in M'Range => M (J) = Rule)
then
return 0;
end if;
Rule := Rule.Next;
end loop;
return Match_Count;
end;
elsif Group.Kind = GROUP_DBAR then
declare
M : Rule_Type_Access_Array (1 .. Group.Count);
N : Natural;
Cnt : Natural := 0;
Found : Boolean;
begin
Rule := Group.List;
while Rule /= null loop
Cnt := Cnt + 1;
M (Cnt) := Rule;
Rule := Rule.Next;
end loop;
while Cur_Pos <= Count loop
Found := False;
for I in 1 .. Cnt loop
Rule := M (I);
N := Rule.Match (Value, Result, Cur_Pos);
if N > 0 then
Match_Count := Match_Count + N;
if I /= Cnt then
M (I .. Cnt - 1) := M (I + 1 .. Cnt);
end if;
Cnt := Cnt - 1;
Cur_Pos := Cur_Pos + N;
Found := True;
exit;
end if;
end loop;
exit when Cnt = 0 or else not Found;
end loop;
return Match_Count;
end;
elsif Group.Kind = GROUP_SEQ then
declare
N : Natural;
begin
Rule := Group.List;
while Cur_Pos <= Count loop
exit when Rule = null;
N := Rule.Match (Value, Result, Cur_Pos);
if N = 0 and then Rule.Min_Repeat > 0 then
return 0;
end if;
Match_Count := Match_Count + N;
Cur_Pos := Cur_Pos + N;
Rule := Rule.Next;
end loop;
return Match_Count;
end;
end if;
return Match_Count;
end Match;
-- Create a rule that describes a group of rules whose head is passed in <tt>Rules</tt>.
procedure Append_Group (Into : out Rule_Type_Access;
First : in Rule_Type_Access;
Second : in Rule_Type_Access;
Kind : in Group_Type) is
Count : Natural := 1;
Rule : Rule_Type_Access := Second;
begin
while Rule /= null loop
Count := Count + 1;
Rule := Rule.Next;
end loop;
if First.all in Group_Rule_Type'Class and then Group_Rule_Type (First.all).Kind = Kind then
Append (Group_Rule_Type (First.all).List.all, Second);
Group_Rule_Type (First.all).Count := Group_Rule_Type (First.all).Count + Count;
Into := First;
else
Into := new Group_Rule_Type '(Ada.Finalization.Limited_Controlled with
Next => null, List => First,
Kind => Kind,
Loc => First.Loc,
Count => Count,
Min_Repeat => 1,
Max_Repeat => 1, others => <>);
First.Next := Second;
end if;
Log.Debug ("Create rule group");
end Append_Group;
-- ------------------------------
-- Print the rule definition to the print stream.
-- ------------------------------
overriding
procedure Print (Rule : in Function_Rule_Type;
Stream : in out CSS.Printer.File_Type'Class) is
begin
Stream.Print (Rule.Ident);
Group_Rule_Type (Rule).Print (Stream);
end Print;
-- Check if the value matches the function with its parameters.
overriding
function Match (Rule : access Function_Rule_Type;
Value : in CSS.Core.Values.Value_List;
Result : access Match_Result;
Pos : in Positive := 1) return Natural is
use type CSS.Core.Values.Value_Kind, CSS.Core.Values.Value_List_Access;
Func : constant CSS.Core.Values.Value_Type := Value.Get_Value (Pos);
Params : CSS.Core.Values.Value_List_Access;
begin
if CSS.Core.Values.Get_Type (Func) /= CSS.Core.Values.VALUE_FUNCTION then
return 0;
end if;
if CSS.Core.Values.Get_Value (Func) /= Rule.Ident then
return 0;
end if;
Params := CSS.Core.Values.Get_Parameters (Func);
if Params = null then
return 0;
end if;
declare
Match_Count : Natural := 0;
N : Natural;
Count : constant Natural := Params.Get_Count;
Cur_Pos : Positive := 1;
R : Rule_Type_Access := Rule.List;
begin
while Cur_Pos <= Count loop
exit when R = null;
N := R.Match (Params.all, Result, Cur_Pos);
if N = 0 and then Rule.Min_Repeat > 0 then
return 0;
end if;
Match_Count := Match_Count + N;
Cur_Pos := Cur_Pos + N;
R := R.Next;
end loop;
if Match_Count /= Count then
return 0;
else
return 1;
end if;
end;
end Match;
-- ------------------------------
-- Create a rule that describes a function call with parameters.
-- ------------------------------
function Create_Function (Name : in String;
Params : in Rule_Type_Access;
Loc : in Location) return Rule_Type_Access is
begin
return new Function_Rule_Type '(Ada.Finalization.Limited_Controlled with
Len => Name'Length,
Loc => Loc,
Kind => GROUP_PARAMS,
Next => null,
List => Params,
Ident => Name,
others => <>);
end Create_Function;
-- ------------------------------
-- Print the repository rule definitions to the print stream.
-- ------------------------------
procedure Print (Stream : in out CSS.Printer.File_Type'Class;
Repository : in Repository_Type) is
Iter : Rule_Maps.Cursor := Repository.Rules.First;
begin
while Rule_Maps.Has_Element (Iter) loop
Stream.Print (Rule_Maps.Key (Iter));
Stream.Print (" := ");
Rule_Maps.Element (Iter).Print (Stream);
Stream.New_Line;
Rule_Maps.Next (Iter);
end loop;
end Print;
procedure Resolve (Repository : in out Repository_Type) is
begin
while not Repository.Deferred.Is_Empty loop
declare
First : Rule_Vectors.Cursor := Repository.Deferred.First;
Rule : constant Definition_Rule_Type_Access := Rule_Vectors.Element (First);
Pos : constant Rule_Maps.Cursor := Repository.Rules.Find (Rule.Ident);
begin
if Rule_Maps.Has_Element (Pos) then
Rule.Rule := Rule_Maps.Element (Pos);
else
Log.Error ("{0}: Unknown rule definition '{1}'",
CSS.Core.To_String (Rule.Loc), Rule.Ident);
end if;
Repository.Deferred.Delete (First);
end;
end loop;
end Resolve;
procedure Analyze (Repository : in out Repository_Type;
Sheet : in CSS.Core.Sheets.CSSStylesheet;
Report : in out CSS.Core.Errors.Error_Handler'Class) is
procedure Process (Rule : in CSS.Core.Styles.CSSStyleRule'Class;
Prop : in CSS.Core.Properties.CSSProperty);
procedure Process (Rule : in CSS.Core.Styles.CSSStyleRule'Class;
Prop : in CSS.Core.Properties.CSSProperty) is
pragma Unreferenced (Rule);
R : constant Rule_Type_Access := Repository.Find_Property (Prop.Name.all);
Match_Count : Natural;
Count : Natural;
Result : aliased Match_Result;
begin
if R = null then
Report.Warning (Prop.Location, "Invalid property: " & Prop.Name.all);
else
Count := Prop.Value.Get_Count;
Match_Count := R.Match (Prop.Value, Result'Access);
if Match_Count /= Count then
if Count = 1 then
Report.Warning (Prop.Location, "Invalid value '"
& Prop.Value.To_String & "' for property " & Prop.Name.all);
elsif Match_Count = 0 then
Report.Warning (Prop.Location, "Invalid values '"
& Prop.Value.To_String & "' for property " & Prop.Name.all);
elsif Match_Count = Count - 1 then
Report.Warning (Prop.Location, "Unexpected value '"
& Prop.Value.To_String (Match_Count + 1, Positive'Last)
& "' after '"
& Prop.Value.To_String (1, Match_Count)
& "' for property " & Prop.Name.all);
else
Report.Warning (Prop.Location, "Unexpected values '"
& Prop.Value.To_String (Match_Count + 1, Positive'Last)
& "' after '"
& Prop.Value.To_String (1, Match_Count)
& "' for property " & Prop.Name.all);
end if;
end if;
end if;
end Process;
begin
Repository.Resolve;
Sheet.Iterate_Properties (Process'Access);
end Analyze;
-- ------------------------------
-- Search for properties that use the given rule and call the Process procedure
-- for each property that uses the rule definition.
-- ------------------------------
procedure Search (Repository : in out Repository_Type;
Sheet : in CSS.Core.Sheets.CSSStylesheet;
Rule : access Rule_Type'Class;
Process : access procedure (Prop : in CSS.Core.Properties.CSSProperty;
Match : in Match_Result)) is
procedure Process_Property (Def : in CSS.Core.Styles.CSSStyleRule'Class;
Prop : in CSS.Core.Properties.CSSProperty);
procedure Process_Property (Def : in CSS.Core.Styles.CSSStyleRule'Class;
Prop : in CSS.Core.Properties.CSSProperty) is
pragma Unreferenced (Def);
R : constant Rule_Type_Access := Repository.Find_Property (Prop.Name.all);
Match_Count : Natural;
Count : Natural;
Result : aliased Match_Result;
begin
if R /= null then
Count := Prop.Value.Get_Count;
Match_Count := R.Match (Prop.Value, Result'Access);
if not Result.List.Is_Empty then
if (for some M of Result.List => Is_Rule (M.Rule, Rule)) then
Process (Prop, Result);
end if;
end if;
end if;
end Process_Property;
begin
Repository.Resolve;
Sheet.Iterate_Properties (Process_Property'Access);
end Search;
-- ------------------------------
-- Erase all the rules that have been loaded in the repository.
-- ------------------------------
procedure Clear (Repository : in out Repository_Type) is
begin
Clear (Repository.Rules);
Clear (Repository.Properties);
end Clear;
procedure Clear (Rules : in out Rule_Maps.Map) is
begin
while not Rules.Is_Empty loop
declare
Pos : Rule_Maps.Cursor := Rules.First;
Rule : Rule_Type_Access := Rule_Maps.Element (Pos);
begin
Rule.Used := Rule.Used - 1;
if Rule.Used = 0 then
-- Log.Error (" Free {0} - {1}", Rule_Maps.Key (Pos),
-- System.Address_Image (Rule.all'Address));
Free (Rule);
end if;
Rules.Delete (Pos);
end;
end loop;
end Clear;
overriding
procedure Finalize (Rule : in out Group_Rule_Type) is
begin
Free (Rule.List);
Finalize (Rule_Type (Rule));
end Finalize;
overriding
procedure Finalize (Rule : in out Rule_Type) is
List : Rule_Type_Access := Rule.Next;
Next : Rule_Type_Access;
begin
-- Log.Error (" Finalize {0}", System.Address_Image (Rule'Address));
while List /= null loop
Next := List.Next;
List.Next := null;
Free (List);
List := Next;
end loop;
end Finalize;
overriding
procedure Initialize (Repository : in out Repository_Type) is
begin
Types.Register (Repository);
end Initialize;
-- ------------------------------
-- Release the rules allocated dynamically.
-- ------------------------------
overriding
procedure Finalize (Repository : in out Repository_Type) is
begin
Repository.Clear;
end Finalize;
end CSS.Analysis.Rules;
|
AdaCore/libadalang | Ada | 81,632 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- G N A T . D E B U G _ P O O L S --
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-2016, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with GNAT.IO; use GNAT.IO;
with System.CRTL;
with System.Memory; use System.Memory;
with System.Soft_Links; use System.Soft_Links;
with System.Traceback_Entries;
with GNAT.Debug_Utilities; use GNAT.Debug_Utilities;
with GNAT.HTable;
with GNAT.Traceback; use GNAT.Traceback;
with Ada.Unchecked_Conversion;
package body GNAT.Debug_Pools is
Storage_Alignment : constant := Standard'Maximum_Alignment;
-- Alignment enforced for all the memory chunks returned by Allocate,
-- maximized to make sure that it will be compatible with all types.
--
-- The addresses returned by the underlying low-level allocator (be it
-- 'new' or a straight 'malloc') aren't guaranteed to be that much aligned
-- on some targets, so we manage the needed alignment padding ourselves
-- systematically. Use of a common value for every allocation allows
-- significant simplifications in the code, nevertheless, for improved
-- robustness and efficiency overall.
-- We combine a few internal devices to offer the pool services:
--
-- * A management header attached to each allocated memory block, located
-- right ahead of it, like so:
--
-- Storage Address returned by the pool,
-- aligned on Storage_Alignment
-- v
-- +------+--------+---------------------
-- | ~~~~ | HEADER | USER DATA ... |
-- +------+--------+---------------------
-- <---->
-- alignment
-- padding
--
-- The alignment padding is required
--
-- * A validity bitmap, which holds a validity bit for blocks managed by
-- the pool. Enforcing Storage_Alignment on those blocks allows efficient
-- validity management.
--
-- * A list of currently used blocks.
Max_Ignored_Levels : constant Natural := 10;
-- Maximum number of levels that will be ignored in backtraces. This is so
-- that we still have enough significant levels in the tracebacks returned
-- to the user.
--
-- The value 10 is chosen as being greater than the maximum callgraph
-- in this package. Its actual value is not really relevant, as long as it
-- is high enough to make sure we still have enough frames to return to
-- the user after we have hidden the frames internal to this package.
Disable : Boolean := False;
-- This variable is used to avoid infinite loops, where this package would
-- itself allocate memory and then call itself recursively, forever. Useful
-- when System_Memory_Debug_Pool_Enabled is True.
System_Memory_Debug_Pool_Enabled : Boolean := False;
-- If True, System.Memory allocation uses Debug_Pool
Allow_Unhandled_Memory : Boolean := False;
-- If True, protects Deallocate against releasing memory allocated before
-- System_Memory_Debug_Pool_Enabled was set.
Traceback_Count : Byte_Count := 0;
-- Total number of traceback elements
---------------------------
-- Back Trace Hash Table --
---------------------------
-- This package needs to store one set of tracebacks for each allocation
-- point (when was it allocated or deallocated). This would use too much
-- memory, so the tracebacks are actually stored in a hash table, and
-- we reference elements in this hash table instead.
-- This hash-table will remain empty if the discriminant Stack_Trace_Depth
-- for the pools is set to 0.
-- This table is a global table, that can be shared among all debug pools
-- with no problems.
type Header is range 1 .. 1023;
-- Number of elements in the hash-table
type Tracebacks_Array_Access is access Tracebacks_Array;
type Traceback_Kind is (Alloc, Dealloc, Indirect_Alloc, Indirect_Dealloc);
type Traceback_Htable_Elem;
type Traceback_Htable_Elem_Ptr
is access Traceback_Htable_Elem;
type Traceback_Htable_Elem is record
Traceback : Tracebacks_Array_Access;
Kind : Traceback_Kind;
Count : Natural;
-- Size of the memory allocated/freed at Traceback since last Reset call
Total : Byte_Count;
-- Number of chunk of memory allocated/freed at Traceback since last
-- Reset call.
Frees : Natural;
-- Number of chunk of memory allocated at Traceback, currently freed
-- since last Reset call. (only for Alloc & Indirect_Alloc elements)
Total_Frees : Byte_Count;
-- Size of the memory allocated at Traceback, currently freed since last
-- Reset call. (only for Alloc & Indirect_Alloc elements)
Next : Traceback_Htable_Elem_Ptr;
end record;
-- Subprograms used for the Backtrace_Htable instantiation
procedure Set_Next
(E : Traceback_Htable_Elem_Ptr;
Next : Traceback_Htable_Elem_Ptr);
pragma Inline (Set_Next);
function Next
(E : Traceback_Htable_Elem_Ptr) return Traceback_Htable_Elem_Ptr;
pragma Inline (Next);
function Get_Key
(E : Traceback_Htable_Elem_Ptr) return Tracebacks_Array_Access;
pragma Inline (Get_Key);
function Hash (T : Tracebacks_Array_Access) return Header;
pragma Inline (Hash);
function Equal (K1, K2 : Tracebacks_Array_Access) return Boolean;
-- Why is this not inlined???
-- The hash table for back traces
package Backtrace_Htable is new GNAT.HTable.Static_HTable
(Header_Num => Header,
Element => Traceback_Htable_Elem,
Elmt_Ptr => Traceback_Htable_Elem_Ptr,
Null_Ptr => null,
Set_Next => Set_Next,
Next => Next,
Key => Tracebacks_Array_Access,
Get_Key => Get_Key,
Hash => Hash,
Equal => Equal);
-----------------------
-- Allocations table --
-----------------------
type Allocation_Header;
type Allocation_Header_Access is access Allocation_Header;
type Traceback_Ptr_Or_Address is new System.Address;
-- A type that acts as a C union, and is either a System.Address or a
-- Traceback_Htable_Elem_Ptr.
-- The following record stores extra information that needs to be
-- memorized for each block allocated with the special debug pool.
type Allocation_Header is record
Allocation_Address : System.Address;
-- Address of the block returned by malloc, possibly unaligned
Block_Size : Storage_Offset;
-- Needed only for advanced freeing algorithms (traverse all allocated
-- blocks for potential references). This value is negated when the
-- chunk of memory has been logically freed by the application. This
-- chunk has not been physically released yet.
Alloc_Traceback : Traceback_Htable_Elem_Ptr;
-- ??? comment required
Dealloc_Traceback : Traceback_Ptr_Or_Address;
-- Pointer to the traceback for the allocation (if the memory chunk is
-- still valid), or to the first deallocation otherwise. Make sure this
-- is a thin pointer to save space.
--
-- Dealloc_Traceback is also for blocks that are still allocated to
-- point to the previous block in the list. This saves space in this
-- header, and make manipulation of the lists of allocated pointers
-- faster.
Next : System.Address;
-- Point to the next block of the same type (either allocated or
-- logically freed) in memory. This points to the beginning of the user
-- data, and does not include the header of that block.
end record;
function Header_Of
(Address : System.Address) return Allocation_Header_Access;
pragma Inline (Header_Of);
-- Return the header corresponding to a previously allocated address
function To_Address is new Ada.Unchecked_Conversion
(Traceback_Ptr_Or_Address, System.Address);
function To_Address is new Ada.Unchecked_Conversion
(System.Address, Traceback_Ptr_Or_Address);
function To_Traceback is new Ada.Unchecked_Conversion
(Traceback_Ptr_Or_Address, Traceback_Htable_Elem_Ptr);
function To_Traceback is new Ada.Unchecked_Conversion
(Traceback_Htable_Elem_Ptr, Traceback_Ptr_Or_Address);
Header_Offset : constant Storage_Count :=
(Allocation_Header'Object_Size / System.Storage_Unit);
-- Offset, in bytes, from start of allocation Header to start of User
-- data. The start of user data is assumed to be aligned at least as much
-- as what the header type requires, so applying this offset yields a
-- suitably aligned address as well.
Extra_Allocation : constant Storage_Count :=
(Storage_Alignment - 1 + Header_Offset);
-- Amount we need to secure in addition to the user data for a given
-- allocation request: room for the allocation header plus worst-case
-- alignment padding.
-----------------------
-- Local subprograms --
-----------------------
function Align (Addr : Integer_Address) return Integer_Address;
pragma Inline (Align);
-- Return the next address aligned on Storage_Alignment from Addr.
function Find_Or_Create_Traceback
(Pool : Debug_Pool;
Kind : Traceback_Kind;
Size : Storage_Count;
Ignored_Frame_Start : System.Address;
Ignored_Frame_End : System.Address) return Traceback_Htable_Elem_Ptr;
-- Return an element matching the current traceback (omitting the frames
-- that are in the current package). If this traceback already existed in
-- the htable, a pointer to this is returned to spare memory. Null is
-- returned if the pool is set not to store tracebacks. If the traceback
-- already existed in the table, the count is incremented so that
-- Dump_Tracebacks returns useful results. All addresses up to, and
-- including, an address between Ignored_Frame_Start .. Ignored_Frame_End
-- are ignored.
function Output_File (Pool : Debug_Pool) return File_Type;
pragma Inline (Output_File);
-- Returns file_type on which error messages have to be generated for Pool
procedure Put_Line
(File : File_Type;
Depth : Natural;
Traceback : Tracebacks_Array_Access;
Ignored_Frame_Start : System.Address := System.Null_Address;
Ignored_Frame_End : System.Address := System.Null_Address);
-- Print Traceback to File. If Traceback is null, print the call_chain
-- at the current location, up to Depth levels, ignoring all addresses
-- up to the first one in the range:
-- Ignored_Frame_Start .. Ignored_Frame_End
procedure Stdout_Put (S : String);
-- Wrapper for Put that ensures we always write to stdout instead of the
-- current output file defined in GNAT.IO.
procedure Stdout_Put_Line (S : String);
-- Wrapper for Put_Line that ensures we always write to stdout instead of
-- the current output file defined in GNAT.IO.
procedure Print_Traceback
(Output_File : File_Type;
Prefix : String;
Traceback : Traceback_Htable_Elem_Ptr);
-- Output Prefix & Traceback & EOL. Print nothing if Traceback is null.
procedure Print_Address (File : File_Type; Addr : Address);
-- Output System.Address without using secondary stack.
-- When System.Memory uses Debug_Pool, secondary stack cannot be used
-- during Allocate calls, as some Allocate calls are done to
-- register/initialize a secondary stack for a foreign thread.
-- During these calls, the secondary stack is not available yet.
package Validity is
function Is_Handled (Storage : System.Address) return Boolean;
pragma Inline (Is_Handled);
-- Return True if Storage is the address of a block that the debug pool
-- already had under its control. Used to allow System.Memory to use
-- Debug_Pools
function Is_Valid (Storage : System.Address) return Boolean;
pragma Inline (Is_Valid);
-- Return True if Storage is the address of a block that the debug pool
-- has under its control, in which case Header_Of may be used to access
-- the associated allocation header.
procedure Set_Valid (Storage : System.Address; Value : Boolean);
pragma Inline (Set_Valid);
-- Mark the address Storage as being under control of the memory pool
-- (if Value is True), or not (if Value is False).
Validity_Count : Byte_Count := 0;
-- Total number of validity elements
end Validity;
use Validity;
procedure Set_Dead_Beef
(Storage_Address : System.Address;
Size_In_Storage_Elements : Storage_Count);
-- Set the contents of the memory block pointed to by Storage_Address to
-- the 16#DEADBEEF# pattern. If Size_In_Storage_Elements is not a multiple
-- of the length of this pattern, the last instance may be partial.
procedure Free_Physically (Pool : in out Debug_Pool);
-- Start to physically release some memory to the system, until the amount
-- of logically (but not physically) freed memory is lower than the
-- expected amount in Pool.
procedure Allocate_End;
procedure Deallocate_End;
procedure Dereference_End;
-- These procedures are used as markers when computing the stacktraces,
-- so that addresses in the debug pool itself are not reported to the user.
Code_Address_For_Allocate_End : System.Address;
Code_Address_For_Deallocate_End : System.Address;
Code_Address_For_Dereference_End : System.Address;
-- Taking the address of the above procedures will not work on some
-- architectures (HPUX for instance). Thus we do the same thing that
-- is done in a-except.adb, and get the address of labels instead.
procedure Skip_Levels
(Depth : Natural;
Trace : Tracebacks_Array;
Start : out Natural;
Len : in out Natural;
Ignored_Frame_Start : System.Address;
Ignored_Frame_End : System.Address);
-- Set Start .. Len to the range of values from Trace that should be output
-- to the user. This range of values excludes any address prior to the
-- first one in Ignored_Frame_Start .. Ignored_Frame_End (basically
-- addresses internal to this package). Depth is the number of levels that
-- the user is interested in.
package STBE renames System.Traceback_Entries;
function PC_For (TB_Entry : STBE.Traceback_Entry) return System.Address
renames STBE.PC_For;
-----------
-- Align --
-----------
function Align (Addr : Integer_Address) return Integer_Address is
Factor : constant Integer_Address := Storage_Alignment;
begin
return ((Addr + Factor - 1) / Factor) * Factor;
end Align;
---------------
-- Header_Of --
---------------
function Header_Of (Address : System.Address)
return Allocation_Header_Access
is
function Convert is new Ada.Unchecked_Conversion
(System.Address, Allocation_Header_Access);
begin
return Convert (Address - Header_Offset);
end Header_Of;
--------------
-- Set_Next --
--------------
procedure Set_Next
(E : Traceback_Htable_Elem_Ptr;
Next : Traceback_Htable_Elem_Ptr)
is
begin
E.Next := Next;
end Set_Next;
----------
-- Next --
----------
function Next
(E : Traceback_Htable_Elem_Ptr) return Traceback_Htable_Elem_Ptr is
begin
return E.Next;
end Next;
-----------
-- Equal --
-----------
function Equal (K1, K2 : Tracebacks_Array_Access) return Boolean is
use type Tracebacks_Array;
begin
return K1.all = K2.all;
end Equal;
-------------
-- Get_Key --
-------------
function Get_Key
(E : Traceback_Htable_Elem_Ptr) return Tracebacks_Array_Access
is
begin
return E.Traceback;
end Get_Key;
----------
-- Hash --
----------
function Hash (T : Tracebacks_Array_Access) return Header is
Result : Integer_Address := 0;
begin
for X in T'Range loop
Result := Result + To_Integer (PC_For (T (X)));
end loop;
return Header (1 + Result mod Integer_Address (Header'Last));
end Hash;
-----------------
-- Output_File --
-----------------
function Output_File (Pool : Debug_Pool) return File_Type is
begin
if Pool.Errors_To_Stdout then
return Standard_Output;
else
return Standard_Error;
end if;
end Output_File;
-------------------
-- Print_Address --
-------------------
procedure Print_Address (File : File_Type; Addr : Address) is
begin
-- Warning: secondary stack cannot be used here. When System.Memory
-- implementation uses Debug_Pool, Print_Address can be called during
-- secondary stack creation for foreign threads.
Put (File, Image_C (Addr));
end Print_Address;
--------------
-- Put_Line --
--------------
procedure Put_Line
(File : File_Type;
Depth : Natural;
Traceback : Tracebacks_Array_Access;
Ignored_Frame_Start : System.Address := System.Null_Address;
Ignored_Frame_End : System.Address := System.Null_Address)
is
procedure Print (Tr : Tracebacks_Array);
-- Print the traceback to standard_output
-----------
-- Print --
-----------
procedure Print (Tr : Tracebacks_Array) is
begin
for J in Tr'Range loop
Print_Address (File, PC_For (Tr (J)));
Put (File, ' ');
end loop;
Put (File, ASCII.LF);
end Print;
-- Start of processing for Put_Line
begin
if Traceback = null then
declare
Len : Natural;
Start : Natural;
Trace : aliased Tracebacks_Array (1 .. Depth + Max_Ignored_Levels);
begin
Call_Chain (Trace, Len);
Skip_Levels
(Depth => Depth,
Trace => Trace,
Start => Start,
Len => Len,
Ignored_Frame_Start => Ignored_Frame_Start,
Ignored_Frame_End => Ignored_Frame_End);
Print (Trace (Start .. Len));
end;
else
Print (Traceback.all);
end if;
end Put_Line;
-----------------
-- Skip_Levels --
-----------------
procedure Skip_Levels
(Depth : Natural;
Trace : Tracebacks_Array;
Start : out Natural;
Len : in out Natural;
Ignored_Frame_Start : System.Address;
Ignored_Frame_End : System.Address)
is
begin
Start := Trace'First;
while Start <= Len
and then (PC_For (Trace (Start)) < Ignored_Frame_Start
or else PC_For (Trace (Start)) > Ignored_Frame_End)
loop
Start := Start + 1;
end loop;
Start := Start + 1;
-- Just in case: make sure we have a traceback even if Ignore_Till
-- wasn't found.
if Start > Len then
Start := 1;
end if;
if Len - Start + 1 > Depth then
Len := Depth + Start - 1;
end if;
end Skip_Levels;
------------------------------
-- Find_Or_Create_Traceback --
------------------------------
function Find_Or_Create_Traceback
(Pool : Debug_Pool;
Kind : Traceback_Kind;
Size : Storage_Count;
Ignored_Frame_Start : System.Address;
Ignored_Frame_End : System.Address) return Traceback_Htable_Elem_Ptr
is
begin
if Pool.Stack_Trace_Depth = 0 then
return null;
end if;
declare
Disable_Exit_Value : constant Boolean := Disable;
Elem : Traceback_Htable_Elem_Ptr;
Len : Natural;
Start : Natural;
Trace : aliased Tracebacks_Array
(1 .. Integer (Pool.Stack_Trace_Depth) +
Max_Ignored_Levels);
begin
Disable := True;
Call_Chain (Trace, Len);
Skip_Levels
(Depth => Pool.Stack_Trace_Depth,
Trace => Trace,
Start => Start,
Len => Len,
Ignored_Frame_Start => Ignored_Frame_Start,
Ignored_Frame_End => Ignored_Frame_End);
-- Check if the traceback is already in the table
Elem :=
Backtrace_Htable.Get (Trace (Start .. Len)'Unrestricted_Access);
-- If not, insert it
if Elem = null then
Elem :=
new Traceback_Htable_Elem'
(Traceback =>
new Tracebacks_Array'(Trace (Start .. Len)),
Count => 1,
Kind => Kind,
Total => Byte_Count (Size),
Frees => 0,
Total_Frees => 0,
Next => null);
Traceback_Count := Traceback_Count + 1;
Backtrace_Htable.Set (Elem);
else
Elem.Count := Elem.Count + 1;
Elem.Total := Elem.Total + Byte_Count (Size);
end if;
Disable := Disable_Exit_Value;
return Elem;
exception
when others =>
Disable := Disable_Exit_Value;
raise;
end;
end Find_Or_Create_Traceback;
--------------
-- Validity --
--------------
package body Validity is
-- The validity bits of the allocated blocks are kept in a has table.
-- Each component of the hash table contains the validity bits for a
-- 16 Mbyte memory chunk.
-- The reason the validity bits are kept for chunks of memory rather
-- than in a big array is that on some 64 bit platforms, it may happen
-- that two chunk of allocated data are very far from each other.
Memory_Chunk_Size : constant Integer_Address := 2 ** 24; -- 16 MB
Validity_Divisor : constant := Storage_Alignment * System.Storage_Unit;
Max_Validity_Byte_Index : constant :=
Memory_Chunk_Size / Validity_Divisor;
subtype Validity_Byte_Index is
Integer_Address range 0 .. Max_Validity_Byte_Index - 1;
type Byte is mod 2 ** System.Storage_Unit;
type Validity_Bits_Part is array (Validity_Byte_Index) of Byte;
type Validity_Bits_Part_Ref is access all Validity_Bits_Part;
No_Validity_Bits_Part : constant Validity_Bits_Part_Ref := null;
type Validity_Bits is record
Valid : Validity_Bits_Part_Ref := No_Validity_Bits_Part;
-- True if chunk of memory at this address is currently allocated
Handled : Validity_Bits_Part_Ref := No_Validity_Bits_Part;
-- True if chunk of memory at this address was allocated once after
-- Allow_Unhandled_Memory was set to True. Used to know on Deallocate
-- if chunk of memory should be handled a block allocated by this
-- package.
end record;
type Validity_Bits_Ref is access all Validity_Bits;
No_Validity_Bits : constant Validity_Bits_Ref := null;
Max_Header_Num : constant := 1023;
type Header_Num is range 0 .. Max_Header_Num - 1;
function Hash (F : Integer_Address) return Header_Num;
function Is_Valid_Or_Handled
(Storage : System.Address;
Valid : Boolean) return Boolean;
pragma Inline (Is_Valid_Or_Handled);
-- Internal implementation of Is_Valid and Is_Handled.
-- Valid is used to select Valid or Handled arrays.
package Validy_Htable is new GNAT.HTable.Simple_HTable
(Header_Num => Header_Num,
Element => Validity_Bits_Ref,
No_Element => No_Validity_Bits,
Key => Integer_Address,
Hash => Hash,
Equal => "=");
-- Table to keep the validity and handled bit blocks for the allocated
-- data.
function To_Pointer is new Ada.Unchecked_Conversion
(System.Address, Validity_Bits_Part_Ref);
procedure Memset (A : Address; C : Integer; N : size_t);
pragma Import (C, Memset, "memset");
----------
-- Hash --
----------
function Hash (F : Integer_Address) return Header_Num is
begin
return Header_Num (F mod Max_Header_Num);
end Hash;
-------------------------
-- Is_Valid_Or_Handled --
-------------------------
function Is_Valid_Or_Handled
(Storage : System.Address;
Valid : Boolean) return Boolean is
Int_Storage : constant Integer_Address := To_Integer (Storage);
begin
-- The pool only returns addresses aligned on Storage_Alignment so
-- anything off cannot be a valid block address and we can return
-- early in this case. We actually have to since our data structures
-- map validity bits for such aligned addresses only.
if Int_Storage mod Storage_Alignment /= 0 then
return False;
end if;
declare
Block_Number : constant Integer_Address :=
Int_Storage / Memory_Chunk_Size;
Ptr : constant Validity_Bits_Ref :=
Validy_Htable.Get (Block_Number);
Offset : constant Integer_Address :=
(Int_Storage -
(Block_Number * Memory_Chunk_Size)) /
Storage_Alignment;
Bit : constant Byte :=
2 ** Natural (Offset mod System.Storage_Unit);
begin
if Ptr = No_Validity_Bits then
return False;
else
if Valid then
return (Ptr.Valid (Offset / System.Storage_Unit)
and Bit) /= 0;
else
if Ptr.Handled = No_Validity_Bits_Part then
return False;
else
return (Ptr.Handled (Offset / System.Storage_Unit)
and Bit) /= 0;
end if;
end if;
end if;
end;
end Is_Valid_Or_Handled;
--------------
-- Is_Valid --
--------------
function Is_Valid (Storage : System.Address) return Boolean is
begin
return Is_Valid_Or_Handled (Storage => Storage, Valid => True);
end Is_Valid;
-----------------
-- Is_Handled --
-----------------
function Is_Handled (Storage : System.Address) return Boolean is
begin
return Is_Valid_Or_Handled (Storage => Storage, Valid => False);
end Is_Handled;
---------------
-- Set_Valid --
---------------
procedure Set_Valid (Storage : System.Address; Value : Boolean) is
Int_Storage : constant Integer_Address := To_Integer (Storage);
Block_Number : constant Integer_Address :=
Int_Storage / Memory_Chunk_Size;
Ptr : Validity_Bits_Ref := Validy_Htable.Get (Block_Number);
Offset : constant Integer_Address :=
(Int_Storage - (Block_Number * Memory_Chunk_Size)) /
Storage_Alignment;
Bit : constant Byte :=
2 ** Natural (Offset mod System.Storage_Unit);
procedure Set_Handled;
pragma Inline (Set_Handled);
-- if Allow_Unhandled_Memory set Handled bit in table.
-----------------
-- Set_Handled --
-----------------
procedure Set_Handled is
begin
if Allow_Unhandled_Memory then
if Ptr.Handled = No_Validity_Bits_Part then
Ptr.Handled :=
To_Pointer (Alloc (size_t (Max_Validity_Byte_Index)));
Memset
(A => Ptr.Handled.all'Address,
C => 0,
N => size_t (Max_Validity_Byte_Index));
end if;
Ptr.Handled (Offset / System.Storage_Unit) :=
Ptr.Handled (Offset / System.Storage_Unit) or Bit;
end if;
end Set_Handled;
-- Start of processing for Set_Valid
begin
if Ptr = No_Validity_Bits then
-- First time in this memory area: allocate a new block and put
-- it in the table.
if Value then
Ptr := new Validity_Bits;
Validity_Count := Validity_Count + 1;
Ptr.Valid :=
To_Pointer (Alloc (size_t (Max_Validity_Byte_Index)));
Validy_Htable.Set (Block_Number, Ptr);
Memset
(A => Ptr.Valid.all'Address,
C => 0,
N => size_t (Max_Validity_Byte_Index));
Ptr.Valid (Offset / System.Storage_Unit) := Bit;
Set_Handled;
end if;
else
if Value then
Ptr.Valid (Offset / System.Storage_Unit) :=
Ptr.Valid (Offset / System.Storage_Unit) or Bit;
Set_Handled;
else
Ptr.Valid (Offset / System.Storage_Unit) :=
Ptr.Valid (Offset / System.Storage_Unit) and (not Bit);
end if;
end if;
end Set_Valid;
end Validity;
--------------
-- Allocate --
--------------
procedure Allocate
(Pool : in out Debug_Pool;
Storage_Address : out Address;
Size_In_Storage_Elements : Storage_Count;
Alignment : Storage_Count)
is
pragma Unreferenced (Alignment);
-- Ignored, we always force Storage_Alignment
type Local_Storage_Array is new Storage_Array
(1 .. Size_In_Storage_Elements + Extra_Allocation);
type Ptr is access Local_Storage_Array;
-- On some systems, we might want to physically protect pages against
-- writing when they have been freed (of course, this is expensive in
-- terms of wasted memory). To do that, all we should have to do it to
-- set the size of this array to the page size. See mprotect().
Current : Byte_Count;
P : Ptr;
Trace : Traceback_Htable_Elem_Ptr;
Reset_Disable_At_Exit : Boolean := False;
begin
<<Allocate_Label>>
Lock_Task.all;
if Disable then
Storage_Address :=
System.CRTL.malloc (System.CRTL.size_t (Size_In_Storage_Elements));
Unlock_Task.all;
return;
end if;
Reset_Disable_At_Exit := True;
Disable := True;
Pool.Alloc_Count := Pool.Alloc_Count + 1;
-- If necessary, start physically releasing memory. The reason this is
-- done here, although Pool.Logically_Deallocated has not changed above,
-- is so that we do this only after a series of deallocations (e.g loop
-- that deallocates a big array). If we were doing that in Deallocate,
-- we might be physically freeing memory several times during the loop,
-- which is expensive.
if Pool.Logically_Deallocated >
Byte_Count (Pool.Maximum_Logically_Freed_Memory)
then
Free_Physically (Pool);
end if;
-- Use standard (i.e. through malloc) allocations. This automatically
-- raises Storage_Error if needed. We also try once more to physically
-- release memory, so that even marked blocks, in the advanced scanning,
-- are freed. Note that we do not initialize the storage array since it
-- is not necessary to do so (however this will cause bogus valgrind
-- warnings, which should simply be ignored).
begin
P := new Local_Storage_Array;
exception
when Storage_Error =>
Free_Physically (Pool);
P := new Local_Storage_Array;
end;
-- Compute Storage_Address, aimed at receiving user data. We need room
-- for the allocation header just ahead of the user data space plus
-- alignment padding so Storage_Address is aligned on Storage_Alignment,
-- like so:
--
-- Storage_Address, aligned
-- on Storage_Alignment
-- v
-- | ~~~~ | Header | User data ... |
-- ^........^
-- Header_Offset
--
-- Header_Offset is fixed so moving back and forth between user data
-- and allocation header is straightforward. The value is also such
-- that the header type alignment is honored when starting from
-- Default_alignment.
-- For the purpose of computing Storage_Address, we just do as if the
-- header was located first, followed by the alignment padding:
Storage_Address :=
To_Address (Align (To_Integer (P.all'Address) +
Integer_Address (Header_Offset)));
-- Computation is done in Integer_Address, not Storage_Offset, because
-- the range of Storage_Offset may not be large enough.
pragma Assert ((Storage_Address - System.Null_Address)
mod Storage_Alignment = 0);
pragma Assert (Storage_Address + Size_In_Storage_Elements
<= P.all'Address + P'Length);
Trace :=
Find_Or_Create_Traceback
(Pool => Pool,
Kind => Alloc,
Size => Size_In_Storage_Elements,
Ignored_Frame_Start => Allocate_Label'Address,
Ignored_Frame_End => Code_Address_For_Allocate_End);
pragma Warnings (Off);
-- Turn warning on alignment for convert call off. We know that in fact
-- this conversion is safe since P itself is always aligned on
-- Storage_Alignment.
Header_Of (Storage_Address).all :=
(Allocation_Address => P.all'Address,
Alloc_Traceback => Trace,
Dealloc_Traceback => To_Traceback (null),
Next => Pool.First_Used_Block,
Block_Size => Size_In_Storage_Elements);
pragma Warnings (On);
-- Link this block in the list of used blocks. This will be used to list
-- memory leaks in Print_Info, and for the advanced schemes of
-- Physical_Free, where we want to traverse all allocated blocks and
-- search for possible references.
-- We insert in front, since most likely we'll be freeing the most
-- recently allocated blocks first (the older one might stay allocated
-- for the whole life of the application).
if Pool.First_Used_Block /= System.Null_Address then
Header_Of (Pool.First_Used_Block).Dealloc_Traceback :=
To_Address (Storage_Address);
end if;
Pool.First_Used_Block := Storage_Address;
-- Mark the new address as valid
Set_Valid (Storage_Address, True);
if Pool.Low_Level_Traces then
Put (Output_File (Pool),
"info: Allocated"
& Storage_Count'Image (Size_In_Storage_Elements)
& " bytes at ");
Print_Address (Output_File (Pool), Storage_Address);
Put (Output_File (Pool),
" (physically:"
& Storage_Count'Image (Local_Storage_Array'Length)
& " bytes at ");
Print_Address (Output_File (Pool), P.all'Address);
Put (Output_File (Pool),
"), at ");
Put_Line (Output_File (Pool), Pool.Stack_Trace_Depth, null,
Allocate_Label'Address,
Code_Address_For_Deallocate_End);
end if;
-- Update internal data
Pool.Allocated :=
Pool.Allocated + Byte_Count (Size_In_Storage_Elements);
Current := Pool.Current_Water_Mark;
if Current > Pool.High_Water then
Pool.High_Water := Current;
end if;
Disable := False;
Unlock_Task.all;
exception
when others =>
if Reset_Disable_At_Exit then
Disable := False;
end if;
Unlock_Task.all;
raise;
end Allocate;
------------------
-- Allocate_End --
------------------
-- DO NOT MOVE, this must be right after Allocate. This is similar to what
-- is done in a-except, so that we can hide the traceback frames internal
-- to this package
procedure Allocate_End is
begin
<<Allocate_End_Label>>
Code_Address_For_Allocate_End := Allocate_End_Label'Address;
end Allocate_End;
-------------------
-- Set_Dead_Beef --
-------------------
procedure Set_Dead_Beef
(Storage_Address : System.Address;
Size_In_Storage_Elements : Storage_Count)
is
Dead_Bytes : constant := 4;
type Data is mod 2 ** (Dead_Bytes * 8);
for Data'Size use Dead_Bytes * 8;
Dead : constant Data := 16#DEAD_BEEF#;
type Dead_Memory is array
(1 .. Size_In_Storage_Elements / Dead_Bytes) of Data;
type Mem_Ptr is access Dead_Memory;
type Byte is mod 2 ** 8;
for Byte'Size use 8;
type Dead_Memory_Bytes is array (0 .. 2) of Byte;
type Dead_Memory_Bytes_Ptr is access Dead_Memory_Bytes;
function From_Ptr is new Ada.Unchecked_Conversion
(System.Address, Mem_Ptr);
function From_Ptr is new Ada.Unchecked_Conversion
(System.Address, Dead_Memory_Bytes_Ptr);
M : constant Mem_Ptr := From_Ptr (Storage_Address);
M2 : Dead_Memory_Bytes_Ptr;
Modulo : constant Storage_Count :=
Size_In_Storage_Elements mod Dead_Bytes;
begin
M.all := (others => Dead);
-- Any bytes left (up to three of them)
if Modulo /= 0 then
M2 := From_Ptr (Storage_Address + M'Length * Dead_Bytes);
M2 (0) := 16#DE#;
if Modulo >= 2 then
M2 (1) := 16#AD#;
if Modulo >= 3 then
M2 (2) := 16#BE#;
end if;
end if;
end if;
end Set_Dead_Beef;
---------------------
-- Free_Physically --
---------------------
procedure Free_Physically (Pool : in out Debug_Pool) is
type Byte is mod 256;
type Byte_Access is access Byte;
function To_Byte is new Ada.Unchecked_Conversion
(System.Address, Byte_Access);
type Address_Access is access System.Address;
function To_Address_Access is new Ada.Unchecked_Conversion
(System.Address, Address_Access);
In_Use_Mark : constant Byte := 16#D#;
Free_Mark : constant Byte := 16#F#;
Total_Freed : Storage_Count := 0;
procedure Reset_Marks;
-- Unmark all the logically freed blocks, so that they are considered
-- for physical deallocation
procedure Mark
(H : Allocation_Header_Access; A : System.Address; In_Use : Boolean);
-- Mark the user data block starting at A. For a block of size zero,
-- nothing is done. For a block with a different size, the first byte
-- is set to either "D" (in use) or "F" (free).
function Marked (A : System.Address) return Boolean;
-- Return true if the user data block starting at A might be in use
-- somewhere else
procedure Mark_Blocks;
-- Traverse all allocated blocks, and search for possible references
-- to logically freed blocks. Mark them appropriately
procedure Free_Blocks (Ignore_Marks : Boolean);
-- Physically release blocks. Only the blocks that haven't been marked
-- will be released, unless Ignore_Marks is true.
-----------------
-- Free_Blocks --
-----------------
procedure Free_Blocks (Ignore_Marks : Boolean) is
Header : Allocation_Header_Access;
Tmp : System.Address := Pool.First_Free_Block;
Next : System.Address;
Previous : System.Address := System.Null_Address;
begin
while Tmp /= System.Null_Address
and then
not (Total_Freed > Pool.Minimum_To_Free
and Pool.Logically_Deallocated <
Byte_Count (Pool.Maximum_Logically_Freed_Memory))
loop
Header := Header_Of (Tmp);
-- If we know, or at least assume, the block is no longer
-- referenced anywhere, we can free it physically.
if Ignore_Marks or else not Marked (Tmp) then
declare
pragma Suppress (All_Checks);
-- Suppress the checks on this section. If they are overflow
-- errors, it isn't critical, and we'd rather avoid a
-- Constraint_Error in that case.
begin
-- Note that block_size < zero for freed blocks
Pool.Physically_Deallocated :=
Pool.Physically_Deallocated -
Byte_Count (Header.Block_Size);
Pool.Logically_Deallocated :=
Pool.Logically_Deallocated +
Byte_Count (Header.Block_Size);
Total_Freed := Total_Freed - Header.Block_Size;
end;
Next := Header.Next;
if Pool.Low_Level_Traces then
Put
(Output_File (Pool),
"info: Freeing physical memory "
& Storage_Count'Image
((abs Header.Block_Size) + Extra_Allocation)
& " bytes at ");
Print_Address (Output_File (Pool),
Header.Allocation_Address);
Put_Line (Output_File (Pool), "");
end if;
if System_Memory_Debug_Pool_Enabled then
System.CRTL.free (Header.Allocation_Address);
else
System.Memory.Free (Header.Allocation_Address);
end if;
Set_Valid (Tmp, False);
-- Remove this block from the list
if Previous = System.Null_Address then
Pool.First_Free_Block := Next;
else
Header_Of (Previous).Next := Next;
end if;
Tmp := Next;
else
Previous := Tmp;
Tmp := Header.Next;
end if;
end loop;
end Free_Blocks;
----------
-- Mark --
----------
procedure Mark
(H : Allocation_Header_Access;
A : System.Address;
In_Use : Boolean)
is
begin
if H.Block_Size /= 0 then
To_Byte (A).all := (if In_Use then In_Use_Mark else Free_Mark);
end if;
end Mark;
-----------------
-- Mark_Blocks --
-----------------
procedure Mark_Blocks is
Tmp : System.Address := Pool.First_Used_Block;
Previous : System.Address;
Last : System.Address;
Pointed : System.Address;
Header : Allocation_Header_Access;
begin
-- For each allocated block, check its contents. Things that look
-- like a possible address are used to mark the blocks so that we try
-- and keep them, for better detection in case of invalid access.
-- This mechanism is far from being fool-proof: it doesn't check the
-- stacks of the threads, doesn't check possible memory allocated not
-- under control of this debug pool. But it should allow us to catch
-- more cases.
while Tmp /= System.Null_Address loop
Previous := Tmp;
Last := Tmp + Header_Of (Tmp).Block_Size;
while Previous < Last loop
-- ??? Should we move byte-per-byte, or consider that addresses
-- are always aligned on 4-bytes boundaries ? Let's use the
-- fastest for now.
Pointed := To_Address_Access (Previous).all;
if Is_Valid (Pointed) then
Header := Header_Of (Pointed);
-- Do not even attempt to mark blocks in use. That would
-- screw up the whole application, of course.
if Header.Block_Size < 0 then
Mark (Header, Pointed, In_Use => True);
end if;
end if;
Previous := Previous + System.Address'Size;
end loop;
Tmp := Header_Of (Tmp).Next;
end loop;
end Mark_Blocks;
------------
-- Marked --
------------
function Marked (A : System.Address) return Boolean is
begin
return To_Byte (A).all = In_Use_Mark;
end Marked;
-----------------
-- Reset_Marks --
-----------------
procedure Reset_Marks is
Current : System.Address := Pool.First_Free_Block;
Header : Allocation_Header_Access;
begin
while Current /= System.Null_Address loop
Header := Header_Of (Current);
Mark (Header, Current, False);
Current := Header.Next;
end loop;
end Reset_Marks;
-- Start of processing for Free_Physically
begin
Lock_Task.all;
if Pool.Advanced_Scanning then
-- Reset the mark for each freed block
Reset_Marks;
Mark_Blocks;
end if;
Free_Blocks (Ignore_Marks => not Pool.Advanced_Scanning);
-- The contract is that we need to free at least Minimum_To_Free bytes,
-- even if this means freeing marked blocks in the advanced scheme
if Total_Freed < Pool.Minimum_To_Free
and then Pool.Advanced_Scanning
then
Pool.Marked_Blocks_Deallocated := True;
Free_Blocks (Ignore_Marks => True);
end if;
Unlock_Task.all;
exception
when others =>
Unlock_Task.all;
raise;
end Free_Physically;
--------------
-- Get_Size --
--------------
procedure Get_Size
(Storage_Address : Address;
Size_In_Storage_Elements : out Storage_Count;
Valid : out Boolean) is
begin
Lock_Task.all;
Valid := Is_Valid (Storage_Address);
if Is_Valid (Storage_Address) then
declare
Header : constant Allocation_Header_Access :=
Header_Of (Storage_Address);
begin
if Header.Block_Size >= 0 then
Valid := True;
Size_In_Storage_Elements := Header.Block_Size;
else
Valid := False;
end if;
end;
else
Valid := False;
end if;
Unlock_Task.all;
exception
when others =>
Unlock_Task.all;
raise;
end Get_Size;
---------------------
-- Print_Traceback --
---------------------
procedure Print_Traceback
(Output_File : File_Type;
Prefix : String;
Traceback : Traceback_Htable_Elem_Ptr) is
begin
if Traceback /= null then
Put (Output_File, Prefix);
Put_Line (Output_File, 0, Traceback.Traceback);
end if;
end Print_Traceback;
----------------
-- Deallocate --
----------------
procedure Deallocate
(Pool : in out Debug_Pool;
Storage_Address : Address;
Size_In_Storage_Elements : Storage_Count;
Alignment : Storage_Count)
is
pragma Unreferenced (Alignment);
Unlock_Task_Required : Boolean := False;
Header : constant Allocation_Header_Access :=
Header_Of (Storage_Address);
Valid : Boolean;
Previous : System.Address;
begin
<<Deallocate_Label>>
Lock_Task.all;
Unlock_Task_Required := True;
Valid := Is_Valid (Storage_Address);
if not Valid then
Unlock_Task_Required := False;
Unlock_Task.all;
if Storage_Address = System.Null_Address then
if Pool.Raise_Exceptions and then
Size_In_Storage_Elements /= Storage_Count'Last
then
raise Freeing_Not_Allocated_Storage;
else
Put (Output_File (Pool),
"error: Freeing Null_Address, at ");
Put_Line (Output_File (Pool), Pool.Stack_Trace_Depth, null,
Deallocate_Label'Address,
Code_Address_For_Deallocate_End);
return;
end if;
end if;
if Allow_Unhandled_Memory and then not Is_Handled (Storage_Address)
then
System.CRTL.free (Storage_Address);
return;
end if;
if Pool.Raise_Exceptions and then
Size_In_Storage_Elements /= Storage_Count'Last
then
raise Freeing_Not_Allocated_Storage;
else
Put (Output_File (Pool),
"error: Freeing not allocated storage, at ");
Put_Line (Output_File (Pool), Pool.Stack_Trace_Depth, null,
Deallocate_Label'Address,
Code_Address_For_Deallocate_End);
end if;
elsif Header.Block_Size < 0 then
Unlock_Task_Required := False;
Unlock_Task.all;
if Pool.Raise_Exceptions then
raise Freeing_Deallocated_Storage;
else
Put (Output_File (Pool),
"error: Freeing already deallocated storage, at ");
Put_Line (Output_File (Pool), Pool.Stack_Trace_Depth, null,
Deallocate_Label'Address,
Code_Address_For_Deallocate_End);
Print_Traceback (Output_File (Pool),
" Memory already deallocated at ",
To_Traceback (Header.Dealloc_Traceback));
Print_Traceback (Output_File (Pool), " Memory was allocated at ",
Header.Alloc_Traceback);
end if;
else
-- Some sort of codegen problem or heap corruption caused the
-- Size_In_Storage_Elements to be wrongly computed.
-- The code below is all based on the assumption that Header.all
-- is not corrupted, such that the error is non-fatal.
if Header.Block_Size /= Size_In_Storage_Elements and then
Size_In_Storage_Elements /= Storage_Count'Last
then
Put_Line (Output_File (Pool),
"error: Deallocate size "
& Storage_Count'Image (Size_In_Storage_Elements)
& " does not match allocate size "
& Storage_Count'Image (Header.Block_Size));
end if;
if Pool.Low_Level_Traces then
Put (Output_File (Pool),
"info: Deallocated"
& Storage_Count'Image (Header.Block_Size)
& " bytes at ");
Print_Address (Output_File (Pool), Storage_Address);
Put (Output_File (Pool),
" (physically"
& Storage_Count'Image (Header.Block_Size + Extra_Allocation)
& " bytes at ");
Print_Address (Output_File (Pool), Header.Allocation_Address);
Put (Output_File (Pool), "), at ");
Put_Line (Output_File (Pool), Pool.Stack_Trace_Depth, null,
Deallocate_Label'Address,
Code_Address_For_Deallocate_End);
Print_Traceback (Output_File (Pool), " Memory was allocated at ",
Header.Alloc_Traceback);
end if;
-- Remove this block from the list of used blocks
Previous :=
To_Address (Header.Dealloc_Traceback);
if Previous = System.Null_Address then
Pool.First_Used_Block := Header_Of (Pool.First_Used_Block).Next;
if Pool.First_Used_Block /= System.Null_Address then
Header_Of (Pool.First_Used_Block).Dealloc_Traceback :=
To_Traceback (null);
end if;
else
Header_Of (Previous).Next := Header.Next;
if Header.Next /= System.Null_Address then
Header_Of
(Header.Next).Dealloc_Traceback := To_Address (Previous);
end if;
end if;
-- Update the Alloc_Traceback Frees/Total_Frees members (if present)
if Header.Alloc_Traceback /= null then
Header.Alloc_Traceback.Frees := Header.Alloc_Traceback.Frees + 1;
Header.Alloc_Traceback.Total_Frees :=
Header.Alloc_Traceback.Total_Frees +
Byte_Count (Header.Block_Size);
end if;
Pool.Free_Count := Pool.Free_Count + 1;
-- Update the header
Header.all :=
(Allocation_Address => Header.Allocation_Address,
Alloc_Traceback => Header.Alloc_Traceback,
Dealloc_Traceback => To_Traceback
(Find_Or_Create_Traceback
(Pool, Dealloc,
Header.Block_Size,
Deallocate_Label'Address,
Code_Address_For_Deallocate_End)),
Next => System.Null_Address,
Block_Size => -Header.Block_Size);
if Pool.Reset_Content_On_Free then
Set_Dead_Beef (Storage_Address, -Header.Block_Size);
end if;
Pool.Logically_Deallocated :=
Pool.Logically_Deallocated + Byte_Count (-Header.Block_Size);
-- Link this free block with the others (at the end of the list, so
-- that we can start releasing the older blocks first later on).
if Pool.First_Free_Block = System.Null_Address then
Pool.First_Free_Block := Storage_Address;
Pool.Last_Free_Block := Storage_Address;
else
Header_Of (Pool.Last_Free_Block).Next := Storage_Address;
Pool.Last_Free_Block := Storage_Address;
end if;
-- Do not physically release the memory here, but in Alloc.
-- See comment there for details.
Unlock_Task_Required := False;
Unlock_Task.all;
end if;
exception
when others =>
if Unlock_Task_Required then
Unlock_Task.all;
end if;
raise;
end Deallocate;
--------------------
-- Deallocate_End --
--------------------
-- DO NOT MOVE, this must be right after Deallocate
-- See Allocate_End
-- This is making assumptions about code order that may be invalid ???
procedure Deallocate_End is
begin
<<Deallocate_End_Label>>
Code_Address_For_Deallocate_End := Deallocate_End_Label'Address;
end Deallocate_End;
-----------------
-- Dereference --
-----------------
procedure Dereference
(Pool : in out Debug_Pool;
Storage_Address : Address;
Size_In_Storage_Elements : Storage_Count;
Alignment : Storage_Count)
is
pragma Unreferenced (Alignment, Size_In_Storage_Elements);
Valid : constant Boolean := Is_Valid (Storage_Address);
Header : Allocation_Header_Access;
begin
-- Locking policy: we do not do any locking in this procedure. The
-- tables are only read, not written to, and although a problem might
-- appear if someone else is modifying the tables at the same time, this
-- race condition is not intended to be detected by this storage_pool (a
-- now invalid pointer would appear as valid). Instead, we prefer
-- optimum performance for dereferences.
<<Dereference_Label>>
if not Valid then
if Pool.Raise_Exceptions then
raise Accessing_Not_Allocated_Storage;
else
Put (Output_File (Pool),
"error: Accessing not allocated storage, at ");
Put_Line (Output_File (Pool), Pool.Stack_Trace_Depth, null,
Dereference_Label'Address,
Code_Address_For_Dereference_End);
end if;
else
Header := Header_Of (Storage_Address);
if Header.Block_Size < 0 then
if Pool.Raise_Exceptions then
raise Accessing_Deallocated_Storage;
else
Put (Output_File (Pool),
"error: Accessing deallocated storage, at ");
Put_Line
(Output_File (Pool), Pool.Stack_Trace_Depth, null,
Dereference_Label'Address,
Code_Address_For_Dereference_End);
Print_Traceback (Output_File (Pool), " First deallocation at ",
To_Traceback (Header.Dealloc_Traceback));
Print_Traceback (Output_File (Pool), " Initial allocation at ",
Header.Alloc_Traceback);
end if;
end if;
end if;
end Dereference;
---------------------
-- Dereference_End --
---------------------
-- DO NOT MOVE: this must be right after Dereference
-- See Allocate_End
-- This is making assumptions about code order that may be invalid ???
procedure Dereference_End is
begin
<<Dereference_End_Label>>
Code_Address_For_Dereference_End := Dereference_End_Label'Address;
end Dereference_End;
----------------
-- Print_Info --
----------------
procedure Print_Info
(Pool : Debug_Pool;
Cumulate : Boolean := False;
Display_Slots : Boolean := False;
Display_Leaks : Boolean := False)
is
package Backtrace_Htable_Cumulate is new GNAT.HTable.Static_HTable
(Header_Num => Header,
Element => Traceback_Htable_Elem,
Elmt_Ptr => Traceback_Htable_Elem_Ptr,
Null_Ptr => null,
Set_Next => Set_Next,
Next => Next,
Key => Tracebacks_Array_Access,
Get_Key => Get_Key,
Hash => Hash,
Equal => Equal);
-- This needs a comment ??? probably some of the ones below do too???
Data : Traceback_Htable_Elem_Ptr;
Elem : Traceback_Htable_Elem_Ptr;
Current : System.Address;
Header : Allocation_Header_Access;
K : Traceback_Kind;
begin
Put_Line
("Total allocated bytes : " &
Byte_Count'Image (Pool.Allocated));
Put_Line
("Total logically deallocated bytes : " &
Byte_Count'Image (Pool.Logically_Deallocated));
Put_Line
("Total physically deallocated bytes : " &
Byte_Count'Image (Pool.Physically_Deallocated));
if Pool.Marked_Blocks_Deallocated then
Put_Line ("Marked blocks were physically deallocated. This is");
Put_Line ("potentially dangerous, and you might want to run");
Put_Line ("again with a lower value of Minimum_To_Free");
end if;
Put_Line
("Current Water Mark: " &
Byte_Count'Image (Pool.Current_Water_Mark));
Put_Line
("High Water Mark: " &
Byte_Count'Image (Pool.High_Water));
Put_Line ("");
if Display_Slots then
Data := Backtrace_Htable.Get_First;
while Data /= null loop
if Data.Kind in Alloc .. Dealloc then
Elem :=
new Traceback_Htable_Elem'
(Traceback => new Tracebacks_Array'(Data.Traceback.all),
Count => Data.Count,
Kind => Data.Kind,
Total => Data.Total,
Frees => Data.Frees,
Total_Frees => Data.Total_Frees,
Next => null);
Backtrace_Htable_Cumulate.Set (Elem);
if Cumulate then
K := (if Data.Kind = Alloc then Indirect_Alloc
else Indirect_Dealloc);
-- Propagate the direct call to all its parents
for T in Data.Traceback'First + 1 .. Data.Traceback'Last loop
Elem := Backtrace_Htable_Cumulate.Get
(Data.Traceback
(T .. Data.Traceback'Last)'Unrestricted_Access);
-- If not, insert it
if Elem = null then
Elem := new Traceback_Htable_Elem'
(Traceback => new Tracebacks_Array'
(Data.Traceback (T .. Data.Traceback'Last)),
Count => Data.Count,
Kind => K,
Total => Data.Total,
Frees => Data.Frees,
Total_Frees => Data.Total_Frees,
Next => null);
Backtrace_Htable_Cumulate.Set (Elem);
-- Properly take into account that the subprograms
-- indirectly called might be doing either allocations
-- or deallocations. This needs to be reflected in the
-- counts.
else
Elem.Count := Elem.Count + Data.Count;
if K = Elem.Kind then
Elem.Total := Elem.Total + Data.Total;
elsif Elem.Total > Data.Total then
Elem.Total := Elem.Total - Data.Total;
else
Elem.Kind := K;
Elem.Total := Data.Total - Elem.Total;
end if;
end if;
end loop;
end if;
Data := Backtrace_Htable.Get_Next;
end if;
end loop;
Put_Line ("List of allocations/deallocations: ");
Data := Backtrace_Htable_Cumulate.Get_First;
while Data /= null loop
case Data.Kind is
when Alloc => Put ("alloc (count:");
when Indirect_Alloc => Put ("indirect alloc (count:");
when Dealloc => Put ("free (count:");
when Indirect_Dealloc => Put ("indirect free (count:");
end case;
Put (Natural'Image (Data.Count) & ", total:" &
Byte_Count'Image (Data.Total) & ") ");
for T in Data.Traceback'Range loop
Put (Image_C (PC_For (Data.Traceback (T))) & ' ');
end loop;
Put_Line ("");
Data := Backtrace_Htable_Cumulate.Get_Next;
end loop;
Backtrace_Htable_Cumulate.Reset;
end if;
if Display_Leaks then
Put_Line ("");
Put_Line ("List of not deallocated blocks:");
-- Do not try to group the blocks with the same stack traces
-- together. This is done by the gnatmem output.
Current := Pool.First_Used_Block;
while Current /= System.Null_Address loop
Header := Header_Of (Current);
Put ("Size: " & Storage_Count'Image (Header.Block_Size) & " at: ");
if Header.Alloc_Traceback /= null then
for T in Header.Alloc_Traceback.Traceback'Range loop
Put (Image_C
(PC_For (Header.Alloc_Traceback.Traceback (T))) & ' ');
end loop;
end if;
Put_Line ("");
Current := Header.Next;
end loop;
end if;
end Print_Info;
----------
-- Dump --
----------
procedure Dump
(Pool : Debug_Pool;
Size : Positive;
Report : Report_Type := All_Reports) is
Total_Freed : constant Byte_Count :=
Pool.Logically_Deallocated + Pool.Physically_Deallocated;
procedure Do_Report (Sort : Report_Type);
-- Do a specific type of report
procedure Do_Report (Sort : Report_Type) is
Elem : Traceback_Htable_Elem_Ptr;
Bigger : Boolean;
Grand_Total : Float;
Max : array (1 .. Size) of Traceback_Htable_Elem_Ptr :=
(others => null);
-- Sorted array for the biggest memory users
begin
Put_Line ("");
case Sort is
when All_Reports
| Memory_Usage
=>
Put_Line (Size'Img & " biggest memory users at this time:");
Put_Line ("Results include bytes and chunks still allocated");
Grand_Total := Float (Pool.Current_Water_Mark);
when Allocations_Count =>
Put_Line (Size'Img & " biggest number of live allocations:");
Put_Line ("Results include bytes and chunks still allocated");
Grand_Total := Float (Pool.Current_Water_Mark);
when Sort_Total_Allocs =>
Put_Line (Size'Img & " biggest number of allocations:");
Put_Line ("Results include total bytes and chunks allocated,");
Put_Line ("even if no longer allocated - Deallocations are"
& " ignored");
Grand_Total := Float (Pool.Allocated);
when Marked_Blocks =>
Put_Line ("Special blocks marked by Mark_Traceback");
Grand_Total := 0.0;
end case;
Elem := Backtrace_Htable.Get_First;
while Elem /= null loop
-- Handle only alloc elememts
if Elem.Kind = Alloc then
-- Ignore small blocks (depending on the sorting criteria) to
-- gain speed.
if (Sort = Memory_Usage
and then Elem.Total - Elem.Total_Frees >= 1_000)
or else (Sort = Allocations_Count
and then Elem.Count - Elem.Frees >= 1)
or else (Sort = Sort_Total_Allocs and then Elem.Count > 1)
or else (Sort = Marked_Blocks
and then Elem.Total = 0)
then
if Sort = Marked_Blocks then
Grand_Total := Grand_Total + Float (Elem.Count);
end if;
for M in Max'Range loop
Bigger := Max (M) = null;
if not Bigger then
case Sort is
when All_Reports
| Memory_Usage
=>
Bigger :=
Max (M).Total - Max (M).Total_Frees
< Elem.Total - Elem.Total_Frees;
when Allocations_Count =>
Bigger :=
Max (M).Count - Max (M).Frees
< Elem.Count - Elem.Frees;
when Marked_Blocks
| Sort_Total_Allocs
=>
Bigger := Max (M).Count < Elem.Count;
end case;
end if;
if Bigger then
Max (M + 1 .. Max'Last) := Max (M .. Max'Last - 1);
Max (M) := Elem;
exit;
end if;
end loop;
end if;
end if;
Elem := Backtrace_Htable.Get_Next;
end loop;
if Grand_Total = 0.0 then
Grand_Total := 1.0;
end if;
for M in Max'Range loop
exit when Max (M) = null;
declare
type Percent is delta 0.1 range 0.0 .. 100.0;
Total : Byte_Count;
P : Percent;
begin
case Sort is
when All_Reports
| Allocations_Count
| Memory_Usage
=>
Total := Max (M).Total - Max (M).Total_Frees;
when Sort_Total_Allocs =>
Total := Max (M).Total;
when Marked_Blocks =>
Total := Byte_Count (Max (M).Count);
end case;
P := Percent (100.0 * Float (Total) / Grand_Total);
case Sort is
when Memory_Usage | Allocations_Count | All_Reports =>
declare
Count : constant Natural :=
Max (M).Count - Max (M).Frees;
begin
Put (P'Img & "%:" & Total'Img & " bytes in"
& Count'Img & " chunks at");
end;
when Sort_Total_Allocs =>
Put (P'Img & "%:" & Total'Img & " bytes in"
& Max (M).Count'Img & " chunks at");
when Marked_Blocks =>
Put (P'Img & "%:"
& Max (M).Count'Img & " chunks /"
& Integer (Grand_Total)'Img & " at");
end case;
end;
for J in Max (M).Traceback'Range loop
Put (" " & Image_C (PC_For (Max (M).Traceback (J))));
end loop;
Put_Line ("");
end loop;
end Do_Report;
begin
Put_Line ("Traceback elements allocated: " & Traceback_Count'Img);
Put_Line ("Validity elements allocated: " & Validity_Count'Img);
Put_Line ("");
Put_Line ("Ada Allocs:" & Pool.Allocated'Img
& " bytes in" & Pool.Alloc_Count'Img & " chunks");
Put_Line ("Ada Free:" & Total_Freed'Img & " bytes in" &
Pool.Free_Count'Img
& " chunks");
Put_Line ("Ada Current watermark: "
& Byte_Count'Image (Pool.Current_Water_Mark)
& " in" & Byte_Count'Image (Pool.Alloc_Count -
Pool.Free_Count) & " chunks");
Put_Line ("Ada High watermark: " & Pool.High_Water_Mark'Img);
case Report is
when All_Reports =>
for Sort in Report_Type loop
if Sort /= All_Reports then
Do_Report (Sort);
end if;
end loop;
when others =>
Do_Report (Report);
end case;
end Dump;
-----------------
-- Dump_Stdout --
-----------------
procedure Dump_Stdout
(Pool : Debug_Pool;
Size : Positive;
Report : Report_Type := All_Reports)
is
procedure Internal is new Dump
(Put_Line => Stdout_Put_Line,
Put => Stdout_Put);
-- Start of processing for Dump_Stdout
begin
Internal (Pool, Size, Report);
end Dump_Stdout;
-----------
-- Reset --
-----------
procedure Reset is
Elem : Traceback_Htable_Elem_Ptr;
begin
Elem := Backtrace_Htable.Get_First;
while Elem /= null loop
Elem.Count := 0;
Elem.Frees := 0;
Elem.Total := 0;
Elem.Total_Frees := 0;
Elem := Backtrace_Htable.Get_Next;
end loop;
end Reset;
------------------
-- Storage_Size --
------------------
function Storage_Size (Pool : Debug_Pool) return Storage_Count is
pragma Unreferenced (Pool);
begin
return Storage_Count'Last;
end Storage_Size;
---------------------
-- High_Water_Mark --
---------------------
function High_Water_Mark
(Pool : Debug_Pool) return Byte_Count is
begin
return Pool.High_Water;
end High_Water_Mark;
------------------------
-- Current_Water_Mark --
------------------------
function Current_Water_Mark
(Pool : Debug_Pool) return Byte_Count is
begin
return Pool.Allocated - Pool.Logically_Deallocated -
Pool.Physically_Deallocated;
end Current_Water_Mark;
------------------------------
-- System_Memory_Debug_Pool --
------------------------------
procedure System_Memory_Debug_Pool
(Has_Unhandled_Memory : Boolean := True) is
begin
System_Memory_Debug_Pool_Enabled := True;
Allow_Unhandled_Memory := Has_Unhandled_Memory;
end System_Memory_Debug_Pool;
---------------
-- Configure --
---------------
procedure Configure
(Pool : in out Debug_Pool;
Stack_Trace_Depth : Natural := Default_Stack_Trace_Depth;
Maximum_Logically_Freed_Memory : SSC := Default_Max_Freed;
Minimum_To_Free : SSC := Default_Min_Freed;
Reset_Content_On_Free : Boolean := Default_Reset_Content;
Raise_Exceptions : Boolean := Default_Raise_Exceptions;
Advanced_Scanning : Boolean := Default_Advanced_Scanning;
Errors_To_Stdout : Boolean := Default_Errors_To_Stdout;
Low_Level_Traces : Boolean := Default_Low_Level_Traces)
is
begin
Pool.Stack_Trace_Depth := Stack_Trace_Depth;
Pool.Maximum_Logically_Freed_Memory := Maximum_Logically_Freed_Memory;
Pool.Reset_Content_On_Free := Reset_Content_On_Free;
Pool.Raise_Exceptions := Raise_Exceptions;
Pool.Minimum_To_Free := Minimum_To_Free;
Pool.Advanced_Scanning := Advanced_Scanning;
Pool.Errors_To_Stdout := Errors_To_Stdout;
Pool.Low_Level_Traces := Low_Level_Traces;
end Configure;
----------------
-- Print_Pool --
----------------
procedure Print_Pool (A : System.Address) is
Storage : constant Address := A;
Valid : constant Boolean := Is_Valid (Storage);
Header : Allocation_Header_Access;
begin
-- We might get Null_Address if the call from gdb was done
-- incorrectly. For instance, doing a "print_pool(my_var)" passes 0x0,
-- instead of passing the value of my_var
if A = System.Null_Address then
Put_Line
(Standard_Output, "Memory not under control of the storage pool");
return;
end if;
if not Valid then
Put_Line
(Standard_Output, "Memory not under control of the storage pool");
else
Header := Header_Of (Storage);
Print_Address (Standard_Output, A);
Put_Line (Standard_Output, " allocated at:");
Print_Traceback (Standard_Output, "", Header.Alloc_Traceback);
if To_Traceback (Header.Dealloc_Traceback) /= null then
Print_Address (Standard_Output, A);
Put_Line (Standard_Output,
" logically freed memory, deallocated at:");
Print_Traceback (Standard_Output, "",
To_Traceback (Header.Dealloc_Traceback));
end if;
end if;
end Print_Pool;
-----------------------
-- Print_Info_Stdout --
-----------------------
procedure Print_Info_Stdout
(Pool : Debug_Pool;
Cumulate : Boolean := False;
Display_Slots : Boolean := False;
Display_Leaks : Boolean := False)
is
procedure Internal is new Print_Info
(Put_Line => Stdout_Put_Line,
Put => Stdout_Put);
-- Start of processing for Print_Info_Stdout
begin
Internal (Pool, Cumulate, Display_Slots, Display_Leaks);
end Print_Info_Stdout;
------------------
-- Dump_Gnatmem --
------------------
procedure Dump_Gnatmem (Pool : Debug_Pool; File_Name : String) is
type File_Ptr is new System.Address;
function fopen (Path : String; Mode : String) return File_Ptr;
pragma Import (C, fopen);
procedure fwrite
(Ptr : System.Address;
Size : size_t;
Nmemb : size_t;
Stream : File_Ptr);
procedure fwrite
(Str : String;
Size : size_t;
Nmemb : size_t;
Stream : File_Ptr);
pragma Import (C, fwrite);
procedure fputc (C : Integer; Stream : File_Ptr);
pragma Import (C, fputc);
procedure fclose (Stream : File_Ptr);
pragma Import (C, fclose);
Address_Size : constant size_t :=
System.Address'Max_Size_In_Storage_Elements;
-- Size in bytes of a pointer
File : File_Ptr;
Current : System.Address;
Header : Allocation_Header_Access;
Actual_Size : size_t;
Num_Calls : Integer;
Tracebk : Tracebacks_Array_Access;
Dummy_Time : Duration := 1.0;
begin
File := fopen (File_Name & ASCII.NUL, "wb" & ASCII.NUL);
fwrite ("GMEM DUMP" & ASCII.LF, 10, 1, File);
fwrite (Dummy_Time'Address, Duration'Max_Size_In_Storage_Elements, 1,
File);
-- List of not deallocated blocks (see Print_Info)
Current := Pool.First_Used_Block;
while Current /= System.Null_Address loop
Header := Header_Of (Current);
Actual_Size := size_t (Header.Block_Size);
Tracebk := Header.Alloc_Traceback.Traceback;
if Header.Alloc_Traceback /= null then
Num_Calls := Tracebk'Length;
-- (Code taken from memtrack.adb in GNAT's sources)
-- Logs allocation call using the format:
-- 'A' <mem addr> <size chunk> <len backtrace> <addr1> ... <addrn>
fputc (Character'Pos ('A'), File);
fwrite (Current'Address, Address_Size, 1, File);
fwrite (Actual_Size'Address, size_t'Max_Size_In_Storage_Elements,
1, File);
fwrite (Dummy_Time'Address, Duration'Max_Size_In_Storage_Elements,
1, File);
fwrite (Num_Calls'Address, Integer'Max_Size_In_Storage_Elements, 1,
File);
for J in Tracebk'First .. Tracebk'First + Num_Calls - 1 loop
declare
Ptr : System.Address := PC_For (Tracebk (J));
begin
fwrite (Ptr'Address, Address_Size, 1, File);
end;
end loop;
end if;
Current := Header.Next;
end loop;
fclose (File);
end Dump_Gnatmem;
----------------
-- Stdout_Put --
----------------
procedure Stdout_Put (S : String) is
begin
Put (Standard_Output, S);
end Stdout_Put;
---------------------
-- Stdout_Put_Line --
---------------------
procedure Stdout_Put_Line (S : String) is
begin
Put_Line (Standard_Output, S);
end Stdout_Put_Line;
-- Package initialization
begin
Allocate_End;
Deallocate_End;
Dereference_End;
end GNAT.Debug_Pools;
|
onedigitallife-net/Byron | Ada | 597 | ads | Pragma Ada_2012;
Pragma Assertion_Policy( Check );
with
Byron.Generics.Vector;
Generic
with Package Vector_Package is new Byron.Generics.Vector(<>);
with Procedure Replace_Element(
Container : in out Vector_Package.Vector;
Position : Vector_Package.Index_Type;
New_Item : Vector_Package.Element_Type
) is <>;
with Procedure Operation(Item : in out Vector_Package.Element_Type) is null;
Procedure Byron.Generics.Updater(Input : in out Vector_Package.Vector)
with Pure, SPARK_Mode => On,
Global => Null,
Depends => (Input =>+ Input)
;
|
RREE/ada-util | Ada | 3,016 | adb | -----------------------------------------------------------------------
-- util-beans-objects-maps -- Object maps
-- Copyright (C) 2010, 2011, 2012, 2017, 2018, 2019 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
package body Util.Beans.Objects.Maps is
-- ------------------------------
-- Get the value identified by the name.
-- If the name cannot be found, the method should return the Null object.
-- ------------------------------
function Get_Value (From : in Map_Bean;
Name : in String) return Object is
Pos : constant Cursor := From.Find (Name);
begin
if Has_Element (Pos) then
return Element (Pos);
else
return Null_Object;
end if;
end Get_Value;
-- ------------------------------
-- Set the value identified by the name.
-- If the map contains the given name, the value changed.
-- Otherwise name is added to the map and the value associated with it.
-- ------------------------------
procedure Set_Value (From : in out Map_Bean;
Name : in String;
Value : in Object) is
begin
From.Include (Name, Value);
end Set_Value;
-- ------------------------------
-- Iterate over the members of the map.
-- ------------------------------
procedure Iterate (From : in Object;
Process : not null access procedure (Name : in String;
Item : in Object)) is
procedure Process_One (Pos : in Maps.Cursor);
procedure Process_One (Pos : in Maps.Cursor) is
begin
Process (Maps.Key (Pos), Maps.Element (Pos));
end Process_One;
Bean : constant access Util.Beans.Basic.Readonly_Bean'Class := To_Bean (From);
begin
if Bean /= null and then Bean.all in Util.Beans.Objects.Maps.Map_Bean'Class then
Map_Bean'Class (Bean.all).Iterate (Process_One'Access);
end if;
end Iterate;
-- ------------------------------
-- Create an object that contains a <tt>Map_Bean</tt> instance.
-- ------------------------------
function Create return Object is
M : constant Map_Bean_Access := new Map_Bean;
begin
return To_Object (Value => M, Storage => DYNAMIC);
end Create;
end Util.Beans.Objects.Maps;
|
AdaCore/Ada_Drivers_Library | Ada | 3,048 | ads | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2015-2016, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with Serial_Port; use Serial_Port;
with STM32.Device; use STM32.Device;
with STM32.GPIO; use STM32.GPIO;
with STM32.USARTs; use STM32.USARTs;
with Ada.Interrupts; use Ada.Interrupts;
with Ada.Interrupts.Names; use Ada.Interrupts.Names;
package Peripherals is
Transceiver : USART renames USART_1;
TX_Pin : constant GPIO_Point := PB7;
RX_Pin : constant GPIO_Point := PB6;
Transceiver_Interrupt_Id : constant Interrupt_ID := USART1_Interrupt;
Transceiver_AF : constant STM32.GPIO_Alternate_Function := GPIO_AF_USART1_7;
COM : Serial_Port.Controller (Transceiver'Access, Transceiver_Interrupt_Id);
end Peripherals;
|
davidkristola/vole | Ada | 3,676 | adb | with Ada.Exceptions; use Ada.Exceptions;
with Ada.Unchecked_Deallocation;
with Ada.Containers.Indefinite_Ordered_Maps;
with kv.avm.Log;
package body kv.avm.Capabilities is
use kv.avm.Log;
package Resources is new Ada.Containers.Indefinite_Ordered_Maps
(Key_Type => String,
Element_Type => Capability_Access);
use Resources;
type Resource_Access is access Resources.Map;
type Capabilities_Reference_Counter_Type is
record
Count : Natural := 0;
Data : Resource_Access;
end record;
-----------------------------------------------------------------------------
procedure Free is new Ada.Unchecked_Deallocation(Capabilities_Reference_Counter_Type, Capabilities_Reference_Counter_Access);
-----------------------------------------------------------------------------
procedure Free is new Ada.Unchecked_Deallocation(Resources.Map, Resource_Access);
-----------------------------------------------------------------------------
procedure Initialize (Self : in out Capabilities_Type) is
begin
Self.Ref := new Capabilities_Reference_Counter_Type;
Self.Ref.Count := 1;
Self.Ref.Data := new Resources.Map;
end Initialize;
-----------------------------------------------------------------------------
procedure Adjust (Self : in out Capabilities_Type) is
Ref : Capabilities_Reference_Counter_Access := Self.Ref;
begin
if Ref /= null then
Ref.Count := Ref.Count + 1;
end if;
end Adjust;
-----------------------------------------------------------------------------
procedure Finalize (Self : in out Capabilities_Type) is
Ref : Capabilities_Reference_Counter_Access := Self.Ref;
begin
Self.Ref := null;
if Ref /= null then
Ref.Count := Ref.Count - 1;
if Ref.Count = 0 then
Free(Ref.Data);
Free(Ref);
end if;
end if;
end Finalize;
-----------------------------------------------------------------------------
function Has(Self : Capabilities_Type; Key : String) return Boolean is
begin
return Self.Ref.Data.Contains(Key);
end Has;
-----------------------------------------------------------------------------
function Lookup(Self : Capabilities_Type; Key : String) return Capability_Access is
Location : Cursor;
begin
Location := Self.Ref.Data.Find(Key);
if Location /= No_Element then
return Element(Location);
end if;
return null;
end Lookup;
-----------------------------------------------------------------------------
procedure Add
(Self : in out Capabilities_Type;
Key : in String;
Value : in Capability_Access) is
begin
Self.Ref.Data.Insert(Key, Value);
end Add;
-----------------------------------------------------------------------------
procedure Execute
(Self : in Capabilities_Type;
Key : in String;
Machine : in out kv.avm.Control.Control_Interface'CLASS;
Input : in kv.avm.Registers.Register_Type;
Output : out kv.avm.Registers.Register_Type;
Status : out kv.avm.Control.Status_Type) is
Capability : Capability_Access;
begin
Capability := Self.Lookup(Key);
if Capability /= null then
Capability.Execute(Machine, Input, Output, Status);
else
Put_Error("Capabilities_Type.Execute could not find '" & Key & "', returning an Error status.");
Output := kv.avm.Registers.Make_U(0);
Status := kv.avm.Control.Error;
end if;
end Execute;
end kv.avm.Capabilities;
|
zhmu/ananas | Ada | 215 | ads | with Compile_Time_Error1_Pkg;
package Compile_Time_Error1 is
type Rec is record
I : Integer;
end record;
package Inst is new Compile_Time_Error1_Pkg (Rec);
procedure Dummy;
end Compile_Time_Error1;
|
Fabien-Chouteau/coffee-clock | Ada | 54,980 | ads | -- This file was generated by bmp2ada
with Giza.Image;
with Giza.Image.DMA2D;
use Giza.Image.DMA2D;
package digit_3 is
pragma Style_Checks (Off);
CLUT : aliased constant L4_CLUT_T := (
(R => 0, G => 0, B => 0),
(R => 255, G => 0, B => 0), others => (0, 0, 0));
Data : aliased constant L4_Data_T := (
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16,
17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 16, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
);
Image : constant Giza.Image.Ref := new Giza.Image.DMA2D.Instance'
(Mode => L4, W => 160, H => 195, Length => 15600, L4_CLUT => CLUT'Access, L4_Data => Data'Access);
pragma Style_Checks (On);
end digit_3;
|
reznikmm/matreshka | Ada | 3,824 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Attributes;
package ODF.DOM.Draw_Concentric_Gradient_Fill_Allowed_Attributes is
pragma Preelaborate;
type ODF_Draw_Concentric_Gradient_Fill_Allowed_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Draw_Concentric_Gradient_Fill_Allowed_Attribute_Access is
access all ODF_Draw_Concentric_Gradient_Fill_Allowed_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Draw_Concentric_Gradient_Fill_Allowed_Attributes;
|
Gabriel-Degret/adalib | Ada | 1,819 | ads | -- Standard Ada library specification
-- Copyright (c) 2003-2018 Maxim Reznik <[email protected]>
-- Copyright (c) 2004-2016 AXE Consultants
-- Copyright (c) 2004, 2005, 2006 Ada-Europe
-- Copyright (c) 2000 The MITRE Corporation, Inc.
-- Copyright (c) 1992, 1993, 1994, 1995 Intermetrics, Inc.
-- SPDX-License-Identifier: BSD-3-Clause and LicenseRef-AdaReferenceManual
---------------------------------------------------------------------------
with Ada.Streams; -- see 13.13.1
package System.RPC is
type Partition_Id is range 0 .. implementation_defined;
Communication_Error : exception;
type Params_Stream_Type (Initial_Size : Ada.Streams.Stream_Element_Count) is
new Ada.Streams.Root_Stream_Type with private;
procedure Read (Stream : in out Params_Stream_Type;
Item : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset);
procedure Write (Stream : in out Params_Stream_Type;
Item : in Ada.Streams.Stream_Element_Array);
-- Synchronous call
procedure Do_RPC (Partition : in Partition_Id;
Params : access Params_Stream_Type;
Result : access Params_Stream_Type);
-- Asynchronous call
procedure Do_APC (Partition : in Partition_Id;
Params : access Params_Stream_Type);
-- The handler for incoming RPCs
type RPC_Receiver is access procedure (Params : access Params_Stream_Type;
Result : access Params_Stream_Type);
procedure Establish_RPC_Receiver (Partition : in Partition_Id;
Receiver : in RPC_Receiver);
private
pragma Import (Ada, Params_Stream_Type);
end System.RPC;
|
jhumphry/PRNG_Zoo | Ada | 1,599 | ads | --
-- PRNG Zoo
-- Copyright 2014 James Humphry
--
package PRNG_Zoo.Tests is
subtype Counter is Integer range 0..Integer'Last;
type Counter_array is array (Integer range <>) of Counter
with Default_Component_Value => 0;
type Counter_array_ptr is access Counter_array;
type LF_array is array (Integer range <>) of Long_Float;
type Binned(N : Positive) is tagged
record
Bin_Counts : Counter_array(1..N);
Bin_Expected : LF_array(1..N);
Distribution_DF : Positive;
Bin_Boundary : LF_array(1..N);
end record;
type Test is limited interface;
function Result_Ready(T: Test) return Boolean is abstract;
function Passed(T : in Test; p : in Long_Float := 0.01) return Boolean is abstract
with Pre'Class => Result_Ready(Test'Class(T));
function p(T : in Test) return Long_Float is abstract
with Pre'Class => Result_Ready(Test'Class(T));
function Describe_Result(T : in Test) return String is abstract
with Pre'Class => Result_Ready(Test'Class(T));
type Test_Ptr is access all Test'Class;
type PRNG_Test is limited interface and Test;
procedure Reset(T : in out PRNG_Test) is abstract;
procedure Feed(T : in out PRNG_Test; X : in U64) is abstract;
procedure Compute_Result(T : in out PRNG_Test) is abstract;
type Test_32 is limited interface and PRNG_Test;
procedure Feed(T : in out Test_32; X : in U64) is null;
procedure Feed(T : in out Test_32; X : in U32) is abstract;
type PRNG_Test_Ptr is access all PRNG_Test'Class;
Insufficient_Data : exception;
end PRNG_Zoo.Tests;
|
stcarrez/ada-wiki | Ada | 3,086 | ads | -----------------------------------------------------------------------
-- wiki-streams-html-stream -- Generic Wiki HTML output stream
-- Copyright (C) 2016, 2020, 2022 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Wiki.Strings;
generic
type Output_Stream is limited new Wiki.Streams.Output_Stream with private;
package Wiki.Streams.Html.Stream is
type Html_Output_Stream is limited new Output_Stream
and Html.Html_Output_Stream with private;
-- Set the indentation level for HTML output stream.
overriding
procedure Set_Indent_Level (Writer : in out Html_Output_Stream;
Indent : in Natural);
-- Write an XML attribute within an XML element.
-- The attribute value is escaped according to the XML escape rules.
overriding
procedure Write_Wide_Attribute (Stream : in out Html_Output_Stream;
Name : in String;
Content : in Wiki.Strings.UString);
-- Write an XML attribute within an XML element.
-- The attribute value is escaped according to the XML escape rules.
overriding
procedure Write_Wide_Attribute (Stream : in out Html_Output_Stream;
Name : in String;
Content : in Wide_Wide_String);
-- Start an XML element with the given name.
overriding
procedure Start_Element (Stream : in out Html_Output_Stream;
Name : in String);
-- Closes an XML element of the given name.
overriding
procedure End_Element (Stream : in out Html_Output_Stream;
Name : in String);
-- Write a text escaping any character as necessary.
overriding
procedure Write_Wide_Text (Stream : in out Html_Output_Stream;
Content : in Wiki.Strings.WString);
-- Write an optional newline or space.
overriding
procedure Newline (Writer : in out Html_Output_Stream);
private
type Html_Output_Stream is limited new Output_Stream
and Html.Html_Output_Stream with record
-- Whether an XML element must be closed (that is a '>' is necessary)
Close_Start : Boolean := False;
Empty_Line : Boolean := True;
Indent_Level : Natural := 0;
Indent_Pos : Natural := 0;
Text_Length : Natural := 0;
end record;
end Wiki.Streams.Html.Stream;
|
nerilex/ada-util | Ada | 8,891 | ads | -----------------------------------------------------------------------
-- util-http-clients -- HTTP Clients
-- Copyright (C) 2011, 2012, 2015 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Finalization;
with Util.Http.Cookies;
-- == Client ==
-- The <tt>Util.Http.Clients</tt> package defines a set of API for an HTTP client to send
-- requests to an HTTP server.
--
-- === GET request ===
-- To retrieve a content using the HTTP GET operation, a client instance must be created.
-- The response is returned in a specific object that must therefore be declared:
--
-- Http : Util.Http.Clients.Client;
-- Response : Util.Http.Clients.Response;
--
-- Before invoking the GET operation, the client can setup a number of HTTP headers.
--
-- Http.Add_Header ("X-Requested-By", "wget");
--
-- The GET operation is performed when the <tt>Get</tt> procedure is called:
--
-- Http.Get ("http://www.google.com", Response);
--
-- Once the response is received, the <tt>Response</tt> object contains the status of the
-- HTTP response, the HTTP reply headers and the body. A response header can be obtained
-- by using the <tt>Get_Header</tt> function and the body using <tt>Get_Body</tt>:
--
-- Body : constant String := Response.Get_Body;
--
package Util.Http.Clients is
Connection_Error : exception;
-- ------------------------------
-- Http response
-- ------------------------------
-- The <b>Response</b> type represents a response returned by an HTTP request.
type Response is limited new Abstract_Response with private;
-- Returns a boolean indicating whether the named response header has already
-- been set.
overriding
function Contains_Header (Reply : in Response;
Name : in String) return Boolean;
-- Returns the value of the specified response header as a String. If the response
-- did not include a header of the specified name, this method returns null.
-- If there are multiple headers with the same name, this method returns the
-- first head in the request. The header name is case insensitive. You can use
-- this method with any response header.
overriding
function Get_Header (Reply : in Response;
Name : in String) return String;
-- Sets a message header with the given name and value. If the header had already
-- been set, the new value overwrites the previous one. The containsHeader
-- method can be used to test for the presence of a header before setting its value.
overriding
procedure Set_Header (Reply : in out Response;
Name : in String;
Value : in String);
-- Adds a request header with the given name and value.
-- This method allows request headers to have multiple values.
overriding
procedure Add_Header (Reply : in out Response;
Name : in String;
Value : in String);
-- Iterate over the response headers and executes the <b>Process</b> procedure.
overriding
procedure Iterate_Headers (Reply : in Response;
Process : not null access
procedure (Name : in String;
Value : in String));
-- Get the response body as a string.
overriding
function Get_Body (Reply : in Response) return String;
-- Get the response status code.
overriding
function Get_Status (Reply : in Response) return Natural;
-- ------------------------------
-- Http client
-- ------------------------------
-- The <b>Client</b> type allows to execute HTTP GET/POST requests.
type Client is limited new Abstract_Request with private;
type Client_Access is access all Client;
-- Returns a boolean indicating whether the named response header has already
-- been set.
overriding
function Contains_Header (Request : in Client;
Name : in String) return Boolean;
-- Returns the value of the specified request header as a String. If the request
-- did not include a header of the specified name, this method returns null.
-- If there are multiple headers with the same name, this method returns the
-- first head in the request. The header name is case insensitive. You can use
-- this method with any response header.
overriding
function Get_Header (Request : in Client;
Name : in String) return String;
-- Sets a header with the given name and value. If the header had already
-- been set, the new value overwrites the previous one. The containsHeader
-- method can be used to test for the presence of a header before setting its value.
overriding
procedure Set_Header (Request : in out Client;
Name : in String;
Value : in String);
-- Adds a header with the given name and value.
-- This method allows headers to have multiple values.
overriding
procedure Add_Header (Request : in out Client;
Name : in String;
Value : in String);
-- Iterate over the request headers and executes the <b>Process</b> procedure.
overriding
procedure Iterate_Headers (Request : in Client;
Process : not null access
procedure (Name : in String;
Value : in String));
-- Removes all headers with the given name.
procedure Remove_Header (Request : in out Client;
Name : in String);
-- Adds the specified cookie to the request. This method can be called multiple
-- times to set more than one cookie.
procedure Add_Cookie (Http : in out Client;
Cookie : in Util.Http.Cookies.Cookie);
-- Execute an http GET request on the given URL. Additional request parameters,
-- cookies and headers should have been set on the client object.
procedure Get (Request : in out Client;
URL : in String;
Reply : out Response'Class);
-- Execute an http POST request on the given URL. The post data is passed in <b>Data</b>.
-- Additional request cookies and headers should have been set on the client object.
procedure Post (Request : in out Client;
URL : in String;
Data : in String;
Reply : out Response'Class);
private
subtype Http_Request is Abstract_Request;
subtype Http_Request_Access is Abstract_Request_Access;
subtype Http_Response is Abstract_Response;
subtype Http_Response_Access is Abstract_Response_Access;
type Http_Manager is interface;
type Http_Manager_Access is access all Http_Manager'Class;
procedure Create (Manager : in Http_Manager;
Http : in out Client'Class) is abstract;
procedure Do_Get (Manager : in Http_Manager;
Http : in Client'Class;
URI : in String;
Reply : out Response'Class) is abstract;
procedure Do_Post (Manager : in Http_Manager;
Http : in Client'Class;
URI : in String;
Data : in String;
Reply : out Response'Class) is abstract;
Default_Http_Manager : Http_Manager_Access;
type Response is limited new Ada.Finalization.Limited_Controlled
and Abstract_Response with record
Delegate : Abstract_Response_Access;
end record;
-- Free the resource used by the response.
overriding
procedure Finalize (Reply : in out Response);
type Client is limited new Ada.Finalization.Limited_Controlled
and Abstract_Request with record
Manager : Http_Manager_Access;
Delegate : Http_Request_Access;
end record;
-- Initialize the client
overriding
procedure Initialize (Http : in out Client);
overriding
procedure Finalize (Http : in out Client);
end Util.Http.Clients;
|
ohenley/ada-util | Ada | 4,257 | ads | -----------------------------------------------------------------------
-- util-streams -- Stream utilities
-- Copyright (C) 2010, 2016, 2018 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Streams;
-- = Streams =
-- The `Util.Streams` package provides several types and operations to allow the
-- composition of input and output streams. Input streams can be chained together so that
-- they traverse the different stream objects when the data is read from them. Similarly,
-- output streams can be chained and the data that is written will traverse the different
-- streams from the first one up to the last one in the chain. During such traversal, the
-- stream object is able to bufferize the data or make transformations on the data.
--
-- The `Input_Stream` interface represents the stream to read data. It only provides a
-- `Read` procedure. The `Output_Stream` interface represents the stream to write data.
-- It provides a `Write`, `Flush` and `Close` operation.
--
-- @include util-streams-buffered.ads
-- @include util-streams-texts.ads
-- @include util-streams-files.ads
-- @include util-streams-pipes.ads
-- @include util-streams-sockets.ads
-- @include util-streams-raw.ads
-- @include util-streams-buffered-encoders.ads
package Util.Streams is
pragma Preelaborate;
-- -----------------------
-- Output stream
-- -----------------------
-- The <b>Output_Stream</b> is an interface that accepts output bytes
-- and sends them to a sink.
type Output_Stream is limited interface;
type Output_Stream_Access is access all Output_Stream'Class;
-- Write the buffer array to the output stream.
procedure Write (Stream : in out Output_Stream;
Buffer : in Ada.Streams.Stream_Element_Array) is abstract;
-- Flush the buffer (if any) to the sink.
procedure Flush (Stream : in out Output_Stream) is null;
-- Close the sink.
procedure Close (Stream : in out Output_Stream) is null;
-- -----------------------
-- Input stream
-- -----------------------
-- The <b>Input_Stream</b> is the interface that reads input bytes
-- from a source and returns them.
type Input_Stream is limited interface;
type Input_Stream_Access is access all Input_Stream'Class;
-- Read into the buffer as many bytes as possible and return in
-- <b>last</b> the position of the last byte read.
procedure Read (Stream : in out Input_Stream;
Into : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset) is abstract;
-- Copy the input stream to the output stream until the end of the input stream
-- is reached.
procedure Copy (From : in out Input_Stream'Class;
Into : in out Output_Stream'Class);
-- Copy the stream array to the string.
-- The string must be large enough to hold the stream array
-- or a Constraint_Error exception is raised.
procedure Copy (From : in Ada.Streams.Stream_Element_Array;
Into : in out String);
-- Copy the string to the stream array.
-- The stream array must be large enough to hold the string
-- or a Constraint_Error exception is raised.
procedure Copy (From : in String;
Into : in out Ada.Streams.Stream_Element_Array);
-- Notes:
-- ------
-- The <b>Ada.Streams.Root_Stream_Type</b> implements the <b>Output_Stream</b>
-- and <b>Input_Stream</b>. It is however not easy to use for composing various
-- stream behaviors.
end Util.Streams;
|
wcarthur/SHARPpy | Ada | 3,269 | ads | %TITLE%
ADS 010507/0000
LEVEL HGHT TEMP DWPT WDIR WSPD
-------------------------------------------------------------------
%RAW%
991.75, 158.79, 26.61, 22.35, 164.08, 8.53
975.00, 309.81, 25.49, 20.91, 165.43, 12.62
950.00, 538.20, 23.78, 18.97, 168.45, 17.43
925.00, 771.20, 21.79, 17.56, 178.42, 18.51
900.00, 1008.89, 19.96, 15.94, 195.98, 18.10
875.00, 1251.44, 18.13, 13.83, 212.56, 17.74
850.00, 1499.58, 16.63, 8.81, 222.94, 18.37
825.00, 1753.28, 15.29, 2.35, 230.21, 19.49
800.00, 2013.28, 13.35, 0.37, 235.84, 20.20
775.00, 2279.13, 11.71, -7.51, 239.46, 19.64
750.00, 2551.82, 9.20, -8.87, 244.10, 19.01
725.00, 2831.37, 7.08, -8.03, 252.75, 19.96
700.00, 3118.97, 5.10, -9.16, 258.32, 20.69
675.00, 3414.87, 2.93, -11.45, 262.14, 21.58
650.00, 3718.57, 0.79, -14.69, 264.65, 22.67
625.00, 4031.71, -1.28, -18.82, 265.59, 23.55
600.00, 4356.07, -3.37, -22.64, 263.54, 24.61
575.00, 4690.66, -5.61, -25.40, 259.82, 26.43
550.00, 5037.26, -8.17, -26.90, 255.42, 28.56
525.00, 5396.26, -10.97, -27.95, 251.38, 31.03
500.00, 5768.71, -13.74, -30.05, 247.76, 34.17
475.00, 6156.17, -16.26, -35.04, 244.28, 37.81
450.00, 6560.67, -19.13, -40.46, 243.32, 42.55
425.00, 6983.12, -22.26, -43.30, 243.42, 46.13
400.00, 7425.12, -25.40, -41.51, 243.91, 49.54
375.00, 7891.02, -28.87, -43.30, 244.60, 53.03
350.00, 8379.71, -32.61, -45.68, 245.24, 56.78
325.00, 8898.31, -36.04, -46.14, 245.51, 61.53
300.00, 9449.91, -39.28, -47.05, 245.58, 66.99
275.00, 10041.15, -42.66, -51.97, 244.69, 76.03
250.00, 10678.75, -46.61, -55.24, 247.44, 78.58
225.00, 11371.10, -50.85, -59.44, 253.60, 67.31
200.00, 12131.35, -54.79, -63.81, 252.71, 58.83
175.00, 12978.15, -57.75, -68.75, 248.16, 56.59
150.00, 13949.36, -58.31, -69.22, 244.20, 50.52
125.00, 15105.81, -61.13, -71.56, 245.24, 39.69
100.00, 16459.81, -66.59, -76.99, 251.27, 27.16
75.00, 18205.42, -58.31, -69.22, 244.20, 50.52
50.00, 20665.71, -58.31, -69.22, 244.20, 50.52
%END%
----- Parcel Information-----
*** 50mb MIXED LAYER PARCEL ***
LPL: P=992 T=81F Td=67F
CAPE: 2818 J/kg
CINH: -33 J/kg
LI: -10 C
LI(300mb): -8 C
3km Cape: 163 J/kg
NCAPE: 0.27 m/s2
LCL: 886mb 988m
LFC: 850mb 1341m
EL: 200mb 11973m
MPL: 118mb 15297m
All heights AGL
----- Moisture -----
Precip Water: 1.13 in
Mean W: 14.4 g/Kg
----- Lapse Rates -----
700-500mb 19 C 7.2 C/km
850-500mb 32 C 7.4 C/km
----- Note -----
Old Title: RUC 010507/0000F000 ads
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.