repo_name
stringlengths
9
74
language
stringclasses
1 value
length_bytes
int64
11
9.34M
extension
stringclasses
2 values
content
stringlengths
11
9.34M
sebsgit/textproc
Ada
633
ads
with AUnit; use AUnit; with AUnit.Test_Cases; use AUnit.Test_Cases; package HistogramTests is type TestCase is new AUnit.Test_Cases.Test_Case with null record; procedure Register_Tests(T: in out TestCase); function Name(T: TestCase) return Message_String; procedure testBasicHistograms(T : in out Test_Cases.Test_Case'Class); procedure testRescale(T : in out Test_Cases.Test_Case'Class); procedure testMultiplication(T: in out Test_Cases.Test_Case'Class); procedure testProjections(T : in out Test_Cases.Test_Case'Class); procedure testDistance(T : in out Test_Cases.Test_Case'Class); end HistogramTests;
reznikmm/matreshka
Ada
3,576
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Web 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$ ------------------------------------------------------------------------------ with League.Strings; with AWF.Internals.AWF_Widgets; package AWF.Painter is function Draw (Widget : not null AWF.Internals.AWF_Widgets.AWF_Widget_Proxy_Access) return League.Strings.Universal_String; end AWF.Painter;
1Crazymoney/LearnAda
Ada
240
adb
with swap, ada.text_io; use ada.text_io; procedure demo is a:integer:=3; b:integer:=5; begin put_line("A:"&integer'image(a)&", B:"&integer'image(b)); swap(a,b); put_line("A:"&integer'image(a)&", B:"&integer'image(b)); end demo;
reznikmm/matreshka
Ada
5,064
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.UML.Parameter_Sets.Collections is pragma Preelaborate; package UML_Parameter_Set_Collections is new AMF.Generic_Collections (UML_Parameter_Set, UML_Parameter_Set_Access); type Set_Of_UML_Parameter_Set is new UML_Parameter_Set_Collections.Set with null record; Empty_Set_Of_UML_Parameter_Set : constant Set_Of_UML_Parameter_Set; type Ordered_Set_Of_UML_Parameter_Set is new UML_Parameter_Set_Collections.Ordered_Set with null record; Empty_Ordered_Set_Of_UML_Parameter_Set : constant Ordered_Set_Of_UML_Parameter_Set; type Bag_Of_UML_Parameter_Set is new UML_Parameter_Set_Collections.Bag with null record; Empty_Bag_Of_UML_Parameter_Set : constant Bag_Of_UML_Parameter_Set; type Sequence_Of_UML_Parameter_Set is new UML_Parameter_Set_Collections.Sequence with null record; Empty_Sequence_Of_UML_Parameter_Set : constant Sequence_Of_UML_Parameter_Set; private Empty_Set_Of_UML_Parameter_Set : constant Set_Of_UML_Parameter_Set := (UML_Parameter_Set_Collections.Set with null record); Empty_Ordered_Set_Of_UML_Parameter_Set : constant Ordered_Set_Of_UML_Parameter_Set := (UML_Parameter_Set_Collections.Ordered_Set with null record); Empty_Bag_Of_UML_Parameter_Set : constant Bag_Of_UML_Parameter_Set := (UML_Parameter_Set_Collections.Bag with null record); Empty_Sequence_Of_UML_Parameter_Set : constant Sequence_Of_UML_Parameter_Set := (UML_Parameter_Set_Collections.Sequence with null record); end AMF.UML.Parameter_Sets.Collections;
twdroeger/ada-awa
Ada
34,336
adb
----------------------------------------------------------------------- -- AWA.Images.Models -- AWA.Images.Models ----------------------------------------------------------------------- -- File generated by ada-gen DO NOT MODIFY -- Template used: templates/model/package-body.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. ----------------------------------------------------------------------- with Ada.Unchecked_Deallocation; with Util.Beans.Objects.Time; with ASF.Events.Faces.Actions; package body AWA.Images.Models is use type ADO.Objects.Object_Record_Access; use type ADO.Objects.Object_Ref; pragma Warnings (Off, "formal parameter * is not referenced"); function Image_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key is Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER, Of_Class => IMAGE_DEF'Access); begin ADO.Objects.Set_Value (Result, Id); return Result; end Image_Key; function Image_Key (Id : in String) return ADO.Objects.Object_Key is Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER, Of_Class => IMAGE_DEF'Access); begin ADO.Objects.Set_Value (Result, Id); return Result; end Image_Key; function "=" (Left, Right : Image_Ref'Class) return Boolean is begin return ADO.Objects.Object_Ref'Class (Left) = ADO.Objects.Object_Ref'Class (Right); end "="; procedure Set_Field (Object : in out Image_Ref'Class; Impl : out Image_Access) is Result : ADO.Objects.Object_Record_Access; begin Object.Prepare_Modify (Result); Impl := Image_Impl (Result.all)'Access; end Set_Field; -- Internal method to allocate the Object_Record instance procedure Allocate (Object : in out Image_Ref) is Impl : Image_Access; begin Impl := new Image_Impl; Impl.Width := 0; Impl.Height := 0; Impl.Thumb_Width := 0; Impl.Thumb_Height := 0; Impl.Public := False; Impl.Version := 0; ADO.Objects.Set_Object (Object, Impl.all'Access); end Allocate; -- ---------------------------------------- -- Data object: Image -- ---------------------------------------- procedure Set_Id (Object : in out Image_Ref; Value : in ADO.Identifier) is Impl : Image_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Key_Value (Impl.all, 1, Value); end Set_Id; function Get_Id (Object : in Image_Ref) return ADO.Identifier is Impl : constant Image_Access := Image_Impl (Object.Get_Object.all)'Access; begin return Impl.Get_Key_Value; end Get_Id; procedure Set_Width (Object : in out Image_Ref; Value : in Integer) is Impl : Image_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Integer (Impl.all, 2, Impl.Width, Value); end Set_Width; function Get_Width (Object : in Image_Ref) return Integer is Impl : constant Image_Access := Image_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Width; end Get_Width; procedure Set_Height (Object : in out Image_Ref; Value : in Integer) is Impl : Image_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Integer (Impl.all, 3, Impl.Height, Value); end Set_Height; function Get_Height (Object : in Image_Ref) return Integer is Impl : constant Image_Access := Image_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Height; end Get_Height; procedure Set_Thumb_Width (Object : in out Image_Ref; Value : in Integer) is Impl : Image_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Integer (Impl.all, 4, Impl.Thumb_Width, Value); end Set_Thumb_Width; function Get_Thumb_Width (Object : in Image_Ref) return Integer is Impl : constant Image_Access := Image_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Thumb_Width; end Get_Thumb_Width; procedure Set_Thumb_Height (Object : in out Image_Ref; Value : in Integer) is Impl : Image_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Integer (Impl.all, 5, Impl.Thumb_Height, Value); end Set_Thumb_Height; function Get_Thumb_Height (Object : in Image_Ref) return Integer is Impl : constant Image_Access := Image_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Thumb_Height; end Get_Thumb_Height; procedure Set_Path (Object : in out Image_Ref; Value : in String) is Impl : Image_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_String (Impl.all, 6, Impl.Path, Value); end Set_Path; procedure Set_Path (Object : in out Image_Ref; Value : in Ada.Strings.Unbounded.Unbounded_String) is Impl : Image_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Unbounded_String (Impl.all, 6, Impl.Path, Value); end Set_Path; function Get_Path (Object : in Image_Ref) return String is begin return Ada.Strings.Unbounded.To_String (Object.Get_Path); end Get_Path; function Get_Path (Object : in Image_Ref) return Ada.Strings.Unbounded.Unbounded_String is Impl : constant Image_Access := Image_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Path; end Get_Path; procedure Set_Public (Object : in out Image_Ref; Value : in Boolean) is Impl : Image_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Boolean (Impl.all, 7, Impl.Public, Value); end Set_Public; function Get_Public (Object : in Image_Ref) return Boolean is Impl : constant Image_Access := Image_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Public; end Get_Public; function Get_Version (Object : in Image_Ref) return Integer is Impl : constant Image_Access := Image_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Version; end Get_Version; procedure Set_Thumbnail (Object : in out Image_Ref; Value : in AWA.Storages.Models.Storage_Ref'Class) is Impl : Image_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Object (Impl.all, 9, Impl.Thumbnail, Value); end Set_Thumbnail; function Get_Thumbnail (Object : in Image_Ref) return AWA.Storages.Models.Storage_Ref'Class is Impl : constant Image_Access := Image_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Thumbnail; end Get_Thumbnail; procedure Set_Folder (Object : in out Image_Ref; Value : in AWA.Storages.Models.Storage_Folder_Ref'Class) is Impl : Image_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Object (Impl.all, 10, Impl.Folder, Value); end Set_Folder; function Get_Folder (Object : in Image_Ref) return AWA.Storages.Models.Storage_Folder_Ref'Class is Impl : constant Image_Access := Image_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Folder; end Get_Folder; procedure Set_Owner (Object : in out Image_Ref; Value : in AWA.Users.Models.User_Ref'Class) is Impl : Image_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Object (Impl.all, 11, Impl.Owner, Value); end Set_Owner; function Get_Owner (Object : in Image_Ref) return AWA.Users.Models.User_Ref'Class is Impl : constant Image_Access := Image_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Owner; end Get_Owner; procedure Set_Storage (Object : in out Image_Ref; Value : in AWA.Storages.Models.Storage_Ref'Class) is Impl : Image_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Object (Impl.all, 12, Impl.Storage, Value); end Set_Storage; function Get_Storage (Object : in Image_Ref) return AWA.Storages.Models.Storage_Ref'Class is Impl : constant Image_Access := Image_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Storage; end Get_Storage; -- Copy of the object. procedure Copy (Object : in Image_Ref; Into : in out Image_Ref) is Result : Image_Ref; begin if not Object.Is_Null then declare Impl : constant Image_Access := Image_Impl (Object.Get_Load_Object.all)'Access; Copy : constant Image_Access := new Image_Impl; begin ADO.Objects.Set_Object (Result, Copy.all'Access); Copy.Copy (Impl.all); Copy.Width := Impl.Width; Copy.Height := Impl.Height; Copy.Thumb_Width := Impl.Thumb_Width; Copy.Thumb_Height := Impl.Thumb_Height; Copy.Path := Impl.Path; Copy.Public := Impl.Public; Copy.Version := Impl.Version; Copy.Thumbnail := Impl.Thumbnail; Copy.Folder := Impl.Folder; Copy.Owner := Impl.Owner; Copy.Storage := Impl.Storage; end; end if; Into := Result; end Copy; procedure Find (Object : in out Image_Ref; Session : in out ADO.Sessions.Session'Class; Query : in ADO.SQL.Query'Class; Found : out Boolean) is Impl : constant Image_Access := new Image_Impl; begin Impl.Find (Session, Query, Found); if Found then ADO.Objects.Set_Object (Object, Impl.all'Access); else ADO.Objects.Set_Object (Object, null); Destroy (Impl); end if; end Find; procedure Load (Object : in out Image_Ref; Session : in out ADO.Sessions.Session'Class; Id : in ADO.Identifier) is Impl : constant Image_Access := new Image_Impl; Found : Boolean; Query : ADO.SQL.Query; begin Query.Bind_Param (Position => 1, Value => Id); Query.Set_Filter ("id = ?"); Impl.Find (Session, Query, Found); if not Found then Destroy (Impl); raise ADO.Objects.NOT_FOUND; end if; ADO.Objects.Set_Object (Object, Impl.all'Access); end Load; procedure Load (Object : in out Image_Ref; Session : in out ADO.Sessions.Session'Class; Id : in ADO.Identifier; Found : out Boolean) is Impl : constant Image_Access := new Image_Impl; Query : ADO.SQL.Query; begin Query.Bind_Param (Position => 1, Value => Id); Query.Set_Filter ("id = ?"); Impl.Find (Session, Query, Found); if not Found then Destroy (Impl); else ADO.Objects.Set_Object (Object, Impl.all'Access); end if; end Load; procedure Save (Object : in out Image_Ref; Session : in out ADO.Sessions.Master_Session'Class) is Impl : ADO.Objects.Object_Record_Access := Object.Get_Object; begin if Impl = null then Impl := new Image_Impl; ADO.Objects.Set_Object (Object, Impl); end if; if not ADO.Objects.Is_Created (Impl.all) then Impl.Create (Session); else Impl.Save (Session); end if; end Save; procedure Delete (Object : in out Image_Ref; Session : in out ADO.Sessions.Master_Session'Class) is Impl : constant ADO.Objects.Object_Record_Access := Object.Get_Object; begin if Impl /= null then Impl.Delete (Session); end if; end Delete; -- -------------------- -- Free the object -- -------------------- procedure Destroy (Object : access Image_Impl) is type Image_Impl_Ptr is access all Image_Impl; procedure Unchecked_Free is new Ada.Unchecked_Deallocation (Image_Impl, Image_Impl_Ptr); pragma Warnings (Off, "*redundant conversion*"); Ptr : Image_Impl_Ptr := Image_Impl (Object.all)'Access; pragma Warnings (On, "*redundant conversion*"); begin Unchecked_Free (Ptr); end Destroy; procedure Find (Object : in out Image_Impl; Session : in out ADO.Sessions.Session'Class; Query : in ADO.SQL.Query'Class; Found : out Boolean) is Stmt : ADO.Statements.Query_Statement := Session.Create_Statement (Query, IMAGE_DEF'Access); begin Stmt.Execute; if Stmt.Has_Elements then Object.Load (Stmt, Session); Stmt.Next; Found := not Stmt.Has_Elements; else Found := False; end if; end Find; overriding procedure Load (Object : in out Image_Impl; Session : in out ADO.Sessions.Session'Class) is Found : Boolean; Query : ADO.SQL.Query; Id : constant ADO.Identifier := Object.Get_Key_Value; begin Query.Bind_Param (Position => 1, Value => Id); Query.Set_Filter ("id = ?"); Object.Find (Session, Query, Found); if not Found then raise ADO.Objects.NOT_FOUND; end if; end Load; procedure Save (Object : in out Image_Impl; Session : in out ADO.Sessions.Master_Session'Class) is Stmt : ADO.Statements.Update_Statement := Session.Create_Statement (IMAGE_DEF'Access); begin if Object.Is_Modified (1) then Stmt.Save_Field (Name => COL_0_1_NAME, -- id Value => Object.Get_Key); Object.Clear_Modified (1); end if; if Object.Is_Modified (2) then Stmt.Save_Field (Name => COL_1_1_NAME, -- width Value => Object.Width); Object.Clear_Modified (2); end if; if Object.Is_Modified (3) then Stmt.Save_Field (Name => COL_2_1_NAME, -- height Value => Object.Height); Object.Clear_Modified (3); end if; if Object.Is_Modified (4) then Stmt.Save_Field (Name => COL_3_1_NAME, -- thumb_width Value => Object.Thumb_Width); Object.Clear_Modified (4); end if; if Object.Is_Modified (5) then Stmt.Save_Field (Name => COL_4_1_NAME, -- thumb_height Value => Object.Thumb_Height); Object.Clear_Modified (5); end if; if Object.Is_Modified (6) then Stmt.Save_Field (Name => COL_5_1_NAME, -- path Value => Object.Path); Object.Clear_Modified (6); end if; if Object.Is_Modified (7) then Stmt.Save_Field (Name => COL_6_1_NAME, -- public Value => Object.Public); Object.Clear_Modified (7); end if; if Object.Is_Modified (9) then Stmt.Save_Field (Name => COL_8_1_NAME, -- thumbnail_id Value => Object.Thumbnail); Object.Clear_Modified (9); end if; if Object.Is_Modified (10) then Stmt.Save_Field (Name => COL_9_1_NAME, -- folder_id Value => Object.Folder); Object.Clear_Modified (10); end if; if Object.Is_Modified (11) then Stmt.Save_Field (Name => COL_10_1_NAME, -- owner_id Value => Object.Owner); Object.Clear_Modified (11); end if; if Object.Is_Modified (12) then Stmt.Save_Field (Name => COL_11_1_NAME, -- storage_id Value => Object.Storage); Object.Clear_Modified (12); end if; if Stmt.Has_Save_Fields then Object.Version := Object.Version + 1; Stmt.Save_Field (Name => "version", Value => Object.Version); Stmt.Set_Filter (Filter => "id = ? and version = ?"); Stmt.Add_Param (Value => Object.Get_Key); Stmt.Add_Param (Value => Object.Version - 1); declare Result : Integer; begin Stmt.Execute (Result); if Result /= 1 then if Result /= 0 then raise ADO.Objects.UPDATE_ERROR; else raise ADO.Objects.LAZY_LOCK; end if; end if; end; end if; end Save; procedure Create (Object : in out Image_Impl; Session : in out ADO.Sessions.Master_Session'Class) is Query : ADO.Statements.Insert_Statement := Session.Create_Statement (IMAGE_DEF'Access); Result : Integer; begin Object.Version := 1; Session.Allocate (Id => Object); Query.Save_Field (Name => COL_0_1_NAME, -- id Value => Object.Get_Key); Query.Save_Field (Name => COL_1_1_NAME, -- width Value => Object.Width); Query.Save_Field (Name => COL_2_1_NAME, -- height Value => Object.Height); Query.Save_Field (Name => COL_3_1_NAME, -- thumb_width Value => Object.Thumb_Width); Query.Save_Field (Name => COL_4_1_NAME, -- thumb_height Value => Object.Thumb_Height); Query.Save_Field (Name => COL_5_1_NAME, -- path Value => Object.Path); Query.Save_Field (Name => COL_6_1_NAME, -- public Value => Object.Public); Query.Save_Field (Name => COL_7_1_NAME, -- version Value => Object.Version); Query.Save_Field (Name => COL_8_1_NAME, -- thumbnail_id Value => Object.Thumbnail); Query.Save_Field (Name => COL_9_1_NAME, -- folder_id Value => Object.Folder); Query.Save_Field (Name => COL_10_1_NAME, -- owner_id Value => Object.Owner); Query.Save_Field (Name => COL_11_1_NAME, -- storage_id Value => Object.Storage); Query.Execute (Result); if Result /= 1 then raise ADO.Objects.INSERT_ERROR; end if; ADO.Objects.Set_Created (Object); end Create; procedure Delete (Object : in out Image_Impl; Session : in out ADO.Sessions.Master_Session'Class) is Stmt : ADO.Statements.Delete_Statement := Session.Create_Statement (IMAGE_DEF'Access); begin Stmt.Set_Filter (Filter => "id = ?"); Stmt.Add_Param (Value => Object.Get_Key); Stmt.Execute; end Delete; -- ------------------------------ -- Get the bean attribute identified by the name. -- ------------------------------ overriding function Get_Value (From : in Image_Ref; Name : in String) return Util.Beans.Objects.Object is Obj : ADO.Objects.Object_Record_Access; Impl : access Image_Impl; begin if From.Is_Null then return Util.Beans.Objects.Null_Object; end if; Obj := From.Get_Load_Object; Impl := Image_Impl (Obj.all)'Access; if Name = "id" then return ADO.Objects.To_Object (Impl.Get_Key); elsif Name = "width" then return Util.Beans.Objects.To_Object (Long_Long_Integer (Impl.Width)); elsif Name = "height" then return Util.Beans.Objects.To_Object (Long_Long_Integer (Impl.Height)); elsif Name = "thumb_width" then return Util.Beans.Objects.To_Object (Long_Long_Integer (Impl.Thumb_Width)); elsif Name = "thumb_height" then return Util.Beans.Objects.To_Object (Long_Long_Integer (Impl.Thumb_Height)); elsif Name = "path" then return Util.Beans.Objects.To_Object (Impl.Path); elsif Name = "public" then return Util.Beans.Objects.To_Object (Impl.Public); end if; return Util.Beans.Objects.Null_Object; end Get_Value; procedure List (Object : in out Image_Vector; Session : in out ADO.Sessions.Session'Class; Query : in ADO.SQL.Query'Class) is Stmt : ADO.Statements.Query_Statement := Session.Create_Statement (Query, IMAGE_DEF'Access); begin Stmt.Execute; Image_Vectors.Clear (Object); while Stmt.Has_Elements loop declare Item : Image_Ref; Impl : constant Image_Access := new Image_Impl; begin Impl.Load (Stmt, Session); ADO.Objects.Set_Object (Item, Impl.all'Access); Object.Append (Item); end; Stmt.Next; end loop; end List; -- ------------------------------ -- Load the object from current iterator position -- ------------------------------ procedure Load (Object : in out Image_Impl; Stmt : in out ADO.Statements.Query_Statement'Class; Session : in out ADO.Sessions.Session'Class) is begin Object.Set_Key_Value (Stmt.Get_Identifier (0)); Object.Width := Stmt.Get_Integer (1); Object.Height := Stmt.Get_Integer (2); Object.Thumb_Width := Stmt.Get_Integer (3); Object.Thumb_Height := Stmt.Get_Integer (4); Object.Path := Stmt.Get_Unbounded_String (5); Object.Public := Stmt.Get_Boolean (6); if not Stmt.Is_Null (8) then Object.Thumbnail.Set_Key_Value (Stmt.Get_Identifier (8), Session); end if; if not Stmt.Is_Null (9) then Object.Folder.Set_Key_Value (Stmt.Get_Identifier (9), Session); end if; if not Stmt.Is_Null (10) then Object.Owner.Set_Key_Value (Stmt.Get_Identifier (10), Session); end if; if not Stmt.Is_Null (11) then Object.Storage.Set_Key_Value (Stmt.Get_Identifier (11), Session); end if; Object.Version := Stmt.Get_Integer (7); ADO.Objects.Set_Created (Object); end Load; procedure Op_Load (Bean : in out Image_Bean; Outcome : in out Ada.Strings.Unbounded.Unbounded_String); procedure Op_Load (Bean : in out Image_Bean; Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is begin Image_Bean'Class (Bean).Load (Outcome); end Op_Load; package Binding_Image_Bean_1 is new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Image_Bean, Method => Op_Load, Name => "load"); Binding_Image_Bean_Array : aliased constant Util.Beans.Methods.Method_Binding_Array := (1 => Binding_Image_Bean_1.Proxy'Access ); -- ------------------------------ -- This bean provides some methods that can be used in a Method_Expression. -- ------------------------------ overriding function Get_Method_Bindings (From : in Image_Bean) return Util.Beans.Methods.Method_Binding_Array_Access is pragma Unreferenced (From); begin return Binding_Image_Bean_Array'Access; end Get_Method_Bindings; -- ------------------------------ -- Get the bean attribute identified by the name. -- ------------------------------ overriding function Get_Value (From : in Image_Bean; Name : in String) return Util.Beans.Objects.Object is begin if Name = "folder_id" then return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Folder_Id)); elsif Name = "folder_name" then return Util.Beans.Objects.To_Object (From.Folder_Name); elsif Name = "id" then return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Id)); elsif Name = "name" then return Util.Beans.Objects.To_Object (From.Name); elsif Name = "create_date" then return Util.Beans.Objects.Time.To_Object (From.Create_Date); elsif Name = "uri" then return Util.Beans.Objects.To_Object (From.Uri); elsif Name = "storage" then return AWA.Storages.Models.Storage_Type_Objects.To_Object (From.Storage); elsif Name = "mime_type" then return Util.Beans.Objects.To_Object (From.Mime_Type); elsif Name = "file_size" then return Util.Beans.Objects.To_Object (Long_Long_Integer (From.File_Size)); elsif Name = "is_public" then return Util.Beans.Objects.To_Object (From.Is_Public); elsif Name = "width" then return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Width)); elsif Name = "height" then return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Height)); end if; return Util.Beans.Objects.Null_Object; end Get_Value; -- ------------------------------ -- Set the value identified by the name -- ------------------------------ overriding procedure Set_Value (Item : in out Image_Bean; Name : in String; Value : in Util.Beans.Objects.Object) is begin if Name = "folder_id" then Item.Folder_Id := ADO.Identifier (Util.Beans.Objects.To_Long_Long_Integer (Value)); elsif Name = "folder_name" then Item.Folder_Name := Util.Beans.Objects.To_Unbounded_String (Value); elsif Name = "id" then Item.Id := ADO.Identifier (Util.Beans.Objects.To_Long_Long_Integer (Value)); elsif Name = "name" then Item.Name := Util.Beans.Objects.To_Unbounded_String (Value); elsif Name = "create_date" then Item.Create_Date := Util.Beans.Objects.Time.To_Time (Value); elsif Name = "uri" then Item.Uri := Util.Beans.Objects.To_Unbounded_String (Value); elsif Name = "storage" then Item.Storage := AWA.Storages.Models.Storage_Type_Objects.To_Value (Value); elsif Name = "mime_type" then Item.Mime_Type := Util.Beans.Objects.To_Unbounded_String (Value); elsif Name = "file_size" then Item.File_Size := Util.Beans.Objects.To_Integer (Value); elsif Name = "is_public" then Item.Is_Public := Util.Beans.Objects.To_Boolean (Value); elsif Name = "width" then Item.Width := Util.Beans.Objects.To_Integer (Value); elsif Name = "height" then Item.Height := Util.Beans.Objects.To_Integer (Value); end if; end Set_Value; -- -------------------- -- Read in the object the data from the query result and prepare to read the next row. -- If there is no row, raise the ADO.NOT_FOUND exception. -- -------------------- procedure Read (Into : in out Image_Bean; Stmt : in out ADO.Statements.Query_Statement'Class) is begin if not Stmt.Has_Elements then raise ADO.Objects.NOT_FOUND; end if; Into.Folder_Id := Stmt.Get_Identifier (0); Into.Folder_Name := Stmt.Get_Unbounded_String (1); Into.Id := Stmt.Get_Identifier (2); Into.Name := Stmt.Get_Unbounded_String (3); Into.Create_Date := Stmt.Get_Time (4); Into.Uri := Stmt.Get_Unbounded_String (5); Into.Storage := AWA.Storages.Models.Storage_Type'Val (Stmt.Get_Integer (6)); Into.Mime_Type := Stmt.Get_Unbounded_String (7); Into.File_Size := Stmt.Get_Integer (8); Into.Is_Public := Stmt.Get_Boolean (9); Into.Width := Stmt.Get_Integer (10); Into.Height := Stmt.Get_Integer (11); Stmt.Next; end Read; -- -------------------- -- Run the query controlled by <b>Context</b> and load the result in <b>Object</b>. -- -------------------- procedure Load (Object : in out Image_Bean'Class; Session : in out ADO.Sessions.Session'Class; Context : in out ADO.Queries.Context'Class) is Stmt : ADO.Statements.Query_Statement := Session.Create_Statement (Context); begin Stmt.Execute; Read (Object, Stmt); if Stmt.Has_Elements then raise ADO.Objects.NOT_FOUND; end if; end Load; -- ------------------------------ -- Get the bean attribute identified by the name. -- ------------------------------ overriding function Get_Value (From : in Image_Info; Name : in String) return Util.Beans.Objects.Object is begin if Name = "id" then return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Id)); elsif Name = "name" then return Util.Beans.Objects.To_Object (From.Name); elsif Name = "create_date" then return Util.Beans.Objects.Time.To_Object (From.Create_Date); elsif Name = "uri" then return Util.Beans.Objects.To_Object (From.Uri); elsif Name = "storage" then return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Storage)); elsif Name = "mime_type" then return Util.Beans.Objects.To_Object (From.Mime_Type); elsif Name = "file_size" then return Util.Beans.Objects.To_Object (Long_Long_Integer (From.File_Size)); elsif Name = "width" then return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Width)); elsif Name = "height" then return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Height)); elsif Name = "thumb_width" then return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Thumb_Width)); elsif Name = "thumb_height" then return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Thumb_Height)); elsif Name = "thumbnail_id" then return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Thumbnail_Id)); end if; return Util.Beans.Objects.Null_Object; end Get_Value; -- ------------------------------ -- Set the value identified by the name -- ------------------------------ overriding procedure Set_Value (Item : in out Image_Info; Name : in String; Value : in Util.Beans.Objects.Object) is begin if Name = "id" then Item.Id := ADO.Identifier (Util.Beans.Objects.To_Long_Long_Integer (Value)); elsif Name = "name" then Item.Name := Util.Beans.Objects.To_Unbounded_String (Value); elsif Name = "create_date" then Item.Create_Date := Util.Beans.Objects.Time.To_Time (Value); elsif Name = "uri" then Item.Uri := Util.Beans.Objects.To_Unbounded_String (Value); elsif Name = "storage" then Item.Storage := Util.Beans.Objects.To_Integer (Value); elsif Name = "mime_type" then Item.Mime_Type := Util.Beans.Objects.To_Unbounded_String (Value); elsif Name = "file_size" then Item.File_Size := Util.Beans.Objects.To_Integer (Value); elsif Name = "width" then Item.Width := Util.Beans.Objects.To_Integer (Value); elsif Name = "height" then Item.Height := Util.Beans.Objects.To_Integer (Value); elsif Name = "thumb_width" then Item.Thumb_Width := Util.Beans.Objects.To_Integer (Value); elsif Name = "thumb_height" then Item.Thumb_Height := Util.Beans.Objects.To_Integer (Value); elsif Name = "thumbnail_id" then Item.Thumbnail_Id := ADO.Identifier (Util.Beans.Objects.To_Long_Long_Integer (Value)); end if; end Set_Value; -- -------------------- -- Run the query controlled by <b>Context</b> and append the list in <b>Object</b>. -- -------------------- procedure List (Object : in out Image_Info_List_Bean'Class; Session : in out ADO.Sessions.Session'Class; Context : in out ADO.Queries.Context'Class) is begin List (Object.List, Session, Context); end List; -- -------------------- -- The list of images for a given folder. -- -------------------- procedure List (Object : in out Image_Info_Vector; Session : in out ADO.Sessions.Session'Class; Context : in out ADO.Queries.Context'Class) is procedure Read (Into : in out Image_Info); Stmt : ADO.Statements.Query_Statement := Session.Create_Statement (Context); Pos : Positive := 1; procedure Read (Into : in out Image_Info) is begin Into.Id := Stmt.Get_Identifier (0); Into.Name := Stmt.Get_Unbounded_String (1); Into.Create_Date := Stmt.Get_Time (2); Into.Uri := Stmt.Get_Unbounded_String (3); Into.Storage := Stmt.Get_Integer (4); Into.Mime_Type := Stmt.Get_Unbounded_String (5); Into.File_Size := Stmt.Get_Integer (6); Into.Width := Stmt.Get_Integer (7); Into.Height := Stmt.Get_Integer (8); Into.Thumb_Width := Stmt.Get_Integer (9); Into.Thumb_Height := Stmt.Get_Integer (10); Into.Thumbnail_Id := Stmt.Get_Identifier (11); end Read; begin Stmt.Execute; Image_Info_Vectors.Clear (Object); while Stmt.Has_Elements loop Object.Insert_Space (Before => Pos); Object.Update_Element (Index => Pos, Process => Read'Access); Pos := Pos + 1; Stmt.Next; end loop; end List; end AWA.Images.Models;
stcarrez/ada-awa
Ada
14,325
ads
----------------------------------------------------------------------- -- AWA.Votes.Models -- AWA.Votes.Models ----------------------------------------------------------------------- -- File generated by Dynamo DO NOT MODIFY -- Template used: templates/model/package-spec.xhtml -- Ada Generator: https://github.com/stcarrez/dynamo Version 1.4.0 ----------------------------------------------------------------------- -- Copyright (C) 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. ----------------------------------------------------------------------- pragma Warnings (Off); with ADO.Sessions; with ADO.Objects; with ADO.Statements; with ADO.SQL; with ADO.Schemas; with Ada.Containers.Vectors; with Ada.Strings.Unbounded; with Util.Beans.Objects; with Util.Beans.Basic.Lists; with Util.Beans.Methods; pragma Warnings (On); package AWA.Votes.Models is pragma Style_Checks ("-mrIu"); type Rating_Ref is new ADO.Objects.Object_Ref with null record; type Vote_Ref is new ADO.Objects.Object_Ref with null record; -- Create an object key for Rating. function Rating_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key; -- Create an object key for Rating from a string. -- Raises Constraint_Error if the string cannot be converted into the object key. function Rating_Key (Id : in String) return ADO.Objects.Object_Key; Null_Rating : constant Rating_Ref; function "=" (Left, Right : Rating_Ref'Class) return Boolean; -- Set the rating identifier procedure Set_Id (Object : in out Rating_Ref; Value : in ADO.Identifier); -- Get the rating identifier function Get_Id (Object : in Rating_Ref) return ADO.Identifier; -- Set the rating taking into account all votes procedure Set_Rating (Object : in out Rating_Ref; Value : in Integer); -- Get the rating taking into account all votes function Get_Rating (Object : in Rating_Ref) return Integer; -- Set the number of votes procedure Set_Vote_Count (Object : in out Rating_Ref; Value : in Integer); -- Get the number of votes function Get_Vote_Count (Object : in Rating_Ref) return Integer; -- procedure Set_For_Entity_Id (Object : in out Rating_Ref; Value : in ADO.Identifier); -- function Get_For_Entity_Id (Object : in Rating_Ref) return ADO.Identifier; -- Set the entity type procedure Set_For_Entity_Type (Object : in out Rating_Ref; Value : in ADO.Entity_Type); -- Get the entity type function Get_For_Entity_Type (Object : in Rating_Ref) return ADO.Entity_Type; -- Load the entity identified by 'Id'. -- Raises the NOT_FOUND exception if it does not exist. procedure Load (Object : in out Rating_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 Rating_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 Rating_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 Rating_Ref; Session : in out ADO.Sessions.Master_Session'Class); -- Delete the entity. overriding procedure Delete (Object : in out Rating_Ref; Session : in out ADO.Sessions.Master_Session'Class); overriding function Get_Value (From : in Rating_Ref; Name : in String) return Util.Beans.Objects.Object; -- Table definition RATING_TABLE : constant ADO.Schemas.Class_Mapping_Access; -- Internal method to allocate the Object_Record instance overriding procedure Allocate (Object : in out Rating_Ref); -- Copy of the object. procedure Copy (Object : in Rating_Ref; Into : in out Rating_Ref); -- -------------------- -- The vote table tracks a vote action by a user on a given database entity. -- The primary key is made of the user, the entity id and entity type. -- -------------------- -- Create an object key for Vote. function Vote_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key; -- Create an object key for Vote from a string. -- Raises Constraint_Error if the string cannot be converted into the object key. function Vote_Key (Id : in String) return ADO.Objects.Object_Key; Null_Vote : constant Vote_Ref; function "=" (Left, Right : Vote_Ref'Class) return Boolean; -- procedure Set_Rating (Object : in out Vote_Ref; Value : in Integer); -- function Get_Rating (Object : in Vote_Ref) return Integer; -- procedure Set_Entity (Object : in out Vote_Ref; Value : in Rating_Ref'Class); -- function Get_Entity (Object : in Vote_Ref) return Rating_Ref'Class; -- procedure Set_User_Id (Object : in out Vote_Ref; Value : in ADO.Identifier); -- function Get_User_Id (Object : in Vote_Ref) return ADO.Identifier; -- Load the entity identified by 'Id'. -- Raises the NOT_FOUND exception if it does not exist. procedure Load (Object : in out Vote_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 Vote_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 Vote_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 Vote_Ref; Session : in out ADO.Sessions.Master_Session'Class); -- Delete the entity. overriding procedure Delete (Object : in out Vote_Ref; Session : in out ADO.Sessions.Master_Session'Class); overriding function Get_Value (From : in Vote_Ref; Name : in String) return Util.Beans.Objects.Object; -- Table definition VOTE_TABLE : constant ADO.Schemas.Class_Mapping_Access; -- Internal method to allocate the Object_Record instance overriding procedure Allocate (Object : in out Vote_Ref); -- Copy of the object. procedure Copy (Object : in Vote_Ref; Into : in out Vote_Ref); type Vote_Bean is abstract new Util.Beans.Basic.Bean and Util.Beans.Methods.Method_Bean with record -- the permission name to check if the user is allowed to vote Permission : Ada.Strings.Unbounded.Unbounded_String; -- the entity identifier Entity_Id : ADO.Identifier; -- the user rating Rating : Integer; -- the entity type Entity_Type : Ada.Strings.Unbounded.Unbounded_String; -- the total rating for the entity Total : Integer; end record; -- This bean provides some methods that can be used in a Method_Expression. overriding function Get_Method_Bindings (From : in Vote_Bean) return Util.Beans.Methods.Method_Binding_Array_Access; -- Get the bean attribute identified by the name. overriding function Get_Value (From : in Vote_Bean; Name : in String) return Util.Beans.Objects.Object; -- Set the bean attribute identified by the name. overriding procedure Set_Value (Item : in out Vote_Bean; Name : in String; Value : in Util.Beans.Objects.Object); procedure Vote_Up (Bean : in out Vote_Bean; Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is abstract; procedure Vote_Down (Bean : in out Vote_Bean; Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is abstract; procedure Vote (Bean : in out Vote_Bean; Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is abstract; private RATING_NAME : aliased constant String := "awa_rating"; COL_0_1_NAME : aliased constant String := "id"; COL_1_1_NAME : aliased constant String := "rating"; COL_2_1_NAME : aliased constant String := "vote_count"; COL_3_1_NAME : aliased constant String := "for_entity_id"; COL_4_1_NAME : aliased constant String := "for_entity_type"; RATING_DEF : aliased constant ADO.Schemas.Class_Mapping := (Count => 5, Table => RATING_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) ); RATING_TABLE : constant ADO.Schemas.Class_Mapping_Access := RATING_DEF'Access; Null_Rating : constant Rating_Ref := Rating_Ref'(ADO.Objects.Object_Ref with null record); type Rating_Impl is new ADO.Objects.Object_Record (Key_Type => ADO.Objects.KEY_INTEGER, Of_Class => RATING_DEF'Access) with record Rating : Integer; Vote_Count : Integer; For_Entity_Id : ADO.Identifier; For_Entity_Type : ADO.Entity_Type; end record; type Rating_Access is access all Rating_Impl; overriding procedure Destroy (Object : access Rating_Impl); overriding procedure Find (Object : in out Rating_Impl; Session : in out ADO.Sessions.Session'Class; Query : in ADO.SQL.Query'Class; Found : out Boolean); overriding procedure Load (Object : in out Rating_Impl; Session : in out ADO.Sessions.Session'Class); procedure Load (Object : in out Rating_Impl; Stmt : in out ADO.Statements.Query_Statement'Class; Session : in out ADO.Sessions.Session'Class); overriding procedure Save (Object : in out Rating_Impl; Session : in out ADO.Sessions.Master_Session'Class); overriding procedure Create (Object : in out Rating_Impl; Session : in out ADO.Sessions.Master_Session'Class); overriding procedure Delete (Object : in out Rating_Impl; Session : in out ADO.Sessions.Master_Session'Class); procedure Set_Field (Object : in out Rating_Ref'Class; Impl : out Rating_Access); VOTE_NAME : aliased constant String := "awa_vote"; COL_0_2_NAME : aliased constant String := "rating"; COL_1_2_NAME : aliased constant String := "entity_id"; COL_2_2_NAME : aliased constant String := "user_id"; VOTE_DEF : aliased constant ADO.Schemas.Class_Mapping := (Count => 3, Table => VOTE_NAME'Access, Members => ( 1 => COL_0_2_NAME'Access, 2 => COL_1_2_NAME'Access, 3 => COL_2_2_NAME'Access) ); VOTE_TABLE : constant ADO.Schemas.Class_Mapping_Access := VOTE_DEF'Access; Null_Vote : constant Vote_Ref := Vote_Ref'(ADO.Objects.Object_Ref with null record); type Vote_Impl is new ADO.Objects.Object_Record (Key_Type => ADO.Objects.KEY_INTEGER, Of_Class => VOTE_DEF'Access) with record Rating : Integer; Entity : Rating_Ref; end record; type Vote_Access is access all Vote_Impl; overriding procedure Destroy (Object : access Vote_Impl); overriding procedure Find (Object : in out Vote_Impl; Session : in out ADO.Sessions.Session'Class; Query : in ADO.SQL.Query'Class; Found : out Boolean); overriding procedure Load (Object : in out Vote_Impl; Session : in out ADO.Sessions.Session'Class); procedure Load (Object : in out Vote_Impl; Stmt : in out ADO.Statements.Query_Statement'Class; Session : in out ADO.Sessions.Session'Class); overriding procedure Save (Object : in out Vote_Impl; Session : in out ADO.Sessions.Master_Session'Class); overriding procedure Create (Object : in out Vote_Impl; Session : in out ADO.Sessions.Master_Session'Class); overriding procedure Delete (Object : in out Vote_Impl; Session : in out ADO.Sessions.Master_Session'Class); procedure Set_Field (Object : in out Vote_Ref'Class; Impl : out Vote_Access); end AWA.Votes.Models;
kraileth/ravenadm
Ada
127,972
adb
-- This file is covered by the Internet Software Consortium (ISC) License -- Reference: ../License.txt with Ada.Characters.Latin_1; with Ada.Directories; with Ada.Exceptions; with Ada.Calendar; with Ada.Text_IO; with File_Operations; with Port_Specification.Buildsheet; with Port_Specification.Transform; with Port_Specification.Json; with Port_Specification.Web; with Specification_Parser; with PortScan.Log; with PortScan.Operations; with Parameters; with Utilities; with Replicant; with Signals; with Unix; package body PortScan.Scan is package UTL renames Utilities; package REP renames Replicant; package PM renames Parameters; package LOG renames PortScan.Log; package OPS renames PortScan.Operations; package FOP renames File_Operations; package PAR renames Specification_Parser; package PSB renames Port_Specification.Buildsheet; package PST renames Port_Specification.Transform; package WEB renames Port_Specification.Web; package PSP renames Port_Specification; package LAT renames Ada.Characters.Latin_1; package DIR renames Ada.Directories; package EX renames Ada.Exceptions; package TIO renames Ada.Text_IO; -------------------------------------------------------------------------------------------- -- scan_entire_ports_tree -------------------------------------------------------------------------------------------- function scan_entire_ports_tree (sysrootver : sysroot_characteristics) return Boolean is good_scan : Boolean; using_screen : constant Boolean := Unix.screen_attached; conspiracy : constant String := HT.USS (PM.configuration.dir_conspiracy); unkindness : constant String := HT.USS (PM.configuration.dir_unkindness); compiled_BS : constant String := HT.USS (PM.configuration.dir_profile) & "/unkindness"; begin -- Override BATCH_MODE setting when we build everything PM.configuration.batch_mode := True; -- All scanning done on host system (no need to mount in a slave) prescan_ports_tree (conspiracy, unkindness, sysrootver); prescan_unkindness (unkindness, compiled_BS); set_portlist_to_everything; LOG.set_scan_start_time (CAL.Clock); parallel_deep_scan (conspiracy => conspiracy, compiled_BS => compiled_BS, sysrootver => sysrootver, success => good_scan, show_progress => using_screen); LOG.set_scan_complete (CAL.Clock); return good_scan; exception when badscan : bad_index_data => TIO.Put_Line ("Index scan failed: " & EX.Exception_Message (badscan)); return False; when unknown : others => TIO.Put_Line ("scan_entire_ports_tree failed for unknown reason:"); TIO.Put_Line (EX.Exception_Information (unknown)); return False; end scan_entire_ports_tree; -------------------------------------------------------------------------------------------- -- generate_entire_website -------------------------------------------------------------------------------------------- function generate_entire_website (www_site : String; sysrootver : sysroot_characteristics) return Boolean is good_operation : Boolean; conspiracy : constant String := HT.USS (PM.configuration.dir_conspiracy); unkindness : constant String := HT.USS (PM.configuration.dir_unkindness); compiled_BS : constant String := HT.USS (PM.configuration.dir_profile) & "/unkindness"; sharedir : constant String := host_localbase & "/share/ravenadm"; ravencss : constant String := "/ravenports.css"; ravenboxpng : constant String := "/ravenports-200.png"; styledir : constant String := www_site & "/style"; begin -- Override BATCH_MODE setting when we build everything PM.configuration.batch_mode := True; -- All scanning done on host system (no need to mount in a slave) prescan_ports_tree (conspiracy, unkindness, sysrootver); prescan_unkindness (unkindness, compiled_BS); -- pre-place css file DIR.Create_Path (styledir); DIR.Copy_File (sharedir & ravencss, styledir & ravencss); DIR.Copy_File (sharedir & ravenboxpng, styledir & ravenboxpng); -- subcontract web site generation serially_generate_web_pages (www_site => www_site, sysrootver => sysrootver, success => good_operation); return good_operation; exception when badscan : bad_index_data => TIO.Put_Line ("Index scan failed: " & EX.Exception_Message (badscan)); return False; when unknown : others => TIO.Put_Line ("scan_entire_ports_tree failed for unknown reason:"); TIO.Put_Line (EX.Exception_Information (unknown)); return False; end generate_entire_website; -------------------------------------------------------------------------------------------- -- prescan_ports_tree -------------------------------------------------------------------------------------------- procedure prescan_ports_tree (conspiracy : String; unkindness : String; sysrootver : sysroot_characteristics) is conspindex_path : constant String := conspiracy & conspindex; custom_avail : constant Boolean := unkindness /= PM.no_unkindness; -- Disable parallel scanning (not reliable; make one scanner do everything -- max_lots : constant scanners := get_max_lots; max_lots : constant scanners := 1; begin if not DIR.Exists (conspindex_path) then raise missing_index with conspindex; end if; declare fulldata : String := FOP.get_file_contents (conspindex_path); markers : HT.Line_Markers; linenum : Natural := 0; begin HT.initialize_markers (fulldata, markers); loop exit when not HT.next_line_present (fulldata, markers); linenum := linenum + 1; declare line : constant String := HT.extract_line (fulldata, markers); bucket : constant String := HT.specific_field (line, 1); namebase : constant String := HT.specific_field (line, 2); numvar : constant String := HT.specific_field (line, 3); bsheet : constant String := "/bucket_" & bucket & "/" & namebase; linestr : constant String := ", line " & HT.int2str (linenum); varcount : Integer; begin if bucket'Length /= 2 or else namebase'Length = 0 or else numvar'Length = 0 then raise bad_index_data with conspindex & linestr; end if; begin varcount := Integer'Value (numvar); exception when others => raise bad_index_data with conspindex & ", numvariant field is not an integer" & linestr; end; if not DIR.Exists (conspiracy & bsheet) then raise bad_index_data with bsheet & " buildsheet does not exist" & linestr; end if; if custom_avail and then DIR.Exists (unkindness & bsheet) then -- postpone custom port scan (done prescan_unkindness) null; else for varx in Integer range 1 .. varcount loop declare varxname : constant String := HT.specific_field (line, varx + 3); portkey : HT.Text := HT.SUS (namebase & ":" & varxname); kc : portkey_crate.Cursor; success : Boolean; begin if varxname = "" then raise bad_index_data with conspindex & ", less variants than counter" & linestr; end if; ports_keys.Insert (Key => portkey, New_Item => lot_counter, Position => kc, Inserted => success); last_port := lot_counter; all_ports (lot_counter).sequence_id := lot_counter; all_ports (lot_counter).key_cursor := kc; all_ports (lot_counter).port_namebase := HT.SUS (namebase); all_ports (lot_counter).port_variant := HT.SUS (varxname); all_ports (lot_counter).bucket := bucket_code (bucket); all_ports (lot_counter).unkind_custom := False; make_queue (lot_number).Append (lot_counter); lot_counter := lot_counter + 1; if lot_number = max_lots then lot_number := 1; else lot_number := lot_number + 1; end if; end; end loop; end if; end; end loop; end; prescanned := True; end prescan_ports_tree; -------------------------------------------------------------------------------------------- -- prescan_unkindness -------------------------------------------------------------------------------------------- procedure prescan_unkindness (unkindness : String; compiled_BS : String) is unkinindex_path : constant String := compiled_BS & unkinindex; -- Disable parallel scanning (not reliable; make one scanner do everything -- max_lots : constant scanners := get_max_lots; max_lots : constant scanners := 1; begin if unkindness = PM.no_unkindness or else not DIR.Exists (unkinindex_path) then return; end if; declare fulldata : String := FOP.get_file_contents (unkinindex_path); markers : HT.Line_Markers; linenum : Natural := 0; begin HT.initialize_markers (fulldata, markers); loop exit when not HT.next_line_present (fulldata, markers); linenum := linenum + 1; declare line : constant String := HT.extract_line (fulldata, markers); bucket : constant String := HT.specific_field (line, 1); namebase : constant String := HT.specific_field (line, 2); numvar : constant String := HT.specific_field (line, 3); bsheet : constant String := "/bucket_" & bucket & "/" & namebase; linestr : constant String := ", line " & HT.int2str (linenum); varcount : Integer; begin if bucket'Length /= 2 or else namebase'Length = 0 or else numvar'Length = 0 then raise bad_index_data with unkinindex & linestr; end if; begin varcount := Integer'Value (numvar); exception when others => raise bad_index_data with unkinindex & ", numvariant fields not an integer" & linestr; end; if not DIR.Exists (compiled_BS & bsheet) then raise bad_index_data with unkinindex & bsheet & " buildsheet does not exist" & linestr; end if; for varx in Integer range 1 .. varcount loop declare use type portkey_crate.Cursor; varxname : constant String := HT.specific_field (line, varx + 3); portkey : HT.Text := HT.SUS (namebase & ":" & varxname); kc : portkey_crate.Cursor; success : Boolean; begin if varxname = "" then raise bad_index_data with unkinindex & ", less variants than counter" & linestr; end if; if ports_keys.Contains (portkey) then kc := ports_keys.Find (portkey); for x in 1 .. last_port loop if all_ports (x).key_cursor = kc then all_ports (x).unkind_custom := True; exit; end if; end loop; else ports_keys.Insert (Key => portkey, New_Item => lot_counter, Position => kc, Inserted => success); last_port := lot_counter; all_ports (lot_counter).sequence_id := lot_counter; all_ports (lot_counter).key_cursor := kc; all_ports (lot_counter).port_namebase := HT.SUS (namebase); all_ports (lot_counter).port_variant := HT.SUS (varxname); all_ports (lot_counter).bucket := bucket_code (bucket); all_ports (lot_counter).unkind_custom := True; make_queue (lot_number).Append (lot_counter); lot_counter := lot_counter + 1; if lot_number = max_lots then lot_number := 1; else lot_number := lot_number + 1; end if; end if; end; end loop; end; end loop; end; end prescan_unkindness; -------------------------------------------------------------------------------------------- -- set_portlist_to_everything -------------------------------------------------------------------------------------------- procedure set_portlist_to_everything is begin for x in 0 .. last_port loop declare portkey : String := get_port_variant (all_ports (x)); begin if not HT.equivalent (all_ports (x).port_namebase, default_compiler) then portlist.Append (HT.SUS (portkey)); end if; end; end loop; end set_portlist_to_everything; -------------------------------------------------------------------------------------------- -- get_max_lots -------------------------------------------------------------------------------------------- function get_max_lots return scanners is first_try : constant Positive := Positive (PM.configuration.number_cores) * 3; begin if first_try > Positive (scanners'Last) then return scanners'Last; else return scanners (first_try); end if; end get_max_lots; -------------------------------------------------------------------------------------------- -- parallel_deep_scan -------------------------------------------------------------------------------------------- procedure parallel_deep_scan (conspiracy : String; compiled_BS : String; sysrootver : sysroot_characteristics; success : out Boolean; show_progress : Boolean) is finished : array (scanners) of Boolean := (others => False); combined_wait : Boolean := True; aborted : Boolean := False; task type scan (lot : scanners) is pragma Storage_Size (task_stack_limit); end scan; task body scan is procedure populate (cursor : subqueue.Cursor); procedure populate (cursor : subqueue.Cursor) is target_port : port_index := subqueue.Element (cursor); begin if not aborted then populate_port_data (conspiracy => conspiracy, compiled_BS => compiled_BS, target => target_port, always_build => False, sysrootver => sysrootver); mq_progress (lot) := mq_progress (lot) + 1; end if; exception when issue : others => aborted := True; TIO.Put_Line ("Scan aborted"); TIO.Put_Line ("culprit: " & get_port_variant (all_ports (target_port))); TIO.Put_Line (EX.Exception_Information (issue)); end populate; begin make_queue (lot).Iterate (populate'Access); finished (lot) := True; end scan; scan_01 : scan (lot => 1); scan_02 : scan (lot => 2); scan_03 : scan (lot => 3); scan_04 : scan (lot => 4); scan_05 : scan (lot => 5); scan_06 : scan (lot => 6); scan_07 : scan (lot => 7); scan_08 : scan (lot => 8); scan_09 : scan (lot => 9); scan_10 : scan (lot => 10); scan_11 : scan (lot => 11); scan_12 : scan (lot => 12); scan_13 : scan (lot => 13); scan_14 : scan (lot => 14); scan_15 : scan (lot => 15); scan_16 : scan (lot => 16); scan_17 : scan (lot => 17); scan_18 : scan (lot => 18); scan_19 : scan (lot => 19); scan_20 : scan (lot => 20); scan_21 : scan (lot => 21); scan_22 : scan (lot => 22); scan_23 : scan (lot => 23); scan_24 : scan (lot => 24); scan_25 : scan (lot => 25); scan_26 : scan (lot => 26); scan_27 : scan (lot => 27); scan_28 : scan (lot => 28); scan_29 : scan (lot => 29); scan_30 : scan (lot => 30); scan_31 : scan (lot => 31); scan_32 : scan (lot => 32); -- Expansion of cpu_range from 32 to 64 means 64 possible scanners scan_33 : scan (lot => 33); scan_34 : scan (lot => 34); scan_35 : scan (lot => 35); scan_36 : scan (lot => 36); scan_37 : scan (lot => 37); scan_38 : scan (lot => 38); scan_39 : scan (lot => 39); scan_40 : scan (lot => 40); scan_41 : scan (lot => 41); scan_42 : scan (lot => 42); scan_43 : scan (lot => 43); scan_44 : scan (lot => 44); scan_45 : scan (lot => 45); scan_46 : scan (lot => 46); scan_47 : scan (lot => 47); scan_48 : scan (lot => 48); scan_49 : scan (lot => 49); scan_50 : scan (lot => 50); scan_51 : scan (lot => 51); scan_52 : scan (lot => 52); scan_53 : scan (lot => 53); scan_54 : scan (lot => 54); scan_55 : scan (lot => 55); scan_56 : scan (lot => 56); scan_57 : scan (lot => 57); scan_58 : scan (lot => 58); scan_59 : scan (lot => 59); scan_60 : scan (lot => 60); scan_61 : scan (lot => 61); scan_62 : scan (lot => 62); scan_63 : scan (lot => 63); scan_64 : scan (lot => 64); begin TIO.Put_Line ("Scanning entire ports tree."); while combined_wait loop delay 1.0; if show_progress then TIO.Put (scan_progress); end if; combined_wait := False; for j in scanners'Range loop if not finished (j) then combined_wait := True; exit; end if; end loop; if Signals.graceful_shutdown_requested then aborted := True; end if; end loop; success := not aborted; end parallel_deep_scan; -------------------------------------------------------------------------------------------- -- skeleton_compiler_data -------------------------------------------------------------------------------------------- procedure skeleton_compiler_data (conspiracy : String; compiled_BS : String; target : port_index; sysrootver : sysroot_characteristics) is rec : port_record renames all_ports (target); function calc_dossier return String; thespec : PSP.Portspecs; successful : Boolean; variant : constant String := HT.USS (rec.port_variant); osrelease : constant String := HT.USS (sysrootver.release); function calc_dossier return String is buildsheet : String := "/bucket_" & rec.bucket & "/" & HT.USS (rec.port_namebase); begin if rec.unkind_custom then return compiled_BS & buildsheet; else return conspiracy & buildsheet; end if; end calc_dossier; begin OPS.parse_and_transform_buildsheet (specification => thespec, successful => successful, buildsheet => calc_dossier, variant => variant, portloc => "", excl_targets => True, avoid_dialog => True, for_webpage => False, sysrootver => sysrootver); if not successful then raise bsheet_parsing with calc_dossier & "-> " & thespec.get_parse_error; end if; rec.pkgversion := HT.SUS (thespec.calculate_pkgversion); rec.ignore_reason := HT.SUS (thespec.aggregated_ignore_reason); rec.ignored := not HT.IsBlank (rec.ignore_reason); rec.scanned := False; for item in Positive range 1 .. thespec.get_subpackage_length (variant) loop declare newrec : subpackage_record; subpackage : String := thespec.get_subpackage_item (variant, item); begin newrec.subpackage := HT.SUS (subpackage); newrec.never_remote := True; newrec.pkg_present := True; rec.subpackages.Append (newrec); end; end loop; end skeleton_compiler_data; -------------------------------------------------------------------------------------------- -- populate_port_data -------------------------------------------------------------------------------------------- procedure populate_port_data (conspiracy : String; compiled_BS : String; target : port_index; always_build : Boolean; sysrootver : sysroot_characteristics) is rec : port_record renames all_ports (target); function calc_dossier return String; thespec : PSP.Portspecs; successful : Boolean; variant : constant String := HT.USS (rec.port_variant); osrelease : constant String := HT.USS (sysrootver.release); prime_pkg : HT.Text := HT.blank; function calc_dossier return String is buildsheet : String := "/bucket_" & rec.bucket & "/" & HT.USS (rec.port_namebase); begin if rec.unkind_custom then return compiled_BS & buildsheet; else return conspiracy & buildsheet; end if; end calc_dossier; begin OPS.parse_and_transform_buildsheet (specification => thespec, successful => successful, buildsheet => calc_dossier, variant => variant, portloc => "", excl_targets => True, avoid_dialog => False, for_webpage => False, sysrootver => sysrootver); if not successful then raise bsheet_parsing with calc_dossier & "-> " & thespec.get_parse_error; end if; rec.pkgversion := HT.SUS (thespec.calculate_pkgversion); rec.ignore_reason := HT.SUS (thespec.aggregated_ignore_reason); rec.ignored := not HT.IsBlank (rec.ignore_reason); rec.scanned := True; for item in Positive range 1 .. thespec.get_list_length (PSP.sp_build_deps) loop populate_set_depends (target, thespec.get_list_item (PSP.sp_build_deps, item), build); end loop; for item in Positive range 1 .. thespec.get_list_length (PSP.sp_buildrun_deps) loop populate_set_depends (target, thespec.get_list_item (PSP.sp_buildrun_deps, item), buildrun); end loop; for item in Positive range 1 .. thespec.get_list_length (PSP.sp_run_deps) loop populate_set_depends (target, thespec.get_list_item (PSP.sp_run_deps, item), runtime); end loop; for item in Positive range 1 .. thespec.get_subpackage_length (variant) loop declare newrec : subpackage_record; subpackage : String := thespec.get_subpackage_item (variant, item); is_primary : Boolean := False; begin newrec.subpackage := HT.SUS (subpackage); newrec.never_remote := always_build; if subpackage /= spkg_complete and then subpackage /= spkg_examples and then subpackage /= spkg_docs and then subpackage /= spkg_nls and then HT.IsBlank (prime_pkg) then prime_pkg := newrec.subpackage; is_primary := True; end if; for subitem in Positive range 1 .. thespec.get_number_extra_run (subpackage) loop declare dep : String := thespec.get_extra_runtime (subpackage, subitem); begin populate_set_depends (target, dep, extra_runtime); declare -- These will pass because populate_set_depends didn't throw exception portkey : HT.Text := HT.SUS (convert_tuple_to_portkey (dep)); depindex : port_index := ports_keys.Element (portkey); idrec : subpackage_identifier; begin idrec.port := depindex; idrec.subpackage := HT.SUS (extract_subpackage (dep)); if not newrec.spkg_run_deps.Contains (idrec) then newrec.spkg_run_deps.Append (idrec); end if; end; end; end loop; if is_primary then for si in Positive range 1 .. thespec.get_list_length (PSP.sp_buildrun_deps) loop declare dep : String := thespec.get_list_item (PSP.sp_buildrun_deps, si); portkey : HT.Text := HT.SUS (convert_tuple_to_portkey (dep)); depindex : port_index := ports_keys.Element (portkey); idrec : subpackage_identifier; begin idrec.port := depindex; idrec.subpackage := HT.SUS (extract_subpackage (dep)); if not newrec.spkg_run_deps.Contains (idrec) then newrec.spkg_run_deps.Append (idrec); end if; end; end loop; for si in Positive range 1 .. thespec.get_list_length (PSP.sp_run_deps) loop declare dep : String := thespec.get_list_item (PSP.sp_run_deps, si); portkey : HT.Text := HT.SUS (convert_tuple_to_portkey (dep)); depindex : port_index := ports_keys.Element (portkey); idrec : subpackage_identifier; begin idrec.port := depindex; idrec.subpackage := HT.SUS (extract_subpackage (dep)); if not newrec.spkg_run_deps.Contains (idrec) then newrec.spkg_run_deps.Append (idrec); end if; end; end loop; end if; if subpackage = spkg_complete then for si in Positive range 1 .. thespec.get_subpackage_length (variant) loop declare innersub : constant String := thespec.get_subpackage_item (variant, si); idrec : subpackage_identifier; begin if innersub /= spkg_complete then idrec.port := target; idrec.subpackage := HT.SUS (innersub); if not newrec.spkg_run_deps.Contains (idrec) then newrec.spkg_run_deps.Append (idrec); end if; end if; end; end loop; end if; rec.subpackages.Append (newrec); end; end loop; if variant = variant_standard then for item in Positive range 1 .. thespec.get_list_length (PSP.sp_opts_standard) loop declare optname : String := thespec.get_list_item (PSP.sp_opts_standard, item); begin if optname /= options_none then populate_option (target, optname, thespec.option_current_setting (optname)); end if; end; end loop; else for item in Positive range 1 .. thespec.get_list_length (PSP.sp_opts_avail) loop declare optname : String := thespec.get_list_item (PSP.sp_opts_avail, item); begin populate_option (target, optname, thespec.option_current_setting (optname)); end; end loop; end if; end populate_port_data; -------------------------------------------------------------------------------------------- -- populate_option -------------------------------------------------------------------------------------------- procedure populate_option (target : port_index; option_name : String; setting : Boolean) is optname_text : HT.Text := HT.SUS (option_name); begin if not all_ports (target).options.Contains (optname_text) then all_ports (target).options.Insert (Key => optname_text, New_Item => setting); end if; end populate_option; -------------------------------------------------------------------------------------------- -- populate_set_depends -------------------------------------------------------------------------------------------- procedure populate_set_depends (target : port_index; tuple : String; dtype : dependency_type) is portkey : HT.Text := HT.SUS (convert_tuple_to_portkey (tuple)); depindex : port_index; begin if not ports_keys.Contains (portkey) then raise populate_error with "dependency on non-existent port " & tuple; end if; depindex := ports_keys.Element (portkey); if target = depindex then if dtype = extra_runtime then return; else raise populate_error with tuple & " can't depend on itself (" & get_port_variant (all_ports (depindex)) & ")"; end if; end if; if HT.USS (all_ports (depindex).port_namebase) = default_compiler then if dtype = extra_runtime then return; else raise populate_error with tuple & " belongs to the default compiler which is a " & "special case that can only be specified via EXRUN"; end if; end if; if not all_ports (target).blocked_by.Contains (depindex) then all_ports (target).blocked_by.Insert (depindex, depindex); end if; if dtype in LR_set and then not all_ports (target).run_deps.Contains (depindex) then all_ports (target).run_deps.Insert (Key => depindex, New_Item => depindex); end if; end populate_set_depends; -------------------------------------------------------------------------------------------- -- convert_tuple_to_portkey -------------------------------------------------------------------------------------------- function convert_tuple_to_portkey (tuple : String) return String is -- tuple format is <namebase>:<subpackage>:<variant> -- portkey format is <namebase>-<variant> begin if HT.count_char (tuple, LAT.Colon) /= 2 then raise populate_error with "tuple has invalid format: " & tuple; end if; declare namebase : String := HT.specific_field (tuple, 1, ":"); variant : String := HT.specific_field (tuple, 3, ":"); begin return namebase & LAT.Colon & variant; end; end convert_tuple_to_portkey; -------------------------------------------------------------------------------------------- -- extract_subpackage -------------------------------------------------------------------------------------------- function extract_subpackage (tuple : String) return String is -- tuple format is <namebase>:<subpackage>:<variant> begin if HT.count_char (tuple, LAT.Colon) /= 2 then raise populate_error with "tuple has invalid format: " & tuple; end if; return HT.tail (HT.head (tuple, ":"), ":"); end extract_subpackage; -------------------------------------------------------------------------------------------- -- scan_single_port -------------------------------------------------------------------------------------------- function scan_single_port (namebase : String; variant : String; always_build : Boolean; sysrootver : sysroot_characteristics; fatal : out Boolean) return Boolean is procedure dig (cursor : block_crate.Cursor); conspiracy : constant String := HT.USS (PM.configuration.dir_conspiracy); unkindness : constant String := HT.USS (PM.configuration.dir_unkindness); compiled_BS : constant String := HT.USS (PM.configuration.dir_profile) & "/unkindness"; two_partid : constant String := namebase & LAT.Colon & variant; portkey : HT.Text := HT.SUS (two_partid); target : port_index; aborted : Boolean := False; indy500 : Boolean := False; procedure dig (cursor : block_crate.Cursor) is new_target : port_index := block_crate.Element (cursor); begin if not aborted then if all_ports (new_target).scan_locked then -- We've already seen this (circular dependency) raise circular_logic; end if; if not all_ports (new_target).scanned then populate_port_data (conspiracy => conspiracy, compiled_BS => compiled_BS, target => new_target, always_build => False, sysrootver => sysrootver); all_ports (new_target).scan_locked := True; all_ports (new_target).blocked_by.Iterate (dig'Access); all_ports (new_target).scan_locked := False; if indy500 then TIO.Put_Line ("... backtrace " & get_port_variant (all_ports (new_target))); end if; end if; end if; exception when issue : circular_logic => aborted := True; indy500 := True; TIO.Put_Line (LAT.LF & two_partid & " scan aborted because a circular dependency on " & get_port_variant (all_ports (new_target)) & " was detected."); when issue : populate_error => aborted := True; TIO.Put_Line ("Scan aborted during port data population."); TIO.Put_Line (EX.Exception_Message (issue)); when issue : others => aborted := True; TIO.Put_Line ("Scan aborted for an unknown reason."); TIO.Put_Line (EX.Exception_Message (issue)); end dig; begin fatal := False; if not prescanned then begin prescan_ports_tree (conspiracy, unkindness, sysrootver); prescan_unkindness (unkindness, compiled_BS); exception when badscan : bad_index_data => TIO.Put_Line ("Index scan failed: " & EX.Exception_Message (badscan)); return False; when unknown : others => TIO.Put_Line ("scan_entire_ports_tree failed for unknown reason:"); TIO.Put_Line (EX.Exception_Information (unknown)); return False; end; end if; if ports_keys.Contains (portkey) then target := ports_keys.Element (portkey); else TIO.Put_Line (namebase & " specification not listed in Mk/Misc/conspiracy-variants, "); TIO.Put_Line ("nor found in the custom ports directory"); return False; end if; begin if all_ports (target).scanned then -- This can happen when a dpendency is also on the build list. return True; else populate_port_data (conspiracy => conspiracy, compiled_BS => compiled_BS, target => target, always_build => always_build, sysrootver => sysrootver); end if; exception when issue : others => TIO.Put_Line ("Encountered issue with " & two_partid & " or its dependencies" & LAT.LF & " => " & EX.Exception_Message (issue)); return False; end; all_ports (target).scan_locked := True; all_ports (target).blocked_by.Iterate (dig'Access); all_ports (target).scan_locked := False; if indy500 then TIO.Put_Line ("... backtrace " & two_partid); fatal := True; end if; return not aborted; end scan_single_port; -------------------------------------------------------------------------------------------- -- set_build_priority -------------------------------------------------------------------------------------------- procedure set_build_priority is begin iterate_reverse_deps; iterate_drill_down; end set_build_priority; -------------------------------------------------------------------------------------------- -- iterate_reverse_deps -------------------------------------------------------------------------------------------- procedure iterate_reverse_deps is procedure set_reverse (cursor : block_crate.Cursor); victim : port_index; procedure set_reverse (cursor : block_crate.Cursor) is blocker : port_index renames block_crate.Element (cursor); begin -- Using conditional insert here causes a finalization error when -- the program exists. Reluctantly, do the condition check manually if not all_ports (blocker).blocks.Contains (victim) then all_ports (blocker).blocks.Insert (victim, victim); end if; end set_reverse; begin for port in port_index'First .. last_port loop if all_ports (port).scanned then victim := port; all_ports (port).blocked_by.Iterate (set_reverse'Access); end if; end loop; end iterate_reverse_deps; -------------------------------------------------------------------------------------------- -- iterate_reverse_deps -------------------------------------------------------------------------------------------- procedure iterate_drill_down is monaco : Boolean := False; begin rank_queue.Clear; for port in port_index'First .. last_port loop if all_ports (port).scanned then drill_down (next_target => port, circular_flag => monaco); declare ndx : constant port_index := port_index (all_ports (port).reverse_score); QR : constant queue_record := (ap_index => port, reverse_score => ndx); begin rank_queue.Insert (New_Item => QR); end; end if; if monaco then raise circular_logic with "Circular dependency detected during drill down"; end if; end loop; end iterate_drill_down; -------------------------------------------------------------------------------------------- -- drill_down -------------------------------------------------------------------------------------------- procedure drill_down (next_target : port_index; circular_flag : in out Boolean) is procedure stamp_and_drill (cursor : block_crate.Cursor); procedure slurp_scanned (cursor : block_crate.Cursor); rec : port_record renames all_ports (next_target); procedure slurp_scanned (cursor : block_crate.Cursor) is rev_id : port_index := block_crate.Element (Position => cursor); begin if not all_ports (next_target).all_reverse.Contains (rev_id) then all_ports (next_target).all_reverse.Insert (rev_id, rev_id); end if; end slurp_scanned; procedure stamp_and_drill (cursor : block_crate.Cursor) is pmc : port_index := block_crate.Element (Position => cursor); begin if all_ports (pmc).scan_locked then -- We've already seen this port (circular dependency) circular_flag := True; TIO.Put_Line ("!! Dependency violation on " & get_port_variant (all_ports (pmc))); else if not all_ports (next_target).all_reverse.Contains (pmc) then all_ports (next_target).all_reverse.Insert (pmc, pmc); end if; if not all_ports (pmc).rev_scanned then drill_down (next_target => pmc, circular_flag => circular_flag); end if; all_ports (pmc).all_reverse.Iterate (slurp_scanned'Access); end if; end stamp_and_drill; begin if not rec.scanned then return; end if; if rec.rev_scanned or else circular_flag then -- It is possible to get here if an earlier port scanned this port -- as a reverse dependencies return; end if; rec.scan_locked := True; rec.blocks.Iterate (stamp_and_drill'Access); rec.scan_locked := False; rec.reverse_score := port_index (rec.all_reverse.Length); rec.rev_scanned := True; if circular_flag then TIO.Put_Line ("... backtrace " & get_port_variant (all_ports (next_target))); end if; end drill_down; -------------------------------------------------------------------------------------------- -- scan_provided_list_of_ports -------------------------------------------------------------------------------------------- function scan_provided_list_of_ports (always_build : Boolean; sysrootver : sysroot_characteristics) return Boolean is procedure scan (plcursor : string_crate.Cursor); successful : Boolean := True; just_stop_now : Boolean; compiler_key : HT.Text := HT.SUS (default_compiler & ":" & variant_standard); procedure scan (plcursor : string_crate.Cursor) is origin : constant String := HT.USS (string_crate.Element (plcursor)); namebase : constant String := HT.part_1 (origin, ":"); variant : constant String := HT.part_2 (origin, ":"); begin if not successful then return; end if; if Signals.graceful_shutdown_requested then successful := False; return; end if; if not scan_single_port (namebase => namebase, variant => variant, always_build => always_build, sysrootver => sysrootver, fatal => just_stop_now) then if just_stop_now then -- backtrace outputs, no need for more information. null; else TIO.Put_Line ("Scan of " & origin & " failed, bulk run cancelled"); end if; successful := False; end if; end scan; begin portlist.Iterate (Process => scan'Access); if successful and then not portlist.Contains (compiler_key) then -- We always need current information on the default compiler declare compiled_BS : String := HT.USS (PM.configuration.dir_profile) & "/unkindness"; begin skeleton_compiler_data (conspiracy => HT.USS (PM.configuration.dir_conspiracy), compiled_BS => compiled_BS, target => ports_keys.Element (compiler_key), sysrootver => sysrootver); exception when others => TIO.Put_Line ("Scan of the compiler port failed, fatal issue"); successful := False; end; end if; return successful; end scan_provided_list_of_ports; -------------------------------------------------------------------------------------------- -- generate_conspiracy_index -------------------------------------------------------------------------------------------- function tohex (value : AF) return Character is begin case value is when 0 .. 9 => return Character'Val (Character'Pos ('0') + value); when others => return Character'Val (Character'Pos ('A') + value - 10); end case; end tohex; -------------------------------------------------------------------------------------------- -- generate_conspiracy_index -------------------------------------------------------------------------------------------- procedure generate_conspiracy_index (sysrootver : sysroot_characteristics) is procedure scan_port (position : string_crate.Cursor); conspiracy : constant String := HT.USS (PM.configuration.dir_conspiracy); misc_dir : constant String := conspiracy & "/Mk/Misc/"; finalcvar : constant String := misc_dir & "conspiracy_variants"; finalfpceq : constant String := misc_dir & "fpc_equivalents"; summary : constant String := misc_dir & "summary.txt"; repology : constant String := misc_dir & "repology.json"; indexfile : TIO.File_Type; fpcfile : TIO.File_Type; repofile : TIO.File_Type; bucket : bucket_code; total_ports : Natural := 0; total_variants : Natural := 0; total_subpkgs : Natural := 0; procedure scan_port (position : string_crate.Cursor) is namebase : String := HT.USS (string_crate.Element (position)); successful : Boolean; customspec : PSP.Portspecs; arch_focus : supported_arch := x86_64; -- unused, pick one dossier : constant String := conspiracy & "/bucket_" & bucket & "/" & namebase; begin PAR.parse_specification_file (dossier => dossier, spec => customspec, opsys_focus => platform_type, arch_focus => arch_focus, success => successful, stop_at_targets => True); if not successful then raise bsheet_parsing with dossier & "-> " & customspec.get_parse_error; end if; declare varcnt : Natural := customspec.get_number_of_variants; varlist : String := customspec.get_field_value (PSP.sp_variants); begin total_ports := total_ports + 1; total_variants := total_variants + varcnt; TIO.Put (indexfile, bucket & " " & namebase & " " & HT.int2str (varcnt)); for varx in Integer range 1 .. varcnt loop declare variant : String := HT.specific_field (varlist, varx, ", "); spkgcnt : Natural := customspec.get_subpackage_length (variant); begin total_subpkgs := total_subpkgs + spkgcnt; TIO.Put (indexfile, " " & variant); end; end loop; TIO.Put_Line (indexfile, ""); declare vers : constant String := customspec.get_field_value (PSP.sp_version); begin TIO.Put (fpcfile, namebase & " " & vers & " "); if customspec.port_is_generated then TIO.Put_Line (fpcfile, "generated"); else TIO.Put_Line (fpcfile, customspec.equivalent_fpc_port); end if; end; Port_Specification.Json.describe_port (specs => customspec, dossier => repofile, bucket => bucket, index => total_ports); end; end scan_port; begin LOG.set_scan_start_time (CAL.Clock); TIO.Create (File => indexfile, Mode => TIO.Out_File, Name => finalcvar); TIO.Create (File => fpcfile, Mode => TIO.Out_File, Name => finalfpceq); TIO.Create (File => repofile, Mode => TIO.Out_File, Name => repology); TIO.Put (repofile, UTL.json_object (True, 0, 1) & UTL.json_name_complex ("ravenports", 1, 1) & UTL.json_array (True, 2)); for highdigit in AF'Range loop for lowdigit in AF'Range loop bucket := tohex (highdigit) & tohex (lowdigit); declare bucket_dir : constant String := conspiracy & "/bucket_" & bucket; Inner_Search : DIR.Search_Type; Inner_Dirent : DIR.Directory_Entry_Type; tempstore : string_crate.Vector; use type DIR.File_Kind; begin if DIR.Exists (bucket_dir) and then DIR.Kind (bucket_dir) = DIR.Directory then DIR.Start_Search (Search => Inner_Search, Directory => bucket_dir, Filter => (DIR.Ordinary_File => True, others => False), Pattern => "*"); while DIR.More_Entries (Inner_Search) loop DIR.Get_Next_Entry (Search => Inner_Search, Directory_Entry => Inner_Dirent); tempstore.Append (HT.SUS (DIR.Simple_Name (Inner_Dirent))); end loop; DIR.End_Search (Inner_Search); sorter.Sort (tempstore); tempstore.Iterate (scan_port'Access); end if; end; end loop; end loop; TIO.Close (indexfile); TIO.Close (fpcfile); LOG.set_scan_complete (CAL.Clock); TIO.Put_Line ("Index successfully generated."); TIO.Put_Line (" Total ports : " & HT.int2str (total_ports)); TIO.Put_Line (" Total variants : " & HT.int2str (total_variants)); TIO.Put_Line (" Total packages : " & HT.int2str (total_subpkgs)); TIO.Put_Line (" Linear scan time : " & LOG.scan_duration); TIO.Put_Line (repofile, UTL.json_array (False, 2) & UTL.json_name_complex ("summary", 2, 1) & UTL.json_object (True, 2, 1) & UTL.json_nvpair_integer ("ports", total_ports, 1, 3) & UTL.json_nvpair_integer ("variants", total_variants, 2, 3) & UTL.json_nvpair_integer ("packages", total_subpkgs, 3, 3) & UTL.json_object (False, 2, 1) & LAT.Right_Curly_Bracket); TIO.Create (File => indexfile, Mode => TIO.Out_File, Name => summary); TIO.Put_Line (indexfile, " Statistics derived from generation of conspiracy index"); TIO.Put_Line (indexfile, "=========================================================="); TIO.Put_Line (indexfile, " Total ports : " & HT.int2str (total_ports)); TIO.Put_Line (indexfile, " Total variants : " & HT.int2str (total_variants)); TIO.Put_Line (indexfile, " Total packages : " & HT.int2str (total_subpkgs)); TIO.Put_Line (indexfile, " Linear scan time : " & LOG.scan_duration); TIO.Close (indexfile); exception when issue : others => if TIO.Is_Open (indexfile) then TIO.Close (indexfile); end if; if TIO.Is_Open (fpcfile) then TIO.Close (fpcfile); end if; if TIO.Is_Open (repofile) then TIO.Close (repofile); end if; TIO.Put_Line ("generate_conspiracy_index failure: " & EX.Exception_Message (issue)); end generate_conspiracy_index; -------------------------------------------------------------------------------------------- -- generate_all_buildsheets -------------------------------------------------------------------------------------------- procedure generate_all_buildsheets (ravensource : String) is max_lots : constant scanners := get_max_lots; consdir : constant String := HT.USS (PM.configuration.dir_conspiracy); release : constant String := "1"; source : array (scanners) of string_crate.Vector; counter : scanners := scanners'First; aborted : Boolean := False; bucket : bucket_code; begin for highdigit in AF'Range loop for lowdigit in AF'Range loop bucket := tohex (highdigit) & tohex (lowdigit); declare bucket_dir : constant String := ravensource & "/bucket_" & bucket; Inner_Search : DIR.Search_Type; Inner_Dirent : DIR.Directory_Entry_Type; use type DIR.File_Kind; begin if DIR.Exists (bucket_dir) and then DIR.Kind (bucket_dir) = DIR.Directory then DIR.Start_Search (Search => Inner_Search, Directory => bucket_dir, Filter => (DIR.Directory => True, others => False), Pattern => "*"); while DIR.More_Entries (Inner_Search) loop DIR.Get_Next_Entry (Search => Inner_Search, Directory_Entry => Inner_Dirent); declare dsn : constant String := DIR.Simple_Name (Inner_Dirent); begin if dsn /= "." and then dsn /= ".." then source (counter).Append (HT.SUS (bucket & "/" & dsn)); if counter = max_lots then counter := scanners'First; else counter := counter + 1; end if; end if; end; end loop; DIR.End_Search (Inner_Search); end if; end; end loop; end loop; LOG.set_scan_start_time (CAL.Clock); declare finished : array (scanners) of Boolean := (others => False); combined_wait : Boolean := True; task type scan (lot : scanners) is pragma Storage_Size (task_stack_limit); end scan; task body scan is procedure make_buildsheet (cursor : string_crate.Cursor); procedure make_buildsheet (cursor : string_crate.Cursor) is begin if not aborted then declare portname : constant String := "bucket_" & HT.USS (string_crate.Element (cursor)); sourcedir : constant String := ravensource & "/" & portname; specfile : constant String := sourcedir & "/specification"; premsg : constant String := "aborted : " & portname & " "; specification : Port_Specification.Portspecs; successful : Boolean; begin if DIR.Exists (specfile) then PAR.parse_specification_file (dossier => specfile, spec => specification, opsys_focus => platform_type, -- unused arch_focus => x86_64, -- irrevelevant success => successful, stop_at_targets => False); if not successful then aborted := True; TIO.Put_Line (premsg & "failed to parse specification file." & " " & specification.get_parse_error); end if; else aborted := True; TIO.Put_Line (premsg & "has no specification file."); end if; if not aborted then PST.set_option_defaults (specs => specification, variant => specification.get_list_item (PSP.sp_variants, 1), opsys => platform_type, arch_standard => x86_64, osrelease => release); if not specification.post_transform_option_group_defaults_passes then aborted := True; TIO.Put_Line (premsg & "failed option transformation."); end if; end if; if not aborted then declare namebase : String := specification.get_namebase; catport : String := "bucket_" & UTL.bucket (palabra => namebase) & "/" & namebase; output_file : String := consdir & "/" & catport; begin FOP.mkdirp_from_filename (output_file); PSB.generator (specs => specification, ravensrcdir => sourcedir, output_file => output_file); TIO.Put_Line (catport & " buildsheet generated"); end; end if; end; end if; exception when uhoh : others => TIO.Put ("Error with bucket_" & HT.USS (string_crate.Element (cursor)) & ": "); TIO.Put_Line (EX.Exception_Information (uhoh)); aborted := True; end make_buildsheet; begin source (lot).Iterate (make_buildsheet'Access); finished (lot) := True; end scan; scan_01 : scan (lot => 1); scan_02 : scan (lot => 2); scan_03 : scan (lot => 3); scan_04 : scan (lot => 4); scan_05 : scan (lot => 5); scan_06 : scan (lot => 6); scan_07 : scan (lot => 7); scan_08 : scan (lot => 8); scan_09 : scan (lot => 9); scan_10 : scan (lot => 10); scan_11 : scan (lot => 11); scan_12 : scan (lot => 12); scan_13 : scan (lot => 13); scan_14 : scan (lot => 14); scan_15 : scan (lot => 15); scan_16 : scan (lot => 16); scan_17 : scan (lot => 17); scan_18 : scan (lot => 18); scan_19 : scan (lot => 19); scan_20 : scan (lot => 20); scan_21 : scan (lot => 21); scan_22 : scan (lot => 22); scan_23 : scan (lot => 23); scan_24 : scan (lot => 24); scan_25 : scan (lot => 25); scan_26 : scan (lot => 26); scan_27 : scan (lot => 27); scan_28 : scan (lot => 28); scan_29 : scan (lot => 29); scan_30 : scan (lot => 30); scan_31 : scan (lot => 31); scan_32 : scan (lot => 32); scan_33 : scan (lot => 33); scan_34 : scan (lot => 34); scan_35 : scan (lot => 35); scan_36 : scan (lot => 36); scan_37 : scan (lot => 37); scan_38 : scan (lot => 38); scan_39 : scan (lot => 39); scan_40 : scan (lot => 40); scan_41 : scan (lot => 41); scan_42 : scan (lot => 42); scan_43 : scan (lot => 43); scan_44 : scan (lot => 44); scan_45 : scan (lot => 45); scan_46 : scan (lot => 46); scan_47 : scan (lot => 47); scan_48 : scan (lot => 48); scan_49 : scan (lot => 49); scan_50 : scan (lot => 50); scan_51 : scan (lot => 51); scan_52 : scan (lot => 52); scan_53 : scan (lot => 53); scan_54 : scan (lot => 54); scan_55 : scan (lot => 55); scan_56 : scan (lot => 56); scan_57 : scan (lot => 57); scan_58 : scan (lot => 58); scan_59 : scan (lot => 59); scan_60 : scan (lot => 60); scan_61 : scan (lot => 61); scan_62 : scan (lot => 62); scan_63 : scan (lot => 63); scan_64 : scan (lot => 64); begin while combined_wait loop delay 0.1; combined_wait := False; for j in scanners'Range loop if not finished (j) then combined_wait := True; exit; end if; end loop; if Signals.graceful_shutdown_requested then aborted := True; end if; end loop; end; LOG.set_scan_complete (CAL.Clock); if aborted then TIO.Put_Line ("Aborted after " & LOG.scan_duration); else TIO.Put_Line ("Conspiracy generation time: " & LOG.scan_duration); end if; end generate_all_buildsheets; -------------------------------------------------------------------------------------------- -- version_difference -------------------------------------------------------------------------------------------- function version_difference (id : port_id; kind : out verdiff) return String is procedure each_subpackage (position : subpackage_crate.Cursor); pkg8 : constant String := HT.USS (PM.configuration.sysroot_pkg8); dir_pkg : constant String := HT.USS (PM.configuration.dir_repository); version : constant String := HT.USS (all_ports (id).pkgversion); origin : constant String := get_port_variant (id); upgrade : HT.Text; all_present : Boolean := True; procedure each_subpackage (position : subpackage_crate.Cursor) is rec : subpackage_record renames subpackage_crate.Element (position); subpackage : String := HT.USS (rec.subpackage); current : String := calculate_package_name (id, subpackage); base_pattern : String := HT.USS (all_ports (id).port_namebase) & "-" & HT.USS (all_ports (id).port_variant) & "-"; pattern : String := base_pattern & "*" & arc_ext; pkg_search : DIR.Search_Type; dirent : DIR.Directory_Entry_Type; begin if rec.pkg_present then return; else all_present := False; end if; if not HT.IsBlank (upgrade) then return; end if; DIR.Start_Search (Search => pkg_search, Directory => dir_pkg, Filter => (DIR.Ordinary_File => True, others => False), Pattern => pattern); while DIR.More_Entries (Search => pkg_search) loop DIR.Get_Next_Entry (Search => pkg_search, Directory_Entry => dirent); declare sname : String := DIR.Simple_Name (dirent); verend : Natural := sname'Length - arc_ext'Length; command : String := pkg8 & " query -F " & dir_pkg & "/" & sname & " %o"; status : Integer; testorigin : HT.Text := Unix.piped_command (command, status); begin if status = 0 and then HT.equivalent (testorigin, origin) then upgrade := HT.SUS (" (" & sname (base_pattern'Length + 1 .. verend) & " => " & version & ")"); end if; end; end loop; DIR.End_Search (pkg_search); end each_subpackage; begin all_ports (id).subpackages.Iterate (each_subpackage'Access); if all_present then kind := rebuild; return " (rebuild " & version & ")"; end if; if not HT.IsBlank (upgrade) then kind := change; return HT.USS (upgrade); end if; kind := newbuild; return " (new " & version & ")"; end version_difference; -------------------------------------------------------------------------------------------- -- display_results_of_dry_run -------------------------------------------------------------------------------------------- procedure display_results_of_dry_run is procedure print (cursor : ranking_crate.Cursor); listlog : TIO.File_Type; filename : constant String := "/tmp/ravenadm_status_results.txt"; max_lots : constant scanners := get_max_lots; elapsed : constant String := LOG.scan_duration; goodlog : Boolean; procedure print (cursor : ranking_crate.Cursor) is id : port_id := ranking_crate.Element (cursor).ap_index; kind : verdiff; diff : constant String := version_difference (id, kind); origin : constant String := get_port_variant (id); begin case kind is when newbuild => TIO.Put_Line (" N => " & origin); when rebuild => TIO.Put_Line (" R => " & origin); when change => TIO.Put_Line (" U => " & origin & diff); end case; if goodlog then TIO.Put_Line (listlog, origin & diff); end if; end print; begin begin TIO.Create (File => listlog, Mode => TIO.Out_File, Name => filename); goodlog := True; exception when others => goodlog := False; end; TIO.Put_Line ("These are the ports that would be built ([N]ew, " & "[R]ebuild, [U]pgrade):"); rank_queue.Iterate (print'Access); TIO.Put_Line ("Total packages that would be built:" & rank_queue.Length'Img); if goodlog then TIO.Put_Line (listlog, LAT.LF & LAT.LF & "------------------------------" & LAT.LF & "-- Statistics" & LAT.LF & "------------------------------" & LAT.LF & " Ports scanned :" & last_port'Img & LAT.LF & " Elapsed time : " & elapsed & LAT.LF & " Parallelism :" & max_lots'Img & " scanners" & LAT.LF & " ncpu :" & Parameters.configuration.number_cores'Img); TIO.Close (listlog); TIO.Put_Line ("The complete build list can also be found at:" & LAT.LF & filename); end if; end display_results_of_dry_run; -------------------------------------------------------------------------------------------- -- gather_distfile_set -------------------------------------------------------------------------------------------- function gather_distfile_set (sysrootver : sysroot_characteristics) return Boolean is good_scan : Boolean; using_screen : constant Boolean := Unix.screen_attached; conspiracy : constant String := HT.USS (PM.configuration.dir_conspiracy); unkindness : constant String := HT.USS (PM.configuration.dir_unkindness); compiled_BS : constant String := HT.USS (PM.configuration.dir_profile) & "/unkindness"; begin prescan_conspiracy_index_for_distfiles (conspiracy, unkindness, sysrootver); LOG.set_scan_start_time (CAL.Clock); parallel_distfile_scan (conspiracy => conspiracy, sysrootver => sysrootver, success => good_scan, show_progress => using_screen); if unkindness /= PM.no_unkindness then linear_scan_unkindness_for_distfiles (compiled_BS); end if; LOG.set_scan_complete (CAL.Clock); return good_scan; end gather_distfile_set; -------------------------------------------------------------------------------------------- -- prescan_conspiracy_index_for_distfiles -------------------------------------------------------------------------------------------- procedure prescan_conspiracy_index_for_distfiles (conspiracy : String; unkindness : String; sysrootver : sysroot_characteristics) is conspindex_path : constant String := conspiracy & conspindex; max_lots : constant scanners := get_max_lots; custom_avail : constant Boolean := unkindness /= PM.no_unkindness; begin if not DIR.Exists (conspindex_path) then raise missing_index with conspindex; end if; declare fulldata : String := FOP.get_file_contents (conspindex_path); markers : HT.Line_Markers; linenum : Natural := 0; begin HT.initialize_markers (fulldata, markers); loop exit when not HT.next_line_present (fulldata, markers); linenum := linenum + 1; declare line : constant String := HT.extract_line (fulldata, markers); bucket : constant String := HT.specific_field (line, 1); namebase : constant String := HT.specific_field (line, 2); bsheet : constant String := "/bucket_" & bucket & "/" & namebase; linestr : constant String := ", line " & HT.int2str (linenum); begin if bucket'Length /= 2 or else namebase'Length = 0 then raise bad_index_data with conspindex & linestr; end if; if not DIR.Exists (conspiracy & bsheet) then raise bad_index_data with conspindex & bsheet & " buildsheet does not exist" & linestr; end if; if custom_avail and then DIR.Exists (unkindness & bsheet) then -- postpone custom port scan (done prescan_unkindness) null; else declare portkey : HT.Text := HT.SUS (namebase); kc : portkey_crate.Cursor; success : Boolean; begin ports_keys.Insert (Key => portkey, New_Item => lot_counter, Position => kc, Inserted => success); last_port := lot_counter; all_ports (lot_counter).sequence_id := lot_counter; all_ports (lot_counter).key_cursor := kc; all_ports (lot_counter).port_namebase := HT.SUS (namebase); all_ports (lot_counter).bucket := bucket_code (bucket); all_ports (lot_counter).unkind_custom := False; make_queue (lot_number).Append (lot_counter); lot_counter := lot_counter + 1; if lot_number = max_lots then lot_number := 1; else lot_number := lot_number + 1; end if; end; end if; end; end loop; end; end prescan_conspiracy_index_for_distfiles; -------------------------------------------------------------------------------------------- -- linear_scan_unkindness_for_distfiles -------------------------------------------------------------------------------------------- procedure linear_scan_unkindness_for_distfiles (compiled_BS : String) is procedure insert_distfile (dist_subdir : String; distfile_group : String); dindex : port_index := 0; procedure insert_distfile (dist_subdir : String; distfile_group : String) is function determine_distname return String; use_subdir : Boolean := (dist_subdir /= ""); function determine_distname return String is distfile : String := HT.part_1 (distfile_group, ":"); begin if use_subdir then return dist_subdir & "/" & distfile; else return distfile; end if; end determine_distname; distfile_path : HT.Text := HT.SUS (determine_distname); begin if not distfile_set.Contains (distfile_path) then dindex := dindex + 1; distfile_set.Insert (distfile_path, dindex); end if; end insert_distfile; begin -- caller must check that custom ports are being used. -- It's assumed that this has been done for highdigit in AF'Range loop for lowdigit in AF'Range loop declare bucket : bucket_code := tohex (highdigit) & tohex (lowdigit); bucket_dir : constant String := compiled_BS & "/bucket_" & bucket; Inner_Search : DIR.Search_Type; Inner_Dirent : DIR.Directory_Entry_Type; use type DIR.File_Kind; begin if DIR.Exists (bucket_dir) and then DIR.Kind (bucket_dir) = DIR.Directory then DIR.Start_Search (Search => Inner_Search, Directory => bucket_dir, Filter => (DIR.Ordinary_File => True, others => False), Pattern => "*"); while DIR.More_Entries (Inner_Search) loop DIR.Get_Next_Entry (Inner_Search, Inner_Dirent); declare namebase : String := DIR.Simple_Name (Inner_Dirent); successful : Boolean; customspec : PSP.Portspecs; arch_focus : supported_arch := x86_64; -- unused, pick one buildsheet : constant String := "/bucket_" & bucket & "/" & namebase; begin PAR.parse_specification_file (dossier => compiled_BS & buildsheet, spec => customspec, opsys_focus => platform_type, arch_focus => arch_focus, success => successful, stop_at_targets => True); if not successful then raise bsheet_parsing with compiled_BS & buildsheet & "-> " & customspec.get_parse_error; end if; declare num_dfiles : Natural; dist_subdir : String := customspec.get_field_value (PSP.sp_distsubdir); begin num_dfiles := customspec.get_list_length (PSP.sp_distfiles); for df in 1 .. num_dfiles loop insert_distfile (dist_subdir, customspec.get_list_item (PSP.sp_distfiles, df)); end loop; end; end; end loop; DIR.End_Search (Inner_Search); end if; end; end loop; end loop; end linear_scan_unkindness_for_distfiles; -------------------------------------------------------------------------------------------- -- parallel_distfile_scan -------------------------------------------------------------------------------------------- procedure parallel_distfile_scan (conspiracy : String; sysrootver : sysroot_characteristics; success : out Boolean; show_progress : Boolean) is procedure combine (position : portkey_crate.Cursor); finished : array (scanners) of Boolean := (others => False); task_storage : array (scanners) of portkey_crate.Map; combined_wait : Boolean := True; aborted : Boolean := False; dindex : port_index := port_index (distfile_set.Length); procedure combine (position : portkey_crate.Cursor) is distfile : HT.Text := portkey_crate.Key (position); begin if not distfile_set.Contains (distfile) then dindex := dindex + 1; distfile_set.Insert (distfile, dindex); end if; end combine; task type scan (lot : scanners) is pragma Storage_Size (task_stack_limit); end scan; task body scan is procedure populate (cursor : subqueue.Cursor); procedure populate (cursor : subqueue.Cursor) is procedure insert_distfile (dist_subdir : String; distfile : String); target_port : port_index := subqueue.Element (cursor); namebase : String := HT.USS (all_ports (target_port).port_namebase); bucket : bucket_code := all_ports (target_port).bucket; customspec : PSP.Portspecs; successful : Boolean; arch_focus : supported_arch := x86_64; -- unused, pick one buildsheet : constant String := "/bucket_" & bucket & "/" & namebase; procedure insert_distfile (dist_subdir : String; distfile : String) is function determine_distname return String; use_subdir : Boolean := (dist_subdir /= ""); function determine_distname return String is begin if use_subdir then return dist_subdir & "/" & distfile; else return distfile; end if; end determine_distname; distfile_path : HT.Text := HT.SUS (determine_distname); begin if not task_storage (lot).Contains (distfile_path) then task_storage (lot).Insert (distfile_path, 1); end if; end insert_distfile; begin if not aborted then PAR.parse_specification_file (dossier => conspiracy & buildsheet, spec => customspec, opsys_focus => platform_type, arch_focus => arch_focus, success => successful, stop_at_targets => True); if not successful then TIO.Put_Line (LAT.LF & "culprit: " & buildsheet & "-> " & customspec.get_parse_error); aborted := True; end if; declare dist_subdir : String := customspec.get_field_value (PSP.sp_distsubdir); num_dfiles : Natural := customspec.get_list_length (PSP.sp_distfiles); begin for df in 1 .. num_dfiles loop insert_distfile (dist_subdir, customspec.get_list_item (PSP.sp_distfiles, df)); end loop; end; mq_progress (lot) := mq_progress (lot) + 1; end if; end populate; begin make_queue (lot).Iterate (populate'Access); finished (lot) := True; end scan; scan_01 : scan (lot => 1); scan_02 : scan (lot => 2); scan_03 : scan (lot => 3); scan_04 : scan (lot => 4); scan_05 : scan (lot => 5); scan_06 : scan (lot => 6); scan_07 : scan (lot => 7); scan_08 : scan (lot => 8); scan_09 : scan (lot => 9); scan_10 : scan (lot => 10); scan_11 : scan (lot => 11); scan_12 : scan (lot => 12); scan_13 : scan (lot => 13); scan_14 : scan (lot => 14); scan_15 : scan (lot => 15); scan_16 : scan (lot => 16); scan_17 : scan (lot => 17); scan_18 : scan (lot => 18); scan_19 : scan (lot => 19); scan_20 : scan (lot => 20); scan_21 : scan (lot => 21); scan_22 : scan (lot => 22); scan_23 : scan (lot => 23); scan_24 : scan (lot => 24); scan_25 : scan (lot => 25); scan_26 : scan (lot => 26); scan_27 : scan (lot => 27); scan_28 : scan (lot => 28); scan_29 : scan (lot => 29); scan_30 : scan (lot => 30); scan_31 : scan (lot => 31); scan_32 : scan (lot => 32); -- Expansion of cpu_range from 32 to 64 means 64 possible scanners scan_33 : scan (lot => 33); scan_34 : scan (lot => 34); scan_35 : scan (lot => 35); scan_36 : scan (lot => 36); scan_37 : scan (lot => 37); scan_38 : scan (lot => 38); scan_39 : scan (lot => 39); scan_40 : scan (lot => 40); scan_41 : scan (lot => 41); scan_42 : scan (lot => 42); scan_43 : scan (lot => 43); scan_44 : scan (lot => 44); scan_45 : scan (lot => 45); scan_46 : scan (lot => 46); scan_47 : scan (lot => 47); scan_48 : scan (lot => 48); scan_49 : scan (lot => 49); scan_50 : scan (lot => 50); scan_51 : scan (lot => 51); scan_52 : scan (lot => 52); scan_53 : scan (lot => 53); scan_54 : scan (lot => 54); scan_55 : scan (lot => 55); scan_56 : scan (lot => 56); scan_57 : scan (lot => 57); scan_58 : scan (lot => 58); scan_59 : scan (lot => 59); scan_60 : scan (lot => 60); scan_61 : scan (lot => 61); scan_62 : scan (lot => 62); scan_63 : scan (lot => 63); scan_64 : scan (lot => 64); begin TIO.Put_Line ("Scanning entire ports tree for distfiles."); while combined_wait loop delay 1.0; if show_progress then TIO.Put (scan_progress); end if; combined_wait := False; for j in scanners'Range loop if not finished (j) then combined_wait := True; exit; end if; end loop; if Signals.graceful_shutdown_requested then aborted := True; end if; end loop; success := not aborted; if success then -- Now that the scanners are complete, we can combine the results for j in scanners'Range loop task_storage (j).Iterate (combine'Access); end loop; end if; end parallel_distfile_scan; -------------------------------------------------------------------------------------------- -- display_kmg -------------------------------------------------------------------------------------------- function display_kmg (number : disktype) return String is type kmgtype is delta 0.01 digits 6; kilo : constant disktype := 1024; mega : constant disktype := kilo * kilo; giga : constant disktype := kilo * mega; XXX : kmgtype; begin if number > giga then XXX := kmgtype (number / giga); return XXX'Img & " gigabytes"; elsif number > mega then XXX := kmgtype (number / mega); return XXX'Img & " megabytes"; else XXX := kmgtype (number / kilo); return XXX'Img & " kilobytes"; end if; end display_kmg; -------------------------------------------------------------------------------------------- -- purge_obsolete_distfiles -------------------------------------------------------------------------------------------- procedure purge_obsolete_distfiles is procedure kill (position : portkey_crate.Cursor); procedure find_actual_tarballs (folder : String); distfiles_directory : String := Unix.true_path (HT.USS (PM.configuration.dir_distfiles)); abort_purge : Boolean := False; bytes_purged : disktype := 0; rmfiles : portkey_crate.Map; procedure kill (position : portkey_crate.Cursor) is tarball : String := HT.USS (portkey_crate.Key (position)); path : String := distfiles_directory & "/" & tarball; begin TIO.Put_Line ("Deleting " & tarball); DIR.Delete_File (path); end kill; procedure find_actual_tarballs (folder : String) is procedure walkdir (item : DIR.Directory_Entry_Type); procedure print (item : DIR.Directory_Entry_Type); uniqid : port_id := 0; leftindent : Natural := distfiles_directory'Length + 2; procedure print (item : DIR.Directory_Entry_Type) is FN : constant String := DIR.Full_Name (item); tball : HT.Text := HT.SUS (FN (leftindent .. FN'Last)); begin if not distfile_set.Contains (tball) then if not rmfiles.Contains (tball) then uniqid := uniqid + 1; rmfiles.Insert (Key => tball, New_Item => uniqid); bytes_purged := bytes_purged + disktype (DIR.Size (FN)); end if; end if; end print; procedure walkdir (item : DIR.Directory_Entry_Type) is begin if DIR.Simple_Name (item) /= "." and then DIR.Simple_Name (item) /= ".." then find_actual_tarballs (DIR.Full_Name (item)); end if; exception when DIR.Name_Error => abort_purge := True; TIO.Put_Line ("walkdir: " & folder & " directory does not exist"); end walkdir; begin DIR.Search (folder, "*", (DIR.Ordinary_File => True, others => False), print'Access); DIR.Search (folder, "", (DIR.Directory => True, others => False), walkdir'Access); exception when DIR.Name_Error => abort_purge := True; TIO.Put_Line ("The " & folder & " directory does not exist"); when DIR.Use_Error => abort_purge := True; TIO.Put_Line ("Searching " & folder & " directory is not supported"); when failed : others => abort_purge := True; TIO.Put_Line ("purge_obsolete_distfiles: Unknown error - directory search"); TIO.Put_Line (EX.Exception_Information (failed)); end find_actual_tarballs; begin find_actual_tarballs (distfiles_directory); if abort_purge then TIO.Put_Line ("Distfile purge operation aborted."); else rmfiles.Iterate (kill'Access); TIO.Put_Line ("Recovered" & display_kmg (bytes_purged)); end if; end purge_obsolete_distfiles; -------------------------------------------------------------------------------------------- -- scan_repository -------------------------------------------------------------------------------------------- function scan_repository (repository : String) return Boolean is pkg_search : DIR.Search_Type; dirent : DIR.Directory_Entry_Type; pkg_index : scanners := scanners'First; result : Boolean := False; begin DIR.Start_Search (Search => pkg_search, Directory => repository, Filter => (DIR.Ordinary_File => True, others => False), Pattern => "*" & arc_ext); while DIR.More_Entries (Search => pkg_search) loop DIR.Get_Next_Entry (Search => pkg_search, Directory_Entry => dirent); declare pkgname : HT.Text := HT.SUS (DIR.Simple_Name (dirent)); begin package_list.Append (pkgname); result := True; end; end loop; DIR.End_Search (pkg_search); return result; end scan_repository; -------------------------------------------------------------------------------------------- -- store_port_dependencies -------------------------------------------------------------------------------------------- procedure store_port_dependencies (port : port_index; conspiracy : String; unkindness : String; sysrootver : sysroot_characteristics) is function calc_dossier return String; rec : port_record renames all_ports (port); nbase : constant String := HT.USS (rec.port_namebase); function calc_dossier return String is buildsheet : String := "/bucket_" & rec.bucket & "/" & nbase; begin if rec.unkind_custom then return unkindness & buildsheet; else return conspiracy & buildsheet; end if; end calc_dossier; thespec : PSP.Portspecs; successful : Boolean; dossier : constant String := calc_dossier; variant : constant String := HT.USS (rec.port_variant); begin OPS.parse_and_transform_buildsheet (specification => thespec, successful => successful, buildsheet => dossier, variant => variant, portloc => "", excl_targets => True, avoid_dialog => True, for_webpage => False, sysrootver => sysrootver); if not successful then -- fail silently. The issue is caught in pass #2 return; end if; all_ports (port).ignore_reason := HT.SUS (thespec.get_tagline (variant)); all_ports (port).port_namebase := HT.SUS (nbase); all_ports (port).port_variant := HT.SUS (variant); all_ports (port).pkgversion := HT.SUS (thespec.calculate_pkgversion); all_ports (port).scanned := True; for item in Positive range 1 .. thespec.get_list_length (PSP.sp_build_deps) loop populate_set_depends (port, thespec.get_list_item (PSP.sp_build_deps, item), build); end loop; for item in Positive range 1 .. thespec.get_list_length (PSP.sp_buildrun_deps) loop populate_set_depends (port, thespec.get_list_item (PSP.sp_buildrun_deps, item), buildrun); end loop; for item in Positive range 1 .. thespec.get_list_length (PSP.sp_run_deps) loop populate_set_depends (port, thespec.get_list_item (PSP.sp_run_deps, item), runtime); end loop; for item in Positive range 1 .. thespec.get_subpackage_length (variant) loop declare subpackage : String := thespec.get_subpackage_item (variant, item); begin for subitem in Positive range 1 .. thespec.get_number_extra_run (subpackage) loop declare dep : String := thespec.get_extra_runtime (subpackage, subitem); begin populate_set_depends (port, dep, extra_runtime); end; end loop; end; end loop; end store_port_dependencies; -------------------------------------------------------------------------------------------- -- blocked_text_block -------------------------------------------------------------------------------------------- function blocked_text_block (port : port_index) return String is procedure scan (position : block_crate.Cursor); procedure print (position : string_crate.Cursor); result : HT.Text; tempstore : string_crate.Vector; procedure scan (position : block_crate.Cursor) is blocked : port_index renames block_crate.Element (position); pv : constant String := get_port_variant (all_ports (blocked)); begin tempstore.Append (HT.SUS (pv)); end scan; procedure print (position : string_crate.Cursor) is pvkey : HT.Text renames string_crate.Element (position); pndx : constant port_index := ports_keys.Element (pvkey); namebase : constant String := HT.USS (all_ports (pndx).port_namebase); variant : constant String := HT.USS (all_ports (pndx).port_variant); bucket : constant String := "bucket_" & UTL.bucket (namebase); begin HT.SU.Append (result, get_port_variant (all_ports (pndx)) & ";" & "../../../" & bucket & "/" & namebase & "/" & variant & ";" & HT.USS (all_ports (pndx).ignore_reason) & LAT.LF); end print; begin all_ports (port).blocks.Iterate (scan'Access); sorter.Sort (tempstore); tempstore.Iterate (print'Access); return HT.USS (result); end blocked_text_block; -------------------------------------------------------------------------------------------- -- generate_single_page -------------------------------------------------------------------------------------------- function generate_single_page (port : port_index; workzone : String; www_site : String; conspiracy : String; unkindness : String; cdatetime : CAL.Time; mdatetime : CAL.Time; sysrootver : sysroot_characteristics) return Boolean is function calc_dossier return String; rec : port_record renames all_ports (port); nbase : constant String := HT.USS (rec.port_namebase); function calc_dossier return String is buildsheet : String := "/bucket_" & rec.bucket & "/" & nbase; begin if rec.unkind_custom then return unkindness & buildsheet; else return conspiracy & buildsheet; end if; end calc_dossier; thespec : PSP.Portspecs; successful : Boolean; html_page : TIO.File_Type; variant : constant String := HT.USS (rec.port_variant); page : constant String := www_site & "/bucket_" & rec.bucket & "/" & nbase & "/" & variant & "/index.html"; work_dir : constant String := workzone & "/" & nbase; dossier : constant String := calc_dossier; begin OPS.parse_and_transform_buildsheet (specification => thespec, successful => successful, buildsheet => dossier, variant => variant, portloc => work_dir, excl_targets => False, avoid_dialog => True, for_webpage => True, sysrootver => sysrootver); if successful then begin FOP.mkdirp_from_filename (page); TIO.Create (File => html_page, Mode => TIO.Out_File, Name => page); WEB.produce_page (specs => thespec, variant => variant, dossier => html_page, portdir => work_dir, blocked => blocked_text_block (port), created => cdatetime, changed => mdatetime, devscan => True); REP.clear_workzone_directory (nbase); TIO.Close (html_page); return True; exception when issue : others => if TIO.Is_Open (html_page) then TIO.Close (html_page); end if; TIO.Put_Line ("WWW: Failed to create " & page); end; else TIO.Put_Line ("WWW: Failed to parse " & dossier); end if; return False; end generate_single_page; -------------------------------------------------------------------------------------------- -- generate_catalog_index -------------------------------------------------------------------------------------------- function generate_catalog_index (www_site : String; crate : dates_crate.Map; catcrate : catalog_crate.Set) return Boolean is page : constant String := www_site & "/index.html"; successful : Boolean; html_page : TIO.File_Type; begin TIO.Create (File => html_page, Mode => TIO.Out_File, Name => page); successful := WEB.generate_catalog_index (html_page, catalog_row_block (crate, catcrate)); TIO.Close (html_page); return successful; exception when issue : others => if TIO.Is_Open (html_page) then TIO.Close (html_page); end if; return False; end generate_catalog_index; -------------------------------------------------------------------------------------------- -- serially_generate_web_pages -------------------------------------------------------------------------------------------- procedure serially_generate_web_pages (www_site : String; sysrootver : sysroot_characteristics; success : out Boolean) is procedure set_timestamps (index : port_index); all_good : Boolean := True; workzone : constant String := REP.get_workzone_path; conspiracy : constant String := HT.USS (PM.configuration.dir_conspiracy); unkindness : constant String := HT.USS (PM.configuration.dir_unkindness); crate : dates_crate.Map; catcrate : catalog_crate.Set; cdatetime : CAL.Time; mdatetime : CAL.Time; procedure set_timestamps (index : port_index) is key : HT.Text := all_ports (index).port_namebase; begin if crate.Contains (key) then cdatetime := crate.Element (key).creation; mdatetime := crate.Element (key).lastmod; else cdatetime := CAL.Time_Of (1970, 1, 1); mdatetime := cdatetime; end if; end set_timestamps; begin for x in 0 .. last_port loop store_port_dependencies (port => x, conspiracy => conspiracy, unkindness => unkindness, sysrootver => sysrootver); end loop; iterate_reverse_deps; scan_port_dates (conspiracy, crate, catcrate); REP.launch_workzone; for x in 0 .. last_port loop set_timestamps (x); if not generate_single_page (port => x, workzone => workzone, www_site => www_site, conspiracy => conspiracy, unkindness => unkindness, cdatetime => cdatetime, mdatetime => mdatetime, sysrootver => sysrootver) then all_good := False; end if; end loop; REP.destroy_workzone; if all_good then if generate_catalog_index (www_site, crate, catcrate) then success := True; return; end if; end if; success := False; end serially_generate_web_pages; -------------------------------------------------------------------------------------------- -- scan_port_dates -------------------------------------------------------------------------------------------- procedure scan_port_dates (conspiracy : String; crate : in out dates_crate.Map; catcrate : in out catalog_crate.Set) is package lastmod_crate is new CON.Hashed_Maps (Key_Type => HT.Text, Element_Type => disktype, Hash => port_hash, Equivalent_Keys => HT.equivalent); procedure build_up_catcrate (index : port_index); tempstore : lastmod_crate.Map; procedure build_up_catcrate (index : port_index) is tempkey : HT.Text := all_ports (index).port_namebase; newrec : catalog_record; begin newrec.origin := HT.SUS (get_port_variant (index)); if tempstore.Contains (tempkey) then newrec.lastmod64 := tempstore.Element (tempkey); else newrec.lastmod64 := 205329600; -- dummy: USA bicentennial end if; catcrate.Insert (newrec); end build_up_catcrate; begin crate.Clear; declare filename : constant String := conspiracy & "/" & port_dates; contents : constant String := FOP.get_file_contents (filename); markers : HT.Line_Markers; begin HT.initialize_markers (contents, markers); loop exit when not HT.next_line_present (contents, markers); declare line : constant String := HT.extract_line (contents, markers); key : constant String := HT.specific_field (line, 1); date1 : constant String := HT.specific_field (line, 2); date2 : constant String := HT.specific_field (line, 3); keytxt : HT.Text := HT.SUS (key); newrec : port_dates_record; begin newrec.creation := UTL.convert_unixtime (date1); newrec.lastmod := UTL.convert_unixtime (date2); crate.Insert (keytxt, newrec); tempstore.Insert (keytxt, disktype'Value (date2)); exception when others => null; end; end loop; for x in 0 .. last_port loop build_up_catcrate (x); end loop; exception when issue : others => TIO.Put_Line ("WARNING: Failed to ingest " & port_dates & " file"); end; end scan_port_dates; -------------------------------------------------------------------------------------------- -- "<" for catalog crate ordered sets -------------------------------------------------------------------------------------------- function "<" (L, R : catalog_record) return Boolean is begin if L.lastmod64 = R.lastmod64 then return HT.SU.">" (R.origin, L.origin); end if; return L.lastmod64 > R.lastmod64; end "<"; -------------------------------------------------------------------------------------------- -- catalog_row_block -------------------------------------------------------------------------------------------- function catalog_row_block (crate : dates_crate.Map; catcrate : catalog_crate.Set) return String is procedure scan (position : catalog_crate.Cursor); function get_lastmod (index : port_index) return String; function Q (value : String; first : Boolean := False) return String; result : HT.Text; counter : Positive := 1; function get_lastmod (index : port_index) return String is key : HT.Text := all_ports (index).port_namebase; mdatetime : CAL.Time; begin if crate.Contains (key) then mdatetime := crate.Element (key).lastmod; else mdatetime := CAL.Time_Of (1970, 1, 1); end if; return HT.substring (LOG.timestamp (mdatetime, True), 0, 4); end get_lastmod; function Q (value : String; first : Boolean := False) return String is begin if first then return LAT.Quotation & value & LAT.Quotation; else return LAT.Comma & LAT.Quotation & value & LAT.Quotation; end if; end Q; procedure scan (position : catalog_crate.Cursor) is keytext : HT.Text renames catalog_crate.Element (position).origin; target : port_index := ports_keys.Element (keytext); origin : constant String := get_port_variant (target); pkgver : constant String := HT.USS (all_ports (target).pkgversion); bucket : constant String := all_ports (target).bucket; tstamp : constant String := get_lastmod (target); sindex : constant String := HT.int2str (counter); tagline : constant String := HT.replace_all (HT.USS (all_ports (target).ignore_reason), LAT.Quotation, LAT.Apostrophe); begin HT.SU.Append (result, LAT.HT & "row_assy(" & Q (sindex, True) & Q (bucket) & Q (origin) & Q (pkgver) & Q (tagline) & Q (tstamp) & ");" & LAT.LF); counter := counter + 1; end scan; begin catcrate.Iterate (scan'Access); return (HT.USS (result)); exception when issue : others => TIO.Put_Line ("catalog_row_block: " & Ada.Exceptions.Exception_Message (issue)); return (HT.USS (result)); end catalog_row_block; -------------------------------------------------------------------------------------------- -- scan_unkindness_buildsheets -------------------------------------------------------------------------------------------- procedure scan_unkindness_buildsheets (comp_unkind : String; crate : in out dates_crate.Map) is bucket : bucket_code; begin -- caller must ensure comp_unkind exists and is a directory crate.Clear; for highdigit in AF'Range loop for lowdigit in AF'Range loop bucket := tohex (highdigit) & tohex (lowdigit); declare bucket_dir : constant String := comp_unkind & "/bucket_" & bucket; Inner_Search : DIR.Search_Type; Inner_Dirent : DIR.Directory_Entry_Type; use type DIR.File_Kind; begin if DIR.Exists (bucket_dir) and then DIR.Kind (bucket_dir) = DIR.Directory then DIR.Start_Search (Search => Inner_Search, Directory => bucket_dir, Filter => (DIR.Ordinary_File => True, others => False), Pattern => "*"); while DIR.More_Entries (Inner_Search) loop DIR.Get_Next_Entry (Inner_Search, Inner_Dirent); declare newrec : port_dates_record; namebase : HT.Text := HT.SUS (DIR.Simple_Name (Inner_Dirent)); begin newrec.lastmod := DIR.Modification_Time (Inner_Dirent); crate.Insert (namebase, newrec); end; end loop; DIR.End_Search (Inner_Search); end if; end; end loop; end loop; end scan_unkindness_buildsheets; -------------------------------------------------------------------------------------------- -- unkindness_index_required -------------------------------------------------------------------------------------------- function unkindness_index_required return Boolean is procedure delete_BS (position : dates_crate.Cursor); use type DIR.File_Kind; compiled_BS_directory : String := HT.USS (PM.configuration.dir_profile) & "/unkindness"; generation_required : Boolean := False; current_buildsheets : dates_crate.Map; procedure delete_BS (position : dates_crate.Cursor) is name_key : HT.Text renames dates_crate.Key (position); namebase : String := HT.USS (name_key); bucket : bucket_code := UTL.bucket (namebase); buckname : constant String := "bucket_" & bucket & "/" & namebase; BS_file : String := compiled_BS_directory & "/" & buckname; begin TIO.Put_Line ("Removing obsolete custom buildsheet: " & buckname); DIR.Delete_File (BS_file); generation_required := True; exception when others => TIO.Put_Line ("Failed to remove obsolete custom buildsheet: " & BS_file); end delete_BS; begin if HT.equivalent (PM.configuration.dir_unkindness, PM.no_unkindness) then if DIR.Exists (compiled_BS_directory) then begin if DIR.Kind (compiled_BS_directory) = DIR.Directory then DIR.Delete_Tree (compiled_BS_directory); elsif DIR.Kind (compiled_BS_directory) = DIR.Ordinary_File or else DIR.Kind (compiled_BS_directory) = DIR.Special_File then DIR.Delete_File (compiled_BS_directory); end if; exception when issue : others => TIO.Put_Line ("Encountered issue removing obsolete custom directory: " & compiled_BS_directory); TIO.Put_Line (EX.Exception_Information (issue)); end; end if; return False; else if not DIR.Exists (compiled_BS_directory) then DIR.Create_Path (compiled_BS_directory); elsif DIR.Kind (compiled_BS_directory) /= DIR.Directory then TIO.Put_Line ("Notice: custom buildsheet location not a directory: " & compiled_BS_directory); TIO.Put_Line ("Customization disabled."); return False; end if; scan_unkindness_buildsheets (compiled_BS_directory, current_buildsheets); generation_required := generate_buildsheets (compiled_BS_directory, current_buildsheets); end if; current_buildsheets.Iterate (delete_BS'Access); return generation_required; end unkindness_index_required; -------------------------------------------------------------------------------------------- -- generate_buildsheets -------------------------------------------------------------------------------------------- function generate_buildsheets (comp_unkind : String; crate : in out dates_crate.Map) return Boolean is bucket : bucket_code; must_gen_index : Boolean := False; unkindness : constant String := HT.USS (PM.configuration.dir_unkindness); begin for highdigit in AF'Range loop for lowdigit in AF'Range loop bucket := tohex (highdigit) & tohex (lowdigit); declare bucket_dir : constant String := unkindness & "/bucket_" & bucket; Inner_Search : DIR.Search_Type; Inner_Dirent : DIR.Directory_Entry_Type; use type DIR.File_Kind; begin if DIR.Exists (bucket_dir) and then DIR.Kind (bucket_dir) = DIR.Directory then DIR.Start_Search (Search => Inner_Search, Directory => bucket_dir, Filter => (DIR.Directory => True, others => False), Pattern => "[a-zA-Z0-9_\-]*"); while DIR.More_Entries (Inner_Search) loop DIR.Get_Next_Entry (Inner_Search, Inner_Dirent); declare namebase : String := DIR.Simple_Name (Inner_Dirent); name_key : HT.Text := HT.SUS (namebase); buckname : String := bucket_dir & "/" & namebase; compname : String := comp_unkind & "/bucket_" & bucket & "/" & namebase; must_gen : Boolean := False; broken : Boolean; begin if crate.Contains (name_key) then if unkindness_source_newer (BS_modtime => crate.Element (name_key).lastmod, bucket_name => buckname) then must_gen := True; else crate.Delete (name_key); end if; else must_gen := True; end if; if must_gen then broken := generate_unkindness_buildsheet (buckname, compname); if not broken then must_gen_index := True; if crate.Contains (name_key) then crate.Delete (name_key); end if; end if; end if; end; end loop; DIR.End_Search (Inner_Search); end if; end; end loop; end loop; return must_gen_index; end generate_buildsheets; -------------------------------------------------------------------------------------------- -- unkindness_source_newer -------------------------------------------------------------------------------------------- function unkindness_source_newer (BS_modtime : Ada.Calendar.Time; bucket_name : String) return Boolean is use type CAL.Time; inner_search : DIR.Search_Type; inner_dirent : DIR.Directory_Entry_Type; already_newer : Boolean := False; begin DIR.Start_Search (Search => inner_search, Directory => bucket_name, Filter => (others => True), Pattern => "*"); while not already_newer and then DIR.More_Entries (inner_search) loop DIR.Get_Next_Entry (inner_search, inner_dirent); -- We're going to get "." and "..". It's faster to check them (always older) -- than convert to simple name and exclude them. if BS_modtime < DIR.Modification_Time (inner_dirent) then already_newer := True; end if; end loop; DIR.End_Search (inner_search); return already_newer; end unkindness_source_newer; -------------------------------------------------------------------------------------------- -- generate_unkindness_buildsheet -------------------------------------------------------------------------------------------- function generate_unkindness_buildsheet (unkindness_srcdir : String; new_buildsheet : String) return Boolean is filename : constant String := unkindness_srcdir & "/specification"; specification : Port_Specification.Portspecs; successful : Boolean; begin PAR.parse_specification_file (dossier => filename, spec => specification, opsys_focus => platform_type, -- unused arch_focus => x86_64, -- irrelevant success => successful, stop_at_targets => False); if not successful then TIO.Put_Line ("Custom: Failed to parse " & filename); TIO.Put_Line (specification.get_parse_error); return True; end if; if specification.broken_all_set then return True; end if; -- This check here only verifies option transformation works. PST.set_option_defaults (specs => specification, variant => specification.get_list_item (Port_Specification.sp_variants, 1), opsys => platform_type, arch_standard => x86_64, osrelease => "1"); if not specification.post_transform_option_group_defaults_passes then successful := False; return True; end if; declare namebase : String := specification.get_namebase; begin FOP.mkdirp_from_filename (new_buildsheet); PSB.generator (specs => specification, ravensrcdir => unkindness_srcdir, output_file => new_buildsheet); TIO.Put_Line ("custom buildsheet regenerated: " & namebase); end; return False; -- specification file is not broken (normal state) end generate_unkindness_buildsheet; -------------------------------------------------------------------------------------------- -- generate_unkindness_index -------------------------------------------------------------------------------------------- function generate_unkindness_index (sysrootver : sysroot_characteristics) return Boolean is procedure scan_port (position : string_crate.Cursor); compiled_BS : constant String := HT.USS (PM.configuration.dir_profile) & "/unkindness"; finalcvar : constant String := compiled_BS & unkinindex; indexfile : TIO.File_Type; bucket : bucket_code; total_ports : Natural := 0; total_variants : Natural := 0; total_subpkgs : Natural := 0; procedure scan_port (position : string_crate.Cursor) is namebase : String := HT.USS (string_crate.Element (position)); successful : Boolean; customspec : PSP.Portspecs; arch_focus : supported_arch := x86_64; -- unused, pick one dossier : constant String := compiled_BS & "/bucket_" & bucket & "/" & namebase; begin PAR.parse_specification_file (dossier => dossier, spec => customspec, opsys_focus => platform_type, arch_focus => arch_focus, success => successful, stop_at_targets => True); if not successful then raise bsheet_parsing with dossier & "-> " & customspec.get_parse_error; end if; declare varcnt : Natural := customspec.get_number_of_variants; varlist : String := customspec.get_field_value (PSP.sp_variants); begin total_ports := total_ports + 1; total_variants := total_variants + varcnt; TIO.Put (indexfile, bucket & " " & namebase & " " & HT.int2str (varcnt)); for varx in Integer range 1 .. varcnt loop declare variant : String := HT.specific_field (varlist, varx, ", "); spkgcnt : Natural := customspec.get_subpackage_length (variant); begin total_subpkgs := total_subpkgs + spkgcnt; TIO.Put (indexfile, " " & variant); end; end loop; TIO.Put_Line (indexfile, ""); end; end scan_port; begin TIO.Create (File => indexfile, Mode => TIO.Out_File, Name => finalcvar); for highdigit in AF'Range loop for lowdigit in AF'Range loop bucket := tohex (highdigit) & tohex (lowdigit); declare bucket_dir : constant String := compiled_BS & "/bucket_" & bucket; Inner_Search : DIR.Search_Type; Inner_Dirent : DIR.Directory_Entry_Type; tempstore : string_crate.Vector; use type DIR.File_Kind; begin if DIR.Exists (bucket_dir) and then DIR.Kind (bucket_dir) = DIR.Directory then DIR.Start_Search (Search => Inner_Search, Directory => bucket_dir, Filter => (DIR.Ordinary_File => True, others => False), Pattern => "*"); while DIR.More_Entries (Inner_Search) loop DIR.Get_Next_Entry (Search => Inner_Search, Directory_Entry => Inner_Dirent); tempstore.Append (HT.SUS (DIR.Simple_Name (Inner_Dirent))); end loop; DIR.End_Search (Inner_Search); sorter.Sort (tempstore); tempstore.Iterate (scan_port'Access); end if; end; end loop; end loop; TIO.Close (indexfile); TIO.Put_Line ("Custom index successfully generated."); TIO.Put_Line (" Total custom ports : " & HT.int2str (total_ports)); TIO.Put_Line (" Total custom variants : " & HT.int2str (total_variants)); TIO.Put_Line (" Total custom packages : " & HT.int2str (total_subpkgs)); return True; exception when issue : others => if TIO.Is_Open (indexfile) then TIO.Close (indexfile); end if; TIO.Put_Line ("generate_unkindness_index failure: " & EX.Exception_Message (issue)); return False; end generate_unkindness_index; -------------------------------------------------------------------------------------------- -- gather_list_of_build_logs -------------------------------------------------------------------------------------------- procedure gather_list_of_build_logs is buildlog_dir : constant String := HT.USS (PM.configuration.dir_logs) & "/logs"; Log_Search : DIR.Search_Type; Log_Dirent : DIR.Directory_Entry_Type; use type DIR.File_Kind; begin if DIR.Exists (buildlog_dir) and then DIR.Kind (buildlog_dir) = DIR.Directory then DIR.Start_Search (Search => Log_Search, Directory => buildlog_dir, Filter => (DIR.Ordinary_File => True, others => False), Pattern => "*.log"); while DIR.More_Entries (Log_Search) loop DIR.Get_Next_Entry (Log_Search, Log_Dirent); log_list.Append (HT.SUS (DIR.Simple_Name (Log_Dirent))); end loop; DIR.End_Search (Log_Search); end if; end gather_list_of_build_logs; -------------------------------------------------------------------------------------------- -- eliminate_current_logs -------------------------------------------------------------------------------------------- procedure eliminate_current_logs (main_tree : Boolean) is function get_variant_index return String; procedure erase_filename (log_prefix : String); function get_variant_index return String is conspiracy : constant String := HT.USS (PM.configuration.dir_conspiracy); unkindness : constant String := HT.USS (PM.configuration.dir_unkindness); begin if main_tree then return conspiracy & conspindex; else return unkindness & unkinindex; end if; end get_variant_index; procedure erase_filename (log_prefix : String) is logname : HT.Text := HT.SUS (log_prefix & ".log"); begin if log_list.Contains (logname) then log_list.Delete (log_list.Find_Index (logname)); end if; end erase_filename; variant_index : constant String := get_variant_index; begin -- Filter out the 0* logs, we never want to remove these erase_filename ("00_last_results"); erase_filename ("01_success_list"); erase_filename ("02_failure_list"); erase_filename ("03_ignored_list"); erase_filename ("04_skipped_list"); erase_filename ("05_abnormal_command_output"); erase_filename ("06_obsolete_packages"); if not DIR.Exists (variant_index) then return; end if; declare fulldata : String := FOP.get_file_contents (variant_index); markers : HT.Line_Markers; begin HT.initialize_markers (fulldata, markers); loop exit when not HT.next_line_present (fulldata, markers); declare line : constant String := HT.extract_line (fulldata, markers); namebase : constant String := HT.specific_field (line, 2); numvar : constant Positive := Positive'Value (HT.specific_field (line, 3)); begin for x in 1 .. numvar loop declare variant : constant String := HT.specific_field (line, 3 + x); prefix : constant String := namebase & "___" & variant; begin erase_filename (prefix); end; end loop; end; end loop; end; end eliminate_current_logs; -------------------------------------------------------------------------------------------- -- remove_obsolete_logs -------------------------------------------------------------------------------------------- procedure remove_obsolete_logs is procedure delete_log (position : string_crate.Cursor); bytes_purged : disktype := 0; buildlog_dir : constant String := HT.USS (PM.configuration.dir_logs) & "/logs/"; procedure delete_log (position : string_crate.Cursor) is logname : constant String := HT.USS (string_crate.Element (position)); fullpath : constant String := buildlog_dir & logname; begin bytes_purged := bytes_purged + disktype (DIR.Size (fullpath)); TIO.Put_Line (" " & logname); DIR.Delete_File (fullpath); end delete_log; begin TIO.Put_Line ("Removed the following logs:"); log_list.Iterate (delete_log'Access); TIO.Put_Line ("Recovered" & display_kmg (bytes_purged)); end remove_obsolete_logs; end PortScan.Scan;
zrmyers/VulkanAda
Ada
6,754
adb
-------------------------------------------------------------------------------- -- 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. -------------------------------------------------------------------------------- with Ada.Text_IO; with Ada.Characters.Latin_1; with Vulkan.Math.GenDMatrix; with Vulkan.Math.Dmat2x2; with Vulkan.Math.Dmat4x2; with Vulkan.Math.Dmat3x4; with Vulkan.Math.GenDType; with Vulkan.Math.Dvec2; with Vulkan.Math.Dvec4; with Vulkan.Test.Framework; use Ada.Text_IO; use Ada.Characters.Latin_1; use Vulkan.Math.Dmat2x2; use Vulkan.Math.Dmat4x2; use Vulkan.Math.Dmat3x4; use Vulkan.Math.GenDType; use Vulkan.Math.Dvec2; use Vulkan.Math.Dvec4; use Vulkan.Test.Framework; -------------------------------------------------------------------------------- --< @group Vulkan Math Basic Types -------------------------------------------------------------------------------- --< @summary --< This package provides tests for single precision floating point mat4x2. -------------------------------------------------------------------------------- package body Vulkan.Math.Dmat4x2.Test is -- Test Mat4x2 procedure Test_Dmat4x2 is vec1 : Vkm_Dvec2 := Make_Dvec2(1.0, 2.0); vec2 : Vkm_Dvec4 := Make_Dvec4(1.0, 2.0, 3.0, 4.0); mat1 : Vkm_Dmat4x2 := Make_Dmat4x2; mat2 : Vkm_Dmat4x2 := Make_Dmat4x2(0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0); mat3 : Vkm_Dmat4x2 := Make_Dmat4x2(vec1, - vec1, 2.0 * vec1, - 2.0 * vec1); mat4 : Vkm_Dmat4x2 := Make_Dmat4x2(mat2); mat5 : Vkm_Dmat2x2 := Make_Dmat2x2(5.0); mat6 : Vkm_Dmat4x2 := Make_Dmat4x2(mat5); mat7 : Vkm_Dmat3x4 := Make_Dmat3x4(mat5); begin Put_Line(LF & "Testing Mat4x2 Constructors..."); Put_Line("mat1 " & mat1.Image); Assert_Dmat4x2_Equals(mat1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0); Put_Line("mat2 " & mat2.Image); Assert_Dmat4x2_Equals(mat2, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0); Put_Line("mat3 " & mat3.Image); Assert_Dmat4x2_Equals(mat3, 1.0, 2.0, -1.0, -2.0, 2.0, 4.0, -2.0, -4.0); Put_Line("mat4 " & mat4.Image); Assert_Dmat4x2_Equals(mat4, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0); Put_Line("mat6 " & mat6.Image); Assert_Dmat4x2_Equals(mat6, 5.0, 0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0); Put_Line("Testing '=' operator..."); Put_Line(" mat2 != mat3"); Assert_Vkm_Bool_Equals(mat2 = mat3, False); Put_Line(" mat4 != mat5"); Assert_Vkm_Bool_Equals(mat4 = mat5, False); Put_Line(" mat4 = mat2"); Assert_Vkm_Bool_Equals(mat4 = mat2, True); Put_Line(" Testing unary '+/-' operator"); Put_Line(" + mat4 = " & Image(+ mat4)); Assert_Dmat4x2_Equals(+mat4, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0); Put_Line(" - mat4 = " & Image(- mat4)); Assert_Dmat4x2_Equals(-mat4, -0.0, -1.0, -2.0, -3.0, -4.0, -5.0, -6.0, -7.0); Put_Line("+(- mat4) = " & Image(+(- mat4))); Assert_Dmat4x2_Equals(-mat4, -0.0, -1.0, -2.0, -3.0, -4.0, -5.0, -6.0, -7.0); Put_Line("Testing 'abs' operator..."); Put_Line(" abs(- mat4) = " & Image(abs(-mat4))); Assert_Dmat4x2_Equals(abs(-mat4), 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0); Put_Line("Testing '+' operator..."); Put_Line(" mat4 + mat3 = " & Image(mat4 + mat3)); Assert_Dmat4x2_Equals(mat4 + mat3, 1.0, 3.0, 1.0, 1.0, 6.0, 9.0, 4.0, 3.0); Put_Line("Testing '-' operator..."); Put_Line(" mat4 - mat3 = " & Image(mat4 -mat3)); Assert_Dmat4x2_Equals(mat4 - mat3, -1.0, -1.0, 3.0, 5.0, 2.0, 1.0, 8.0, 11.0); Put_Line("Testing '*' operator..."); Put_Line(" mat4 * mat5 = " & Image(mat4 * mat5)); Assert_Dmat4x2_Equals(mat4 * mat5, 0.0, 5.0, 10.0, 15.0, 20.0, 25.0, 30.0, 35.0); Put_Line(" mat7 * mat4 = " & Image(mat7 * mat4)); Assert_Dmat3x2_Equals(mat7 * mat4, 0.0, 5.0, 10.0, 15.0, 0.0, 0.0); Put_Line(" mat4 * vec1 = " & Image(mat4 * vec1)); Assert_Dvec4_Equals(mat4 * vec1, 2.0 , 8.0 , 14.0, 20.0); Put_Line(" vec2 * mat4 = " & Image(vec2 * mat4)); Assert_Dvec2_Equals(vec2 * mat4, 40.0 , 50.0 ); end Test_Dmat4x2; end Vulkan.Math.Dmat4x2.Test;
afrl-rq/OpenUxAS
Ada
13,783
adb
with DOM.Core.Elements; with Ada.Text_IO; use Ada.Text_IO; with AFRL.CMASI.AutomationResponse; use AFRL.CMASI.AutomationResponse; with AFRL.CMASI.AirVehicleState; use AFRL.CMASI.AirVehicleState; with AFRL.CMASI.MissionCommand; use AFRL.CMASI.MissionCommand; with Common; use Common; with LMCP_Messages; -- use LMCP_Messages; with LMCP_Message_Conversions; use LMCP_Message_Conversions; package body UxAS.Comms.LMCP_Net_Client.Service.Waypoint_Plan_Management is --------------------------- -- Convenience functions -- --------------------------- function TurnType_Attribute (XML_Node : DOM.Core.Element; Name : String; Default : LMCP_Messages.TurnTypeEnum) return LMCP_Messages.TurnTypeEnum; function UInt32_Attribute (XML_Node : DOM.Core.Element; Name : String; Default : Common.UInt32) return Common.UInt32; function Int64_Attribute (XML_Node : DOM.Core.Element; Name : String; Default : Common.Int64) return Common.Int64; function Real64_Attribute (XML_Node : DOM.Core.Element; Name : String; Default : Common.Real64) return Common.Real64; function Boolean_Attribute (XML_Node : DOM.Core.Element; Name : String; Default : Boolean) return Boolean; ----------------------- -- Local subprograms -- ----------------------- procedure Handle_AirVehicleState_Msg (This : in out Waypoint_Plan_Manager_Service; Msg : Any_LMCP_Message); procedure Handle_AutomationResponse_Msg (This : in out Waypoint_Plan_Manager_Service; Msg : Any_LMCP_Message); procedure Handle_MissionCommand_Msg (This : in out Waypoint_Plan_Manager_Service; Msg : Any_LMCP_Message); --------------- -- Configure -- --------------- overriding procedure Configure (This : in out Waypoint_Plan_Manager_Service; XML_Node : DOM.Core.Element; Result : out Boolean) is Unused : Boolean; begin This.Config.VehicleID := Int64_Attribute (XML_Node, "VehicleID", Default => Common.Int64 (This.Entity_Id)); -- Is it This.Entity_Id or Entity_Id (This)? This.Config.NumberWaypointsToServe := UInt32_Attribute (XML_Node, "NumberWaypointsToServe", Default => This.Config.NumberWaypointsToServe); This.Config.NumberWaypointsToServe := Common.UInt32'Max (This.Config.NumberWaypointsToServe, 1); This.Config.NumberWaypointsOverlap := UInt32_Attribute (XML_Node, "NumberWaypointsOverlap", Default => This.Config.NumberWaypointsOverlap); This.Config.NumberWaypointsOverlap := Common.UInt32'Max (This.Config.NumberWaypointsOverlap, 2); This.Config.LoiterRadiusDefault := Real64_Attribute (XML_Node, "DefaultLoiterRadius_m", Default => This.Config.LoiterRadiusDefault); This.Config.GimbalPayloadId := Int64_Attribute (XML_Node, "GimbalPayloadId", Default => This.Config.GimbalPayloadId); This.Config.TurnType := TurnType_Attribute (XML_Node, "TurnType", Default => This.Config.TurnType); -- Put_Line ("===== Configuration Done ====="); -- Put_Line ("VehicleID:" & This.Config.VehicleID'Image); -- Put_Line ("NumberWaypointsToServe:" & This.Config.NumberWaypointsToServe'Image); -- Put_Line ("NumberWaypointOverlap:" & This.Config.NumberWaypointsOverlap'Image); -- Put_Line ("LoiterRadiusDefault:" & This.Config.LoiterRadiusDefault'Image); -- Put_Line ("GimbalPayloadId:" & This.Config.GimbalPayloadId'Image); -- Put_Line ("TurnType:" & This.Config.TurnType'Image); This.Add_Subscription_Address (AFRL.CMASI.AutomationResponse.Subscription, Unused); This.Add_Subscription_Address (AFRL.CMASI.AirVehicleState.Subscription, Unused); This.Add_Subscription_Address (AFRL.CMASI.MissionCommand.Subscription, Unused); Result := True; end Configure; ------------ -- Create -- ------------ function Create return Any_Service is Result : Waypoint_Plan_Manager_Service_Ref; begin Result := new Waypoint_Plan_Manager_Service; Result.Construct_Service (Service_Type => Type_Name, Work_Directory_Name => Directory_Name); return Any_Service (Result); end Create; ---------------------------- -- Handle_AirVehicleState -- ---------------------------- procedure Handle_AirVehicleState_Msg (This : in out Waypoint_Plan_Manager_Service; Msg : Any_LMCP_Message) is AVS : constant AirVehicleState_Any := AirVehicleState_Any (Msg.Payload); AV_ID : constant Common.Int64 := Common.Int64 (AVS.getID); Time : constant Common.Int64 := Common.Int64 (AVS.getTime); WP_ID : constant Common.Int64 := Common.Int64 (AVS.getCurrentWaypoint); begin -- If the AVS is for this vehicle, update timer and waypoint state if AV_ID = This.Config.VehicleID then if This.Timer = 0 then This.Timer := Time; end if; if Time - This.Timer > This.Min_Time_Between_Commands_ms then This.Timer := Time; This.Time_Elapsed := True; end if; if WP_ID = This.State.Next_First_Id then This.State.Headed_To_First_Id := True; end if; end if; end Handle_AirVehicleState_Msg; ---------------------------- -- Handle_Mission_Command -- ---------------------------- procedure Handle_MissionCommand_Msg (This : in out Waypoint_Plan_Manager_Service; Msg : Any_LMCP_Message) is MC : constant MissionCommand_Acc := MissionCommand_Acc (Msg.Payload); Vehicle_ID : Common.Int64 := Common.Int64 (MC.getVehicleID); begin if Vehicle_ID = This.Config.VehicleID then Handle_MissionCommand (This.State, As_MissionCommand_Message (MC)); Put_Line ("Got MC."); end if; end Handle_MissionCommand_Msg; -------------------------------- -- Handle_Automation_Response -- -------------------------------- procedure Handle_AutomationResponse_Msg (This : in out Waypoint_Plan_Manager_Service; Msg : Any_LMCP_Message) is AR : constant AutomationResponse_Any := AutomationResponse_Any (Msg.Payload); Vec_MC_Acc_Acc : constant Vect_MissionCommand_Acc_Acc := AR.getMissionCommandList; begin for MC of Vec_MC_Acc_Acc.all loop if Common.Int64 (MC.getVehicleID) = This.Config.VehicleID then Handle_MissionCommand (This.State, As_MissionCommand_Message (MC)); -- Put_Line ("Got AR."); -- Print (This.State); exit; end if; end loop; end Handle_AutomationResponse_Msg; ---------------- -- Initialize -- ---------------- overriding procedure Initialize (This : in out Waypoint_Plan_Manager_Service; Result : out Boolean) is -- Since we are not doing the Timers begin -- the C++ version creates the timers here (but we don't currently). Waypoint_Plan_Manager_Communication.Initialize (This.Mailbox, Source_Group => Value (This.Message_Source_Group), Unique_Id => Common.Int64 (UxAS.Comms.LMCP_Net_Client.Unique_Entity_Send_Message_Id), Entity_Id => Common.UInt32 (This.Entity_Id), Service_Id => Common.UInt32 (This.Network_Id)); Result := True; end Initialize; ----------------------------------- -- Process_Received_LMCP_Message -- ----------------------------------- overriding procedure Process_Received_LMCP_Message (This : in out Waypoint_Plan_Manager_Service; Received_Message : not null Any_LMCP_Message; Should_Terminate : out Boolean) is begin if Received_Message.Payload.all in AirVehicleState'Class then This.Handle_AirVehicleState_Msg (Received_Message); elsif Received_Message.Payload.all in MissionCommand'Class then This.Handle_MissionCommand_Msg (Received_Message); elsif Received_Message.Payload.all in AutomationResponse'Class then This.Handle_AutomationResponse_Msg (Received_Message); end if; if This.Time_Elapsed then if (This.State.New_Command and This.State.Next_Segment_Id > 0 and This.State.Next_First_Id > 0) or else (not This.State.New_Command and This.State.Headed_To_First_Id) then Produce_Segment (This.State, This.Config, This.Mailbox); This.Time_Elapsed := False; This.State.Headed_To_First_Id := False; end if; end if; Should_Terminate := False; end Process_Received_LMCP_Message; --------------------------------- -- Registry_Service_Type_Names -- --------------------------------- function Registry_Service_Type_Names return Service_Type_Names_List is (Service_Type_Names_List'(1 => Instance (Service_Type_Name_Max_Length, Content => Type_Name))); ------------------------ -- TurnType_Attribute -- ------------------------ function TurnType_Attribute (XML_Node : DOM.Core.Element; Name : String; Default : LMCP_Messages.TurnTypeEnum) return LMCP_Messages.TurnTypeEnum is use DOM.Core; Attr_Value : constant DOM_String := Elements.Get_Attribute (XML_Node, Name); begin if Attr_Value /= "" then begin return LMCP_Messages.TurnTypeEnum'Value (Attr_Value); exception when others => Put_Line ("Could not convert " & Attr_Value & " to TurnTypeEnum. Using default " & Default'Image); return Default; end; else return Default; end if; end TurnType_Attribute; ---------------------- -- UInt32_Attribute -- ---------------------- function UInt32_Attribute (XML_Node : DOM.Core.Element; Name : String; Default : Common.UInt32) return Common.UInt32 is use DOM.Core; Attr_Value : constant DOM_String := Elements.Get_Attribute (XML_Node, Name); begin if Attr_Value /= "" then begin return Common.UInt32'Value (Attr_Value); exception when others => Put_Line ("Could not convert " & Attr_Value & " to UInt32. Using default " & Default'Image); return Default; end; else return Default; end if; end UInt32_Attribute; --------------------- -- Int64_Attribute -- --------------------- function Int64_Attribute (XML_Node : DOM.Core.Element; Name : String; Default : Common.Int64) return Common.Int64 is use DOM.Core; Attr_Value : constant DOM_String := Elements.Get_Attribute (XML_Node, Name); begin if Attr_Value /= "" then begin return Common.Int64'Value (Attr_Value); exception when others => Put_Line ("Could not convert " & Attr_Value & " to Int64. Using default " & Default'Image); return Default; end; else return Default; end if; end Int64_Attribute; ---------------------- -- Real64_Attribute -- ---------------------- function Real64_Attribute (XML_Node : DOM.Core.Element; Name : String; Default : Common.Real64) return Common.Real64 is use DOM.Core; Attr_Value : constant DOM_String := Elements.Get_Attribute (XML_Node, Name); begin if Attr_Value /= "" then begin return Common.Real64'Value (Attr_Value); exception when others => Put_Line ("Could not convert " & Attr_Value & " to Real64. Using default " & Default'Image); return Default; end; else return Default; end if; end Real64_Attribute; ----------------------- -- Boolean_Attribute -- ----------------------- function Boolean_Attribute (XML_Node : DOM.Core.Element; Name : String; Default : Boolean) return Boolean is use DOM.Core; Attr_Value : constant DOM_String := Elements.Get_Attribute (XML_Node, Name); begin if Attr_Value /= "" then begin return Boolean'Value (Attr_Value); exception when others => Put_Line ("Could not convert " & Attr_Value & " to Boolean. Using default " & Default'Image); return Default; end; else return Default; end if; end Boolean_Attribute; ----------------------------- -- Package Executable Part -- ----------------------------- -- This is the executable part for the package, invoked automatically and only once. begin -- All concrete service subclasses must call this procedure in their -- own package like this, with their own params. The effect is the same as the -- following: -- -- WaypointPlanManagerService::ServiceBase::CreationRegistrar<WaypointPlanManagerService> -- WaypointPlanManagerService::s_registrar(WaypointPlanManagerService::s_registryServiceTypeNames()); -- -- located at the top of the cpp file Register_Service_Creation_Function_Pointers (Registry_Service_Type_Names, Create'Access); end UxAS.Comms.LMCP_Net_Client.Service.Waypoint_Plan_Management;
reznikmm/matreshka
Ada
3,683
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Web Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2016, 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$ ------------------------------------------------------------------------------ package body Demo_Actions is --------------------- -- Triggered_Event -- --------------------- overriding procedure Triggered_Event (Self : in out Demo_Action; Event : in out UI.Events.Mouse.Click.Click_Event'Class) is begin Self.Window.Set_Position (300, 300); end Triggered_Event; end Demo_Actions;
AdaCore/Ada_Drivers_Library
Ada
18,900
ads
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2016-2020, 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; with NRF_SVD.POWER; with NRF_SVD.CLOCK; with NRF_SVD.GPIOTE; with NRF_SVD.PPI; with NRF_SVD.RADIO; with NRF_SVD.TIMER; with NRF_SVD.RTC; with NRF_SVD.WDT; with NRF_SVD.RNG; with NRF_SVD.TEMP; with NRF_SVD.ECB; with NRF_SVD.CCM; with NRF_SVD.AAR; with NRF_SVD.TWI; with NRF_SVD.UART; with NRF_SVD.QDEC; with NRF_SVD.ADC; with HAL; use HAL; package nRF.Tasks is procedure Trigger (T : Task_Type); -- Software task trigger function Get_Address (T : Task_Type) return System.Address; function Get_Address (T : Task_Type) return UInt32; -- Power management tasks Power_CONSTLAT : constant Task_Type; Power_LOWPWR : constant Task_Type; -- Clock tasks Clock_HFCLKSTART : constant Task_Type; Clock_HFCLKSTOP : constant Task_Type; Clock_LFCLKSTART : constant Task_Type; Clock_LFCLKSTOP : constant Task_Type; Clock_CAL : constant Task_Type; Clock_CTSTART : constant Task_Type; Clock_CTSTOP : constant Task_Type; -- GPIO tasks GPIOTE_OUT_0 : constant Task_Type; GPIOTE_OUT_1 : constant Task_Type; GPIOTE_OUT_2 : constant Task_Type; GPIOTE_OUT_3 : constant Task_Type; -- Programmable Peripheral Interconnect tasks PPI_CHG_0_EN : constant Task_Type; PPI_CHG_0_DIS : constant Task_Type; PPI_CHG_1_EN : constant Task_Type; PPI_CHG_1_DIS : constant Task_Type; PPI_CHG_2_EN : constant Task_Type; PPI_CHG_2_DIS : constant Task_Type; PPI_CHG_3_EN : constant Task_Type; PPI_CHG_3_DIS : constant Task_Type; -- Radio tasks Radio_TXEN : constant Task_Type; Radio_RXEN : constant Task_Type; Radio_START : constant Task_Type; Radio_STOP : constant Task_Type; Radio_DISABLE : constant Task_Type; Radio_RSSISTART : constant Task_Type; Radio_RSSISTOP : constant Task_Type; Radio_BCSTART : constant Task_Type; Radio_BCSTOP : constant Task_Type; -- Timer 0 tasks Timer_0_START : constant Task_Type; Timer_0_STOP : constant Task_Type; Timer_0_COUNT : constant Task_Type; Timer_0_CLEAR : constant Task_Type; Timer_0_CAPTURE_0 : constant Task_Type; Timer_0_CAPTURE_1 : constant Task_Type; Timer_0_CAPTURE_2 : constant Task_Type; Timer_0_CAPTURE_3 : constant Task_Type; -- Timer 1 tasks Timer_1_START : constant Task_Type; Timer_1_STOP : constant Task_Type; Timer_1_COUNT : constant Task_Type; Timer_1_CLEAR : constant Task_Type; Timer_1_CAPTURE_0 : constant Task_Type; Timer_1_CAPTURE_1 : constant Task_Type; Timer_1_CAPTURE_2 : constant Task_Type; Timer_1_CAPTURE_3 : constant Task_Type; -- Timer 2 tasks Timer_2_START : constant Task_Type; Timer_2_STOP : constant Task_Type; Timer_2_COUNT : constant Task_Type; Timer_2_CLEAR : constant Task_Type; Timer_2_CAPTURE_0 : constant Task_Type; Timer_2_CAPTURE_1 : constant Task_Type; Timer_2_CAPTURE_2 : constant Task_Type; Timer_2_CAPTURE_3 : constant Task_Type; -- RTC 0 tasks RTC_0_START : constant Task_Type; RTC_0_STOP : constant Task_Type; RTC_0_CLEAR : constant Task_Type; RTC_0_TRIGOVRFLW : constant Task_Type; -- RTC 1 tasks RTC_1_START : constant Task_Type; RTC_1_STOP : constant Task_Type; RTC_1_CLEAR : constant Task_Type; RTC_1_TRIGOVRFLW : constant Task_Type; -- Watchdog task Watchdog_START : constant Task_Type; -- Random Number Genrator tasks RNG_START : constant Task_Type; RNG_STOP : constant Task_Type; -- Temperature tasks Temperature_START : constant Task_Type; Temperature_STOP : constant Task_Type; -- AES Electronic Codebook mode encryption (ECB) tasks ECB_START : constant Task_Type; ECB_STOP : constant Task_Type; -- AES CCM mode encryption (CCM) tasks CCM_KSGEN : constant Task_Type; CCM_CRYPT : constant Task_Type; CCM_STOP : constant Task_Type; -- Accelerated Address Resolver (AAR) tasks AAR_START : constant Task_Type; AAR_STOP : constant Task_Type; -- Two Wire Interface (TWI) 0 tasks TWI_0_STARTRX : constant Task_Type; TWI_0_STARTTX : constant Task_Type; TWI_0_STOP : constant Task_Type; TWI_0_SUSPEND : constant Task_Type; TWI_0_RESUME : constant Task_Type; -- Two Wire Interface (TWI) 1 tasks TWI_1_STARTRX : constant Task_Type; TWI_1_STARTTX : constant Task_Type; TWI_1_STOP : constant Task_Type; TWI_1_SUSPEND : constant Task_Type; TWI_1_RESUME : constant Task_Type; -- Universal Asynchronous Receiver/Transmitter (UART) Tasks UART_STARTRX : constant Task_Type; UART_STOPRX : constant Task_Type; UART_STARTTX : constant Task_Type; UART_STOPTX : constant Task_Type; -- Quadrature Decoder (QDEC) QDEC_START : constant Task_Type; QDEC_STOP : constant Task_Type; QDEC_READCLRACC : constant Task_Type; -- Analof to Digital Converter (ADC) ADC_START : constant Task_Type; ADC_STOP : constant Task_Type; private -- Power management tasks Power_CONSTLAT : constant Task_Type := Task_Type (NRF_SVD.POWER.POWER_Periph.TASKS_CONSTLAT'Address); Power_LOWPWR : constant Task_Type := Task_Type (NRF_SVD.POWER.POWER_Periph.TASKS_LOWPWR'Address); -- Clock tasks Clock_HFCLKSTART : constant Task_Type := Task_Type (NRF_SVD.CLOCK.CLOCK_Periph.TASKS_HFCLKSTART'Address); Clock_HFCLKSTOP : constant Task_Type := Task_Type (NRF_SVD.CLOCK.CLOCK_Periph.TASKS_HFCLKSTOP'Address); Clock_LFCLKSTART : constant Task_Type := Task_Type (NRF_SVD.CLOCK.CLOCK_Periph.TASKS_LFCLKSTART'Address); Clock_LFCLKSTOP : constant Task_Type := Task_Type (NRF_SVD.CLOCK.CLOCK_Periph.TASKS_LFCLKSTOP'Address); Clock_CAL : constant Task_Type := Task_Type (NRF_SVD.CLOCK.CLOCK_Periph.TASKS_CAL'Address); Clock_CTSTART : constant Task_Type := Task_Type (NRF_SVD.CLOCK.CLOCK_Periph.TASKS_CTSTART'Address); Clock_CTSTOP : constant Task_Type := Task_Type (NRF_SVD.CLOCK.CLOCK_Periph.TASKS_CTSTOP'Address); -- GPIOTE tasks GPIOTE_OUT_0 : constant Task_Type := Task_Type (NRF_SVD.GPIOTE.GPIOTE_Periph.TASKS_OUT (0)'Address); GPIOTE_OUT_1 : constant Task_Type := Task_Type (NRF_SVD.GPIOTE.GPIOTE_Periph.TASKS_OUT (1)'Address); GPIOTE_OUT_2 : constant Task_Type := Task_Type (NRF_SVD.GPIOTE.GPIOTE_Periph.TASKS_OUT (2)'Address); GPIOTE_OUT_3 : constant Task_Type := Task_Type (NRF_SVD.GPIOTE.GPIOTE_Periph.TASKS_OUT (3)'Address); -- Programmable Peripheral Interconnect Tasks PPI_CHG_0_EN : constant Task_Type := Task_Type (NRF_SVD.PPI.PPI_Periph.TASKS_CHG (0).EN'Address); PPI_CHG_0_DIS : constant Task_Type := Task_Type (NRF_SVD.PPI.PPI_Periph.TASKS_CHG (0).DIS'Address); PPI_CHG_1_EN : constant Task_Type := Task_Type (NRF_SVD.PPI.PPI_Periph.TASKS_CHG (1).EN'Address); PPI_CHG_1_DIS : constant Task_Type := Task_Type (NRF_SVD.PPI.PPI_Periph.TASKS_CHG (1).DIS'Address); PPI_CHG_2_EN : constant Task_Type := Task_Type (NRF_SVD.PPI.PPI_Periph.TASKS_CHG (2).EN'Address); PPI_CHG_2_DIS : constant Task_Type := Task_Type (NRF_SVD.PPI.PPI_Periph.TASKS_CHG (2).DIS'Address); PPI_CHG_3_EN : constant Task_Type := Task_Type (NRF_SVD.PPI.PPI_Periph.TASKS_CHG (3).EN'Address); PPI_CHG_3_DIS : constant Task_Type := Task_Type (NRF_SVD.PPI.PPI_Periph.TASKS_CHG (3).DIS'Address); -- Radio tasks Radio_TXEN : constant Task_Type := Task_Type (NRF_SVD.RADIO.RADIO_Periph.TASKS_TXEN'Address); Radio_RXEN : constant Task_Type := Task_Type (NRF_SVD.RADIO.RADIO_Periph.TASKS_RXEN'Address); Radio_START : constant Task_Type := Task_Type (NRF_SVD.RADIO.RADIO_Periph.TASKS_START'Address); Radio_STOP : constant Task_Type := Task_Type (NRF_SVD.RADIO.RADIO_Periph.TASKS_STOP'Address); Radio_DISABLE : constant Task_Type := Task_Type (NRF_SVD.RADIO.RADIO_Periph.TASKS_DISABLE'Address); Radio_RSSISTART : constant Task_Type := Task_Type (NRF_SVD.RADIO.RADIO_Periph.TASKS_RSSISTART'Address); Radio_RSSISTOP : constant Task_Type := Task_Type (NRF_SVD.RADIO.RADIO_Periph.TASKS_RSSISTOP'Address); Radio_BCSTART : constant Task_Type := Task_Type (NRF_SVD.RADIO.RADIO_Periph.TASKS_BCSTART'Address); Radio_BCSTOP : constant Task_Type := Task_Type (NRF_SVD.RADIO.RADIO_Periph.TASKS_BCSTOP'Address); -- Timer 0 tasks Timer_0_START : constant Task_Type := Task_Type (NRF_SVD.TIMER.TIMER0_Periph.TASKS_START'Address); Timer_0_STOP : constant Task_Type := Task_Type (NRF_SVD.TIMER.TIMER0_Periph.TASKS_START'Address); Timer_0_COUNT : constant Task_Type := Task_Type (NRF_SVD.TIMER.TIMER0_Periph.TASKS_START'Address); Timer_0_CLEAR : constant Task_Type := Task_Type (NRF_SVD.TIMER.TIMER0_Periph.TASKS_START'Address); Timer_0_CAPTURE_0 : constant Task_Type := Task_Type (NRF_SVD.TIMER.TIMER0_Periph.TASKS_START'Address); Timer_0_CAPTURE_1 : constant Task_Type := Task_Type (NRF_SVD.TIMER.TIMER0_Periph.TASKS_START'Address); Timer_0_CAPTURE_2 : constant Task_Type := Task_Type (NRF_SVD.TIMER.TIMER0_Periph.TASKS_START'Address); Timer_0_CAPTURE_3 : constant Task_Type := Task_Type (NRF_SVD.TIMER.TIMER0_Periph.TASKS_START'Address); -- Timer 1 tasks Timer_1_START : constant Task_Type := Task_Type (NRF_SVD.TIMER.TIMER1_Periph.TASKS_START'Address); Timer_1_STOP : constant Task_Type := Task_Type (NRF_SVD.TIMER.TIMER1_Periph.TASKS_START'Address); Timer_1_COUNT : constant Task_Type := Task_Type (NRF_SVD.TIMER.TIMER1_Periph.TASKS_START'Address); Timer_1_CLEAR : constant Task_Type := Task_Type (NRF_SVD.TIMER.TIMER1_Periph.TASKS_START'Address); Timer_1_CAPTURE_0 : constant Task_Type := Task_Type (NRF_SVD.TIMER.TIMER1_Periph.TASKS_START'Address); Timer_1_CAPTURE_1 : constant Task_Type := Task_Type (NRF_SVD.TIMER.TIMER1_Periph.TASKS_START'Address); Timer_1_CAPTURE_2 : constant Task_Type := Task_Type (NRF_SVD.TIMER.TIMER1_Periph.TASKS_START'Address); Timer_1_CAPTURE_3 : constant Task_Type := Task_Type (NRF_SVD.TIMER.TIMER1_Periph.TASKS_START'Address); -- Timer 2 tasks Timer_2_START : constant Task_Type := Task_Type (NRF_SVD.TIMER.TIMER2_Periph.TASKS_START'Address); Timer_2_STOP : constant Task_Type := Task_Type (NRF_SVD.TIMER.TIMER2_Periph.TASKS_START'Address); Timer_2_COUNT : constant Task_Type := Task_Type (NRF_SVD.TIMER.TIMER2_Periph.TASKS_START'Address); Timer_2_CLEAR : constant Task_Type := Task_Type (NRF_SVD.TIMER.TIMER2_Periph.TASKS_START'Address); Timer_2_CAPTURE_0 : constant Task_Type := Task_Type (NRF_SVD.TIMER.TIMER2_Periph.TASKS_START'Address); Timer_2_CAPTURE_1 : constant Task_Type := Task_Type (NRF_SVD.TIMER.TIMER2_Periph.TASKS_START'Address); Timer_2_CAPTURE_2 : constant Task_Type := Task_Type (NRF_SVD.TIMER.TIMER2_Periph.TASKS_START'Address); Timer_2_CAPTURE_3 : constant Task_Type := Task_Type (NRF_SVD.TIMER.TIMER2_Periph.TASKS_START'Address); -- RTC 0 tasks RTC_0_START : constant Task_Type := Task_Type (NRF_SVD.RTC.RTC0_Periph.TASKS_START'Address); RTC_0_STOP : constant Task_Type := Task_Type (NRF_SVD.RTC.RTC0_Periph.TASKS_STOP'Address); RTC_0_CLEAR : constant Task_Type := Task_Type (NRF_SVD.RTC.RTC0_Periph.TASKS_CLEAR'Address); RTC_0_TRIGOVRFLW : constant Task_Type := Task_Type (NRF_SVD.RTC.RTC0_Periph.TASKS_TRIGOVRFLW'Address); -- RTC 1 tasks RTC_1_START : constant Task_Type := Task_Type (NRF_SVD.RTC.RTC1_Periph.TASKS_START'Address); RTC_1_STOP : constant Task_Type := Task_Type (NRF_SVD.RTC.RTC1_Periph.TASKS_STOP'Address); RTC_1_CLEAR : constant Task_Type := Task_Type (NRF_SVD.RTC.RTC1_Periph.TASKS_CLEAR'Address); RTC_1_TRIGOVRFLW : constant Task_Type := Task_Type (NRF_SVD.RTC.RTC1_Periph.TASKS_TRIGOVRFLW'Address); -- Watchdog tasks Watchdog_START : constant Task_Type := Task_Type (NRF_SVD.WDT.WDT_Periph.TASKS_START'Address); -- Random Number Genrator tasks RNG_START : constant Task_Type := Task_Type (NRF_SVD.RNG.RNG_Periph.TASKS_START'Address); RNG_STOP : constant Task_Type := Task_Type (NRF_SVD.RNG.RNG_Periph.TASKS_START'Address); -- Temperature tasks Temperature_START : constant Task_Type := Task_Type (NRF_SVD.TEMP.TEMP_Periph.TASKS_START'Address); Temperature_STOP : constant Task_Type := Task_Type (NRF_SVD.TEMP.TEMP_Periph.TASKS_STOP'Address); -- AES Electronic Codebook mode encryption (ECB) tasks ECB_START : constant Task_Type := Task_Type (NRF_SVD.ECB.ECB_Periph.TASKS_STARTECB'Address); ECB_STOP : constant Task_Type := Task_Type (NRF_SVD.ECB.ECB_Periph.TASKS_STOPECB'Address); -- AES CCM mode encryption (CCM) tasks CCM_KSGEN : constant Task_Type := Task_Type (NRF_SVD.CCM.CCM_Periph.TASKS_KSGEN'Address); CCM_CRYPT : constant Task_Type := Task_Type (NRF_SVD.CCM.CCM_Periph.TASKS_CRYPT'Address); CCM_STOP : constant Task_Type := Task_Type (NRF_SVD.CCM.CCM_Periph.TASKS_STOP'Address); -- Accelerated Address Resolver (AAR) tasks AAR_START : constant Task_Type := Task_Type (NRF_SVD.AAR.AAR_Periph.TASKS_START'Address); AAR_STOP : constant Task_Type := Task_Type (NRF_SVD.AAR.AAR_Periph.TASKS_STOP'Address); -- Two Wire Interface (TWI) 0 tasks TWI_0_STARTRX : constant Task_Type := Task_Type (NRF_SVD.TWI.TWI0_Periph.TASKS_STARTRX'Address); TWI_0_STARTTX : constant Task_Type := Task_Type (NRF_SVD.TWI.TWI0_Periph.TASKS_STARTTX'Address); TWI_0_STOP : constant Task_Type := Task_Type (NRF_SVD.TWI.TWI0_Periph.TASKS_STOP'Address); TWI_0_SUSPEND : constant Task_Type := Task_Type (NRF_SVD.TWI.TWI0_Periph.TASKS_SUSPEND'Address); TWI_0_RESUME : constant Task_Type := Task_Type (NRF_SVD.TWI.TWI0_Periph.TASKS_RESUME'Address); -- Two Wire Interface (TWI) 1 tasks TWI_1_STARTRX : constant Task_Type := Task_Type (NRF_SVD.TWI.TWI1_Periph.TASKS_STARTRX'Address); TWI_1_STARTTX : constant Task_Type := Task_Type (NRF_SVD.TWI.TWI1_Periph.TASKS_STARTTX'Address); TWI_1_STOP : constant Task_Type := Task_Type (NRF_SVD.TWI.TWI1_Periph.TASKS_STOP'Address); TWI_1_SUSPEND : constant Task_Type := Task_Type (NRF_SVD.TWI.TWI1_Periph.TASKS_SUSPEND'Address); TWI_1_RESUME : constant Task_Type := Task_Type (NRF_SVD.TWI.TWI1_Periph.TASKS_RESUME'Address); -- Universal Asynchronous Receiver/Transmitter (UART) Tasks UART_STARTRX : constant Task_Type := Task_Type (NRF_SVD.UART.UART0_Periph.TASKS_STARTRX'Address); UART_STOPRX : constant Task_Type := Task_Type (NRF_SVD.UART.UART0_Periph.TASKS_STOPRX'Address); UART_STARTTX : constant Task_Type := Task_Type (NRF_SVD.UART.UART0_Periph.TASKS_STARTTX'Address); UART_STOPTX : constant Task_Type := Task_Type (NRF_SVD.UART.UART0_Periph.TASKS_STOPTX'Address); -- Quadrature Decoder (QDEC) QDEC_START : constant Task_Type := Task_Type (NRF_SVD.QDEC.QDEC_Periph.TASKS_START'Address); QDEC_STOP : constant Task_Type := Task_Type (NRF_SVD.QDEC.QDEC_Periph.TASKS_STOP'Address); QDEC_READCLRACC : constant Task_Type := Task_Type (NRF_SVD.QDEC.QDEC_Periph.TASKS_READCLRACC'Address); -- Analof to Digital Converter (ADC) ADC_START : constant Task_Type := Task_Type (NRF_SVD.ADC.ADC_Periph.TASKS_START'Address); ADC_STOP : constant Task_Type := Task_Type (NRF_SVD.ADC.ADC_Periph.TASKS_STOP'Address); end nRF.Tasks;
io7m/coreland-vector-ada
Ada
415
ads
generic package vector.absolute is -- absolute, in place procedure f (a : in out vector_f_t); pragma inline (f); procedure d (a : in out vector_d_t); pragma inline (d); -- absolute, external storage procedure f_ext (a : vector_f_t; x : out vector_f_t); pragma inline (f_ext); procedure d_ext (a : vector_d_t; x : out vector_d_t); pragma inline (d_ext); end vector.absolute;
optikos/oasis
Ada
7,221
ads
-- Copyright (c) 2019 Maxim Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with Program.Lexical_Elements; with Program.Elements.Defining_Identifiers; with Program.Elements.Aspect_Specifications; with Program.Element_Vectors; with Program.Elements.Identifiers; with Program.Elements.Protected_Body_Declarations; with Program.Element_Visitors; package Program.Nodes.Protected_Body_Declarations is pragma Preelaborate; type Protected_Body_Declaration is new Program.Nodes.Node and Program.Elements.Protected_Body_Declarations .Protected_Body_Declaration and Program.Elements.Protected_Body_Declarations .Protected_Body_Declaration_Text with private; function Create (Protected_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Body_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Name : not null Program.Elements.Defining_Identifiers .Defining_Identifier_Access; With_Token : Program.Lexical_Elements.Lexical_Element_Access; Aspects : Program.Elements.Aspect_Specifications .Aspect_Specification_Vector_Access; Is_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Protected_Operations : not null Program.Element_Vectors .Element_Vector_Access; End_Token : not null Program.Lexical_Elements .Lexical_Element_Access; End_Name : Program.Elements.Identifiers.Identifier_Access; Semicolon_Token : not null Program.Lexical_Elements .Lexical_Element_Access) return Protected_Body_Declaration; type Implicit_Protected_Body_Declaration is new Program.Nodes.Node and Program.Elements.Protected_Body_Declarations .Protected_Body_Declaration with private; function Create (Name : not null Program.Elements.Defining_Identifiers .Defining_Identifier_Access; Aspects : Program.Elements.Aspect_Specifications .Aspect_Specification_Vector_Access; Protected_Operations : not null Program.Element_Vectors .Element_Vector_Access; End_Name : Program.Elements.Identifiers.Identifier_Access; Is_Part_Of_Implicit : Boolean := False; Is_Part_Of_Inherited : Boolean := False; Is_Part_Of_Instance : Boolean := False) return Implicit_Protected_Body_Declaration with Pre => Is_Part_Of_Implicit or Is_Part_Of_Inherited or Is_Part_Of_Instance; private type Base_Protected_Body_Declaration is abstract new Program.Nodes.Node and Program.Elements.Protected_Body_Declarations .Protected_Body_Declaration with record Name : not null Program.Elements.Defining_Identifiers .Defining_Identifier_Access; Aspects : Program.Elements.Aspect_Specifications .Aspect_Specification_Vector_Access; Protected_Operations : not null Program.Element_Vectors .Element_Vector_Access; End_Name : Program.Elements.Identifiers.Identifier_Access; end record; procedure Initialize (Self : aliased in out Base_Protected_Body_Declaration'Class); overriding procedure Visit (Self : not null access Base_Protected_Body_Declaration; Visitor : in out Program.Element_Visitors.Element_Visitor'Class); overriding function Name (Self : Base_Protected_Body_Declaration) return not null Program.Elements.Defining_Identifiers .Defining_Identifier_Access; overriding function Aspects (Self : Base_Protected_Body_Declaration) return Program.Elements.Aspect_Specifications .Aspect_Specification_Vector_Access; overriding function Protected_Operations (Self : Base_Protected_Body_Declaration) return not null Program.Element_Vectors.Element_Vector_Access; overriding function End_Name (Self : Base_Protected_Body_Declaration) return Program.Elements.Identifiers.Identifier_Access; overriding function Is_Protected_Body_Declaration_Element (Self : Base_Protected_Body_Declaration) return Boolean; overriding function Is_Declaration_Element (Self : Base_Protected_Body_Declaration) return Boolean; type Protected_Body_Declaration is new Base_Protected_Body_Declaration and Program.Elements.Protected_Body_Declarations .Protected_Body_Declaration_Text with record Protected_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Body_Token : not null Program.Lexical_Elements .Lexical_Element_Access; With_Token : Program.Lexical_Elements.Lexical_Element_Access; Is_Token : not null Program.Lexical_Elements .Lexical_Element_Access; End_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Semicolon_Token : not null Program.Lexical_Elements .Lexical_Element_Access; end record; overriding function To_Protected_Body_Declaration_Text (Self : aliased in out Protected_Body_Declaration) return Program.Elements.Protected_Body_Declarations .Protected_Body_Declaration_Text_Access; overriding function Protected_Token (Self : Protected_Body_Declaration) return not null Program.Lexical_Elements.Lexical_Element_Access; overriding function Body_Token (Self : Protected_Body_Declaration) return not null Program.Lexical_Elements.Lexical_Element_Access; overriding function With_Token (Self : Protected_Body_Declaration) return Program.Lexical_Elements.Lexical_Element_Access; overriding function Is_Token (Self : Protected_Body_Declaration) return not null Program.Lexical_Elements.Lexical_Element_Access; overriding function End_Token (Self : Protected_Body_Declaration) return not null Program.Lexical_Elements.Lexical_Element_Access; overriding function Semicolon_Token (Self : Protected_Body_Declaration) return not null Program.Lexical_Elements.Lexical_Element_Access; type Implicit_Protected_Body_Declaration is new Base_Protected_Body_Declaration with record Is_Part_Of_Implicit : Boolean; Is_Part_Of_Inherited : Boolean; Is_Part_Of_Instance : Boolean; end record; overriding function To_Protected_Body_Declaration_Text (Self : aliased in out Implicit_Protected_Body_Declaration) return Program.Elements.Protected_Body_Declarations .Protected_Body_Declaration_Text_Access; overriding function Is_Part_Of_Implicit (Self : Implicit_Protected_Body_Declaration) return Boolean; overriding function Is_Part_Of_Inherited (Self : Implicit_Protected_Body_Declaration) return Boolean; overriding function Is_Part_Of_Instance (Self : Implicit_Protected_Body_Declaration) return Boolean; end Program.Nodes.Protected_Body_Declarations;
sergev/vak-opensource
Ada
101
ads
with Stream; package Hello_Ada is procedure Start (console : Stream.Stream'Class); end Hello_Ada;
persan/advent-of-code-2020
Ada
2,707
ads
-- --- Day 7: Handy Haversacks --- -- -- You land at the regional airport in time for your next flight. In fact, -- it looks like you'll even have time to grab some food: -- all flights are currently delayed due to issues in luggage processing. -- -- Due to recent aviation regulations, -- many rules (your puzzle input) are being enforced about bags and their contents; -- bags must be color-coded and must contain specific quantities of other color-coded bags. -- Apparently, nobody responsible for these regulations considered how long they would take to enforce! -- -- For example, consider the following rules: -- -- light red bags contain 1 bright white bag, 2 muted yellow bags. -- dark orange bags contain 3 bright white bags, 4 muted yellow bags. -- bright white bags contain 1 shiny gold bag. -- muted yellow bags contain 2 shiny gold bags, 9 faded blue bags. -- shiny gold bags contain 1 dark olive bag, 2 vibrant plum bags. -- dark olive bags contain 3 faded blue bags, 4 dotted black bags. -- vibrant plum bags contain 5 faded blue bags, 6 dotted black bags. -- faded blue bags contain no other bags. -- dotted black bags contain no other bags. -- -- These rules specify the required contents for 9 bag types. -- In this example, every faded blue bag is empty, -- every vibrant plum bag contains 11 bags (5 faded blue and 6 dotted black), and so on. -- -- You have a shiny gold bag. If you wanted to carry it in at least one other bag, -- how many different bag colors would be valid for the outermost bag? -- (In other words: how many colors can, eventually, contain at least one shiny gold bag?) -- -- In the above rules, the following options would be available to you: -- -- A bright white bag, which can hold your shiny gold bag directly. -- A muted yellow bag, which can hold your shiny gold bag directly, -- plus some other bags. -- A dark orange bag, which can hold bright white and muted yellow bags, -- either of which could then hold your shiny gold bag. -- A light red bag, which can hold bright white and muted yellow bags, -- either of which could then hold your shiny gold bag. -- -- So, in this example, the number of bag colors that can eventually -- contain at least one shiny gold bag is 4. -- -- How many bag colors can eventually contain at least one shiny gold bag? -- (The list of rules is quite long; make sure you get all of it.) package Adventofcode.Day_7 is type Bag; type Bags is access Bag; type Bag is tagged record Colour : Ada.Strings.Unbounded.Unbounded_String; Count : Natural := 0; Allowed_Content : Bags; end record; Funci end Adventofcode.Day_7;
shintakezou/drake
Ada
9,517
adb
with Ada.Exception_Identification.From_Here; with Ada.Exceptions.Finally; with System.Formatting; with System.Long_Long_Integer_Types; with System.Synchronous_Control; with C.bits.socket; with C.errno; with C.netinet.in_h; with C.unistd; package body System.Native_IO.Sockets is use Ada.Exception_Identification.From_Here; use type C.size_t; use type C.netdb.struct_addrinfo_ptr; use type C.unistd.socklen_t; subtype Word_Unsigned is Long_Long_Integer_Types.Word_Unsigned; SOCK_STREAM : constant := C.sys.socket.enum_socket_type'Enum_Rep (C.sys.socket.SOCK_STREAM); SOCK_CLOEXEC : constant := C.sys.socket.enum_socket_type'Enum_Rep (C.sys.socket.SOCK_CLOEXEC); -- implementation procedure Close_Socket (Handle : Handle_Type; Raise_On_Error : Boolean) is R : C.signed_int; begin R := C.unistd.close (Handle); if R < 0 and then Raise_On_Error then Raise_Exception (Use_Error'Identity); end if; end Close_Socket; -- client function Get ( Host_Name : not null access constant C.char; Service : not null access constant C.char; Hints : not null access constant C.netdb.struct_addrinfo) return End_Point; function Get ( Host_Name : not null access constant C.char; Service : not null access constant C.char; Hints : not null access constant C.netdb.struct_addrinfo) return End_Point is Data : aliased C.netdb.struct_addrinfo_ptr; R : C.signed_int; begin R := C.netdb.getaddrinfo (Host_Name, Service, Hints, Data'Access); if R /= 0 then Raise_Exception (Use_Error'Identity); else return Data; end if; end Get; -- implementation of client function Resolve (Host_Name : String; Service : String) return End_Point is Hints : aliased constant C.netdb.struct_addrinfo := ( ai_flags => 0, ai_family => C.sys.socket.AF_UNSPEC, ai_socktype => SOCK_STREAM, ai_protocol => C.netinet.in_h.Cast (C.netinet.in_h.IPPROTO_TCP), ai_addrlen => 0, ai_canonname => null, ai_addr => null, ai_next => null); C_Host_Name : C.char_array ( 0 .. Host_Name'Length * Zero_Terminated_Strings.Expanding); C_Service : C.char_array ( 0 .. Service'Length * Zero_Terminated_Strings.Expanding); begin Zero_Terminated_Strings.To_C (Host_Name, C_Host_Name (0)'Access); Zero_Terminated_Strings.To_C (Service, C_Service (0)'Access); return Get (C_Host_Name (0)'Access, C_Service (0)'Access, Hints'Access); end Resolve; function Resolve (Host_Name : String; Port : Port_Number) return End_Point is Hints : aliased constant C.netdb.struct_addrinfo := ( ai_flags => C.netdb.AI_NUMERICSERV, ai_family => C.sys.socket.AF_UNSPEC, ai_socktype => SOCK_STREAM, ai_protocol => C.netinet.in_h.Cast (C.netinet.in_h.IPPROTO_TCP), ai_addrlen => 0, ai_canonname => null, ai_addr => null, ai_next => null); C_Host_Name : C.char_array ( 0 .. Host_Name'Length * Zero_Terminated_Strings.Expanding); Service : C.char_array (0 .. 5); -- "65535" & NUL Service_Length : C.size_t; Error : Boolean; begin Zero_Terminated_Strings.To_C (Host_Name, C_Host_Name (0)'Access); declare Service_As_String : String (1 .. 5); for Service_As_String'Address use Service'Address; Service_Last : Natural; begin Formatting.Image ( Word_Unsigned (Port), Service_As_String, Service_Last, Base => 10, Error => Error); Service_Length := C.size_t (Service_Last); end; Service (Service_Length) := C.char'Val (0); return Get (C_Host_Name (0)'Access, Service (0)'Access, Hints'Access); end Resolve; procedure Connect (Handle : aliased out Handle_Type; Peer : End_Point) is I : C.netdb.struct_addrinfo_ptr := Peer; begin while I /= null loop Handle := C.sys.socket.socket ( I.ai_family, C.signed_int (C.unsigned_int (I.ai_socktype) or SOCK_CLOEXEC), I.ai_protocol); if Handle >= 0 then if C.sys.socket.connect ( Handle, C.sys.socket.CONST_SOCKADDR_ARG'( Unchecked_Tag => 0, sockaddr => C.bits.socket.struct_sockaddr_const_ptr (I.ai_addr)), I.ai_addrlen) = 0 then -- connected return; end if; declare Closing_Handle : constant Handle_Type := Handle; begin Handle := Invalid_Handle; Close_Socket (Closing_Handle, Raise_On_Error => True); end; end if; I := I.ai_next; end loop; Raise_Exception (Use_Error'Identity); end Connect; procedure Finalize (Item : End_Point) is begin C.netdb.freeaddrinfo (Item); end Finalize; -- implementation of server procedure Listen (Server : aliased out Listener; Port : Port_Number) is Hints : aliased constant C.netdb.struct_addrinfo := ( ai_flags => C.signed_int ( C.unsigned_int'(C.netdb.AI_PASSIVE or C.netdb.AI_NUMERICSERV)), ai_family => C.sys.socket.AF_UNSPEC, ai_socktype => SOCK_STREAM, ai_protocol => C.netinet.in_h.Cast (C.netinet.in_h.IPPROTO_TCP), ai_addrlen => 0, ai_canonname => null, ai_addr => null, ai_next => null); Data : aliased C.netdb.struct_addrinfo_ptr; Service : C.char_array (0 .. 5); -- "65535" & NUL Service_Length : C.size_t; begin declare Service_As_String : String (1 .. 5); for Service_As_String'Address use Service'Address; Service_Last : Natural; Error : Boolean; begin Formatting.Image ( Word_Unsigned (Port), Service_As_String, Service_Last, Base => 10, Error => Error); Service_Length := C.size_t (Service_Last); end; Service (Service_Length) := C.char'Val (0); if C.netdb.getaddrinfo ( null, Service (0)'Access, Hints'Access, Data'Access) /= 0 then Raise_Exception (Use_Error'Identity); end if; declare procedure Finally (X : in out C.netdb.struct_addrinfo_ptr); procedure Finally (X : in out C.netdb.struct_addrinfo_ptr) is begin C.netdb.freeaddrinfo (X); end Finally; package Holder is new Ada.Exceptions.Finally.Scoped_Holder ( C.netdb.struct_addrinfo_ptr, Finally); Reuse_Addr_Option : aliased C.signed_int; Socket_Address_Argument : C.sys.socket.CONST_SOCKADDR_ARG; begin Holder.Assign (Data); Server := C.sys.socket.socket ( Data.ai_family, C.signed_int ( C.unsigned_int (Data.ai_socktype) or SOCK_CLOEXEC), Data.ai_protocol); -- set SO_REUSEADDR Reuse_Addr_Option := 1; if C.sys.socket.setsockopt ( Server, C.sys.socket.SOL_SOCKET, C.sys.socket.SO_REUSEADDR, C.void_const_ptr (Reuse_Addr_Option'Address), Reuse_Addr_Option'Size / Standard'Storage_Unit) < 0 then Raise_Exception (Use_Error'Identity); end if; -- bind Socket_Address_Argument.sockaddr := C.bits.socket.struct_sockaddr_const_ptr (Data.ai_addr); if C.sys.socket.bind ( Server, Socket_Address_Argument, Data.ai_addrlen) < 0 then Raise_Exception (Use_Error'Identity); end if; -- listen if C.sys.socket.listen (Server, C.sys.socket.SOMAXCONN) < 0 then Raise_Exception (Use_Error'Identity); end if; end; end Listen; procedure Accept_Socket ( Server : Listener; Handle : aliased out Handle_Type; Remote_Address : out Socket_Address) is begin loop declare Len : aliased C.unistd.socklen_t := Socket_Address'Size / Standard'Storage_Unit; Socket_Address_Argument : C.sys.socket.SOCKADDR_ARG; New_Socket : C.signed_int; errno : C.signed_int; begin Synchronous_Control.Unlock_Abort; Socket_Address_Argument.sockaddr := Remote_Address'Unrestricted_Access; New_Socket := C.sys.socket.accept4 ( Server, Socket_Address_Argument, Len'Access, SOCK_CLOEXEC); errno := C.errno.errno; Synchronous_Control.Lock_Abort; if New_Socket < 0 then if errno /= C.errno.EINTR then Raise_Exception (Use_Error'Identity); end if; -- interrupted and the signal is not "abort", then retry else Handle := New_Socket; exit; end if; end; end loop; end Accept_Socket; end System.Native_IO.Sockets;
ohenley/ada-util
Ada
8,031
ads
----------------------------------------------------------------------- -- util-system-os -- Windows system operations -- 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 System; with Interfaces.C; with Interfaces.C.Strings; with Util.Systems.Types; -- The <b>Util.Systems.Os</b> package defines various types and operations which are specific -- to the OS (Windows). package Util.Systems.Os is -- The directory separator. Directory_Separator : constant Character := '\'; -- The path separator. Path_Separator : constant Character := ';'; -- Defines several windows specific types. type BOOL is mod 8; type WORD is new Interfaces.C.short; type DWORD is new Interfaces.C.unsigned_long; type PDWORD is access all DWORD; for PDWORD'Size use Standard'Address_Size; function Get_Last_Error return Integer; pragma Import (Stdcall, Get_Last_Error, "GetLastError"); -- Some useful error codes (See Windows document "System Error Codes (0-499)"). ERROR_BROKEN_PIPE : constant Integer := 109; -- ------------------------------ -- Handle -- ------------------------------ -- The windows HANDLE is defined as a void* in the C API. subtype HANDLE is System.Address; type PHANDLE is access all HANDLE; for PHANDLE'Size use Standard'Address_Size; function Wait_For_Single_Object (H : in HANDLE; Time : in DWORD) return DWORD; pragma Import (Stdcall, Wait_For_Single_Object, "WaitForSingleObject"); type Security_Attributes is record Length : DWORD; Security_Descriptor : System.Address; Inherit : Boolean; end record; type LPSECURITY_ATTRIBUTES is access all Security_Attributes; for LPSECURITY_ATTRIBUTES'Size use Standard'Address_Size; -- ------------------------------ -- File operations -- ------------------------------ subtype File_Type is HANDLE; NO_FILE : constant File_Type := System.Null_Address; STD_INPUT_HANDLE : constant DWORD := -10; STD_OUTPUT_HANDLE : constant DWORD := -11; STD_ERROR_HANDLE : constant DWORD := -12; function Get_Std_Handle (Kind : in DWORD) return File_Type; pragma Import (Stdcall, Get_Std_Handle, "GetStdHandle"); function Close_Handle (Fd : in File_Type) return BOOL; pragma Import (Stdcall, Close_Handle, "CloseHandle"); function Duplicate_Handle (SourceProcessHandle : in HANDLE; SourceHandle : in HANDLE; TargetProcessHandle : in HANDLE; TargetHandle : in PHANDLE; DesiredAccess : in DWORD; InheritHandle : in BOOL; Options : in DWORD) return BOOL; pragma Import (Stdcall, Duplicate_Handle, "DuplicateHandle"); function Read_File (Fd : in File_Type; Buf : in System.Address; Size : in DWORD; Result : in PDWORD; Overlap : in System.Address) return BOOL; pragma Import (Stdcall, Read_File, "ReadFile"); function Write_File (Fd : in File_Type; Buf : in System.Address; Size : in DWORD; Result : in PDWORD; Overlap : in System.Address) return BOOL; pragma Import (Stdcall, Write_File, "WriteFile"); function Create_Pipe (Read_Handle : in PHANDLE; Write_Handle : in PHANDLE; Attributes : in LPSECURITY_ATTRIBUTES; Buf_Size : in DWORD) return BOOL; pragma Import (Stdcall, Create_Pipe, "CreatePipe"); -- type Size_T is mod 2 ** Standard'Address_Size; subtype LPWSTR is Interfaces.C.Strings.chars_ptr; subtype PBYTE is Interfaces.C.Strings.chars_ptr; subtype Ptr is Interfaces.C.Strings.chars_ptr; subtype LPCTSTR is System.Address; subtype LPTSTR is System.Address; type CommandPtr is access all Interfaces.C.wchar_array; NULL_STR : constant LPWSTR := Interfaces.C.Strings.Null_Ptr; type Startup_Info is record cb : DWORD := 0; lpReserved : LPWSTR := NULL_STR; lpDesktop : LPWSTR := NULL_STR; lpTitle : LPWSTR := NULL_STR; dwX : DWORD := 0; dwY : DWORD := 0; dwXsize : DWORD := 0; dwYsize : DWORD := 0; dwXCountChars : DWORD := 0; dwYCountChars : DWORD := 0; dwFillAttribute : DWORD := 0; dwFlags : DWORD := 0; wShowWindow : WORD := 0; cbReserved2 : WORD := 0; lpReserved2 : PBYTE := Interfaces.C.Strings.Null_Ptr; hStdInput : HANDLE := System.Null_Address; hStdOutput : HANDLE := System.Null_Address; hStdError : HANDLE := System.Null_Address; end record; pragma Pack (Startup_Info); type Startup_Info_Access is access all Startup_Info; type PROCESS_INFORMATION is record hProcess : HANDLE := NO_FILE; hThread : HANDLE := NO_FILE; dwProcessId : DWORD; dwThreadId : DWORD; end record; type Process_Information_Access is access all PROCESS_INFORMATION; function Get_Current_Process return HANDLE; pragma Import (Stdcall, Get_Current_Process, "GetCurrentProcess"); function Get_Exit_Code_Process (Proc : in HANDLE; Code : in PDWORD) return BOOL; pragma Import (Stdcall, Get_Exit_Code_Process, "GetExitCodeProcess"); function Create_Process (Name : in LPCTSTR; Command : in System.Address; Process_Attributes : in LPSECURITY_ATTRIBUTES; Thread_Attributes : in LPSECURITY_ATTRIBUTES; Inherit_Handlers : in Boolean; Creation_Flags : in DWORD; Environment : in LPTSTR; Directory : in LPCTSTR; Startup_Info : in Startup_Info_Access; Process_Info : in Process_Information_Access) return Integer; pragma Import (Stdcall, Create_Process, "CreateProcessW"); -- Terminate the windows process and all its threads. function Terminate_Process (Proc : in HANDLE; Code : in DWORD) return Integer; pragma Import (Stdcall, Terminate_Process, "TerminateProcess"); function Sys_Stat (Path : in LPWSTR; Stat : access Util.Systems.Types.Stat_Type) return Integer; pragma Import (C, Sys_Stat, "_stat64"); function Sys_Fstat (Fs : in File_Type; Stat : access Util.Systems.Types.Stat_Type) return Integer; pragma Import (C, Sys_Fstat, "_fstat64"); private -- kernel32 is used on Windows32 as well as Windows64. pragma Linker_Options ("-lkernel32"); end Util.Systems.Os;
reznikmm/gela
Ada
243
ads
with League.Strings; with Gela.Elements; package Gela.Debug_Properties is pragma Preelaborate; procedure Dump (Element : Gela.Elements.Element_Access; Debug : League.Strings.Universal_String); end Gela.Debug_Properties;
AdaCore/libadalang
Ada
1,091
adb
with Ada.Text_IO; use Ada.Text_IO; procedure Test is package Itfs is type I is interface; --% node.p_get_primitives() procedure Foo (X : I) is abstract; type I2 is interface; --% node.p_get_primitives() procedure Foo (X : I2) is null; type I3 is interface and I and I2; --% node.p_get_primitives() end Itfs; package Concr is type T is tagged null record; procedure Foo (X : T) is null; type R is tagged null record; procedure Foo (X : R) is null; type S is tagged null record; end Concr; package Der is type U is new Concr.T and Itfs.I and Itfs.I2 with null record; --% node.p_get_primitives() type V is new Concr.T and Itfs.I3 with null record; --% node.p_get_primitives() type W is new Itfs.I2 with null record; --% node.p_get_primitives() end Der; package Itfs_Der is type J is interface and Itfs.I; --% node.p_get_primitives() procedure Foo (X : J) is abstract; end Itfs_Der; X : Der.U; begin X.Foo; end Test;
reznikmm/matreshka
Ada
65,985
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- XML Processor -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2010-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 Ada.Unchecked_Deallocation; with League.IRIs; with League.Strings.Internals; with Matreshka.Internals.Strings.Operations; with Matreshka.Internals.Unicode.Characters.Latin; with Matreshka.Internals.URI_Utilities; with XML.SAX.Simple_Readers.Callbacks; with XML.SAX.Simple_Readers.Scanner.Actions; with XML.SAX.Simple_Readers.Scanner.Tables; package body XML.SAX.Simple_Readers.Scanner is use type Interfaces.Unsigned_32; use Matreshka.Internals.Unicode; use Matreshka.Internals.Unicode.Characters.Latin; use Matreshka.Internals.Utf16; use Matreshka.Internals.XML; use Matreshka.Internals.XML.Base_Scopes; use Matreshka.Internals.XML.Entity_Tables; use XML.SAX.Simple_Readers.Scanner.Tables; procedure Set_Whitespace_Matched (Self : in out Simple_Reader'Class) with Inline => True; -- Sets "whitespace matched" flag. procedure Free is new Ada.Unchecked_Deallocation (XML.SAX.Input_Sources.SAX_Input_Source'Class, XML.SAX.Input_Sources.SAX_Input_Source_Access); --------------------------- -- Enter_Start_Condition -- --------------------------- procedure Enter_Start_Condition (Self : in out Simple_Reader'Class; State : Interfaces.Unsigned_32) is begin Self.Scanner_State.YY_Start_State := State * 2 + 1; end Enter_Start_Condition; -------------- -- Finalize -- -------------- procedure Finalize (Self : in out Simple_Reader'Class) is use type XML.SAX.Input_Sources.SAX_Input_Source_Access; begin -- Unwind entity stack and release all input sources owned by the -- reader. while not Self.Scanner_Stack.Is_Empty loop if Self.Scanner_State.Source /= null then -- Deallocate input source and replacement text data, because -- it was not yet saved in the entities table. Free (Self.Scanner_State.Source); Matreshka.Internals.Strings.Dereference (Self.Scanner_State.Data); end if; Self.Scanner_State := Self.Scanner_Stack.Last_Element; Self.Scanner_Stack.Delete_Last; end loop; -- Release last token, it can be unused by the parser when fatal error -- occured. Clear (Self.YYLVal); -- Release shared string when scanner's stack is empty, because it is -- buffer for document entity. Matreshka.Internals.Strings.Dereference (Self.Scanner_State.Data); end Finalize; ---------------- -- Initialize -- ---------------- procedure Initialize (Self : in out Simple_Reader'Class) is begin Self.Scanner_State.Start_Condition_Stack.Append (Tables.DOCUMENT_10); end Initialize; ------------------------- -- Pop_Start_Condition -- ------------------------- procedure Pop_Start_Condition (Self : in out Simple_Reader'Class) is begin Enter_Start_Condition (Self, Self.Scanner_State.Start_Condition_Stack.Last_Element); Self.Scanner_State.Start_Condition_Stack.Delete_Last; end Pop_Start_Condition; ------------------------------------ -- Push_And_Enter_Start_Condition -- ------------------------------------ procedure Push_And_Enter_Start_Condition (Self : in out Simple_Reader'Class; Push : Interfaces.Unsigned_32; Enter : Interfaces.Unsigned_32) is begin Self.Scanner_State.Start_Condition_Stack.Append (Push); Self.Scanner_State.YY_Start_State := 1 + 2 * Enter; end Push_And_Enter_Start_Condition; -------------------------------------------- -- Push_Current_And_Enter_Start_Condition -- -------------------------------------------- procedure Push_Current_And_Enter_Start_Condition (Self : in out Simple_Reader'Class; Enter : Interfaces.Unsigned_32) is begin Self.Scanner_State.Start_Condition_Stack.Append (Start_Condition (Self)); Self.Scanner_State.YY_Start_State := 1 + 2 * Enter; end Push_Current_And_Enter_Start_Condition; ----------------- -- Push_Entity -- ----------------- function Push_Entity (Self : in out Simple_Reader'Class; Entity : Matreshka.Internals.XML.Entity_Identifier; In_Document_Type : Boolean; In_Literal : Boolean) return Boolean is use type Matreshka.Internals.Strings.Shared_String_Access; use type League.Strings.Universal_String; Source : XML.SAX.Input_Sources.SAX_Input_Source_Access; Text : Matreshka.Internals.Strings.Shared_String_Access; Last_Match : Boolean; Condition : constant Interfaces.Unsigned_32 := Start_Condition (Self); begin -- Resolve entity when necessary. if not Is_Resolved (Self.Entities, Entity) then Callbacks.Call_Resolve_Entity (Self, Entity, Public_Id (Self.Entities, Entity), Enclosing_Base_URI (Self.Entities, Entity), System_Id (Self.Entities, Entity), Source); Text := Matreshka.Internals.Strings.Shared_Empty'Access; Last_Match := False; if not Self.Continue then Self.Error_Message.Prepend ("unable to resolve external entity: "); Callbacks.Call_Fatal_Error (Self, Self.Error_Message); return False; end if; Set_Is_Resolved (Self.Entities, Entity, True); Set_Entity_Base_URI (Self.Entities, Entity, Matreshka.Internals.URI_Utilities.Directory_Name (Source.System_Id)); case Self.Version is when XML_1_0 => Source.Set_Version (League.Strings.To_Universal_String ("1.0")); when XML_1_1 => Source.Set_Version (League.Strings.To_Universal_String ("1.1")); end case; else Source := null; Text := Replacement_Text (Self.Entities, Entity); Last_Match := True; if Text.Unused = 0 then -- Replacement text is empty string, -- [XML 4.4.8] Included as PE -- -- "Just as with external parsed entities, parameter entities need -- only be included if validating. When a parameter-entity -- reference is recognized in the DTD and included, its -- replacement text MUST be enlarged by the attachment of one -- leading and one following space (#x20) character; the intent is -- to constrain the replacement text of parameter entities to -- contain an integral number of grammatical tokens in the DTD. -- This behavior MUST NOT apply to parameter entity references -- within entity values; these are described in 4.4.5 Included in -- Literal." -- -- Set Whitespace_Matched flag, it is used only while processing -- of DTD, so the place where parameter entity declarations are -- allowed. Self.Whitespace_Matched := True; return True; end if; end if; -- [XML 4.4.8] Included as PE -- -- "Just as with external parsed entities, parameter entities need only -- be included if validating. When a parameter-entity reference is -- recognized in the DTD and included, its replacement text MUST be -- enlarged by the attachment of one leading and one following space -- (#x20) character; the intent is to constrain the replacement text of -- parameter entities to contain an integral number of grammatical -- tokens in the DTD. This behavior MUST NOT apply to parameter entity -- references within entity values; these are described in 4.4.5 -- Included in Literal." -- -- Set Whitespace_Matched flag, it is used only while processing of DTD, -- so the place where parameter entity declarations are allowed. Self.Whitespace_Matched := True; Self.Scanner_Stack.Append (Self.Scanner_State); Self.Scanner_State := (Source => Source, Data => Text, Entity => Entity, In_Literal => In_Literal, Delimiter => 0, others => <>); -- Push base URI into the stack. Entity base URI is used for external -- entities; current base URI is used for internal entities. if Entity_Base_URI (Self.Entities, Entity) = Matreshka.Internals.Strings.Shared_Empty'Access then Matreshka.Internals.XML.Base_Scopes.Push_Scope (Self.Bases); else Matreshka.Internals.XML.Base_Scopes.Push_Scope (Self.Bases, League.IRIs.From_Universal_String (League.Strings.Internals.Create (Entity_Base_URI (Self.Entities, Entity)))); end if; if Last_Match then Self.Scanner_State.YY_Current_Position := First_Position (Self.Entities, Entity); Self.Scanner_State.YY_Current_Index := Integer (First_Position (Self.Entities, Entity)) + 1; if In_Document_Type then -- External subset processed after processing of internal subset -- is completed and scanner returns to DOCTYPE_INT start -- condition; but it must be switched back to -- DOCTYPE_INTSUBSET_10 or DOCTYPE_INTSUBSET_11 start condition. case Self.Version is when XML_1_0 => Enter_Start_Condition (Self, DOCTYPE_INTSUBSET_10); when XML_1_1 => Enter_Start_Condition (Self, DOCTYPE_INTSUBSET_11); end case; else if Condition = DOCUMENT_11 and Is_Internal_General_Entity (Self.Entities, Entity) then -- Character references are resolved when replacement text of -- internal general entity is constructed. In XML 1.1 character -- references can refer to restricted characters which is not -- valid in text, but valid in replacement text. Enter_Start_Condition (Self, DOCUMENT_U11); else Enter_Start_Condition (Self, Condition); end if; end if; else -- Reset scanner to INITIAL state to be able to process text -- declaration at the beginning of the external entity. if In_Document_Type then -- External subset processed after processing of internal subset -- is completed and scanner returns to DOCTYPE_INT start -- condition; but it must be switched back to -- DOCTYPE_INTSUBSET_10 or DOCTYPE_INTSUBSET_11 start condition. case Self.Version is when XML_1_0 => Push_And_Enter_Start_Condition (Self, DOCTYPE_INTSUBSET_10, INITIAL); when XML_1_1 => Push_And_Enter_Start_Condition (Self, DOCTYPE_INTSUBSET_11, INITIAL); end case; else Push_And_Enter_Start_Condition (Self, Condition, INITIAL); end if; end if; return True; end Push_Entity; ------------------------------ -- Reset_Whitespace_Matched -- ------------------------------ procedure Reset_Whitespace_Matched (Self : in out Simple_Reader'Class) is begin Self.Whitespace_Matched := False; end Reset_Whitespace_Matched; --------------------------------------- -- Set_Document_Version_And_Encoding -- --------------------------------------- procedure Set_Document_Version_And_Encoding (Self : in out Simple_Reader'Class; Version : XML_Version; Encoding : League.Strings.Universal_String) is Restart : Boolean; Success : Boolean; End_Of_Source : Boolean; begin Pop_Start_Condition (Self); if Self.Version /= Version then -- [XML1.0 2.8] -- -- "Note: When an XML 1.0 processor encounters a document that -- specifies a 1.x version number other than '1.0', it will process -- it as a 1.0 document. This means that an XML 1.0 processor will -- accept 1.x documents provided they do not use any non-1.0 -- features." -- -- [XML1.1 4.3.4] -- -- "Each entity, including the document entity, can be separately -- declared as XML 1.0 or XML 1.1. The version declaration appearing -- in the document entity determines the version of the document as a -- whole. An XML 1.1 document may invoke XML 1.0 external entities, -- so that otherwise duplicated versions of external entities, -- particularly DTD external subsets, need not be maintained. -- However, in such a case the rules of XML 1.1 are applied to the -- entire document." -- -- So, XML version of the document can be declared only once, in the -- XML declaration at the start of the document entity. All other -- occurrences of version declaration in external subset and -- external entities are ignored. This allows to simplify code of -- the version change subprogram. Self.Version := Version; case Self.Version is when XML_1_0 => Enter_Start_Condition (Self, Tables.DOCUMENT_10); when XML_1_1 => Enter_Start_Condition (Self, Tables.DOCUMENT_11); end case; end if; case Self.Version is when XML_1_0 => Self.Scanner_State.Source.Reset (League.Strings.To_Universal_String ("1.0"), Encoding, Restart, Success); when XML_1_1 => Self.Scanner_State.Source.Reset (League.Strings.To_Universal_String ("1.1"), Encoding, Restart, Success); end case; if not Success then Callbacks.Call_Fatal_Error (Self, League.Strings.To_Universal_String ("invalid or unsupported encoding")); elsif Restart then Matreshka.Internals.Strings.Operations.Reset (Self.Scanner_State.Data); Self.Scanner_State.Source.Next (Self.Scanner_State.Data, End_Of_Source); end if; end Set_Document_Version_And_Encoding; ---------------------------- -- Set_Whitespace_Matched -- ---------------------------- procedure Set_Whitespace_Matched (Self : in out Simple_Reader'Class) is begin Self.Whitespace_Matched := True; end Set_Whitespace_Matched; --------------------- -- Start_Condition -- --------------------- function Start_Condition (Self : Simple_Reader'Class) return Interfaces.Unsigned_32 is begin return (Self.Scanner_State.YY_Start_State - 1) / 2; end Start_Condition; ---------------------- -- YY_Move_Backward -- ---------------------- procedure YY_Move_Backward (Self : in out Simple_Reader'Class) is begin Self.Scanner_State.YY_Current_Position := Self.Scanner_State.YY_Current_Position - 1; Self.Scanner_State.YY_Current_Index := Self.Scanner_State.YY_Current_Index - 1; Self.Scanner_State.YY_Current_Column := Self.Scanner_State.YY_Current_Column - 1; end YY_Move_Backward; ------------- -- YY_Text -- ------------- function YY_Text (Self : Simple_Reader'Class; Trim_Left : Natural := 0; Trim_Right : Natural := 0; Trim_Whitespace : Boolean := False) return Matreshka.Internals.Strings.Shared_String_Access is -- Trailing and leading character as well as whitespace characters -- belongs to BMP and don't require expensive UTF-16 decoding. FP : Utf16_String_Index := Self.Scanner_State.YY_Base_Position + Utf16_String_Index (Trim_Left); FI : Positive := Self.Scanner_State.YY_Base_Index + Trim_Left; LP : constant Utf16_String_Index := Self.Scanner_State.YY_Current_Position - Utf16_String_Index (Trim_Right); LI : constant Positive := Self.Scanner_State.YY_Current_Index - Trim_Right; C : Code_Point; begin if Trim_Whitespace then loop C := Code_Point (Self.Scanner_State.Data.Value (FP)); exit when C /= Space and then C /= Character_Tabulation and then C /= Carriage_Return and then C /= Line_Feed; FP := FP + 1; FI := FI + 1; end loop; end if; return Matreshka.Internals.Strings.Operations.Slice (Self.Scanner_State.Data, FP, LP - FP, LI - FI); end YY_Text; ----------- -- YYLex -- ----------- function YYLex (Self : in out Simple_Reader'Class) return Token is use type XML.SAX.Input_Sources.SAX_Input_Source_Access; type YY_End_Of_Buffer_Actions is (YY_Continue_Scan, -- Continue scanning from the current position. -- It is used to continue processing after pop -- up of entity from the scanner's stack. YY_Report_Entity_End, -- Return end of entity mark. YY_Restart_Scan, -- Restart scanning from the base position. YY_Accept_Last_Match, -- Accept last matched action. YY_End_Of_Chunk, -- End of chunk of data is reached. YY_End_Of_Input); -- End of input is reached. YY_Action : Interfaces.Unsigned_32; YY_C : Interfaces.Unsigned_32; YY_Current_State : Interfaces.Unsigned_32; YY_Current_Code : Code_Point; YY_Last_Accepting_Position : Utf16_String_Index; YY_Last_Accepting_Index : Positive; YY_Last_Accepting_State : Interfaces.Unsigned_32; YY_Last_Accepting_Line : Natural; YY_Last_Accepting_Column : Natural; YY_Last_Accepting_Skip_LF : Boolean; YY_Last_Accepting : Boolean; YY_Next_Position : Utf16_String_Index; YY_Next_Index : Positive; YY_Next_Line : Natural; YY_Next_Column : Natural; YY_Next_Skip_LF : Boolean; YY_Last_Match_Position : Utf16_String_Index; YY_Last_Match_Index : Positive; YY_Last_Match_State : Interfaces.Unsigned_32; YY_Last_Match_Line : Natural; YY_Last_Match_Column : Natural; YY_Last_Match_Skip_LF : Boolean; YY_Last_Match : Boolean; YYLVal : YYSType renames Self.YYLVal; YY_Last : Utf16_String_Index; End_Of_Source : Boolean; YY_End_Of_Buffer_Action : YY_End_Of_Buffer_Actions; YY_Position_Offset : Utf16_String_Index; YY_Index_Offset : Natural; YY_Start_Condition : Interfaces.Unsigned_32; Start_Issued : Boolean; function YY_Text_Internal (Trim_Left : Natural := 0; Trim_Right : Natural := 0; Trim_Whitespace : Boolean := False) return Matreshka.Internals.Strings.Shared_String_Access; ---------------------- -- YY_Text_Internal -- ---------------------- function YY_Text_Internal (Trim_Left : Natural := 0; Trim_Right : Natural := 0; Trim_Whitespace : Boolean := False) return Matreshka.Internals.Strings.Shared_String_Access is -- Trailing and leading character as well as whitespace characters -- belongs to BMP and don't require expensive UTF-16 decoding. FP : Utf16_String_Index := Self.Scanner_State.YY_Base_Position + Utf16_String_Index (Trim_Left); FI : Positive := Self.Scanner_State.YY_Base_Index + Trim_Left; LP : constant Utf16_String_Index := Self.Scanner_State.YY_Current_Position - Utf16_String_Index (Trim_Right); LI : constant Positive := Self.Scanner_State.YY_Current_Index - Trim_Right; C : Code_Point; begin if Trim_Whitespace then loop C := Code_Point (Self.Scanner_State.Data.Value (FP)); exit when C /= Space and then C /= Character_Tabulation and then C /= Carriage_Return and then C /= Line_Feed; FP := FP + 1; FI := FI + 1; end loop; end if; return Matreshka.Internals.Strings.Operations.Slice (Self.Scanner_State.Data, FP, LP - FP, LI - FI); end YY_Text_Internal; begin loop -- Loops until end-of-data is reached. Self.Scanner_State.YY_Base_Position := Self.Scanner_State.YY_Current_Position; Self.Scanner_State.YY_Base_Index := Self.Scanner_State.YY_Current_Index; Self.Scanner_State.YY_Base_Line := Self.Scanner_State.YY_Current_Line; Self.Scanner_State.YY_Base_Column := Self.Scanner_State.YY_Current_Column; Self.Scanner_State.YY_Base_Skip_LF := Self.Scanner_State.YY_Current_Skip_LF; YY_Current_State := Self.Scanner_State.YY_Start_State; YY_Last_Match := False; YY_Last_Accepting := False; loop YY_Next_Position := Self.Scanner_State.YY_Current_Position; YY_Next_Index := Self.Scanner_State.YY_Current_Index; YY_Next_Line := Self.Scanner_State.YY_Current_Line; YY_Next_Column := Self.Scanner_State.YY_Current_Column; YY_Next_Skip_LF := Self.Scanner_State.YY_Current_Skip_LF; if YY_Next_Position < Self.Scanner_State.Data.Unused then Unchecked_Next (Self.Scanner_State.Data.Value, YY_Next_Position, YY_Current_Code); YY_Next_Index := YY_Next_Index + 1; -- Track line/column in entity if YY_Current_Code = Carriage_Return then -- Start of new line. YY_Next_Line := YY_Next_Line + 1; YY_Next_Column := 1; YY_Next_Skip_LF := True; elsif YY_Current_Code = Line_Feed then if YY_Next_Skip_LF then -- Ignore CR after LF. YY_Next_Skip_LF := False; else YY_Next_Line := YY_Next_Line + 1; YY_Next_Column := 1; end if; else -- Move to next column. YY_Next_Column := YY_Next_Column + 1; YY_Next_Skip_LF := False; end if; YY_C := YY_EC_Base (YY_Current_Code / 16#100#) (YY_Current_Code mod 16#100#); else -- End of buffer reached. YY_C := 0; -- Aflex uses character with code point zero to mark end of -- buffer character. This character always has YY_EC zero. YY_Last_Match := YY_Last_Accepting; if YY_Last_Accepting then YY_Last_Match_Position := YY_Last_Accepting_Position; YY_Last_Match_Index := YY_Last_Accepting_Index; YY_Last_Match_State := YY_Last_Accepting_State; YY_Last_Match_Line := YY_Last_Accepting_Line; YY_Last_Match_Column := YY_Last_Accepting_Column; YY_Last_Match_Skip_LF := YY_Last_Accepting_Skip_LF; end if; end if; if YY_Accept (YY_Current_State) /= 0 then -- Accepting state reached, save for possible backtrack. YY_Last_Accepting_Position := Self.Scanner_State.YY_Current_Position; YY_Last_Accepting_Index := Self.Scanner_State.YY_Current_Index; YY_Last_Accepting_Line := Self.Scanner_State.YY_Current_Line; YY_Last_Accepting_Column := Self.Scanner_State.YY_Current_Column; YY_Last_Accepting_Skip_LF := Self.Scanner_State.YY_Current_Skip_LF; YY_Last_Accepting_State := YY_Current_State; YY_Last_Accepting := True; end if; while YY_Chk (YY_Base (YY_Current_State) + YY_C) /= YY_Current_State loop YY_Current_State := YY_Def (YY_Current_State); if YY_Current_State >= YY_First_Template then YY_C := YY_Meta (YY_C); end if; end loop; Self.Scanner_State.YY_Current_Position := YY_Next_Position; Self.Scanner_State.YY_Current_Index := YY_Next_Index; Self.Scanner_State.YY_Current_Line := YY_Next_Line; Self.Scanner_State.YY_Current_Column := YY_Next_Column; Self.Scanner_State.YY_Current_Skip_LF := YY_Next_Skip_LF; YY_Current_State := YY_Nxt (YY_Base (YY_Current_State) + YY_C); exit when YY_Base (YY_Current_State) = YY_Jam_Base; end loop; -- Return back to last accepting state. <<Next_Action>> YY_Action := YY_Accept (YY_Current_State); case YY_Action is when 0 => -- must backtrack if YY_Last_Accepting then Self.Scanner_State.YY_Current_Position := YY_Last_Accepting_Position; Self.Scanner_State.YY_Current_Index := YY_Last_Accepting_Index; Self.Scanner_State.YY_Current_Line := YY_Last_Accepting_Line; Self.Scanner_State.YY_Current_Column := YY_Last_Accepting_Column; Self.Scanner_State.YY_Current_Skip_LF := YY_Last_Accepting_Skip_LF; YY_Current_State := YY_Last_Accepting_State; YY_Last_Accepting := False; goto Next_Action; else raise Program_Error; end if; pragma Style_Checks ("M127"); when 1 => -- Open of XML declaration or text declaration, rules [23], [77]. return Actions.On_Open_Of_XML_Or_Text_Declaration (Self); when 2 => -- Any character except literal "<?xml" means there is no XML declaration -- in this document/external parsed entity. Actions.On_No_XML_Declaration (Self); when 3 => -- Open of processing instruction, rule [16]. Rule [17] is implemented -- implicitly by ordering of open of XMLDecl and open of PI. return Actions.On_Open_Of_Processing_Instruction (Self); when 4 => -- Open tag of document type declaration and name of root element, -- rule [28]. return Actions.On_Open_Of_Document_Type_Declaration (Self); when 5 => -- Open of start tag, rule [40], or empty element, rule [44]. return Actions.On_Open_Of_Start_Tag (Self); when 6 => -- Open of end tag, rule [42]. return Actions.On_Open_Of_End_Tag (Self); when 7 => -- Segment of whitespaces. if Actions.On_Whitespace_In_Document (Self) then return Token_String_Segment; end if; when 8 => -- Segment of character data, rule [14]. return Actions.On_Character_Data (Self); when 9 => -- Segment of character data, rule [14]. return Actions.On_Character_Data (Self); when 10 => -- Segment of character data, rule [14]. return Actions.On_Character_Data (Self); when 11 => -- Start of CDATA section, production [19]. return Actions.On_Open_Of_CDATA (Self); when 12 => -- Start of CDATA section, production [19]. return Actions.On_Open_Of_CDATA (Self); when 13 => -- Start of CDATA section, production [19]. return Actions.On_Open_Of_CDATA (Self); when 14 => -- Text data of CDATA section, production [20]. return Actions.On_CDATA (Self); when 15 => -- Text data of CDATA section, production [20]. return Actions.On_CDATA (Self); when 16 => -- Text data of CDATA section, production [20]. return Actions.On_CDATA (Self); when 17 => -- End of CDATA section, production [21]. return Actions.On_Close_Of_CDATA (Self); when 18 => -- End of CDATA section, production [21]. return Actions.On_Close_Of_CDATA (Self); when 19 => -- End of CDATA section, production [21]. return Actions.On_Close_Of_CDATA (Self); when 20 => -- General entity reference rule [68] in document content. declare Aux : constant Token := Actions.On_General_Entity_Reference_In_Document_Content (Self); begin -- By convention, End_Of_Input means that replacement text of the -- referenced entity is empty and it is not pushed into the scanner -- stack. if Aux /= End_Of_Input then return Aux; end if; end; when 21 => -- [24] VersionInfo return Actions.On_Version_Keyword (Self); when 22 => -- [80] EncodingDecl return Actions.On_Encoding_Keyword (Self); when 23 => -- [32] SDDecl return Actions.On_Standalone_Keyword (Self); when 24 => -- Synthetic rule. XMLDECL_ATTRIBUTE_CHAR is a union of characters allowed -- by [26] VersionNum, [81] EncName, [32] SDDecl. Precise check is -- processed while parsing. return Actions.On_Attribute_Value_In_XML_Declaration (Self); when 25 => -- Close of XML declaration (production [23]) or text declaration -- (production [77]). return Actions.On_Close_Of_XML_Or_Text_Declaration (Self); when 26 => -- Close of processing instruction (rule [16]). return Actions.On_Close_Of_Processing_Instruction (Self, True); when 27 => -- Ignore all whitespaces is followed by processing insturction's name, -- rule [16]. Actions.On_Whitespace_In_Processing_Instruction (Self); when 28 => -- Segment of data and close delimiter of the processing instruction, rule -- [16]. return Actions.On_Close_Of_Processing_Instruction (Self, False); when 29 => -- Segment of data and close delimiter of the processing instruction, rule -- [16]. return Actions.On_Close_Of_Processing_Instruction (Self, False); when 30 => -- Keyword SYSTEM, rule [75]. return Actions.On_System_Keyword_In_Document_Type (Self); when 31 => -- System literal, rule [11], used in rule [75]. return Actions.On_System_Literal (Self); when 32 => -- Productions [82], [83] allows absence of system literal in -- notation declaration. Pop_Start_Condition (Self); if Start_Condition (Self) = NOTATION_DECL then Pop_Start_Condition (Self); end if; return Token_Close; when 33 => -- Keyword PUBLIC, rule [75]. Reset_Whitespace_Matched (Self); Push_And_Enter_Start_Condition (Self, DOCTYPE_INT, EXTERNAL_ID_PUB); return Token_Public; when 34 => -- Public id literal, rule [12], used in rule [75]. return Actions.On_Public_Literal (Self); when 35 => -- Open of internal subset declaration, rule [28]. return Actions.On_Open_Of_Internal_Subset (Self); when 36 => -- Close of internal subset declaration, rule [28]. Enter_Start_Condition (Self, DOCTYPE_INT); return Token_Internal_Subset_Close; when 37 => -- Text of comment, rule [15]. Set_String_Internal (Item => YYLVal, String => YY_Text_Internal (4, 3), Is_Whitespace => False); return Token_Comment; when 38 => -- Text of comment, rule [15]. Set_String_Internal (Item => YYLVal, String => YY_Text_Internal (4, 3), Is_Whitespace => False); return Token_Comment; when 39 => -- Parameter entity reference rule [69] in document type declaration. return Actions.On_Parameter_Entity_Reference_In_Document_Declaration (Self); when 40 => -- Open of entity declaration, rules [71], [72]. Enter_Start_Condition (Self, ENTITY_DECL); Reset_Whitespace_Matched (Self); return Token_Entity_Decl_Open; when 41 => -- Open of element declaration and name of the element, rule [45]. return Actions.On_Open_Of_Element_Declaration (Self); when 42 => -- Open of attribute list declaration, rule [52]. return Actions.On_Open_Of_Attribute_List_Declaration (Self); when 43 => -- Open of notation declaration, production [82]. return Actions.On_Open_Of_Notation_Declaration (Self); when 44 => -- Start of conditional section. return Actions.On_Open_Of_Conditional_Section (Self); when 45 => -- Close of conditional section. return Actions.On_Close_Of_Conditional_Section (Self); when 46 => -- Close of notation declaration, production [82]. Pop_Start_Condition (Self); return Token_Close; when 47 => -- Name in entity declaration, rules [71], [72]. return Actions.On_Name_In_Entity_Declaration (Self); when 48 => -- Percent mark in parameter entity declaration, rule [72]. return Actions.On_Percent_Sign (Self); when 49 => -- Entity value, rule [9]. return Actions.On_Entity_Value_Open_Delimiter (Self); when 50 => -- Entity value as ExternalID, rule [75], used by rules [73], [74]. return Actions.On_System_Keyword_In_Entity_Or_Notation (Self); when 51 => -- Entity value as ExternalID, rule [75], used by rules [73], [74]. -- Notation as ExternalID or Public_ID (productions [75], [82], [83]). Reset_Whitespace_Matched (Self); Push_Current_And_Enter_Start_Condition (Self, EXTERNAL_ID_PUB); return Token_Public; when 52 => -- NDATA keyword, rule [76]. return Actions.On_NDATA (Self); when 53 => -- Name of NDATA, rule [76]. return Actions.On_Name_In_Entity_Declaration_Notation (Self); when 54 => Set_String_Internal (Item => YYLVal, String => YY_Text_Internal, Is_Whitespace => False); return Token_String_Segment; when 55 => Set_String_Internal (Item => YYLVal, String => YY_Text_Internal, Is_Whitespace => False); return Token_String_Segment; when 56 => -- Close of entity value, rule [9]. return Actions.On_Entity_Value_Close_Delimiter (Self); when 57 => -- Decimal form of character reference rule [66] in entity value rule [9]; -- or content of element, rule [43]. return Actions.On_Character_Reference (Self, False); when 58 => -- Decimal form of character reference rule [66] in attribute value, -- rule [10]. if not Actions.On_Character_Reference_In_Attribute_Value (Self, False) then return Error; end if; when 59 => -- Hexadecimal form of character reference rule [66] in entity value rule -- [9] or content of element, rule [43]. return Actions.On_Character_Reference (Self, True); when 60 => -- Hexadecimal form of character reference rule [66] in attribute value, -- rule [10]. if not Actions.On_Character_Reference_In_Attribute_Value (Self, True) then return Error; end if; when 61 => -- General entity reference rule [68] in entity value rule [9]. return Actions.On_General_Entity_Reference_In_Entity_Value (Self); when 62 => -- Parameter entity reference rule [69] in entity value rule [9]. -- -- Processing of parameter entity uses separate scanner's state, thus -- after processing current state is restored automatically. This allows -- to reuse code for three modes: parsing of entity value delimited by -- quotation; parsing of entity value delimited by apostrophe; and -- parsing of parameter entity replacement text when it is referenced -- in any of two form of entity value. if not Actions.On_Parameter_Entity_Reference_In_Entity_Value (Self) then return Error; end if; when 63 => -- Name of the element in element declaration. return Actions.On_Name_In_Element_Declaration (Self); when 64 => -- EMPTY keyword, rule [46]. return Token_Empty; when 65 => -- ANY keyword, rule [46]. return Token_Any; when 66 => -- Open parenthesis, rules [49], [50], [51]. return Actions.On_Open_Parenthesis_In_Content_Declaration (Self); when 67 => -- Close parenthesis, rules [49], [50], [51]. return Actions.On_Close_Parenthesis_In_Content_Declaration (Self); when 68 => -- Question mark in rules [47], [48]. return Actions.On_Question_Mark_In_Content_Declaration (Self); when 69 => -- Asterisk in rules [47], [48], [51]. return Actions.On_Asterisk_In_Content_Declaration (Self); when 70 => -- Plus sign in rules [47], [48]. return Actions.On_Plus_In_Content_Declaration (Self); when 71 => -- Vertical bar in rule [49]. return Token_Vertical_Bar; when 72 => -- Comma in rule [50]. return Token_Comma; when 73 => -- #PCDATA in rule [51]. return Token_Pcdata; when 74 => -- Name in element's children declaration, rules [48], [51]. return Actions.On_Name_In_Element_Declaration_Children (Self); when 75 => -- Close token of entity declaration, rules [71], [72]. -- Close of element declaration, rule [45]. -- Close of attribute list declaration, rule [52]. return Actions.On_Close_Of_Declaration (Self); when 76 => -- Element's name in attribute list declaration, rule [52]. return Actions.On_Element_Name_In_Attribute_List_Declaration (Self); when 77 => -- Name of the attribute, rule [53]. return Actions.On_Attribute_Name_In_Attribute_List_Declaration (Self); when 78 => -- CDATA keyword, rule [55]. return Actions.On_Attribute_Type (Self, Token_Cdata); when 79 => -- ID keyword, rule [56]. return Actions.On_Attribute_Type (Self, Token_Id); when 80 => -- IDREF keyword, rule [56]. return Actions.On_Attribute_Type (Self, Token_Idref); when 81 => -- IDREFS keyword, rule [56]. return Actions.On_Attribute_Type (Self, Token_Idrefs); when 82 => -- ENTITY keyword, rule [56]. return Actions.On_Attribute_Type (Self, Token_Entity); when 83 => -- ENTITIES keyword, rule [56]. return Actions.On_Attribute_Type (Self, Token_Entities); when 84 => -- NMTOKEN keyword, rule [56]. return Actions.On_Attribute_Type (Self, Token_Nmtoken); when 85 => -- NMTOKENS keyword, rule [56]. return Actions.On_Attribute_Type (Self, Token_Nmtokens); when 86 => -- NOTATION keyword, rule [58]. return Actions.On_Attribute_Type (Self, Token_Notation); when 87 => -- #REQUIRED keyword, rule [60]. return Actions.On_Default_Declaration (Self, ATTLIST_DECL, Token_Required); when 88 => -- #IMPLIED keyword, rule [60]. return Actions.On_Default_Declaration (Self, ATTLIST_DECL, Token_Implied); when 89 => -- #FIXED keyword, rule [60]. return Actions.On_Default_Declaration (Self, ATTLIST_TYPE, Token_Fixed); when 90 => -- Open parenthesis, rules [58], [59]. return Actions.On_Open_Parenthesis_In_Notation_Attribute (Self); when 91 => -- Close parenthesis, rules [58], [59]. return Actions.On_Close_Parenthesis_In_Notation_Attribute (Self); when 92 => -- Vertical bar, rules [58], [59]. return Token_Vertical_Bar; when 93 => -- Name in the rule [58]. return Actions.On_Name_In_Attribute_List_Declaration_Notation (Self); when 94 => -- Nmtoken in the rule [59]. Set_String_Internal (Item => YYLVal, String => YY_Text_Internal, Is_Whitespace => False); -- XXX Need to add flag to mark Nmtoken. return Token_Name; when 95 => -- Open delimiter of attribute value, rule [10]. if not Actions.On_Attribute_Value_Open_Delimiter (Self, ATTLIST_DECL) then return Error; end if; when 96 => -- Parameter entity reference rule [69] in attribute declaration. -- Parameter entity reference in element's children declaration, [51]. if not Actions.On_Parameter_Entity_Reference_In_Markup_Declaration (Self) then return Error; end if; when 97 => -- All white spaces from rules [28] are ignored. -- Whitespace before name in rule [76] is ignored. null; when 98 => -- IGNORE directive of the conditional section. Actions.On_Conditional_Section_Directive (Self, False); when 99 => -- INCLUDE directive of the conditional section. Actions.On_Conditional_Section_Directive (Self, True); when 100 => -- Start of content of conditional section. if not Actions.On_Open_Of_Conditional_Section_Content (Self) then return Error; end if; when 101 => -- Content of ignore conditional section. It ends with "]]>" or "<![". null; when 102 => -- Content of ignore conditional section. It ends with "]]>" or "<![". null; when 103 => -- White spaces in entity declaration are not optional, rules [71], [72], -- [75], [76]. -- -- White spaces in start tag, rule [40], are ignored, but white space -- between attribute value and name of the next attribute are must be -- present. -- -- All white spaces from rules [23], [24], [25], [32], [80], [82] are -- ignored, but white space between attribute value and name of the -- next attribute are must be present. -- -- Production [45] requires whitespace after the name and before -- content specification. -- -- Productions [47], [48] don't allow spaces before multiplicity -- indicator. Set_Whitespace_Matched (Self); when 104 => -- Name of the attribute, rule [41]. return Actions.On_Name_In_Element_Start_Tag (Self); when 105 => -- Equal sign as attribute's name value delimiter, rule [25] in rules [41], -- [24], [32], [80]. return Token_Equal; when 106 => -- Close of empty element tag, rule [44]. return Actions.On_Close_Of_Empty_Element_Tag (Self); when 107 => -- Close tag of document type declaration, rule [28]. if Actions.On_Close_Of_Document_Type_Declaration (Self) then return Token_Close; end if; when 108 => -- Close of tag, rule [40]. -- Close tag of document type declaration, rule [28]. return Actions.On_Close_Of_Tag (Self); when 109 => -- Open delimiter of attribute value, rule [10]. Actions.On_Attribute_Value_Open_Delimiter (Self, ELEMENT_START); when 110 => -- Close delimiter of attribute value, rule [10]. if Actions.On_Attribute_Value_Close_Delimiter (Self) then return Token_String_Segment; end if; when 111 => -- Value of attribute, rule [10]. Actions.On_Attribute_Value_Character_Data (Self); when 112 => -- Value of attribute, rule [10]. Actions.On_Attribute_Value_Character_Data (Self); when 113 => -- Less-than sign can't be used in the attribute value. return Actions.On_Less_Than_Sign_In_Attribute_Value (Self); when 114 => -- General entity reference rule [68] in attribute value, rule [10]. if not Actions.On_General_Entity_Reference_In_Attribute_Value (Self) then return Error; end if; when 115 => -- Unexpected character. return Actions.On_Unexpected_Character (Self); pragma Style_Checks ("M79"); -- when YY_END_OF_BUFFER + INITIAL + 1 -- => -- return End_Of_Input; -- when YY_End_Of_Buffer => if Self.Scanner_State.Source /= null then -- Input source is used to retrieve data. if Is_Document_Entity (Self.Entities, Self.Scanner_State.Entity) and Self.Scanner_State.YY_Base_Position /= 0 then -- For document entity, remove already scanned data. -- Construct slice only when we actually need to move -- data. Matreshka.Internals.Strings.Operations.Slice (Self.Scanner_State.Data, Self.Scanner_State.YY_Base_Position, Self.Scanner_State.Data.Unused - Self.Scanner_State.YY_Base_Position, Self.Scanner_State.Data.Length - Self.Scanner_State.YY_Base_Index + 1); YY_Position_Offset := Self.Scanner_State.YY_Base_Position; YY_Index_Offset := Self.Scanner_State.YY_Base_Index - 1; Self.Scanner_State.YY_Base_Position := Self.Scanner_State.YY_Base_Position - YY_Position_Offset; Self.Scanner_State.YY_Base_Index := Self.Scanner_State.YY_Base_Index - YY_Index_Offset; Self.Scanner_State.YY_Current_Position := Self.Scanner_State.YY_Current_Position - YY_Position_Offset; Self.Scanner_State.YY_Current_Index := Self.Scanner_State.YY_Current_Index - YY_Index_Offset; if YY_Last_Match then YY_Last_Match_Position := YY_Last_Match_Position - YY_Position_Offset; YY_Last_Match_Index := YY_Last_Match_Index - YY_Index_Offset; end if; end if; -- Obtain next portion of data from the input source. YY_Last := Self.Scanner_State.Data.Unused; Self.Scanner_State.Source.Next (Self.Scanner_State.Data, End_Of_Source); YY_End_Of_Buffer_Action := YY_Restart_Scan; if YY_Last = Self.Scanner_State.Data.Unused then -- There is no new data retrieved, handle end of source -- state. It is possible to not reach end of source and -- retrieve no new data at the same time, for example -- when source data is mailformed and decoder unable to -- convert data. The same situtation is possible when -- some kind of filter is inserted between input source -- and actual stream (SSL/TLS encription, for example). if End_Of_Source then -- Replacement text of the entity is loaded from input -- source and need to be stored in the entities table, -- except replacement text of the document entity. -- Input source can be deallocated. if not Is_Document_Entity (Self.Entities, Self.Scanner_State.Entity) then Set_Replacement_Text (Self.Entities, Self.Scanner_State.Entity, Self.Scanner_State.Data); Free (Self.Scanner_State.Source); -- XXX Input source should not be deallocated, it -- can be needed later to reread entity when XML -- version (document entity only) or encoding is -- changed. else Self.Scanner_State.Source := null; -- Input source of document entity is managed by -- application. end if; elsif Self.Scanner_State.Incremental then YY_End_Of_Buffer_Action := YY_End_Of_Chunk; end if; end if; else -- Input source is not used, complete replacement text of -- the entity is in the scanner's buffer. This covers two -- cases: (1) entity is internal or predefined entity, and -- (2) text of the entity is loaded completely. if Self.Scanner_State.Data.Unused /= Self.Scanner_State.YY_Base_Position then -- Continue processing till end of buffer will be -- reached. YY_End_Of_Buffer_Action := YY_Accept_Last_Match; else -- Replacement text of the entity is completely scanned, -- pop scanner's entity stack. When scanner's stack is -- empty returns End_Of_Input token. if not Self.Scanner_Stack.Is_Empty then if Is_Parameter_Entity (Self.Entities, Self.Scanner_State.Entity) then -- For parameter entities start condition need to -- be propagated to previous state, otherwise -- scanner can start from the wrong condition. -- For non-parameter entities it is not needed, -- because their processing doesn't use stack of -- start conditions. YY_Start_Condition := Start_Condition (Self); -- Save flag whether or not Token_Entity_Start was -- issued. Start_Issued := Self.Scanner_State.Start_Issued; -- When entity's replacement text is empty and -- there are no text declaration, then scanner is -- in the initial state and actual state must be -- retrieved from the state stack. if YY_Start_Condition = INITIAL then Pop_Start_Condition (Self); YY_Start_Condition := Start_Condition (Self); end if; Free (Self.Scanner_State.Source); Self.Scanner_State := Self.Scanner_Stack.Last_Element; Self.Scanner_Stack.Delete_Last; Pop_Scope (Self.Bases); Enter_Start_Condition (Self, YY_Start_Condition); -- [XML 4.4.8] Included as PE -- -- "Just as with external parsed entities, -- parameter entities need only be included if -- validating. When a parameter-entity reference is -- recognized in the DTD and included, its -- replacement text MUST be enlarged by the -- attachment of one leading and one following -- space (#x20) character; the intent is to -- constrain the replacement text of parameter -- entities to contain an integral number of -- grammatical tokens in the DTD. This behavior -- MUST NOT apply to parameter entity references -- within entity values; these are described in -- 4.4.5 Included in Literal." -- -- Set Whitespace_Matched flag, it is used only -- while processing of DTD, so the place where -- parameter entity declarations are allowed. Self.Whitespace_Matched := True; -- [XML WFC: PE Between Declarations] -- -- "The replacement text of a parameter entity -- reference in a DeclSep MUST match the production -- extSubsetDecl." -- -- To check this constraint special rule is added -- in parser. To pass this rule Token_Entity_End -- must be returned when handling of parameter -- entity reference between markup declaration is -- completed. if Start_Issued then YY_End_Of_Buffer_Action := YY_Report_Entity_End; else YY_End_Of_Buffer_Action := YY_Continue_Scan; end if; elsif Self.In_Document_Content and not Self.Scanner_State.In_Literal then -- For entity references in the document content -- we need to track start/end of entity. Free (Self.Scanner_State.Source); Self.Scanner_State := Self.Scanner_Stack.Last_Element; Self.Scanner_Stack.Delete_Last; Pop_Scope (Self.Bases); YY_End_Of_Buffer_Action := YY_Report_Entity_End; else Free (Self.Scanner_State.Source); Self.Scanner_State := Self.Scanner_Stack.Last_Element; Self.Scanner_Stack.Delete_Last; Pop_Scope (Self.Bases); YY_End_Of_Buffer_Action := YY_Continue_Scan; end if; else YY_End_Of_Buffer_Action := YY_End_Of_Input; end if; end if; end if; case YY_End_Of_Buffer_Action is when YY_Continue_Scan => null; when YY_Report_Entity_End => return Token_Entity_End; when YY_Restart_Scan | YY_End_Of_Chunk => -- Back current position to base position. Self.Scanner_State.YY_Current_Position := Self.Scanner_State.YY_Base_Position; Self.Scanner_State.YY_Current_Index := Self.Scanner_State.YY_Base_Index; Self.Scanner_State.YY_Current_Line := Self.Scanner_State.YY_Base_Line; Self.Scanner_State.YY_Current_Column := Self.Scanner_State.YY_Base_Column; Self.Scanner_State.YY_Current_Skip_LF := Self.Scanner_State.YY_Base_Skip_LF; if YY_End_Of_Buffer_Action = YY_End_Of_Chunk then return End_Of_Chunk; end if; when YY_Accept_Last_Match => -- Replace current position to last matched position and -- process matched action. -- XXX: Other cases handle line/column numbers and -- "skip LF" flag also, should they be handled here? if YY_Last_Match then Self.Scanner_State.YY_Current_Position := YY_Last_Match_Position; Self.Scanner_State.YY_Current_Index := YY_Last_Match_Index; Self.Scanner_State.YY_Current_Line := YY_Last_Match_Line; Self.Scanner_State.YY_Current_Column := YY_Last_Match_Column; Self.Scanner_State.YY_Current_Skip_LF := YY_Last_Match_Skip_LF; YY_Current_State := YY_Last_Match_State; YY_Last_Match := False; else raise Program_Error; end if; goto Next_Action; when YY_End_Of_Input => return End_Of_Input; end case; when others => raise Program_Error with "Unhandled action" & Interfaces.Unsigned_32'Image (YY_Action) & " in scanner"; end case; end loop; -- end of loop waiting for end of file end YYLex; end XML.SAX.Simple_Readers.Scanner;
reznikmm/coroutines
Ada
669
ads
-- Copyright (c) 2019 Maxim Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with System.Storage_Elements; with GNAT.Sockets; package TCP_Servers is type TCP_Coroutine is access procedure (Socket : GNAT.Sockets.Socket_Type); procedure Listen_Port (Port : GNAT.Sockets.Port_Type; Run : not null TCP_Coroutine; Stack : System.Storage_Elements.Storage_Count); -- Start new coroutine, that will listen given Port and start Run coroutine -- on each connect. Use given Stack size for both kinds of coroutines. end TCP_Servers;
sungyeon/drake
Ada
2,288
ads
pragma License (Unrestricted); -- Ada 2012 package Ada.Strings.UTF_Encoding.Conversions is pragma Pure; -- Conversions between various encoding schemes function Convert ( Item : UTF_String; Input_Scheme : Encoding_Scheme; Output_Scheme : Encoding_Scheme; Output_BOM : Boolean := False) return UTF_String; -- function from binary to 8 is missing, use from binary to binary function Convert ( Item : UTF_String; Input_Scheme : Encoding_Scheme; Output_BOM : Boolean := False) return UTF_16_Wide_String; -- extended -- This function convets from binary to 32. function Convert ( Item : UTF_String; Input_Scheme : Encoding_Scheme; Output_BOM : Boolean := False) return UTF_32_Wide_Wide_String; -- function from 8 to binary is missing, use from binary to binary function Convert ( Item : UTF_8_String; Output_BOM : Boolean := False) return UTF_16_Wide_String; -- extended -- This function convets from 8 to 32. function Convert ( Item : UTF_8_String; Output_BOM : Boolean := False) return UTF_32_Wide_Wide_String; function Convert ( Item : UTF_16_Wide_String; Output_Scheme : Encoding_Scheme; Output_BOM : Boolean := False) return UTF_String; function Convert ( Item : UTF_16_Wide_String; Output_BOM : Boolean := False) return UTF_8_String; -- extended -- This function convets from 16 to 32. function Convert ( Item : UTF_16_Wide_String; Output_BOM : Boolean := False) return UTF_32_Wide_Wide_String; -- extended -- This function convets from 32 to binary. function Convert ( Item : UTF_32_Wide_Wide_String; Output_Scheme : Encoding_Scheme; Output_BOM : Boolean := False) return UTF_String; -- extended -- This function convets from 32 to 8. function Convert ( Item : UTF_32_Wide_Wide_String; Output_BOM : Boolean := False) return UTF_8_String; -- extended -- This function convets from 32 to 16. function Convert ( Item : UTF_32_Wide_Wide_String; Output_BOM : Boolean := False) return UTF_16_Wide_String; end Ada.Strings.UTF_Encoding.Conversions;
burratoo/Acton
Ada
4,136
adb
------------------------------------------------------------------------------------------ -- -- -- OAK PROJECT SUPPORT PACKAGE -- -- ST STM32F4 -- -- -- -- OAK.PROJECT_SUPPORT_PACKAGE.MICROCONTROLLER -- -- -- -- Copyright (C) 2014-2021, Patrick Bernardi -- -- -- ------------------------------------------------------------------------------------------ with ST; use ST; with ST.STM32F4; use ST.STM32F4; with ST.STM32F4.Flash; use ST.STM32F4.Flash; with ST.STM32F4.RCC; use ST.STM32F4.RCC; package body Oak.Project_Support_Package.Microcontroller is procedure Setup_Clocks; procedure Setup is begin Setup_Clocks; end Setup; procedure Setup_Clocks is begin -- Enable Power Interface RCC.APB1_Peripheral_Clock_Enable_Register := (Power_Interface => Enable, others => Disable); -- Enable high-speed internal clock. Used as fall back if PLL for the -- high-speed external clock fails. RCC.Clock_Control_Register.High_Speed_Internal_Clock := Enable; loop exit when RCC.Clock_Control_Register.High_Speed_Internal_Clock_Ready; end loop; -- Enable high-speed external clock RCC.Clock_Control_Register.High_Speed_External_Clock := Enable; loop exit when RCC.Clock_Control_Register.High_Speed_External_Clock_Ready; end loop; -- Setup low-speed internal clock RCC.Clock_Control_And_Status_Register.Low_Speed_Internal_Clock := Enable; loop exit when RCC.Clock_Control_And_Status_Register. Low_Speed_Internal_Clock_Ready; end loop; -- Setup the PLL used by the high-speed external clock -- Set for a 168MHz clock using an external 8MHz crystal RCC.PLL_Configuration_Register := (Peripheral_Clock_Divider => 7, Clock_Source => High_Speed_External_Clock, System_Clock_Divider => Divide_By_2, VCO_Multiplier => 336, Input_Clock_Divider => 8); RCC.Clock_Control_Register.PLL_Main := Enable; loop exit when RCC.Clock_Control_Register.PLL_Main_Locked; end loop; -- Configure flash states before attempting to use the PLL as the system -- clock, otherwise access to the flash will be lost. Flash.Access_Control_Register := (Data_Cache => Enable, Instruction_Cache => Enable, Prefetch => Enable, Wait_States => 5, others => Do_Not_Reset); -- Setup derived clocks for similar reason RCC.Clock_Configuration_Register := (Microcontroller_Clock_Output_2 => System_Clock, Microcontroller_Clock_Output_2_Prescaler => Divide_By_5, Microcontroller_Clock_Output_1_Prescaler => No_Division, I2S_Clock_Selection => PLL_I2S, Microcontroller_Clock_Output_1 => High_Speed_Internal_Clock, HSE_Clock_Divider_For_RTC => 0, APB1_Prescaler => Divide_By_2, APB2_Prescaler => Divide_By_4, AHB_Prescaler => No_Division, System_Clock_Status => PLL, -- not written System_Clock_Source => PLL); loop exit when RCC.Clock_Configuration_Register.System_Clock_Status = PLL; end loop; end Setup_Clocks; end Oak.Project_Support_Package.Microcontroller;
reznikmm/matreshka
Ada
3,649
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.Elements; package ODF.DOM.Anim_Param_Elements is pragma Preelaborate; type ODF_Anim_Param is limited interface and XML.DOM.Elements.DOM_Element; type ODF_Anim_Param_Access is access all ODF_Anim_Param'Class with Storage_Size => 0; end ODF.DOM.Anim_Param_Elements;
XMoose25X/Advanced-Dungeon-Assault
Ada
7,531
adb
with Ada.Text_IO, Ada.Integer_Text_IO, display; use Ada.Text_IO, Ada.Integer_Text_IO, display; procedure spritemaker is procedure showFile(Filename : String) is File : File_Type; begin Open(File, In_File, Filename); while(not End_Of_File(File)) loop Put(Get_Line(File => File)); new_line; end loop; Close(File); end showFile; function LoadSpriteNoFormat(FileName : String) return SpriteType is File : File_Type; width : Integer; height : Integer; sprite : SpriteType; line: String(1..128); color : colorType := colorDefault; offset : Positive := 1; begin --clear garbage data width := 127; height := 63; For Y in Integer range 0..height loop For X in Integer range 0..width loop sprite.Image(X,Y).char := ' '; sprite.color := colorDefault; end loop; end loop; --load sprite Open(File, In_File, FileName); Get(File => File, Item => width); Get(File => File, Item => height); sprite.Width := width; sprite.Height := height; Skip_Line(File); For Y in Integer range 0..height-1 loop Get_Line(File => File, Item => line, Last => width); Width := Width - 1; offset := 1; For X in Integer range 0..width loop sprite.Image(X,Y).char := line(X+offset); sprite.Image(X,Y).color := colorDefault; put(line(X+offset)); end loop; --Put(" <EOL> "); new_line; end loop; Close(File); Return sprite; end LoadSpriteNoFormat; procedure saveSprite(sprite : SpriteType; FileName : String) is File : File_Type; width : Natural := sprite.width; height : Natural := sprite.height; begin Create(File, Out_File, FileName); Put(File => File, Item => sprite.width , Width => 0); Put(File => File, Item => " "); Put(File => File, Item => sprite.height, Width => 0); New_Line(File); For Y in Integer range 0..height loop For X in Integer range 0..width loop Put(File => File, Item => sprite.Image(X,Y).color); Put(File => File, Item => sprite.Image(X,Y).char); end loop; New_Line(File); end loop; Close(File); end saveSprite; --paint tools procedure boxFill (X,Y,W,H : Integer) is begin null;--do stuff end; procedure paintFill (sprite : in out SpriteType; color : colorType) is begin for Y in 0..sprite.Width loop For X in 0..sprite.Height loop begin sprite.image(Y,X).color := color; exception when others => null; end; end loop; end loop; end paintFill; --handle cursor input input : Character; cursorX, cursorY : Integer; stickey : Boolean := False; function cursorInput(wrap : Boolean) return Boolean is begin if(input = character'val(68)) then--left cursorX := cursorX - 1; elsif (input = character'val(67)) then--right cursorX := cursorX + 1; elsif (input = character'val(65)) then--up cursorY := cursorY - 1; elsif (input = character'val(66)) then--down cursorY := cursorY + 1; else return False; end if; --wrap if(wrap = True) then if(cursorX < 0) then cursorX := Screen_Width; elsif (cursorX > Screen_Width) then cursorX := 0; elsif (cursorY < 0) then cursorY := Screen_Height; elsif (cursorY > Screen_Height) then cursorY := 0; end if; else --limit if(cursorX < 0) then cursorX := 0; elsif (cursorX > Screen_Width) then cursorX := Screen_Width; elsif (cursorY < 0) then cursorY := 0; elsif (cursorY > Screen_Height) then cursorY := Screen_Height; end if; end if; return True; end; --display functions currentChar : character := ' '; currentCol : colorType := colorDefault; procedure ShowCommands is posX : Integer := Screen_Width-14; posY : Integer := 2; begin for I in 0..Screen_Height loop setPixel(posX-02,I,character'val(186), colorDefault); setPixel(posX+14,I,character'val(186), colorDefault); end loop; SetText(posX, posY+00, "Color ", currentCol); SetText(posX, posY+02, "Black : 0"); SetText(posX, posY+03, "Red : 1"); SetText(posX, posY+04, "Green : 2"); SetText(posX, posY+05, "Yellow : 3"); SetText(posX, posY+06, "Blue : 4"); SetText(posX, posY+07, "Magenta : 5"); SetText(posX, posY+08, "Cyan : 6"); SetText(posX, posY+09, "White : 7"); SetText(posX, posY+10, "Shade : 8"); SetText(posX, posY+11, "Invert : 9"); SetText(posX, posY+12, "Set : Space"); SetText(posX, posY+13, "Auto : S"); SetText(posX, posY+14, "Fill : F"); --SetText(posX, posY+15, "\Box Fill: B"); SetText(posX, posY+20, "Save : -"); SetText(posX, posY+21, "Quit : Q"); end ShowCommands; line : String(1..250); len : Natural; editSprite : SpriteType; useBox : Boolean := False; boxStartX : Integer := 0; boxStartY : Integer := 0; begin put(ASCII.ESC & "[?25l"); -- cursor off (?25h for on) cursorX := 0; cursorY := 0; Initialize(140,50); --primary menu loop WipeScreen; setText(4, 12, "What would you like to load?"); setText(6, 14, "1 - Unformatted sprite"); setText(6, 15, "2 - Existing Sprite file"); refresh; get_immediate(input); exit when input = '1'; exit when input = '2'; end loop; loop Put("Enter File to load"); new_line; Get_Line(Item => line, Last => len); Put("Loading " & line(1..len)); new_line; begin--exception if(input = '1') then editSprite := LoadSpriteNoFormat(line(1..len)); Put("----"); exit; elsif(input = '2') then editSprite := LoadSprite(line(1..len)); Put("----"); end if; exit; exception when others => Put("File does not exist or the file format is incorrect."); end; end loop; Put(ASCII.ESC & "[2J"); loop--editor main Get_Immediate(input); exit when input = 'q'; if(input = '-') then Put("Save as : "); new_line; Get_Line(Item => line, Last => len); saveSprite(editSprite, line(1..len)); exit; end if; if(cursorInput(True) and stickey = True) then if(cursorX >= 0 and cursorX <= editSprite.Width and cursorY >= 0 and cursorY <= editSprite.Height) then editSprite.image(cursorX,cursorY).color := currentCol; end if; end if; if (input = '0') then currentCol(9) := '0'; elsif (input = '1') then currentCol(9) := '1'; elsif (input = '2') then currentCol(9) := '2'; elsif (input = '3') then currentCol(9) := '3'; elsif (input = '4') then currentCol(9) := '4'; elsif (input = '5') then currentCol(9) := '5'; elsif (input = '6') then currentCol(9) := '6'; elsif (input = '7') then currentCol(9) := '7'; elsif (input = '8') then if(currentCol(3) = '0') then currentCol(3) := '1'; else currentCol(3) := '0'; end if; elsif (input = '9') then if(currentCol(5) = '2') then currentCol(5) := '0'; else currentCol(5) := '2'; end if; end if; if(input = 's') then stickey := not stickey; end if; if(input = ' ') then editSprite.image(cursorX,cursorY).color := currentCol; end if; --fill if(input = 'f') then paintFill(editSprite, currentCol); end if; clearDisplay; setSprite(0,0,editSprite); --setText(0,0, Integer'Image(character'pos(input)), colorDefault); if(screen(cursorX,CursorY).color(5) = '2') then screen(cursorX,CursorY).color(5) := '0'; else screen(cursorX,CursorY).color(5) := '2'; end if; --setPixel(cursorX, cursorY, character'val(200), colorDefault); ShowCommands; refresh; end loop;--main --quit commands put(ASCII.ESC & "[?25h"); end spritemaker;
Fabien-Chouteau/shoot-n-loot
Ada
98,257
ads
with GESTE; pragma Style_Checks (Off); package Game_Assets.Tileset_Collisions is Tiles : aliased constant GESTE.Tile_Collisions_Array := ( 1 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 2 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 3 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 4 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 5 => ((True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True)), 6 => ((True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True)), 7 => ((True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True)), 8 => ((True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True)), 9 => ((True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True)), 10 => ((True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True)), 11 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 12 => ((True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True)), 13 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 14 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 15 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 16 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 17 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 18 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 19 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 20 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 21 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 22 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 23 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 24 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 25 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 26 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 27 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 28 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 29 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 30 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 31 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 32 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 33 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 34 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 35 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 36 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 37 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 38 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 39 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 40 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 41 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 42 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 43 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 44 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 45 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 46 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 47 => ((True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True)), 48 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 49 => ((True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True)), 50 => ((True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True)), 51 => ((True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True)), 52 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 53 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 54 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 55 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 56 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 57 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 58 => ((True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True)), 59 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 60 => ((True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True)), 61 => ((True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True)), 62 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 63 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 64 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 65 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 66 => ((True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True)), 67 => ((True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True)), 68 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 69 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 70 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 71 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 72 => ((True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True)), 73 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 74 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 75 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 76 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 77 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 78 => ((True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True)), 79 => ((True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True)), 80 => ((True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True)), 81 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 82 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 83 => ((True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True)), 84 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 85 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 86 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 87 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 88 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 89 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 90 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 91 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 92 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 93 => ((True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True)), 94 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 95 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 96 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 97 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 98 => ((True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True)), 99 => ((True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True), (True,True,True,True,True,True,True,True)), 100 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 101 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 102 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 103 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 104 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 105 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 106 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 107 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 108 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 109 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 110 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 111 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 112 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 113 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 114 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 115 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 116 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 117 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 118 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 119 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 120 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 121 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 122 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 123 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 124 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 125 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 126 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 127 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 128 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 129 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 130 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 131 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 132 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 133 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 134 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 135 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 136 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 137 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 138 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 139 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 140 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 141 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 142 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 143 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 144 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 145 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 146 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 147 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 148 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 149 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 150 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 151 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 152 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 153 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 154 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 155 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 156 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 157 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 158 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 159 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 160 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 161 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 162 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 163 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 164 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 165 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 166 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 167 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 168 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 169 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 170 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 171 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 172 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 173 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 174 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 175 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 176 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 177 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 178 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 179 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 180 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 181 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 182 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 183 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 184 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 185 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 186 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 187 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 188 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 189 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 190 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 191 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 192 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 193 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False)), 194 => ((False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False), (False,False,False,False,False,False,False,False))); end Game_Assets.Tileset_Collisions;
reznikmm/matreshka
Ada
11,869
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 AMF.Internals.UML_Named_Elements; with AMF.UML.Dependencies.Collections; with AMF.UML.General_Orderings.Collections; with AMF.UML.Interaction_Operands; with AMF.UML.Interactions; with AMF.UML.Lifelines.Collections; with AMF.UML.Message_Occurrence_Specifications; with AMF.UML.Messages; with AMF.UML.Named_Elements; with AMF.UML.Namespaces; with AMF.UML.Packages.Collections; with AMF.UML.String_Expressions; with AMF.Visitors; package AMF.Internals.UML_Message_Occurrence_Specifications is type UML_Message_Occurrence_Specification_Proxy is limited new AMF.Internals.UML_Named_Elements.UML_Named_Element_Proxy and AMF.UML.Message_Occurrence_Specifications.UML_Message_Occurrence_Specification with null record; overriding function Get_Message (Self : not null access constant UML_Message_Occurrence_Specification_Proxy) return AMF.UML.Messages.UML_Message_Access; -- Getter of MessageEnd::message. -- -- References a Message. overriding procedure Set_Message (Self : not null access UML_Message_Occurrence_Specification_Proxy; To : AMF.UML.Messages.UML_Message_Access); -- Setter of MessageEnd::message. -- -- References a Message. overriding function Get_Client_Dependency (Self : not null access constant UML_Message_Occurrence_Specification_Proxy) return AMF.UML.Dependencies.Collections.Set_Of_UML_Dependency; -- Getter of NamedElement::clientDependency. -- -- Indicates the dependencies that reference the client. overriding function Get_Name_Expression (Self : not null access constant UML_Message_Occurrence_Specification_Proxy) return AMF.UML.String_Expressions.UML_String_Expression_Access; -- Getter of NamedElement::nameExpression. -- -- The string expression used to define the name of this named element. overriding procedure Set_Name_Expression (Self : not null access UML_Message_Occurrence_Specification_Proxy; To : AMF.UML.String_Expressions.UML_String_Expression_Access); -- Setter of NamedElement::nameExpression. -- -- The string expression used to define the name of this named element. overriding function Get_Namespace (Self : not null access constant UML_Message_Occurrence_Specification_Proxy) return AMF.UML.Namespaces.UML_Namespace_Access; -- Getter of NamedElement::namespace. -- -- Specifies the namespace that owns the NamedElement. overriding function Get_Qualified_Name (Self : not null access constant UML_Message_Occurrence_Specification_Proxy) return AMF.Optional_String; -- Getter of NamedElement::qualifiedName. -- -- A name which allows the NamedElement to be identified within a -- hierarchy of nested Namespaces. It is constructed from the names of the -- containing namespaces starting at the root of the hierarchy and ending -- with the name of the NamedElement itself. overriding function Get_Covered (Self : not null access constant UML_Message_Occurrence_Specification_Proxy) return AMF.UML.Lifelines.UML_Lifeline_Access; -- Getter of OccurrenceSpecification::covered. -- -- References the Lifeline on which the OccurrenceSpecification appears. overriding procedure Set_Covered (Self : not null access UML_Message_Occurrence_Specification_Proxy; To : AMF.UML.Lifelines.UML_Lifeline_Access); -- Setter of OccurrenceSpecification::covered. -- -- References the Lifeline on which the OccurrenceSpecification appears. overriding function Get_To_After (Self : not null access constant UML_Message_Occurrence_Specification_Proxy) return AMF.UML.General_Orderings.Collections.Set_Of_UML_General_Ordering; -- Getter of OccurrenceSpecification::toAfter. -- -- References the GeneralOrderings that specify EventOcurrences that must -- occur after this OccurrenceSpecification overriding function Get_To_Before (Self : not null access constant UML_Message_Occurrence_Specification_Proxy) return AMF.UML.General_Orderings.Collections.Set_Of_UML_General_Ordering; -- Getter of OccurrenceSpecification::toBefore. -- -- References the GeneralOrderings that specify EventOcurrences that must -- occur before this OccurrenceSpecification overriding function Get_Covered (Self : not null access constant UML_Message_Occurrence_Specification_Proxy) return AMF.UML.Lifelines.Collections.Set_Of_UML_Lifeline; -- Getter of InteractionFragment::covered. -- -- References the Lifelines that the InteractionFragment involves. overriding function Get_Enclosing_Interaction (Self : not null access constant UML_Message_Occurrence_Specification_Proxy) return AMF.UML.Interactions.UML_Interaction_Access; -- Getter of InteractionFragment::enclosingInteraction. -- -- The Interaction enclosing this InteractionFragment. overriding procedure Set_Enclosing_Interaction (Self : not null access UML_Message_Occurrence_Specification_Proxy; To : AMF.UML.Interactions.UML_Interaction_Access); -- Setter of InteractionFragment::enclosingInteraction. -- -- The Interaction enclosing this InteractionFragment. overriding function Get_Enclosing_Operand (Self : not null access constant UML_Message_Occurrence_Specification_Proxy) return AMF.UML.Interaction_Operands.UML_Interaction_Operand_Access; -- Getter of InteractionFragment::enclosingOperand. -- -- The operand enclosing this InteractionFragment (they may nest -- recursively) overriding procedure Set_Enclosing_Operand (Self : not null access UML_Message_Occurrence_Specification_Proxy; To : AMF.UML.Interaction_Operands.UML_Interaction_Operand_Access); -- Setter of InteractionFragment::enclosingOperand. -- -- The operand enclosing this InteractionFragment (they may nest -- recursively) overriding function Get_General_Ordering (Self : not null access constant UML_Message_Occurrence_Specification_Proxy) return AMF.UML.General_Orderings.Collections.Set_Of_UML_General_Ordering; -- Getter of InteractionFragment::generalOrdering. -- -- The general ordering relationships contained in this fragment. overriding function All_Owning_Packages (Self : not null access constant UML_Message_Occurrence_Specification_Proxy) return AMF.UML.Packages.Collections.Set_Of_UML_Package; -- Operation NamedElement::allOwningPackages. -- -- The query allOwningPackages() returns all the directly or indirectly -- owning packages. overriding function Is_Distinguishable_From (Self : not null access constant UML_Message_Occurrence_Specification_Proxy; N : AMF.UML.Named_Elements.UML_Named_Element_Access; Ns : AMF.UML.Namespaces.UML_Namespace_Access) return Boolean; -- Operation NamedElement::isDistinguishableFrom. -- -- The query isDistinguishableFrom() determines whether two NamedElements -- may logically co-exist within a Namespace. By default, two named -- elements are distinguishable if (a) they have unrelated types or (b) -- they have related types but different names. overriding function Namespace (Self : not null access constant UML_Message_Occurrence_Specification_Proxy) return AMF.UML.Namespaces.UML_Namespace_Access; -- Operation NamedElement::namespace. -- -- Missing derivation for NamedElement::/namespace : Namespace overriding procedure Enter_Element (Self : not null access constant UML_Message_Occurrence_Specification_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); -- Dispatch call to corresponding subprogram of visitor interface. overriding procedure Leave_Element (Self : not null access constant UML_Message_Occurrence_Specification_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); -- Dispatch call to corresponding subprogram of visitor interface. overriding procedure Visit_Element (Self : not null access constant UML_Message_Occurrence_Specification_Proxy; Iterator : in out AMF.Visitors.Abstract_Iterator'Class; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); -- Dispatch call to corresponding subprogram of iterator interface. end AMF.Internals.UML_Message_Occurrence_Specifications;
jrcarter/Ada_GUI
Ada
13,506
adb
-- -- -- package Tables Copyright (c) Dmitry A. Kazakov -- -- Implementation Luebeck -- -- Spring, 2000 -- -- -- -- Last revision : 13:11 14 Sep 2019 -- -- -- -- This library 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 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. See the GNU -- -- General Public License for more details. You should have -- -- received a copy of the GNU General Public License along with -- -- this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- -- As a special exception, if other files instantiate generics from -- -- this unit, or you link this unit with other files to produce an -- -- executable, this unit does not by itself cause the resulting -- -- executable to be covered by the GNU General Public License. This -- -- exception does not however invalidate any other reasons why the -- -- executable file might be covered by the GNU Public License. -- --____________________________________________________________________-- with Ada.IO_Exceptions; use Ada.IO_Exceptions; with Ada.Unchecked_Deallocation; package body Tables is Increment : constant := 256; procedure Free is new Ada.Unchecked_Deallocation (Token, TokenPtr); procedure Free is new Ada.Unchecked_Deallocation (TokenList, TokenListPtr); function Search ( Folder : Table; Name : String ) return Integer is function Compare (Item : String) return Equality; pragma Inline (Compare); function Compare (Item : String) return Equality is Index1 : Integer := Name'First; Index2 : Integer := Item'First; Symbol1 : Character; Symbol2 : Character; begin loop if Index1 > Name'Last then if Index2 > Item'Last then return Equal; else return Less; end if; elsif Index2 > Item'Last then return Greater; end if; Symbol1 := Name (Index1); Symbol2 := Item (Index2); if Symbol1 /= Symbol2 then if Symbol1 > Symbol2 then return Greater; else return Less; end if; end if; Index1 := Index1 + 1; Index2 := Index2 + 1; end loop; end Compare; Low : Integer := 0; High : Integer := Folder.Size + 1; This : Integer; begin if High = 1 then return -1; end if; loop This := (Low + High) / 2; case Compare (Folder.List (This).Name) is when Less => High := This; if High - Low = 1 then return -This; end if; when Equal => return This; when Greater => Low := This; if High - Low = 1 then return -(This + 1); end if; end case; end loop; end Search; procedure Insert ( Folder : in out Table; Place : Positive; Name : String; Data : Tag ) is List : TokenListPtr; Item : constant TokenPtr := new Token'(Name'Length, Data, Name); begin if Folder.List = null then Folder.List := new TokenList (1..Increment); Folder.Size := 1; Folder.List (1) := Item; elsif Folder.List'Length = Folder.Size then List := new TokenList (1..Folder.Size + Increment); if Place > 1 then List (1..Place - 1) := Folder.List (1..Place - 1); end if; List (Place) := Item; if Place <= Folder.Size then List (Place + 1..Folder.Size + 1) := Folder.List (Place..Folder.Size); end if; Free (Folder.List); Folder.List := List; Folder.Size := Folder.Size + 1; else for Index in reverse Place..Folder.Size loop Folder.List (Index + 1) := Folder.List (Index); end loop; Folder.List (Place) := Item; Folder.Size := Folder.Size + 1; end if; end Insert; procedure Add (Folder : in out Table; Name : String; Data : Tag) is Index : constant Integer := Search (Folder, Name); begin if Index > 0 then raise Name_Error; else Insert (Folder, -Index, Name, Data); end if; end Add; procedure Add ( Folder : in out Table; Name : String; Data : Tag; Offset : out Positive ) is Index : Integer := Search (Folder, Name); begin if Index > 0 then raise Name_Error; else Index := -Index; Insert (Folder, Index, Name, Data); Offset := Index; end if; end Add; procedure Adjust (Folder : in out Table) is List : TokenListPtr; begin if Folder.Size > 0 then List := new TokenList (1..Folder.Size); for Index in List'range loop List (Index) := new Token'(Folder.List (Index).all); end loop; Folder.List := List; end if; end Adjust; procedure Delete ( Folder : in out Table; Offset : Positive ) is begin if Offset > Folder.Size then raise End_Error; end if; Free (Folder.List (Offset)); if Offset /= Folder.Size then Folder.List (Offset .. Folder.Size - 1) := Folder.List (Offset + 1 .. Folder.Size); end if; Folder.Size := Folder.Size - 1; end Delete; procedure Delete (Folder : in out Table; Name : String) is Index : constant Integer := Search (Folder, Name); begin if Index > 0 then Delete (Folder, Index); end if; end Delete; procedure Erase (Folder : in out Table) is begin for Item in 1..Folder.Size loop Free (Folder.List (Item)); end loop; Folder.Size := 0; end Erase; procedure Finalize (Folder : in out Table) is begin for Index in 1..Folder.Size loop Free (Folder.List (Index)); end loop; if Folder.List /= null then Free (Folder.List); end if; end Finalize; function Find (Folder : Table; Name : String) return Tag is Index : constant Integer := Search (Folder, Name); begin if Index > 0 then return Folder.List (Index).Data; else raise End_Error; end if; end Find; procedure Get ( Source : String; Pointer : in out Integer; Folder : Table; Data : out Tag ) is Index : Natural; begin Locate (Source, Pointer, Folder, Index); if Index = 0 then raise End_Error; else Data := Folder.List (Index).Data; end if; end Get; procedure Get ( Source : String; Pointer : in out Integer; Folder : Table; Data : out Tag; Got_It : out Boolean ) is Index : Natural; begin Locate (Source, Pointer, Folder, Index); if Index = 0 then Got_It := False; else Got_It := True; Data := Folder.List (Index).Data; end if; end Get; function GetName ( Folder : Table; Offset : Positive ) return String is begin if Offset > Folder.Size then raise End_Error; else return Folder.List (Offset).Name; end if; end GetName; function GetTag (Folder : Table; Offset : Positive) return Tag is begin if Offset > Folder.Size then raise End_Error; else return Folder.List (Offset).Data; end if; end GetTag; function GetSize (Folder : Table) return Natural is begin return Folder.Size; end GetSize; function IsIn (Folder : Table; Name : String) return Boolean is begin return Search (Folder, Name) > 0; end IsIn; function Locate (Folder : Table; Name : String) return Natural is Index : constant Integer := Search (Folder, Name); begin if Index > 0 then return Index; else return 0; end if; end Locate; procedure Locate ( Source : String; Pointer : in out Integer; Folder : Table; Offset : out Natural ) is function Compare (Item : String) return Equality; pragma Inline (Compare); function Compare (Item : String) return Equality is Index1 : Integer := Pointer; Index2 : Integer := Item'First; begin loop if Index2 > Item'Last then return Equal; end if; if Index1 > Source'Last then return Less; end if; if Source (Index1) /= Item (Index2) then if Source (Index1) > Item (Index2) then return Greater; else return Less; end if; end if; Index1 := Index1 + 1; Index2 := Index2 + 1; end loop; end Compare; Found : Integer := 0; Low : Integer := 0; High : Integer := Folder.Size + 1; This : Integer; begin if ( Pointer < Source'First or else ( Pointer > Source'Last and then Pointer - 1 > Source'Last ) ) then raise Layout_Error; end if; while High - Low /= 1 loop This := (Low + High) / 2; case Compare (Folder.List (This).Name) is when Less => High := This; when Equal => Found := This; Low := This; when Greater => for Lower in reverse Low + 1 .. This - 1 loop exit when ( Found /= 0 and then ( Folder.List (Found).Name'Length > Folder.List (Lower).Name'Length ) ); case Compare (Folder.List (Lower).Name) is when Less => -- Rest items could be only exit; -- lesser than this, exit when Equal => Found := Lower; -- Here we are. Ignore the rest exit; -- lesser, i.e. shorter, items when Greater => null; -- Undecided, continue end case; end loop; Low := This; end case; end loop; Offset := Found; if Found /= 0 then Pointer := Pointer + Folder.List (Found).Name'Length; end if; end Locate; procedure Replace ( Folder : in out Table; Name : String; Data : Tag ) is Index : constant Integer := Search (Folder, Name); begin if Index > 0 then Folder.List (Index).Data := Data; else Insert (Folder, -Index, Name, Data); end if; end Replace; procedure Replace ( Folder : in out Table; Name : String; Data : Tag; Offset : out Positive ) is Index : Integer := Search (Folder, Name); begin if Index > 0 then Folder.List (Index).Data := Data; else Index := -Index; Insert (Folder, Index, Name, Data); Offset := Index; end if; end Replace; procedure Replace ( Folder : in out Table; Offset : Positive; Data : Tag ) is begin if Offset > Folder.Size then raise End_Error; else Folder.List (Offset).Data := Data; end if; end Replace; end Tables;
charlie5/cBound
Ada
1,776
ads
-- This file is generated by SWIG. Please do not modify by hand. -- with Interfaces; with swig; with Interfaces.C; with Interfaces.C.Pointers; package xcb.xcb_glx_get_doublev_reply_t is -- Item -- type Item is record response_type : aliased Interfaces.Unsigned_8; pad0 : aliased Interfaces.Unsigned_8; sequence : aliased Interfaces.Unsigned_16; length : aliased Interfaces.Unsigned_32; pad1 : aliased swig.int8_t_Array (0 .. 3); n : aliased Interfaces.Unsigned_32; datum : aliased xcb.xcb_glx_float64_t; pad2 : aliased swig.int8_t_Array (0 .. 7); end record; -- Item_Array -- type Item_Array is array (Interfaces.C .size_t range <>) of aliased xcb.xcb_glx_get_doublev_reply_t .Item; -- Pointer -- package C_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_glx_get_doublev_reply_t.Item, Element_Array => xcb.xcb_glx_get_doublev_reply_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_doublev_reply_t .Pointer; -- Pointer_Pointer -- package C_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_glx_get_doublev_reply_t.Pointer, Element_Array => xcb.xcb_glx_get_doublev_reply_t.Pointer_Array, Default_Terminator => null); subtype Pointer_Pointer is C_Pointer_Pointers.Pointer; end xcb.xcb_glx_get_doublev_reply_t;
iyan22/AprendeAda
Ada
2,898
adb
with Ada.Text_Io, Ada.Integer_Text_Io, Datos; with Crear_Lista_Vacia, Ins, Esc, Calcular_Maximo_y_Posicion; use Datos; use Ada.Text_Io, Ada.Integer_Text_Io; procedure Prueba_Calcular_Maximo_y_posicion is Lis : Lista; -- variable del programa principal Maximo, Posicion: Integer; procedure Pedir_Return is begin Put_Line("pulsa return para continuar "); Skip_Line; end Pedir_Return; begin -- programa principal -- Casos de prueba: -- 1. Lista vacia. Resultado: cero -- 2. Lista no vacia. Lista de un elemento -- 3. Lista no vacia. Varios elementos -- 3.1. El maximo al comienzo -- 3.2. El maximo en medio -- 3.3. El maximo al final Put_Line("Programa de prueba: "); Put_Line("*********"); Crear_Lista_Vacia(Lis); Put_Line("Caso de prueba 1: Lista vacia "); Put_Line("Ahora deberia escribir cero: "); Calcular_Maximo_y_Posicion(Lis, Maximo, Posicion); Put("Maximo: "); Put(Maximo); new_line; Put("Posicion: "); Put(Posicion); New_Line; New_Line; Pedir_Return; Crear_Lista_Vacia(Lis); Ins(Lis, 4); Put_Line("Caso de prueba 2: lista de un solo elemento."); Put_Line("La lista inicial contiene "); Esc(Lis); Put_Line("Ahora deberia escribir 4, 1: "); Calcular_Maximo_y_Posicion(Lis, Maximo, Posicion); Put("Maximo: "); Put(Maximo); new_line; Put("Posicion: "); Put(Posicion); New_Line; New_Line; Pedir_Return; Crear_Lista_Vacia(Lis); Ins(Lis, 6); Ins(Lis, 8); Ins(Lis, 9); Ins(Lis, 10); Put_Line("Caso de prueba 3.1: lista de varios elementos. Maximo al comienzo"); Put_Line("La lista inicial contiene "); Esc(Lis); Put_Line("Ahora deberia escribir 10, 1: "); Calcular_Maximo_y_Posicion(Lis, Maximo, Posicion); Put("Maximo: "); Put(Maximo); new_line; Put("Posicion: "); Put(Posicion); New_Line; New_Line; Pedir_Return; Crear_Lista_Vacia(Lis); Ins(Lis, 8); Ins(Lis, 9); Ins(Lis, 10); Ins(Lis, 6); Put_Line("Caso de prueba 3.2: lista de varios elementos. Maximo en medio"); Put_Line("La lista inicial contiene "); Esc(Lis); Put_Line("Ahora deberia escribir 10, 2: "); Calcular_Maximo_y_Posicion(Lis, Maximo, Posicion); Put("Maximo: "); Put(Maximo); new_line; Put("Posicion: "); Put(Posicion); New_Line; New_Line; Pedir_Return; Crear_Lista_Vacia(Lis); Ins(Lis, 10); Ins(Lis, 6); Ins(Lis, 8); Ins(Lis, 9); Put_Line("Caso de prueba 3.3: lista de varios elementos. Maximo al final"); Put_Line("La lista inicial contiene "); Esc(Lis); Put_Line("Ahora deberia escribir 10, 4: "); Calcular_Maximo_y_Posicion(Lis, Maximo, Posicion); Put("Maximo: "); Put(Maximo); new_line; Put("Posicion: "); Put(Posicion); New_Line; New_Line; Pedir_Return; Put_Line("Se acabo la prueba. Agurtz "); end Prueba_Calcular_Maximo_y_posicion;
zhmu/ananas
Ada
2,797
adb
-- { dg-do compile { target i?86-*-* x86_64-*-* } } -- { dg-options "-O3 -msse2 -fno-vect-cost-model -fdump-tree-vect-details" } package body Vect3 is function "+" (X, Y : Varray) return Varray is R : Varray (X'Range); begin for I in X'Range loop R(I) := X(I) + Y(I); end loop; return R; end; procedure Add (X, Y : Varray; R : out Varray) is begin for I in X'Range loop R(I) := X(I) + Y(I); end loop; end; procedure Add (X, Y : not null access Varray; R : not null access Varray) is begin for I in X'Range loop R(I) := X(I) + Y(I); end loop; end; function "+" (X, Y : Sarray) return Sarray is R : Sarray; begin for I in Sarray'Range loop R(I) := X(I) + Y(I); end loop; return R; end; procedure Add (X, Y : Sarray; R : out Sarray) is begin for I in Sarray'Range loop R(I) := X(I) + Y(I); end loop; end; procedure Add (X, Y : not null access Sarray; R : not null access Sarray) is begin for I in Sarray'Range loop R(I) := X(I) + Y(I); end loop; end; function "+" (X, Y : Darray1) return Darray1 is R : Darray1; begin for I in Darray1'Range loop R(I) := X(I) + Y(I); end loop; return R; end; procedure Add (X, Y : Darray1; R : out Darray1) is begin for I in Darray1'Range loop R(I) := X(I) + Y(I); end loop; end; procedure Add (X, Y : not null access Darray1; R : not null access Darray1) is begin for I in Darray1'Range loop R(I) := X(I) + Y(I); end loop; end; function "+" (X, Y : Darray2) return Darray2 is R : Darray2; begin for I in Darray2'Range loop R(I) := X(I) + Y(I); end loop; return R; end; procedure Add (X, Y : Darray2; R : out Darray2) is begin for I in Darray2'Range loop R(I) := X(I) + Y(I); end loop; end; procedure Add (X, Y : not null access Darray2; R : not null access Darray2) is begin for I in Darray2'Range loop R(I) := X(I) + Y(I); end loop; end; function "+" (X, Y : Darray3) return Darray3 is R : Darray3; begin for I in Darray3'Range loop R(I) := X(I) + Y(I); end loop; return R; end; procedure Add (X, Y : Darray3; R : out Darray3) is begin for I in Darray3'Range loop R(I) := X(I) + Y(I); end loop; end; procedure Add (X, Y : not null access Darray3; R : not null access Darray3) is begin for I in Darray3'Range loop R(I) := X(I) + Y(I); end loop; end; end Vect3; -- { dg-final { scan-tree-dump-times "vectorized 1 loops" 15 "vect" } }
jscparker/math_packages
Ada
13,793
adb
-- Procedure tests Fourier8. Code fragments -- demonstrate some features of FFT's. with Fourier8; with Text_IO; use Text_IO; with Ada.Numerics.Generic_Elementary_Functions; procedure fourier8_demo_1 is type Real is digits 15; package math is new Ada.Numerics.Generic_Elementary_Functions (Real); use math; package rio is new Float_IO(Real); use rio; package iio is new Integer_IO(Integer); use iio; Log_Of_Max_Data_Length : constant := 12; -- NOTICE this means max data array size is 2**Log_Of_Max_Data_Length. -- The larger you make this array, the slower program might run. type Array_Index is range 0..2**(Log_Of_Max_Data_Length+1)-1; type Data_Array is array(Array_Index) of Real; package fft8 is new Fourier8 (Real, Array_Index, Data_Array, Log_Of_Max_Data_Length); use fft8; D_Re, D_Im : Data_Array; Data_Set_Last : Data_Index; Basis_Function_Last : Data_Index; Transformed_Data_Last : Data_Index; Theta, Frequency, Norm : Real; Two_Pi_Over_N : Real; Num, Mode : Integer; Area1, Area2 : Real; DeltaRE, DeltaIM : Real; Dat_Re, Dat_Im : Real; Exp_Table : Exp_Storage; -- And put the following in calls to FFT: -- Exp_Table => Exp_Table, Max_Error, Del : Real; Pii : constant Real := 3.14159_26535_89793_23846; ----------- -- Pause -- ----------- procedure Pause (s1,s2,s3,s4,s5,s6,s7,s8,s9,s10 : string := "") is Continue : Character := ' '; begin new_line(2); if S1 /= "" then put_line (S1); end if; if S2 /= "" then put_line (S2); end if; if S3 /= "" then put_line (S3); end if; if S4 /= "" then put_line (S4); end if; if S5 /= "" then put_line (S5); end if; if S6 /= "" then put_line (S6); end if; if S7 /= "" then put_line (S7); end if; if S8 /= "" then put_line (S8); end if; if S9 /= "" then put_line (S9); end if; if S10 /= "" then put_line (S10); end if; dialog: loop begin new_line(1); put ("Type a character to continue: "); get_immediate (Continue); exit dialog; exception when others => null; end; end loop dialog; new_line(2); end pause; begin new_line; put ("Input number of data points to use in the following tests."); new_line; put ("The maximum allowed number is "); put (Integer'Image(2**Log_Of_Max_Data_Length)); new_line; put ("A good number to start with is 37"); new_line; put ("Enter the desired number: "); get (Num); Data_Set_Last := Data_Index (Num - 1); -- Get nearest power of 2. declare Pow : Integer := 0; begin for I in Integer range 0..Log_Of_Max_Data_Length loop if 2**I >= Num then Pow := I; exit; end if; end loop; Basis_Function_Last := Data_Index (2**Pow - 1); end; new_line; put ("You requested an FFT on the first "); put (Integer'Image (Num)); put (" data points."); new_line; put ("The actual FFT will be performed on "); put (Integer'Image (Integer (Basis_Function_Last)+1)); put (" data points."); new_line; put ("Data is set to 0 beyond the first "); put (Integer'Image (Num)); put (" data points."); new_line(2); --***************************************************************** -- Test 1. -- Make a basis element of the set of Fourier basis states: -- Its FFT should zero everywhere except for the element = Mode. -- There, the value of the FFT should be (1.0, 0.0). Below -- we normalize the basis element with the factor Norm = 1/Sqrt(N). --***************************************************************** Pause ("Test 1: take the FFT of the Fourier basis function:", " ", " Exp (i*T*Mode*2*Pi/N) / SQRT(N),", " ", "where N is the number of points. The result of the FFT", "should be a delta-function peaked at position Mode."); put_line ("Input Mode (0, 1, 2, ...) of the basis function you wish to FFT: "); Get (Mode); Frequency := Real (Mode); --***************************************************************** Two_Pi_Over_N := 2.0 * Pii / (Real (Basis_Function_Last) + 1.0); Norm := 1.0 / SQRT ((Real (Basis_Function_Last) + 1.0)); for I in 0..Basis_Function_Last loop Theta := Two_Pi_Over_N * Frequency * Real (I); D_Re(I) := Norm * Cos (Theta); D_Im(I) := Norm * Sin (Theta); end loop; put_line ("Starting Test 1:"); new_line; put ("Basis function was constructed using "); put(Num); put(" data points."); FFT (Data_Re => D_Re, Data_Im => D_Im, Transformed_Data_Last => Transformed_Data_Last, Input_Data_Last => Basis_Function_Last, Exp_Table => Exp_Table, Inverse_FFT_Desired => False, Normalized_Data_Desired => True); Pause ("Ending FFT.", "We have taken the FFT of Exp (i*T*Mode*2*Pi/N) / SQRT(N).", "The result should be (0.0, 0.0) everywhere except for ", "a (1.0, 0.0) at data point Mode."); for I in Data_Index range 0..Basis_Function_Last loop new_line; put (Integer(I)); put(' '); put (D_Re(I)); put(' '); put(D_Im(I)); end loop; --***************************************************************** -- test 1b. -- We 1st make a basis element of the set of Fourier basis states: -- Its FFT should zero everywhere except for the element = Mode. -- There, the value of the FFT should be (1.0, 0.0). Below -- we normalize the basis element with the factor Norm = 1/Sqrt(N). --***************************************************************** Pause ("Test 1b: take the inverse FFT of the Fourier basis function:", " ", " Exp (-i*T*Mode*2*Pi/N) / SQRT(N),", " ", "where N is the number of points. The result of the FFT", "should be a delta-function peaked at position Mode."); put_line ("Input Mode (0, 1, 2, ...) of the basis function you wish to FFT: "); Get (Mode); Frequency := Real (Mode); --***************************************************************** Two_Pi_Over_N := 2.0 * Pii / (Real (Basis_Function_Last) + 1.0); Norm := 1.0 / SQRT ((Real (Basis_Function_Last) + 1.0)); for I in 0..Basis_Function_Last loop Theta := Two_Pi_Over_N * Frequency * Real (I); D_Re(I) := Norm * Cos (Theta); D_Im(I) := -Norm * Sin (Theta); end loop; put_line ("Starting Test 1b:"); new_Line; put ("Basis function was constructed using "); put(Integer(Basis_Function_Last)+1); put(" data points."); new_line(2); FFT (Data_Re => D_Re, Data_Im => D_Im, Transformed_Data_Last => Transformed_Data_Last, Input_Data_Last => Basis_Function_Last, Exp_Table => Exp_Table, Inverse_FFT_Desired => True, Normalized_Data_Desired => True); Pause ("Ending FFT.", "We have taken the inverse FFT of Exp (-i*T*Mode*2*Pi/N) / SQRT(N).", "The result should be (0.0, 0.0) everywhere except for ", "a (1.0, 0.0) at data point Mode."); for I in Data_Index range 0..Basis_Function_Last loop new_line; put (Integer(I)); put(' '); put (D_Re(I)); put(' '); put(D_Im(I)); end loop; --***************************************************************** -- Test2. -- Verify Parceval's Theorem. The area under the FFT coefficients -- should equal the area under the data. Notice that was true in the -- above test, because Sum (|exp(i*T*Mode*2*Pi/N) / Sqrt(N)|**2) is -- one on the interval [0,N-1]. -- First we create a new data set: --***************************************************************** for I in 0..Data_Set_Last loop Theta := Real (I); D_Re(I) := 1.0 / (Theta + 1.0); D_Im(I) := Theta**2; end loop; Area1 := 0.0; for I in 0..Data_Set_Last loop Area1 := Area1 + D_Re(I)*D_Re(I) + D_Im(I)*D_Im(I); end loop; Pause ("Test 2: test of Parceval's theorem. The area under the", "FFT curve (sum of coefficients modulus squared) should equal", "area under the original curve. This requires the use of the", "normalized version of the FFT."); put_line ("Starting Test 2:"); FFT (Data_Re => D_Re, Data_Im => D_Im, Transformed_Data_Last => Transformed_Data_Last, --output padded data length-1 Input_Data_Last => Data_Set_Last, --input desired data length-1 Exp_Table => Exp_Table, Inverse_FFT_Desired => False, Normalized_Data_Desired => True); put_line ("Ending FFT"); Area2 := 0.0; for I in 0..Transformed_Data_Last loop Area2 := Area2 + D_Re(I)*D_Re(I) + D_Im(I)*D_Im(I); end loop; new_line; put ("Area under the original curve: "); put(Area1); new_line; put ("Area under Fourier transformed curve: "); put(Area2); -- Test3. -- Inverse FFT of the FFT. Pause ("Test 3: take the inverse FFT of the FFT of some", "artificial data, and compare with the original data.", "The test calculates: Data - Inverse_FFT (FFT (Data),", "then prints the max error."); for I in 0..Data_Set_Last loop Theta := Real (I); D_Re(I) := Sqrt (Theta) / (Theta + 1.0); D_Im(I) := Cos (0.03737*Theta**2/(Theta + 1.0)) * Theta / (Theta + 1.0); end loop; put_line("Starting Test 3:"); FFT (Data_Re => D_Re, Data_Im => D_Im, Transformed_Data_Last => Transformed_Data_Last, Input_Data_Last => Data_Set_Last, Exp_Table => Exp_Table, Inverse_FFT_Desired => False, Normalized_Data_Desired => True); FFT (Data_Re => D_Re, Data_Im => D_Im, Transformed_Data_Last => Transformed_Data_Last, Input_Data_Last => Transformed_Data_Last, Exp_Table => Exp_Table, Inverse_FFT_Desired => True, Normalized_Data_Desired => True); Max_Error := 0.0; for I in 0..Data_Set_Last loop Theta := Real (I); Dat_Re := Sqrt (Theta) / (Theta + 1.0); Dat_Im := Cos (0.03737*Theta**2/(Theta + 1.0)) * Theta / (Theta + 1.0); Del := Abs (Dat_Re - D_Re(I)); if Max_Error < Del then Max_Error := Del; end if; Del := Abs (Dat_Im - D_Im(I)); if Max_Error < Del then Max_Error := Del; end if; end loop; new_line(2); put ("Max error in Data - Inverse_FFT (FFT (Data)):"); put (Max_Error); new_line; Pause ("If the number of data points FFT'd was not a power", "of 2 in length, then the data set was padded with zeros", "out to the nearest power of 2. To see if these data", "values were preserved by the two transformations, type", "a character. Should get a number near 10.0**(-15):"); -- These points were padded with zero's in the FFT routine, prior -- to being FFT'd. The application of the inverse FFT should -- bring them back to zero again. if Data_Set_Last < Data_Index'Last then Max_Error := 0.0; for I in Data_Set_Last+1 .. Transformed_Data_Last loop Del := Abs (D_Re(I) - 0.0); if Max_Error < Del then Max_Error := Del; end if; Del := Abs (D_Im(I) - 0.0); if Max_Error < Del then Max_Error := Del; end if; end loop; put ("Max error in [Data - Inverse_FFT (FFT (Data))]: "); put (Max_Error); end if; Pause ("Test 4 is a long test..runs through entire range of Array_Index ", "to see if FFT_Inverse (FFT (Data)) = Data. Nothing is printed", "unless large errors are detected. (Use 15 digit floating point.)", "Interrupt the program here if you do not want a long wait."); for N in Array_Index range 0..Basis_Function_Last loop for I in Array_Index range 0..N loop Theta := Real (I); D_Re(I) := 1.0 / (Theta + 1.0); D_Im(I) := Cos (0.03737 * Theta**2 / (Theta + 1.0)); end loop; FFT (Data_Re => D_Re, Data_Im => D_Im, Transformed_Data_Last => Transformed_Data_Last, --output padded data length-1 Input_Data_Last => N, --input desired data length-1 Exp_Table => Exp_Table, Inverse_FFT_Desired => False, Normalized_Data_Desired => True); FFT (Data_Re => D_Re, Data_Im => D_Im, Transformed_Data_Last => Transformed_Data_Last, Input_Data_Last => Transformed_Data_Last, Exp_Table => Exp_Table, Inverse_FFT_Desired => True, Normalized_Data_Desired => True); for I in Array_Index range 0..N loop Theta := Real (I); Dat_Re := 1.0 / (Theta + 1.0); Dat_Im := Cos (0.03737 * Theta**2 / (Theta + 1.0)); DeltaRE := Abs (Dat_Re - D_Re(I)); DeltaIM := Abs (Dat_Im - D_Im(I)); if DeltaRE > 1.0E-11 then new_line; put("FAILURE: "); put (DeltaRE); put(" at "); put(Real(I)); end if; if DeltaIM > 1.0E-11 then new_line; put("FAILURE: "); put (DeltaIM); put(" at "); put(Real(I)); end if; end loop; end loop; end;
MinimSecure/unum-sdk
Ada
1,062
adb
-- Copyright 2008-2019 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/>. procedure Foo is type Bar (N : Natural) is record S : String (1 .. N); end record; function Get (S : String) return Bar is begin return (N => S'Length, S => S); end Get; procedure Do_Nothing (B : Bar) is begin null; end Do_Nothing; B : Bar := Get ("Foo"); begin Do_Nothing (B); -- STOP end Foo;
stcarrez/ada-asf
Ada
2,681
ads
----------------------------------------------------------------------- -- asf-events -- ASF Events -- Copyright (C) 2010, 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.Events; with ASF.Lifecycles; with ASF.Components.Base; with ASF.Events.Phases; with Ada.Containers.Vectors; -- The <b>ASF.Events</b> package defines the application events that an ASF -- application can receive. Events are queued while processing the JSF phases -- (See UIComponent.Queue_Event). They are dispatched after each phase -- (See UIComponent.Broadcast). -- -- This package is an Ada adaptation for the Java Server Faces Specification -- JSR 314 - 3.4.2 Application Events. package ASF.Events.Faces is -- ------------------------------ -- Faces event -- ------------------------------ -- The <b>Faces_Event</b> represents the root type for ASF events. -- The event is associated with a component and a lifecycle phase after -- which it will be processed. type Faces_Event is new Util.Events.Event with private; -- Get the lifecycle phase where the event must be processed. function Get_Phase (Event : in Faces_Event) return ASF.Lifecycles.Phase_Type; -- Set the lifecycle phase when this event must be processed. procedure Set_Phase (Event : in out Faces_Event; Phase : in ASF.Lifecycles.Phase_Type); -- Get the component onto which the event was posted. function Get_Component (Event : in Faces_Event) return Components.Base.UIComponent_Access; private type Faces_Event_Access is access all Faces_Event'Class; package Event_Vectors is new Ada.Containers.Vectors (Index_Type => Natural, Element_Type => Faces_Event_Access); type Faces_Event is new Util.Events.Event with record Phase : ASF.Events.Phases.Phase_Type := ASF.Events.Phases.RESTORE_VIEW; Component : Components.Base.UIComponent_Access := null; end record; end ASF.Events.Faces;
reznikmm/matreshka
Ada
3,613
adb
------------------------------------------------------------------------------ -- -- -- 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$ ------------------------------------------------------------------------------ separate (AMF.Internals.Factories.Utp_Factories) function Convert_Duration_To_String (Value : League.Holders.Holder) return League.Strings.Universal_String is begin raise Program_Error; return League.Strings.Empty_Universal_String; end Convert_Duration_To_String;
osannolik/ada-canopen
Ada
393
ads
package ACO.Protocols.Network_Management.Slaves is type Slave (Id : ACO.Messages.Node_Nr; Od : not null access ACO.OD.Object_Dictionary'Class) is new NMT with private; private type Slave (Id : ACO.Messages.Node_Nr; Od : not null access ACO.OD.Object_Dictionary'Class) is new NMT (Id, Od) with null record; end ACO.Protocols.Network_Management.Slaves;
reznikmm/matreshka
Ada
7,281
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Localization, Internationalization, Globalization for Ada -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-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.Internals.Calendars.Times; package body Matreshka.Internals.Calendars.Formatting.Times is procedure Append (Result : in out League.Strings.Universal_String; Value : Natural; Padding : Positive); ------------ -- Append -- ------------ procedure Append (Result : in out League.Strings.Universal_String; Value : Natural; Padding : Positive) is Image : constant Wide_Wide_String := Integer'Wide_Wide_Image (Value); begin for J in 1 .. Padding - Image'Length + 1 loop Result.Append ('0'); end loop; Result.Append (Image (Image'First + 1 .. Image'Last)); end Append; ------------------------------ -- Append_Fractional_Second -- ------------------------------ overriding procedure Append_Fractional_Second (Self : Time_Printer; Output : in out League.Strings.Universal_String; Time : Relative_Time; Leap : Relative_Time; Padding : Positive) is Image : constant Wide_Wide_String := Matreshka.Internals.Calendars.Times.Nano_Second_100_Number' Wide_Wide_Image (Matreshka.Internals.Calendars.Times.Nanosecond_100 (Time, Leap)); Buffer : Wide_Wide_String := "0000000"; begin Buffer (Buffer'Last - Image'Length + 2 .. Buffer'Last) := Image (Image'First + 1 .. Image'Last); Output.Append (Buffer (1 .. Padding)); end Append_Fractional_Second; -------------------------- -- Append_Full_Day_Hour -- -------------------------- overriding procedure Append_Full_Day_Hour (Self : Time_Printer; Output : in out League.Strings.Universal_String; Time : Relative_Time; Padding : Positive; Zero_Based : Boolean) is begin Append (Output, Matreshka.Internals.Calendars.Times.Hour (Time), Padding); end Append_Full_Day_Hour; -------------------------- -- Append_Half_Day_Hour -- -------------------------- overriding procedure Append_Half_Day_Hour (Self : Time_Printer; Output : in out League.Strings.Universal_String; Time : Relative_Time; Padding : Positive; Zero_Based : Boolean) is begin -- XXX Not yet implemented. null; end Append_Half_Day_Hour; -------------------------------- -- Append_Milliseconds_In_Day -- -------------------------------- overriding procedure Append_Milliseconds_In_Day (Self : Time_Printer; Output : in out League.Strings.Universal_String; Time : Relative_Time; Leap : Relative_Time; Padding : Positive) is begin -- XXX Not yet implemented. null; end Append_Milliseconds_In_Day; ------------------- -- Append_Minute -- ------------------- overriding procedure Append_Minute (Self : Time_Printer; Output : in out League.Strings.Universal_String; Time : Relative_Time; Padding : Positive) is begin Append (Output, Matreshka.Internals.Calendars.Times.Minute (Time), Padding); end Append_Minute; ------------------- -- Append_Period -- ------------------- overriding procedure Append_Period (Self : Time_Printer; Output : in out League.Strings.Universal_String; Time : Relative_Time) is begin -- XXX Not yet implemented. null; end Append_Period; ------------------- -- Append_Second -- ------------------- overriding procedure Append_Second (Self : Time_Printer; Output : in out League.Strings.Universal_String; Time : Relative_Time; Leap : Relative_Time; Padding : Positive) is begin Append (Output, Matreshka.Internals.Calendars.Times.Second (Time, Leap), Padding); end Append_Second; end Matreshka.Internals.Calendars.Formatting.Times;
zhmu/ananas
Ada
2,896
ads
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S Y S T E M . F A T _ F L T -- -- -- -- 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. -- -- -- -- 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. -- -- -- ------------------------------------------------------------------------------ -- This package contains an instantiation of the floating-point attribute -- runtime routines for the type Float. with System.Fat_Gen; package System.Fat_Flt is pragma Pure; -- Note the only entity from this package that is accessed by Rtsfind -- is the name of the package instantiation. Entities within this package -- (i.e. the individual floating-point attribute routines) are accessed -- by name using selected notation. package Attr_Float is new System.Fat_Gen (Float); end System.Fat_Flt;
reznikmm/matreshka
Ada
3,784
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.Style_Background_Transparency_Attributes is pragma Preelaborate; type ODF_Style_Background_Transparency_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Style_Background_Transparency_Attribute_Access is access all ODF_Style_Background_Transparency_Attribute'Class with Storage_Size => 0; end ODF.DOM.Style_Background_Transparency_Attributes;
AdaCore/libadalang
Ada
227
adb
package body Pkg is procedure Prim (Value : T); procedure Prim (Value : T) is begin null; end Prim; procedure Foo is V : T; begin V.Prim; pragma Test_Statement; end Foo; end Pkg;
stcarrez/stm32-ui
Ada
3,148
ads
package Cosin_Table is subtype Cosin_Value is Natural; type Cosin_Array is array (0 .. 179) of Cosin_Value; Factor : constant Cosin_Value := 65536; Sin_Table : constant array (0 .. 179) of Cosin_Value := ( 0, 572, 1144, 1716, 2287, 2859, 3430, 4001, 4572, 5142, 5712, 6281, 6850, 7419, 7987, 8554, 9121, 9687, 10252, 10817, 11380, 11943, 12505, 13066, 13626, 14185, 14742, 15299, 15855, 16409, 16962, 17514, 18064, 18613, 19161, 19707, 20252, 20795, 21336, 21876, 22415, 22951, 23486, 24019, 24550, 25080, 25607, 26132, 26656, 27177, 27697, 28214, 28729, 29242, 29753, 30261, 30767, 31271, 31772, 32271, 32768, 33262, 33754, 34242, 34729, 35212, 35693, 36172, 36647, 37120, 37590, 38057, 38521, 38982, 39441, 39896, 40348, 40797, 41243, 41686, 42126, 42562, 42995, 43425, 43852, 44275, 44695, 45112, 45525, 45935, 46341, 46744, 47143, 47538, 47930, 48318, 48703, 49084, 49461, 49834, 50203, 50569, 50931, 51289, 51643, 51993, 52339, 52682, 53020, 53354, 53684, 54010, 54332, 54650, 54963, 55273, 55578, 55879, 56175, 56468, 56756, 57040, 57319, 57594, 57865, 58131, 58393, 58650, 58903, 59152, 59396, 59635, 59870, 60100, 60326, 60547, 60764, 60976, 61183, 61386, 61584, 61777, 61966, 62149, 62328, 62503, 62672, 62837, 62997, 63152, 63303, 63449, 63589, 63725, 63856, 63983, 64104, 64220, 64332, 64439, 64540, 64637, 64729, 64816, 64898, 64975, 65048, 65115, 65177, 65234, 65287, 65334, 65376, 65414, 65446, 65474, 65496, 65514, 65526, 65534); Cos_Table : constant array (0 .. 179) of Cosin_Value := ( 65536, 65534, 65526, 65514, 65496, 65474, 65446, 65414, 65376, 65334, 65287, 65234, 65177, 65115, 65048, 64975, 64898, 64816, 64729, 64637, 64540, 64439, 64332, 64220, 64104, 63983, 63856, 63725, 63589, 63449, 63303, 63152, 62997, 62837, 62672, 62503, 62328, 62149, 61966, 61777, 61584, 61386, 61183, 60976, 60764, 60547, 60326, 60100, 59870, 59635, 59396, 59152, 58903, 58650, 58393, 58131, 57865, 57594, 57319, 57040, 56756, 56468, 56175, 55879, 55578, 55273, 54963, 54650, 54332, 54010, 53684, 53354, 53020, 52682, 52339, 51993, 51643, 51289, 50931, 50569, 50203, 49834, 49461, 49084, 48703, 48318, 47930, 47538, 47143, 46744, 46341, 45935, 45525, 45112, 44695, 44275, 43852, 43425, 42995, 42562, 42126, 41686, 41243, 40797, 40348, 39896, 39441, 38982, 38521, 38057, 37590, 37120, 36647, 36172, 35693, 35212, 34729, 34242, 33754, 33262, 32768, 32271, 31772, 31271, 30767, 30261, 29753, 29242, 28729, 28214, 27697, 27177, 26656, 26132, 25607, 25080, 24550, 24019, 23486, 22951, 22415, 21876, 21336, 20795, 20252, 19707, 19161, 18613, 18064, 17514, 16962, 16409, 15855, 15299, 14742, 14185, 13626, 13066, 12505, 11943, 11380, 10817, 10252, 9687, 9121, 8554, 7987, 7419, 6850, 6281, 5712, 5142, 4572, 4001, 3430, 2859, 2287, 1716, 1144, 572); end Cosin_Table;
sungyeon/drake
Ada
312
ads
pragma License (Unrestricted); -- Ada 2012 -- with Ada.Interrupts; package Ada.Execution_Time.Interrupts is -- function Clock (Interrupt : Ada.Interrupts.Interrupt_Id) return CPU_Time; -- function Supported (Interrupt : Ada.Interrupts.Interrupt_Id) -- return Boolean; end Ada.Execution_Time.Interrupts;
zhmu/ananas
Ada
364
adb
-- { dg-do compile } -- { dg-options "-O -gnatws -fdump-tree-optimized" } with Pure_Function3_Pkg; use Pure_Function3_Pkg; procedure Pure_Function3a is V : T; begin if F (V) = 1 then raise Program_Error; elsif F (V) = 2 then raise Program_Error; end if; end; -- { dg-final { scan-tree-dump-times "pure_function3_pkg.f" 1 "optimized" } }
sebsgit/textproc
Ada
3,468
adb
with Interfaces.C; use Interfaces.C; with Interfaces.C.Strings; with StbiWrapper; use StbiWrapper.UCharPtr; with Ada.Integer_Text_IO; with Ada.Containers; use Ada.Containers; package body ImageIO is package C renames Interfaces.C; function load(filename: C.Strings.chars_ptr) return PixelArray.ImagePlane is imageData: StbiWrapper.ImageData; begin imageData := StbiWrapper.load(filename); return result: PixelArray.ImagePlane := PixelArray.allocate(Integer(imageData.width), Integer(imageData.height)) do if imageData.nChannels = 1 then for y in 0 .. imageData.height - 1 loop for x in 0 .. imageData.width - 1 loop declare ptr: constant StbiWrapper.UCharPtr.Pointer := imageData.pixels + C.ptrdiff_t(x + y * imageData.width); begin result.set(Integer(x), Integer(y), PixelArray.Pixel(ptr.all)); end; end loop; end loop; else for y in 0 .. imageData.height - 1 loop for x in 0 .. imageData.width - 1 loop declare ptrR: constant StbiWrapper.UCharPtr.Pointer := imageData.pixels + C.ptrdiff_t(3 * x + 0 + y * 3 * imageData.width); ptrG: constant StbiWrapper.UCharPtr.Pointer := imageData.pixels + C.ptrdiff_t(3 * x + 1 + y * 3 * imageData.width); ptrB: constant StbiWrapper.UCharPtr.Pointer := imageData.pixels + C.ptrdiff_t(3 * x + 2 + y * 3 * imageData.width); avgPx: constant Float := (Float(ptrR.all) + Float(ptrG.all) + Float(ptrB.all)) / 3.0; begin result.set(Integer(x), Integer(y), PixelArray.Pixel(avgPx)); end; end loop; end loop; end if; end return; end load; function save(filename: C.Strings.chars_ptr; image: PixelArray.ImagePlane) return Boolean is begin declare arraySize: constant C.size_t := C.size_t(image.width * image.height * 3); pxArray: StbiWrapper.UCharArray(0 .. arraySize); save_result: C.int; index: Integer := 0; begin for y in 0 .. image.height - 1 loop for x in 0 .. image.width - 1 loop declare charValue: constant C.unsigned_char := C.unsigned_char(image.get(x, y)); begin pxArray(C.size_t(3 * index)) := charValue; pxArray(C.size_t(3 * index + 1)) := charValue; pxArray(C.size_t(3 * index + 2)) := charValue; index := index + 1; end; end loop; end loop; save_result := StbiWrapper.writePng(filename, C.int(image.width), C.int(image.height), 3, pxArray(pxArray'First)'Unchecked_Access, C.int(3 * image.width)); return save_result = 1; end; end save; function load(filename: String) return PixelArray.ImagePlane is begin return load(C.Strings.New_String(filename)); end load; function save(filename: String; image: PixelArray.ImagePlane) return Boolean is begin return save(C.Strings.New_String(filename), image); end save; procedure save(filename: String; image: PixelArray.ImagePlane) is flag: Boolean; begin flag := save(C.Strings.New_String(filename), image); end save; end ImageIO;
sungyeon/drake
Ada
36
ads
../machine-apple-darwin/s-natdir.ads
ActorExpose/Amass
Ada
6,091
ads
-- Copyright 2017-2021 Jeff Foley. All rights reserved. -- Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. local json = require("json") name = "Spyse" type = "api" function start() setratelimit(1) end function check() local c local cfg = datasrc_config() if cfg ~= nil then c = cfg.credentials end if (c ~= nil and c.key ~= nil and c.key ~= "") then return true end return false end function vertical(ctx, domain) local c local cfg = datasrc_config() if cfg ~= nil then c = cfg.credentials end if (c == nil or c.key == nil or c.key == "") then return end local step = 100 for i = 0,10000,step do local payload = '{"search_params":[{"name":{"operator":"ends","value":".' .. domain .. '"}}],"limit":100,"offset":' .. tostring(i) .. '}' local resp = postreq(ctx, "https://api.spyse.com/v4/data/domain/search", c.key, cfg.ttl, payload) if (resp == "") then break end local d = json.decode(resp) if (d == nil or #(d['data'].items) == 0) then return false end for i, item in pairs(d['data'].items) do sendnames(ctx, item.name) end if (i+step >= d['data'].total_items) then break end end end function horizontal(ctx, domain) local c local cfg = datasrc_config() if cfg ~= nil then c = cfg.credentials end if (c == nil or c.key == nil or c.key == "") then return end horizoncerts(ctx, domain, c.key, cfg.ttl) end function horizoncerts(ctx, domain, key, ttl) local u = "https://api.spyse.com/v4/data/domain/" .. domain local resp = getpage(ctx, u, key, ttl) if (resp == "") then return end local d = json.decode(resp) if (d == nil or #(d['data'].items) == 0) then return end if (d['data'].items[0].cert_summary == nil) then return end local certid = d['data'].items[0].cert_summary.fingerprint_sha256 u = "https://api.spyse.com/v4/data/certificate/" .. certid resp = getpage(ctx, u, key, ttl) if (resp == "") then return end d = json.decode(resp) if (d == nil or #(d['data'].items) == 0) then return end local san = d['data'].items[0].parsed.extensions.subject_alt_name if (san ~= nil and #(san.dns_names) > 0) then for j, name in pairs(san.dns_names) do local names = find(name, subdomainre) if (names ~= nil and #names > 0 and names[1] ~= "") then associated(ctx, domain, names[1]) end end end end function asn(ctx, addr, asn) local c local cfg = datasrc_config() if cfg ~= nil then c = cfg.credentials end if (c == nil or c.key == nil or c.key == "") then return end local prefix if (asn == 0) then if (addr == "") then return end asn, prefix = getasn(ctx, addr, c.key, cfg.ttl) if (asn == 0) then return end end local a = asinfo(ctx, asn, c.key, cfg.ttl) if (a == nil or #(a.netblocks) == 0) then return end if (prefix == "") then prefix = a.netblocks[1] parts = split(prefix, "/") addr = parts[1] end newasn(ctx, { ['addr']=addr, ['asn']=asn, ['prefix']=prefix, ['desc']=a.desc, ['netblocks']=a.netblocks, }) end function getasn(ctx, ip, key, ttl) local u = "https://api.spyse.com/v4/data/ip/" .. tostring(ip) local resp = getpage(ctx, u, key, ttl) if (resp == "") then return 0, "" end local d = json.decode(resp) if (d == nil or #(d['data'].items) == 0) then return 0, "" end local cidr local asn = 0 for i, item in pairs(d['data'].items) do local num = item.isp_info.as_num if (asn == 0 or asn < num) then asn = num cidr = item.cidr end end return asn, cidr end function asinfo(ctx, asn, key, ttl) local u = "https://api.spyse.com/v4/data/as/" .. tostring(asn) local resp = getpage(ctx, u, key, ttl) if (resp == "") then return nil end local d = json.decode(resp) if (d == nil or #(d['data'].items) == 0) then return nil end local cidrs = {} for i, p in pairs(d.items[1].ipv4_cidr_array) do table.insert(cidrs, p.ip .. "/" .. tostring(p.cidr)) end for i, p in pairs(d.items[1].ipv6_cidr_array) do table.insert(cidrs, p.ip .. "/" .. tostring(p.cidr)) end return { desc=d.items[1].as_org, netblocks=cidrs, } end function getpage(ctx, url, key, ttl) local resp, err = request(ctx, { ['url']=url, headers={ ['Authorization']="Bearer " .. key, ['Content-Type']="application/json", }, }) if (err ~= nil and err ~= "") then return "" end return resp end function postreq(ctx, url, key, ttl, payload) local resp, err = request(ctx, { ['url']=url, method="POST", data=payload, headers={ ['Authorization']="Bearer " .. key, ['Content-Type']="application/json", }, }) if (err ~= nil and err ~= "") then return "" end return resp end function sendnames(ctx, content) local names = find(content, subdomainre) if (names == nil) then return end local found = {} for i, v in pairs(names) do if (found[v] == nil) then newname(ctx, v) found[v] = true end end end function split(str, delim) local result = {} local pattern = "[^%" .. delim .. "]+" local matches = find(str, pattern) if (matches == nil or #matches == 0) then return result end for i, match in pairs(matches) do table.insert(result, match) end return result end
cognitedata/unreal-openapi-generator
Ada
4,771
ads
-- OpenAPI Petstore -- This is a sample server Petstore server. For this sample, you can use the api key `special_key` to test the authorization filters. -- -- OpenAPI spec version: 1.0.0 -- -- -- NOTE: This package is auto generated by OpenAPI-Generator 4.0.0-SNAPSHOT. -- https://openapi-generator.tech -- Do not edit the class manually. with Samples.Petstore.Models; with Swagger.Clients; package Samples.Petstore.Clients is type Client_Type is new Swagger.Clients.Client_Type with null record; -- Add a new pet to the store procedure Add_Pet (Client : in out Client_Type; P_Body : in Samples.Petstore.Models.PetType); -- Deletes a pet procedure Delete_Pet (Client : in out Client_Type; Pet_Id : in Swagger.Long; Api_Key : in Swagger.Nullable_UString); -- Finds Pets by status -- Multiple status values can be provided with comma separated strings procedure Find_Pets_By_Status (Client : in out Client_Type; Status : in Swagger.UString_Vectors.Vector; Result : out Samples.Petstore.Models.PetType_Vectors.Vector); -- Finds Pets by tags -- Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. procedure Find_Pets_By_Tags (Client : in out Client_Type; Tags : in Swagger.UString_Vectors.Vector; Result : out Samples.Petstore.Models.PetType_Vectors.Vector); -- Find pet by ID -- Returns a single pet procedure Get_Pet_By_Id (Client : in out Client_Type; Pet_Id : in Swagger.Long; Result : out Samples.Petstore.Models.PetType); -- Update an existing pet procedure Update_Pet (Client : in out Client_Type; P_Body : in Samples.Petstore.Models.PetType); -- Updates a pet in the store with form data procedure Update_Pet_With_Form (Client : in out Client_Type; Pet_Id : in Swagger.Long; Name : in Swagger.Nullable_UString; Status : in Swagger.Nullable_UString); -- uploads an image procedure Upload_File (Client : in out Client_Type; Pet_Id : in Swagger.Long; Additional_Metadata : in Swagger.Nullable_UString; File : in Swagger.File_Part_Type; Result : out Samples.Petstore.Models.ApiResponseType); -- Delete purchase order by ID -- For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors procedure Delete_Order (Client : in out Client_Type; Order_Id : in Swagger.UString); -- Returns pet inventories by status -- Returns a map of status codes to quantities procedure Get_Inventory (Client : in out Client_Type; Result : out Swagger.Integer_Map); -- Find purchase order by ID -- For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions procedure Get_Order_By_Id (Client : in out Client_Type; Order_Id : in Swagger.Long; Result : out Samples.Petstore.Models.OrderType); -- Place an order for a pet procedure Place_Order (Client : in out Client_Type; P_Body : in Samples.Petstore.Models.OrderType; Result : out Samples.Petstore.Models.OrderType); -- Create user -- This can only be done by the logged in user. procedure Create_User (Client : in out Client_Type; P_Body : in Samples.Petstore.Models.UserType); -- Creates list of users with given input array procedure Create_Users_With_Array_Input (Client : in out Client_Type; P_Body : in Samples.Petstore.Models.UserType_Vectors.Vector); -- Creates list of users with given input array procedure Create_Users_With_List_Input (Client : in out Client_Type; P_Body : in Samples.Petstore.Models.UserType_Vectors.Vector); -- Delete user -- This can only be done by the logged in user. procedure Delete_User (Client : in out Client_Type; Username : in Swagger.UString); -- Get user by user name procedure Get_User_By_Name (Client : in out Client_Type; Username : in Swagger.UString; Result : out Samples.Petstore.Models.UserType); -- Logs user into the system procedure Login_User (Client : in out Client_Type; Username : in Swagger.UString; Password : in Swagger.UString; Result : out Swagger.UString); -- Logs out current logged in user session procedure Logout_User (Client : in out Client_Type); -- Updated user -- This can only be done by the logged in user. procedure Update_User (Client : in out Client_Type; Username : in Swagger.UString; P_Body : in Samples.Petstore.Models.UserType); end Samples.Petstore.Clients;
AdaCore/libadalang
Ada
539
adb
with Text_IO; use Text_IO; procedure Test4 is type Day is (Monday, Tuesday, Friday, Sunday); generic type T is (<>) or use Day; D : T; procedure Check (Day : T); procedure Check (Day : T) is begin Put_Line (T'First'Img); Put_Line (Day'Img); end; procedure Inst1 is new Check (D => Monday); pragma Test_Statement; procedure Inst2 is new Check (Positive, 8); pragma Test_Statement; begin Put_Line ("Check default discrete type"); Inst1 (Sunday); Inst2 (Day'Pos (Sunday)); end;
AdaCore/Ada_Drivers_Library
Ada
6,208
adb
------------------------------------------------------------------------------ -- -- -- Copyright (C) 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 STM32.Device; use STM32.Device; package body STM32.CRC.DMA is procedure Configure_DMA (Controller : access DMA_Controller; Stream : DMA_Stream_Selector; Data_Width : DMA_Data_Transfer_Widths); -- Configures the DMA controller and stream for transfering memory blocks, -- of the width specified, to the CRC processor. --------------------------- -- Transfer_Input_To_CRC -- --------------------------- procedure Transfer_Input_To_CRC (This : in out CRC_32; Controller : access DMA_Controller; Stream : DMA_Stream_Selector; Input_Address : System.Address; Input_Length : UInt16; Data_Width : DMA_Data_Transfer_Widths) is begin Configure_DMA (Controller, Stream, Data_Width); -- We configure the unit each time to ensure the data width is right. Clear_All_Status (Controller.all, Stream); -- Ensure previous calls or other use hasn't set any status flags. Start_Transfer_with_Interrupts (Controller.all, Stream, Source => Input_Address, Destination => This.DR'Address, Data_Count => Input_Length, Enabled_Interrupts => (Transfer_Complete_Interrupt => True, others => False)); end Transfer_Input_To_CRC; ---------------- -- Update_CRC -- ---------------- procedure Update_CRC (This : in out CRC_32; Controller : access DMA_Controller; Stream : DMA_Stream_Selector; Input : Block_32) is begin Transfer_Input_To_CRC (This, Controller, Stream, Input'Address, Input'Length, Data_Width => Words); end Update_CRC; ---------------- -- Update_CRC -- ---------------- procedure Update_CRC (This : in out CRC_32; Controller : access DMA_Controller; Stream : DMA_Stream_Selector; Input : Block_16) is begin Transfer_Input_To_CRC (This, Controller, Stream, Input'Address, Input'Length, Data_Width => HalfWords); end Update_CRC; ---------------- -- Update_CRC -- ---------------- procedure Update_CRC (This : in out CRC_32; Controller : access DMA_Controller; Stream : DMA_Stream_Selector; Input : Block_8) is begin Transfer_Input_To_CRC (This, Controller, Stream, Input'Address, Input'Length, Data_Width => Bytes); end Update_CRC; ------------------- -- Configure_DMA -- ------------------- procedure Configure_DMA (Controller : access DMA_Controller; Stream : DMA_Stream_Selector; Data_Width : DMA_Data_Transfer_Widths) is Config : DMA_Stream_Configuration; begin -- See app note AN4187 Table 3 for this configuration (other than the -- channel number). It works, although it looks counterintuitive. Config.Channel := Channel_0; -- arbitrary Config.Direction := Memory_To_Memory; Config.Memory_Data_Format := Data_Width; Config.Peripheral_Data_Format := Words; Config.Increment_Peripheral_Address := True; Config.Increment_Memory_Address := False; Config.Operation_Mode := Normal_Mode; Config.Priority := Priority_Very_High; Config.FIFO_Enabled := False; Config.Memory_Burst_Size := Memory_Burst_Single; Config.Peripheral_Burst_Size := Peripheral_Burst_Single; Configure (Controller.all, Stream, Config); end Configure_DMA; end STM32.CRC.DMA;
skill-lang/adaCommon
Ada
1,411
ads
-- ___ _ ___ _ _ -- -- / __| |/ (_) | | Common SKilL implementation -- -- \__ \ ' <| | | |__ equals used in skill -- -- |___/_|\_\_|_|____| by: Timm Felden -- -- -- pragma Ada_2012; with Ada.Containers; with Ada.Strings.Hash; with Skill.Types; with Skill.Types.Pools; with Interfaces; -- the trick of this package is to instantiate equals codes as Skill.Equals.equals -- independent of the type! :) package Skill.Equals is -- pragma Preelaborate; use type Skill.Types.String_Access; use Interfaces; function Equals (A, B : Skill.Types.String_Access) return Boolean is (A = B or else ((null /= A and null /= B) and then A.all = B.all) ); use type Skill.Types.Pools.Pool; function Equals (A, B : Skill.Types.Pools.Pool) return Boolean is (A = B); function Equals (A, B : Interfaces.Integer_8) return Boolean is (A = B); function Equals (A, B : Interfaces.Integer_16) return Boolean is (A = B); function Equals (A, B : Interfaces.Integer_32) return Boolean is (A = B); function Equals (A, B : Interfaces.Integer_64) return Boolean is (A = B); end Skill.Equals;
zhmu/ananas
Ada
3,152
adb
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- -- -- S Y S T E M . C O N C A T _ 2 -- -- -- -- B o d y -- -- -- -- Copyright (C) 2008-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. -- -- -- ------------------------------------------------------------------------------ package body System.Concat_2 is pragma Suppress (All_Checks); ------------------ -- Str_Concat_2 -- ------------------ procedure Str_Concat_2 (R : out String; S1, S2 : String) is F, L : Natural; begin F := R'First; L := F + S1'Length - 1; R (F .. L) := S1; F := L + 1; L := R'Last; R (F .. L) := S2; end Str_Concat_2; ------------------------- -- Str_Concat_Bounds_2 -- ------------------------- procedure Str_Concat_Bounds_2 (Lo, Hi : out Natural; S1, S2 : String) is begin if S1 = "" then Lo := S2'First; Hi := S2'Last; else Lo := S1'First; Hi := S1'Last + S2'Length; end if; end Str_Concat_Bounds_2; end System.Concat_2;
reznikmm/matreshka
Ada
3,709
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_Sharpness_Attributes is pragma Preelaborate; type ODF_Draw_Sharpness_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Draw_Sharpness_Attribute_Access is access all ODF_Draw_Sharpness_Attribute'Class with Storage_Size => 0; end ODF.DOM.Draw_Sharpness_Attributes;
persan/AdaYaml
Ada
637
adb
-- part of ParserTools, (c) 2017 Felix Krause -- released under the terms of the MIT license, see the file "copying.txt" with Ada.IO_Exceptions; package body Lexer.Base.Unicode is function Next (Object : in out Instance'Class) return Rune is begin if Object.Buffer (Object.Pos) = Character'Val (4) then return End_Of_Input; end if; return Ret : Rune do Strings_Edit.UTF8.Get (Object.Buffer.all, Object.Pos, Ret); end return; exception when Ada.IO_Exceptions.Data_Error => raise Lexer_Error with "Illegal content in UTF-8 source"; end Next; end Lexer.Base.Unicode;
zhmu/ananas
Ada
15,248
adb
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- -- -- S Y S T E M . O S _ I N T E R F A C E -- -- -- -- B o d y -- -- -- -- Copyright (C) 1991-1994, Florida State University -- -- Copyright (C) 1995-2022, AdaCore -- -- -- -- 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/>. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. -- -- Extensive contributions were provided by Ada Core Technologies, Inc. -- -- -- ------------------------------------------------------------------------------ -- This is a DCE version of this package. -- Currently HP-UX and SNI use this file -- This package encapsulates all direct interfaces to OS services -- that are needed by children of System. with Interfaces.C; use Interfaces.C; package body System.OS_Interface is ----------------- -- To_Duration -- ----------------- function To_Duration (TS : timespec) return Duration is begin return Duration (TS.tv_sec) + Duration (TS.tv_nsec) / 10#1#E9; end To_Duration; ----------------- -- To_Timespec -- ----------------- function To_Timespec (D : Duration) return timespec is S : time_t; F : Duration; begin S := time_t (Long_Long_Integer (D)); F := D - Duration (S); -- If F has negative value due to a round-up, adjust for positive F -- value. if F < 0.0 then S := S - 1; F := F + 1.0; end if; return timespec'(tv_sec => S, tv_nsec => long (Long_Long_Integer (F * 10#1#E9))); end To_Timespec; ------------------------- -- POSIX.1c Section 3 -- ------------------------- function sigwait (set : access sigset_t; sig : access Signal) return int is Result : int; begin Result := sigwait (set); if Result = -1 then sig.all := 0; return errno; end if; sig.all := Signal (Result); return 0; end sigwait; -- DCE_THREADS does not have pthread_kill. Instead, we just ignore it function pthread_kill (thread : pthread_t; sig : Signal) return int is pragma Unreferenced (thread, sig); begin return 0; end pthread_kill; -------------------------- -- POSIX.1c Section 11 -- -------------------------- -- For all following functions, DCE Threads has a non standard behavior. -- It sets errno but the standard Posix requires it to be returned. function pthread_mutexattr_init (attr : access pthread_mutexattr_t) return int is function pthread_mutexattr_create (attr : access pthread_mutexattr_t) return int; pragma Import (C, pthread_mutexattr_create, "pthread_mutexattr_create"); begin if pthread_mutexattr_create (attr) /= 0 then return errno; else return 0; end if; end pthread_mutexattr_init; function pthread_mutexattr_destroy (attr : access pthread_mutexattr_t) return int is function pthread_mutexattr_delete (attr : access pthread_mutexattr_t) return int; pragma Import (C, pthread_mutexattr_delete, "pthread_mutexattr_delete"); begin if pthread_mutexattr_delete (attr) /= 0 then return errno; else return 0; end if; end pthread_mutexattr_destroy; function pthread_mutex_init (mutex : access pthread_mutex_t; attr : access pthread_mutexattr_t) return int is function pthread_mutex_init_base (mutex : access pthread_mutex_t; attr : pthread_mutexattr_t) return int; pragma Import (C, pthread_mutex_init_base, "pthread_mutex_init"); begin if pthread_mutex_init_base (mutex, attr.all) /= 0 then return errno; else return 0; end if; end pthread_mutex_init; function pthread_mutex_destroy (mutex : access pthread_mutex_t) return int is function pthread_mutex_destroy_base (mutex : access pthread_mutex_t) return int; pragma Import (C, pthread_mutex_destroy_base, "pthread_mutex_destroy"); begin if pthread_mutex_destroy_base (mutex) /= 0 then return errno; else return 0; end if; end pthread_mutex_destroy; function pthread_mutex_lock (mutex : access pthread_mutex_t) return int is function pthread_mutex_lock_base (mutex : access pthread_mutex_t) return int; pragma Import (C, pthread_mutex_lock_base, "pthread_mutex_lock"); begin if pthread_mutex_lock_base (mutex) /= 0 then return errno; else return 0; end if; end pthread_mutex_lock; function pthread_mutex_unlock (mutex : access pthread_mutex_t) return int is function pthread_mutex_unlock_base (mutex : access pthread_mutex_t) return int; pragma Import (C, pthread_mutex_unlock_base, "pthread_mutex_unlock"); begin if pthread_mutex_unlock_base (mutex) /= 0 then return errno; else return 0; end if; end pthread_mutex_unlock; function pthread_condattr_init (attr : access pthread_condattr_t) return int is function pthread_condattr_create (attr : access pthread_condattr_t) return int; pragma Import (C, pthread_condattr_create, "pthread_condattr_create"); begin if pthread_condattr_create (attr) /= 0 then return errno; else return 0; end if; end pthread_condattr_init; function pthread_condattr_destroy (attr : access pthread_condattr_t) return int is function pthread_condattr_delete (attr : access pthread_condattr_t) return int; pragma Import (C, pthread_condattr_delete, "pthread_condattr_delete"); begin if pthread_condattr_delete (attr) /= 0 then return errno; else return 0; end if; end pthread_condattr_destroy; function pthread_cond_init (cond : access pthread_cond_t; attr : access pthread_condattr_t) return int is function pthread_cond_init_base (cond : access pthread_cond_t; attr : pthread_condattr_t) return int; pragma Import (C, pthread_cond_init_base, "pthread_cond_init"); begin if pthread_cond_init_base (cond, attr.all) /= 0 then return errno; else return 0; end if; end pthread_cond_init; function pthread_cond_destroy (cond : access pthread_cond_t) return int is function pthread_cond_destroy_base (cond : access pthread_cond_t) return int; pragma Import (C, pthread_cond_destroy_base, "pthread_cond_destroy"); begin if pthread_cond_destroy_base (cond) /= 0 then return errno; else return 0; end if; end pthread_cond_destroy; function pthread_cond_signal (cond : access pthread_cond_t) return int is function pthread_cond_signal_base (cond : access pthread_cond_t) return int; pragma Import (C, pthread_cond_signal_base, "pthread_cond_signal"); begin if pthread_cond_signal_base (cond) /= 0 then return errno; else return 0; end if; end pthread_cond_signal; function pthread_cond_wait (cond : access pthread_cond_t; mutex : access pthread_mutex_t) return int is function pthread_cond_wait_base (cond : access pthread_cond_t; mutex : access pthread_mutex_t) return int; pragma Import (C, pthread_cond_wait_base, "pthread_cond_wait"); begin if pthread_cond_wait_base (cond, mutex) /= 0 then return errno; else return 0; end if; end pthread_cond_wait; function pthread_cond_timedwait (cond : access pthread_cond_t; mutex : access pthread_mutex_t; abstime : access timespec) return int is function pthread_cond_timedwait_base (cond : access pthread_cond_t; mutex : access pthread_mutex_t; abstime : access timespec) return int; pragma Import (C, pthread_cond_timedwait_base, "pthread_cond_timedwait"); begin if pthread_cond_timedwait_base (cond, mutex, abstime) /= 0 then return (if errno = EAGAIN then ETIMEDOUT else errno); else return 0; end if; end pthread_cond_timedwait; ---------------------------- -- POSIX.1c Section 13 -- ---------------------------- function pthread_setschedparam (thread : pthread_t; policy : int; param : access struct_sched_param) return int is function pthread_setscheduler (thread : pthread_t; policy : int; priority : int) return int; pragma Import (C, pthread_setscheduler, "pthread_setscheduler"); begin if pthread_setscheduler (thread, policy, param.sched_priority) = -1 then return errno; else return 0; end if; end pthread_setschedparam; function sched_yield return int is procedure pthread_yield; pragma Import (C, pthread_yield, "pthread_yield"); begin pthread_yield; return 0; end sched_yield; ----------------------------- -- P1003.1c - Section 16 -- ----------------------------- function pthread_attr_init (attributes : access pthread_attr_t) return int is function pthread_attr_create (attributes : access pthread_attr_t) return int; pragma Import (C, pthread_attr_create, "pthread_attr_create"); begin if pthread_attr_create (attributes) /= 0 then return errno; else return 0; end if; end pthread_attr_init; function pthread_attr_destroy (attributes : access pthread_attr_t) return int is function pthread_attr_delete (attributes : access pthread_attr_t) return int; pragma Import (C, pthread_attr_delete, "pthread_attr_delete"); begin if pthread_attr_delete (attributes) /= 0 then return errno; else return 0; end if; end pthread_attr_destroy; function pthread_attr_setstacksize (attr : access pthread_attr_t; stacksize : size_t) return int is function pthread_attr_setstacksize_base (attr : access pthread_attr_t; stacksize : size_t) return int; pragma Import (C, pthread_attr_setstacksize_base, "pthread_attr_setstacksize"); begin if pthread_attr_setstacksize_base (attr, stacksize) /= 0 then return errno; else return 0; end if; end pthread_attr_setstacksize; function pthread_create (thread : access pthread_t; attributes : access pthread_attr_t; start_routine : Thread_Body; arg : System.Address) return int is function pthread_create_base (thread : access pthread_t; attributes : pthread_attr_t; start_routine : Thread_Body; arg : System.Address) return int; pragma Import (C, pthread_create_base, "pthread_create"); begin if pthread_create_base (thread, attributes.all, start_routine, arg) /= 0 then return errno; else return 0; end if; end pthread_create; -------------------------- -- POSIX.1c Section 17 -- -------------------------- function pthread_setspecific (key : pthread_key_t; value : System.Address) return int is function pthread_setspecific_base (key : pthread_key_t; value : System.Address) return int; pragma Import (C, pthread_setspecific_base, "pthread_setspecific"); begin if pthread_setspecific_base (key, value) /= 0 then return errno; else return 0; end if; end pthread_setspecific; function pthread_getspecific (key : pthread_key_t) return System.Address is function pthread_getspecific_base (key : pthread_key_t; value : access System.Address) return int; pragma Import (C, pthread_getspecific_base, "pthread_getspecific"); Addr : aliased System.Address; begin if pthread_getspecific_base (key, Addr'Access) /= 0 then return System.Null_Address; else return Addr; end if; end pthread_getspecific; function pthread_key_create (key : access pthread_key_t; destructor : destructor_pointer) return int is function pthread_keycreate (key : access pthread_key_t; destructor : destructor_pointer) return int; pragma Import (C, pthread_keycreate, "pthread_keycreate"); begin if pthread_keycreate (key, destructor) /= 0 then return errno; else return 0; end if; end pthread_key_create; function Get_Stack_Base (thread : pthread_t) return Address is pragma Warnings (Off, thread); begin return Null_Address; end Get_Stack_Base; procedure pthread_init is begin null; end pthread_init; function intr_attach (sig : int; handler : isr_address) return long is function c_signal (sig : int; handler : isr_address) return long; pragma Import (C, c_signal, "signal"); begin return c_signal (sig, handler); end intr_attach; end System.OS_Interface;
reznikmm/matreshka
Ada
22,586
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.Internals.OCL_Elements; with AMF.OCL.Expression_In_Ocls; with AMF.OCL.Ocl_Expressions; with AMF.OCL.Variables.Collections; with AMF.String_Collections; with AMF.UML.Behaviors; with AMF.UML.Classifiers; with AMF.UML.Comments.Collections; with AMF.UML.Dependencies.Collections; with AMF.UML.Elements.Collections; with AMF.UML.Named_Elements; with AMF.UML.Namespaces.Collections; with AMF.UML.Packages.Collections; with AMF.UML.Parameterable_Elements; with AMF.UML.Parameters; with AMF.UML.String_Expressions; with AMF.UML.Template_Parameters; with AMF.UML.Types; with AMF.Visitors; package AMF.Internals.OCL_Expression_In_Ocls is type OCL_Expression_In_Ocl_Proxy is limited new AMF.Internals.OCL_Elements.OCL_Element_Proxy and AMF.OCL.Expression_In_Ocls.OCL_Expression_In_Ocl with null record; overriding function Get_Body_Expression (Self : not null access constant OCL_Expression_In_Ocl_Proxy) return AMF.OCL.Ocl_Expressions.OCL_Ocl_Expression_Access; -- Getter of ExpressionInOcl::bodyExpression. -- overriding procedure Set_Body_Expression (Self : not null access OCL_Expression_In_Ocl_Proxy; To : AMF.OCL.Ocl_Expressions.OCL_Ocl_Expression_Access); -- Setter of ExpressionInOcl::bodyExpression. -- overriding function Get_Context_Variable (Self : not null access constant OCL_Expression_In_Ocl_Proxy) return AMF.OCL.Variables.OCL_Variable_Access; -- Getter of ExpressionInOcl::contextVariable. -- overriding procedure Set_Context_Variable (Self : not null access OCL_Expression_In_Ocl_Proxy; To : AMF.OCL.Variables.OCL_Variable_Access); -- Setter of ExpressionInOcl::contextVariable. -- overriding function Get_Result_Variable (Self : not null access constant OCL_Expression_In_Ocl_Proxy) return AMF.OCL.Variables.OCL_Variable_Access; -- Getter of ExpressionInOcl::resultVariable. -- overriding procedure Set_Result_Variable (Self : not null access OCL_Expression_In_Ocl_Proxy; To : AMF.OCL.Variables.OCL_Variable_Access); -- Setter of ExpressionInOcl::resultVariable. -- overriding function Get_Parameter_Variable (Self : not null access constant OCL_Expression_In_Ocl_Proxy) return AMF.OCL.Variables.Collections.Ordered_Set_Of_OCL_Variable; -- Getter of ExpressionInOcl::parameterVariable. -- overriding function Get_Generated_Type (Self : not null access constant OCL_Expression_In_Ocl_Proxy) return AMF.UML.Classifiers.UML_Classifier_Access; -- Getter of ExpressionInOcl::generatedType. -- overriding procedure Set_Generated_Type (Self : not null access OCL_Expression_In_Ocl_Proxy; To : AMF.UML.Classifiers.UML_Classifier_Access); -- Setter of ExpressionInOcl::generatedType. -- overriding function Get_Behavior (Self : not null access constant OCL_Expression_In_Ocl_Proxy) return AMF.UML.Behaviors.UML_Behavior_Access; -- Getter of OpaqueExpression::behavior. -- -- Specifies the behavior of the opaque expression. overriding procedure Set_Behavior (Self : not null access OCL_Expression_In_Ocl_Proxy; To : AMF.UML.Behaviors.UML_Behavior_Access); -- Setter of OpaqueExpression::behavior. -- -- Specifies the behavior of the opaque expression. overriding function Get_Body (Self : not null access constant OCL_Expression_In_Ocl_Proxy) return AMF.String_Collections.Sequence_Of_String; -- Getter of OpaqueExpression::body. -- -- The text of the expression, possibly in multiple languages. overriding function Get_Language (Self : not null access constant OCL_Expression_In_Ocl_Proxy) return AMF.String_Collections.Ordered_Set_Of_String; -- Getter of OpaqueExpression::language. -- -- Specifies the languages in which the expression is stated. The -- interpretation of the expression body depends on the languages. If the -- languages are unspecified, they might be implicit from the expression -- body or the context. Languages are matched to body strings by order. overriding function Get_Result (Self : not null access constant OCL_Expression_In_Ocl_Proxy) return AMF.UML.Parameters.UML_Parameter_Access; -- Getter of OpaqueExpression::result. -- -- Restricts an opaque expression to return exactly one return result. -- When the invocation of the opaque expression completes, a single set of -- values is returned to its owner. This association is derived from the -- single return result parameter of the associated behavior. overriding function Get_Type (Self : not null access constant OCL_Expression_In_Ocl_Proxy) return AMF.UML.Types.UML_Type_Access; -- Getter of TypedElement::type. -- -- The type of the TypedElement. -- This information is derived from the return result for this Operation. overriding procedure Set_Type (Self : not null access OCL_Expression_In_Ocl_Proxy; To : AMF.UML.Types.UML_Type_Access); -- Setter of TypedElement::type. -- -- The type of the TypedElement. -- This information is derived from the return result for this Operation. overriding function Get_Client_Dependency (Self : not null access constant OCL_Expression_In_Ocl_Proxy) return AMF.UML.Dependencies.Collections.Set_Of_UML_Dependency; -- Getter of NamedElement::clientDependency. -- -- Indicates the dependencies that reference the client. overriding function Get_Name (Self : not null access constant OCL_Expression_In_Ocl_Proxy) return AMF.Optional_String; -- Getter of NamedElement::name. -- -- The name of the NamedElement. overriding procedure Set_Name (Self : not null access OCL_Expression_In_Ocl_Proxy; To : AMF.Optional_String); -- Setter of NamedElement::name. -- -- The name of the NamedElement. overriding function Get_Name_Expression (Self : not null access constant OCL_Expression_In_Ocl_Proxy) return AMF.UML.String_Expressions.UML_String_Expression_Access; -- Getter of NamedElement::nameExpression. -- -- The string expression used to define the name of this named element. overriding procedure Set_Name_Expression (Self : not null access OCL_Expression_In_Ocl_Proxy; To : AMF.UML.String_Expressions.UML_String_Expression_Access); -- Setter of NamedElement::nameExpression. -- -- The string expression used to define the name of this named element. overriding function Get_Namespace (Self : not null access constant OCL_Expression_In_Ocl_Proxy) return AMF.UML.Namespaces.UML_Namespace_Access; -- Getter of NamedElement::namespace. -- -- Specifies the namespace that owns the NamedElement. overriding function Get_Qualified_Name (Self : not null access constant OCL_Expression_In_Ocl_Proxy) return AMF.Optional_String; -- Getter of NamedElement::qualifiedName. -- -- A name which allows the NamedElement to be identified within a -- hierarchy of nested Namespaces. It is constructed from the names of the -- containing namespaces starting at the root of the hierarchy and ending -- with the name of the NamedElement itself. overriding function Get_Visibility (Self : not null access constant OCL_Expression_In_Ocl_Proxy) return AMF.UML.Optional_UML_Visibility_Kind; -- Getter of NamedElement::visibility. -- -- Determines where the NamedElement appears within different Namespaces -- within the overall model, and its accessibility. overriding procedure Set_Visibility (Self : not null access OCL_Expression_In_Ocl_Proxy; To : AMF.UML.Optional_UML_Visibility_Kind); -- Setter of NamedElement::visibility. -- -- Determines where the NamedElement appears within different Namespaces -- within the overall model, and its accessibility. overriding function Get_Owned_Comment (Self : not null access constant OCL_Expression_In_Ocl_Proxy) return AMF.UML.Comments.Collections.Set_Of_UML_Comment; -- Getter of Element::ownedComment. -- -- The Comments owned by this element. overriding function Get_Owned_Element (Self : not null access constant OCL_Expression_In_Ocl_Proxy) return AMF.UML.Elements.Collections.Set_Of_UML_Element; -- Getter of Element::ownedElement. -- -- The Elements owned by this element. overriding function Get_Owner (Self : not null access constant OCL_Expression_In_Ocl_Proxy) return AMF.UML.Elements.UML_Element_Access; -- Getter of Element::owner. -- -- The Element that owns this element. overriding function Get_Visibility (Self : not null access constant OCL_Expression_In_Ocl_Proxy) return AMF.UML.UML_Visibility_Kind; -- Getter of PackageableElement::visibility. -- -- Indicates that packageable elements must always have a visibility, -- i.e., visibility is not optional. overriding procedure Set_Visibility (Self : not null access OCL_Expression_In_Ocl_Proxy; To : AMF.UML.UML_Visibility_Kind); -- Setter of PackageableElement::visibility. -- -- Indicates that packageable elements must always have a visibility, -- i.e., visibility is not optional. overriding function Get_Owning_Template_Parameter (Self : not null access constant OCL_Expression_In_Ocl_Proxy) return AMF.UML.Template_Parameters.UML_Template_Parameter_Access; -- Getter of ParameterableElement::owningTemplateParameter. -- -- The formal template parameter that owns this element. overriding procedure Set_Owning_Template_Parameter (Self : not null access OCL_Expression_In_Ocl_Proxy; To : AMF.UML.Template_Parameters.UML_Template_Parameter_Access); -- Setter of ParameterableElement::owningTemplateParameter. -- -- The formal template parameter that owns this element. overriding function Get_Template_Parameter (Self : not null access constant OCL_Expression_In_Ocl_Proxy) return AMF.UML.Template_Parameters.UML_Template_Parameter_Access; -- Getter of ParameterableElement::templateParameter. -- -- The template parameter that exposes this element as a formal parameter. overriding procedure Set_Template_Parameter (Self : not null access OCL_Expression_In_Ocl_Proxy; To : AMF.UML.Template_Parameters.UML_Template_Parameter_Access); -- Setter of ParameterableElement::templateParameter. -- -- The template parameter that exposes this element as a formal parameter. overriding function Is_Integral (Self : not null access constant OCL_Expression_In_Ocl_Proxy) return Boolean; -- Operation OpaqueExpression::isIntegral. -- -- The query isIntegral() tells whether an expression is intended to -- produce an integer. overriding function Is_Non_Negative (Self : not null access constant OCL_Expression_In_Ocl_Proxy) return Boolean; -- Operation OpaqueExpression::isNonNegative. -- -- The query isNonNegative() tells whether an integer expression has a -- non-negative value. overriding function Is_Positive (Self : not null access constant OCL_Expression_In_Ocl_Proxy) return Boolean; -- Operation OpaqueExpression::isPositive. -- -- The query isPositive() tells whether an integer expression has a -- positive value. overriding function Result (Self : not null access constant OCL_Expression_In_Ocl_Proxy) return AMF.UML.Parameters.UML_Parameter_Access; -- Operation OpaqueExpression::result. -- -- Missing derivation for OpaqueExpression::/result : Parameter overriding function Value (Self : not null access constant OCL_Expression_In_Ocl_Proxy) return Integer; -- Operation OpaqueExpression::value. -- -- The query value() gives an integer value for an expression intended to -- produce one. overriding function Boolean_Value (Self : not null access constant OCL_Expression_In_Ocl_Proxy) return AMF.Optional_Boolean; -- Operation ValueSpecification::booleanValue. -- -- The query booleanValue() gives a single Boolean value when one can be -- computed. overriding function Integer_Value (Self : not null access constant OCL_Expression_In_Ocl_Proxy) return AMF.Optional_Integer; -- Operation ValueSpecification::integerValue. -- -- The query integerValue() gives a single Integer value when one can be -- computed. overriding function Is_Compatible_With (Self : not null access constant OCL_Expression_In_Ocl_Proxy; P : AMF.UML.Parameterable_Elements.UML_Parameterable_Element_Access) return Boolean; -- Operation ValueSpecification::isCompatibleWith. -- -- The query isCompatibleWith() determines if this parameterable element -- is compatible with the specified parameterable element. By default -- parameterable element P is compatible with parameterable element Q if -- the kind of P is the same or a subtype as the kind of Q. In addition, -- for ValueSpecification, the type must be conformant with the type of -- the specified parameterable element. overriding function Is_Computable (Self : not null access constant OCL_Expression_In_Ocl_Proxy) return Boolean; -- Operation ValueSpecification::isComputable. -- -- The query isComputable() determines whether a value specification can -- be computed in a model. This operation cannot be fully defined in OCL. -- A conforming implementation is expected to deliver true for this -- operation for all value specifications that it can compute, and to -- compute all of those for which the operation is true. A conforming -- implementation is expected to be able to compute the value of all -- literals. overriding function Is_Null (Self : not null access constant OCL_Expression_In_Ocl_Proxy) return Boolean; -- Operation ValueSpecification::isNull. -- -- The query isNull() returns true when it can be computed that the value -- is null. overriding function Real_Value (Self : not null access constant OCL_Expression_In_Ocl_Proxy) return AMF.Optional_Real; -- Operation ValueSpecification::realValue. -- -- The query realValue() gives a single Real value when one can be -- computed. overriding function String_Value (Self : not null access constant OCL_Expression_In_Ocl_Proxy) return AMF.Optional_String; -- Operation ValueSpecification::stringValue. -- -- The query stringValue() gives a single String value when one can be -- computed. overriding function Unlimited_Value (Self : not null access constant OCL_Expression_In_Ocl_Proxy) return AMF.Optional_Unlimited_Natural; -- Operation ValueSpecification::unlimitedValue. -- -- The query unlimitedValue() gives a single UnlimitedNatural value when -- one can be computed. overriding function All_Namespaces (Self : not null access constant OCL_Expression_In_Ocl_Proxy) return AMF.UML.Namespaces.Collections.Ordered_Set_Of_UML_Namespace; -- Operation NamedElement::allNamespaces. -- -- The query allNamespaces() gives the sequence of namespaces in which the -- NamedElement is nested, working outwards. overriding function All_Owning_Packages (Self : not null access constant OCL_Expression_In_Ocl_Proxy) return AMF.UML.Packages.Collections.Set_Of_UML_Package; -- Operation NamedElement::allOwningPackages. -- -- The query allOwningPackages() returns all the directly or indirectly -- owning packages. overriding function Is_Distinguishable_From (Self : not null access constant OCL_Expression_In_Ocl_Proxy; N : AMF.UML.Named_Elements.UML_Named_Element_Access; Ns : AMF.UML.Namespaces.UML_Namespace_Access) return Boolean; -- Operation NamedElement::isDistinguishableFrom. -- -- The query isDistinguishableFrom() determines whether two NamedElements -- may logically co-exist within a Namespace. By default, two named -- elements are distinguishable if (a) they have unrelated types or (b) -- they have related types but different names. overriding function Namespace (Self : not null access constant OCL_Expression_In_Ocl_Proxy) return AMF.UML.Namespaces.UML_Namespace_Access; -- Operation NamedElement::namespace. -- -- Missing derivation for NamedElement::/namespace : Namespace overriding function Qualified_Name (Self : not null access constant OCL_Expression_In_Ocl_Proxy) return League.Strings.Universal_String; -- Operation NamedElement::qualifiedName. -- -- When there is a name, and all of the containing namespaces have a name, -- the qualified name is constructed from the names of the containing -- namespaces. overriding function Separator (Self : not null access constant OCL_Expression_In_Ocl_Proxy) return League.Strings.Universal_String; -- Operation NamedElement::separator. -- -- The query separator() gives the string that is used to separate names -- when constructing a qualified name. overriding function All_Owned_Elements (Self : not null access constant OCL_Expression_In_Ocl_Proxy) return AMF.UML.Elements.Collections.Set_Of_UML_Element; -- Operation Element::allOwnedElements. -- -- The query allOwnedElements() gives all of the direct and indirect owned -- elements of an element. overriding function Must_Be_Owned (Self : not null access constant OCL_Expression_In_Ocl_Proxy) return Boolean; -- Operation Element::mustBeOwned. -- -- The query mustBeOwned() indicates whether elements of this type must -- have an owner. Subclasses of Element that do not require an owner must -- override this operation. overriding function Is_Template_Parameter (Self : not null access constant OCL_Expression_In_Ocl_Proxy) return Boolean; -- Operation ParameterableElement::isTemplateParameter. -- -- The query isTemplateParameter() determines if this parameterable -- element is exposed as a formal template parameter. overriding procedure Enter_Element (Self : not null access constant OCL_Expression_In_Ocl_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); overriding procedure Leave_Element (Self : not null access constant OCL_Expression_In_Ocl_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); overriding procedure Visit_Element (Self : not null access constant OCL_Expression_In_Ocl_Proxy; Iterator : in out AMF.Visitors.Abstract_Iterator'Class; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); end AMF.Internals.OCL_Expression_In_Ocls;
reinertk/cpros
Ada
5,851
adb
-------------------------------------------------------------------------------------- -- -- Copyright (c) 2016 Reinert Korsnes -- 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. -- -- NB: this is the MIT License, as found 2016-09-27 on the site -- http://www.opensource.org/licenses/mit-license.php -------------------------------------------------------------------------------------- -- Change log: -- 2020.06.14: Major upgrade (by Reinert Korsnes) -------------------------------------------------------------------------------------- with split_string; use split_string; with Ada.Strings.Fixed; use Ada.Strings.Fixed; with Ada.IO_Exceptions; with Ada.Exceptions; use Ada.Exceptions; package body cpros is procedure cpros0 (file1 : in File_Type; command_string : String := "") is term1 : constant Boolean := file1 in Ada.Text_IO.Standard_Input; function rep1 (str0 : String) return String is i : constant Natural := Index (str0, "$"); begin if i = 0 then return str0; elsif i = str0'Last then raise cfe0; else declare k : constant Positive := Positive'Value (str0 (i + 1 .. i + 1)); begin return str0 (str0'First .. i - 1) & word (command_string, k + 2) & (if i + 2 < str0'Last then rep1 (str0 (i + 2 .. str0'Last)) else ""); end; end if; exception when others => Put_Line ("* Command format error (wrong use of '$') *"); raise cfe0; end rep1; begin command_loop : loop if term1 then Put ("Enter command:"); else exit command_loop when End_Of_File (file1); end if; begin declare str0 : constant String := rep1 (Get_Line (file1)); str1 : constant String := expand1 (remove_comment1 (str0), "&"); type aux_commands1_t is (c_do, c_repeat, c_exit, c_none); function aux_command1 (s : String) return aux_commands1_t is begin return aux_commands1_t'Value ("C_" & s); exception when others => return c_none; end aux_command1; acom1 : constant aux_commands1_t := aux_command1 (first_word (str1)); begin if not term1 then Put_Line (str0); end if; if number_of_words (str1) > 0 then exit command_loop when acom1 = c_exit; if acom1 in c_do | c_repeat then do_loop : loop declare cfile2 : constant String := word (str1, 2); file2 : File_Type; begin Open (file2, In_File, cfile2); cpros0 (file1 => file2, command_string => str1); Close (File => file2); exception when event : Name_Error => New_Line; Put_Line (Exception_Message (event)); New_Line; raise cfe0; when others => Close (File => file2); raise cfe0; end; exit do_loop when acom1 /= c_repeat; end loop do_loop; else begin cpros_main (command => c_t'Value ("C_" & first_word (str1)), str => str1); exception when Constraint_Error => Put_Line (" * Unknown command: " & first_word (str1)); raise cfe0; when event : cfe0 => New_Line; Put_Line ("* Command format error *"); Put_Line (Exception_Message (event)); raise; end; end if; end if; end; exception when cfe0 => if not term1 then raise; end if; end; end loop command_loop; return; exception when Ada.IO_Exceptions.End_Error => return; when cfe0 => if not term1 then raise; end if; end cpros0; end cpros;
jhumphry/PRNG_Zoo
Ada
1,964
adb
-- -- PRNG Zoo -- Copyright (c) 2014 - 2015, 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. package body PRNG_Zoo is -------------- -- Generate -- -------------- function Generate (G: in out PRNG_32Only) return U64 is R1 : constant U32 := Generate(PRNG_32Only'Class(G)); R2 : constant U32 := Generate(PRNG_32Only'Class(G)); begin return Shift_Left(U64(R1), 32) or U64(R2); end Generate; --------------------- -- Generate_Padded -- --------------------- function Generate_Padded (G: in out PRNG_32Only) return U64 is begin return U64(U32'(Generate(PRNG_32Only'Class(G)))); end Generate_Padded; --------------------- -- Generate_Padded -- --------------------- function Generate_Padded (G: in out PRNG_64Only) return U64 is begin return U64'(Generate(PRNG_64Only'Class(G))); end Generate_Padded; -------------- -- Generate -- -------------- function Generate (G: in out PRNG_64Only) return U32 is begin return U32(U64'(Generate(PRNG_64Only'Class(G))) and 16#FFFFFFFF#); end Generate; ----------- -- Reset -- ----------- procedure Reset(G: in out Dispatcher; S: in U64) is begin Reset(G.IG.all, S); end Reset; end PRNG_Zoo;
sebsgit/textproc
Ada
987
adb
with MathUtils; package body DataBatch is function size(b: in Batch) return Natural is begin return Natural(b.data.Length); end size; procedure randomize(b: in out Batch) is steps: constant Natural := b.size * 2; i1, i2: Positive; begin for i in 0 .. steps loop i1 := Positive(MathUtils.rand(Float(b.data.First_Index), Float(b.data.Last_Index))); i2 := Positive(MathUtils.rand(Float(b.data.First_Index), Float(b.data.Last_Index))); b.data.Swap(i1, i2); end loop; end randomize; procedure reserve(b: in out Batch; count: Positive) is begin b.data.Reserve_Capacity(Capacity => Ada.Containers.Count_Type(count)); end reserve; procedure append(b: in out Batch; vec: MathUtils.Vector) is begin b.data.Append(vec); end append; function contains(b: in Batch; vec: in MathUtils.Vector) return Boolean is begin return b.data.Contains(vec); end contains; end DataBatch;
reznikmm/matreshka
Ada
4,239
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Web Framework -- -- -- -- Tools Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 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 Asis.Expressions; package body Properties.Expressions.Slice is ---------- -- Code -- ---------- function Code (Engine : access Engines.Contexts.Context; Element : Asis.Expression; Name : Engines.Text_Property) return League.Strings.Universal_String is Text : League.Strings.Universal_String; Down : League.Strings.Universal_String; Child : constant Asis.Discrete_Range := Asis.Expressions.Slice_Range (Element); begin Down := Engine.Text.Get_Property (Asis.Expressions.Prefix (Element), Name); Text.Append (Down); Text.Append ("._slice("); Text.Append (Engine.Text.Get_Property (Child, Engines.Lower)); Text.Append (", "); Text.Append (Engine.Text.Get_Property (Child, Engines.Upper)); Text.Append (")"); return Text; end Code; end Properties.Expressions.Slice;
zhmu/ananas
Ada
218
adb
-- { dg-do compile } with Renaming16_Pkg; use Renaming16_Pkg; procedure Renaming16 is Results : Bindings_Query_Results_Type; begin for I in Create_Bindings_Iterator (Results) loop null; end loop; end;
AdaCore/Ada_Drivers_Library
Ada
5,472
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 HAL.Bitmap; package HAL.Framebuffer is pragma Preelaborate; subtype FB_Color_Mode is HAL.Bitmap.Bitmap_Color_Mode range HAL.Bitmap.ARGB_8888 .. HAL.Bitmap.M_1; type Display_Orientation is (Default, Landscape, Portrait); type Wait_Mode is (Polling, Interrupt); type Frame_Buffer_Display is limited interface; type Any_Frame_Buffer_Display is access all Frame_Buffer_Display'Class; function Max_Layers (This : Frame_Buffer_Display) return Positive is abstract; function Supported (This : Frame_Buffer_Display; Mode : FB_Color_Mode) return Boolean is abstract; procedure Set_Orientation (This : in out Frame_Buffer_Display; Orientation : Display_Orientation) is abstract; procedure Set_Mode (This : in out Frame_Buffer_Display; Mode : Wait_Mode) is abstract; function Initialized (This : Frame_Buffer_Display) return Boolean is abstract; function Width (This : Frame_Buffer_Display) return Positive is abstract; function Height (This : Frame_Buffer_Display) return Positive is abstract; function Swapped (This : Frame_Buffer_Display) return Boolean is abstract; -- Whether X/Y coordinates are considered Swapped by the drawing primitives -- This simulates Landscape/Portrait orientation on displays not supporting -- hardware orientation change. procedure Set_Background (This : Frame_Buffer_Display; R, G, B : UInt8) is abstract; procedure Initialize_Layer (This : in out Frame_Buffer_Display; Layer : Positive; Mode : FB_Color_Mode; X : Natural := 0; Y : Natural := 0; Width : Positive := Positive'Last; Height : Positive := Positive'Last) is abstract; -- All layers are double buffered, so an explicit call to Update_Layer -- needs to be performed to actually display the current buffer attached -- to the layer. -- Alloc is called to create the actual buffer. function Initialized (This : Frame_Buffer_Display; Layer : Positive) return Boolean is abstract; procedure Update_Layer (This : in out Frame_Buffer_Display; Layer : Positive; Copy_Back : Boolean := False) is abstract; -- Updates the layer so that the hidden buffer is displayed. procedure Update_Layers (This : in out Frame_Buffer_Display) is abstract; -- Updates all initialized layers at once with their respective hidden -- buffer. function Color_Mode (This : Frame_Buffer_Display; Layer : Positive) return FB_Color_Mode is abstract; -- Retrieves the current color mode for the layer. function Hidden_Buffer (This : in out Frame_Buffer_Display; Layer : Positive) return not null HAL.Bitmap.Any_Bitmap_Buffer is abstract; -- Retrieves the current hidden buffer for the layer. function Pixel_Size (Display : Frame_Buffer_Display; Layer : Positive) return Positive is abstract; -- Retrieves the current hidden buffer for the layer. end HAL.Framebuffer;
charlie5/lace
Ada
8,135
adb
with eGL.binding; with openGL.Display.privvy; with Interfaces.C; package body opengl.surface_Profile is use openGL.Display.privvy, eGL, eGL.Binding, Interfaces; subtype egl_attribute_List is EGLint_array; function to_egl_Attributes (Desired : Qualities) return egl_attribute_List is use C; the_Attributes : egl_attribute_List (1 .. 50); Count : c.size_t := 0; procedure add (Attribute : in EGLint; Value : in EGLint) is begin Count := Count + 1; the_Attributes (Count) := Attribute; Count := Count + 1; the_Attributes (Count) := Value; end add; begin add (EGL_SURFACE_TYPE, EGL_WINDOW_BIT); add (EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT); if desired.color_Buffer.Bits_blue /= Irrelevant then add (EGL_BLUE_SIZE, EGLint (desired.color_Buffer.Bits_blue)); end if; if desired.color_Buffer.Bits_green /= Irrelevant then add (EGL_GREEN_SIZE, EGLint (desired.color_Buffer.Bits_green)); end if; if desired.color_Buffer.Bits_luminence /= Irrelevant then add (EGL_LUMINANCE_SIZE, EGLint (desired.color_Buffer.Bits_luminence)); end if; if desired.color_Buffer.Bits_alpha /= Irrelevant then add (EGL_ALPHA_SIZE, EGLint (desired.color_Buffer.Bits_alpha)); end if; if desired.color_Buffer.Bits_alpha_mask /= Irrelevant then add (EGL_ALPHA_MASK_SIZE, EGLint (desired.color_Buffer.Bits_alpha_mask)); end if; if desired.depth_buffer_Bits /= Irrelevant then add (EGL_DEPTH_SIZE, EGLint (desired.depth_buffer_Bits)); end if; if desired.stencil_buffer_Bits /= Irrelevant then add (EGL_STENCIL_SIZE, EGLint (desired.stencil_buffer_Bits)); end if; Count := Count + 1; the_Attributes (Count) := EGL_NONE; -- add 'end-of-list' token return the_Attributes (1 .. Count); end to_egl_Attributes; procedure define (Self : in out Item; the_Display : access opengl.Display.item'Class; Screen : access openGL.Screen .item'Class; Desired : in Qualities := default_Qualities) is use C; config_Count : aliased EGLint; attribList : egl_attribute_List := to_egl_Attributes (Desired); Success : EGLBoolean; begin Self.Display := the_Display; Success := eglChooseConfig (to_eGL (the_Display.all), attribList (attribList'First)'Unchecked_Access, self.egl_Config 'Unchecked_Access, 1, config_Count 'Unchecked_Access); if Success = EGL_FALSE then raise opengl.Error with "eglChooseConfig failed"; end if; if config_Count = 0 then raise desired_Qualitites_unavailable; end if; end define; function fetch_All (the_Display : access opengl.Display.item'class) return surface_Profile.items is use type EGLBoolean; Count : aliased EGLint; Success : EGLBoolean := eglGetConfigs (to_eGL (the_Display.all), null, 1, Count'Unchecked_Access); begin if Success = EGL_FALSE then raise opengl.Error with "Failed to get egl Config count."; end if; if Count = 0 then raise opengl.Error with "Found zero egl Configs."; end if; declare egl_Configs : array (1 .. Count) of aliased EGLConfig; the_Profiles : surface_Profile.items (1 .. Positive (Count)); begin Success := eglGetConfigs (to_eGL (the_Display.all), egl_Configs (1)'Unchecked_Access, Count, Count'Unchecked_Access); if Success = EGL_FALSE then raise opengl.Error with "Failed to get egl Configs."; end if; for Each in the_Profiles'Range loop the_Profiles (Each).egl_Config := egl_Configs (EGLint (Each)); the_Profiles (Each).Display := the_Display; end loop; return the_Profiles; end; end fetch_All; function Quality (Self : in Item) return Qualities is the_Qualities : Qualities; Success : EGLBoolean; Value : aliased EGLint; procedure check_Success is use type EGLBoolean; begin if Success = EGL_FALSE then raise openGL.Error with "Unable to get eGL surface configuration attribute."; end if; end check_Success; procedure set_Value (Attribute : out Natural) is begin if Value = EGL_DONT_CARE then Attribute := Irrelevant; else Attribute := Natural (Value); end if; end set_Value; begin Success := eglGetConfigAttrib (to_eGL (Self.Display.all), Self.egl_Config, EGL_RED_SIZE, Value'Unchecked_Access); check_Success; set_Value (the_Qualities.color_Buffer.Bits_red); Success := eglGetConfigAttrib (to_eGL (Self.Display.all), Self.egl_Config, EGL_GREEN_SIZE, Value'Unchecked_Access); check_Success; set_Value (the_Qualities.color_Buffer.Bits_green); Success := eglGetConfigAttrib (to_eGL (Self.Display.all), Self.egl_Config, EGL_BLUE_SIZE, Value'Unchecked_Access); check_Success; set_Value (the_Qualities.color_Buffer.Bits_blue); Success := eglGetConfigAttrib (to_eGL (Self.Display.all), Self.egl_Config, EGL_LUMINANCE_SIZE, Value'Unchecked_Access); check_Success; set_Value (the_Qualities.color_Buffer.Bits_luminence); Success := eglGetConfigAttrib (to_eGL (Self.Display.all), Self.egl_Config, EGL_ALPHA_SIZE, Value'Unchecked_Access); check_Success; set_Value (the_Qualities.color_Buffer.Bits_alpha); Success := eglGetConfigAttrib (to_eGL (Self.Display.all), Self.egl_Config, EGL_ALPHA_MASK_SIZE, Value'Unchecked_Access); check_Success; set_Value (the_Qualities.color_Buffer.Bits_alpha_mask); Success := eglGetConfigAttrib (to_eGL (Self.Display.all), Self.egl_Config, EGL_DEPTH_SIZE, Value'Unchecked_Access); check_Success; set_Value (the_Qualities.depth_buffer_Bits); Success := eglGetConfigAttrib (to_eGL (Self.Display.all), Self.egl_Config, EGL_STENCIL_SIZE, Value'Unchecked_Access); check_Success; set_Value (the_Qualities.stencil_buffer_Bits); return the_Qualities; end Quality; function value_Image (Value : in Natural) return String is begin if Value = Irrelevant then return "Irrelevant"; else return Natural'Image (Value); end if; end value_Image; function Image (Self : in color_Buffer) return String is begin return "Bits_red =>" & value_Image (Self.Bits_red) & " Bits_green =>" & value_Image (Self.Bits_green) & " Bits_blue =>" & value_Image (Self.Bits_blue) & " Bits_luminence =>" & value_Image (Self.Bits_luminence) & " Bits_alpha =>" & value_Image (Self.Bits_alpha) & " Bits_alpha_mask =>" & value_Image (Self.Bits_alpha_mask); end Image; function Image (Self : in Qualities) return String is begin return Image (Self.color_Buffer) & " depth_buffer_Bits =>" & value_Image (Self.depth_buffer_Bits) & " stencil_buffer_Bits => " & value_Image (Self.stencil_buffer_Bits); end Image; end opengl.surface_Profile;
UCL-RITS/pi_examples
Ada
929
adb
with Ada.Text_IO; use Ada.Text_IO; with Ada.Calendar; use Ada.Calendar; with Ada.Command_Line; use Ada.Command_line; procedure Pi is n, i : Long_Integer; sum, x, slice, mp, rt : Long_Float; start, stop : Time; begin n:=1000000000; -- Parsing arguments is relatively painless. if Argument_Count > 0 then n:=Long_Integer'Value(Argument(1)); end if; Put_Line ("Calculating PI using:" & Long_Integer'Image(n) & " slices"); start:=Clock; sum:=0.0; slice:=1.0/Long_Float(n); -- Doing loop this way because it's not clear how to use Long_Integer in a for -- loop in Ada. i:=1; loop x:=(Long_Float(i) - 0.5)*slice; sum:=sum + (4.0/(1.0 + (x*x))); i:=i+1; exit when i>n; end loop; mp:=sum * slice; stop:=Clock; rt:=Long_Float(stop - start); Put_Line ("Obtained value of PI:" & Long_Float'Image(mp)); Put_Line ("Time taken:" & Long_Float'Image(rt) & " seconds"); end Pi;
reznikmm/matreshka
Ada
4,645
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.Escape_Processing_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Db_Escape_Processing_Attribute_Node is begin return Self : Db_Escape_Processing_Attribute_Node do Matreshka.ODF_Db.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Db_Prefix); end return; end Create; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Db_Escape_Processing_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Escape_Processing_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Db_URI, Matreshka.ODF_String_Constants.Escape_Processing_Attribute, Db_Escape_Processing_Attribute_Node'Tag); end Matreshka.ODF_Db.Escape_Processing_Attributes;
fractal-mind/Amass
Ada
612
ads
-- Copyright 2017-2021 Jeff Foley. All rights reserved. -- Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. local url = require("url") name = "ArchiveIt" type = "archive" function start() set_rate_limit(2) end function vertical(ctx, domain) scrape(ctx, {['url']=build_url(domain)}) end function build_url(domain) local params = { ['url']=domain, ['matchType']="domain", ['fl']="original", ['collapse']="urlkey", } return "https://wayback.archive-it.org/all/timemap/cdx?" .. url.build_query_string(params) end
reznikmm/matreshka
Ada
7,015
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Web Framework -- -- -- -- Tools Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 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 Asis.Declarations; with Asis.Elements; with Asis.Expressions; with Properties.Tools; package body Properties.Declarations.Package_Instantiation is function Is_Predefined (Name : Asis.Expression) return Boolean; ---------- -- Code -- ---------- function Code (Engine : access Engines.Contexts.Context; Element : Asis.Declaration; Name : Engines.Text_Property) return League.Strings.Universal_String is Generic_Name : constant Asis.Expression := Asis.Declarations.Generic_Unit_Name (Element); Spec : constant Asis.Declaration := Asis.Declarations.Corresponding_Declaration (Element); Text : League.Strings.Universal_String; Down : League.Strings.Universal_String; Named : League.Strings.Universal_String; Is_Library_Level : constant Boolean := Asis.Elements.Is_Nil (Asis.Elements.Enclosing_Element (Element)); Inside_Package : constant Boolean := Engine.Boolean.Get_Property (Element, Engines.Inside_Package); begin Named := Engine.Text.Get_Property (Asis.Declarations.Names (Element) (1), Name); case Asis.Elements.Expression_Kind (Generic_Name) is when Asis.A_Selected_Component => if Is_Predefined (Generic_Name) then declare Selector : constant Asis.Identifier := Asis.Expressions.Selector (Generic_Name); Image : constant Asis.Program_Text := Asis.Expressions.Name_Image (Selector); begin if Is_Library_Level then Text.Append (Properties.Tools.Library_Level_Header (Asis.Elements.Enclosing_Compilation_Unit (Element))); Text.Append ("return "); end if; if Inside_Package then Text.Append ("_ec."); else Text.Append ("var "); end if; Text.Append (Named); Text.Append ("= _ec._"); Named := League.Strings.From_UTF_16_Wide_String (Image); Named := Named.To_Lowercase; Text.Append (Named); Text.Append ("(_ec);"); return Text; end; end if; when others => null; end case; if Is_Library_Level then Text.Append (Properties.Tools.Library_Level_Header (Asis.Elements.Enclosing_Compilation_Unit (Element))); Text.Append ("return "); end if; if not Inside_Package then Text.Append ("var "); Text.Append (Named); Text.Append ("="); end if; Down := Engine.Text.Get_Property (Spec, Name); Text.Append (Down); if Is_Library_Level then Text.Append ("});"); end if; return Text; end Code; ------------------- -- Is_Predefined -- ------------------- function Is_Predefined (Name : Asis.Expression) return Boolean is Selector : constant Asis.Identifier := Asis.Expressions.Selector (Name); Image : constant Asis.Program_Text := Asis.Expressions.Name_Image (Selector); begin return Image = "Generic_Elementary_Functions" or else Image = "Address_To_Access_Conversions" or else Image = "Unchecked_Deallocation" or else Image = "Generic_Holders"; -- Matreshka Generic_Holders end Is_Predefined; end Properties.Declarations.Package_Instantiation;
charlie5/lace
Ada
440
ads
with openGL.Buffer.general; package openGL.Buffer.short_indices is new openGL.Buffer.general (base_Object => Buffer.element_array_Object, Index => long_Index_t, Element => short_Index_t, Element_Array => short_Indices);
reznikmm/matreshka
Ada
3,759
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.Table_Cell_Range_Address_Attributes is pragma Preelaborate; type ODF_Table_Cell_Range_Address_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Table_Cell_Range_Address_Attribute_Access is access all ODF_Table_Cell_Range_Address_Attribute'Class with Storage_Size => 0; end ODF.DOM.Table_Cell_Range_Address_Attributes;
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.Chart_Plot_Area_Elements; package Matreshka.ODF_Chart.Plot_Area_Elements is type Chart_Plot_Area_Element_Node is new Matreshka.ODF_Chart.Abstract_Chart_Element_Node and ODF.DOM.Chart_Plot_Area_Elements.ODF_Chart_Plot_Area with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters) return Chart_Plot_Area_Element_Node; overriding function Get_Local_Name (Self : not null access constant Chart_Plot_Area_Element_Node) return League.Strings.Universal_String; overriding procedure Enter_Node (Self : not null access Chart_Plot_Area_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 Chart_Plot_Area_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 Chart_Plot_Area_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_Chart.Plot_Area_Elements;
vikasbidhuri1995/DW1000
Ada
6,237
adb
------------------------------------------------------------------------------- -- Copyright (c) 2016 Daniel King -- -- 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.Real_Time; use Ada.Real_Time; with DecaDriver; use DecaDriver; with DW1000.BSP; with DW1000.Driver; use DW1000.Driver; with DW1000.System_Time; use DW1000.System_Time; with DW1000.Types; with Tx_Power; -- This example continuously waits for a packet to be received, and then -- re-transmits the received packet after a 500 ms delay. procedure Echo_Example with SPARK_Mode, Global => (Input => Ada.Real_Time.Clock_Time, In_Out => (DW1000.BSP.Device_State, DecaDriver.Driver, DecaDriver.Tx_Complete_Flag)), Depends => (DecaDriver.Driver =>+ (DW1000.BSP.Device_State, DecaDriver.Driver), DW1000.BSP.Device_State =>+ (DecaDriver.Driver), DecaDriver.Tx_Complete_Flag =>+ (DecaDriver.Driver, DW1000.BSP.Device_State), null => Ada.Real_Time.Clock_Time) is Rx_Packet : DW1000.Types.Byte_Array (1 .. 127) := (others => 0); Rx_Packet_Length : DecaDriver.Frame_Length_Number; Rx_Frame_Info : DecaDriver.Frame_Info_Type; Rx_Status : DecaDriver.Rx_Status_Type; Rx_Overrun : Boolean; Rx_Timestamp : DW1000.System_Time.Fine_System_Time; Tx_Timestamp : DW1000.System_Time.Fine_System_Time; Tx_Result : DW1000.Driver.Result_Type; begin -- Driver must be initialized once before it is used. DecaDriver.Driver.Initialize (Load_Antenna_Delay => True, Load_XTAL_Trim => True, Load_UCode_From_ROM => True); -- Configure the DW1000 DecaDriver.Driver.Configure (DecaDriver.Configuration_Type' (Channel => 1, PRF => PRF_64MHz, Tx_Preamble_Length => PLEN_1024, Rx_PAC => PAC_8, Tx_Preamble_Code => 9, Rx_Preamble_Code => 9, Use_Nonstandard_SFD => False, Data_Rate => Data_Rate_110k, PHR_Mode => Standard_Frames, SFD_Timeout => 1024 + 64 + 1)); -- Configure the transmit power for the PRF and channel chosen. -- We use the reference values for the EVB1000 in this example. DW1000.Driver.Configure_Tx_Power (Tx_Power.Manual_Tx_Power_Table (1, PRF_64MHz)); -- Enable the LEDs controlled by the DW1000. DW1000.Driver.Configure_LEDs (Tx_LED_Enable => True, -- Enable transmit LED Rx_LED_Enable => True, -- Enable receive LED Rx_OK_LED_Enable => False, SFD_LED_Enable => False, Test_Flash => True); -- Flash both LEDs once -- In this example we only want to receive valid packets without errors, -- so configure the DW1000 to automatically re-enable the receiver when -- errors occur. The driver will not be notified of receiver errors whilst -- this is enabled. DW1000.Driver.Set_Auto_Rx_Reenable (Enable => True); DecaDriver.Driver.Start_Rx_Immediate; -- Continuously receive packets, and echo them back after a 500 ms delay. loop DecaDriver.Driver.Rx_Wait (Frame => Rx_Packet, Length => Rx_Packet_Length, Frame_Info => Rx_Frame_Info, Status => Rx_Status, Overrun => Rx_Overrun); if Rx_Status = No_Error then -- Limit frame length Rx_Packet_Length := Frame_Length_Number'Min (Rx_Packet_Length, Rx_Packet'Length); -- Get the timestamp at which the packet was received. Rx_Timestamp := DecaDriver.Receive_Timestamp (Rx_Frame_Info); -- We want to send the packet 0.5 seconds after it was received. Tx_Timestamp := System_Time_Offset (Rx_Timestamp, 0.5); -- Configure the transmitter to transmit the packet -- at the delayed time. DW1000.Driver.Set_Delayed_Tx_Rx_Time (Coarse_System_Time (Tx_Timestamp)); -- Load the packet into the transmitter DW1000.Driver.Set_Tx_Data (Data => Rx_Packet (1 .. Rx_Packet_Length), Offset => 0); -- Tell the driver the length of the packet and its position in the -- transmit buffer. DW1000.Driver.Set_Tx_Frame_Length (Length => Rx_Packet_Length, Offset => 0); -- Transmit the delayed packet, and enable the receiver after the -- packet is sent. DecaDriver.Driver.Start_Tx_Delayed (Rx_After_Tx => True, Result => Tx_Result); -- If the target transmit time has already passed (e.g. because we -- took too long to configure the transmitter, etc...) then don't -- transmit and just wait for another packet if Tx_Result /= Success then DecaDriver.Driver.Start_Rx_Immediate; end if; end if; end loop; end Echo_Example;
io7m/coreland-sdl-ada
Ada
3,207
ads
with Interfaces.C; with System; package SDL is package C renames Interfaces.C; -- integer types type Int8_t is range -16#7f# .. 16#7f#; type Int16_t is range -16#7fff# .. 16#7fff#; type Int32_t is range -16#7fffffff# .. 16#7fffffff#; type Uint8_t is mod 2 ** 8; type Uint16_t is mod 2 ** 16; type Uint32_t is mod 2 ** 32; for Int8_t'Size use 8; for Int16_t'Size use 16; for Int32_t'Size use 32; for Uint8_t'Size use 8; for Uint16_t'Size use 16; for Uint32_t'Size use 32; type Int_Ptr_t is access all C.int; type Int8_Ptr_t is access all Int8_t; type Int16_Ptr_t is access all Int16_t; type Int32_Ptr_t is access all Int32_t; type Uint8_Ptr_t is access all Uint8_t; type Uint16_Ptr_t is access all Uint16_t; type Uint32_Ptr_t is access all Uint32_t; pragma Convention (C, Int_Ptr_t); pragma Convention (C, Int8_t); pragma Convention (C, Int16_t); pragma Convention (C, Int32_t); pragma Convention (C, Uint8_t); pragma Convention (C, Uint16_t); pragma Convention (C, Uint32_t); pragma Convention (C, Int8_Ptr_t); pragma Convention (C, Int16_Ptr_t); pragma Convention (C, Int32_Ptr_t); pragma Convention (C, Uint8_Ptr_t); pragma Convention (C, Uint16_Ptr_t); pragma Convention (C, Uint32_Ptr_t); -- Pointer types type Void_Ptr_t is new System.Address; -- bitfield type Init_Flags_t is new Uint32_t; pragma Convention (C, Init_Flags_t); Init_Timer : constant Init_Flags_t := 16#00000001#; Init_Audio : constant Init_Flags_t := 16#00000010#; Init_Video : constant Init_Flags_t := 16#00000020#; Init_Cdrom : constant Init_Flags_t := 16#00000100#; Init_Joystick : constant Init_Flags_t := 16#00000200#; Init_Noparachute : constant Init_Flags_t := 16#00100000#; Init_Eventthread : constant Init_Flags_t := 16#01000000#; Init_Everything : constant Init_Flags_t := 16#0000ffff#; -- Initializes SDL function Init (Flags : Init_Flags_t) return C.int; pragma Import (C, Init, "SDL_Init"); function Init (Flags : Init_Flags_t) return Boolean; pragma Inline (Init); -- Initializes subsystems function InitSubSystem (Flags : Init_Flags_t) return C.int; function Init_Sub_System (Flags : Init_Flags_t) return C.int renames InitSubSystem; pragma Import (C, InitSubSystem, "SDL_InitSubSystem"); function InitSubSystem (Flags : Init_Flags_t) return Boolean; function Init_Sub_System (Flags : Init_Flags_t) return Boolean renames InitSubSystem; pragma Inline (InitSubSystem); -- Shuts down a subsystem procedure QuitSubSystem (Flags : Init_Flags_t); procedure Quit_Sub_System (Flags : Init_Flags_t) renames QuitSubSystem; pragma Import (C, QuitSubSystem, "SDL_QuitSubSystem"); -- Checks which subsystems are initialized function WasInit (Flags : Init_Flags_t) return Init_Flags_t; function Was_Init (Flags : Init_Flags_t) return Init_Flags_t renames WasInit; pragma Import (C, WasInit, "SDL_WasInit"); function WasInit (Flags : Init_Flags_t) return Boolean; function Was_Init (Flags : Init_Flags_t) return Boolean renames WasInit; pragma Inline (WasInit); -- Shuts down SDL procedure Quit; pragma Import (C, Quit, "SDL_Quit"); end SDL;
reznikmm/matreshka
Ada
4,363
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Web Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014-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$ ------------------------------------------------------------------------------ -- A servlet configuration object used by a servlet container to pass -- information to a servlet during initialization. ------------------------------------------------------------------------------ with League.Strings; with Servlet.Contexts; package Servlet.Configs is pragma Preelaborate; type Servlet_Config is limited interface; not overriding function Get_Servlet_Name (Self : Servlet_Config) return League.Strings.Universal_String is abstract; -- Returns the name of this servlet instance. The name may be provided via -- server administration, assigned in the web application deployment -- descriptor, or for an unregistered (and thus unnamed) servlet instance -- it will be the servlet's class name. not overriding function Get_Servlet_Context (Self : Servlet_Config) return not null access Servlet.Contexts.Servlet_Context'Class is abstract; -- Returns a reference to the ServletContext in which the caller is -- executing. end Servlet.Configs;
HackInvent/Ada_Drivers_Library
Ada
4,874
ads
-- This spec has been automatically generated from STM32H7x3.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; pragma Style_Checks (Off); with System; package STM32_SVD.PF is pragma Preelaborate; --------------- -- Registers -- --------------- -- CLIDR_CL array element subtype CLIDR_CL_Element is STM32_SVD.UInt3; -- CLIDR_CL array type CLIDR_CL_Field_Array is array (1 .. 7) of CLIDR_CL_Element with Component_Size => 3, Size => 21; -- Type definition for CLIDR_CL type CLIDR_CL_Field (As_Array : Boolean := False) is record case As_Array is when False => -- CL as a value Val : STM32_SVD.UInt21; when True => -- CL as an array Arr : CLIDR_CL_Field_Array; end case; end record with Unchecked_Union, Size => 21; for CLIDR_CL_Field use record Val at 0 range 0 .. 20; Arr at 0 range 0 .. 20; end record; subtype CLIDR_LoUIS_Field is STM32_SVD.UInt3; subtype CLIDR_LoC_Field is STM32_SVD.UInt3; subtype CLIDR_LoU_Field is STM32_SVD.UInt3; -- Cache Level ID register type CLIDR_Register is record -- Read-only. CL1 CL : CLIDR_CL_Field; -- Read-only. LoUIS LoUIS : CLIDR_LoUIS_Field; -- Read-only. LoC LoC : CLIDR_LoC_Field; -- Read-only. LoU LoU : CLIDR_LoU_Field; -- unspecified Reserved_30_31 : STM32_SVD.UInt2; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for CLIDR_Register use record CL at 0 range 0 .. 20; LoUIS at 0 range 21 .. 23; LoC at 0 range 24 .. 26; LoU at 0 range 27 .. 29; Reserved_30_31 at 0 range 30 .. 31; end record; subtype CTR_IminLine_Field is STM32_SVD.UInt4; subtype CTR_DMinLine_Field is STM32_SVD.UInt4; subtype CTR_ERG_Field is STM32_SVD.UInt4; subtype CTR_CWG_Field is STM32_SVD.UInt4; subtype CTR_Format_Field is STM32_SVD.UInt3; -- Cache Type register type CTR_Register is record -- Read-only. IminLine IminLine : CTR_IminLine_Field; -- unspecified Reserved_4_15 : STM32_SVD.UInt12; -- Read-only. DMinLine DMinLine : CTR_DMinLine_Field; -- Read-only. ERG ERG : CTR_ERG_Field; -- Read-only. CWG CWG : CTR_CWG_Field; -- unspecified Reserved_28_28 : STM32_SVD.Bit; -- Read-only. Format Format : CTR_Format_Field; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for CTR_Register use record IminLine at 0 range 0 .. 3; Reserved_4_15 at 0 range 4 .. 15; DMinLine at 0 range 16 .. 19; ERG at 0 range 20 .. 23; CWG at 0 range 24 .. 27; Reserved_28_28 at 0 range 28 .. 28; Format at 0 range 29 .. 31; end record; subtype CCSIDR_LineSize_Field is STM32_SVD.UInt3; subtype CCSIDR_Associativity_Field is STM32_SVD.UInt10; subtype CCSIDR_NumSets_Field is STM32_SVD.UInt15; -- Cache Size ID register type CCSIDR_Register is record -- Read-only. LineSize LineSize : CCSIDR_LineSize_Field; -- Read-only. Associativity Associativity : CCSIDR_Associativity_Field; -- Read-only. NumSets NumSets : CCSIDR_NumSets_Field; -- Read-only. WA WA : Boolean; -- Read-only. RA RA : Boolean; -- Read-only. WB WB : Boolean; -- Read-only. WT WT : Boolean; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for CCSIDR_Register use record LineSize at 0 range 0 .. 2; Associativity at 0 range 3 .. 12; NumSets at 0 range 13 .. 27; WA at 0 range 28 .. 28; RA at 0 range 29 .. 29; WB at 0 range 30 .. 30; WT at 0 range 31 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- Processor features type PF_Peripheral is record -- Cache Level ID register CLIDR : aliased CLIDR_Register; -- Cache Type register CTR : aliased CTR_Register; -- Cache Size ID register CCSIDR : aliased CCSIDR_Register; end record with Volatile; for PF_Peripheral use record CLIDR at 16#0# range 0 .. 31; CTR at 16#4# range 0 .. 31; CCSIDR at 16#8# range 0 .. 31; end record; -- Processor features PF_Periph : aliased PF_Peripheral with Import, Address => PF_Base; end STM32_SVD.PF;
xeenta/learning-ada
Ada
2,219
adb
with Ada.Text_IO; use Ada.Text_IO; with Ada.Float_Text_IO; use Ada.Float_Text_IO; procedure Steps_7 is task Bank is entry Put_Amount (Amount : in Float); entry Get_Amount (Amount : in Float); entry Give_Bonus (Amount : in Float); end Bank; task body Bank is Fee : constant Float := 2.0; Debt_Limit : constant Float := 1000.0; Money : Float := 0.0; begin loop select when Money > 0.0 => accept Get_Amount (Amount : in Float) do if Money - Amount < -Debt_Limit + Fee then Put ("BANK: No debts greater than "); Put (Debt_Limit, Aft => 2, Exp => 0); New_Line; else Money := Money - Amount - 2.0; Put ("BANK: Withdrawing "); Put (Amount, Aft => 2, Exp => 0); New_Line; Put ("BANK: Current deposit: "); Put (Money, Aft => 2, Exp => 0); New_Line; end if; end Get_Amount; or when Money < 0.0 => accept Give_Bonus (Amount : in Float) do requeue Put_Amount; end Give_Bonus; or accept Put_Amount (Amount : in Float) do Put ("BANK: Deposit "); Put (Amount, Aft => 2, Exp => 0); New_Line; Money := Money + Amount; Put ("BANK: Current deposit: "); Put (Money, Aft => 2, Exp => 0); New_Line; end Put_Amount; end select; end loop; end Bank; task Bonus; task body Bonus is Bonus_Amount : constant Float := 200.0; begin loop -- Put_Line ("Checking for need"); delay 5.0; Bank.Give_Bonus (Bonus_Amount); Put ("STATE: We helped the bank^H^H^H^H you with a bonus of "); Put (Bonus_Amount, Aft => 2, Exp => 0); New_Line; end loop; end Bonus; begin Bank.Put_Amount (120.0); Bank.Get_Amount (125.0); Put_Line ("We need more money, but we must wait for the bonus"); Bank.Get_Amount (50.0); end;
zhmu/ananas
Ada
529
ads
with System; package Init10 is type My_Integer is new Integer; for My_Integer'Alignment use 1; type R1 is record I : My_Integer; end record; for R1'Bit_Order use System.Low_Order_First; for R1'Scalar_Storage_Order use System.Low_Order_First; type R2 is record I : My_Integer; end record; for R2'Bit_Order use System.High_Order_First; for R2'Scalar_Storage_Order use System.High_Order_First; My_R1 : constant R1 := (I => 16#12345678#); My_R2 : constant R2 := (I => 16#12345678#); end Init10;
Intelligente-sanntidssystemer/Ada-prosjekt
Ada
1,286
adb
with NRF52_DK.Time; use NRF52_DK.Time; with HAL; use HAL; package body sensor is function Distance(TrigPin, EchoPin : NRF52_DK.IOs.Pin_Id) return Float is TimeNow : Time_Ms; --Maximum distance of sensor is 400cm = 23200uS. We add a 1ms margin on top of that DeadlineMicroseconds : constant Integer := 5800; Duration_Result : Time_Ms; Pulse : Boolean; DistanceLimit : constant Float := 100.0; begin TimeNow := NRF52_DK.Time.Clock; NRF52_DK.IOs.Set(TrigPin, False); NRF52_DK.Time.Delay_Ms(UInt64 (2 / 1000)); NRF52_DK.IOs.Set(TrigPin, True); NRF52_DK.Time.Delay_Ms (UInt64 (2 / 1000)); NRF52_DK.IOs.Set(TrigPin, False); --There must be no interrupts between these parts. Pulse := NRF52_DK.IOs.Set(EchoPin); while Pulse = NRF52_DK.IOs.Set(EchoPin) loop --Wait for the analog signal to change from low - high or high - low null; end loop; Duration_Result := (NRF52_DK.Time.Clock - TimeNow); return (Float(Duration_Result) / 58.0) * 1000000.0; -- https://github.com/gamegine/HCSR04-ultrasonic-sensor-lib/blob/master/src/HCSR04.cpp return -1.0; --Something went wrong if we end up here! end Distance; end sensor;
reznikmm/matreshka
Ada
4,600
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_Style.Scale_To_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Style_Scale_To_Attribute_Node is begin return Self : Style_Scale_To_Attribute_Node do Matreshka.ODF_Style.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Style_Prefix); end return; end Create; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Style_Scale_To_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Scale_To_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Style_URI, Matreshka.ODF_String_Constants.Scale_To_Attribute, Style_Scale_To_Attribute_Node'Tag); end Matreshka.ODF_Style.Scale_To_Attributes;
reznikmm/matreshka
Ada
3,744
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.Number_Decimal_Places_Attributes is pragma Preelaborate; type ODF_Number_Decimal_Places_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Number_Decimal_Places_Attribute_Access is access all ODF_Number_Decimal_Places_Attribute'Class with Storage_Size => 0; end ODF.DOM.Number_Decimal_Places_Attributes;
onox/orka
Ada
14,089
ads
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2016 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. with GL.Objects.Buffers; with GL.Types.Indirect; with Orka.Types; package Orka.Rendering.Buffers is pragma Preelaborate; subtype Storage_Bits is GL.Objects.Buffers.Storage_Bits; use GL.Types; use all type Orka.Types.Element_Type; ----------------------------------------------------------------------------- type Bindable_Buffer is interface; type Indexed_Buffer_Target is (Shader_Storage, Uniform); -- Buffer targets that can be read/written in shaders type Buffer_Target is (Index, Dispatch_Indirect, Draw_Indirect, Parameter, Pixel_Pack, Pixel_Unpack, Query); procedure Bind (Object : Bindable_Buffer; Target : Indexed_Buffer_Target; Index : Natural) is abstract; -- Bind the buffer object to the binding point at the given index of -- the target procedure Bind (Object : Bindable_Buffer; Target : Buffer_Target) is abstract; -- Bind the buffer object to the target function Length (Object : Bindable_Buffer) return Positive is abstract; ----------------------------------------------------------------------------- type Buffer (Kind : Types.Element_Type) is new Bindable_Buffer with private; overriding function "=" (Left, Right : Buffer) return Boolean; function Create_Buffer (Flags : Storage_Bits; Kind : Types.Element_Type; Length : Positive) return Buffer with Post => Create_Buffer'Result.Length = Length; ----------------------------------------------------------------------------- function Create_Buffer (Flags : Storage_Bits; Data : Float_16_Array) return Buffer with Post => Create_Buffer'Result.Length = Data'Length; function Create_Buffer (Flags : Storage_Bits; Data : Float_32_Array) return Buffer with Post => Create_Buffer'Result.Length = Data'Length; function Create_Buffer (Flags : Storage_Bits; Data : Float_64_Array) return Buffer with Post => Create_Buffer'Result.Length = Data'Length; function Create_Buffer (Flags : Storage_Bits; Data : Integer_8_Array) return Buffer with Post => Create_Buffer'Result.Length = Data'Length; function Create_Buffer (Flags : Storage_Bits; Data : Integer_16_Array) return Buffer with Post => Create_Buffer'Result.Length = Data'Length; function Create_Buffer (Flags : Storage_Bits; Data : Integer_32_Array) return Buffer with Post => Create_Buffer'Result.Length = Data'Length; function Create_Buffer (Flags : Storage_Bits; Data : Unsigned_8_Array) return Buffer with Post => Create_Buffer'Result.Length = Data'Length; function Create_Buffer (Flags : Storage_Bits; Data : Unsigned_16_Array) return Buffer with Post => Create_Buffer'Result.Length = Data'Length; function Create_Buffer (Flags : Storage_Bits; Data : Unsigned_32_Array) return Buffer with Post => Create_Buffer'Result.Length = Data'Length; function Create_Buffer (Flags : Storage_Bits; Data : Orka.Types.Singles.Vector4_Array) return Buffer with Post => Create_Buffer'Result.Length = Data'Length; function Create_Buffer (Flags : Storage_Bits; Data : Orka.Types.Singles.Matrix4_Array) return Buffer with Post => Create_Buffer'Result.Length = Data'Length; function Create_Buffer (Flags : Storage_Bits; Data : Orka.Types.Doubles.Vector4_Array) return Buffer with Post => Create_Buffer'Result.Length = Data'Length; function Create_Buffer (Flags : Storage_Bits; Data : Orka.Types.Doubles.Matrix4_Array) return Buffer with Post => Create_Buffer'Result.Length = Data'Length; function Create_Buffer (Flags : Storage_Bits; Data : Indirect.Arrays_Indirect_Command_Array) return Buffer with Post => Create_Buffer'Result.Length = Data'Length; function Create_Buffer (Flags : Storage_Bits; Data : Indirect.Elements_Indirect_Command_Array) return Buffer with Post => Create_Buffer'Result.Length = Data'Length; function Create_Buffer (Flags : Storage_Bits; Data : Indirect.Dispatch_Indirect_Command_Array) return Buffer with Post => Create_Buffer'Result.Length = Data'Length; ----------------------------------------------------------------------------- overriding function Length (Object : Buffer) return Positive with Inline; overriding procedure Bind (Object : Buffer; Target : Indexed_Buffer_Target; Index : Natural); -- Bind the buffer object to the binding point at the given index of -- the target overriding procedure Bind (Object : Buffer; Target : Buffer_Target); -- Bind the buffer object to the target ----------------------------------------------------------------------------- procedure Set_Data (Object : Buffer; Data : Float_16_Array; Offset : Natural := 0) with Pre => Object.Kind = Half_Type and Offset + Data'Length <= Object.Length; procedure Set_Data (Object : Buffer; Data : Float_32_Array; Offset : Natural := 0) with Pre => Object.Kind = Single_Type and Offset + Data'Length <= Object.Length; procedure Set_Data (Object : Buffer; Data : Float_64_Array; Offset : Natural := 0) with Pre => Object.Kind = Double_Type and Offset + Data'Length <= Object.Length; procedure Set_Data (Object : Buffer; Data : Integer_8_Array; Offset : Natural := 0) with Pre => Object.Kind = Byte_Type and Offset + Data'Length <= Object.Length; procedure Set_Data (Object : Buffer; Data : Integer_16_Array; Offset : Natural := 0) with Pre => Object.Kind = Short_Type and Offset + Data'Length <= Object.Length; procedure Set_Data (Object : Buffer; Data : Integer_32_Array; Offset : Natural := 0) with Pre => Object.Kind = Int_Type and Offset + Data'Length <= Object.Length; procedure Set_Data (Object : Buffer; Data : Unsigned_8_Array; Offset : Natural := 0) with Pre => Object.Kind = UByte_Type and Offset + Data'Length <= Object.Length; procedure Set_Data (Object : Buffer; Data : Unsigned_16_Array; Offset : Natural := 0) with Pre => Object.Kind = UShort_Type and Offset + Data'Length <= Object.Length; procedure Set_Data (Object : Buffer; Data : Unsigned_32_Array; Offset : Natural := 0) with Pre => Object.Kind = UInt_Type and Offset + Data'Length <= Object.Length; procedure Set_Data (Object : Buffer; Data : Orka.Types.Singles.Vector4_Array; Offset : Natural := 0) with Pre => Object.Kind = Single_Vector_Type and Offset + Data'Length <= Object.Length; procedure Set_Data (Object : Buffer; Data : Orka.Types.Singles.Matrix4_Array; Offset : Natural := 0) with Pre => Object.Kind = Single_Matrix_Type and Offset + Data'Length <= Object.Length; procedure Set_Data (Object : Buffer; Data : Orka.Types.Doubles.Vector4_Array; Offset : Natural := 0) with Pre => Object.Kind = Double_Vector_Type and Offset + Data'Length <= Object.Length; procedure Set_Data (Object : Buffer; Data : Orka.Types.Doubles.Matrix4_Array; Offset : Natural := 0) with Pre => Object.Kind = Double_Matrix_Type and Offset + Data'Length <= Object.Length; procedure Set_Data (Object : Buffer; Data : Indirect.Arrays_Indirect_Command_Array; Offset : Natural := 0) with Pre => Object.Kind = Arrays_Command_Type and Offset + Data'Length <= Object.Length; procedure Set_Data (Object : Buffer; Data : Indirect.Elements_Indirect_Command_Array; Offset : Natural := 0) with Pre => Object.Kind = Elements_Command_Type and Offset + Data'Length <= Object.Length; procedure Set_Data (Object : Buffer; Data : Indirect.Dispatch_Indirect_Command_Array; Offset : Natural := 0) with Pre => Object.Kind = Dispatch_Command_Type and Offset + Data'Length <= Object.Length; ----------------------------------------------------------------------------- procedure Get_Data (Object : Buffer; Data : in out Float_16_Array; Offset : Natural := 0) with Pre => Object.Kind = Half_Type and Offset + Data'Length <= Object.Length; procedure Get_Data (Object : Buffer; Data : in out Float_32_Array; Offset : Natural := 0) with Pre => Object.Kind = Single_Type and Offset + Data'Length <= Object.Length; procedure Get_Data (Object : Buffer; Data : in out Float_64_Array; Offset : Natural := 0) with Pre => Object.Kind = Double_Type and Offset + Data'Length <= Object.Length; procedure Get_Data (Object : Buffer; Data : in out Integer_8_Array; Offset : Natural := 0) with Pre => Object.Kind = Byte_Type and Offset + Data'Length <= Object.Length; procedure Get_Data (Object : Buffer; Data : in out Integer_16_Array; Offset : Natural := 0) with Pre => Object.Kind = Int_Type and Offset + Data'Length <= Object.Length; procedure Get_Data (Object : Buffer; Data : in out Integer_32_Array; Offset : Natural := 0) with Pre => Object.Kind = Int_Type and Offset + Data'Length <= Object.Length; procedure Get_Data (Object : Buffer; Data : in out Unsigned_8_Array; Offset : Natural := 0) with Pre => Object.Kind = UByte_Type and Offset + Data'Length <= Object.Length; procedure Get_Data (Object : Buffer; Data : in out Unsigned_16_Array; Offset : Natural := 0) with Pre => Object.Kind = UShort_Type and Offset + Data'Length <= Object.Length; procedure Get_Data (Object : Buffer; Data : in out Unsigned_32_Array; Offset : Natural := 0) with Pre => Object.Kind = UInt_Type and Offset + Data'Length <= Object.Length; ----------------------------------------------------------------------------- procedure Get_Data (Object : Buffer; Data : in out Orka.Types.Singles.Vector4_Array; Offset : Natural := 0) with Pre => Object.Kind = Single_Vector_Type and Offset + Data'Length <= Object.Length; procedure Get_Data (Object : Buffer; Data : in out Orka.Types.Singles.Matrix4_Array; Offset : Natural := 0) with Pre => Object.Kind = Single_Matrix_Type and Offset + Data'Length <= Object.Length; procedure Get_Data (Object : Buffer; Data : in out Orka.Types.Doubles.Vector4_Array; Offset : Natural := 0) with Pre => Object.Kind = Double_Vector_Type and Offset + Data'Length <= Object.Length; procedure Get_Data (Object : Buffer; Data : in out Orka.Types.Doubles.Matrix4_Array; Offset : Natural := 0) with Pre => Object.Kind = Double_Matrix_Type and Offset + Data'Length <= Object.Length; ----------------------------------------------------------------------------- procedure Clear_Data (Object : Buffer; Data : Integer_8_Array) with Pre => Object.Kind = Byte_Type and Data'Length in 1 .. 4 and Object.Length mod Data'Length = 0; procedure Clear_Data (Object : Buffer; Data : Integer_16_Array) with Pre => Object.Kind = Short_Type and Data'Length in 1 .. 4 and Object.Length mod Data'Length = 0; procedure Clear_Data (Object : Buffer; Data : Integer_32_Array) with Pre => Object.Kind = Int_Type and Data'Length in 1 .. 4 and Object.Length mod Data'Length = 0; procedure Clear_Data (Object : Buffer; Data : Unsigned_8_Array) with Pre => Object.Kind = UByte_Type and Data'Length in 1 .. 4 and Object.Length mod Data'Length = 0; procedure Clear_Data (Object : Buffer; Data : Unsigned_16_Array) with Pre => Object.Kind = UShort_Type and Data'Length in 1 .. 4 and Object.Length mod Data'Length = 0; procedure Clear_Data (Object : Buffer; Data : Unsigned_32_Array) with Pre => Object.Kind = UInt_Type and Data'Length in 1 .. 4 and Object.Length mod Data'Length = 0; procedure Clear_Data (Object : Buffer; Data : Float_32_Array) with Pre => Object.Kind = Single_Type and Data'Length in 1 .. 4 and Object.Length mod Data'Length = 0; procedure Clear_Data (Object : Buffer; Data : Orka.Types.Singles.Vector4) with Pre => Object.Kind = Single_Vector_Type or else (Object.Kind = Single_Type and Object.Length mod 4 = 0); ----------------------------------------------------------------------------- procedure Copy_Data (Object : Buffer; Target : Buffer) with Pre => Object.Kind = Target.Kind and then Object.Length = Target.Length; procedure Copy_Data (Object : Buffer; Target : Buffer; Read_Offset : Natural; Write_Offset : Natural; Length : Positive) with Pre => Object.Kind = Target.Kind and then (Read_Offset + Length <= Object.Length and Write_Offset + Length <= Target.Length); private type Buffer (Kind : Types.Element_Type) is new Bindable_Buffer with record Buffer : GL.Objects.Buffers.Buffer; Length : Positive; end record; use type GL.Objects.Buffers.Buffer; overriding function "=" (Left, Right : Buffer) return Boolean is (Left.Buffer = Right.Buffer); end Orka.Rendering.Buffers;
jscparker/math_packages
Ada
7,757
ads
generic type Gauss_Index_61 is range <>; type Real is digits <>; type Gauss_Values is array (Gauss_Index_61) of Real; package Gauss_Nodes_61_bak is Gauss_Weights_61_bak : constant Gauss_Values := (0.0013890136_9867700762_4551591226_760, 0.0038904611_2709988405_1267201844_516, 0.0066307039_1593129217_3319826369_750, 0.0092732796_5951776342_8441146892_024, 0.0118230152_5349634174_2232898853_251, 0.0143697295_0704580481_2451432443_580, 0.0169208891_8905327262_7572289420_322, 0.0194141411_9394238117_3408951050_128, 0.0218280358_2160919229_7167485738_339, 0.0241911620_7808060136_5686370725_232, 0.0265099548_8233310161_0601709335_075, 0.0287540487_6504129284_3978785354_334, 0.0309072575_6238776247_2884252943_092, 0.0329814470_5748372603_1814191016_854, 0.0349793380_2806002413_7499670731_468, 0.0368823646_5182122922_3911065617_136, 0.0386789456_2472759295_0348651532_281, 0.0403745389_5153595911_1995279752_468, 0.0419698102_1516424614_7147541285_970, 0.0434525397_0135606931_6831728117_073, 0.0448148001_3316266319_2355551616_723, 0.0460592382_7100698811_6271735559_374, 0.0471855465_6929915394_5261478181_099, 0.0481858617_5708712914_0779492298_305, 0.0490554345_5502977888_7528165367_238, 0.0497956834_2707420635_7811569379_942, 0.0504059214_0278234684_0893085653_585, 0.0508817958_9874960649_2297473049_805, 0.0512215478_4925877217_0656282604_944, 0.0514261285_3745902593_3862879215_781, 0.0514947294_2945156755_8340433647_099, 0.0514261285_3745902593_3862879215_781, 0.0512215478_4925877217_0656282604_944, 0.0508817958_9874960649_2297473049_805, 0.0504059214_0278234684_0893085653_585, 0.0497956834_2707420635_7811569379_942, 0.0490554345_5502977888_7528165367_238, 0.0481858617_5708712914_0779492298_305, 0.0471855465_6929915394_5261478181_099, 0.0460592382_7100698811_6271735559_374, 0.0448148001_3316266319_2355551616_723, 0.0434525397_0135606931_6831728117_073, 0.0419698102_1516424614_7147541285_970, 0.0403745389_5153595911_1995279752_468, 0.0386789456_2472759295_0348651532_281, 0.0368823646_5182122922_3911065617_136, 0.0349793380_2806002413_7499670731_468, 0.0329814470_5748372603_1814191016_854, 0.0309072575_6238776247_2884252943_092, 0.0287540487_6504129284_3978785354_334, 0.0265099548_8233310161_0601709335_075, 0.0241911620_7808060136_5686370725_232, 0.0218280358_2160919229_7167485738_339, 0.0194141411_9394238117_3408951050_128, 0.0169208891_8905327262_7572289420_322, 0.0143697295_0704580481_2451432443_580, 0.0118230152_5349634174_2232898853_251, 0.0092732796_5951776342_8441146892_024, 0.0066307039_1593129217_3319826369_750, 0.0038904611_2709988405_1267201844_516, 0.0013890136_9867700762_4551591226_760); Gauss_Roots_61_bak : constant Gauss_Values := (-0.9994844100_5049063757_1325895705_811, -0.9968934840_7464954027_1630050918_695, -0.9916309968_7040459485_8628366109_486, -0.9836681232_7974720997_0032581605_663, -0.9731163225_0112626837_4693868423_707, -0.9600218649_6830751221_6871025581_798, -0.9443744447_4855997941_5831324037_439, -0.9262000474_2927432587_9324277080_474, -0.9055733076_9990779854_6522558925_958, -0.8825605357_9205268154_3116462530_226, -0.8572052335_4606109895_8658510658_944, -0.8295657623_8276839744_2898119732_502, -0.7997278358_2183908301_3668942322_683, -0.7677774321_0482619491_7977340974_503, -0.7337900624_5322680472_6171131369_528, -0.6978504947_9331579693_2292388026_640, -0.6600610641_2662696137_0053668149_271, -0.6205261829_8924286114_0477556431_189, -0.5793452358_2636169175_6024932172_540, -0.5366241481_4201989926_4169793311_073, -0.4924804678_6177857499_3693061207_709, -0.4470337695_3808917678_0609900322_854, -0.4004012548_3039439253_5476211542_661, -0.3527047255_3087811347_1037207089_374, -0.3040732022_7362507737_2677107199_257, -0.2546369261_6788984643_9805129817_805, -0.2045251166_8230989143_8957671002_025, -0.1538699136_0858354696_3794672743_256, -0.1028069379_6673703014_7096751318_001, -0.0514718425_5531769583_3025213166_723, 0.0, 0.0514718425_5531769583_3025213166_723, 0.1028069379_6673703014_7096751318_001, 0.1538699136_0858354696_3794672743_256, 0.2045251166_8230989143_8957671002_025, 0.2546369261_6788984643_9805129817_805, 0.3040732022_7362507737_2677107199_257, 0.3527047255_3087811347_1037207089_374, 0.4004012548_3039439253_5476211542_661, 0.4470337695_3808917678_0609900322_854, 0.4924804678_6177857499_3693061207_709, 0.5366241481_4201989926_4169793311_073, 0.5793452358_2636169175_6024932172_540, 0.6205261829_8924286114_0477556431_189, 0.6600610641_2662696137_0053668149_271, 0.6978504947_9331579693_2292388026_640, 0.7337900624_5322680472_6171131369_528, 0.7677774321_0482619491_7977340974_503, 0.7997278358_2183908301_3668942322_683, 0.8295657623_8276839744_2898119732_502, 0.8572052335_4606109895_8658510658_944, 0.8825605357_9205268154_3116462530_226, 0.9055733076_9990779854_6522558925_958, 0.9262000474_2927432587_9324277080_474, 0.9443744447_4855997941_5831324037_439, 0.9600218649_6830751221_6871025581_798, 0.9731163225_0112626837_4693868423_707, 0.9836681232_7974720997_0032581605_663, 0.9916309968_7040459485_8628366109_486, 0.9968934840_7464954027_1630050918_695, 0.9994844100_5049063757_1325895705_811); -- The following weights are used in a 30 point gauss -- quadrature rule. Their usual purpose is to estimate the -- the error in the 61-point calculation. They are associated with -- X-axis points at index 2*I-1 = -3,-1,1,3 ... in the array -- Gauss_Roots. So its not necessary to re-evaluate the function to -- estimate error. subtype Gauss_Index_30_bak is Gauss_Index_61 range -14..15; Gauss_Weights_30_bak : constant array(Gauss_Index_30_bak) of Real := (0.0079681924_9616660561_5465883474_674, 0.0184664683_1109095914_2302131912_047, 0.0287847078_8332336934_9719179611_292, 0.0387991925_6962704959_6801936446_348, 0.0484026728_3059405290_2938140422_808, 0.0574931562_1761906648_1721689402_056, 0.0659742298_8218049512_8128515115_962, 0.0737559747_3770520626_8243850022_191, 0.0807558952_2942021535_4694938460_530, 0.0868997872_0108297980_2387530715_126, 0.0921225222_3778612871_7632707087_619, 0.0963687371_7464425963_9468626351_810, 0.0995934205_8679526706_2780282103_569, 0.1017623897_4840550459_6428952168_554, 0.1028526528_9355884034_1285636705_415, 0.1028526528_9355884034_1285636705_415, 0.1017623897_4840550459_6428952168_554, 0.0995934205_8679526706_2780282103_569, 0.0963687371_7464425963_9468626351_810, 0.0921225222_3778612871_7632707087_619, 0.0868997872_0108297980_2387530715_126, 0.0807558952_2942021535_4694938460_530, 0.0737559747_3770520626_8243850022_191, 0.0659742298_8218049512_8128515115_962, 0.0574931562_1761906648_1721689402_056, 0.0484026728_3059405290_2938140422_808, 0.0387991925_6962704959_6801936446_348, 0.0287847078_8332336934_9719179611_292, 0.0184664683_1109095914_2302131912_047, 0.0079681924_9616660561_5465883474_674); end Gauss_Nodes_61_bak;
reznikmm/matreshka
Ada
4,583
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_Form.Enctype_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Form_Enctype_Attribute_Node is begin return Self : Form_Enctype_Attribute_Node do Matreshka.ODF_Form.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Form_Prefix); end return; end Create; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Form_Enctype_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Enctype_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Form_URI, Matreshka.ODF_String_Constants.Enctype_Attribute, Form_Enctype_Attribute_Node'Tag); end Matreshka.ODF_Form.Enctype_Attributes;
ekoeppen/STM32_Generic_Ada_Drivers
Ada
4,672
adb
with Interfaces; use Interfaces; with STM32GD; with STM32_SVD; use STM32_SVD; with STM32GD.Board; use STM32GD.Board; with CBOR_Codec; with Utils; package body Host_Message is Sensor_Reading_Tag : constant Natural := 6; Voltage_Tag : constant Natural := 7; Temperature_Tag : constant Natural := 8; Humidity_Tag : constant Natural := 9; Pressure_Tag : constant Natural := 10; Lux_Tag : constant Natural := 11; UV_Index_Tag : constant Natural := 12; Motion_Tag : constant Natural := 13; Sound_Level_Tag : constant Natural := 14; CO2_Tag : constant Natural := 15; Test_Packet_Tag : constant Natural := 64; Heartbeat_Tag : constant Natural := 65; Log_Message_Tag : constant Natural := 66; Ping_Tag : constant Natural := 67; Register_Value_Tag : constant Natural := 68; Error_Message_Tag : constant Natural := 69; Modem_Message_Tag : constant Natural := 70; Modem_ID_Tag : constant Natural := 71; RF_Packet_Tag : constant Natural := 72; Mote_Info_Tag : constant Natural := 73; Revision_Tag : constant Natural := 74; Status_Cmd_Tag : constant Natural := 256; Ping_Cmd_Tag : constant Natural := 257; Reset_Cmd_Tag : constant Natural := 258; UID : STM32GD.UID_Type := STM32GD.UID; Message : array (1 .. 256) of Character; Message_Index : Natural; type Heartbeat_Range is range 0 .. 999; Heartbeat : Heartbeat_Range := Heartbeat_Range'First; procedure Write_Message (C : Unsigned_8); function Read_Message return Unsigned_8; package CBOR is new CBOR_Codec (Write => Write_Message, Read => Read_Message); procedure Start_Message is begin Message_Index := Message'First; CBOR.Encode_Tag (Modem_Message_Tag); CBOR.Encode_Array (2); CBOR.Encode_Tag (Modem_ID_Tag); CBOR.Encode_Integer (Integer (UID (1) xor UID (2) xor UID (3))); end Start_Message; procedure Write_Message (C : Unsigned_8) is H : Utils.Hex_String_Byte; begin H := Utils.To_Hex_String (C); Message (Message_Index) := H (1); Message (Message_Index + 1) := H (2); Message_Index := Message_Index + 2; end Write_Message; function Read_Message return Unsigned_8 is begin return 0; end Read_Message; procedure Send_Message is begin for I in 1 .. Message_Index - 1 loop Text_IO.Put (Message (I)); end loop; Text_IO.New_Line; end Send_Message; procedure Send_Hello is begin Start_Message; CBOR.Encode_Tag (Log_Message_Tag); CBOR.Encode_Byte_String ("Starting"); Send_Message; end Send_Hello; procedure Send_Packet (Packet: Packet_Type; Length: Unsigned_8) is begin if Length > 0 and then Length < Packet'Length then Start_Message; CBOR.Encode_Tag (RF_Packet_Tag); CBOR.Encode_Additional_Data (Integer (Length), CBOR.Byte_String); for I in 0 .. Length - 1 loop Write_Message (Packet (Packet'First + I)); end loop; Send_Message; end if; end Send_Packet; procedure Send_Heartbeat is U : Utils.Hex_String_Word; begin U := Utils.To_Hex_String (UID (1) xor UID (2) xor UID (3)); Start_Message; CBOR.Encode_Tag (Heartbeat_Tag); CBOR.Encode_Array (2); CBOR.Encode_Byte_String (U); CBOR.Encode_Integer (Integer (Heartbeat)); Send_Message; Heartbeat := Heartbeat + 1; if Heartbeat = Heartbeat_Range'Last then Heartbeat := Heartbeat_Range'First; end if; end Send_Heartbeat; procedure Send_Register (Register: Radio.Register_Type; Radio_Registers: Radio.Raw_Register_Array) is U : Utils.Hex_String_Word; begin U := Utils.To_Hex_String (UID (1) xor UID (2) xor UID (3)); Start_Message; CBOR.Encode_Tag (Register_Value_Tag); CBOR.Encode_Array (3); CBOR.Encode_Byte_String (U); CBOR.Encode_Integer (Register'Enum_Rep); CBOR.Encode_Integer (Integer (Radio_Registers (Register'Enum_Rep))); Send_Message; end Send_Register; procedure Send_Status (Radio_Registers: Radio.Raw_Register_Array) is begin Send_Register (Radio.OPMODE, Radio_Registers); Send_Register (Radio.IRQFLAGS1, Radio_Registers); Send_Register (Radio.IRQFLAGS2, Radio_Registers); end Send_Status; procedure Send_Error_Message (M : String) is begin Start_Message; CBOR.Encode_Tag (Log_Message_Tag); CBOR.Encode_Byte_String (M); Send_Message; end Send_Error_Message; end Host_Message;
zhmu/ananas
Ada
7,943
ads
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- S Y S T E M -- -- -- -- S p e c -- -- (VxWorks Version x86 for RTPs) -- -- -- -- Copyright (C) 1992-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/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ package System is pragma Pure; -- Note that we take advantage of the implementation permission to make -- this unit Pure instead of Preelaborable; see RM 13.7.1(15). In Ada -- 2005, this is Pure in any case (AI-362). pragma No_Elaboration_Code_All; -- Allow the use of that restriction in units that WITH this unit type Name is (SYSTEM_NAME_GNAT); System_Name : constant Name := SYSTEM_NAME_GNAT; -- System-Dependent Named Numbers Min_Int : constant := -2 ** (Standard'Max_Integer_Size - 1); Max_Int : constant := 2 ** (Standard'Max_Integer_Size - 1) - 1; Max_Binary_Modulus : constant := 2 ** Standard'Max_Integer_Size; Max_Nonbinary_Modulus : constant := 2 ** Integer'Size - 1; Max_Base_Digits : constant := Long_Long_Float'Digits; Max_Digits : constant := Long_Long_Float'Digits; Max_Mantissa : constant := Standard'Max_Integer_Size - 1; Fine_Delta : constant := 2.0 ** (-Max_Mantissa); Tick : constant := 1.0 / 60.0; -- Storage-related Declarations type Address is private; pragma Preelaborable_Initialization (Address); Null_Address : constant Address; Storage_Unit : constant := 8; Word_Size : constant := 32; Memory_Size : constant := 2 ** 32; -- Address comparison function "<" (Left, Right : Address) return Boolean; function "<=" (Left, Right : Address) return Boolean; function ">" (Left, Right : Address) return Boolean; function ">=" (Left, Right : Address) return Boolean; function "=" (Left, Right : Address) return Boolean; pragma Import (Intrinsic, "<"); pragma Import (Intrinsic, "<="); pragma Import (Intrinsic, ">"); pragma Import (Intrinsic, ">="); pragma Import (Intrinsic, "="); -- Other System-Dependent Declarations type Bit_Order is (High_Order_First, Low_Order_First); Default_Bit_Order : constant Bit_Order := Low_Order_First; pragma Warnings (Off, Default_Bit_Order); -- kill constant condition warning -- Priority-related Declarations (RM D.1) -- Ada priorities are mapped to VxWorks priorities using the following -- transformation: 255 - Ada Priority -- Ada priorities are used as follows: -- 256 is reserved for the VxWorks kernel -- 248 - 255 correspond to hardware interrupt levels 0 .. 7 -- 247 is a catchall default "interrupt" priority for signals, -- allowing higher priority than normal tasks, but lower than -- hardware priority levels. Protected Object ceilings can -- override these values. -- 246 is used by the Interrupt_Manager task Max_Priority : constant Positive := 245; Max_Interrupt_Priority : constant Positive := 255; subtype Any_Priority is Integer range 0 .. 255; subtype Priority is Any_Priority range 0 .. 245; subtype Interrupt_Priority is Any_Priority range 246 .. 255; Default_Priority : constant Priority := 122; private pragma Linker_Options ("--specs=vxworks-x86-link.spec"); -- Setup proper set of -L's for this configuration type Address is mod Memory_Size; Null_Address : constant Address := 0; -------------------------------------- -- System Implementation Parameters -- -------------------------------------- -- These parameters provide information about the target that is used -- by the compiler. They are in the private part of System, where they -- can be accessed using the special circuitry in the Targparm unit -- whose source should be consulted for more detailed descriptions -- of the individual switch values. Backend_Divide_Checks : constant Boolean := False; Backend_Overflow_Checks : constant Boolean := True; Command_Line_Args : constant Boolean := True; Configurable_Run_Time : constant Boolean := False; Denorm : constant Boolean := True; Duration_32_Bits : constant Boolean := False; Exit_Status_Supported : constant Boolean := True; Machine_Overflows : constant Boolean := False; Machine_Rounds : constant Boolean := True; Preallocated_Stacks : constant Boolean := False; Signed_Zeros : constant Boolean := True; Stack_Check_Default : constant Boolean := False; Stack_Check_Probes : constant Boolean := True; Stack_Check_Limits : constant Boolean := False; Support_Aggregates : constant Boolean := True; Support_Atomic_Primitives : constant Boolean := True; Support_Composite_Assign : constant Boolean := True; Support_Composite_Compare : constant Boolean := True; Support_Long_Shifts : constant Boolean := True; Always_Compatible_Rep : constant Boolean := False; Suppress_Standard_Library : constant Boolean := False; Use_Ada_Main_Program_Name : constant Boolean := False; Frontend_Exceptions : constant Boolean := False; ZCX_By_Default : constant Boolean := True; Executable_Extension : constant String := ".vxe"; end System;
reznikmm/matreshka
Ada
3,989
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.Fo_Border_Left_Attributes; package Matreshka.ODF_Fo.Border_Left_Attributes is type Fo_Border_Left_Attribute_Node is new Matreshka.ODF_Fo.Abstract_Fo_Attribute_Node and ODF.DOM.Fo_Border_Left_Attributes.ODF_Fo_Border_Left_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Fo_Border_Left_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Fo_Border_Left_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Fo.Border_Left_Attributes;
reznikmm/matreshka
Ada
4,051
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.Style_Num_Letter_Sync_Attributes; package Matreshka.ODF_Style.Num_Letter_Sync_Attributes is type Style_Num_Letter_Sync_Attribute_Node is new Matreshka.ODF_Style.Abstract_Style_Attribute_Node and ODF.DOM.Style_Num_Letter_Sync_Attributes.ODF_Style_Num_Letter_Sync_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Style_Num_Letter_Sync_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Style_Num_Letter_Sync_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Style.Num_Letter_Sync_Attributes;
stcarrez/ada-asf
Ada
2,130
ads
----------------------------------------------------------------------- -- components-widgets-progress -- Simple progress bar -- Copyright (C) 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 ASF.Components.Html; with ASF.Contexts.Faces; package ASF.Components.Widgets.Progress is VALUE_ATTR_NAME : constant String := "value"; MIN_VALUE_ATTR_NAME : constant String := "minValue"; MAX_VALUE_ATTR_NAME : constant String := "maxValue"; DIRECTION_ATTR_NAME : constant String := "direction"; type Progress_Type is delta 0.1 digits 4 range 0.0 .. 100.0; -- ------------------------------ -- UIProgressBar -- ------------------------------ -- The <b>UIProgressBar</b> component displays a simple progress bar component. type UIProgressBar is new ASF.Components.Html.UIHtmlComponent with null record; -- Get the progress value function Get_Progress (UI : in UIProgressBar; Context : in ASF.Contexts.Faces.Faces_Context'Class) return Progress_Type; -- Render the tab start. overriding procedure Encode_Begin (UI : in UIProgressBar; Context : in out ASF.Contexts.Faces.Faces_Context'Class); -- Render the tab close. overriding procedure Encode_End (UI : in UIProgressBar; Context : in out ASF.Contexts.Faces.Faces_Context'Class); end ASF.Components.Widgets.Progress;
ekoeppen/STM32_Generic_Ada_Drivers
Ada
3,317
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; with STM32GD.EXTI; 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 null; end Unlock; procedure Lock is begin null; end Lock; procedure Read (Date_Time : out Date_Time_Type) is begin null; 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; Lock; EXTI.Enable_External_Interrupt (17, EXTI.Interrupt_Rising_Edge); end Set_Alarm; procedure Clear_Alarm is ICPR : UInt32; begin ICPR := NVIC_Periph.ICPR0; ICPR := ICPR or 2 ** 3; NVIC_Periph.ICPR0 := ICPR; EXTI.Clear_External_Interrupt (17); Unlock; RTC_Periph.CRL.ALRF := 0; Lock; end Clear_Alarm; procedure Init is begin null; 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 loop STM32GD.Wait_For_Event; exit when Alarm_Triggered; end loop; Clear_Alarm; end Wait_For_Alarm; function Alarm_Triggered return Boolean is begin return RTC_Periph.CRL.ALRF = 1; end Alarm_Triggered; end STM32GD.RTC;
reznikmm/matreshka
Ada
5,262
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.CMOF.Behavioral_Features.Collections is pragma Preelaborate; package CMOF_Behavioral_Feature_Collections is new AMF.Generic_Collections (CMOF_Behavioral_Feature, CMOF_Behavioral_Feature_Access); type Set_Of_CMOF_Behavioral_Feature is new CMOF_Behavioral_Feature_Collections.Set with null record; Empty_Set_Of_CMOF_Behavioral_Feature : constant Set_Of_CMOF_Behavioral_Feature; type Ordered_Set_Of_CMOF_Behavioral_Feature is new CMOF_Behavioral_Feature_Collections.Ordered_Set with null record; Empty_Ordered_Set_Of_CMOF_Behavioral_Feature : constant Ordered_Set_Of_CMOF_Behavioral_Feature; type Bag_Of_CMOF_Behavioral_Feature is new CMOF_Behavioral_Feature_Collections.Bag with null record; Empty_Bag_Of_CMOF_Behavioral_Feature : constant Bag_Of_CMOF_Behavioral_Feature; type Sequence_Of_CMOF_Behavioral_Feature is new CMOF_Behavioral_Feature_Collections.Sequence with null record; Empty_Sequence_Of_CMOF_Behavioral_Feature : constant Sequence_Of_CMOF_Behavioral_Feature; private Empty_Set_Of_CMOF_Behavioral_Feature : constant Set_Of_CMOF_Behavioral_Feature := (CMOF_Behavioral_Feature_Collections.Set with null record); Empty_Ordered_Set_Of_CMOF_Behavioral_Feature : constant Ordered_Set_Of_CMOF_Behavioral_Feature := (CMOF_Behavioral_Feature_Collections.Ordered_Set with null record); Empty_Bag_Of_CMOF_Behavioral_Feature : constant Bag_Of_CMOF_Behavioral_Feature := (CMOF_Behavioral_Feature_Collections.Bag with null record); Empty_Sequence_Of_CMOF_Behavioral_Feature : constant Sequence_Of_CMOF_Behavioral_Feature := (CMOF_Behavioral_Feature_Collections.Sequence with null record); end AMF.CMOF.Behavioral_Features.Collections;
JeremyGrosser/clock3
Ada
6,806
ads
pragma Style_Checks (Off); -- Copyright (c) 2018 Microchip Technology Inc. -- -- SPDX-License-Identifier: Apache-2.0 -- -- 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 spec has been automatically generated from ATSAMD21G18A.svd -- and modified to fix dumb peripheral layout pragma Restrictions (No_Elaboration_Code); with HAL; with System; package SAMD21_SVD.PORT is pragma Preelaborate; --------------- -- Registers -- --------------- subtype WRCONFIG_PINMASK_Field is HAL.UInt16; subtype WRCONFIG_PMUX_Field is HAL.UInt4; -- Write Configuration type WRCONFIG_Register is record -- Write-only. Pin Mask for Multiple Pin Configuration PINMASK : WRCONFIG_PINMASK_Field := 16#0#; -- Write-only. Peripheral Multiplexer Enable PMUXEN : Boolean := False; -- Write-only. Input Enable INEN : Boolean := False; -- Write-only. Pull Enable PULLEN : Boolean := False; -- unspecified Reserved_19_21 : HAL.UInt3 := 16#0#; -- Write-only. Output Driver Strength Selection DRVSTR : Boolean := False; -- unspecified Reserved_23_23 : HAL.Bit := 16#0#; -- Write-only. Peripheral Multiplexing PMUX : WRCONFIG_PMUX_Field := 16#0#; -- Write-only. Write PMUX WRPMUX : Boolean := False; -- unspecified Reserved_29_29 : HAL.Bit := 16#0#; -- Write-only. Write PINCFG WRPINCFG : Boolean := False; -- Write-only. Half-Word Select HWSEL : Boolean := False; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for WRCONFIG_Register use record PINMASK at 0 range 0 .. 15; PMUXEN at 0 range 16 .. 16; INEN at 0 range 17 .. 17; PULLEN at 0 range 18 .. 18; Reserved_19_21 at 0 range 19 .. 21; DRVSTR at 0 range 22 .. 22; Reserved_23_23 at 0 range 23 .. 23; PMUX at 0 range 24 .. 27; WRPMUX at 0 range 28 .. 28; Reserved_29_29 at 0 range 29 .. 29; WRPINCFG at 0 range 30 .. 30; HWSEL at 0 range 31 .. 31; end record; -- Peripheral Multiplexing Even type PMUX_PMUXSelect is (-- Peripheral function A selected A, -- Peripheral function B selected B, -- Peripheral function C selected C, -- Peripheral function D selected D, -- Peripheral function E selected E, -- Peripheral function F selected F, -- Peripheral function G selected G, -- Peripheral function H selected H) with Size => 4; for PMUX_PMUXSelect use (A => 0, B => 1, C => 2, D => 3, E => 4, F => 5, G => 6, H => 7); -- Peripheral Multiplexing n - Group 0 type PMUX_Register is record -- Peripheral Multiplexing Even PMUXE : PMUX_PMUXSelect := SAMD21_SVD.PORT.A; -- Peripheral Multiplexing Odd PMUXO : PMUX_PMUXSelect := SAMD21_SVD.PORT.A; end record with Volatile_Full_Access, Object_Size => 8, Bit_Order => System.Low_Order_First; for PMUX_Register use record PMUXE at 0 range 0 .. 3; PMUXO at 0 range 4 .. 7; end record; -- Peripheral Multiplexing n - Group 0 type PMUX_Registers is array (0 .. 15) of PMUX_Register; -- Pin Configuration n - Group 0 type PINCFG_Register is record -- Peripheral Multiplexer Enable PMUXEN : Boolean := False; -- Input Enable INEN : Boolean := False; -- Pull Enable PULLEN : Boolean := False; -- unspecified Reserved_3_5 : HAL.UInt3 := 16#0#; -- Write-only. Output Driver Strength Selection DRVSTR : Boolean := False; -- unspecified Reserved_7_7 : HAL.Bit := 16#0#; end record with Volatile_Full_Access, Object_Size => 8, Bit_Order => System.Low_Order_First; for PINCFG_Register use record PMUXEN at 0 range 0 .. 0; INEN at 0 range 1 .. 1; PULLEN at 0 range 2 .. 2; Reserved_3_5 at 0 range 3 .. 5; DRVSTR at 0 range 6 .. 6; Reserved_7_7 at 0 range 7 .. 7; end record; -- Pin Configuration n - Group 0 type PINCFG_Registers is array (0 .. 31) of PINCFG_Register; ----------------- -- Peripherals -- ----------------- -- Port Module type PORT_Peripheral is record -- Data Direction DIR : aliased HAL.UInt32; -- Data Direction Clear DIRCLR : aliased HAL.UInt32; -- Data Direction Set DIRSET : aliased HAL.UInt32; -- Data Direction Toggle DIRTGL : aliased HAL.UInt32; -- Data Output Value DOUT : aliased HAL.UInt32; -- Data Output Value Clear OUTCLR : aliased HAL.UInt32; -- Data Output Value Set OUTSET : aliased HAL.UInt32; -- Data Output Value Toggle OUTTGL : aliased HAL.UInt32; -- Data Input Value DIN : aliased HAL.UInt32; -- Control CTRL : aliased HAL.UInt32; -- Write Configuration WRCONFIG : aliased WRCONFIG_Register; -- Peripheral Multiplexing n - Group 0 PMUX : aliased PMUX_Registers; -- Pin Configuration n - Group 0 PINCFG : aliased PINCFG_Registers; end record with Volatile; for PORT_Peripheral use record DIR at 16#0# range 0 .. 31; DIRCLR at 16#4# range 0 .. 31; DIRSET at 16#8# range 0 .. 31; DIRTGL at 16#C# range 0 .. 31; DOUT at 16#10# range 0 .. 31; OUTCLR at 16#14# range 0 .. 31; OUTSET at 16#18# range 0 .. 31; OUTTGL at 16#1C# range 0 .. 31; DIN at 16#20# range 0 .. 31; CTRL at 16#24# range 0 .. 31; WRCONFIG at 16#28# range 0 .. 31; PMUX at 16#30# range 0 .. 127; PINCFG at 16#40# range 0 .. 255; end record; -- Port Module PORTA_Periph : aliased PORT_Peripheral with Import, Address => PORTA_Base; PORTB_Periph : aliased PORT_Peripheral with Import, Address => PORTB_Base; end SAMD21_SVD.PORT;
AdaCore/Ada_Drivers_Library
Ada
2,613
ads
------------------------------------------------------------------------------ -- -- -- Copyright (C) 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 File_IO; use File_IO; with HAL.Bitmap; use HAL.Bitmap; package Bitmap_File_Output is procedure Write_BMP_File (File : in out File_Descriptor; Bitmap : Bitmap_Buffer'Class); end Bitmap_File_Output;
iyan22/AprendeAda
Ada
2,749
adb
with Ada.Text_Io; use Ada.Text_Io; with datos; use datos; with Ordenar_Por_Insercion, Escribir_Lista; procedure Prueba_Ordenar_Por_Insercion is -- este programa hace llamadas al subprograma ordenar_por_inserción -- para comprobar si su funcionamiento es correcto Lista1, Lista_Resultado: Lista_Enteros; begin Lista1.Numeros(1) := 1; Lista1.Cont := 1; Put_line("Caso 1: lista de un solo elemento: (1)"); Put_line(" la lista inicial es: "); Escribir_Lista(Lista1); put_line(" y la lista resultado es: "); Ordenar_Por_Insercion(Lista1, Lista_Resultado); Escribir_Lista(Lista_Resultado); New_Line(3); Put_Line("Pulsa return para continuar"); Skip_Line; New_Line(3); Lista1.Numeros(1) := 3; Lista1.Numeros(2) := 1; Lista1.Numeros(3) := 4; Lista1.Numeros(4) := 8; Lista1.Numeros(5) := 6; Lista1.Cont := 5; Put_line("Caso 2: lista no ordenada de varios elementos: (3 1 4 8 6)"); Put_line(" la lista inicial es: "); Escribir_Lista(Lista1); put_line(" y la lista resultado es: "); Ordenar_Por_Insercion(Lista1, Lista_Resultado); Escribir_Lista(Lista_Resultado); New_Line(3); Put_Line("Pulsa return para continuar"); Skip_Line; New_Line(3); Lista1.Numeros(1) := 3; Lista1.Numeros(2) := 1; Lista1.Numeros(3) := 4; Lista1.Numeros(4) := 8; Lista1.Numeros(5) := 6; Lista1.Numeros(6) := 23; Lista1.Numeros(7) := 2; Lista1.Numeros(8) := 13; Lista1.Numeros(9) := 25; Lista1.Numeros(10) := 7; Lista1.Cont := 10; Put_line("Caso 3: lista no ordenada del tope de elementos: (3 1 4 8 6 23 2 13 25 7)"); Put_line(" la lista inicial es: "); Escribir_Lista(Lista1); put_line(" y la lista resultado es: "); Ordenar_Por_Insercion(Lista1, Lista_Resultado); Escribir_Lista(Lista_Resultado); New_Line(3); Put_Line("Pulsa return para continuar"); Skip_Line; New_Line(3); Lista1.Numeros(1) := 1; Lista1.Numeros(2) := 3; Lista1.Numeros(3) := 5; Lista1.Numeros(4) := 7; Lista1.Numeros(5) := 9; Lista1.Cont := 5; Put_line("Caso 4: lista ordenada: (1 3 5 7 9)"); Put_line(" la lista inicial es: "); Escribir_Lista(Lista1); put_line(" y la lista resultado es: "); Ordenar_Por_Insercion(Lista1, Lista_Resultado); Escribir_Lista(Lista_Resultado); New_Line(3); Put_Line("Pulsa return para continuar"); Skip_Line; New_Line(3); Lista1.Cont := 0; Put_line("Caso 5: lista vacia: ()"); Put_line(" la lista inicial es: "); Escribir_Lista(Lista1); put_line(" y la lista resultado es: "); Ordenar_Por_Insercion(Lista1, Lista_Resultado); Escribir_Lista(Lista_Resultado); New_Line(3); Put_Line("Pulsa return para continuar"); Skip_Line; New_Line(3); end Prueba_Ordenar_Por_Insercion;
reznikmm/matreshka
Ada
6,960
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_Text.User_Field_Decl_Elements is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters) return Text_User_Field_Decl_Element_Node is begin return Self : Text_User_Field_Decl_Element_Node do Matreshka.ODF_Text.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Text_Prefix); end return; end Create; ---------------- -- Enter_Node -- ---------------- overriding procedure Enter_Node (Self : not null access Text_User_Field_Decl_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_Text_User_Field_Decl (ODF.DOM.Text_User_Field_Decl_Elements.ODF_Text_User_Field_Decl_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 Text_User_Field_Decl_Element_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.User_Field_Decl_Element; end Get_Local_Name; ---------------- -- Leave_Node -- ---------------- overriding procedure Leave_Node (Self : not null access Text_User_Field_Decl_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_Text_User_Field_Decl (ODF.DOM.Text_User_Field_Decl_Elements.ODF_Text_User_Field_Decl_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 Text_User_Field_Decl_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_Text_User_Field_Decl (Visitor, ODF.DOM.Text_User_Field_Decl_Elements.ODF_Text_User_Field_Decl_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.Text_URI, Matreshka.ODF_String_Constants.User_Field_Decl_Element, Text_User_Field_Decl_Element_Node'Tag); end Matreshka.ODF_Text.User_Field_Decl_Elements;
zhmu/ananas
Ada
3,227
ads
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- S Y S T E M . P A C K _ 5 7 -- -- -- -- 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. -- -- -- -- 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. -- -- -- ------------------------------------------------------------------------------ -- Handling of packed arrays with Component_Size = 57 package System.Pack_57 is pragma Preelaborate; Bits : constant := 57; type Bits_57 is mod 2 ** Bits; for Bits_57'Size use Bits; -- In all subprograms below, Rev_SSO is set True if the array has the -- non-default scalar storage order. function Get_57 (Arr : System.Address; N : Natural; Rev_SSO : Boolean) return Bits_57 with Inline; -- Arr is the address of the packed array, N is the zero-based -- subscript. This element is extracted and returned. procedure Set_57 (Arr : System.Address; N : Natural; E : Bits_57; Rev_SSO : Boolean) with Inline; -- Arr is the address of the packed array, N is the zero-based -- subscript. This element is set to the given value. end System.Pack_57;
ytomino/gnat4drake
Ada
1,129
adb
with Ada.Characters.Conversions; package body GNAT.Decode_String is procedure Decode_Wide_Character ( Input : String; Ptr : in out Natural; Result : out Wide_Character) is Item : Wide_Wide_Character; begin Decode_Wide_Wide_Character (Input, Ptr, Item); Result := Ada.Characters.Conversions.To_Wide_Character (Item); end Decode_Wide_Character; procedure Decode_Wide_Wide_Character ( Input : String; Ptr : in out Natural; Result : out Wide_Wide_Character) is begin case Encoding_Method is when System.WCh_Con.WCEM_UTF8 => Ada.Characters.Conversions.Get ( Input (Ptr .. Input'Last), Ptr, Result); -- String is UTF-8 in drake. when others => raise Program_Error; -- unimplemented end case; end Decode_Wide_Wide_Character; procedure Next_Wide_Character (Input : String; Ptr : in out Natural) is Unused : Wide_Character; begin Decode_Wide_Character (Input, Ptr, Unused); end Next_Wide_Character; end GNAT.Decode_String;
godunko/adagl
Ada
3,436
adb
------------------------------------------------------------------------------ -- -- -- Ada binding for OpenGL/WebGL -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2016-2018, 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. -- -- -- ------------------------------------------------------------------------------ package body OpenGL.Textures.Internals is ---------------------------- -- Get_WebGL_Texture -- ---------------------------- function Get_WebGL_Texture (Self : OpenGL_Texture'Class) return WebAPI.WebGL.Textures.WebGL_Texture_Access is begin return Self.Texture; end Get_WebGL_Texture; end OpenGL.Textures.Internals;
zhmu/ananas
Ada
3,227
ads
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- S Y S T E M . P A C K _ 1 3 -- -- -- -- 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. -- -- -- -- 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. -- -- -- ------------------------------------------------------------------------------ -- Handling of packed arrays with Component_Size = 13 package System.Pack_13 is pragma Preelaborate; Bits : constant := 13; type Bits_13 is mod 2 ** Bits; for Bits_13'Size use Bits; -- In all subprograms below, Rev_SSO is set True if the array has the -- non-default scalar storage order. function Get_13 (Arr : System.Address; N : Natural; Rev_SSO : Boolean) return Bits_13 with Inline; -- Arr is the address of the packed array, N is the zero-based -- subscript. This element is extracted and returned. procedure Set_13 (Arr : System.Address; N : Natural; E : Bits_13; Rev_SSO : Boolean) with Inline; -- Arr is the address of the packed array, N is the zero-based -- subscript. This element is set to the given value. end System.Pack_13;
stcarrez/sql-benchmark
Ada
907
ads
----------------------------------------------------------------------- -- tool -- Tool to reconcile the SQL benchmark results -- Copyright (C) 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. ----------------------------------------------------------------------- package Tool is pragma Pure; end Tool;
godunko/adawebui
Ada
4,156
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Web Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2018-2020, 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: 5871 $ $Date: 2018-09-22 11:55:27 +0200 (Sat, 22 Sep 2018) $ ------------------------------------------------------------------------------ package body Web.UI.Applications is Global_Instance : Application_Access; -------------------------- -- Focus_Changed_Signal -- -------------------------- not overriding function Focus_Changed_Signal (Self : in out Application) return not null access Web.UI.Widgets_Widgets_Slots.Signal'Class is begin return Self.Focus_Changed'Unchecked_Access; end Focus_Changed_Signal; ---------------- -- Initialize -- ---------------- procedure Initialize is begin Global_Instance := new Application; end Initialize; -------------- -- Instance -- -------------- function Instance return Application_Access is begin return Global_Instance; end Instance; end Web.UI.Applications;
tum-ei-rcs/StratoX
Ada
4,179
ads
------------------------------------------------------------------------------ -- -- -- SPARK LIBRARY COMPONENTS -- -- -- -- S P A R K . A R I T H M E T I C _ L E M M A S -- -- -- -- S p e c -- -- -- -- Copyright (C) 2016, AdaCore -- -- -- -- SPARK 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. SPARK 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/>. -- -- -- ------------------------------------------------------------------------------ generic type Int is range <>; package SPARK.Arithmetic_Lemmas with SPARK_Mode, Pure, Ghost is pragma Warnings (Off, "postcondition does not check the outcome of calling"); subtype Nat is Int range 0 .. Int'Last; subtype Pos is Int range 1 .. Int'Last; procedure Lemma_Div_Is_Monotonic (Val1 : Int; Val2 : Int; Denom : Pos) with Global => null, Pre => Val1 <= Val2, Post => Val1 / Denom <= Val2 / Denom; -- MANUAL PROOF procedure Lemma_Mod_Range (Arg1 : Int; Arg2 : Pos) with Global => null, Post => Arg1 mod Arg2 in 0 .. Arg2 - 1; procedure Lemma_Mod_Symmetry (Arg1 : Int; Arg2 : Int) with Global => null, Pre => Arg2 /= 0, Post => (-Arg1) mod (-Arg2) = -(Arg1 mod Arg2); -- MANUAL PROOF procedure Lemma_Mult_Is_Monotonic (Val1 : Int; Val2 : Int; Factor : Nat) with Global => null, Pre => Val1 <= Val2, Post => Val1 * Factor <= Val2 * Factor; -- MANUAL PROOF procedure Lemma_Mult_Is_Strictly_Monotonic (Val1 : Int; Val2 : Int; Factor : Pos) with Global => null, Pre => Val1 < Val2, Post => Val1 * Factor < Val2 * Factor; -- MANUAL PROOF procedure Lemma_Mult_Protect (Arg1 : Int; Arg2 : Nat; Upper_Bound : Nat) with Global => null, Pre => Arg2 = 0 or else Arg1 <= Upper_Bound / Arg2, Post => Arg1 * Arg2 <= Upper_Bound; procedure Lemma_Mult_Scale (Val : Int; Scale_Num : Nat; Scale_Denom : Pos; Res : Int) with Global => null, Pre => Scale_Num <= Scale_Denom and then Res = (Val * Scale_Num) / Scale_Denom, Post => abs (Res) <= abs (Val) and then (if Val >= 0 then Res >= 0 else Res <= 0); procedure Lemma_Mult_Then_Mod_Is_Zero (Arg1 : Int; Arg2 : Pos) with Global => null, Post => (Arg1 * Arg2) mod Arg2 = 0; end SPARK.Arithmetic_Lemmas;
pdaxrom/Kino2
Ada
3,818
ads
------------------------------------------------------------------------------ -- -- -- GNAT ncurses Binding Samples -- -- -- -- Sample.Menu_Demo.Handler -- -- -- -- S P E C -- -- -- ------------------------------------------------------------------------------ -- Copyright (c) 1998 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 -- Contact: http://www.familiepfeifer.de/Contact.aspx?Lang=en -- Version Control -- $Revision: 1.8 $ -- Binding Version 01.00 ------------------------------------------------------------------------------ with Terminal_Interface.Curses; use Terminal_Interface.Curses; with Terminal_Interface.Curses.Panels; use Terminal_Interface.Curses.Panels; with Terminal_Interface.Curses.Menus; use Terminal_Interface.Curses.Menus; generic with function My_Driver (Men : Menu; K : Key_Code; Pan : Panel) return Boolean; package Sample.Menu_Demo.Handler is procedure Drive_Me (M : in Menu; Lin : in Line_Position; Col : in Column_Position; Title : in String := ""); -- Position the menu at the given point and drive it. procedure Drive_Me (M : in Menu; Title : in String := ""); -- Center menu and drive it. end Sample.Menu_Demo.Handler;